Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Unified Diff: src/interpreter/interpreter.cc

Issue 1985753002: [interpreter] Introduce fused bytecodes for common sequences. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 226ddbd8533bca6b28763f4e475a673c93d3642d..53fbb92b340adda177896e7cb5c9bdf3977ec522 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -286,32 +286,29 @@ void Interpreter::DoLdaSmi(InterpreterAssembler* assembler) {
__ Dispatch();
}
-void Interpreter::DoLoadConstant(InterpreterAssembler* assembler) {
+// LdaConstant <idx>
+//
+// Load constant literal at |idx| in the constant pool into the accumulator.
+void Interpreter::DoLdaConstant(InterpreterAssembler* assembler) {
Node* index = __ BytecodeOperandIdx(0);
Node* constant = __ LoadConstantPoolEntry(index);
__ SetAccumulator(constant);
__ Dispatch();
}
-
-// LdaConstant <idx>
-//
-// Load constant literal at |idx| in the constant pool into the accumulator.
-void Interpreter::DoLdaConstant(InterpreterAssembler* assembler) {
- DoLoadConstant(assembler);
+Node* Interpreter::BuildLoadUndefined(InterpreterAssembler* assembler) {
+ return __ HeapConstant(isolate_->factory()->undefined_value());
}
// LdaUndefined
//
// Load Undefined into the accumulator.
void Interpreter::DoLdaUndefined(InterpreterAssembler* assembler) {
- Node* undefined_value =
- __ HeapConstant(isolate_->factory()->undefined_value());
- __ SetAccumulator(undefined_value);
+ Node* result = BuildLoadUndefined(assembler);
+ __ SetAccumulator(result);
__ Dispatch();
}
-
// LdaNull
//
// Load Null into the accumulator.
@@ -385,8 +382,8 @@ void Interpreter::DoMov(InterpreterAssembler* assembler) {
__ Dispatch();
}
-
-void Interpreter::DoLoadGlobal(Callable ic, InterpreterAssembler* assembler) {
+Node* Interpreter::BuildLoadGlobal(Callable ic,
+ InterpreterAssembler* assembler) {
// Get the global object.
Node* context = __ GetContext();
Node* native_context =
@@ -400,8 +397,12 @@ void Interpreter::DoLoadGlobal(Callable ic, InterpreterAssembler* assembler) {
Node* raw_slot = __ BytecodeOperandIdx(1);
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
- Node* result = __ CallStub(ic.descriptor(), code_target, context, global,
- name, smi_slot, type_feedback_vector);
+ return __ CallStub(ic.descriptor(), code_target, context, global, name,
+ smi_slot, type_feedback_vector);
+}
+
+void Interpreter::DoLdaGlobal(Callable ic, InterpreterAssembler* assembler) {
rmcilroy 2016/05/17 15:49:33 I'd just remove these existing helpers - it's not
oth 2016/05/18 20:22:25 Done.
+ Node* result = BuildLoadGlobal(ic, assembler);
__ SetAccumulator(result);
__ Dispatch();
}
@@ -413,7 +414,7 @@ void Interpreter::DoLoadGlobal(Callable ic, InterpreterAssembler* assembler) {
void Interpreter::DoLdaGlobal(InterpreterAssembler* assembler) {
Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
UNINITIALIZED);
- DoLoadGlobal(ic, assembler);
+ DoLdaGlobal(ic, assembler);
}
// LdaGlobalInsideTypeof <name_index> <slot>
@@ -423,10 +424,10 @@ void Interpreter::DoLdaGlobal(InterpreterAssembler* assembler) {
void Interpreter::DoLdaGlobalInsideTypeof(InterpreterAssembler* assembler) {
Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, INSIDE_TYPEOF,
UNINITIALIZED);
- DoLoadGlobal(ic, assembler);
+ DoLdaGlobal(ic, assembler);
}
-void Interpreter::DoStoreGlobal(Callable ic, InterpreterAssembler* assembler) {
+void Interpreter::DoStaGlobal(Callable ic, InterpreterAssembler* assembler) {
// Get the global object.
Node* context = __ GetContext();
Node* native_context =
@@ -454,7 +455,7 @@ void Interpreter::DoStoreGlobal(Callable ic, InterpreterAssembler* assembler) {
void Interpreter::DoStaGlobalSloppy(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
- DoStoreGlobal(ic, assembler);
+ DoStaGlobal(ic, assembler);
}
@@ -465,17 +466,22 @@ void Interpreter::DoStaGlobalSloppy(InterpreterAssembler* assembler) {
void Interpreter::DoStaGlobalStrict(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
- DoStoreGlobal(ic, assembler);
+ DoStaGlobal(ic, assembler);
+}
+
+compiler::Node* Interpreter::BuildLoadContextSlot(
+ InterpreterAssembler* assembler) {
+ Node* reg_index = __ BytecodeOperandReg(0);
+ Node* context = __ LoadRegister(reg_index);
+ Node* slot_index = __ BytecodeOperandIdx(1);
+ return __ LoadContextSlot(context, slot_index);
}
// LdaContextSlot <context> <slot_index>
//
// Load the object in |slot_index| of |context| into the accumulator.
void Interpreter::DoLdaContextSlot(InterpreterAssembler* assembler) {
- Node* reg_index = __ BytecodeOperandReg(0);
- Node* context = __ LoadRegister(reg_index);
- Node* slot_index = __ BytecodeOperandIdx(1);
- Node* result = __ LoadContextSlot(context, slot_index);
+ Node* result = BuildLoadContextSlot(assembler);
__ SetAccumulator(result);
__ Dispatch();
}
@@ -492,8 +498,8 @@ void Interpreter::DoStaContextSlot(InterpreterAssembler* assembler) {
__ Dispatch();
}
-void Interpreter::DoLoadLookupSlot(Runtime::FunctionId function_id,
- InterpreterAssembler* assembler) {
+void Interpreter::DoLdaLookupSlot(Runtime::FunctionId function_id,
+ InterpreterAssembler* assembler) {
Node* index = __ BytecodeOperandIdx(0);
Node* name = __ LoadConstantPoolEntry(index);
Node* context = __ GetContext();
@@ -507,7 +513,7 @@ void Interpreter::DoLoadLookupSlot(Runtime::FunctionId function_id,
// Lookup the object with the name in constant pool entry |name_index|
// dynamically.
void Interpreter::DoLdaLookupSlot(InterpreterAssembler* assembler) {
- DoLoadLookupSlot(Runtime::kLoadLookupSlot, assembler);
+ DoLdaLookupSlot(Runtime::kLoadLookupSlot, assembler);
}
// LdaLookupSlotInsideTypeof <name_index>
@@ -515,11 +521,11 @@ void Interpreter::DoLdaLookupSlot(InterpreterAssembler* assembler) {
// Lookup the object with the name in constant pool entry |name_index|
// dynamically without causing a NoReferenceError.
void Interpreter::DoLdaLookupSlotInsideTypeof(InterpreterAssembler* assembler) {
- DoLoadLookupSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler);
+ DoLdaLookupSlot(Runtime::kLoadLookupSlotInsideTypeof, assembler);
}
-void Interpreter::DoStoreLookupSlot(LanguageMode language_mode,
- InterpreterAssembler* assembler) {
+void Interpreter::DoStaLookupSlot(LanguageMode language_mode,
+ InterpreterAssembler* assembler) {
Node* value = __ GetAccumulator();
Node* index = __ BytecodeOperandIdx(0);
Node* name = __ LoadConstantPoolEntry(index);
@@ -537,7 +543,7 @@ void Interpreter::DoStoreLookupSlot(LanguageMode language_mode,
// Store the object in accumulator to the object with the name in constant
// pool entry |name_index| in sloppy mode.
void Interpreter::DoStaLookupSlotSloppy(InterpreterAssembler* assembler) {
- DoStoreLookupSlot(LanguageMode::SLOPPY, assembler);
+ DoStaLookupSlot(LanguageMode::SLOPPY, assembler);
}
@@ -546,10 +552,11 @@ void Interpreter::DoStaLookupSlotSloppy(InterpreterAssembler* assembler) {
// Store the object in accumulator to the object with the name in constant
// pool entry |name_index| in strict mode.
void Interpreter::DoStaLookupSlotStrict(InterpreterAssembler* assembler) {
- DoStoreLookupSlot(LanguageMode::STRICT, assembler);
+ DoStaLookupSlot(LanguageMode::STRICT, assembler);
}
-void Interpreter::DoLoadIC(Callable ic, InterpreterAssembler* assembler) {
+Node* Interpreter::BuildLoadNamedProperty(Callable ic,
+ InterpreterAssembler* assembler) {
Node* code_target = __ HeapConstant(ic.code());
Node* register_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(register_index);
@@ -559,23 +566,24 @@ void Interpreter::DoLoadIC(Callable ic, InterpreterAssembler* assembler) {
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
- Node* result = __ CallStub(ic.descriptor(), code_target, context, object,
- name, smi_slot, type_feedback_vector);
- __ SetAccumulator(result);
- __ Dispatch();
+ return __ CallStub(ic.descriptor(), code_target, context, object, name,
+ smi_slot, type_feedback_vector);
}
-// LoadIC <object> <name_index> <slot>
+// LdaNamedProperty <object> <name_index> <slot>
//
// Calls the LoadIC at FeedBackVector slot <slot> for <object> and the name at
// constant pool entry <name_index>.
-void Interpreter::DoLoadIC(InterpreterAssembler* assembler) {
+void Interpreter::DoLdaNamedProperty(InterpreterAssembler* assembler) {
Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
UNINITIALIZED);
- DoLoadIC(ic, assembler);
+ Node* result = BuildLoadNamedProperty(ic, assembler);
+ __ SetAccumulator(result);
+ __ Dispatch();
}
-void Interpreter::DoKeyedLoadIC(Callable ic, InterpreterAssembler* assembler) {
+Node* Interpreter::BuildLoadKeyedProperty(Callable ic,
+ InterpreterAssembler* assembler) {
Node* code_target = __ HeapConstant(ic.code());
Node* reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(reg_index);
@@ -584,23 +592,24 @@ void Interpreter::DoKeyedLoadIC(Callable ic, InterpreterAssembler* assembler) {
Node* smi_slot = __ SmiTag(raw_slot);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
- Node* result = __ CallStub(ic.descriptor(), code_target, context, object,
- name, smi_slot, type_feedback_vector);
- __ SetAccumulator(result);
- __ Dispatch();
+ return __ CallStub(ic.descriptor(), code_target, context, object, name,
+ smi_slot, type_feedback_vector);
}
-// KeyedLoadIC <object> <slot>
+// LdaKeyedProperty <object> <slot>
//
// Calls the KeyedLoadIC at FeedBackVector slot <slot> for <object> and the key
// in the accumulator.
-void Interpreter::DoKeyedLoadIC(InterpreterAssembler* assembler) {
+void Interpreter::DoLdaKeyedProperty(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::KeyedLoadICInOptimizedCode(isolate_, UNINITIALIZED);
- DoKeyedLoadIC(ic, assembler);
+ Node* result = BuildLoadKeyedProperty(ic, assembler);
+ __ SetAccumulator(result);
+ __ Dispatch();
}
-void Interpreter::DoStoreIC(Callable ic, InterpreterAssembler* assembler) {
+void Interpreter::DoStaNamedProperty(Callable ic,
+ InterpreterAssembler* assembler) {
Node* code_target = __ HeapConstant(ic.code());
Node* object_reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(object_reg_index);
@@ -616,31 +625,30 @@ void Interpreter::DoStoreIC(Callable ic, InterpreterAssembler* assembler) {
__ Dispatch();
}
-
-// StoreICSloppy <object> <name_index> <slot>
+// StaNamedPropertySloppy <object> <name_index> <slot>
//
// Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and
// the name in constant pool entry <name_index> with the value in the
// accumulator.
-void Interpreter::DoStoreICSloppy(InterpreterAssembler* assembler) {
+void Interpreter::DoStaNamedPropertySloppy(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
- DoStoreIC(ic, assembler);
+ DoStaNamedProperty(ic, assembler);
}
-
-// StoreICStrict <object> <name_index> <slot>
+// StaNamedPropertyStrict <object> <name_index> <slot>
//
// Calls the strict mode StoreIC at FeedBackVector slot <slot> for <object> and
// the name in constant pool entry <name_index> with the value in the
// accumulator.
-void Interpreter::DoStoreICStrict(InterpreterAssembler* assembler) {
+void Interpreter::DoStaNamedPropertyStrict(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
- DoStoreIC(ic, assembler);
+ DoStaNamedProperty(ic, assembler);
}
-void Interpreter::DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler) {
+void Interpreter::DoStaKeyedProperty(Callable ic,
+ InterpreterAssembler* assembler) {
Node* code_target = __ HeapConstant(ic.code());
Node* object_reg_index = __ BytecodeOperandReg(0);
Node* object = __ LoadRegister(object_reg_index);
@@ -656,26 +664,24 @@ void Interpreter::DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler) {
__ Dispatch();
}
-
-// KeyedStoreICSloppy <object> <key> <slot>
+// StaKeyedPropertySloppy <object> <key> <slot>
//
// Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object>
// and the key <key> with the value in the accumulator.
-void Interpreter::DoKeyedStoreICSloppy(InterpreterAssembler* assembler) {
+void Interpreter::DoStaKeyedPropertySloppy(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
- DoKeyedStoreIC(ic, assembler);
+ DoStaKeyedProperty(ic, assembler);
}
-
-// KeyedStoreICStore <object> <key> <slot>
+// StaKeyedPropertyStrict <object> <key> <slot>
//
// Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object>
// and the key <key> with the value in the accumulator.
-void Interpreter::DoKeyedStoreICStrict(InterpreterAssembler* assembler) {
+void Interpreter::DoStaKeyedPropertyStrict(InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
- DoKeyedStoreIC(ic, assembler);
+ DoStaKeyedProperty(ic, assembler);
}
// PushContext <context>
@@ -1791,6 +1797,65 @@ void Interpreter::DoIllegal(InterpreterAssembler* assembler) {
// No operation.
void Interpreter::DoNop(InterpreterAssembler* assembler) { __ Dispatch(); }
+// LdrUndefined <reg>
+//
+// Loads undefined into the accumulator and |reg|.
rmcilroy 2016/05/17 15:49:33 nit - also group these near Lda variants please
oth 2016/05/18 20:22:25 Done.
+void Interpreter::DoLdrUndefined(InterpreterAssembler* assembler) {
+ Node* result = BuildLoadUndefined(assembler);
+ Node* destination = __ BytecodeOperandReg(0);
+ __ StoreRegister(result, destination);
+ __ Dispatch();
+}
+
+// LdrContextSlot <context> <slot_index> <reg>
+//
+// Load the object in <slot_index> of <context> into register <reg>.
+void Interpreter::DoLdrContextSlot(InterpreterAssembler* assembler) {
+ Node* result = BuildLoadContextSlot(assembler);
+ Node* destination = __ BytecodeOperandReg(2);
+ __ StoreRegister(result, destination);
+ __ Dispatch();
+}
+
+// LdrGlobal <name_index> <slot> <reg>
+//
+// Load the global with name in constant pool entry <name_index> into
+// register <reg> using FeedBackVector slot <slot> outside of a typeof.
+void Interpreter::DoLdrGlobal(InterpreterAssembler* assembler) {
+ Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
+ UNINITIALIZED);
+ Node* result = BuildLoadGlobal(ic, assembler);
+ Node* destination = __ BytecodeOperandReg(2);
+ __ StoreRegister(result, destination);
+ __ Dispatch();
+}
+
+// LdrNamedProperty <object> <name_index> <slot> <reg>
+//
+// Calls the LoadIC at FeedBackVector slot <slot> for <object> and the name at
+// constant pool entry <name_index> and puts the result into register <reg>.
+void Interpreter::DoLdrNamedProperty(InterpreterAssembler* assembler) {
+ Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
+ UNINITIALIZED);
+ Node* result = BuildLoadNamedProperty(ic, assembler);
+ Node* destination = __ BytecodeOperandReg(3);
+ __ StoreRegister(result, destination);
+ __ Dispatch();
+}
+
+// LdrKeyedProperty <object> <slot> <reg>
+//
+// Calls the KeyedLoadIC at FeedBackVector slot <slot> for <object> and the key
+// in the accumulator and puts the result in register <reg>.
+void Interpreter::DoLdrKeyedProperty(InterpreterAssembler* assembler) {
+ Callable ic =
+ CodeFactory::KeyedLoadICInOptimizedCode(isolate_, UNINITIALIZED);
+ Node* result = BuildLoadKeyedProperty(ic, assembler);
+ Node* destination = __ BytecodeOperandReg(2);
+ __ StoreRegister(result, destination);
+ __ Dispatch();
+}
+
// SuspendGenerator <generator>
//
// Exports the register file and stores it into the generator. Also stores the

Powered by Google App Engine
This is Rietveld 408576698