[strings] Use current isolate when externalizing shared strings
v8::String::MakeExternal is currently incorrectly using the shared isolate of the shared string, which will race when setting VM state. In general the shared Isolate shouldn't be used for anything, it's an implementation detail to hold the shared heap space. Bug: v8:12007, v8:13276 Fixed: v8:13276 Change-Id: I21ec57645ed4740a4c19c51b8fa1e2928a07a0f4 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3888384 Reviewed-by: Adam Klein <adamk@chromium.org> Auto-Submit: Shu-yu Guo <syg@chromium.org> Commit-Queue: Shu-yu Guo <syg@chromium.org> Cr-Commit-Position: refs/heads/main@{#83139}
This commit is contained in:
parent
29aed83f33
commit
3868e2ceb4
@ -7055,9 +7055,16 @@ bool v8::String::MakeExternal(v8::String::ExternalStringResource* resource) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// It is safe to call GetIsolateFromWritableHeapObject because
|
||||
// SupportsExternalization already checked that the object is writable.
|
||||
i::Isolate* i_isolate = i::GetIsolateFromWritableObject(obj);
|
||||
// TODO(v8:12007): Consider adding
|
||||
// MakeExternal(Isolate*, ExternalStringResource*).
|
||||
i::Isolate* i_isolate;
|
||||
if (obj.IsShared()) {
|
||||
i_isolate = i::Isolate::Current();
|
||||
} else {
|
||||
// It is safe to call GetIsolateFromWritableHeapObject because
|
||||
// SupportsExternalization already checked that the object is writable.
|
||||
i_isolate = i::GetIsolateFromWritableObject(obj);
|
||||
}
|
||||
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
|
||||
|
||||
CHECK(resource && resource->data());
|
||||
@ -7081,9 +7088,16 @@ bool v8::String::MakeExternal(
|
||||
return false;
|
||||
}
|
||||
|
||||
// It is safe to call GetIsolateFromWritableHeapObject because
|
||||
// SupportsExternalization already checked that the object is writable.
|
||||
i::Isolate* i_isolate = i::GetIsolateFromWritableObject(obj);
|
||||
// TODO(v8:12007): Consider adding
|
||||
// MakeExternal(Isolate*, ExternalOneByteStringResource*).
|
||||
i::Isolate* i_isolate;
|
||||
if (obj.IsShared()) {
|
||||
i_isolate = i::Isolate::Current();
|
||||
} else {
|
||||
// It is safe to call GetIsolateFromWritableHeapObject because
|
||||
// SupportsExternalization already checked that the object is writable.
|
||||
i_isolate = i::GetIsolateFromWritableObject(obj);
|
||||
}
|
||||
ENTER_V8_NO_SCRIPT_NO_EXCEPTION(i_isolate);
|
||||
|
||||
CHECK(resource && resource->data());
|
||||
|
Loading…
Reference in New Issue
Block a user