-
Notifications
You must be signed in to change notification settings - Fork 29.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Original commit message: [api] allow v8::Data as internal field Previously only v8::Value can be stored as internal fields. In some cases, however, it's necessary for the embedder to tie the lifetime of a v8::Data with the lifetime of a JS object, and that v8::Data may not be a v8::Value, as it can be something returned from the V8 API. One way to keep the v8::Data alive may be to use a v8::Persistent<v8::Data> but that can easily lead to leaks. This patch changes v8::Object::GetInternalField() and v8::Object::SetInernalField() to accept v8::Data instead of just v8::Value, so that v8::Data can kept alive by a JS object in a way that the GC can be aware of to address this problem. This is a breaking change for embedders using v8::Object::GetInternalField() as it changes the return type. Since most v8::Value subtypes only support direct casts from v8::Value but not v8::Data, calls like object->GetInternalField(index).As<v8::External>() needs to be updated to cast the value to v8::Value first: object->GetInternalField(index).As<v8::Value>().As<v8::External>() Bug: v8:14120 Change-Id: I731c958d1756b9d5ee4a3e78813416cd60d1b7ca Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4707972 Reviewed-by: Michael Lippautz <[email protected]> Commit-Queue: Joyee Cheung <[email protected]> Cr-Commit-Position: refs/heads/main@{#89718} Refs: v8/v8@0aa622e
- Loading branch information
1 parent
0409cdd
commit ab06393
Showing
8 changed files
with
103 additions
and
36 deletions.
There are no files selected for viewing
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
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
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
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
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
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
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
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