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

Unified Diff: src/interpreter/interpreter.cc

Issue 1343363002: [Interpreter] Basic flow control. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Clarify comment and diff reduction. Created 5 years, 3 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 61cd7a44c085df9ff28be9c40a4ae11affec3f7a..60ba5c55a51294244fba249ccfd3a84dbfe1d4ad 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -282,6 +282,15 @@ void Interpreter::DoBinaryOp(Runtime::FunctionId function_id,
}
+void Interpreter::DoCompareOp(Token::Value op,
+ compiler::InterpreterAssembler* assembler) {
+ // TODO(oth): placeholder until compare path fixed.
+ // The accumulator should be set to true on success (or false otherwise)
+ // by the comparisons so it can be used for conditional jumps.
+ DoLdaTrue(assembler);
+}
+
+
// Add <src>
//
// Add register <src> to accumulator.
@@ -338,6 +347,164 @@ void Interpreter::DoCall(compiler::InterpreterAssembler* assembler) {
}
+// TestEqual <src>
+//
+// Test if register equals the accumulator.
rmcilroy 2015/09/18 10:42:24 nit (for all comments) - /s/Test if register/Test
oth 2015/09/23 10:46:56 Done.
+void Interpreter::DoTestEqual(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::EQ, assembler);
+}
+
+
+// TestNotEqual <src>
+//
+// Test if register not equal to the accumulator.
+void Interpreter::DoTestNotEqual(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::NE, assembler);
+}
+
+
+// TestEqualStrict <src>
+//
+// Test if register strictly equal to the accumulator.
rmcilroy 2015/09/18 10:42:24 /s/strictly/is strictly (and below)
oth 2015/09/23 10:46:56 Done.
+void Interpreter::DoTestEqualStrict(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::EQ_STRICT, assembler);
+}
+
+
+// TestNotEqualStrict <src>
+//
+// Test if register not strictly equal to the accumulator.
+void Interpreter::DoTestNotEqualStrict(
+ compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::NE_STRICT, assembler);
+}
+
+
+// TestLessThan <src>
+//
+// Test if register is less than the accumulator.
+void Interpreter::DoTestLessThan(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::LT, assembler);
+}
+
+
+// TestGreaterThan <src>
+//
+// Test if register is greater than the accumulator.
+void Interpreter::DoTestGreaterThan(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::GT, assembler);
+}
+
+
+// TestLessThanEqual <src>
+//
+// Test if register is less than or equal to the accumulator.
+void Interpreter::DoTestLessThanEqual(
+ compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::LTE, assembler);
+}
+
+
+// TestGreaterThanEqual <src>
+//
+// Test if register is greater than or equal to the accumulator.
+void Interpreter::DoTestGreaterThanEqual(
+ compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::GTE, assembler);
+}
+
+
+// TestIn <src>
+//
+// Test if register is in the collection referenced by the accumulator.
+void Interpreter::DoTestIn(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::IN, assembler);
+}
+
+
+// TestInstanceOf <src>
+//
+// Test if object referenced by register is an an instance of type referenced
+// by the accumulator.
+void Interpreter::DoTestInstanceOf(compiler::InterpreterAssembler* assembler) {
+ DoCompareOp(Token::Value::INSTANCEOF, assembler);
+}
+
+
+// JumpSmi8 <imm8>
+//
+// Jump by number of bytes represented by an immediate operand.
+void Interpreter::DoJumpSmi8(compiler::InterpreterAssembler* assembler) {
+ Node* int_value = __ BytecodeOperandImm8(0);
rmcilroy 2015/09/18 10:42:24 nit - /s/int_value/jump_delta (and below)
oth 2015/09/23 10:46:56 Done. s/int_value/relative_jump/ to match code fur
+ __ Jump(int_value);
+}
+
+
+// JumpConstant <idx>
+//
+// Jump by number of bytes in the Smi in the |idx| entry in the constant pool.
+void Interpreter::DoJumpConstant(compiler::InterpreterAssembler* assembler) {
+ Node* index = __ BytecodeOperandIdx(0);
+ Node* constant = __ LoadConstantPoolEntry(index);
+ Node* int_value = __ SmiUntag(constant);
+ __ Jump(int_value);
+}
+
+
+// JumpIfTrueSmi8 <imm8>
+//
+// Jump by number of bytes represented by an immediate operand if the
+// accumulator contains true.
+void Interpreter::DoJumpIfTrueSmi8(compiler::InterpreterAssembler* assembler) {
+ Node* accumulator = __ GetAccumulator();
+ Node* relative_jump = __ BytecodeOperandImm8(0);
+ Node* boolean_value = __ BooleanConstant(true);
+ __ JumpIfEqual(accumulator, boolean_value, relative_jump);
+}
+
+
+// JumpIfTrueConstant <idx>
+//
+// Jump by number of bytes in the Smi in the |idx| entry in the constant pool
+// if the accumulator contains true.
+void Interpreter::DoJumpIfTrueConstant(
+ compiler::InterpreterAssembler* assembler) {
+ Node* accumulator = __ GetAccumulator();
+ Node* index = __ BytecodeOperandIdx(0);
+ Node* constant = __ LoadConstantPoolEntry(index);
+ Node* relative_jump = __ SmiUntag(constant);
+ Node* boolean_value = __ BooleanConstant(true);
+ __ JumpIfEqual(accumulator, boolean_value, relative_jump);
+}
+
+
+// JumpIfFalseSmi8 <imm8>
+//
+// Jump by number of bytes represented by an immediate operand if the
+// accumulator contains false.
+void Interpreter::DoJumpIfFalseSmi8(compiler::InterpreterAssembler* assembler) {
+ Node* accumulator = __ GetAccumulator();
+ Node* relative_jump = __ BytecodeOperandImm8(0);
+ Node* boolean_value = __ BooleanConstant(false);
+ __ JumpIfEqual(accumulator, boolean_value, relative_jump);
+}
+
+
+// JumpIfFalseConstant <idx>
+//
+// Jump by number of bytes in the Smi in the |idx| entry in the constant pool
+// if the accumulator contains false.
+void Interpreter::DoJumpIfFalseConstant(
+ compiler::InterpreterAssembler* assembler) {
+ Node* accumulator = __ GetAccumulator();
+ Node* index = __ BytecodeOperandIdx(0);
+ Node* constant = __ LoadConstantPoolEntry(index);
+ Node* relative_jump = __ SmiUntag(constant);
+ Node* boolean_value = __ BooleanConstant(false);
+ __ JumpIfEqual(accumulator, boolean_value, relative_jump);
+}
+
+
// Return
//
// Return the value in register 0.

Powered by Google App Engine
This is Rietveld 408576698