Index: src/interpreter/interpreter.cc |
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc |
index 0c1f945d0fd3322f146bc3449409ec5a5734fbb9..a26f0522bd374fd87e5a53a0585f29ef3ad69c3a 100644 |
--- a/src/interpreter/interpreter.cc |
+++ b/src/interpreter/interpreter.cc |
@@ -421,15 +421,12 @@ void Interpreter::DoMov(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
-Node* Interpreter::BuildLoadGlobal(Callable ic, |
+Node* Interpreter::BuildLoadGlobal(Callable ic, Node* context, Node* raw_slot, |
rmcilroy
2016/09/19 09:04:29
nit - rename raw_slot to feedback_slot (in header
Leszek Swirski
2016/09/19 10:34:51
Done.
|
InterpreterAssembler* assembler) { |
typedef LoadGlobalWithVectorDescriptor Descriptor; |
- // Get the global object. |
- Node* context = __ GetContext(); |
// Load the global via the LoadGlobalIC. |
Node* code_target = __ HeapConstant(ic.code()); |
- Node* raw_slot = __ BytecodeOperandIdx(0); |
Node* smi_slot = __ SmiTag(raw_slot); |
Node* type_feedback_vector = __ LoadTypeFeedbackVector(); |
return __ CallStub(ic.descriptor(), code_target, context, |
@@ -437,6 +434,15 @@ Node* Interpreter::BuildLoadGlobal(Callable ic, |
Arg(Descriptor::kVector, type_feedback_vector)); |
} |
+Node* Interpreter::BuildLoadGlobal(Callable ic, |
rmcilroy
2016/09/19 09:04:29
Not sure it's worth having this helper - would pro
Leszek Swirski
2016/09/19 10:34:51
Fair enough, done (or rather, undone).
|
+ InterpreterAssembler* assembler) { |
+ // Get the global object. |
+ Node* context = __ GetContext(); |
+ |
+ Node* raw_slot = __ BytecodeOperandIdx(0); |
+ return BuildLoadGlobal(ic, context, raw_slot, assembler); |
+} |
+ |
// LdaGlobal <slot> |
// |
// Load the global with name in constant pool entry <name_index> into the |
@@ -561,14 +567,20 @@ void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
+void Interpreter::DoLdaLookupSlowPath(Runtime::FunctionId function_id, |
+ Node* name_index, Node* context, |
+ InterpreterAssembler* assembler) { |
+ Node* name = __ LoadConstantPoolEntry(name_index); |
+ Node* result = __ CallRuntime(function_id, context, name); |
+ __ SetAccumulator(result); |
+ __ Dispatch(); |
rmcilroy
2016/09/19 09:04:29
I'd prefer you made this BuildLdaLookupSlowPath an
Leszek Swirski
2016/09/19 10:34:51
Done.
|
+} |
+ |
void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id, |
InterpreterAssembler* assembler) { |
Node* index = __ BytecodeOperandIdx(0); |
- Node* name = __ LoadConstantPoolEntry(index); |
Node* context = __ GetContext(); |
- Node* result = __ CallRuntime(function_id, context, name); |
- __ SetAccumulator(result); |
- __ Dispatch(); |
+ DoLdaLookupSlowPath(function_id, index, context, assembler); |
} |
// LdaLookupSlot <name_index> |
@@ -609,12 +621,7 @@ void Interpreter::DoLdaLookupContextSlot(Runtime::FunctionId function_id, |
// Slow path when we have to call out to the runtime. |
__ Bind(&slowpath); |
- { |
- Node* name = __ LoadConstantPoolEntry(name_index); |
- Node* result = __ CallRuntime(function_id, context, name); |
- __ SetAccumulator(result); |
- __ Dispatch(); |
- } |
+ { DoLdaLookupSlowPath(function_id, name_index, context, assembler); } |
} |
// LdaLookupSlot <name_index> |
@@ -634,6 +641,51 @@ void Interpreter::DoLdaLookupContextSlotInsideTypeof( |
DoLdaLookupContextSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler); |
} |
+void Interpreter::DoLdaLookupGlobalSlot(Runtime::FunctionId function_id, |
+ InterpreterAssembler* assembler) { |
+ Node* context = __ GetContext(); |
+ Node* name_index = __ BytecodeOperandIdx(0); |
+ Node* raw_slot = __ BytecodeOperandIdx(1); |
rmcilroy
2016/09/19 09:04:29
nit - slot_index
Leszek Swirski
2016/09/19 10:34:51
Changed to feedback_slot, to match the parameter n
|
+ Node* depth = __ BytecodeOperandUImm(2); |
+ |
+ Label slowpath(assembler, Label::kDeferred); |
+ |
+ // Check for context extensions to allow the fast path |
+ __ GotoIfHasContextExtensionUpToDepth(context, depth, &slowpath); |
+ |
+ // Fast path does a normal load global |
+ { |
+ Callable ic = CodeFactory::LoadGlobalICInOptimizedCode( |
+ isolate_, function_id == Runtime::kLoadLookupSlotInsideTypeof |
+ ? INSIDE_TYPEOF |
+ : NOT_INSIDE_TYPEOF); |
+ Node* result = BuildLoadGlobal(ic, context, raw_slot, assembler); |
+ __ SetAccumulator(result); |
+ __ Dispatch(); |
+ } |
+ |
+ // Slow path when we have to call out to the runtime |
+ __ Bind(&slowpath); |
+ { DoLdaLookupSlowPath(function_id, name_index, context, assembler); } |
+} |
+ |
+// LdaLookupSlot <name_index> |
+// |
+// Lookup the object with the name in constant pool entry |name_index| |
+// dynamically. |
+void Interpreter::DoLdaLookupGlobalSlot(InterpreterAssembler* assembler) { |
+ DoLdaLookupGlobalSlot(Runtime::kLoadLookupSlot, assembler); |
+} |
+ |
+// LdaLookupSlotInsideTypeof <name_index> |
+// |
+// Lookup the object with the name in constant pool entry |name_index| |
+// dynamically without causing a NoReferenceError. |
+void Interpreter::DoLdaLookupGlobalSlotInsideTypeof( |
+ InterpreterAssembler* assembler) { |
+ DoLdaLookupGlobalSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler); |
+} |
+ |
void Interpreter::DoStaLookupSlot(LanguageMode language_mode, |
InterpreterAssembler* assembler) { |
Node* value = __ GetAccumulator(); |