v8go icon indicating copy to clipboard operation
v8go copied to clipboard

Refactor v8go.cc to reduce heavy use of macros

Open dylanahsmith opened this issue 4 years ago • 0 comments

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_SCOPE introduces an isolate scope, but LOCAL_CONTEXT introduces the context scope
  • there are some like LOCAL_OBJECT that are so similar to LOCAL_VALUE that 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

dylanahsmith avatar Dec 16 '21 16:12 dylanahsmith