Index: src/interpreter/interpreter.cc |
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc |
index 72a8a7ee8b598e859229fe4da1a9fd4b05e8b169..1014fe161bcf9b5e29b709a914c162b1c67235cc 100644 |
--- a/src/interpreter/interpreter.cc |
+++ b/src/interpreter/interpreter.cc |
@@ -293,7 +293,6 @@ void Interpreter::DoLoadConstant(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// LdaConstant <idx> |
// |
// Load constant literal at |idx| in the constant pool into the accumulator. |
@@ -311,7 +310,6 @@ void Interpreter::DoLdaUndefined(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// LdaNull |
// |
// Load Null into the accumulator. |
@@ -321,7 +319,6 @@ void Interpreter::DoLdaNull(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// LdaTheHole |
// |
// Load TheHole into the accumulator. |
@@ -331,7 +328,6 @@ void Interpreter::DoLdaTheHole(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// LdaTrue |
// |
// Load True into the accumulator. |
@@ -341,7 +337,6 @@ void Interpreter::DoLdaTrue(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// LdaFalse |
// |
// Load False into the accumulator. |
@@ -351,7 +346,6 @@ void Interpreter::DoLdaFalse(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// Ldar <src> |
// |
// Load accumulator with value from register <src>. |
@@ -362,7 +356,6 @@ void Interpreter::DoLdar(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// Star <dst> |
// |
// Store accumulator to register <dst>. |
@@ -373,7 +366,6 @@ void Interpreter::DoStar(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// Mov <src> <dst> |
// |
// Stores the value of register <src> to register <dst>. |
@@ -385,7 +377,6 @@ void Interpreter::DoMov(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
void Interpreter::DoLoadGlobal(Callable ic, InterpreterAssembler* assembler) { |
// Get the global object. |
Node* context = __ GetContext(); |
@@ -446,7 +437,6 @@ void Interpreter::DoStoreGlobal(Callable ic, InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// StaGlobalSloppy <name_index> <slot> |
// |
// Store the value in the accumulator into the global with name in constant pool |
@@ -457,7 +447,6 @@ void Interpreter::DoStaGlobalSloppy(InterpreterAssembler* assembler) { |
DoStoreGlobal(ic, assembler); |
} |
- |
// StaGlobalStrict <name_index> <slot> |
// |
// Store the value in the accumulator into the global with name in constant pool |
@@ -540,7 +529,6 @@ void Interpreter::DoStaLookupSlotSloppy(InterpreterAssembler* assembler) { |
DoStoreLookupSlot(LanguageMode::SLOPPY, assembler); |
} |
- |
// StaLookupSlotStrict <name_index> |
// |
// Store the object in accumulator to the object with the name in constant |
@@ -616,7 +604,6 @@ void Interpreter::DoStoreIC(Callable ic, InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// StoreICSloppy <object> <name_index> <slot> |
// |
// Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and |
@@ -628,7 +615,6 @@ void Interpreter::DoStoreICSloppy(InterpreterAssembler* assembler) { |
DoStoreIC(ic, assembler); |
} |
- |
// StoreICStrict <object> <name_index> <slot> |
// |
// Calls the strict mode StoreIC at FeedBackVector slot <slot> for <object> and |
@@ -656,7 +642,6 @@ void Interpreter::DoKeyedStoreIC(Callable ic, InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// KeyedStoreICSloppy <object> <key> <slot> |
// |
// Calls the sloppy mode KeyStoreIC at FeedBackVector slot <slot> for <object> |
@@ -667,7 +652,6 @@ void Interpreter::DoKeyedStoreICSloppy(InterpreterAssembler* assembler) { |
DoKeyedStoreIC(ic, assembler); |
} |
- |
// KeyedStoreICStore <object> <key> <slot> |
// |
// Calls the strict mode KeyStoreIC at FeedBackVector slot <slot> for <object> |
@@ -691,7 +675,6 @@ void Interpreter::DoPushContext(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// PopContext <context> |
// |
// Pops the current context and sets <context> as the new context. |
@@ -716,19 +699,6 @@ void Interpreter::DoBinaryOp(Callable callable, |
__ Dispatch(); |
} |
-void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, |
- InterpreterAssembler* assembler) { |
- // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized |
- // operations, instead of calling builtins directly. |
- Node* reg_index = __ BytecodeOperandReg(0); |
- Node* lhs = __ LoadRegister(reg_index); |
- Node* rhs = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* result = __ CallRuntime(function_id, context, lhs, rhs); |
- __ SetAccumulator(result); |
- __ Dispatch(); |
-} |
- |
template <class Generator> |
void Interpreter::DoBinaryOp(InterpreterAssembler* assembler) { |
Node* reg_index = __ BytecodeOperandReg(0); |
@@ -747,7 +717,6 @@ void Interpreter::DoAdd(InterpreterAssembler* assembler) { |
DoBinaryOp<AddStub>(assembler); |
} |
- |
// Sub <src> |
// |
// Subtract register <src> from accumulator. |
@@ -755,7 +724,6 @@ void Interpreter::DoSub(InterpreterAssembler* assembler) { |
DoBinaryOp<SubtractStub>(assembler); |
} |
- |
// Mul <src> |
// |
// Multiply accumulator by register <src>. |
@@ -763,7 +731,6 @@ void Interpreter::DoMul(InterpreterAssembler* assembler) { |
DoBinaryOp<MultiplyStub>(assembler); |
} |
- |
// Div <src> |
// |
// Divide register <src> by accumulator. |
@@ -771,7 +738,6 @@ void Interpreter::DoDiv(InterpreterAssembler* assembler) { |
DoBinaryOp<DivideStub>(assembler); |
} |
- |
// Mod <src> |
// |
// Modulo register <src> by accumulator. |
@@ -779,7 +745,6 @@ void Interpreter::DoMod(InterpreterAssembler* assembler) { |
DoBinaryOp<ModulusStub>(assembler); |
} |
- |
// BitwiseOr <src> |
// |
// BitwiseOr register <src> to accumulator. |
@@ -787,7 +752,6 @@ void Interpreter::DoBitwiseOr(InterpreterAssembler* assembler) { |
DoBinaryOp<BitwiseOrStub>(assembler); |
} |
- |
// BitwiseXor <src> |
// |
// BitwiseXor register <src> to accumulator. |
@@ -795,7 +759,6 @@ void Interpreter::DoBitwiseXor(InterpreterAssembler* assembler) { |
DoBinaryOp<BitwiseXorStub>(assembler); |
} |
- |
// BitwiseAnd <src> |
// |
// BitwiseAnd register <src> to accumulator. |
@@ -803,7 +766,6 @@ void Interpreter::DoBitwiseAnd(InterpreterAssembler* assembler) { |
DoBinaryOp<BitwiseAndStub>(assembler); |
} |
- |
// ShiftLeft <src> |
// |
// Left shifts register <src> by the count specified in the accumulator. |
@@ -814,7 +776,6 @@ void Interpreter::DoShiftLeft(InterpreterAssembler* assembler) { |
DoBinaryOp<ShiftLeftStub>(assembler); |
} |
- |
// ShiftRight <src> |
// |
// Right shifts register <src> by the count specified in the accumulator. |
@@ -825,7 +786,6 @@ void Interpreter::DoShiftRight(InterpreterAssembler* assembler) { |
DoBinaryOp<ShiftRightStub>(assembler); |
} |
- |
// ShiftRightLogical <src> |
// |
// Right Shifts register <src> by the count specified in the accumulator. |
@@ -836,6 +796,17 @@ void Interpreter::DoShiftRightLogical(InterpreterAssembler* assembler) { |
DoBinaryOp<ShiftRightLogicalStub>(assembler); |
} |
+void Interpreter::DoUnaryOp(Callable callable, |
+ InterpreterAssembler* assembler) { |
+ Node* target = __ HeapConstant(callable.code()); |
+ Node* accumulator = __ GetAccumulator(); |
+ Node* context = __ GetContext(); |
+ Node* result = |
+ __ CallStub(callable.descriptor(), target, context, accumulator); |
+ __ SetAccumulator(result); |
+ __ Dispatch(); |
+} |
+ |
template <class Generator> |
void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { |
Node* value = __ GetAccumulator(); |
@@ -845,6 +816,27 @@ void Interpreter::DoUnaryOp(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
+// ToName |
+// |
+// Cast the object referenced by the accumulator to a name. |
+void Interpreter::DoToName(InterpreterAssembler* assembler) { |
+ DoUnaryOp(CodeFactory::ToName(isolate_), assembler); |
+} |
+ |
+// ToNumber |
+// |
+// Cast the object referenced by the accumulator to a number. |
+void Interpreter::DoToNumber(InterpreterAssembler* assembler) { |
+ DoUnaryOp(CodeFactory::ToNumber(isolate_), assembler); |
+} |
+ |
+// ToObject |
+// |
+// Cast the object referenced by the accumulator to a JSObject. |
+void Interpreter::DoToObject(InterpreterAssembler* assembler) { |
+ DoUnaryOp(CodeFactory::ToObject(isolate_), assembler); |
+} |
+ |
// Inc |
// |
// Increments value in the accumulator by one. |
@@ -859,14 +851,22 @@ void Interpreter::DoDec(InterpreterAssembler* assembler) { |
DoUnaryOp<DecStub>(assembler); |
} |
-void Interpreter::DoLogicalNotOp(Node* value, InterpreterAssembler* assembler) { |
+Node* Interpreter::BuildToBoolean(Node* value, |
+ InterpreterAssembler* assembler) { |
+ Node* context = __ GetContext(); |
+ return ToBooleanStub::Generate(assembler, value, context); |
+} |
+ |
+Node* Interpreter::BuildLogicalNot(Node* value, |
+ InterpreterAssembler* assembler) { |
+ Variable result(assembler, MachineRepresentation::kTagged); |
Label if_true(assembler), if_false(assembler), end(assembler); |
Node* true_value = __ BooleanConstant(true); |
Node* false_value = __ BooleanConstant(false); |
__ BranchIfWordEqual(value, true_value, &if_true, &if_false); |
__ Bind(&if_true); |
{ |
- __ SetAccumulator(false_value); |
+ result.Bind(false_value); |
__ Goto(&end); |
} |
__ Bind(&if_false); |
@@ -875,24 +875,23 @@ void Interpreter::DoLogicalNotOp(Node* value, InterpreterAssembler* assembler) { |
__ AbortIfWordNotEqual(value, false_value, |
BailoutReason::kExpectedBooleanValue); |
} |
- __ SetAccumulator(true_value); |
+ result.Bind(true_value); |
__ Goto(&end); |
} |
__ Bind(&end); |
+ return result.value(); |
} |
-// ToBooleanLogicalNot |
+// LogicalNot |
// |
// Perform logical-not on the accumulator, first casting the |
// accumulator to a boolean value if required. |
+// ToBooleanLogicalNot |
void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::ToBoolean(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
- Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* to_boolean_value = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
- DoLogicalNotOp(to_boolean_value, assembler); |
+ Node* value = __ GetAccumulator(); |
+ Node* to_boolean_value = BuildToBoolean(value, assembler); |
+ Node* result = BuildLogicalNot(to_boolean_value, assembler); |
+ __ SetAccumulator(result); |
__ Dispatch(); |
} |
@@ -902,7 +901,8 @@ void Interpreter::DoToBooleanLogicalNot(InterpreterAssembler* assembler) { |
// value. |
void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { |
Node* value = __ GetAccumulator(); |
- DoLogicalNotOp(value, assembler); |
+ Node* result = BuildLogicalNot(value, assembler); |
+ __ SetAccumulator(result); |
__ Dispatch(); |
} |
@@ -911,14 +911,7 @@ void Interpreter::DoLogicalNot(InterpreterAssembler* assembler) { |
// Load the accumulator with the string representating type of the |
// object in the accumulator. |
void Interpreter::DoTypeOf(InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::Typeof(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
- Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* result = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
- __ SetAccumulator(result); |
- __ Dispatch(); |
+ DoUnaryOp(CodeFactory::Typeof(isolate_), assembler); |
} |
void Interpreter::DoDelete(Runtime::FunctionId function_id, |
@@ -932,7 +925,6 @@ void Interpreter::DoDelete(Runtime::FunctionId function_id, |
__ Dispatch(); |
} |
- |
// DeletePropertyStrict |
// |
// Delete the property specified in the accumulator from the object |
@@ -941,7 +933,6 @@ void Interpreter::DoDeletePropertyStrict(InterpreterAssembler* assembler) { |
DoDelete(Runtime::kDeleteProperty_Strict, assembler); |
} |
- |
// DeletePropertySloppy |
// |
// Delete the property specified in the accumulator from the object |
@@ -967,7 +958,6 @@ void Interpreter::DoJSCall(InterpreterAssembler* assembler, |
__ Dispatch(); |
} |
- |
// Call <callable> <receiver> <arg_count> |
// |
// Call a JSfunction or Callable in |callable| with the |receiver| and |
@@ -995,7 +985,6 @@ void Interpreter::DoCallRuntimeCommon(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// CallRuntime <function_id> <first_arg> <arg_count> |
// |
// Call the runtime function |function_id| with the first argument in |
@@ -1042,7 +1031,6 @@ void Interpreter::DoCallRuntimeForPairCommon(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// CallRuntimeForPair <function_id> <first_arg> <arg_count> <first_return> |
// |
// Call the runtime function |function_id| which returns a pair, with the |
@@ -1074,7 +1062,6 @@ void Interpreter::DoCallJSRuntimeCommon(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// CallJSRuntime <context_index> <receiver> <arg_count> |
// |
// Call the JS runtime function that has the |context_index| with the receiver |
@@ -1098,7 +1085,6 @@ void Interpreter::DoCallConstruct(InterpreterAssembler* assembler) { |
__ Dispatch(); |
} |
- |
// New <constructor> <first_arg> <arg_count> |
// |
// Call operator new with |constructor| and the first argument in |
@@ -1116,7 +1102,6 @@ void Interpreter::DoTestEqual(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::Equal(isolate_), assembler); |
} |
- |
// TestNotEqual <src> |
// |
// Test if the value in the <src> register is not equal to the accumulator. |
@@ -1124,7 +1109,6 @@ void Interpreter::DoTestNotEqual(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::NotEqual(isolate_), assembler); |
} |
- |
// TestEqualStrict <src> |
// |
// Test if the value in the <src> register is strictly equal to the accumulator. |
@@ -1132,7 +1116,6 @@ void Interpreter::DoTestEqualStrict(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::StrictEqual(isolate_), assembler); |
} |
- |
// TestLessThan <src> |
// |
// Test if the value in the <src> register is less than the accumulator. |
@@ -1140,7 +1123,6 @@ void Interpreter::DoTestLessThan(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::LessThan(isolate_), assembler); |
} |
- |
// TestGreaterThan <src> |
// |
// Test if the value in the <src> register is greater than the accumulator. |
@@ -1148,7 +1130,6 @@ void Interpreter::DoTestGreaterThan(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::GreaterThan(isolate_), assembler); |
} |
- |
// TestLessThanOrEqual <src> |
// |
// Test if the value in the <src> register is less than or equal to the |
@@ -1157,7 +1138,6 @@ void Interpreter::DoTestLessThanOrEqual(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::LessThanOrEqual(isolate_), assembler); |
} |
- |
// TestGreaterThanOrEqual <src> |
// |
// Test if the value in the <src> register is greater than or equal to the |
@@ -1166,7 +1146,6 @@ void Interpreter::DoTestGreaterThanOrEqual(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::GreaterThanOrEqual(isolate_), assembler); |
} |
- |
// TestIn <src> |
// |
// Test if the object referenced by the register operand is a property of the |
@@ -1175,7 +1154,6 @@ void Interpreter::DoTestIn(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::HasProperty(isolate_), assembler); |
} |
- |
// TestInstanceOf <src> |
// |
// Test if the object referenced by the <src> register is an an instance of type |
@@ -1184,40 +1162,6 @@ void Interpreter::DoTestInstanceOf(InterpreterAssembler* assembler) { |
DoBinaryOp(CodeFactory::InstanceOf(isolate_), assembler); |
} |
-void Interpreter::DoTypeConversionOp(Callable callable, |
- InterpreterAssembler* assembler) { |
- Node* target = __ HeapConstant(callable.code()); |
- Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* result = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
- __ SetAccumulator(result); |
- __ Dispatch(); |
-} |
- |
-// ToName |
-// |
-// Cast the object referenced by the accumulator to a name. |
-void Interpreter::DoToName(InterpreterAssembler* assembler) { |
- DoTypeConversionOp(CodeFactory::ToName(isolate_), assembler); |
-} |
- |
- |
-// ToNumber |
-// |
-// Cast the object referenced by the accumulator to a number. |
-void Interpreter::DoToNumber(InterpreterAssembler* assembler) { |
- DoTypeConversionOp(CodeFactory::ToNumber(isolate_), assembler); |
-} |
- |
- |
-// ToObject |
-// |
-// Cast the object referenced by the accumulator to a JSObject. |
-void Interpreter::DoToObject(InterpreterAssembler* assembler) { |
- DoTypeConversionOp(CodeFactory::ToObject(isolate_), assembler); |
-} |
- |
// Jump <imm> |
// |
// Jump by number of bytes represented by the immediate operand |imm|. |
@@ -1289,12 +1233,8 @@ void Interpreter::DoJumpIfFalseConstant(InterpreterAssembler* assembler) { |
// Jump by number of bytes represented by an immediate operand if the object |
// referenced by the accumulator is true when the object is cast to boolean. |
void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::ToBoolean(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* to_boolean_value = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
+ Node* to_boolean_value = BuildToBoolean(accumulator, assembler); |
Node* relative_jump = __ BytecodeOperandImm(0); |
Node* true_value = __ BooleanConstant(true); |
__ JumpIfWordEqual(to_boolean_value, true_value, relative_jump); |
@@ -1307,12 +1247,8 @@ void Interpreter::DoJumpIfToBooleanTrue(InterpreterAssembler* assembler) { |
// to boolean. |
void Interpreter::DoJumpIfToBooleanTrueConstant( |
InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::ToBoolean(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* to_boolean_value = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
+ Node* to_boolean_value = BuildToBoolean(accumulator, assembler); |
Node* index = __ BytecodeOperandIdx(0); |
Node* constant = __ LoadConstantPoolEntry(index); |
Node* relative_jump = __ SmiUntag(constant); |
@@ -1325,12 +1261,8 @@ void Interpreter::DoJumpIfToBooleanTrueConstant( |
// Jump by number of bytes represented by an immediate operand if the object |
// referenced by the accumulator is false when the object is cast to boolean. |
void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::ToBoolean(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* to_boolean_value = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
+ Node* to_boolean_value = BuildToBoolean(accumulator, assembler); |
Node* relative_jump = __ BytecodeOperandImm(0); |
Node* false_value = __ BooleanConstant(false); |
__ JumpIfWordEqual(to_boolean_value, false_value, relative_jump); |
@@ -1343,12 +1275,8 @@ void Interpreter::DoJumpIfToBooleanFalse(InterpreterAssembler* assembler) { |
// to boolean. |
void Interpreter::DoJumpIfToBooleanFalseConstant( |
InterpreterAssembler* assembler) { |
- Callable callable = CodeFactory::ToBoolean(isolate_); |
- Node* target = __ HeapConstant(callable.code()); |
Node* accumulator = __ GetAccumulator(); |
- Node* context = __ GetContext(); |
- Node* to_boolean_value = |
- __ CallStub(callable.descriptor(), target, context, accumulator); |
+ Node* to_boolean_value = BuildToBoolean(accumulator, assembler); |
Node* index = __ BytecodeOperandIdx(0); |
Node* constant = __ LoadConstantPoolEntry(index); |
Node* relative_jump = __ SmiUntag(constant); |
@@ -1579,7 +1507,6 @@ void Interpreter::DoCreateMappedArguments(InterpreterAssembler* assembler) { |
} |
} |
- |
// CreateUnmappedArguments |
// |
// Creates a new unmapped arguments object. |
@@ -1639,7 +1566,6 @@ void Interpreter::DoThrow(InterpreterAssembler* assembler) { |
__ Abort(kUnexpectedReturnFromThrow); |
} |
- |
// ReThrow |
// |
// Re-throws the exception in the accumulator. |
@@ -1651,7 +1577,6 @@ void Interpreter::DoReThrow(InterpreterAssembler* assembler) { |
__ Abort(kUnexpectedReturnFromThrow); |
} |
- |
// Return |
// |
// Return the value in the accumulator. |