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}
This commit is contained in:
rmcilroy 2016-06-21 07:37:16 -07:00 committed by Commit bot
parent dacc5a73cd
commit 6003ed0489
16 changed files with 172 additions and 95 deletions

View File

@ -1001,8 +1001,7 @@ Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments(
void BytecodeGraphBuilder::VisitCallRuntime() { void BytecodeGraphBuilder::VisitCallRuntime() {
FrameStateBeforeAndAfter states(this); FrameStateBeforeAndAfter states(this);
Runtime::FunctionId functionId = static_cast<Runtime::FunctionId>( Runtime::FunctionId functionId = bytecode_iterator().GetRuntimeIdOperand(0);
bytecode_iterator().GetRuntimeIdOperand(0));
interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);
@ -1014,8 +1013,7 @@ void BytecodeGraphBuilder::VisitCallRuntime() {
void BytecodeGraphBuilder::VisitCallRuntimeForPair() { void BytecodeGraphBuilder::VisitCallRuntimeForPair() {
FrameStateBeforeAndAfter states(this); FrameStateBeforeAndAfter states(this);
Runtime::FunctionId functionId = static_cast<Runtime::FunctionId>( Runtime::FunctionId functionId = bytecode_iterator().GetRuntimeIdOperand(0);
bytecode_iterator().GetRuntimeIdOperand(0));
interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);
interpreter::Register first_return = interpreter::Register first_return =
@ -1029,8 +1027,7 @@ void BytecodeGraphBuilder::VisitCallRuntimeForPair() {
void BytecodeGraphBuilder::VisitInvokeIntrinsic() { void BytecodeGraphBuilder::VisitInvokeIntrinsic() {
FrameStateBeforeAndAfter states(this); FrameStateBeforeAndAfter states(this);
Runtime::FunctionId functionId = static_cast<Runtime::FunctionId>( Runtime::FunctionId functionId = bytecode_iterator().GetIntrinsicIdOperand(0);
bytecode_iterator().GetRuntimeIdOperand(0));
interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1);
size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2); size_t arg_count = bytecode_iterator().GetRegisterCountOperand(2);

View File

@ -581,11 +581,16 @@ BytecodeArrayBuilder& BytecodeArrayBuilder::CallRuntime(
DCHECK_EQ(0u, arg_count); DCHECK_EQ(0u, arg_count);
first_arg = Register(0); first_arg = Register(0);
} }
Bytecode bytecode = IntrinsicsHelper::IsSupported(function_id) Bytecode bytecode;
? Bytecode::kInvokeIntrinsic uint32_t id;
: Bytecode::kCallRuntime; if (IntrinsicsHelper::IsSupported(function_id)) {
Output(bytecode, static_cast<uint16_t>(function_id), bytecode = Bytecode::kInvokeIntrinsic;
RegisterOperand(first_arg), UnsignedOperand(arg_count)); id = static_cast<uint32_t>(IntrinsicsHelper::FromRuntimeId(function_id));
} else {
bytecode = Bytecode::kCallRuntime;
id = static_cast<uint32_t>(function_id);
}
Output(bytecode, id, RegisterOperand(first_arg), UnsignedOperand(arg_count));
return *this; return *this;
} }
@ -694,6 +699,7 @@ bool BytecodeArrayBuilder::OperandsAreValid(
break; break;
} }
case OperandType::kFlag8: case OperandType::kFlag8:
case OperandType::kIntrinsicId:
if (Bytecodes::SizeForUnsignedOperand(operands[i]) > if (Bytecodes::SizeForUnsignedOperand(operands[i]) >
OperandSize::kByte) { OperandSize::kByte) {
return false; return false;

View File

@ -4,6 +4,7 @@
#include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/objects-inl.h" #include "src/objects-inl.h"
namespace v8 { 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 = OperandType operand_type =
Bytecodes::GetOperandType(current_bytecode(), operand_index); Bytecodes::GetOperandType(current_bytecode(), operand_index);
DCHECK(operand_type == OperandType::kRuntimeId); DCHECK(operand_type == OperandType::kRuntimeId);
return GetUnsignedOperand(operand_index, operand_type); uint32_t raw_id = GetUnsignedOperand(operand_index, operand_type);
return static_cast<Runtime::FunctionId>(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<IntrinsicsHelper::IntrinsicId>(raw_id));
} }
Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand( Handle<Object> BytecodeArrayIterator::GetConstantForIndexOperand(

View File

@ -8,6 +8,7 @@
#include "src/handles.h" #include "src/handles.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
#include "src/objects.h" #include "src/objects.h"
#include "src/runtime/runtime.h"
namespace v8 { namespace v8 {
namespace internal { namespace internal {
@ -34,7 +35,8 @@ class BytecodeArrayIterator {
uint32_t GetRegisterCountOperand(int operand_index) const; uint32_t GetRegisterCountOperand(int operand_index) const;
Register GetRegisterOperand(int operand_index) const; Register GetRegisterOperand(int operand_index) const;
int GetRegisterOperandRange(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<Object> GetConstantForIndexOperand(int operand_index) const; Handle<Object> GetConstantForIndexOperand(int operand_index) const;
// Returns the absolute offset of the branch target at the current // Returns the absolute offset of the branch target at the current

View File

@ -737,6 +737,7 @@ std::ostream& Bytecodes::Decode(std::ostream& os, const uint8_t* bytecode_start,
break; break;
case interpreter::OperandType::kIdx: case interpreter::OperandType::kIdx:
case interpreter::OperandType::kRuntimeId: case interpreter::OperandType::kRuntimeId:
case interpreter::OperandType::kIntrinsicId:
os << "[" os << "["
<< DecodeUnsignedOperand(operand_start, op_type, operand_scale) << DecodeUnsignedOperand(operand_start, op_type, operand_scale)
<< "]"; << "]";

View File

@ -30,6 +30,7 @@ namespace interpreter {
#define SCALAR_OPERAND_TYPE_LIST(V) \ #define SCALAR_OPERAND_TYPE_LIST(V) \
V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \ V(Flag8, OperandTypeInfo::kFixedUnsignedByte) \
V(IntrinsicId, OperandTypeInfo::kFixedUnsignedByte) \
V(Idx, OperandTypeInfo::kScalableUnsignedByte) \ V(Idx, OperandTypeInfo::kScalableUnsignedByte) \
V(Imm, OperandTypeInfo::kScalableSignedByte) \ V(Imm, OperandTypeInfo::kScalableSignedByte) \
V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \ V(RegCount, OperandTypeInfo::kScalableUnsignedByte) \
@ -180,7 +181,7 @@ namespace interpreter {
OperandType::kReg, OperandType::kRegCount) \ OperandType::kReg, OperandType::kRegCount) \
\ \
/* Intrinsics */ \ /* Intrinsics */ \
V(InvokeIntrinsic, AccumulatorUse::kWrite, OperandType::kRuntimeId, \ V(InvokeIntrinsic, AccumulatorUse::kWrite, OperandType::kIntrinsicId, \
OperandType::kMaybeReg, OperandType::kRegCount) \ OperandType::kMaybeReg, OperandType::kRegCount) \
\ \
/* New operator */ \ /* New operator */ \

View File

@ -363,6 +363,15 @@ Node* InterpreterAssembler::BytecodeOperandRuntimeId(int operand_index) {
return BytecodeUnsignedOperand(operand_index, operand_size); 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* InterpreterAssembler::LoadConstantPoolEntry(Node* index) {
Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(), Node* constant_pool = LoadObjectField(BytecodeArrayTaggedPointer(),
BytecodeArray::kConstantPoolOffset); BytecodeArray::kConstantPoolOffset);

View File

@ -41,6 +41,9 @@ class InterpreterAssembler : public CodeStubAssembler {
// Returns the runtime id immediate for bytecode operand // Returns the runtime id immediate for bytecode operand
// |operand_index| in the current bytecode. // |operand_index| in the current bytecode.
compiler::Node* BytecodeOperandRuntimeId(int operand_index); 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. // Accumulator.
compiler::Node* GetAccumulator(); compiler::Node* GetAccumulator();

View File

@ -15,6 +15,7 @@ using compiler::Node;
IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler) IntrinsicsHelper::IntrinsicsHelper(InterpreterAssembler* assembler)
: assembler_(assembler) {} : assembler_(assembler) {}
// static
bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) { bool IntrinsicsHelper::IsSupported(Runtime::FunctionId function_id) {
switch (function_id) { switch (function_id) {
#define SUPPORTED(name, lower_case, count) case Runtime::kInline##name: #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<IntrinsicsHelper::IntrinsicId>(-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<Runtime::FunctionId>(-1);
}
}
Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context, Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
Node* first_arg_reg, Node* arg_count) { Node* first_arg_reg, Node* arg_count) {
InterpreterAssembler::Label abort(assembler_), end(assembler_); InterpreterAssembler::Label abort(assembler_), end(assembler_);
@ -42,7 +73,7 @@ Node* IntrinsicsHelper::InvokeIntrinsic(Node* function_id, Node* context,
#undef LABEL_POINTER #undef LABEL_POINTER
#define CASE(name, lower_case, count) \ #define CASE(name, lower_case, count) \
static_cast<int32_t>(Runtime::kInline##name), static_cast<int32_t>(IntrinsicId::k##name),
int32_t cases[] = {INTRINSICS_LIST(CASE)}; int32_t cases[] = {INTRINSICS_LIST(CASE)};
#undef CASE #undef CASE

View File

@ -20,6 +20,8 @@ namespace compiler {
class Node; class Node;
} // namespace compiler } // namespace compiler
namespace interpreter {
// List of supported intrisics, with upper case name, lower case name and // List of supported intrisics, with upper case name, lower case name and
// expected number of arguments (-1 denoting argument count is variable). // expected number of arguments (-1 denoting argument count is variable).
#define INTRINSICS_LIST(V) \ #define INTRINSICS_LIST(V) \
@ -31,10 +33,16 @@ class Node;
V(IsSmi, is_smi, 1) \ V(IsSmi, is_smi, 1) \
V(IsTypedArray, is_typed_array, 1) V(IsTypedArray, is_typed_array, 1)
namespace interpreter {
class IntrinsicsHelper { class IntrinsicsHelper {
public: 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<uint32_t>(IntrinsicId::kIdCount) <= kMaxUInt8);
explicit IntrinsicsHelper(InterpreterAssembler* assembler); explicit IntrinsicsHelper(InterpreterAssembler* assembler);
compiler::Node* InvokeIntrinsic(compiler::Node* function_id, compiler::Node* InvokeIntrinsic(compiler::Node* function_id,
@ -43,6 +51,8 @@ class IntrinsicsHelper {
compiler::Node* arg_count); compiler::Node* arg_count);
static bool IsSupported(Runtime::FunctionId function_id); static bool IsSupported(Runtime::FunctionId function_id);
static IntrinsicId FromRuntimeId(Runtime::FunctionId function_id);
static Runtime::FunctionId ToRuntimeId(IntrinsicId intrinsic_id);
private: private:
enum InstanceTypeCompareMode { enum InstanceTypeCompareMode {

View File

@ -1045,7 +1045,7 @@ void Interpreter::DoCallRuntime(InterpreterAssembler* assembler) {
// |function_id| with the first argument in |first_arg| and |arg_count| // |function_id| with the first argument in |first_arg| and |arg_count|
// arguments in subsequent registers. // arguments in subsequent registers.
void Interpreter::DoInvokeIntrinsic(InterpreterAssembler* assembler) { void Interpreter::DoInvokeIntrinsic(InterpreterAssembler* assembler) {
Node* function_id = __ BytecodeOperandRuntimeId(0); Node* function_id = __ BytecodeOperandIntrinsicId(0);
Node* first_arg_reg = __ BytecodeOperandReg(1); Node* first_arg_reg = __ BytecodeOperandReg(1);
Node* arg_count = __ BytecodeOperandCount(2); Node* arg_count = __ BytecodeOperandCount(2);
Node* context = __ GetContext(); Node* context = __ GetContext();

View File

@ -19,6 +19,7 @@
#include "src/interpreter/bytecode-array-iterator.h" #include "src/interpreter/bytecode-array-iterator.h"
#include "src/interpreter/bytecode-generator.h" #include "src/interpreter/bytecode-generator.h"
#include "src/interpreter/bytecodes.h" #include "src/interpreter/bytecodes.h"
#include "src/interpreter/interpreter-intrinsics.h"
#include "src/interpreter/interpreter.h" #include "src/interpreter/interpreter.h"
#include "src/interpreter/source-position-table.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<i::Runtime::FunctionId>(index);
}
} // namespace
void BytecodeExpectationsPrinter::PrintBytecodeOperand( void BytecodeExpectationsPrinter::PrintBytecodeOperand(
std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator, std::ostream& stream, const BytecodeArrayIterator& bytecode_iterator,
const Bytecode& bytecode, int op_index, int parameter_count) const { const Bytecode& bytecode, int op_index, int parameter_count) const {
@ -164,9 +159,15 @@ void BytecodeExpectationsPrinter::PrintBytecodeOperand(
stream << bytecode_iterator.GetRegisterCountOperand(op_index); stream << bytecode_iterator.GetRegisterCountOperand(op_index);
break; break;
case OperandType::kRuntimeId: { case OperandType::kRuntimeId: {
uint32_t operand = bytecode_iterator.GetRuntimeIdOperand(op_index); Runtime::FunctionId id =
stream << "Runtime::k" bytecode_iterator.GetRuntimeIdOperand(op_index);
<< i::Runtime::FunctionForId(IndexToFunctionId(operand))->name; 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; break;
} }
default: default:

View File

@ -13,7 +13,7 @@ snippet: "
" "
frame size: 16 frame size: 16
parameter count: 1 parameter count: 1
bytecode array length: 288 bytecode array length: 284
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
B(LdrUndefined), R(4), B(LdrUndefined), R(4),
@ -30,7 +30,7 @@ bytecodes: [
/* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14), /* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14),
/* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5), /* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5),
B(Star), R(2), 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(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7), B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1),
@ -44,7 +44,7 @@ bytecodes: [
B(Mov), R(0), R(7), B(Mov), R(0), R(7),
B(LdaZero), B(LdaZero),
B(Star), R(3), B(Star), R(3),
B(Jump), U8(-49), B(Jump), U8(-48),
B(Jump), U8(41), B(Jump), U8(41),
B(Star), R(14), B(Star), R(14),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -75,15 +75,15 @@ bytecodes: [
B(LdaUndefined), B(LdaUndefined),
B(TestEqualStrict), R(1), B(TestEqualStrict), R(1),
B(ToBooleanLogicalNot), B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(121), B(JumpIfFalse), U8(118),
B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5),
B(LdaNull), B(LdaNull),
B(TestEqual), R(5), B(TestEqual), R(5),
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(109), B(Jump), U8(106),
B(LdaSmi), U8(1), B(LdaSmi), U8(1),
B(TestEqualStrict), R(3), B(TestEqualStrict), R(3),
B(JumpIfFalse), U8(76), B(JumpIfFalse), U8(75),
B(Ldar), R(5), B(Ldar), R(5),
B(TypeOf), B(TypeOf),
B(Star), R(12), B(Star), R(12),
@ -100,7 +100,7 @@ bytecodes: [
B(Mov), R(context), R(12), B(Mov), R(context), R(12),
B(Mov), R(5), R(13), B(Mov), R(5), R(13),
B(Mov), R(1), R(14), 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(Jump), U8(29),
B(Star), R(14), B(Star), R(14),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -112,12 +112,12 @@ bytecodes: [
B(Ldar), R(12), B(Ldar), R(12),
B(PushContext), R(8), B(PushContext), R(8),
B(PopContext), R(8), B(PopContext), R(8),
B(Jump), U8(29), B(Jump), U8(27),
B(Mov), R(5), R(12), B(Mov), R(5), R(12),
B(Mov), R(1), R(13), 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(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(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7), B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1),
@ -143,9 +143,9 @@ constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
] ]
handlers: [ handlers: [
[9, 123, 129], [9, 122, 128],
[12, 82, 84], [12, 81, 83],
[202, 213, 215], [201, 211, 213],
] ]
--- ---
@ -155,7 +155,7 @@ snippet: "
" "
frame size: 17 frame size: 17
parameter count: 1 parameter count: 1
bytecode array length: 301 bytecode array length: 297
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(LdaConstant), U8(0), /* 42 S> */ B(LdaConstant), U8(0),
@ -172,7 +172,7 @@ bytecodes: [
/* 65 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(15), /* 65 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(15),
/* 65 E> */ B(Call), R(15), R(1), U8(1), U8(5), /* 65 E> */ B(Call), R(15), R(1), U8(1), U8(5),
B(Star), R(2), 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(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7), B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1),
@ -188,7 +188,7 @@ bytecodes: [
B(Star), R(10), B(Star), R(10),
B(Mov), R(0), R(11), B(Mov), R(0), R(11),
B(Jump), U8(57), B(Jump), U8(57),
B(Jump), U8(-54), B(Jump), U8(-53),
B(Jump), U8(41), B(Jump), U8(41),
B(Star), R(15), B(Star), R(15),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -219,15 +219,15 @@ bytecodes: [
B(LdaUndefined), B(LdaUndefined),
B(TestEqualStrict), R(1), B(TestEqualStrict), R(1),
B(ToBooleanLogicalNot), B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(121), B(JumpIfFalse), U8(118),
B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5),
B(LdaNull), B(LdaNull),
B(TestEqual), R(5), B(TestEqual), R(5),
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(109), B(Jump), U8(106),
B(LdaSmi), U8(1), B(LdaSmi), U8(1),
B(TestEqualStrict), R(3), B(TestEqualStrict), R(3),
B(JumpIfFalse), U8(76), B(JumpIfFalse), U8(75),
B(Ldar), R(5), B(Ldar), R(5),
B(TypeOf), B(TypeOf),
B(Star), R(13), B(Star), R(13),
@ -244,7 +244,7 @@ bytecodes: [
B(Mov), R(context), R(13), B(Mov), R(context), R(13),
B(Mov), R(5), R(14), B(Mov), R(5), R(14),
B(Mov), R(1), R(15), 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(Jump), U8(29),
B(Star), R(15), B(Star), R(15),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -256,12 +256,12 @@ bytecodes: [
B(Ldar), R(13), B(Ldar), R(13),
B(PushContext), R(9), B(PushContext), R(9),
B(PopContext), R(9), B(PopContext), R(9),
B(Jump), U8(29), B(Jump), U8(27),
B(Mov), R(5), R(13), B(Mov), R(5), R(13),
B(Mov), R(1), R(14), 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(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(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7), B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1),
@ -292,9 +292,9 @@ constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
] ]
handlers: [ handlers: [
[13, 126, 132], [13, 125, 131],
[16, 85, 87], [16, 84, 86],
[206, 217, 219], [205, 215, 217],
] ]
--- ---
@ -306,7 +306,7 @@ snippet: "
" "
frame size: 16 frame size: 16
parameter count: 1 parameter count: 1
bytecode array length: 304 bytecode array length: 300
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
B(LdrUndefined), R(4), B(LdrUndefined), R(4),
@ -323,7 +323,7 @@ bytecodes: [
/* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14), /* 45 S> */ B(LdrNamedProperty), R(1), U8(2), U8(7), R(14),
/* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5), /* 45 E> */ B(Call), R(14), R(1), U8(1), U8(5),
B(Star), R(2), 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(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7), B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(2), U8(1),
@ -345,7 +345,7 @@ bytecodes: [
/* 104 S> */ B(Jump), U8(7), /* 104 S> */ B(Jump), U8(7),
B(LdaZero), B(LdaZero),
B(Star), R(3), B(Star), R(3),
B(Jump), U8(-65), B(Jump), U8(-64),
B(Jump), U8(41), B(Jump), U8(41),
B(Star), R(14), B(Star), R(14),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -376,15 +376,15 @@ bytecodes: [
B(LdaUndefined), B(LdaUndefined),
B(TestEqualStrict), R(1), B(TestEqualStrict), R(1),
B(ToBooleanLogicalNot), B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(121), B(JumpIfFalse), U8(118),
B(LdrNamedProperty), R(1), U8(6), U8(13), R(5), B(LdrNamedProperty), R(1), U8(6), U8(13), R(5),
B(LdaNull), B(LdaNull),
B(TestEqual), R(5), B(TestEqual), R(5),
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(109), B(Jump), U8(106),
B(LdaSmi), U8(1), B(LdaSmi), U8(1),
B(TestEqualStrict), R(3), B(TestEqualStrict), R(3),
B(JumpIfFalse), U8(76), B(JumpIfFalse), U8(75),
B(Ldar), R(5), B(Ldar), R(5),
B(TypeOf), B(TypeOf),
B(Star), R(12), B(Star), R(12),
@ -401,7 +401,7 @@ bytecodes: [
B(Mov), R(context), R(12), B(Mov), R(context), R(12),
B(Mov), R(5), R(13), B(Mov), R(5), R(13),
B(Mov), R(1), R(14), 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(Jump), U8(29),
B(Star), R(14), B(Star), R(14),
B(LdaConstant), U8(5), B(LdaConstant), U8(5),
@ -413,12 +413,12 @@ bytecodes: [
B(Ldar), R(12), B(Ldar), R(12),
B(PushContext), R(8), B(PushContext), R(8),
B(PopContext), R(8), B(PopContext), R(8),
B(Jump), U8(29), B(Jump), U8(27),
B(Mov), R(5), R(12), B(Mov), R(5), R(12),
B(Mov), R(1), R(13), 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(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(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7), B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(6), U8(1),
@ -444,9 +444,9 @@ constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
] ]
handlers: [ handlers: [
[9, 139, 145], [9, 138, 144],
[12, 98, 100], [12, 97, 99],
[218, 229, 231], [217, 227, 229],
] ]
--- ---
@ -456,7 +456,7 @@ snippet: "
" "
frame size: 15 frame size: 15
parameter count: 1 parameter count: 1
bytecode array length: 312 bytecode array length: 308
bytecodes: [ bytecodes: [
/* 30 E> */ B(StackCheck), /* 30 E> */ B(StackCheck),
/* 42 S> */ B(CreateObjectLiteral), U8(0), U8(0), U8(1), /* 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 S> */ B(LdrNamedProperty), R(0), U8(3), U8(7), R(13),
/* 74 E> */ B(Call), R(13), R(0), U8(1), U8(5), /* 74 E> */ B(Call), R(13), R(0), U8(1), U8(5),
B(Star), R(1), 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(ToBooleanLogicalNot),
B(JumpIfFalse), U8(7), B(JumpIfFalse), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(1), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(1), U8(1),
@ -492,7 +492,7 @@ bytecodes: [
B(LdaZero), B(LdaZero),
B(Star), R(8), B(Star), R(8),
B(Jump), U8(57), B(Jump), U8(57),
B(Jump), U8(-55), B(Jump), U8(-54),
B(Jump), U8(41), B(Jump), U8(41),
B(Star), R(13), B(Star), R(13),
B(LdaConstant), U8(7), B(LdaConstant), U8(7),
@ -523,15 +523,15 @@ bytecodes: [
B(LdaUndefined), B(LdaUndefined),
B(TestEqualStrict), R(0), B(TestEqualStrict), R(0),
B(ToBooleanLogicalNot), B(ToBooleanLogicalNot),
B(JumpIfFalse), U8(121), B(JumpIfFalse), U8(118),
B(LdrNamedProperty), R(0), U8(8), U8(17), R(4), B(LdrNamedProperty), R(0), U8(8), U8(17), R(4),
B(LdaNull), B(LdaNull),
B(TestEqual), R(4), B(TestEqual), R(4),
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(109), B(Jump), U8(106),
B(LdaSmi), U8(1), B(LdaSmi), U8(1),
B(TestEqualStrict), R(2), B(TestEqualStrict), R(2),
B(JumpIfFalse), U8(76), B(JumpIfFalse), U8(75),
B(Ldar), R(4), B(Ldar), R(4),
B(TypeOf), B(TypeOf),
B(Star), R(11), B(Star), R(11),
@ -548,7 +548,7 @@ bytecodes: [
B(Mov), R(context), R(11), B(Mov), R(context), R(11),
B(Mov), R(4), R(12), B(Mov), R(4), R(12),
B(Mov), R(0), R(13), 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(Jump), U8(29),
B(Star), R(13), B(Star), R(13),
B(LdaConstant), U8(7), B(LdaConstant), U8(7),
@ -560,12 +560,12 @@ bytecodes: [
B(Ldar), R(11), B(Ldar), R(11),
B(PushContext), R(7), B(PushContext), R(7),
B(PopContext), R(7), B(PopContext), R(7),
B(Jump), U8(29), B(Jump), U8(27),
B(Mov), R(4), R(11), B(Mov), R(4), R(11),
B(Mov), R(0), R(12), 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(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(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(7), B(Jump), U8(7),
B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1), B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), R(5), U8(1),
@ -598,8 +598,8 @@ constant pool: [
InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
] ]
handlers: [ handlers: [
[17, 137, 143], [17, 136, 142],
[20, 96, 98], [20, 95, 97],
[217, 228, 230], [216, 226, 228],
] ]

View File

@ -265,7 +265,7 @@ snippet: "
" "
frame size: 17 frame size: 17
parameter count: 1 parameter count: 1
bytecode array length: 779 bytecode array length: 775
bytecodes: [ bytecodes: [
B(Ldar), R(new_target), B(Ldar), R(new_target),
B(JumpIfUndefined), U8(26), B(JumpIfUndefined), U8(26),
@ -353,7 +353,7 @@ bytecodes: [
/* 27 E> */ B(Call), R(12), R(13), U8(1), U8(5), /* 27 E> */ B(Call), R(12), R(13), U8(1), U8(5),
/* 27 E> */ B(StaContextSlot), R(1), U8(8), /* 27 E> */ B(StaContextSlot), R(1), U8(8),
B(Star), R(11), 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(ToBooleanLogicalNot),
B(JumpIfFalse), U8(11), B(JumpIfFalse), U8(11),
B(LdrContextSlot), R(1), U8(8), R(11), B(LdrContextSlot), R(1), U8(8), R(11),
@ -426,7 +426,7 @@ bytecodes: [
B(PopContext), R(2), B(PopContext), R(2),
B(LdaZero), B(LdaZero),
B(StaContextSlot), R(1), U8(9), B(StaContextSlot), R(1), U8(9),
B(Wide), B(Jump), U16(-223), B(Wide), B(Jump), U16(-222),
B(Jump), U8(46), B(Jump), U8(46),
B(Star), R(12), B(Star), R(12),
B(LdaConstant), U8(11), B(LdaConstant), U8(11),
@ -468,11 +468,11 @@ bytecodes: [
B(LdaNull), B(LdaNull),
B(TestEqual), R(10), B(TestEqual), R(10),
B(JumpIfFalse), U8(4), B(JumpIfFalse), U8(4),
B(Jump), U8(127), B(Jump), U8(124),
B(LdrContextSlot), R(1), U8(9), R(10), B(LdrContextSlot), R(1), U8(9), R(10),
B(LdaSmi), U8(1), B(LdaSmi), U8(1),
B(TestEqualStrict), R(10), B(TestEqualStrict), R(10),
B(JumpIfFalse), U8(79), B(JumpIfFalse), U8(78),
B(LdaContextSlot), R(1), U8(11), B(LdaContextSlot), R(1), U8(11),
B(TypeOf), B(TypeOf),
B(Star), R(10), B(Star), R(10),
@ -489,7 +489,7 @@ bytecodes: [
B(Mov), R(context), R(10), B(Mov), R(context), R(10),
B(LdrContextSlot), R(1), U8(11), R(11), B(LdrContextSlot), R(1), U8(11), R(11),
B(LdrContextSlot), R(1), U8(7), R(12), 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(Jump), U8(29),
B(Star), R(12), B(Star), R(12),
B(LdaConstant), U8(11), B(LdaConstant), U8(11),
@ -501,13 +501,13 @@ bytecodes: [
B(Ldar), R(10), B(Ldar), R(10),
B(PushContext), R(2), B(PushContext), R(2),
B(PopContext), 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(11), R(10),
B(LdrContextSlot), R(1), U8(7), R(11), 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(StaContextSlot), R(1), U8(12),
B(LdrContextSlot), R(1), U8(12), R(10), 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(JumpIfToBooleanFalse), U8(4),
B(Jump), U8(11), B(Jump), U8(11),
B(LdrContextSlot), R(1), U8(12), R(10), B(LdrContextSlot), R(1), U8(12), R(10),
@ -601,9 +601,9 @@ constant pool: [
kInstanceTypeDontCare, kInstanceTypeDontCare,
] ]
handlers: [ handlers: [
[44, 698, 704], [44, 694, 700],
[154, 449, 455], [154, 448, 454],
[157, 403, 405], [157, 402, 404],
[552, 565, 567], [551, 563, 565],
] ]

View File

@ -229,8 +229,7 @@ TEST_F(BytecodeArrayIteratorTest, IteratesBytecodeArray) {
CHECK_EQ(iterator.current_bytecode(), Bytecode::kCallRuntime); CHECK_EQ(iterator.current_bytecode(), Bytecode::kCallRuntime);
CHECK_EQ(iterator.current_offset(), offset); CHECK_EQ(iterator.current_offset(), offset);
CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle); CHECK_EQ(iterator.current_operand_scale(), OperandScale::kSingle);
CHECK_EQ(static_cast<Runtime::FunctionId>(iterator.GetRuntimeIdOperand(0)), CHECK_EQ(iterator.GetRuntimeIdOperand(0), Runtime::kLoadIC_Miss);
Runtime::kLoadIC_Miss);
CHECK_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index()); CHECK_EQ(iterator.GetRegisterOperand(1).index(), reg_0.index());
CHECK_EQ(iterator.GetRegisterCountOperand(2), 1); CHECK_EQ(iterator.GetRegisterCountOperand(2), 1);
CHECK(!iterator.done()); CHECK(!iterator.done());

View File

@ -428,6 +428,10 @@ TARGET_TEST_F(InterpreterAssemblerTest, BytecodeOperand) {
EXPECT_THAT(m.BytecodeOperandRuntimeId(i), EXPECT_THAT(m.BytecodeOperandRuntimeId(i),
m.IsUnsignedOperand(offset, operand_size)); m.IsUnsignedOperand(offset, operand_size));
break; break;
case interpreter::OperandType::kIntrinsicId:
EXPECT_THAT(m.BytecodeOperandIntrinsicId(i),
m.IsUnsignedOperand(offset, operand_size));
break;
case interpreter::OperandType::kNone: case interpreter::OperandType::kNone:
UNREACHABLE(); UNREACHABLE();
break; break;