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

Unified Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1386133002: [Interpreter] Add bitwise operators (Or, Xor, And) to interpreter (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebased the patch Created 5 years, 2 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: test/cctest/interpreter/test-interpreter.cc
diff --git a/test/cctest/interpreter/test-interpreter.cc b/test/cctest/interpreter/test-interpreter.cc
index 132a1aae7abf43c4d386661ef57e2241b6382ff9..fa9f89128b8ea1b094c2f6417f5c05ab1cfc427f 100644
--- a/test/cctest/interpreter/test-interpreter.cc
+++ b/test/cctest/interpreter/test-interpreter.cc
@@ -351,15 +351,17 @@ TEST(InterpreterLoadStoreRegisters) {
}
-static const Token::Value kArithmeticOperators[] = {
- Token::Value::SHL, Token::Value::SAR, Token::Value::SHR, Token::Value::ADD,
- Token::Value::SUB, Token::Value::MUL, Token::Value::DIV, Token::Value::MOD};
-
-
static const Token::Value kShiftOperators[] = {
Token::Value::SHL, Token::Value::SAR, Token::Value::SHR};
+static const Token::Value kArithmeticOperators[] = {
+ Token::Value::BIT_OR, Token::Value::BIT_XOR, Token::Value::BIT_AND,
+ Token::Value::SHL, Token::Value::SAR, Token::Value::SHR,
+ Token::Value::ADD, Token::Value::SUB, Token::Value::MUL,
+ Token::Value::DIV, Token::Value::MOD};
+
+
static double BinaryOpC(Token::Value op, double lhs, double rhs) {
switch (op) {
case Token::Value::ADD:
@@ -372,6 +374,15 @@ static double BinaryOpC(Token::Value op, double lhs, double rhs) {
return lhs / rhs;
case Token::Value::MOD:
return std::fmod(lhs, rhs);
+ case Token::Value::BIT_OR:
+ return (v8::internal::DoubleToInt32(lhs) |
+ v8::internal::DoubleToInt32(rhs));
+ case Token::Value::BIT_XOR:
+ return (v8::internal::DoubleToInt32(lhs) ^
+ v8::internal::DoubleToInt32(rhs));
+ case Token::Value::BIT_AND:
+ return (v8::internal::DoubleToInt32(lhs) &
+ v8::internal::DoubleToInt32(rhs));
case Token::Value::SHL: {
int32_t val = v8::internal::DoubleToInt32(lhs);
uint32_t count = v8::internal::DoubleToUint32(rhs) & 0x1F;
@@ -415,7 +426,7 @@ TEST(InterpreterShiftOpsSmi) {
builder.LoadLiteral(Smi::FromInt(lhs))
.StoreAccumulatorInRegister(reg)
.LoadLiteral(Smi::FromInt(rhs))
- .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK)
+ .BinaryOperation(kShiftOperators[o], reg, Strength::WEAK)
.Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
@@ -445,7 +456,7 @@ TEST(InterpreterBinaryOpsSmi) {
builder.set_parameter_count(1);
Register reg(0);
int lhs = lhs_inputs[l];
- int rhs = rhs_inputs[l];
+ int rhs = rhs_inputs[r];
builder.LoadLiteral(Smi::FromInt(lhs))
.StoreAccumulatorInRegister(reg)
.LoadLiteral(Smi::FromInt(rhs))
@@ -480,7 +491,7 @@ TEST(InterpreterBinaryOpsHeapNumber) {
builder.set_parameter_count(1);
Register reg(0);
double lhs = lhs_inputs[l];
- double rhs = rhs_inputs[l];
+ double rhs = rhs_inputs[r];
builder.LoadLiteral(factory->NewNumber(lhs))
.StoreAccumulatorInRegister(reg)
.LoadLiteral(factory->NewNumber(rhs))
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698