Commit c9dd6b7d authored by Nico Weber's avatar Nico Weber Committed by Commit Bot

blink: Remove kV8PrototypeTypeIndex.

The value is never read, and storing it makes context snapshot writing
nondeterministic.

A comment claims that the mere presence of the field is needed to identify
prototypes, with a link to https://bugs.webkit.org/show_bug.cgi?id=110436
The code in that patch does indeed use v8PrototypeInternalFieldcount to
identify prototypes (see CustomElementHelpers::findWrapperType in that
patch), but the corresponding code in modern blink is
V0CustomElementConstructorBuilder::HasValidPrototypeChainFor which
instead uses a pointer comparison with
script_state_->PerContextData()->PrototypeForType(type). However,
V0CustomElementConstructorBuilder::PrototypeIsValid() does check
`prototype_->InternalFieldCount()` to check if a prototype is
already registered -- so keep kV8PrototypeInternalFieldcount around
and just keep the uninitialized default value (the code only cares
about the number of fields being > 0, not about the value of the field).

TBR=peria (who lg'd this, but Gerrit lost the LG)

Bug: 870584
Change-Id: If5474f37499121047c4b0232a85435f139e5cbc0
Reviewed-on: https://chromium-review.googlesource.com/c/1292385
Commit-Queue: Nico Weber <thakis@chromium.org>
Reviewed-by: default avatarNico Weber <thakis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601464}
parent 098dfd90
...@@ -811,6 +811,7 @@ void V8DOMConfiguration::InitializeDOMInterfaceTemplate( ...@@ -811,6 +811,7 @@ void V8DOMConfiguration::InitializeDOMInterfaceTemplate(
// This is needed since bug 110436 asks WebKit to tell native-initiated // This is needed since bug 110436 asks WebKit to tell native-initiated
// prototypes from pure-JS ones. This doesn't mark kinds "root" classes // prototypes from pure-JS ones. This doesn't mark kinds "root" classes
// like Node, where setting this changes prototype chain structure. // like Node, where setting this changes prototype chain structure.
// The value of this field is not used, only the count.
prototype_template->SetInternalFieldCount(kV8PrototypeInternalFieldcount); prototype_template->SetInternalFieldCount(kV8PrototypeInternalFieldcount);
} }
} }
......
...@@ -102,11 +102,6 @@ v8::Local<v8::Function> V8ObjectConstructor::CreateInterfaceObject( ...@@ -102,11 +102,6 @@ v8::Local<v8::Function> V8ObjectConstructor::CreateInterfaceObject(
CHECK(prototype_value->IsObject()); CHECK(prototype_value->IsObject());
prototype_object = prototype_value.As<v8::Object>(); prototype_object = prototype_value.As<v8::Object>();
if (prototype_object->InternalFieldCount() ==
kV8PrototypeInternalFieldcount) {
prototype_object->SetAlignedPointerInInternalField(
kV8PrototypeTypeIndex, const_cast<WrapperTypeInfo*>(type));
}
} }
if (creation_mode == CreationMode::kInstallConditionalFeatures) { if (creation_mode == CreationMode::kInstallConditionalFeatures) {
......
...@@ -55,7 +55,8 @@ static const int kV8DOMWrapperObjectIndex = ...@@ -55,7 +55,8 @@ static const int kV8DOMWrapperObjectIndex =
static_cast<int>(gin::kEncodedValueIndex); static_cast<int>(gin::kEncodedValueIndex);
static const int kV8DefaultWrapperInternalFieldCount = static const int kV8DefaultWrapperInternalFieldCount =
static_cast<int>(gin::kNumberOfInternalFields); static_cast<int>(gin::kNumberOfInternalFields);
static const int kV8PrototypeTypeIndex = 0; // The value of the following field isn't used (only its presence), hence no
// corresponding Index constant exists for it.
static const int kV8PrototypeInternalFieldcount = 1; static const int kV8PrototypeInternalFieldcount = 1;
typedef v8::Local<v8::FunctionTemplate> ( typedef v8::Local<v8::FunctionTemplate> (
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment