| Index: src/compiler/js-global-object-specialization.cc
|
| diff --git a/src/compiler/js-global-object-specialization.cc b/src/compiler/js-global-object-specialization.cc
|
| index 497f098bafcbbd5e32255a3fcdd8b0c992fdc0c3..f9b1de0feb6206e5b89515c686670b8a235f10cf 100644
|
| --- a/src/compiler/js-global-object-specialization.cc
|
| +++ b/src/compiler/js-global-object-specialization.cc
|
| @@ -28,13 +28,11 @@ struct JSGlobalObjectSpecialization::ScriptContextTableLookupResult {
|
|
|
| JSGlobalObjectSpecialization::JSGlobalObjectSpecialization(
|
| Editor* editor, JSGraph* jsgraph, Flags flags,
|
| - Handle<JSGlobalObject> global_object, CompilationDependencies* dependencies)
|
| + MaybeHandle<Context> native_context, CompilationDependencies* dependencies)
|
| : AdvancedReducer(editor),
|
| jsgraph_(jsgraph),
|
| flags_(flags),
|
| - global_object_(global_object),
|
| - script_context_table_(
|
| - global_object->native_context()->script_context_table(), isolate()),
|
| + native_context_(native_context),
|
| dependencies_(dependencies),
|
| type_cache_(TypeCache::Get()) {}
|
|
|
| @@ -58,9 +56,13 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
|
| Node* effect = NodeProperties::GetEffectInput(node);
|
| Node* control = NodeProperties::GetControlInput(node);
|
|
|
| + // Retrieve the global object from the given {node}.
|
| + Handle<JSGlobalObject> global_object;
|
| + if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange();
|
| +
|
| // Try to lookup the name on the script context table first (lexical scoping).
|
| ScriptContextTableLookupResult result;
|
| - if (LookupInScriptContextTable(name, &result)) {
|
| + if (LookupInScriptContextTable(global_object, name, &result)) {
|
| if (result.context->is_the_hole(result.index)) return NoChange();
|
| Node* context = jsgraph()->HeapConstant(result.context);
|
| Node* value = effect = graph()->NewNode(
|
| @@ -72,7 +74,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSLoadGlobal(Node* node) {
|
|
|
| // Lookup on the global object instead. We only deal with own data
|
| // properties of the global object here (represented as PropertyCell).
|
| - LookupIterator it(global_object(), name, LookupIterator::OWN);
|
| + LookupIterator it(global_object, name, LookupIterator::OWN);
|
| if (it.state() != LookupIterator::DATA) return NoChange();
|
| Handle<PropertyCell> property_cell = it.GetPropertyCell();
|
| PropertyDetails property_details = property_cell->property_details();
|
| @@ -145,9 +147,13 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
|
| Node* effect = NodeProperties::GetEffectInput(node);
|
| Node* control = NodeProperties::GetControlInput(node);
|
|
|
| + // Retrieve the global object from the given {node}.
|
| + Handle<JSGlobalObject> global_object;
|
| + if (!GetGlobalObject(node).ToHandle(&global_object)) return NoChange();
|
| +
|
| // Try to lookup the name on the script context table first (lexical scoping).
|
| ScriptContextTableLookupResult result;
|
| - if (LookupInScriptContextTable(name, &result)) {
|
| + if (LookupInScriptContextTable(global_object, name, &result)) {
|
| if (result.context->is_the_hole(result.index)) return NoChange();
|
| if (result.immutable) return NoChange();
|
| Node* context = jsgraph()->HeapConstant(result.context);
|
| @@ -159,7 +165,7 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
|
|
|
| // Lookup on the global object instead. We only deal with own data
|
| // properties of the global object here (represented as PropertyCell).
|
| - LookupIterator it(global_object(), name, LookupIterator::OWN);
|
| + LookupIterator it(global_object, name, LookupIterator::OWN);
|
| if (it.state() != LookupIterator::DATA) return NoChange();
|
| Handle<PropertyCell> property_cell = it.GetPropertyCell();
|
| PropertyDetails property_details = property_cell->property_details();
|
| @@ -254,16 +260,27 @@ Reduction JSGlobalObjectSpecialization::ReduceJSStoreGlobal(Node* node) {
|
| }
|
|
|
|
|
| +MaybeHandle<JSGlobalObject> JSGlobalObjectSpecialization::GetGlobalObject(
|
| + Node* node) {
|
| + Node* const context = NodeProperties::GetContextInput(node);
|
| + return NodeProperties::GetSpecializationGlobalObject(context,
|
| + native_context());
|
| +}
|
| +
|
| +
|
| bool JSGlobalObjectSpecialization::LookupInScriptContextTable(
|
| - Handle<Name> name, ScriptContextTableLookupResult* result) {
|
| + Handle<JSGlobalObject> global_object, Handle<Name> name,
|
| + ScriptContextTableLookupResult* result) {
|
| if (!name->IsString()) return false;
|
| + Handle<ScriptContextTable> script_context_table(
|
| + global_object->native_context()->script_context_table(), isolate());
|
| ScriptContextTable::LookupResult lookup_result;
|
| - if (!ScriptContextTable::Lookup(script_context_table(),
|
| + if (!ScriptContextTable::Lookup(script_context_table,
|
| Handle<String>::cast(name), &lookup_result)) {
|
| return false;
|
| }
|
| Handle<Context> script_context = ScriptContextTable::GetContext(
|
| - script_context_table(), lookup_result.context_index);
|
| + script_context_table, lookup_result.context_index);
|
| result->context = script_context;
|
| result->immutable = IsImmutableVariableMode(lookup_result.mode);
|
| result->index = lookup_result.slot_index;
|
|
|