Index: src/ic/ic.cc |
diff --git a/src/ic/ic.cc b/src/ic/ic.cc |
index d92d22df40eb71fb14c3fdd53b9645d6226a661e..62571612d72ed3a7c0075dc12662ba9c7814efe7 100644 |
--- a/src/ic/ic.cc |
+++ b/src/ic/ic.cc |
@@ -2313,6 +2313,54 @@ RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Miss) { |
return *result; |
} |
+RUNTIME_FUNCTION(Runtime_LoadGlobalIC_Slow) { |
+ HandleScope scope(isolate); |
+ DCHECK_EQ(2, args.length()); |
+ CONVERT_SMI_ARG_CHECKED(slot, 0); |
+ CONVERT_ARG_HANDLE_CHECKED(TypeFeedbackVector, vector, 1); |
+ |
+ FeedbackVectorSlot vector_slot = vector->ToSlot(slot); |
+ DCHECK_EQ(FeedbackVectorSlotKind::LOAD_GLOBAL_IC, |
+ vector->GetKind(vector_slot)); |
+ Handle<String> name(vector->GetName(vector_slot), isolate); |
+ DCHECK_NE(*name, *isolate->factory()->empty_string()); |
+ |
+ Handle<JSGlobalObject> global = isolate->global_object(); |
+ |
+ Handle<ScriptContextTable> script_contexts( |
+ global->native_context()->script_context_table()); |
+ |
+ ScriptContextTable::LookupResult lookup_result; |
+ if (ScriptContextTable::Lookup(script_contexts, name, &lookup_result)) { |
+ Handle<Context> script_context = ScriptContextTable::GetContext( |
+ script_contexts, lookup_result.context_index); |
+ Handle<Object> result = |
+ FixedArray::get(*script_context, lookup_result.slot_index, isolate); |
+ if (*result == *isolate->factory()->the_hole_value()) { |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, NewReferenceError(MessageTemplate::kNotDefined, name)); |
+ } |
+ return *result; |
+ } |
+ |
+ Handle<Object> result; |
+ bool is_found = false; |
+ ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
+ isolate, result, |
+ Runtime::GetObjectProperty(isolate, global, name, &is_found)); |
+ if (!is_found) { |
+ LoadICNexus nexus(isolate); |
+ LoadIC ic(IC::NO_EXTRA_FRAME, isolate, &nexus); |
+ // It is actually a LoadGlobalICs here but the predicate handles this case |
+ // properly. |
+ if (ic.ShouldThrowReferenceError()) { |
+ THROW_NEW_ERROR_RETURN_FAILURE( |
+ isolate, NewReferenceError(MessageTemplate::kNotDefined, name)); |
+ } |
+ } |
+ return *result; |
+} |
+ |
// Used from ic-<arch>.cc |
RUNTIME_FUNCTION(Runtime_KeyedLoadIC_Miss) { |
TimerEventScope<TimerEventIcMiss> timer(isolate); |