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

Unified Diff: src/interpreter/interpreter.cc

Issue 2552883012: [interpreter][stubs] Fixing issues found by machine graph verifier. (Closed)
Patch Set: Created 4 years 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 5b484cca78e1558c880bbf89b5f219243eb04ee6..3ab1cc3ce4ab2ecb943b072607669f5bee249342 100644
--- a/src/interpreter/interpreter.cc
+++ b/src/interpreter/interpreter.cc
@@ -98,6 +98,11 @@ void Interpreter::InstallBytecodeHandler(Zone* zone, Bytecode bytecode,
BytecodeGeneratorFunc generator) {
if (!Bytecodes::BytecodeHasHandler(bytecode, operand_scale)) return;
+ // TODO(ishell): remove this when code stub assembler graphs verification
+ // is enabled for all stubs.
+ bool sav_csa_verify = FLAG_csa_verify;
+ FLAG_csa_verify = DEBUG_BOOL;
+
InterpreterDispatchDescriptor descriptor(isolate_);
compiler::CodeAssemblerState state(
isolate_, zone, descriptor, Code::ComputeFlags(Code::BYTECODE_HANDLER),
@@ -112,6 +117,7 @@ void Interpreter::InstallBytecodeHandler(Zone* zone, Bytecode bytecode,
CodeEventListener::BYTECODE_HANDLER_TAG,
AbstractCode::cast(*code),
Bytecodes::ToString(bytecode, operand_scale).c_str()));
+ FLAG_csa_verify = sav_csa_verify;
}
Code* Interpreter::GetBytecodeHandler(Bytecode bytecode,
@@ -885,7 +891,8 @@ void Interpreter::DoLdaModuleVariable(InterpreterAssembler* assembler) {
__ LoadObjectField(module, Module::kRegularExportsOffset);
// The actual array index is (cell_index - 1).
Node* export_index = __ IntPtrSub(cell_index, __ IntPtrConstant(1));
- Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
+ Node* cell = __ LoadFixedArrayElement(regular_exports, export_index, 0,
+ CodeStubAssembler::INTPTR_PARAMETERS);
__ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
__ Goto(&end);
}
@@ -896,7 +903,8 @@ void Interpreter::DoLdaModuleVariable(InterpreterAssembler* assembler) {
__ LoadObjectField(module, Module::kRegularImportsOffset);
// The actual array index is (-cell_index - 1).
Node* import_index = __ IntPtrSub(__ IntPtrConstant(-1), cell_index);
- Node* cell = __ LoadFixedArrayElement(regular_imports, import_index);
+ Node* cell = __ LoadFixedArrayElement(regular_imports, import_index, 0,
+ CodeStubAssembler::INTPTR_PARAMETERS);
__ SetAccumulator(__ LoadObjectField(cell, Cell::kValueOffset));
__ Goto(&end);
}
@@ -928,7 +936,8 @@ void Interpreter::DoStaModuleVariable(InterpreterAssembler* assembler) {
__ LoadObjectField(module, Module::kRegularExportsOffset);
// The actual array index is (cell_index - 1).
Node* export_index = __ IntPtrSub(cell_index, __ IntPtrConstant(1));
- Node* cell = __ LoadFixedArrayElement(regular_exports, export_index);
+ Node* cell = __ LoadFixedArrayElement(regular_exports, export_index, 0,
+ CodeStubAssembler::INTPTR_PARAMETERS);
__ StoreObjectField(cell, Cell::kValueOffset, value);
__ Goto(&end);
}
@@ -1359,7 +1368,8 @@ void Interpreter::DoAddSmi(InterpreterAssembler* assembler) {
AddWithFeedbackStub stub(__ isolate());
Callable callable =
Callable(stub.GetCode(), AddWithFeedbackStub::Descriptor(__ isolate()));
- Node* args[] = {left, right, slot_index, type_feedback_vector, context};
+ Node* args[] = {left, right, __ TruncateWordToWord32(slot_index),
+ type_feedback_vector, context};
var_result.Bind(__ CallStubN(callable, args, 1));
__ Goto(&end);
}
@@ -1413,7 +1423,8 @@ void Interpreter::DoSubSmi(InterpreterAssembler* assembler) {
SubtractWithFeedbackStub stub(__ isolate());
Callable callable = Callable(
stub.GetCode(), SubtractWithFeedbackStub::Descriptor(__ isolate()));
- Node* args[] = {left, right, slot_index, type_feedback_vector, context};
+ Node* args[] = {left, right, __ TruncateWordToWord32(slot_index),
+ type_feedback_vector, context};
var_result.Bind(__ CallStubN(callable, args, 1));
__ Goto(&end);
}
@@ -1704,8 +1715,8 @@ void Interpreter::DoJSCall(InterpreterAssembler* assembler,
Node* receiver_reg = __ BytecodeOperandReg(1);
Node* receiver_arg = __ RegisterLocation(receiver_reg);
Node* receiver_args_count = __ BytecodeOperandCount(2);
- Node* receiver_count = __ Int32Constant(1);
- Node* args_count = __ Int32Sub(receiver_args_count, receiver_count);
+ Node* receiver_count = __ IntPtrConstant(1);
+ Node* args_count = __ IntPtrSub(receiver_args_count, receiver_count);
Node* slot_id = __ BytecodeOperandIdx(3);
Node* type_feedback_vector = __ LoadTypeFeedbackVector();
Node* context = __ GetContext();
@@ -1813,8 +1824,8 @@ void Interpreter::DoCallJSRuntime(InterpreterAssembler* assembler) {
Node* receiver_reg = __ BytecodeOperandReg(1);
Node* first_arg = __ RegisterLocation(receiver_reg);
Node* receiver_args_count = __ BytecodeOperandCount(2);
- Node* receiver_count = __ Int32Constant(1);
- Node* args_count = __ Int32Sub(receiver_args_count, receiver_count);
+ Node* receiver_count = __ IntPtrConstant(1);
+ Node* args_count = __ IntPtrSub(receiver_args_count, receiver_count);
// Get the function to call from the native context.
Node* context = __ GetContext();
@@ -1841,7 +1852,7 @@ void Interpreter::DoNewWithSpread(InterpreterAssembler* assembler) {
Node* context = __ GetContext();
// Call into Runtime function NewWithSpread which does everything.
- Node* runtime_function = __ Int32Constant(Runtime::kNewWithSpread);
+ Node* runtime_function = __ IntPtrConstant(Runtime::kNewWithSpread);
Node* result =
__ CallRuntimeN(runtime_function, context, first_arg, args_count);
__ SetAccumulator(result);
@@ -2226,7 +2237,7 @@ void Interpreter::DoJumpLoop(InterpreterAssembler* assembler) {
// Check if OSR points at the given {loop_depth} are armed by comparing it to
// the current {osr_level} loaded from the header of the BytecodeArray.
Label ok(assembler), osr_armed(assembler, Label::kDeferred);
- Node* condition = __ Int32GreaterThanOrEqual(loop_depth, osr_level);
+ Node* condition = __ IntPtrGreaterThanOrEqual(loop_depth, osr_level);
__ Branch(condition, &ok, &osr_armed);
__ Bind(&ok);
@@ -2274,10 +2285,9 @@ void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) {
Label fast_shallow_clone(assembler),
call_runtime(assembler, Label::kDeferred);
- Node* use_fast_shallow_clone = __ Word32And(
- bytecode_flags,
- __ Int32Constant(CreateArrayLiteralFlags::FastShallowCloneBit::kMask));
- __ Branch(use_fast_shallow_clone, &fast_shallow_clone, &call_runtime);
+ __ Branch(__ IsSetWord<CreateArrayLiteralFlags::FastShallowCloneBit>(
+ bytecode_flags),
+ &fast_shallow_clone, &call_runtime);
__ Bind(&fast_shallow_clone);
{
@@ -2291,10 +2301,8 @@ void Interpreter::DoCreateArrayLiteral(InterpreterAssembler* assembler) {
__ Bind(&call_runtime);
{
- STATIC_ASSERT(CreateArrayLiteralFlags::FlagsBits::kShift == 0);
- Node* flags_raw = __ Word32And(
- bytecode_flags,
- __ Int32Constant(CreateArrayLiteralFlags::FlagsBits::kMask));
+ Node* flags_raw =
+ __ DecodeWord<CreateArrayLiteralFlags::FlagsBits>(bytecode_flags);
Node* flags = __ SmiTag(flags_raw);
Node* index = __ BytecodeOperandIdx(0);
Node* constant_elements = __ LoadConstantPoolEntry(index);
@@ -2320,9 +2328,10 @@ void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) {
Label if_fast_clone(assembler),
if_not_fast_clone(assembler, Label::kDeferred);
Node* fast_clone_properties_count =
- __ DecodeWord32<CreateObjectLiteralFlags::FastClonePropertiesCountBits>(
+ __ DecodeWord<CreateObjectLiteralFlags::FastClonePropertiesCountBits>(
bytecode_flags);
- __ Branch(fast_clone_properties_count, &if_fast_clone, &if_not_fast_clone);
+ __ Branch(__ WordNotEqual(fast_clone_properties_count, __ IntPtrConstant(0)),
+ &if_fast_clone, &if_not_fast_clone);
__ Bind(&if_fast_clone);
{
@@ -2341,10 +2350,8 @@ void Interpreter::DoCreateObjectLiteral(InterpreterAssembler* assembler) {
Node* constant_elements = __ LoadConstantPoolEntry(index);
Node* context = __ GetContext();
- STATIC_ASSERT(CreateObjectLiteralFlags::FlagsBits::kShift == 0);
- Node* flags_raw = __ Word32And(
- bytecode_flags,
- __ Int32Constant(CreateObjectLiteralFlags::FlagsBits::kMask));
+ Node* flags_raw =
+ __ DecodeWord<CreateObjectLiteralFlags::FlagsBits>(bytecode_flags);
Node* flags = __ SmiTag(flags_raw);
Node* result =
@@ -2367,17 +2374,14 @@ void Interpreter::DoCreateClosure(InterpreterAssembler* assembler) {
Node* context = __ GetContext();
Label call_runtime(assembler, Label::kDeferred);
- Node* fast_new_closure = __ Word32And(
- flags, __ Int32Constant(CreateClosureFlags::FastNewClosureBit::kMask));
- __ GotoUnless(fast_new_closure, &call_runtime);
+ __ GotoUnless(__ IsSetWord<CreateClosureFlags::FastNewClosureBit>(flags),
+ &call_runtime);
__ SetAccumulator(FastNewClosureStub::Generate(assembler, shared, context));
__ Dispatch();
__ Bind(&call_runtime);
{
- STATIC_ASSERT(CreateClosureFlags::PretenuredBit::kShift == 0);
- Node* tenured_raw = __ Word32And(
- flags, __ Int32Constant(CreateClosureFlags::PretenuredBit::kMask));
+ Node* tenured_raw = __ DecodeWord<CreateClosureFlags::PretenuredBit>(flags);
Node* tenured = __ SmiTag(tenured_raw);
Node* result = __ CallRuntime(Runtime::kInterpreterNewClosure, context,
shared, tenured);
@@ -2729,7 +2733,8 @@ void Interpreter::DoForInNext(InterpreterAssembler* assembler) {
Node* megamorphic_sentinel =
__ HeapConstant(TypeFeedbackVector::MegamorphicSentinel(isolate_));
__ StoreFixedArrayElement(type_feedback_vector, vector_index,
- megamorphic_sentinel, SKIP_WRITE_BARRIER);
+ megamorphic_sentinel, SKIP_WRITE_BARRIER, 0,
+ CodeStubAssembler::INTPTR_PARAMETERS);
// Need to filter the {key} for the {receiver}.
Node* context = __ GetContext();

Powered by Google App Engine
This is Rietveld 408576698