| Index: test/unittests/interpreter/interpreter-assembler-unittest.cc
|
| diff --git a/test/unittests/interpreter/interpreter-assembler-unittest.cc b/test/unittests/interpreter/interpreter-assembler-unittest.cc
|
| index ad49b798f660033aeff25cdebb92d9062ad2ba84..9236d96915bad87a6e069a6b52ffc0481ae221ef 100644
|
| --- a/test/unittests/interpreter/interpreter-assembler-unittest.cc
|
| +++ b/test/unittests/interpreter/interpreter-assembler-unittest.cc
|
| @@ -51,6 +51,12 @@ Matcher<Node*> IsIntPtrSub(const Matcher<Node*>& lhs_matcher,
|
| : IsInt32Sub(lhs_matcher, rhs_matcher);
|
| }
|
|
|
| +Matcher<Node*> IsIntPtrMul(const Matcher<Node*>& lhs_matcher,
|
| + const Matcher<Node*>& rhs_matcher) {
|
| + return kPointerSize == 8 ? IsInt64Mul(lhs_matcher, rhs_matcher)
|
| + : IsInt32Mul(lhs_matcher, rhs_matcher);
|
| +}
|
| +
|
| Matcher<Node*> IsWordShl(const Matcher<Node*>& lhs_matcher,
|
| const Matcher<Node*>& rhs_matcher) {
|
| return kPointerSize == 8 ? IsWord64Shl(lhs_matcher, rhs_matcher)
|
| @@ -69,6 +75,18 @@ Matcher<Node*> IsWordOr(const Matcher<Node*>& lhs_matcher,
|
| : IsWord32Or(lhs_matcher, rhs_matcher);
|
| }
|
|
|
| +Matcher<Node*> IsChangeInt32ToIntPtr(const Matcher<Node*>& matcher) {
|
| + return kPointerSize == 8 ? IsChangeInt32ToInt64(matcher) : matcher;
|
| +}
|
| +
|
| +Matcher<Node*> IsChangeUint32ToWord(const Matcher<Node*>& matcher) {
|
| + return kPointerSize == 8 ? IsChangeUint32ToUint64(matcher) : matcher;
|
| +}
|
| +
|
| +Matcher<Node*> IsTruncateWordToWord32(const Matcher<Node*>& matcher) {
|
| + return kPointerSize == 8 ? IsTruncateInt64ToInt32(matcher) : matcher;
|
| +}
|
| +
|
| InterpreterAssemblerTest::InterpreterAssemblerForTest::
|
| ~InterpreterAssemblerForTest() {
|
| // Tests don't necessarily read and write accumulator but
|
| @@ -98,11 +116,12 @@ Matcher<Node*> InterpreterAssemblerTest::InterpreterAssemblerForTest::IsStore(
|
| Matcher<Node*>
|
| InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedByteOperand(
|
| int offset) {
|
| - return IsLoad(
|
| + Matcher<Node*> load_matcher = IsLoad(
|
| MachineType::Uint8(),
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| IsIntPtrConstant(offset)));
|
| + return IsChangeUint32ToWord(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| @@ -113,17 +132,15 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedByteOperand(
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| IsIntPtrConstant(offset)));
|
| - if (kPointerSize == 8) {
|
| - load_matcher = IsChangeInt32ToInt64(load_matcher);
|
| - }
|
| - return load_matcher;
|
| + return IsChangeInt32ToIntPtr(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand(
|
| int offset) {
|
| + Matcher<Node*> load_matcher;
|
| if (TargetSupportsUnalignedAccess()) {
|
| - return IsLoad(
|
| + load_matcher = IsLoad(
|
| MachineType::Uint16(),
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| @@ -147,9 +164,10 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedShortOperand(
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| IsIntPtrConstant(offset + kMsbOffset + kStep * i)));
|
| }
|
| - return IsWord32Or(IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)),
|
| - bytes[1]);
|
| + load_matcher = IsWord32Or(
|
| + IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]);
|
| }
|
| + return IsChangeUint32ToWord(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| @@ -184,18 +202,15 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedShortOperand(
|
| load_matcher = IsWord32Or(
|
| IsWord32Shl(bytes[0], IsInt32Constant(kBitsPerByte)), bytes[1]);
|
| }
|
| -
|
| - if (kPointerSize == 8) {
|
| - load_matcher = IsChangeInt32ToInt64(load_matcher);
|
| - }
|
| - return load_matcher;
|
| + return IsChangeInt32ToIntPtr(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand(
|
| int offset) {
|
| + Matcher<Node*> load_matcher;
|
| if (TargetSupportsUnalignedAccess()) {
|
| - return IsLoad(
|
| + load_matcher = IsLoad(
|
| MachineType::Uint32(),
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| IsIntPtrAdd(IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| @@ -219,13 +234,14 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsUnsignedQuadOperand(
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeOffset),
|
| IsIntPtrConstant(offset + kMsbOffset + kStep * i)));
|
| }
|
| - return IsWord32Or(
|
| + load_matcher = IsWord32Or(
|
| IsWord32Shl(bytes[0], IsInt32Constant(3 * kBitsPerByte)),
|
| IsWord32Or(
|
| IsWord32Shl(bytes[1], IsInt32Constant(2 * kBitsPerByte)),
|
| IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)),
|
| bytes[3])));
|
| }
|
| + return IsChangeUint32ToWord(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| @@ -264,11 +280,7 @@ InterpreterAssemblerTest::InterpreterAssemblerForTest::IsSignedQuadOperand(
|
| IsWord32Or(IsWord32Shl(bytes[2], IsInt32Constant(1 * kBitsPerByte)),
|
| bytes[3])));
|
| }
|
| -
|
| - if (kPointerSize == 8) {
|
| - load_matcher = IsChangeInt32ToInt64(load_matcher);
|
| - }
|
| - return load_matcher;
|
| + return IsChangeInt32ToIntPtr(load_matcher);
|
| }
|
|
|
| Matcher<Node*>
|
| @@ -318,9 +330,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
|
| m.IsLoad(MachineType::Uint8(),
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| next_bytecode_offset_matcher);
|
| - if (kPointerSize == 8) {
|
| - target_bytecode_matcher = IsChangeUint32ToUint64(target_bytecode_matcher);
|
| - }
|
| + target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher);
|
| Matcher<Node*> code_target_matcher = m.IsLoad(
|
| MachineType::Pointer(),
|
| IsParameter(InterpreterDispatchDescriptor::kDispatchTable),
|
| @@ -338,10 +348,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, Dispatch) {
|
| m.IsLoad(MachineType::Uint8(),
|
| IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| after_lookahead_offset);
|
| - if (kPointerSize == 8) {
|
| - after_lookahead_bytecode =
|
| - IsChangeUint32ToUint64(after_lookahead_bytecode);
|
| - }
|
| + after_lookahead_bytecode = IsChangeUint32ToWord(after_lookahead_bytecode);
|
| target_bytecode_matcher =
|
| IsPhi(MachineType::PointerRepresentation(), target_bytecode_matcher,
|
| after_lookahead_bytecode, _);
|
| @@ -381,10 +388,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, Jump) {
|
| IsIntPtrConstant(jump_offset));
|
| Matcher<Node*> target_bytecode_matcher =
|
| m.IsLoad(MachineType::Uint8(), _, next_bytecode_offset_matcher);
|
| - if (kPointerSize == 8) {
|
| - target_bytecode_matcher =
|
| - IsChangeUint32ToUint64(target_bytecode_matcher);
|
| - }
|
| + target_bytecode_matcher = IsChangeUint32ToWord(target_bytecode_matcher);
|
| Matcher<Node*> code_target_matcher =
|
| m.IsLoad(MachineType::Pointer(),
|
| IsParameter(InterpreterDispatchDescriptor::kDispatchTable),
|
| @@ -599,18 +603,35 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
|
| TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
|
| InterpreterAssemblerTestState state(this, bytecode);
|
| InterpreterAssemblerForTest m(&state, bytecode);
|
| - Node* index = m.IntPtrConstant(2);
|
| - Node* load_constant = m.LoadConstantPoolEntry(index);
|
| - Matcher<Node*> constant_pool_matcher = m.IsLoad(
|
| - MachineType::AnyTagged(),
|
| - IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| - IsIntPtrConstant(BytecodeArray::kConstantPoolOffset - kHeapObjectTag));
|
| - EXPECT_THAT(
|
| - load_constant,
|
| - m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher,
|
| - IsIntPtrAdd(
|
| - IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
|
| - IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2)))));
|
| + {
|
| + Node* index = m.IntPtrConstant(2);
|
| + Node* load_constant = m.LoadConstantPoolEntry(index);
|
| + Matcher<Node*> constant_pool_matcher =
|
| + m.IsLoad(MachineType::AnyTagged(),
|
| + IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| + IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
|
| + kHeapObjectTag));
|
| + EXPECT_THAT(load_constant,
|
| + m.IsLoad(MachineType::AnyTagged(), constant_pool_matcher,
|
| + IsIntPtrConstant(FixedArray::OffsetOfElementAt(2) -
|
| + kHeapObjectTag)));
|
| + }
|
| + {
|
| + Node* index = m.Parameter(2);
|
| + Node* load_constant = m.LoadConstantPoolEntry(index);
|
| + Matcher<Node*> constant_pool_matcher =
|
| + m.IsLoad(MachineType::AnyTagged(),
|
| + IsParameter(InterpreterDispatchDescriptor::kBytecodeArray),
|
| + IsIntPtrConstant(BytecodeArray::kConstantPoolOffset -
|
| + kHeapObjectTag));
|
| + EXPECT_THAT(
|
| + load_constant,
|
| + m.IsLoad(
|
| + MachineType::AnyTagged(), constant_pool_matcher,
|
| + IsIntPtrAdd(
|
| + IsIntPtrConstant(FixedArray::kHeaderSize - kHeapObjectTag),
|
| + IsWordShl(index, IsIntPtrConstant(kPointerSizeLog2)))));
|
| + }
|
| }
|
| }
|
|
|
| @@ -648,16 +669,17 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) {
|
| InterpreterAssemblerForTest m(&state, bytecode);
|
| Callable builtin = CodeFactory::InterpreterCEntry(isolate(), result_size);
|
|
|
| - Node* function_id = m.Int32Constant(0);
|
| - Node* first_arg = m.Int32Constant(1);
|
| - Node* arg_count = m.Int32Constant(2);
|
| - Node* context = m.Int32Constant(4);
|
| + Node* function_id = m.IntPtrConstant(0);
|
| + Node* first_arg = m.IntPtrConstant(1);
|
| + Node* arg_count = m.IntPtrConstant(2);
|
| + Node* context = m.IntPtrConstant(4);
|
|
|
| Matcher<Node*> function_table = IsExternalConstant(
|
| ExternalReference::runtime_function_table_address(isolate()));
|
| - Matcher<Node*> function = IsIntPtrAdd(
|
| - function_table,
|
| - IsInt32Mul(function_id, IsInt32Constant(sizeof(Runtime::Function))));
|
| + Matcher<Node*> function =
|
| + IsIntPtrAdd(function_table,
|
| + IsIntPtrMul(function_id,
|
| + IsIntPtrConstant(sizeof(Runtime::Function))));
|
| Matcher<Node*> function_entry =
|
| m.IsLoad(MachineType::Pointer(), function,
|
| IsIntPtrConstant(offsetof(Runtime::Function, entry)));
|
| @@ -665,8 +687,9 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) {
|
| Node* call_runtime = m.CallRuntimeN(function_id, context, first_arg,
|
| arg_count, result_size);
|
| EXPECT_THAT(call_runtime,
|
| - IsCall(_, IsHeapConstant(builtin.code()), arg_count,
|
| - first_arg, function_entry, context, _, _));
|
| + IsCall(_, IsHeapConstant(builtin.code()),
|
| + IsTruncateWordToWord32(arg_count), first_arg,
|
| + function_entry, context, _, _));
|
| }
|
| }
|
| }
|
| @@ -680,14 +703,15 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallJS) {
|
| InterpreterAssemblerForTest m(&state, bytecode);
|
| Callable builtin =
|
| CodeFactory::InterpreterPushArgsAndCall(isolate(), tail_call_mode);
|
| - Node* function = m.Int32Constant(0);
|
| - Node* first_arg = m.Int32Constant(1);
|
| - Node* arg_count = m.Int32Constant(2);
|
| - Node* context = m.Int32Constant(3);
|
| + Node* function = m.IntPtrConstant(0);
|
| + Node* first_arg = m.IntPtrConstant(1);
|
| + Node* arg_count = m.IntPtrConstant(2);
|
| + Node* context = m.IntPtrConstant(3);
|
| Node* call_js =
|
| m.CallJS(function, context, first_arg, arg_count, tail_call_mode);
|
| - EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()), arg_count,
|
| - first_arg, function, context, _, _));
|
| + EXPECT_THAT(call_js, IsCall(_, IsHeapConstant(builtin.code()),
|
| + IsTruncateWordToWord32(arg_count), first_arg,
|
| + function, context, _, _));
|
| }
|
| }
|
| }
|
|
|