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

Unified Diff: src/interpreter/interpreter.cc

Issue 1300813005: [Interpreter] Add implementations of arithmetic binary op bytecodes. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@mstar_v8h
Patch Set: Fix unittest too... Created 5 years, 4 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
« no previous file with comments | « src/interpreter/interpreter.h ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/interpreter/interpreter.cc
diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc
index 565fa0c443942b5746884904b8deed87d4ff4a8f..7a979a4a3e8ca87314240c87f7f93441f077ee1c 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -165,7 +165,8 @@ void Interpreter::DoLdaFalse(compiler::InterpreterAssembler* assembler) {
//
// Load accumulator with value from register <src>.
void Interpreter::DoLdar(compiler::InterpreterAssembler* assembler) {
- Node* value = __ LoadRegister(__ BytecodeOperandReg(0));
+ Node* reg_index = __ BytecodeOperandReg(0);
+ Node* value = __ LoadRegister(reg_index);
__ SetAccumulator(value);
__ Dispatch();
}
@@ -182,12 +183,24 @@ void Interpreter::DoStar(compiler::InterpreterAssembler* assembler) {
}
+void Interpreter::DoBinaryOp(Builtins::JavaScript binop_builtin,
+ compiler::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* result = __ CallJSBuiltin(binop_builtin, lhs, rhs);
+ __ SetAccumulator(result);
+ __ Dispatch();
+}
+
+
// Add <src>
//
// Add register <src> to accumulator.
void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) {
- // TODO(rmcilroy) Implement.
- __ Dispatch();
+ DoBinaryOp(Builtins::ADD, assembler);
}
@@ -195,8 +208,7 @@ void Interpreter::DoAdd(compiler::InterpreterAssembler* assembler) {
//
// Subtract register <src> from accumulator.
void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) {
- // TODO(rmcilroy) Implement.
- __ Dispatch();
+ DoBinaryOp(Builtins::SUB, assembler);
}
@@ -204,8 +216,7 @@ void Interpreter::DoSub(compiler::InterpreterAssembler* assembler) {
//
// Multiply accumulator by register <src>.
void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) {
- // TODO(rmcilroy) Implement add register to accumulator.
- __ Dispatch();
+ DoBinaryOp(Builtins::MUL, assembler);
}
@@ -213,8 +224,15 @@ void Interpreter::DoMul(compiler::InterpreterAssembler* assembler) {
//
// Divide register <src> by accumulator.
void Interpreter::DoDiv(compiler::InterpreterAssembler* assembler) {
- // TODO(rmcilroy) Implement.
- __ Dispatch();
+ DoBinaryOp(Builtins::DIV, assembler);
+}
+
+
+// Mod <src>
+//
+// Modulo register <src> by accumulator.
+void Interpreter::DoMod(compiler::InterpreterAssembler* assembler) {
+ DoBinaryOp(Builtins::MOD, assembler);
}
« no previous file with comments | « src/interpreter/interpreter.h ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698