Commit c4db8bf5 authored by Leszek Swirski's avatar Leszek Swirski Committed by Commit Bot

[cleanup] TNodify nodes which are set by a TNode function

Automated cleanup which finds patterns of `Node* a = foo` where `foo` is
a TNode expression, and replaces Node* with the appropriate TNode.

Bug: v8:9396
Change-Id: I8b0cd9baf10e74d6e2e336eae62eca6cfe6a9c11
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1762515
Commit-Queue: Leszek Swirski <leszeks@chromium.org>
Auto-Submit: Leszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarTobias Tebbi <tebbi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#63335}
parent 4f0ee93b
......@@ -229,7 +229,7 @@ void CodeAssembler::GenerateCheckMaybeObjectIsObject(Node* node,
&ok);
EmbeddedVector<char, 1024> message;
SNPrintF(message, "no Object: %s", location);
Node* message_node = StringConstant(message.begin());
TNode<String> message_node = StringConstant(message.begin());
// This somewhat misuses the AbortCSAAssert runtime function. This will print
// "abort: CSA_ASSERT failed: <message>", which is good enough.
AbortCSAAssert(message_node);
......@@ -384,6 +384,9 @@ TNode<Context> CodeAssembler::GetJSContextParameter() {
}
void CodeAssembler::Return(SloppyTNode<Object> value) {
// TODO(leszeks): This could also return a non-object, depending on the call
// descriptor. We should probably have multiple return overloads with
// different TNode types which DCHECK the call descriptor.
return raw_assembler()->Return(value);
}
......@@ -990,7 +993,7 @@ TNode<Object> CodeAssembler::LoadRoot(RootIndex root_index) {
// TODO(jgruber): In theory we could generate better code for this by
// letting the macro assembler decide how to load from the roots list. In most
// cases, it would boil down to loading from a fixed kRootRegister offset.
Node* isolate_root =
TNode<ExternalReference> isolate_root =
ExternalConstant(ExternalReference::isolate_root(isolate()));
int offset = IsolateData::root_slot_offset(root_index);
return UncheckedCast<Object>(
......@@ -1130,7 +1133,7 @@ Node* CodeAssembler::AtomicCompareExchange(MachineType type, Node* base,
Node* CodeAssembler::StoreRoot(RootIndex root_index, Node* value) {
DCHECK(!RootsTable::IsImmortalImmovable(root_index));
Node* isolate_root =
TNode<ExternalReference> isolate_root =
ExternalConstant(ExternalReference::isolate_root(isolate()));
int offset = IsolateData::root_slot_offset(root_index);
return StoreFullTaggedNoWriteBarrier(isolate_root, IntPtrConstant(offset),
......@@ -1245,8 +1248,9 @@ TNode<Object> CodeAssembler::CallRuntimeWithCEntryImpl(
Runtime::MayAllocate(function) ? CallDescriptor::kNoFlags
: CallDescriptor::kNoAllocate);
Node* ref = ExternalConstant(ExternalReference::Create(function));
Node* arity = Int32Constant(argc);
TNode<ExternalReference> ref =
ExternalConstant(ExternalReference::Create(function));
TNode<Int32T> arity = Int32Constant(argc);
NodeArray<kMaxNumArgs + 4> inputs;
inputs.Add(centry);
......@@ -1282,7 +1286,8 @@ void CodeAssembler::TailCallRuntimeWithCEntryImpl(
zone(), function, argc, Operator::kNoProperties,
CallDescriptor::kNoFlags);
Node* ref = ExternalConstant(ExternalReference::Create(function));
TNode<ExternalReference> ref =
ExternalConstant(ExternalReference::Create(function));
NodeArray<kMaxNumArgs + 4> inputs;
inputs.Add(centry);
......
......@@ -739,7 +739,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
if (std::is_same<PreviousType, MaybeObject>::value) {
code_assembler_->GenerateCheckMaybeObjectIsObject(node_, location_);
}
Node* function = code_assembler_->ExternalConstant(
TNode<ExternalReference> function = code_assembler_->ExternalConstant(
ExternalReference::check_object_type());
code_assembler_->CallCFunction(
function, MachineType::AnyTagged(),
......@@ -1426,7 +1426,7 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* CallJS(Callable const& callable, Node* context, Node* function,
Node* receiver, TArgs... args) {
int argc = static_cast<int>(sizeof...(args));
Node* arity = Int32Constant(argc);
TNode<Int32T> arity = Int32Constant(argc);
return CallStub(callable, context, function, arity, receiver, args...);
}
......@@ -1434,8 +1434,8 @@ class V8_EXPORT_PRIVATE CodeAssembler {
Node* ConstructJSWithTarget(Callable const& callable, Node* context,
Node* target, Node* new_target, TArgs... args) {
int argc = static_cast<int>(sizeof...(args));
Node* arity = Int32Constant(argc);
Node* receiver = LoadRoot(RootIndex::kUndefinedValue);
TNode<Int32T> arity = Int32Constant(argc);
TNode<Object> receiver = LoadRoot(RootIndex::kUndefinedValue);
// Construct(target, new_target, arity, receiver, arguments...)
return CallStub(callable, context, target, new_target, arity, receiver,
......
......@@ -124,7 +124,7 @@ Node* IntrinsicsGenerator::InvokeIntrinsic(
Node* IntrinsicsGenerator::CompareInstanceType(Node* object, int type,
InstanceTypeCompareMode mode) {
Node* instance_type = __ LoadInstanceType(object);
TNode<Uint16T> instance_type = __ LoadInstanceType(object);
if (mode == kInstanceTypeEqual) {
return __ Word32Equal(instance_type, __ Int32Constant(type));
......@@ -239,7 +239,7 @@ Node* IntrinsicsGenerator::Call(
if (FLAG_debug_code) {
InterpreterAssembler::Label arg_count_positive(assembler_);
Node* comparison =
TNode<BoolT> comparison =
__ Int32LessThan(target_args.reg_count(), __ Int32Constant(0));
__ GotoIfNot(comparison, &arg_count_positive);
__ Abort(AbortReason::kWrongArgumentCountForInvokeIntrinsic);
......@@ -265,13 +265,13 @@ Node* IntrinsicsGenerator::CreateAsyncFromSyncIterator(
__ GotoIf(__ TaggedIsSmi(sync_iterator), &not_receiver);
__ GotoIfNot(__ IsJSReceiver(sync_iterator), &not_receiver);
Node* const next =
TNode<Object> const next =
__ GetProperty(context, sync_iterator, factory()->next_string());
Node* const native_context = __ LoadNativeContext(context);
Node* const map = __ LoadContextElement(
native_context, Context::ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX);
Node* const iterator = __ AllocateJSObjectFromMap(map);
TNode<Context> const native_context = __ LoadNativeContext(context);
TNode<Map> const map = __ CAST(__ LoadContextElement(
native_context, Context::ASYNC_FROM_SYNC_ITERATOR_MAP_INDEX));
TNode<JSObject> const iterator = __ AllocateJSObjectFromMap(map);
__ StoreObjectFieldNoWriteBarrier(
iterator, JSAsyncFromSyncIterator::kSyncIteratorOffset, sync_iterator);
......@@ -303,7 +303,7 @@ Node* IntrinsicsGenerator::CreateJSGeneratorObject(
Node* IntrinsicsGenerator::GeneratorGetResumeMode(
const InterpreterAssembler::RegListNodePair& args, Node* context) {
Node* generator = __ LoadRegisterFromRegisterList(args, 0);
Node* const value =
TNode<Object> const value =
__ LoadObjectField(generator, JSGeneratorObject::kResumeModeOffset);
return value;
......@@ -320,10 +320,10 @@ Node* IntrinsicsGenerator::GeneratorClose(
Node* IntrinsicsGenerator::GetImportMetaObject(
const InterpreterAssembler::RegListNodePair& args, Node* context) {
Node* const module_context = __ LoadModuleContext(context);
Node* const module =
__ LoadContextElement(module_context, Context::EXTENSION_INDEX);
Node* const import_meta =
TNode<Context> const module_context = __ LoadModuleContext(context);
TNode<HeapObject> const module =
__ CAST(__ LoadContextElement(module_context, Context::EXTENSION_INDEX));
TNode<Object> const import_meta =
__ LoadObjectField(module, SourceTextModule::kImportMetaOffset);
InterpreterAssembler::Variable return_value(assembler_,
......@@ -397,7 +397,7 @@ Node* IntrinsicsGenerator::AsyncGeneratorYield(
void IntrinsicsGenerator::AbortIfArgCountMismatch(int expected, Node* actual) {
InterpreterAssembler::Label match(assembler_);
Node* comparison = __ Word32Equal(actual, __ Int32Constant(expected));
TNode<BoolT> comparison = __ Word32Equal(actual, __ Int32Constant(expected));
__ GotoIf(comparison, &match);
__ Abort(AbortReason::kWrongArgumentCountForInvokeIntrinsic);
__ Goto(&match);
......
......@@ -89,7 +89,8 @@ TEST(SimpleCallRuntime1Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* b = SmiTag(m, m.Int32Constant(0));
m.Return(m.CallRuntime(Runtime::kIsSmi, context, b));
FunctionTester ft(asm_tester.GenerateCode());
......@@ -101,7 +102,8 @@ TEST(SimpleTailCallRuntime1Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* b = SmiTag(m, m.Int32Constant(0));
m.TailCallRuntime(Runtime::kIsSmi, context, b);
FunctionTester ft(asm_tester.GenerateCode());
......@@ -113,7 +115,8 @@ TEST(SimpleCallRuntime2Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* a = SmiTag(m, m.Int32Constant(2));
Node* b = SmiTag(m, m.Int32Constant(4));
m.Return(m.CallRuntime(Runtime::kAdd, context, a, b));
......@@ -125,7 +128,8 @@ TEST(SimpleTailCallRuntime2Arg) {
Isolate* isolate(CcTest::InitIsolateOnce());
CodeAssemblerTester asm_tester(isolate);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* a = SmiTag(m, m.Int32Constant(2));
Node* b = SmiTag(m, m.Int32Constant(4));
m.TailCallRuntime(Runtime::kAdd, context, a, b);
......@@ -225,7 +229,7 @@ TEST(VariableMerge1) {
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
Label l1(&m), l2(&m), merge(&m);
Node* temp = m.Int32Constant(0);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
......@@ -244,14 +248,14 @@ TEST(VariableMerge2) {
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
Label l1(&m), l2(&m), merge(&m);
Node* temp = m.Int32Constant(0);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
CHECK_EQ(var1.value(), temp);
m.Goto(&merge);
m.Bind(&l2);
Node* temp2 = m.Int32Constant(2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
......@@ -266,7 +270,7 @@ TEST(VariableMerge3) {
Variable var1(&m, MachineRepresentation::kTagged);
Variable var2(&m, MachineRepresentation::kTagged);
Label l1(&m), l2(&m), merge(&m);
Node* temp = m.Int32Constant(0);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
var2.Bind(temp);
m.Branch(m.Int32Constant(1), &l1, &l2);
......@@ -274,7 +278,7 @@ TEST(VariableMerge3) {
CHECK_EQ(var1.value(), temp);
m.Goto(&merge);
m.Bind(&l2);
Node* temp2 = m.Int32Constant(2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
......@@ -290,7 +294,7 @@ TEST(VariableMergeBindFirst) {
CodeAssembler m(asm_tester.state());
Variable var1(&m, MachineRepresentation::kTagged);
Label l1(&m), l2(&m), merge(&m, &var1), end(&m);
Node* temp = m.Int32Constant(0);
TNode<Int32T> temp = m.Int32Constant(0);
var1.Bind(temp);
m.Branch(m.Int32Constant(1), &l1, &l2);
m.Bind(&l1);
......@@ -301,7 +305,7 @@ TEST(VariableMergeBindFirst) {
CHECK_NOT_NULL(var1.value());
m.Goto(&end);
m.Bind(&l2);
Node* temp2 = m.Int32Constant(2);
TNode<Int32T> temp2 = m.Int32Constant(2);
var1.Bind(temp2);
CHECK_EQ(var1.value(), temp2);
m.Goto(&merge);
......@@ -318,7 +322,7 @@ TEST(VariableMergeSwitch) {
Label l1(&m), l2(&m), default_label(&m);
Label* labels[] = {&l1, &l2};
int32_t values[] = {1, 2};
Node* temp1 = m.Int32Constant(0);
TNode<Smi> temp1 = m.SmiConstant(0);
var1.Bind(temp1);
m.Switch(m.Int32Constant(2), &default_label, values, labels, 2);
m.Bind(&l1);
......@@ -326,7 +330,7 @@ TEST(VariableMergeSwitch) {
m.Return(temp1);
m.Bind(&l2);
CHECK_EQ(temp1, var1.value());
Node* temp2 = m.Int32Constant(7);
TNode<Smi> temp2 = m.SmiConstant(7);
var1.Bind(temp2);
m.Goto(&default_label);
m.Bind(&default_label);
......@@ -453,14 +457,15 @@ TEST(GotoIfException) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* to_string_tag =
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Symbol> to_string_tag =
m.HeapConstant(isolate->factory()->to_string_tag_symbol());
Variable exception(&m, MachineRepresentation::kTagged);
Label exception_handler(&m);
Callable to_string = Builtins::CallableFor(isolate, Builtins::kToString);
Node* string = m.CallStub(to_string, context, to_string_tag);
TNode<Object> string = m.CallStub(to_string, context, to_string_tag);
m.GotoIfException(string, &exception_handler, &exception);
m.Return(string);
......@@ -487,7 +492,8 @@ TEST(GotoIfExceptionMultiple) {
CodeAssemblerTester asm_tester(isolate, kNumParams);
CodeAssembler m(asm_tester.state());
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
Node* first_value = m.Parameter(0);
Node* second_value = m.Parameter(1);
Node* third_value = m.Parameter(2);
......@@ -502,7 +508,7 @@ TEST(GotoIfExceptionMultiple) {
// try { return ToString(param1) } catch (e) { ... }
Callable to_string = Builtins::CallableFor(isolate, Builtins::kToString);
Node* string = m.CallStub(to_string, context, first_value);
TNode<Object> string = m.CallStub(to_string, context, first_value);
m.GotoIfException(string, &exception_handler1, &error);
m.Return(string);
......@@ -575,7 +581,8 @@ TEST(ExceptionHandler) {
Label exception(&m, {&var}, Label::kDeferred);
{
CodeAssemblerScopedExceptionHandler handler(&m, &exception, &var);
Node* context = m.HeapConstant(Handle<Context>(isolate->native_context()));
TNode<Context> context =
m.HeapConstant(Handle<Context>(isolate->native_context()));
m.CallRuntime(Runtime::kThrow, context, m.SmiConstant(2));
}
m.Return(m.SmiConstant(1));
......
......@@ -223,7 +223,7 @@ Handle<Code> BuildTeardownFunction(Isolate* isolate,
TNode<FixedArray> vector =
__ Cast(__ LoadFixedArrayElement(result_array, i));
for (int lane = 0; lane < 4; lane++) {
Node* lane_value =
TNode<Smi> lane_value =
__ SmiFromInt32(tester.raw_assembler_for_testing()->AddNode(
tester.raw_assembler_for_testing()
->machine()
......
......@@ -27,7 +27,8 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) {
int param_count = static_cast<int>(call_descriptor->StackParameterCount());
Node* sum = __ IntPtrConstant(0);
for (int i = 0; i < param_count; ++i) {
Node* product = __ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1));
TNode<IntPtrT> product =
__ Signed(__ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1)));
sum = __ IntPtrAdd(sum, product);
}
__ Return(sum);
......
......@@ -28,8 +28,9 @@ Handle<Code> BuildCallee(Isolate* isolate, CallDescriptor* call_descriptor) {
int param_count = static_cast<int>(call_descriptor->StackParameterCount());
Node* sum = __ IntPtrConstant(0);
for (int i = 0; i < param_count; ++i) {
Node* product = __ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1));
sum = __ IntPtrAdd(sum, product);
TNode<WordT> product =
__ IntPtrMul(__ Parameter(i), __ IntPtrConstant(i + 1));
sum = __ Signed(__ IntPtrAdd(sum, product));
}
__ Return(sum);
return tester.GenerateCodeCloseAndEscape();
......
This diff is collapsed.
......@@ -114,7 +114,7 @@ TEST(TestBuiltinSpecialization) {
CodeAssemblerTester asm_tester(isolate, 0);
TestTorqueAssembler m(asm_tester.state());
{
Node* temp = m.SmiConstant(0);
TNode<Object> temp = m.SmiConstant(0);
m.TestBuiltinSpecialization(m.UncheckedCast<Context>(temp));
m.Return(m.UndefinedConstant());
}
......@@ -171,7 +171,7 @@ TEST(TestFunctionPointerToGeneric) {
CodeAssemblerTester asm_tester(isolate, 0);
TestTorqueAssembler m(asm_tester.state());
{
Node* temp = m.SmiConstant(0);
TNode<Object> temp = m.SmiConstant(0);
m.TestFunctionPointerToGeneric(m.UncheckedCast<Context>(temp));
m.Return(m.UndefinedConstant());
}
......@@ -184,8 +184,8 @@ TEST(TestUnsafeCast) {
CodeAssemblerTester asm_tester(isolate, 0);
TestTorqueAssembler m(asm_tester.state());
{
Node* temp = m.SmiConstant(0);
Node* n = m.SmiConstant(10);
TNode<Object> temp = m.SmiConstant(0);
TNode<Smi> n = m.SmiConstant(10);
m.Return(m.TestUnsafeCast(m.UncheckedCast<Context>(temp),
m.UncheckedCast<Number>(n)));
}
......
......@@ -14,6 +14,7 @@
using ::testing::_;
using v8::internal::compiler::Node;
using v8::internal::compiler::TNode;
namespace c = v8::internal::compiler;
......@@ -29,11 +30,11 @@ CodeStubAssemblerTestState::CodeStubAssemblerTestState(
TARGET_TEST_F(CodeStubAssemblerTest, SmiTag) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
Node* value = m.Int32Constant(44);
TNode<IntPtrT> value = m.IntPtrConstant(44);
EXPECT_THAT(m.SmiTag(value),
IsBitcastWordToTaggedSigned(c::IsIntPtrConstant(
static_cast<intptr_t>(44) << (kSmiShiftSize + kSmiTagSize))));
EXPECT_THAT(m.SmiUntag(value),
EXPECT_THAT(m.SmiUntag(m.ReinterpretCast<Smi>(value)),
c::IsIntPtrConstant(static_cast<intptr_t>(44) >>
(kSmiShiftSize + kSmiTagSize)));
}
......@@ -42,9 +43,9 @@ TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMax) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* z = m.IntPtrMax(a, b);
TNode<IntPtrT> a = m.IntPtrConstant(100);
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<IntPtrT> z = m.IntPtrMax(a, b);
EXPECT_THAT(z, c::IsIntPtrConstant(100));
}
}
......@@ -53,9 +54,9 @@ TARGET_TEST_F(CodeStubAssemblerTest, IntPtrMin) {
CodeStubAssemblerTestState state(this);
CodeStubAssemblerForTest m(&state);
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* z = m.IntPtrMin(a, b);
TNode<IntPtrT> a = m.IntPtrConstant(100);
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<IntPtrT> z = m.IntPtrMin(a, b);
EXPECT_THAT(z, c::IsIntPtrConstant(1));
}
}
......
......@@ -13,6 +13,7 @@
#include "test/unittests/compiler/node-test-utils.h"
using ::testing::_;
using ::testing::Eq;
namespace v8 {
namespace internal {
......@@ -28,29 +29,29 @@ TARGET_TEST_F(CodeAssemblerTest, IntPtrAdd) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* add = m.IntPtrAdd(a, b);
EXPECT_THAT(add, IsIntPtrAdd(a, b));
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<WordT> add = m.IntPtrAdd(a, b);
EXPECT_THAT(add, IsIntPtrAdd(Eq(a), Eq(b)));
}
// x + 0 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* add = m.IntPtrAdd(a, b);
TNode<IntPtrT> b = m.IntPtrConstant(0);
TNode<WordT> add = m.IntPtrAdd(a, b);
EXPECT_THAT(add, a);
}
// 0 + x => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* add = m.IntPtrAdd(b, a);
TNode<IntPtrT> b = m.IntPtrConstant(0);
TNode<WordT> add = m.IntPtrAdd(b, a);
EXPECT_THAT(add, a);
}
// CONST_a + CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(22);
Node* b = m.IntPtrConstant(33);
Node* c = m.IntPtrAdd(a, b);
TNode<IntPtrT> a = m.IntPtrConstant(22);
TNode<IntPtrT> b = m.IntPtrConstant(33);
TNode<WordT> c = m.IntPtrAdd(a, b);
EXPECT_THAT(c, IsIntPtrConstant(55));
}
}
......@@ -60,22 +61,22 @@ TARGET_TEST_F(CodeAssemblerTest, IntPtrSub) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* sub = m.IntPtrSub(a, b);
EXPECT_THAT(sub, IsIntPtrSub(a, b));
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<WordT> sub = m.IntPtrSub(a, b);
EXPECT_THAT(sub, IsIntPtrSub(Eq(a), Eq(b)));
}
// x - 0 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(0);
Node* c = m.IntPtrSub(a, b);
TNode<IntPtrT> b = m.IntPtrConstant(0);
TNode<WordT> c = m.IntPtrSub(a, b);
EXPECT_THAT(c, a);
}
// CONST_a - CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(1);
Node* c = m.IntPtrSub(a, b);
TNode<IntPtrT> a = m.IntPtrConstant(100);
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<WordT> c = m.IntPtrSub(a, b);
EXPECT_THAT(c, IsIntPtrConstant(99));
}
}
......@@ -85,43 +86,43 @@ TARGET_TEST_F(CodeAssemblerTest, IntPtrMul) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(100);
Node* mul = m.IntPtrMul(a, b);
EXPECT_THAT(mul, IsIntPtrMul(a, b));
TNode<IntPtrT> b = m.IntPtrConstant(100);
TNode<WordT> mul = m.IntPtrMul(a, b);
EXPECT_THAT(mul, IsIntPtrMul(Eq(a), Eq(b)));
}
// x * 1 => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* mul = m.IntPtrMul(a, b);
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<WordT> mul = m.IntPtrMul(a, b);
EXPECT_THAT(mul, a);
}
// 1 * x => x
{
Node* a = m.Parameter(0);
Node* b = m.Int32Constant(1);
Node* mul = m.IntPtrMul(b, a);
TNode<IntPtrT> b = m.IntPtrConstant(1);
TNode<WordT> mul = m.IntPtrMul(b, a);
EXPECT_THAT(mul, a);
}
// CONST_a * CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(100);
Node* b = m.IntPtrConstant(5);
Node* c = m.IntPtrMul(a, b);
TNode<IntPtrT> a = m.IntPtrConstant(100);
TNode<IntPtrT> b = m.IntPtrConstant(5);
TNode<WordT> c = m.IntPtrMul(a, b);
EXPECT_THAT(c, IsIntPtrConstant(500));
}
// x * 2^CONST => x << CONST
{
Node* a = m.Parameter(0);
Node* b = m.IntPtrConstant(1 << 3);
Node* c = m.IntPtrMul(a, b);
TNode<IntPtrT> b = m.IntPtrConstant(1 << 3);
TNode<WordT> c = m.IntPtrMul(a, b);
EXPECT_THAT(c, IsWordShl(a, IsIntPtrConstant(3)));
}
// 2^CONST * x => x << CONST
{
Node* a = m.IntPtrConstant(1 << 3);
TNode<IntPtrT> a = m.IntPtrConstant(1 << 3);
Node* b = m.Parameter(0);
Node* c = m.IntPtrMul(a, b);
TNode<WordT> c = m.IntPtrMul(a, b);
EXPECT_THAT(c, IsWordShl(b, IsIntPtrConstant(3)));
}
}
......@@ -169,19 +170,19 @@ TARGET_TEST_F(CodeAssemblerTest, WordShl) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* add = m.WordShl(a, 10);
TNode<WordT> add = m.WordShl(a, 10);
EXPECT_THAT(add, IsWordShl(a, IsIntPtrConstant(10)));
}
// x << 0 => x
{
Node* a = m.Parameter(0);
Node* add = m.WordShl(a, 0);
TNode<WordT> add = m.WordShl(a, 0);
EXPECT_THAT(add, a);
}
// CONST_a << CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(1024);
Node* shl = m.WordShl(a, 2);
TNode<IntPtrT> a = m.IntPtrConstant(1024);
TNode<WordT> shl = m.WordShl(a, 2);
EXPECT_THAT(shl, IsIntPtrConstant(4096));
}
}
......@@ -191,25 +192,25 @@ TARGET_TEST_F(CodeAssemblerTest, WordShr) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* shr = m.WordShr(a, 10);
TNode<WordT> shr = m.WordShr(a, 10);
EXPECT_THAT(shr, IsWordShr(a, IsIntPtrConstant(10)));
}
// x >> 0 => x
{
Node* a = m.Parameter(0);
Node* shr = m.WordShr(a, 0);
TNode<WordT> shr = m.WordShr(a, 0);
EXPECT_THAT(shr, a);
}
// +CONST_a >> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(4096);
Node* shr = m.WordShr(a, 2);
TNode<IntPtrT> a = m.IntPtrConstant(4096);
TNode<WordT> shr = m.WordShr(a, 2);
EXPECT_THAT(shr, IsIntPtrConstant(1024));
}
// -CONST_a >> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(-1234);
Node* shr = m.WordShr(a, 2);
TNode<IntPtrT> a = m.IntPtrConstant(-1234);
TNode<WordT> shr = m.WordShr(a, 2);
EXPECT_THAT(shr, IsIntPtrConstant(static_cast<uintptr_t>(-1234) >> 2));
}
}
......@@ -219,25 +220,25 @@ TARGET_TEST_F(CodeAssemblerTest, WordSar) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* sar = m.WordSar(a, m.IntPtrConstant(10));
TNode<WordT> sar = m.WordSar(a, m.IntPtrConstant(10));
EXPECT_THAT(sar, IsWordSar(a, IsIntPtrConstant(10)));
}
// x >>> 0 => x
{
Node* a = m.Parameter(0);
Node* sar = m.WordSar(a, m.IntPtrConstant(0));
TNode<WordT> sar = m.WordSar(a, m.IntPtrConstant(0));
EXPECT_THAT(sar, a);
}
// +CONST_a >>> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(4096);
Node* sar = m.WordSar(a, m.IntPtrConstant(2));
TNode<IntPtrT> a = m.IntPtrConstant(4096);
TNode<WordT> sar = m.WordSar(a, m.IntPtrConstant(2));
EXPECT_THAT(sar, IsIntPtrConstant(1024));
}
// -CONST_a >>> CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(-1234);
Node* sar = m.WordSar(a, m.IntPtrConstant(2));
TNode<IntPtrT> a = m.IntPtrConstant(-1234);
TNode<WordT> sar = m.WordSar(a, m.IntPtrConstant(2));
EXPECT_THAT(sar, IsIntPtrConstant(static_cast<intptr_t>(-1234) >> 2));
}
}
......@@ -247,25 +248,25 @@ TARGET_TEST_F(CodeAssemblerTest, WordOr) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(a, m.IntPtrConstant(8));
TNode<WordT> z = m.WordOr(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordOr(a, IsIntPtrConstant(8)));
}
// x | 0 => x
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(a, m.IntPtrConstant(0));
TNode<WordT> z = m.WordOr(a, m.IntPtrConstant(0));
EXPECT_THAT(z, a);
}
// 0 | x => x
{
Node* a = m.Parameter(0);
Node* z = m.WordOr(m.IntPtrConstant(0), a);
TNode<WordT> z = m.WordOr(m.IntPtrConstant(0), a);
EXPECT_THAT(z, a);
}
// CONST_a | CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordOr(a, m.IntPtrConstant(7));
TNode<IntPtrT> a = m.IntPtrConstant(3);
TNode<WordT> b = m.WordOr(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(7));
}
}
......@@ -275,13 +276,13 @@ TARGET_TEST_F(CodeAssemblerTest, WordAnd) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordAnd(a, m.IntPtrConstant(8));
TNode<WordT> z = m.WordAnd(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordAnd(a, IsIntPtrConstant(8)));
}
// CONST_a & CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordAnd(a, m.IntPtrConstant(7));
TNode<IntPtrT> a = m.IntPtrConstant(3);
TNode<WordT> b = m.WordAnd(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(3));
}
}
......@@ -291,13 +292,13 @@ TARGET_TEST_F(CodeAssemblerTest, WordXor) {
CodeAssemblerForTest m(&state);
{
Node* a = m.Parameter(0);
Node* z = m.WordXor(a, m.IntPtrConstant(8));
TNode<WordT> z = m.WordXor(a, m.IntPtrConstant(8));
EXPECT_THAT(z, IsWordXor(a, IsIntPtrConstant(8)));
}
// CONST_a ^ CONST_b => CONST_c
{
Node* a = m.IntPtrConstant(3);
Node* b = m.WordXor(a, m.IntPtrConstant(7));
TNode<IntPtrT> a = m.IntPtrConstant(3);
TNode<WordT> b = m.WordXor(a, m.IntPtrConstant(7));
EXPECT_THAT(b, IsIntPtrConstant(4));
}
}
......
......@@ -14,7 +14,9 @@
#include "test/unittests/compiler/node-test-utils.h"
using ::testing::_;
using ::testing::Eq;
using v8::internal::compiler::Node;
using v8::internal::compiler::TNode;
namespace c = v8::internal::compiler;
......@@ -441,7 +443,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadConstantPoolEntry) {
InterpreterAssemblerTestState state(this, bytecode);
InterpreterAssemblerForTest m(&state, bytecode);
{
Node* index = m.IntPtrConstant(2);
TNode<IntPtrT> index = m.IntPtrConstant(2);
Node* load_constant = m.LoadConstantPoolEntry(index);
#ifdef V8_COMPRESS_POINTERS
Matcher<Node*> constant_pool_matcher =
......@@ -511,16 +513,17 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadObjectField) {
TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
InterpreterAssemblerTestState state(this, bytecode);
InterpreterAssemblerForTest m(&state, bytecode);
Node* object = m.IntPtrConstant(0xDEADBEEF);
TNode<HeapObject> object =
m.ReinterpretCast<HeapObject>(m.IntPtrConstant(0xDEADBEEF));
int offset = 16;
Node* load_field = m.LoadObjectField(object, offset);
TNode<Object> load_field = m.LoadObjectField(object, offset);
#ifdef V8_COMPRESS_POINTERS
EXPECT_THAT(load_field, IsChangeCompressedToTagged(m.IsLoadFromObject(
MachineType::AnyCompressed(), object,
MachineType::AnyCompressed(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag))));
#else
EXPECT_THAT(load_field, m.IsLoadFromObject(
MachineType::AnyTagged(), object,
MachineType::AnyTagged(), Eq(object),
c::IsIntPtrConstant(offset - kHeapObjectTag)));
#endif
}
......@@ -530,12 +533,14 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime2) {
TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
InterpreterAssemblerTestState state(this, bytecode);
InterpreterAssemblerForTest m(&state, bytecode);
Node* arg1 = m.Int32Constant(2);
Node* arg2 = m.Int32Constant(3);
Node* context = m.Int32Constant(4);
Node* call_runtime = m.CallRuntime(Runtime::kAdd, context, arg1, arg2);
EXPECT_THAT(call_runtime, c::IsCall(_, _, arg1, arg2, _,
c::IsInt32Constant(2), context, _, _));
TNode<Object> arg1 = m.ReinterpretCast<Object>(m.Int32Constant(2));
TNode<Object> arg2 = m.ReinterpretCast<Object>(m.Int32Constant(3));
TNode<Object> context = m.ReinterpretCast<Object>(m.Int32Constant(4));
TNode<Object> call_runtime =
m.CallRuntime(Runtime::kAdd, context, arg1, arg2);
EXPECT_THAT(call_runtime,
c::IsCall(_, _, Eq(arg1), Eq(arg2), _, c::IsInt32Constant(2),
Eq(context), _, _));
}
}
......@@ -549,18 +554,19 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) {
Callable builtin =
CodeFactory::InterpreterCEntry(isolate(), result_size);
Node* function_id = m.Int32Constant(0);
TNode<Int32T> function_id = m.Int32Constant(0);
InterpreterAssembler::RegListNodePair registers(m.IntPtrConstant(1),
m.Int32Constant(2));
Node* context = m.IntPtrConstant(4);
TNode<Object> context = m.ReinterpretCast<Object>(m.Int32Constant(4));
Matcher<Node*> function_table = c::IsExternalConstant(
ExternalReference::runtime_function_table_address_for_unittests(
isolate()));
Matcher<Node*> function = c::IsIntPtrAdd(
function_table,
c::IsChangeUint32ToWord(c::IsInt32Mul(
function_id, c::IsInt32Constant(sizeof(Runtime::Function)))));
Matcher<Node*> function =
c::IsIntPtrAdd(function_table,
c::IsChangeUint32ToWord(c::IsInt32Mul(
Eq(function_id),
c::IsInt32Constant(sizeof(Runtime::Function)))));
Matcher<Node*> function_entry =
m.IsLoad(MachineType::Pointer(), function,
c::IsIntPtrConstant(offsetof(Runtime::Function, entry)));
......@@ -571,7 +577,7 @@ TARGET_TEST_F(InterpreterAssemblerTest, CallRuntime) {
call_runtime,
c::IsCall(_, c::IsHeapConstant(builtin.code()),
registers.reg_count(), registers.base_reg_location(),
function_entry, context, _, _));
function_entry, Eq(context), _, _));
}
}
}
......@@ -581,12 +587,13 @@ TARGET_TEST_F(InterpreterAssemblerTest, LoadFeedbackVector) {
TRACED_FOREACH(interpreter::Bytecode, bytecode, kBytecodes) {
InterpreterAssemblerTestState state(this, bytecode);
InterpreterAssemblerForTest m(&state, bytecode);
Node* feedback_vector = m.LoadFeedbackVector();
TNode<HeapObject> feedback_vector = m.LoadFeedbackVector();
// Feedback vector is a phi node with two inputs. One of them is loading the
// feedback vector and the other is undefined constant (when feedback
// vectors aren't allocated). Find the input that loads feedback vector.
CHECK(feedback_vector->opcode() == i::compiler::IrOpcode::kPhi);
CHECK_EQ(static_cast<Node*>(feedback_vector)->opcode(),
i::compiler::IrOpcode::kPhi);
Node* value0 =
i::compiler::NodeProperties::GetValueInput(feedback_vector, 0);
Node* value1 =
......
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