-
Notifications
You must be signed in to change notification settings - Fork 2.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring and bug fixes in the V8 API #13754
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…the necessary refactoring
The v8 namespace was confusingly polluted with both classes that exist in the actual V8 API, as well as new classes to support Bun's specific implementation of that API. This commit moves the latter into the namespace v8::shim. It also makes a duplicate of classes with fields in the v8::shim namespace. For those classes, the v8:: version has no fields, no JSC superclass, and only implements the actual V8 API functions, while the v8::shim:: version has the inheritance and functions necessary to be allocated as a JSC object and implements helper functions to support the V8 APIs.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Refactors and bugfixes in our V8 API implementation. So far:
NewStringType::kInternalized
WTF::AtomString
.v8::Context
be aZig::GlobalObject
instead of the same thing asv8::Isolate
, which lets us access the global object with less indirection in functions that take a Contextvoid *
handle was used.v8::Isolate
an actual class containing everythingv8::Roots
used to, and deletev8::Roots
, instead of reinterpreting betweenIsolate
andRoots
v8::Roots
's only purpose was to hold values at the offsets from anIsolate
pointer that V8 expects. Now we actually store those values in theIsolate
like V8 does.EscapableHandleScope
m_
on C++ class field names for clarityv8::shim
.Local
(String
,ObjectTemplate
, etc.) now have zero fields, matching how V8's API works and making it less likely to crash by accessing a member whilethis
is the invalid pointer that we get from V8. The cell pointer stored in the handle is either a built-in type (JSString
,JSObject
) or a type inv8::shim
(v8::shim::InternalFieldObject
,v8::shim::Function
)Function::GetName
andValue::IsFunction
this
value received by native functions correct (it should be coerced to an object, or overridden byglobalThis
if null or undefined, like in JavaScript sloppy mode)How did you verify your code works?
Most of the V8 API is covered by existing tests. A couple new tests were added.