[api] Add v8::Object::GetCreationContextChecked
Using v8::Object::GetCreationContext().ToLocalChecked() causes needless binary size regression on android due to the additional call after migrating to the non-deprecated GetCreationContext API. Bug: chromium:1166077, v8:11451, v8:11165 Change-Id: Ic5e2aada4d47392c5d61b419c19b5bcdbf869f0b Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3244411 Commit-Queue: Camillo Bruni <cbruni@chromium.org> Reviewed-by: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#77563}
This commit is contained in:
parent
f2c7d3a8b4
commit
91475f958a
@ -598,6 +598,11 @@ class V8_EXPORT Object : public Value {
|
||||
Local<Context> CreationContext();
|
||||
MaybeLocal<Context> GetCreationContext();
|
||||
|
||||
/**
|
||||
* Shortcut for GetCreationContext().ToLocalChecked().
|
||||
**/
|
||||
Local<Context> GetCreationContextChecked();
|
||||
|
||||
/** Same as above, but works for Persistents */
|
||||
V8_DEPRECATE_SOON(
|
||||
"Use MaybeLocal<Context> GetCreationContext(const "
|
||||
|
@ -5024,10 +5024,17 @@ MaybeLocal<v8::Context> v8::Object::GetCreationContext() {
|
||||
if (self->GetCreationContext().ToHandle(&context)) {
|
||||
return Utils::ToLocal(context);
|
||||
}
|
||||
|
||||
return MaybeLocal<v8::Context>();
|
||||
}
|
||||
|
||||
Local<v8::Context> v8::Object::GetCreationContextChecked() {
|
||||
Local<Context> context;
|
||||
Utils::ApiCheck(GetCreationContext().ToLocal(&context),
|
||||
"v8::Object::GetCreationContextChecked",
|
||||
"No creation context available");
|
||||
return context;
|
||||
}
|
||||
|
||||
int v8::Object::GetIdentityHash() {
|
||||
i::DisallowGarbageCollection no_gc;
|
||||
auto self = Utils::OpenHandle(this);
|
||||
|
@ -19265,16 +19265,22 @@ THREADED_TEST(CreationContext) {
|
||||
Local<Context> other_context = Context::New(isolate);
|
||||
Context::Scope scope(other_context);
|
||||
CHECK(object1->GetCreationContext().ToLocalChecked() == context1);
|
||||
CHECK(object1->GetCreationContextChecked() == context1);
|
||||
CheckContextId(object1, 1);
|
||||
CHECK(func1->GetCreationContext().ToLocalChecked() == context1);
|
||||
CHECK(func1->GetCreationContextChecked() == context1);
|
||||
CheckContextId(func1, 1);
|
||||
CHECK(instance1->GetCreationContext().ToLocalChecked() == context1);
|
||||
CHECK(instance1->GetCreationContextChecked() == context1);
|
||||
CheckContextId(instance1, 1);
|
||||
CHECK(object2->GetCreationContext().ToLocalChecked() == context2);
|
||||
CHECK(object2->GetCreationContextChecked() == context2);
|
||||
CheckContextId(object2, 2);
|
||||
CHECK(func2->GetCreationContext().ToLocalChecked() == context2);
|
||||
CHECK(func2->GetCreationContextChecked() == context2);
|
||||
CheckContextId(func2, 2);
|
||||
CHECK(instance2->GetCreationContext().ToLocalChecked() == context2);
|
||||
CHECK(instance2->GetCreationContextChecked() == context2);
|
||||
CheckContextId(instance2, 2);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user