v8go
v8go copied to clipboard
Refactor v8go.cc to reduce heavy use of macros
There are a lot of macro use in v8go.cc, making the code harder to read and modify.
Specifically,
- there are a number of these macros, making it harder to just remember what a few of them do
- the macros silently introduce local variables that are used outside the macro, making it harder to follow the origin of the variables and easier to introduce naming conflicts
- the macro names aren't very consistent with naming, for instance
ISOLATE_SCOPEintroduces an isolate scope, butLOCAL_CONTEXTintroduces the context scope - there are some like
LOCAL_OBJECTthat are so similar toLOCAL_VALUEthat it just saves a line of code, which does seem worth the added cognitive overhead to understand the code.
The most important purpose for these macros seem to be making sure the entrypoint functions consistently enter a consistent group of "scopes", such as for the isolate or context. This sort of abstraction could be introduced in a similar way as the V8's scopes, using a class/struct to group together these scopes and members