diff options
Diffstat (limited to 'deps/v8/src/inspector/v8-console.cc')
-rw-r--r-- | deps/v8/src/inspector/v8-console.cc | 36 |
1 files changed, 16 insertions, 20 deletions
diff --git a/deps/v8/src/inspector/v8-console.cc b/deps/v8/src/inspector/v8-console.cc index ec7709f8c69..4fd33e346ae 100644 --- a/deps/v8/src/inspector/v8-console.cc +++ b/deps/v8/src/inspector/v8-console.cc @@ -783,15 +783,11 @@ static bool isCommandLineAPIGetter(const String16& name) { void V8Console::CommandLineAPIScope::accessorGetterCallback( v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) { - CommandLineAPIScope* scope = static_cast<CommandLineAPIScope*>( - info.Data().As<v8::External>()->Value()); - DCHECK(scope); - + CommandLineAPIScope* scope = *static_cast<CommandLineAPIScope**>( + info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data()); v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); - if (scope->m_cleanup) { - bool removed = info.Holder()->Delete(context, name).FromMaybe(false); - DCHECK(removed); - USE(removed); + if (scope == nullptr) { + USE(info.Holder()->Delete(context, name).FromMaybe(false)); return; } v8::Local<v8::Object> commandLineAPI = scope->m_commandLineAPI; @@ -815,16 +811,14 @@ void V8Console::CommandLineAPIScope::accessorGetterCallback( void V8Console::CommandLineAPIScope::accessorSetterCallback( v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) { - CommandLineAPIScope* scope = static_cast<CommandLineAPIScope*>( - info.Data().As<v8::External>()->Value()); + CommandLineAPIScope* scope = *static_cast<CommandLineAPIScope**>( + info.Data().As<v8::ArrayBuffer>()->GetBackingStore()->Data()); + if (scope == nullptr) return; v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); if (!info.Holder()->Delete(context, name).FromMaybe(false)) return; if (!info.Holder()->CreateDataProperty(context, name, value).FromMaybe(false)) return; - bool removed = - scope->m_installedMethods->Delete(context, name).FromMaybe(false); - DCHECK(removed); - USE(removed); + USE(scope->m_installedMethods->Delete(context, name).FromMaybe(false)); } V8Console::CommandLineAPIScope::CommandLineAPIScope( @@ -833,14 +827,15 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( : m_context(context), m_commandLineAPI(commandLineAPI), m_global(global), - m_installedMethods(v8::Set::New(context->GetIsolate())), - m_cleanup(false) { + m_installedMethods(v8::Set::New(context->GetIsolate())) { v8::MicrotasksScope microtasksScope(context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); v8::Local<v8::Array> names; if (!m_commandLineAPI->GetOwnPropertyNames(context).ToLocal(&names)) return; - v8::Local<v8::External> externalThis = - v8::External::New(context->GetIsolate(), this); + m_thisReference = + v8::ArrayBuffer::New(context->GetIsolate(), sizeof(CommandLineAPIScope*)); + *static_cast<CommandLineAPIScope**>( + m_thisReference->GetBackingStore()->Data()) = this; for (uint32_t i = 0; i < names->Length(); ++i) { v8::Local<v8::Value> name; if (!names->Get(context, i).ToLocal(&name) || !name->IsName()) continue; @@ -851,7 +846,7 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( ->SetAccessor(context, v8::Local<v8::Name>::Cast(name), CommandLineAPIScope::accessorGetterCallback, CommandLineAPIScope::accessorSetterCallback, - externalThis, v8::DEFAULT, v8::DontEnum, + m_thisReference, v8::DEFAULT, v8::DontEnum, v8::SideEffectType::kHasNoSideEffect) .FromMaybe(false)) { bool removed = m_installedMethods->Delete(context, name).FromMaybe(false); @@ -865,7 +860,8 @@ V8Console::CommandLineAPIScope::CommandLineAPIScope( V8Console::CommandLineAPIScope::~CommandLineAPIScope() { v8::MicrotasksScope microtasksScope(m_context->GetIsolate(), v8::MicrotasksScope::kDoNotRunMicrotasks); - m_cleanup = true; + *static_cast<CommandLineAPIScope**>( + m_thisReference->GetBackingStore()->Data()) = nullptr; v8::Local<v8::Array> names = m_installedMethods->AsArray(); for (uint32_t i = 0; i < names->Length(); ++i) { v8::Local<v8::Value> name; |