Commit 78551682 authored by rmcilroy's avatar rmcilroy Committed by Commit bot

[Interpreter]: Add support for strict mode load / store ICs.

Adds support for strict mode load / store ICs and cleans up BinaryOp and
CompareOp to only trigger an UNIMPLEMENTED abort if called with STRONG
mode (which is the only language mode which has different compare/binary ops.

BUG=v8:4280
LOG=N

Review URL: https://codereview.chromium.org/1385623002

Cr-Commit-Position: refs/heads/master@{#31134}
parent 9081ee11
...@@ -255,25 +255,49 @@ void BytecodeGraphBuilder::VisitLdaGlobal( ...@@ -255,25 +255,49 @@ void BytecodeGraphBuilder::VisitLdaGlobal(
} }
void BytecodeGraphBuilder::VisitLoadIC( void BytecodeGraphBuilder::VisitLoadICSloppy(
const interpreter::BytecodeArrayIterator& iterator) { const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void BytecodeGraphBuilder::VisitKeyedLoadIC( void BytecodeGraphBuilder::VisitLoadICStrict(
const interpreter::BytecodeArrayIterator& iterator) { const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void BytecodeGraphBuilder::VisitStoreIC( void BytecodeGraphBuilder::VisitKeyedLoadICSloppy(
const interpreter::BytecodeArrayIterator& iterator) { const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
void BytecodeGraphBuilder::VisitKeyedStoreIC( void BytecodeGraphBuilder::VisitKeyedLoadICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
}
void BytecodeGraphBuilder::VisitStoreICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
}
void BytecodeGraphBuilder::VisitStoreICStrict(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
}
void BytecodeGraphBuilder::VisitKeyedStoreICSloppy(
const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED();
}
void BytecodeGraphBuilder::VisitKeyedStoreICStrict(
const interpreter::BytecodeArrayIterator& iterator) { const interpreter::BytecodeArrayIterator& iterator) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
......
...@@ -128,7 +128,12 @@ void BytecodeArrayBuilder::Output(Bytecode bytecode) { ...@@ -128,7 +128,12 @@ void BytecodeArrayBuilder::Output(Bytecode bytecode) {
BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op, BytecodeArrayBuilder& BytecodeArrayBuilder::BinaryOperation(Token::Value op,
Register reg) { Register reg,
Strength strength) {
if (is_strong(strength)) {
UNIMPLEMENTED();
}
Output(BytecodeForBinaryOperation(op), reg.ToOperand()); Output(BytecodeForBinaryOperation(op), reg.ToOperand());
return *this; return *this;
} }
...@@ -147,8 +152,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() { ...@@ -147,8 +152,8 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::TypeOf() {
BytecodeArrayBuilder& BytecodeArrayBuilder::CompareOperation( BytecodeArrayBuilder& BytecodeArrayBuilder::CompareOperation(
Token::Value op, Register reg, LanguageMode language_mode) { Token::Value op, Register reg, Strength strength) {
if (!is_sloppy(language_mode)) { if (is_strong(strength)) {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
...@@ -238,13 +243,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) { ...@@ -238,13 +243,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadGlobal(int slot_index) {
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
Register object, int feedback_slot, LanguageMode language_mode) { Register object, int feedback_slot, LanguageMode language_mode) {
if (!is_sloppy(language_mode)) { Bytecode bytecode = BytecodeForLoadIC(language_mode);
UNIMPLEMENTED();
}
if (FitsInIdx8Operand(feedback_slot)) { if (FitsInIdx8Operand(feedback_slot)) {
Output(Bytecode::kLoadIC, object.ToOperand(), Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
static_cast<uint8_t>(feedback_slot));
} else { } else {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
...@@ -254,13 +255,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty( ...@@ -254,13 +255,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadNamedProperty(
BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty(
Register object, int feedback_slot, LanguageMode language_mode) { Register object, int feedback_slot, LanguageMode language_mode) {
if (!is_sloppy(language_mode)) { Bytecode bytecode = BytecodeForKeyedLoadIC(language_mode);
UNIMPLEMENTED();
}
if (FitsInIdx8Operand(feedback_slot)) { if (FitsInIdx8Operand(feedback_slot)) {
Output(Bytecode::kKeyedLoadIC, object.ToOperand(), Output(bytecode, object.ToOperand(), static_cast<uint8_t>(feedback_slot));
static_cast<uint8_t>(feedback_slot));
} else { } else {
UNIMPLEMENTED(); UNIMPLEMENTED();
} }
...@@ -271,12 +268,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty( ...@@ -271,12 +268,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::LoadKeyedProperty(
BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty(
Register object, Register name, int feedback_slot, Register object, Register name, int feedback_slot,
LanguageMode language_mode) { LanguageMode language_mode) {
if (!is_sloppy(language_mode)) { Bytecode bytecode = BytecodeForStoreIC(language_mode);
UNIMPLEMENTED();
}
if (FitsInIdx8Operand(feedback_slot)) { if (FitsInIdx8Operand(feedback_slot)) {
Output(Bytecode::kStoreIC, object.ToOperand(), name.ToOperand(), Output(bytecode, object.ToOperand(), name.ToOperand(),
static_cast<uint8_t>(feedback_slot)); static_cast<uint8_t>(feedback_slot));
} else { } else {
UNIMPLEMENTED(); UNIMPLEMENTED();
...@@ -288,12 +282,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty( ...@@ -288,12 +282,9 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::StoreNamedProperty(
BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty( BytecodeArrayBuilder& BytecodeArrayBuilder::StoreKeyedProperty(
Register object, Register key, int feedback_slot, Register object, Register key, int feedback_slot,
LanguageMode language_mode) { LanguageMode language_mode) {
if (!is_sloppy(language_mode)) { Bytecode bytecode = BytecodeForKeyedStoreIC(language_mode);
UNIMPLEMENTED();
}
if (FitsInIdx8Operand(feedback_slot)) { if (FitsInIdx8Operand(feedback_slot)) {
Output(Bytecode::kKeyedStoreIC, object.ToOperand(), key.ToOperand(), Output(bytecode, object.ToOperand(), key.ToOperand(),
static_cast<uint8_t>(feedback_slot)); static_cast<uint8_t>(feedback_slot));
} else { } else {
UNIMPLEMENTED(); UNIMPLEMENTED();
...@@ -619,6 +610,72 @@ Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) { ...@@ -619,6 +610,72 @@ Bytecode BytecodeArrayBuilder::BytecodeForCompareOperation(Token::Value op) {
} }
// static
Bytecode BytecodeArrayBuilder::BytecodeForLoadIC(LanguageMode language_mode) {
switch (language_mode) {
case SLOPPY:
return Bytecode::kLoadICSloppy;
case STRICT:
return Bytecode::kLoadICStrict;
case STRONG:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
return static_cast<Bytecode>(-1);
}
// static
Bytecode BytecodeArrayBuilder::BytecodeForKeyedLoadIC(
LanguageMode language_mode) {
switch (language_mode) {
case SLOPPY:
return Bytecode::kKeyedLoadICSloppy;
case STRICT:
return Bytecode::kKeyedLoadICStrict;
case STRONG:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
return static_cast<Bytecode>(-1);
}
// static
Bytecode BytecodeArrayBuilder::BytecodeForStoreIC(LanguageMode language_mode) {
switch (language_mode) {
case SLOPPY:
return Bytecode::kStoreICSloppy;
case STRICT:
return Bytecode::kStoreICStrict;
case STRONG:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
return static_cast<Bytecode>(-1);
}
// static
Bytecode BytecodeArrayBuilder::BytecodeForKeyedStoreIC(
LanguageMode language_mode) {
switch (language_mode) {
case SLOPPY:
return Bytecode::kKeyedStoreICSloppy;
case STRICT:
return Bytecode::kKeyedStoreICStrict;
case STRONG:
UNIMPLEMENTED();
default:
UNREACHABLE();
}
return static_cast<Bytecode>(-1);
}
// static // static
bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) { bool BytecodeArrayBuilder::FitsInIdx8Operand(int value) {
return kMinUInt8 <= value && value <= kMaxUInt8; return kMinUInt8 <= value && value <= kMaxUInt8;
......
...@@ -82,7 +82,8 @@ class BytecodeArrayBuilder { ...@@ -82,7 +82,8 @@ class BytecodeArrayBuilder {
Register first_arg, size_t arg_count); Register first_arg, size_t arg_count);
// Operators (register == lhs, accumulator = rhs). // Operators (register == lhs, accumulator = rhs).
BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg); BytecodeArrayBuilder& BinaryOperation(Token::Value binop, Register reg,
Strength strength);
// Unary Operators. // Unary Operators.
BytecodeArrayBuilder& LogicalNot(); BytecodeArrayBuilder& LogicalNot();
...@@ -90,7 +91,7 @@ class BytecodeArrayBuilder { ...@@ -90,7 +91,7 @@ class BytecodeArrayBuilder {
// Tests. // Tests.
BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg, BytecodeArrayBuilder& CompareOperation(Token::Value op, Register reg,
LanguageMode language_mode); Strength strength);
// Casts // Casts
BytecodeArrayBuilder& CastAccumulatorToBoolean(); BytecodeArrayBuilder& CastAccumulatorToBoolean();
...@@ -117,6 +118,10 @@ class BytecodeArrayBuilder { ...@@ -117,6 +118,10 @@ class BytecodeArrayBuilder {
static Bytecode BytecodeForBinaryOperation(Token::Value op); static Bytecode BytecodeForBinaryOperation(Token::Value op);
static Bytecode BytecodeForCompareOperation(Token::Value op); static Bytecode BytecodeForCompareOperation(Token::Value op);
static Bytecode BytecodeForLoadIC(LanguageMode language_mode);
static Bytecode BytecodeForKeyedLoadIC(LanguageMode language_mode);
static Bytecode BytecodeForStoreIC(LanguageMode language_mode);
static Bytecode BytecodeForKeyedStoreIC(LanguageMode language_mode);
static bool FitsInIdx8Operand(int value); static bool FitsInIdx8Operand(int value);
static bool FitsInIdx8Operand(size_t value); static bool FitsInIdx8Operand(size_t value);
......
...@@ -687,7 +687,7 @@ void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) { ...@@ -687,7 +687,7 @@ void BytecodeGenerator::VisitCompareOperation(CompareOperation* expr) {
Visit(left); Visit(left);
builder()->StoreAccumulatorInRegister(temporary); builder()->StoreAccumulatorInRegister(temporary);
Visit(right); Visit(right);
builder()->CompareOperation(op, temporary, language_mode()); builder()->CompareOperation(op, temporary, language_mode_strength());
} }
...@@ -726,7 +726,7 @@ void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* binop) { ...@@ -726,7 +726,7 @@ void BytecodeGenerator::VisitArithmeticExpression(BinaryOperation* binop) {
Visit(left); Visit(left);
builder()->StoreAccumulatorInRegister(temporary); builder()->StoreAccumulatorInRegister(temporary);
Visit(right); Visit(right);
builder()->BinaryOperation(op, temporary); builder()->BinaryOperation(op, temporary, language_mode_strength());
} }
...@@ -735,6 +735,11 @@ LanguageMode BytecodeGenerator::language_mode() const { ...@@ -735,6 +735,11 @@ LanguageMode BytecodeGenerator::language_mode() const {
} }
Strength BytecodeGenerator::language_mode_strength() const {
return strength(language_mode());
}
int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const { int BytecodeGenerator::feedback_index(FeedbackVectorSlot slot) const {
return info()->feedback_vector()->GetIndex(slot); return info()->feedback_vector()->GetIndex(slot);
} }
......
...@@ -48,6 +48,7 @@ class BytecodeGenerator : public AstVisitor { ...@@ -48,6 +48,7 @@ class BytecodeGenerator : public AstVisitor {
inline void set_info(CompilationInfo* info) { info_ = info; } inline void set_info(CompilationInfo* info) { info_ = info; }
LanguageMode language_mode() const; LanguageMode language_mode() const;
Strength language_mode_strength() const;
int feedback_index(FeedbackVectorSlot slot) const; int feedback_index(FeedbackVectorSlot slot) const;
BytecodeArrayBuilder builder_; BytecodeArrayBuilder builder_;
......
...@@ -46,17 +46,23 @@ namespace interpreter { ...@@ -46,17 +46,23 @@ namespace interpreter {
/* Load globals */ \ /* Load globals */ \
V(LdaGlobal, OperandType::kIdx8) \ V(LdaGlobal, OperandType::kIdx8) \
\ \
/* Reg8ister-accumulator transfers */ \ /* Register-accumulator transfers */ \
V(Ldar, OperandType::kReg8) \ V(Ldar, OperandType::kReg8) \
V(Star, OperandType::kReg8) \ V(Star, OperandType::kReg8) \
\ \
/* LoadIC operations */ \ /* LoadIC operations */ \
V(LoadIC, OperandType::kReg8, OperandType::kIdx8) \ V(LoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \
V(KeyedLoadIC, OperandType::kReg8, OperandType::kIdx8) \ V(LoadICStrict, OperandType::kReg8, OperandType::kIdx8) \
V(KeyedLoadICSloppy, OperandType::kReg8, OperandType::kIdx8) \
V(KeyedLoadICStrict, OperandType::kReg8, OperandType::kIdx8) \
\ \
/* StoreIC operations */ \ /* StoreIC operations */ \
V(StoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ V(StoreICSloppy, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \
V(KeyedStoreIC, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \ V(StoreICStrict, OperandType::kReg8, OperandType::kReg8, OperandType::kIdx8) \
V(KeyedStoreICSloppy, OperandType::kReg8, OperandType::kReg8, \
OperandType::kIdx8) \
V(KeyedStoreICStrict, OperandType::kReg8, OperandType::kReg8, \
OperandType::kIdx8) \
\ \
/* Binary Operators */ \ /* Binary Operators */ \
V(Add, OperandType::kReg8) \ V(Add, OperandType::kReg8) \
...@@ -133,8 +139,8 @@ enum class Bytecode : uint8_t { ...@@ -133,8 +139,8 @@ enum class Bytecode : uint8_t {
}; };
// An interpreter Reg8ister which is located in the function's Reg8ister file // An interpreter Register which is located in the function's Register file
// in its stack-frame. Reg8ister hold parameters, this, and expression values. // in its stack-frame. Register hold parameters, this, and expression values.
class Register { class Register {
public: public:
static const int kMaxRegisterIndex = 127; static const int kMaxRegisterIndex = 127;
......
...@@ -219,28 +219,52 @@ void Interpreter::DoPropertyLoadIC(Callable ic, ...@@ -219,28 +219,52 @@ void Interpreter::DoPropertyLoadIC(Callable ic,
} }
// LoadIC <object> <slot> // LoadICSloppy <object> <slot>
// //
// Calls the LoadIC at FeedBackVector slot <slot> for <object> and the name // Calls the sloppy mode LoadIC at FeedBackVector slot <slot> for <object> and
// in the accumulator. // the name in the accumulator.
void Interpreter::DoLoadIC(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLoadICSloppy(compiler::InterpreterAssembler* assembler) {
Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF, Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
SLOPPY, UNINITIALIZED); SLOPPY, UNINITIALIZED);
DoPropertyLoadIC(ic, assembler); DoPropertyLoadIC(ic, assembler);
} }
// KeyedLoadIC <object> <slot> // LoadICStrict <object> <slot>
// //
// Calls the KeyedLoadIC at FeedBackVector slot <slot> for <object> and the key // Calls the strict mode LoadIC at FeedBackVector slot <slot> for <object> and
// in the accumulator. // the name in the accumulator.
void Interpreter::DoKeyedLoadIC(compiler::InterpreterAssembler* assembler) { void Interpreter::DoLoadICStrict(compiler::InterpreterAssembler* assembler) {
Callable ic = CodeFactory::LoadICInOptimizedCode(isolate_, NOT_INSIDE_TYPEOF,
STRICT, UNINITIALIZED);
DoPropertyLoadIC(ic, assembler);
}
// KeyedLoadICSloppy <object> <slot>
//
// Calls the sloppy mode KeyedLoadIC at FeedBackVector slot <slot> for <object>
// and the key in the accumulator.
void Interpreter::DoKeyedLoadICSloppy(
compiler::InterpreterAssembler* assembler) {
Callable ic = Callable ic =
CodeFactory::KeyedLoadICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); CodeFactory::KeyedLoadICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
DoPropertyLoadIC(ic, assembler); DoPropertyLoadIC(ic, assembler);
} }
// KeyedLoadICStrict <object> <slot>
//
// Calls the strict mode KeyedLoadIC at FeedBackVector slot <slot> for <object>
// and the key in the accumulator.
void Interpreter::DoKeyedLoadICStrict(
compiler::InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::KeyedLoadICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
DoPropertyLoadIC(ic, assembler);
}
void Interpreter::DoPropertyStoreIC(Callable ic, void Interpreter::DoPropertyStoreIC(Callable ic,
compiler::InterpreterAssembler* assembler) { compiler::InterpreterAssembler* assembler) {
Node* code_target = __ HeapConstant(ic.code()); Node* code_target = __ HeapConstant(ic.code());
...@@ -259,28 +283,52 @@ void Interpreter::DoPropertyStoreIC(Callable ic, ...@@ -259,28 +283,52 @@ void Interpreter::DoPropertyStoreIC(Callable ic,
} }
// StoreIC <object> <name> <slot> // StoreICSloppy <object> <name> <slot>
// //
// Calls the StoreIC at FeedBackVector slot <slot> for <object> and the name // Calls the sloppy mode StoreIC at FeedBackVector slot <slot> for <object> and
// <name> with the value in the accumulator. // the name <name> with the value in the accumulator.
void Interpreter::DoStoreIC(compiler::InterpreterAssembler* assembler) { void Interpreter::DoStoreICSloppy(compiler::InterpreterAssembler* assembler) {
Callable ic = Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); CodeFactory::StoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
DoPropertyStoreIC(ic, assembler); DoPropertyStoreIC(ic, assembler);
} }
// KeyedStoreIC <object> <key> <slot> // StoreICStrict <object> <name> <slot>
// //
// Calls the KeyStoreIC at FeedBackVector slot <slot> for <object> and the key // Calls the strict mode StoreIC at FeedBackVector slot <slot> for <object> and
// <key> with the value in the accumulator. // the name <name> with the value in the accumulator.
void Interpreter::DoKeyedStoreIC(compiler::InterpreterAssembler* assembler) { void Interpreter::DoStoreICStrict(compiler::InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::StoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
DoPropertyStoreIC(ic, assembler);
}
// KeyedStoreICSloppy <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(
compiler::InterpreterAssembler* assembler) {
Callable ic = Callable ic =
CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED); CodeFactory::KeyedStoreICInOptimizedCode(isolate_, SLOPPY, UNINITIALIZED);
DoPropertyStoreIC(ic, assembler); DoPropertyStoreIC(ic, assembler);
} }
// KeyedStoreICStore <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(
compiler::InterpreterAssembler* assembler) {
Callable ic =
CodeFactory::KeyedStoreICInOptimizedCode(isolate_, STRICT, UNINITIALIZED);
DoPropertyStoreIC(ic, assembler);
}
void Interpreter::DoBinaryOp(Runtime::FunctionId function_id, void Interpreter::DoBinaryOp(Runtime::FunctionId function_id,
compiler::InterpreterAssembler* assembler) { compiler::InterpreterAssembler* assembler) {
// TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized // TODO(rmcilroy): Call ICs which back-patch bytecode with type specialized
......
...@@ -155,6 +155,7 @@ using v8::internal::LanguageMode; ...@@ -155,6 +155,7 @@ using v8::internal::LanguageMode;
using v8::internal::Object; using v8::internal::Object;
using v8::internal::Runtime; using v8::internal::Runtime;
using v8::internal::Smi; using v8::internal::Smi;
using v8::internal::Strength;
using v8::internal::Token; using v8::internal::Token;
using namespace v8::internal::interpreter; using namespace v8::internal::interpreter;
...@@ -391,7 +392,7 @@ TEST(InterpreterBinaryOpsSmi) { ...@@ -391,7 +392,7 @@ TEST(InterpreterBinaryOpsSmi) {
builder.LoadLiteral(Smi::FromInt(lhs)) builder.LoadLiteral(Smi::FromInt(lhs))
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadLiteral(Smi::FromInt(rhs)) .LoadLiteral(Smi::FromInt(rhs))
.BinaryOperation(kArithmeticOperators[o], reg) .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -426,7 +427,7 @@ TEST(InterpreterBinaryOpsHeapNumber) { ...@@ -426,7 +427,7 @@ TEST(InterpreterBinaryOpsHeapNumber) {
builder.LoadLiteral(factory->NewNumber(lhs)) builder.LoadLiteral(factory->NewNumber(lhs))
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadLiteral(factory->NewNumber(rhs)) .LoadLiteral(factory->NewNumber(rhs))
.BinaryOperation(kArithmeticOperators[o], reg) .BinaryOperation(kArithmeticOperators[o], reg, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -482,7 +483,7 @@ TEST(InterpreterStringAdd) { ...@@ -482,7 +483,7 @@ TEST(InterpreterStringAdd) {
builder.LoadLiteral(test_cases[i].lhs) builder.LoadLiteral(test_cases[i].lhs)
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadLiteral(test_cases[i].rhs) .LoadLiteral(test_cases[i].rhs)
.BinaryOperation(Token::Value::ADD, reg) .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -523,13 +524,13 @@ TEST(InterpreterParameter8) { ...@@ -523,13 +524,13 @@ TEST(InterpreterParameter8) {
builder.set_locals_count(0); builder.set_locals_count(0);
builder.set_parameter_count(8); builder.set_parameter_count(8);
builder.LoadAccumulatorWithRegister(builder.Parameter(0)) builder.LoadAccumulatorWithRegister(builder.Parameter(0))
.BinaryOperation(Token::Value::ADD, builder.Parameter(1)) .BinaryOperation(Token::Value::ADD, builder.Parameter(1), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(2)) .BinaryOperation(Token::Value::ADD, builder.Parameter(2), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(3)) .BinaryOperation(Token::Value::ADD, builder.Parameter(3), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(4)) .BinaryOperation(Token::Value::ADD, builder.Parameter(4), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(5)) .BinaryOperation(Token::Value::ADD, builder.Parameter(5), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(6)) .BinaryOperation(Token::Value::ADD, builder.Parameter(6), Strength::WEAK)
.BinaryOperation(Token::Value::ADD, builder.Parameter(7)) .BinaryOperation(Token::Value::ADD, builder.Parameter(7), Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -663,7 +664,7 @@ TEST(InterpreterLoadKeyedProperty) { ...@@ -663,7 +664,7 @@ TEST(InterpreterLoadKeyedProperty) {
builder.set_parameter_count(1); builder.set_parameter_count(1);
builder.LoadLiteral(key) builder.LoadLiteral(key)
.LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot), .LoadKeyedProperty(builder.Parameter(0), vector->GetIndex(slot),
i::SLOPPY) i::STRICT)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -709,7 +710,7 @@ TEST(InterpreterStoreNamedProperty) { ...@@ -709,7 +710,7 @@ TEST(InterpreterStoreNamedProperty) {
.StoreAccumulatorInRegister(Register(0)) .StoreAccumulatorInRegister(Register(0))
.LoadLiteral(Smi::FromInt(999)) .LoadLiteral(Smi::FromInt(999))
.StoreNamedProperty(builder.Parameter(0), Register(0), .StoreNamedProperty(builder.Parameter(0), Register(0),
vector->GetIndex(slot), i::SLOPPY) vector->GetIndex(slot), i::STRICT)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -955,7 +956,7 @@ static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder& builder, ...@@ -955,7 +956,7 @@ static BytecodeArrayBuilder& IncrementRegister(BytecodeArrayBuilder& builder,
Register scratch) { Register scratch) {
return builder.StoreAccumulatorInRegister(scratch) return builder.StoreAccumulatorInRegister(scratch)
.LoadLiteral(Smi::FromInt(value)) .LoadLiteral(Smi::FromInt(value))
.BinaryOperation(Token::Value::ADD, reg) .BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
.StoreAccumulatorInRegister(reg) .StoreAccumulatorInRegister(reg)
.LoadAccumulatorWithRegister(scratch); .LoadAccumulatorWithRegister(scratch);
} }
...@@ -1085,7 +1086,7 @@ TEST(InterpreterSmiComparisons) { ...@@ -1085,7 +1086,7 @@ TEST(InterpreterSmiComparisons) {
builder.LoadLiteral(Smi::FromInt(inputs[i])) builder.LoadLiteral(Smi::FromInt(inputs[i]))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(Smi::FromInt(inputs[j])) .LoadLiteral(Smi::FromInt(inputs[j]))
.CompareOperation(comparison, r0, LanguageMode::SLOPPY) .CompareOperation(comparison, r0, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -1123,7 +1124,7 @@ TEST(InterpreterHeapNumberComparisons) { ...@@ -1123,7 +1124,7 @@ TEST(InterpreterHeapNumberComparisons) {
builder.LoadLiteral(factory->NewHeapNumber(inputs[i])) builder.LoadLiteral(factory->NewHeapNumber(inputs[i]))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(factory->NewHeapNumber(inputs[j])) .LoadLiteral(factory->NewHeapNumber(inputs[j]))
.CompareOperation(comparison, r0, LanguageMode::SLOPPY) .CompareOperation(comparison, r0, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -1158,7 +1159,7 @@ TEST(InterpreterStringComparisons) { ...@@ -1158,7 +1159,7 @@ TEST(InterpreterStringComparisons) {
builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs)) builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(factory->NewStringFromAsciiChecked(rhs)) .LoadLiteral(factory->NewStringFromAsciiChecked(rhs))
.CompareOperation(comparison, r0, LanguageMode::SLOPPY) .CompareOperation(comparison, r0, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -1206,14 +1207,14 @@ TEST(InterpreterMixedComparisons) { ...@@ -1206,14 +1207,14 @@ TEST(InterpreterMixedComparisons) {
builder.LoadLiteral(factory->NewNumber(lhs)) builder.LoadLiteral(factory->NewNumber(lhs))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr)) .LoadLiteral(factory->NewStringFromAsciiChecked(rhs_cstr))
.CompareOperation(comparison, r0, LanguageMode::SLOPPY) .CompareOperation(comparison, r0, Strength::WEAK)
.Return(); .Return();
} else { } else {
// Comparison with HeapNumber on the rhs and String on the lhs // Comparison with HeapNumber on the rhs and String on the lhs
builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr)) builder.LoadLiteral(factory->NewStringFromAsciiChecked(lhs_cstr))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(factory->NewNumber(rhs)) .LoadLiteral(factory->NewNumber(rhs))
.CompareOperation(comparison, r0, LanguageMode::SLOPPY) .CompareOperation(comparison, r0, Strength::WEAK)
.Return(); .Return();
} }
...@@ -1248,7 +1249,7 @@ TEST(InterpreterInstanceOf) { ...@@ -1248,7 +1249,7 @@ TEST(InterpreterInstanceOf) {
builder.LoadLiteral(cases[i]); builder.LoadLiteral(cases[i]);
builder.StoreAccumulatorInRegister(r0) builder.StoreAccumulatorInRegister(r0)
.LoadLiteral(func) .LoadLiteral(func)
.CompareOperation(Token::Value::INSTANCEOF, r0, LanguageMode::SLOPPY) .CompareOperation(Token::Value::INSTANCEOF, r0, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
...@@ -1278,7 +1279,7 @@ TEST(InterpreterTestIn) { ...@@ -1278,7 +1279,7 @@ TEST(InterpreterTestIn) {
builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i])) builder.LoadLiteral(factory->NewStringFromAsciiChecked(properties[i]))
.StoreAccumulatorInRegister(r0) .StoreAccumulatorInRegister(r0)
.LoadLiteral(Handle<Object>::cast(array)) .LoadLiteral(Handle<Object>::cast(array))
.CompareOperation(Token::Value::IN, r0, LanguageMode::SLOPPY) .CompareOperation(Token::Value::IN, r0, Strength::WEAK)
.Return(); .Return();
Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
......
...@@ -207,7 +207,8 @@ TEST_F(BytecodeGraphBuilderTest, SimpleExpressionWithParameters) { ...@@ -207,7 +207,8 @@ TEST_F(BytecodeGraphBuilderTest, SimpleExpressionWithParameters) {
array_builder()->set_parameter_count(3); array_builder()->set_parameter_count(3);
array_builder() array_builder()
->LoadAccumulatorWithRegister(array_builder()->Parameter(1)) ->LoadAccumulatorWithRegister(array_builder()->Parameter(1))
.BinaryOperation(Token::Value::ADD, array_builder()->Parameter(2)) .BinaryOperation(Token::Value::ADD, array_builder()->Parameter(2),
Strength::WEAK)
.StoreAccumulatorInRegister(interpreter::Register(0)) .StoreAccumulatorInRegister(interpreter::Register(0))
.Return(); .Return();
...@@ -231,7 +232,8 @@ TEST_F(BytecodeGraphBuilderTest, SimpleExpressionWithRegister) { ...@@ -231,7 +232,8 @@ TEST_F(BytecodeGraphBuilderTest, SimpleExpressionWithRegister) {
->LoadLiteral(Smi::FromInt(kLeft)) ->LoadLiteral(Smi::FromInt(kLeft))
.StoreAccumulatorInRegister(interpreter::Register(0)) .StoreAccumulatorInRegister(interpreter::Register(0))
.LoadLiteral(Smi::FromInt(kRight)) .LoadLiteral(Smi::FromInt(kRight))
.BinaryOperation(Token::Value::ADD, interpreter::Register(0)) .BinaryOperation(Token::Value::ADD, interpreter::Register(0),
Strength::WEAK)
.Return(); .Return();
Graph* graph = GetCompletedGraph(); Graph* graph = GetCompletedGraph();
......
...@@ -47,33 +47,37 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) { ...@@ -47,33 +47,37 @@ TEST_F(BytecodeArrayBuilderTest, AllBytecodesGenerated) {
builder.LoadNamedProperty(reg, 0, LanguageMode::SLOPPY) builder.LoadNamedProperty(reg, 0, LanguageMode::SLOPPY)
.LoadKeyedProperty(reg, 0, LanguageMode::SLOPPY) .LoadKeyedProperty(reg, 0, LanguageMode::SLOPPY)
.StoreNamedProperty(reg, reg, 0, LanguageMode::SLOPPY) .StoreNamedProperty(reg, reg, 0, LanguageMode::SLOPPY)
.StoreKeyedProperty(reg, reg, 0, LanguageMode::SLOPPY); .StoreKeyedProperty(reg, reg, 0, LanguageMode::SLOPPY)
.LoadNamedProperty(reg, 0, LanguageMode::STRICT)
.LoadKeyedProperty(reg, 0, LanguageMode::STRICT)
.StoreNamedProperty(reg, reg, 0, LanguageMode::STRICT)
.StoreKeyedProperty(reg, reg, 0, LanguageMode::STRICT);
// Call operations. // Call operations.
builder.Call(reg, reg, 0); builder.Call(reg, reg, 0);
builder.CallRuntime(Runtime::kIsArray, reg, 1); builder.CallRuntime(Runtime::kIsArray, reg, 1);
// Emit binary operator invocations. // Emit binary operator invocations.
builder.BinaryOperation(Token::Value::ADD, reg) builder.BinaryOperation(Token::Value::ADD, reg, Strength::WEAK)
.BinaryOperation(Token::Value::SUB, reg) .BinaryOperation(Token::Value::SUB, reg, Strength::WEAK)
.BinaryOperation(Token::Value::MUL, reg) .BinaryOperation(Token::Value::MUL, reg, Strength::WEAK)
.BinaryOperation(Token::Value::DIV, reg) .BinaryOperation(Token::Value::DIV, reg, Strength::WEAK)
.BinaryOperation(Token::Value::MOD, reg); .BinaryOperation(Token::Value::MOD, reg, Strength::WEAK);
// Emit unary operator invocations. // Emit unary operator invocations.
builder.LogicalNot().TypeOf(); builder.LogicalNot().TypeOf();
// Emit test operator invocations. // Emit test operator invocations.
builder.CompareOperation(Token::Value::EQ, reg, LanguageMode::SLOPPY) builder.CompareOperation(Token::Value::EQ, reg, Strength::WEAK)
.CompareOperation(Token::Value::NE, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::NE, reg, Strength::WEAK)
.CompareOperation(Token::Value::EQ_STRICT, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::EQ_STRICT, reg, Strength::WEAK)
.CompareOperation(Token::Value::NE_STRICT, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::NE_STRICT, reg, Strength::WEAK)
.CompareOperation(Token::Value::LT, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::LT, reg, Strength::WEAK)
.CompareOperation(Token::Value::GT, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::GT, reg, Strength::WEAK)
.CompareOperation(Token::Value::LTE, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::LTE, reg, Strength::WEAK)
.CompareOperation(Token::Value::GTE, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::GTE, reg, Strength::WEAK)
.CompareOperation(Token::Value::INSTANCEOF, reg, LanguageMode::SLOPPY) .CompareOperation(Token::Value::INSTANCEOF, reg, Strength::WEAK)
.CompareOperation(Token::Value::IN, reg, LanguageMode::SLOPPY); .CompareOperation(Token::Value::IN, reg, Strength::WEAK);
// Emit cast operator invocations. // Emit cast operator invocations.
builder.LoadNull().CastAccumulatorToBoolean(); builder.LoadNull().CastAccumulatorToBoolean();
......
...@@ -79,7 +79,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { ...@@ -79,7 +79,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
CHECK(!iterator.done()); CHECK(!iterator.done());
iterator.Advance(); iterator.Advance();
CHECK_EQ(iterator.current_bytecode(), Bytecode::kLoadIC); CHECK_EQ(iterator.current_bytecode(), Bytecode::kLoadICSloppy);
CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index()); CHECK_EQ(iterator.GetRegisterOperand(0).index(), reg_1.index());
CHECK_EQ(iterator.GetIndexOperand(1), feedback_slot); CHECK_EQ(iterator.GetIndexOperand(1), feedback_slot);
CHECK(!iterator.done()); CHECK(!iterator.done());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment