From 6003ed04890cac8bcfe7b4adb9b33f819fa508d4 Mon Sep 17 00:00:00 2001 From: rmcilroy Date: Tue, 21 Jun 2016 07:37:16 -0700 Subject: [PATCH] Reland: [Interpreter] Map runtime id's to intrinsic id's in InvokeIntrinsic bytecode. Make intrinsic ids a contiguous set of ids so that the switch statement can build a table switch rather than doing a large if/else tree. BUG=v8:4822 LOG=N Committed: https://crrev.com/36abd28a8d9932eb55d7c2bf3ad5e7cfe3eb99ea Review-Url: https://codereview.chromium.org/2084623002 Cr-Original-Commit-Position: refs/heads/master@{#37135} Cr-Commit-Position: refs/heads/master@{#37145} --- src/compiler/bytecode-graph-builder.cc | 9 +- src/interpreter/bytecode-array-builder.cc | 16 ++- src/interpreter/bytecode-array-iterator.cc | 17 ++- src/interpreter/bytecode-array-iterator.h | 4 +- src/interpreter/bytecodes.cc | 1 + src/interpreter/bytecodes.h | 3 +- src/interpreter/interpreter-assembler.cc | 9 ++ src/interpreter/interpreter-assembler.h | 3 + src/interpreter/interpreter-intrinsics.cc | 33 +++++- src/interpreter/interpreter-intrinsics.h | 14 ++- src/interpreter/interpreter.cc | 2 +- .../bytecode-expectations-printer.cc | 19 ++-- .../bytecode_expectations/ForOf.golden | 104 +++++++++--------- .../bytecode_expectations/Generators.golden | 26 ++--- .../bytecode-array-iterator-unittest.cc | 3 +- .../interpreter-assembler-unittest.cc | 4 + 16 files changed, 172 insertions(+), 95 deletions(-) diff --git a/src/compiler/bytecode-graph-builder.cc b/src/compiler/bytecode-graph-builder.cc index dbdda35039..3de472f322 100644 --- a/src/compiler/bytecode-graph-builder.cc +++ b/src/compiler/bytecode-graph-builder.cc @@ -1001,8 +1001,7 @@ Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( void BytecodeGraphBuilder::VisitCallRuntime() { FrameStateBeforeAndAfter states(this); - Runtime::FunctionId functionId = static_cast( - bytecode_iterator().GetRuntimeIdOperand(0)); + Runtime::FunctionId functionId = bytecode_iterator().GetRuntimeIdOperand(0); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); @@ -1014,8 +1013,7 @@ void BytecodeGraphBuilder::VisitCallRuntime() { void BytecodeGraphBuilder::VisitCallRuntimeForPair() { FrameStateBeforeAndAfter states(this); - Runtime::FunctionId functionId = static_cast( - bytecode_iterator().GetRuntimeIdOperand(0)); + Runtime::FunctionId functionId = bytecode_iterator().GetRuntimeIdOperand(0); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); interpreter::Register first_return = @@ -1029,8 +1027,7 @@ void BytecodeGraphBuilder::VisitCallRuntimeForPair() { void BytecodeGraphBuilder::VisitInvokeIntrinsic() { FrameStateBeforeAndAfter states(this); - Runtime::FunctionId functionId = static_cast( - bytecode_iterator().GetRuntimeIdOperand(0)); + Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); diff --git a/src/interpreter/bytecode-array-builder.cc b/src/interpreter/bytecode-array-builder.cc index cf49292fa4..721c321287 100644 --- a/src/interpreter/bytecode-array-builder.cc +++ b/src/interpreter/bytecode-array-builder.cc @@ -581,11 +581,16 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime( DCHECK_EQ(0u, arg_count); first_arg = Register(0); } - Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) - ? Bytecode::kInvokeIntrinsic - : Bytecode::kCallRuntime; - Output(bytecode, static_cast(function_id), - RegisterOperand(first_arg), UnsignedOperand(arg_count)); + Bytecode bytecode; + uint32_t id; + if (IntrinsicsHelper::IsSupported(function_id)) { + bytecode = Bytecode::kInvokeIntrinsic; + id = static_cast(IntrinsicsHelper::FromRuntimeId(function_id)); + } else { + bytecode = Bytecode::kCallRuntime; + id = static_cast(function_id); + } + Output(bytecode, id, RegisterOperand(first_arg), UnsignedOperand(arg_count)); return *this; } @@ -694,6 +699,7 @@ bool BytecodeArrayBuilder::OperandsAreValid( break; } case OperandType::kFlag8: + case OperandType::kIntrinsicId: if (Bytecodes::SizeForUnsignedOperand(operands[i]) > OperandSize::kByte) { return false; diff --git a/src/interpreter/bytecode-array-iterator.cc b/src/interpreter/bytecode-array-iterator.cc index 319d2a07bb..a4a8f799a3 100644 --- a/src/interpreter/bytecode-array-iterator.cc +++ b/src/interpreter/bytecode-array-iterator.cc @@ -4,6 +4,7 @@ #include "src/interpreter/bytecode-array-iterator.h" +#include "src/interpreter/interpreter-intrinsics.h" #include "src/objects-inl.h" namespace v8 { @@ -140,11 +141,23 @@ int BytecodeArrayIterator::GetRegisterOperandRange(int operand_index) const { } } -uint32_t BytecodeArrayIterator::GetRuntimeIdOperand(int operand_index) const { +Runtime::FunctionId BytecodeArrayIterator::GetRuntimeIdOperand( + int operand_index) const { OperandType operand_type = Bytecodes::GetOperandType(current_bytecode(), operand_index); DCHECK(operand_type == OperandType::kRuntimeId); - return GetUnsignedOperand(operand_index, operand_type); + uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type); + return static_cast(raw_id); +} + +Runtime::FunctionId BytecodeArrayIterator::GetIntrinsicIdOperand( + int operand_index) const { + OperandType operand_type = + Bytecodes::GetOperandType(current_bytecode(), operand_index); + DCHECK(operand_type == OperandType::kIntrinsicId); + uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type); + return IntrinsicsHelper::ToRuntimeId( + static_cast(raw_id)); } Handle BytecodeArrayIterator::GetConstantForIndexOperand( diff --git a/src/interpreter/bytecode-array-iterator.h b/src/interpreter/bytecode-array-iterator.h index b372894fd8..90001ef293 100644 --- a/src/interpreter/bytecode-array-iterator.h +++ b/src/interpreter/bytecode-array-iterator.h @@ -8,6 +8,7 @@ #include "src/handles.h" #include "src/interpreter/bytecodes.h" #include "src/objects.h" +#include "src/runtime/runtime.h" namespace v8 { namespace internal { @@ -34,7 +35,8 @@ class BytecodeArrayIterator { uint32_t GetRegisterCountOperand(int operand_index) const; Register GetRegisterOperand(int operand_index) const; int GetRegisterOperandRange(int operand_index) const; - uint32_t GetRuntimeIdOperand(int operand_index) const; + Runtime::FunctionId GetRuntimeIdOperand(int operand_index) const; + Runtime::FunctionId GetIntrinsicIdOperand(int operand_index) const; Handle GetConstantForIndexOperand(int operand_index) const; // Returns the absolute offset of the branch target at the current diff --git a/src/interpreter/bytecodes.cc b/src/interpreter/bytecodes.cc index 826d557eb0..44c513893d 100644 --- a/src/interpreter/bytecodes.cc +++ b/src/interpreter/bytecodes.cc @@ -737,6 +737,7 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start, break; case interpreter::OperandType::kIdx: case interpreter::OperandType::kRuntimeId: + case interpreter::OperandType::kIntrinsicId: os << "[" << DecodeUnsignedOperand(operand_start, op_type, operand_scale) << "]"; diff --git a/src/interpreter/bytecodes.h b/src/interpreter/bytecodes.h index dbd5419b84..0e0137fcab 100644 --- a/src/interpreter/bytecodes.h +++ b/src/interpreter/bytecodes.h @@ -30,6 +30,7 @@ namespace interpreter { #define SCALAR_OPERAND_TYPE_LIST(V) \ V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \ + V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \ V(Idx, OperandTypeInfo::kScalableUnsignedByte) \ V(Imm, OperandTypeInfo::kScalableSignedByte) \ V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \ @@ -180,7 +181,7 @@ namespace interpreter { OperandType::kReg, OperandType::kRegCount) \ \ /* Intrinsics */ \ - V(InvokeIntrinsic, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ + V(InvokeIntrinsic, AccumulatorUse::kWrite, OperandType::kIntrinsicId, \ OperandType::kMaybeReg, OperandType::kRegCount) \ \ /* New operator */ \ diff --git a/src/interpreter/interpreter-assembler.cc b/src/interpreter/interpreter-assembler.cc index d878c5c693..cd17e4cada 100644 --- a/src/interpreter/interpreter-assembler.cc +++ b/src/interpreter/interpreter-assembler.cc @@ -363,6 +363,15 @@ Node* InterpreterAssembler::BytecodeOperandRuntimeId(int operand_index) { return BytecodeUnsignedOperand(operand_index, operand_size); } +Node* InterpreterAssembler::BytecodeOperandIntrinsicId(int operand_index) { + DCHECK(OperandType::kIntrinsicId == + Bytecodes::GetOperandType(bytecode_, operand_index)); + OperandSize operand_size = + Bytecodes::GetOperandSize(bytecode_, operand_index, operand_scale()); + DCHECK_EQ(operand_size, OperandSize::kByte); + return BytecodeUnsignedOperand(operand_index, operand_size); +} + Node* InterpreterAssembler::LoadConstantPoolEntry(Node* index) { Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), BytecodeArray::kConstantPoolOffset); diff --git a/src/interpreter/interpreter-assembler.h b/src/interpreter/interpreter-assembler.h index facc7ca7b7..a8ab443348 100644 --- a/src/interpreter/interpreter-assembler.h +++ b/src/interpreter/interpreter-assembler.h @@ -41,6 +41,9 @@ class InterpreterAssembler : public CodeStubAssembler { // Returns the runtime id immediate for bytecode operand // |operand_index| in the current bytecode. compiler::Node* BytecodeOperandRuntimeId(int operand_index); + // Returns the intrinsic id immediate for bytecode operand + // |operand_index| in the current bytecode. + compiler::Node* BytecodeOperandIntrinsicId(int operand_index); // Accumulator. compiler::Node* GetAccumulator(); diff --git a/src/interpreter/interpreter-intrinsics.cc b/src/interpreter/interpreter-intrinsics.cc index f961b3b29a..bf1f7d3e46 100644 --- a/src/interpreter/interpreter-intrinsics.cc +++ b/src/interpreter/interpreter-intrinsics.cc @@ -15,6 +15,7 @@ using compiler::Node; IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler) : assembler_(assembler) {} +// static bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) { switch (function_id) { #define SUPPORTED(name, lower_case, count) case Runtime::kInline##name: @@ -26,6 +27,36 @@ bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) { } } +// static +IntrinsicsHelper::IntrinsicId IntrinsicsHelper::FromRuntimeId( + Runtime::FunctionId function_id) { + switch (function_id) { +#define TO_RUNTIME_ID(name, lower_case, count) \ + case Runtime::kInline##name: \ + return IntrinsicId::k##name; + INTRINSICS_LIST(TO_RUNTIME_ID) +#undef TO_RUNTIME_ID + default: + UNREACHABLE(); + return static_cast(-1); + } +} + +// static +Runtime::FunctionId IntrinsicsHelper::ToRuntimeId( + IntrinsicsHelper::IntrinsicId intrinsic_id) { + switch (intrinsic_id) { +#define TO_INTRINSIC_ID(name, lower_case, count) \ + case IntrinsicId::k##name: \ + return Runtime::kInline##name; + INTRINSICS_LIST(TO_INTRINSIC_ID) +#undef TO_INTRINSIC_ID + default: + UNREACHABLE(); + return static_cast(-1); + } +} + Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context, Node* first_arg_reg, Node* arg_count) { InterpreterAssembler::Label abort(assembler_), end(assembler_); @@ -42,7 +73,7 @@ Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context, #undef LABEL_POINTER #define CASE(name, lower_case, count) \ - static_cast(Runtime::kInline##name), + static_cast(IntrinsicId::k##name), int32_t cases[] = {INTRINSICS_LIST(CASE)}; #undef CASE diff --git a/src/interpreter/interpreter-intrinsics.h b/src/interpreter/interpreter-intrinsics.h index 8606235a2e..fdb7e9b7ff 100644 --- a/src/interpreter/interpreter-intrinsics.h +++ b/src/interpreter/interpreter-intrinsics.h @@ -20,6 +20,8 @@ namespace compiler { class Node; } // namespace compiler +namespace interpreter { + // List of supported intrisics, with upper case name, lower case name and // expected number of arguments (-1 denoting argument count is variable). #define INTRINSICS_LIST(V) \ @@ -31,10 +33,16 @@ class Node; V(IsSmi, is_smi, 1) \ V(IsTypedArray, is_typed_array, 1) -namespace interpreter { - class IntrinsicsHelper { public: + enum class IntrinsicId { +#define DECLARE_INTRINSIC_ID(name, lower_case, count) k##name, + INTRINSICS_LIST(DECLARE_INTRINSIC_ID) +#undef DECLARE_INTRINSIC_ID + kIdCount + }; + STATIC_ASSERT(static_cast(IntrinsicId::kIdCount) <= kMaxUInt8); + explicit IntrinsicsHelper(InterpreterAssembler* assembler); compiler::Node* InvokeIntrinsic(compiler::Node* function_id, @@ -43,6 +51,8 @@ class IntrinsicsHelper { compiler::Node* arg_count); static bool IsSupported(Runtime::FunctionId function_id); + static IntrinsicId FromRuntimeId(Runtime::FunctionId function_id); + static Runtime::FunctionId ToRuntimeId(IntrinsicId intrinsic_id); private: enum InstanceTypeCompareMode { diff --git a/src/interpreter/interpreter.cc b/src/interpreter/interpreter.cc index 6b3f8103a0..aff4d68481 100644 --- a/src/interpreter/interpreter.cc +++ b/src/interpreter/interpreter.cc @@ -1045,7 +1045,7 @@ void Interpreter::DoCallRuntime(InterpreterAssembler* assembler) { // |function_id| with the first argument in |first_arg| and |arg_count| // arguments in subsequent registers. void Interpreter::DoInvokeIntrinsic(InterpreterAssembler* assembler) { - Node* function_id = __ BytecodeOperandRuntimeId(0); + Node* function_id = __ BytecodeOperandIntrinsicId(0); Node* first_arg_reg = __ BytecodeOperandReg(1); Node* arg_count = __ BytecodeOperandCount(2); Node* context = __ GetContext(); diff --git a/test/cctest/interpreter/bytecode-expectations-printer.cc b/test/cctest/interpreter/bytecode-expectations-printer.cc index b0f623611e..83f11c6d42 100644 --- a/test/cctest/interpreter/bytecode-expectations-printer.cc +++ b/test/cctest/interpreter/bytecode-expectations-printer.cc @@ -19,6 +19,7 @@ #include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-generator.h" #include "src/interpreter/bytecodes.h" +#include "src/interpreter/interpreter-intrinsics.h" #include "src/interpreter/interpreter.h" #include "src/interpreter/source-position-table.h" @@ -98,12 +99,6 @@ void BytecodeExpectationsPrinter::PrintEscapedString( } } -namespace { -i::Runtime::FunctionId IndexToFunctionId(uint32_t index) { - return static_cast(index); -} -} // namespace - void BytecodeExpectationsPrinter::PrintBytecodeOperand( std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, const Bytecode& bytecode, int op_index, int parameter_count) const { @@ -164,9 +159,15 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand( stream << bytecode_iterator.GetRegisterCountOperand(op_index); break; case OperandType::kRuntimeId: { - uint32_t operand = bytecode_iterator.GetRuntimeIdOperand(op_index); - stream << "Runtime::k" - << i::Runtime::FunctionForId(IndexToFunctionId(operand))->name; + Runtime::FunctionId id = + bytecode_iterator.GetRuntimeIdOperand(op_index); + stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; + break; + } + case OperandType::kIntrinsicId: { + Runtime::FunctionId id = + bytecode_iterator.GetIntrinsicIdOperand(op_index); + stream << "Runtime::k" << i::Runtime::FunctionForId(id)->name; break; } default: diff --git a/test/cctest/interpreter/bytecode_expectations/ForOf.golden b/test/cctest/interpreter/bytecode_expectations/ForOf.golden index 0a7b1ee004..06cdb3d3b3 100644 --- a/test/cctest/interpreter/bytecode_expectations/ForOf.golden +++ b/test/cctest/interpreter/bytecode_expectations/ForOf.golden @@ -13,7 +13,7 @@ snippet: " " frame size: 16 parameter count: 1 -bytecode array length: 288 +bytecode array length: 284 bytecodes: [ /* 30 E> */ B(StackCheck), B(LdrUndefined), R(4), @@ -30,7 +30,7 @@ bytecodes: [ /* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14), /* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5), B(Star), R(2), - /* 45 E> */ B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(2), U8(1), + /* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), @@ -44,7 +44,7 @@ bytecodes: [ B(Mov), R(0), R(7), B(LdaZero), B(Star), R(3), - B(Jump), U8(-49), + B(Jump), U8(-48), B(Jump), U8(41), B(Star), R(14), B(LdaConstant), U8(5), @@ -75,15 +75,15 @@ bytecodes: [ B(LdaUndefined), B(TestEqualStrict), R(1), B(ToBooleanLogicalNot), - B(JumpIfFalse), U8(121), + B(JumpIfFalse), U8(118), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdaNull), B(TestEqual), R(5), B(JumpIfFalse), U8(4), - B(Jump), U8(109), + B(Jump), U8(106), B(LdaSmi), U8(1), B(TestEqualStrict), R(3), - B(JumpIfFalse), U8(76), + B(JumpIfFalse), U8(75), B(Ldar), R(5), B(TypeOf), B(Star), R(12), @@ -100,7 +100,7 @@ bytecodes: [ B(Mov), R(context), R(12), B(Mov), R(5), R(13), B(Mov), R(1), R(14), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(13), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), B(Jump), U8(29), B(Star), R(14), B(LdaConstant), U8(5), @@ -112,12 +112,12 @@ bytecodes: [ B(Ldar), R(12), B(PushContext), R(8), B(PopContext), R(8), - B(Jump), U8(29), + B(Jump), U8(27), B(Mov), R(5), R(12), B(Mov), R(1), R(13), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(12), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), B(Star), R(6), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(6), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(6), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), @@ -143,9 +143,9 @@ constant pool: [ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, ] handlers: [ - [9, 123, 129], - [12, 82, 84], - [202, 213, 215], + [9, 122, 128], + [12, 81, 83], + [201, 211, 213], ] --- @@ -155,7 +155,7 @@ snippet: " " frame size: 17 parameter count: 1 -bytecode array length: 301 +bytecode array length: 297 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(LdaConstant), U8(0), @@ -172,7 +172,7 @@ bytecodes: [ /* 65 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(15), /* 65 E> */ B(Call), R(15), R(1), U8(1), U8(5), B(Star), R(2), - /* 65 E> */ B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(2), U8(1), + /* 65 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), @@ -188,7 +188,7 @@ bytecodes: [ B(Star), R(10), B(Mov), R(0), R(11), B(Jump), U8(57), - B(Jump), U8(-54), + B(Jump), U8(-53), B(Jump), U8(41), B(Star), R(15), B(LdaConstant), U8(5), @@ -219,15 +219,15 @@ bytecodes: [ B(LdaUndefined), B(TestEqualStrict), R(1), B(ToBooleanLogicalNot), - B(JumpIfFalse), U8(121), + B(JumpIfFalse), U8(118), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdaNull), B(TestEqual), R(5), B(JumpIfFalse), U8(4), - B(Jump), U8(109), + B(Jump), U8(106), B(LdaSmi), U8(1), B(TestEqualStrict), R(3), - B(JumpIfFalse), U8(76), + B(JumpIfFalse), U8(75), B(Ldar), R(5), B(TypeOf), B(Star), R(13), @@ -244,7 +244,7 @@ bytecodes: [ B(Mov), R(context), R(13), B(Mov), R(5), R(14), B(Mov), R(1), R(15), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(14), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(14), U8(2), B(Jump), U8(29), B(Star), R(15), B(LdaConstant), U8(5), @@ -256,12 +256,12 @@ bytecodes: [ B(Ldar), R(13), B(PushContext), R(9), B(PopContext), R(9), - B(Jump), U8(29), + B(Jump), U8(27), B(Mov), R(5), R(13), B(Mov), R(1), R(14), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(13), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), B(Star), R(6), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(6), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(6), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), @@ -292,9 +292,9 @@ constant pool: [ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, ] handlers: [ - [13, 126, 132], - [16, 85, 87], - [206, 217, 219], + [13, 125, 131], + [16, 84, 86], + [205, 215, 217], ] --- @@ -306,7 +306,7 @@ snippet: " " frame size: 16 parameter count: 1 -bytecode array length: 304 +bytecode array length: 300 bytecodes: [ /* 30 E> */ B(StackCheck), B(LdrUndefined), R(4), @@ -323,7 +323,7 @@ bytecodes: [ /* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14), /* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5), B(Star), R(2), - /* 45 E> */ B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(2), U8(1), + /* 45 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(2), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), @@ -345,7 +345,7 @@ bytecodes: [ /* 104 S> */ B(Jump), U8(7), B(LdaZero), B(Star), R(3), - B(Jump), U8(-65), + B(Jump), U8(-64), B(Jump), U8(41), B(Star), R(14), B(LdaConstant), U8(5), @@ -376,15 +376,15 @@ bytecodes: [ B(LdaUndefined), B(TestEqualStrict), R(1), B(ToBooleanLogicalNot), - B(JumpIfFalse), U8(121), + B(JumpIfFalse), U8(118), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdaNull), B(TestEqual), R(5), B(JumpIfFalse), U8(4), - B(Jump), U8(109), + B(Jump), U8(106), B(LdaSmi), U8(1), B(TestEqualStrict), R(3), - B(JumpIfFalse), U8(76), + B(JumpIfFalse), U8(75), B(Ldar), R(5), B(TypeOf), B(Star), R(12), @@ -401,7 +401,7 @@ bytecodes: [ B(Mov), R(context), R(12), B(Mov), R(5), R(13), B(Mov), R(1), R(14), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(13), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(13), U8(2), B(Jump), U8(29), B(Star), R(14), B(LdaConstant), U8(5), @@ -413,12 +413,12 @@ bytecodes: [ B(Ldar), R(12), B(PushContext), R(8), B(PopContext), R(8), - B(Jump), U8(29), + B(Jump), U8(27), B(Mov), R(5), R(12), B(Mov), R(1), R(13), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(12), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), B(Star), R(6), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(6), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(6), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), @@ -444,9 +444,9 @@ constant pool: [ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, ] handlers: [ - [9, 139, 145], - [12, 98, 100], - [218, 229, 231], + [9, 138, 144], + [12, 97, 99], + [217, 227, 229], ] --- @@ -456,7 +456,7 @@ snippet: " " frame size: 15 parameter count: 1 -bytecode array length: 312 +bytecode array length: 308 bytecodes: [ /* 30 E> */ B(StackCheck), /* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), @@ -476,7 +476,7 @@ bytecodes: [ /* 74 S> */ B(LdrNamedProperty), R(0), U8(3), U8(7), R(13), /* 74 E> */ B(Call), R(13), R(0), U8(1), U8(5), B(Star), R(1), - /* 74 E> */ B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(1), U8(1), + /* 74 E> */ B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(1), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(1), U8(1), @@ -492,7 +492,7 @@ bytecodes: [ B(LdaZero), B(Star), R(8), B(Jump), U8(57), - B(Jump), U8(-55), + B(Jump), U8(-54), B(Jump), U8(41), B(Star), R(13), B(LdaConstant), U8(7), @@ -523,15 +523,15 @@ bytecodes: [ B(LdaUndefined), B(TestEqualStrict), R(0), B(ToBooleanLogicalNot), - B(JumpIfFalse), U8(121), + B(JumpIfFalse), U8(118), B(LdrNamedProperty), R(0), U8(8), U8(17), R(4), B(LdaNull), B(TestEqual), R(4), B(JumpIfFalse), U8(4), - B(Jump), U8(109), + B(Jump), U8(106), B(LdaSmi), U8(1), B(TestEqualStrict), R(2), - B(JumpIfFalse), U8(76), + B(JumpIfFalse), U8(75), B(Ldar), R(4), B(TypeOf), B(Star), R(11), @@ -548,7 +548,7 @@ bytecodes: [ B(Mov), R(context), R(11), B(Mov), R(4), R(12), B(Mov), R(0), R(13), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(12), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(12), U8(2), B(Jump), U8(29), B(Star), R(13), B(LdaConstant), U8(7), @@ -560,12 +560,12 @@ bytecodes: [ B(Ldar), R(11), B(PushContext), R(7), B(PopContext), R(7), - B(Jump), U8(29), + B(Jump), U8(27), B(Mov), R(4), R(11), B(Mov), R(0), R(12), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(11), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(11), U8(2), B(Star), R(5), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(5), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(5), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(7), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), @@ -598,8 +598,8 @@ constant pool: [ InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, ] handlers: [ - [17, 137, 143], - [20, 96, 98], - [217, 228, 230], + [17, 136, 142], + [20, 95, 97], + [216, 226, 228], ] diff --git a/test/cctest/interpreter/bytecode_expectations/Generators.golden b/test/cctest/interpreter/bytecode_expectations/Generators.golden index 17b2577279..310ac4ff83 100644 --- a/test/cctest/interpreter/bytecode_expectations/Generators.golden +++ b/test/cctest/interpreter/bytecode_expectations/Generators.golden @@ -265,7 +265,7 @@ snippet: " " frame size: 17 parameter count: 1 -bytecode array length: 779 +bytecode array length: 775 bytecodes: [ B(Ldar), R(new_target), B(JumpIfUndefined), U8(26), @@ -353,7 +353,7 @@ bytecodes: [ /* 27 E> */ B(Call), R(12), R(13), U8(1), U8(5), /* 27 E> */ B(StaContextSlot), R(1), U8(8), B(Star), R(11), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(11), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(11), U8(1), B(ToBooleanLogicalNot), B(JumpIfFalse), U8(11), B(LdrContextSlot), R(1), U8(8), R(11), @@ -426,7 +426,7 @@ bytecodes: [ B(PopContext), R(2), B(LdaZero), B(StaContextSlot), R(1), U8(9), - B(Wide), B(Jump), U16(-223), + B(Wide), B(Jump), U16(-222), B(Jump), U8(46), B(Star), R(12), B(LdaConstant), U8(11), @@ -468,11 +468,11 @@ bytecodes: [ B(LdaNull), B(TestEqual), R(10), B(JumpIfFalse), U8(4), - B(Jump), U8(127), + B(Jump), U8(124), B(LdrContextSlot), R(1), U8(9), R(10), B(LdaSmi), U8(1), B(TestEqualStrict), R(10), - B(JumpIfFalse), U8(79), + B(JumpIfFalse), U8(78), B(LdaContextSlot), R(1), U8(11), B(TypeOf), B(Star), R(10), @@ -489,7 +489,7 @@ bytecodes: [ B(Mov), R(context), R(10), B(LdrContextSlot), R(1), U8(11), R(11), B(LdrContextSlot), R(1), U8(7), R(12), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(11), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(11), U8(2), B(Jump), U8(29), B(Star), R(12), B(LdaConstant), U8(11), @@ -501,13 +501,13 @@ bytecodes: [ B(Ldar), R(10), B(PushContext), R(2), B(PopContext), R(2), - B(Jump), U8(40), + B(Jump), U8(38), B(LdrContextSlot), R(1), U8(11), R(10), B(LdrContextSlot), R(1), U8(7), R(11), - B(InvokeIntrinsic), U16(Runtime::k_Call), R(10), U8(2), + B(InvokeIntrinsic), U8(Runtime::k_Call), R(10), U8(2), B(StaContextSlot), R(1), U8(12), B(LdrContextSlot), R(1), U8(12), R(10), - B(InvokeIntrinsic), U16(Runtime::k_IsJSReceiver), R(10), U8(1), + B(InvokeIntrinsic), U8(Runtime::k_IsJSReceiver), R(10), U8(1), B(JumpIfToBooleanFalse), U8(4), B(Jump), U8(11), B(LdrContextSlot), R(1), U8(12), R(10), @@ -601,9 +601,9 @@ constant pool: [ kInstanceTypeDontCare, ] handlers: [ - [44, 698, 704], - [154, 449, 455], - [157, 403, 405], - [552, 565, 567], + [44, 694, 700], + [154, 448, 454], + [157, 402, 404], + [551, 563, 565], ] diff --git a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc index 9e2ea863bc..f24c818c3b 100644 --- a/test/unittests/interpreter/bytecode-array-iterator-unittest.cc +++ b/test/unittests/interpreter/bytecode-array-iterator-unittest.cc @@ -229,8 +229,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) { CHECK_EQ(iterator.current_bytecode(), Bytecode::kCallRuntime); CHECK_EQ(iterator.current_offset(), offset); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); - CHECK_EQ(static_cast(iterator.GetRuntimeIdOperand(0)), - Runtime::kLoadIC_Miss); + CHECK_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadIC_Miss); CHECK_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); CHECK_EQ(iterator.GetRegisterCountOperand(2), 1); CHECK(!iterator.done()); diff --git a/test/unittests/interpreter/interpreter-assembler-unittest.cc b/test/unittests/interpreter/interpreter-assembler-unittest.cc index 1d85fb9201..1bc80c0e4a 100644 --- a/test/unittests/interpreter/interpreter-assembler-unittest.cc +++ b/test/unittests/interpreter/interpreter-assembler-unittest.cc @@ -428,6 +428,10 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) { EXPECT_THAT(m.BytecodeOperandRuntimeId(i), m.IsUnsignedOperand(offset, operand_size)); break; + case interpreter::OperandType::kIntrinsicId: + EXPECT_THAT(m.BytecodeOperandIntrinsicId(i), + m.IsUnsignedOperand(offset, operand_size)); + break; case interpreter::OperandType::kNone: UNREACHABLE(); break;