Merge V8 5.2.361.47 DO NOT MERGE
https://chromium.googlesource.com/v8/v8/+/5.2.361.47
FPIIM-449
Change-Id: Ibec421b85a9b88cb3a432ada642e469fe7e78346
(cherry picked from commit bcf72ee8e3b26f1d0726869c7ddb3921c68b09a8)
diff --git a/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc b/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc
index 72cfc51..b088d8e 100644
--- a/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc
+++ b/test/unittests/compiler/arm/instruction-selector-arm-unittest.cc
@@ -2954,6 +2954,78 @@
EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
}
+TEST_F(InstructionSelectorTest, Float32Max) {
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(),
+ MachineType::Float32());
+ Node* const p0 = m.Parameter(0);
+ Node* const p1 = m.Parameter(1);
+ Node* const n = m.Float32Max(p0, p1);
+ m.Return(n);
+ Stream s = m.Build(ARMv8);
+ // Float32Max is `(b < a) ? a : b`.
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArmFloat32Max, s[0]->arch_opcode());
+ ASSERT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
+ ASSERT_EQ(1U, s[0]->OutputCount());
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
+}
+
+TEST_F(InstructionSelectorTest, Float32Min) {
+ StreamBuilder m(this, MachineType::Float32(), MachineType::Float32(),
+ MachineType::Float32());
+ Node* const p0 = m.Parameter(0);
+ Node* const p1 = m.Parameter(1);
+ Node* const n = m.Float32Min(p0, p1);
+ m.Return(n);
+ Stream s = m.Build(ARMv8);
+ // Float32Min is `(a < b) ? a : b`.
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArmFloat32Min, s[0]->arch_opcode());
+ ASSERT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
+ ASSERT_EQ(1U, s[0]->OutputCount());
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
+}
+
+TEST_F(InstructionSelectorTest, Float64Max) {
+ StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(),
+ MachineType::Float64());
+ Node* const p0 = m.Parameter(0);
+ Node* const p1 = m.Parameter(1);
+ Node* const n = m.Float64Max(p0, p1);
+ m.Return(n);
+ Stream s = m.Build(ARMv8);
+ // Float64Max is `(b < a) ? a : b`.
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArmFloat64Max, s[0]->arch_opcode());
+ ASSERT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
+ ASSERT_EQ(1U, s[0]->OutputCount());
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
+}
+
+TEST_F(InstructionSelectorTest, Float64Min) {
+ StreamBuilder m(this, MachineType::Float64(), MachineType::Float64(),
+ MachineType::Float64());
+ Node* const p0 = m.Parameter(0);
+ Node* const p1 = m.Parameter(1);
+ Node* const n = m.Float64Min(p0, p1);
+ m.Return(n);
+ Stream s = m.Build(ARMv8);
+ // Float64Min is `(a < b) ? a : b`.
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArmFloat64Min, s[0]->arch_opcode());
+ ASSERT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
+ EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
+ ASSERT_EQ(1U, s[0]->OutputCount());
+ EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
diff --git a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc
index 73532aa..1c638b2 100644
--- a/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc
+++ b/test/unittests/compiler/arm64/instruction-selector-arm64-unittest.cc
@@ -326,6 +326,52 @@
kArm64Float64ToUint32, MachineType::Uint32()},
MachineType::Float64()}};
+// ARM64 instructions that clear the top 32 bits of the destination.
+const MachInst2 kCanElideChangeUint32ToUint64[] = {
+ {&RawMachineAssembler::Word32And, "Word32And", kArm64And32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Or, "Word32Or", kArm64Or32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Xor, "Word32Xor", kArm64Eor32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Shl, "Word32Shl", kArm64Lsl32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Shr, "Word32Shr", kArm64Lsr32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Sar, "Word32Sar", kArm64Asr32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Ror, "Word32Ror", kArm64Ror32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Word32Equal, "Word32Equal", kArm64Cmp32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Int32Add, "Int32Add", kArm64Add32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32AddWithOverflow, "Int32AddWithOverflow",
+ kArm64Add32, MachineType::Int32()},
+ {&RawMachineAssembler::Int32Sub, "Int32Sub", kArm64Sub32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32SubWithOverflow, "Int32SubWithOverflow",
+ kArm64Sub32, MachineType::Int32()},
+ {&RawMachineAssembler::Int32Mul, "Int32Mul", kArm64Mul32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32Div, "Int32Div", kArm64Idiv32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32Mod, "Int32Mod", kArm64Imod32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32LessThan, "Int32LessThan", kArm64Cmp32,
+ MachineType::Int32()},
+ {&RawMachineAssembler::Int32LessThanOrEqual, "Int32LessThanOrEqual",
+ kArm64Cmp32, MachineType::Int32()},
+ {&RawMachineAssembler::Uint32Div, "Uint32Div", kArm64Udiv32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Uint32LessThan, "Uint32LessThan", kArm64Cmp32,
+ MachineType::Uint32()},
+ {&RawMachineAssembler::Uint32LessThanOrEqual, "Uint32LessThanOrEqual",
+ kArm64Cmp32, MachineType::Uint32()},
+ {&RawMachineAssembler::Uint32Mod, "Uint32Mod", kArm64Umod32,
+ MachineType::Uint32()},
+};
+
} // namespace
@@ -2105,6 +2151,71 @@
InstructionSelectorConversionTest,
::testing::ValuesIn(kConversionInstructions));
+typedef InstructionSelectorTestWithParam<MachInst2>
+ InstructionSelectorElidedChangeUint32ToUint64Test;
+
+TEST_P(InstructionSelectorElidedChangeUint32ToUint64Test, Parameter) {
+ const MachInst2 binop = GetParam();
+ StreamBuilder m(this, MachineType::Uint64(), binop.machine_type,
+ binop.machine_type);
+ m.Return(m.ChangeUint32ToUint64(
+ (m.*binop.constructor)(m.Parameter(0), m.Parameter(1))));
+ Stream s = m.Build();
+ // Make sure the `ChangeUint32ToUint64` node turned into a no-op.
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(binop.arch_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+}
+
+INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
+ InstructionSelectorElidedChangeUint32ToUint64Test,
+ ::testing::ValuesIn(kCanElideChangeUint32ToUint64));
+
+TEST_F(InstructionSelectorTest, ChangeUint32ToUint64AfterLoad) {
+ // For each case, make sure the `ChangeUint32ToUint64` node turned into a
+ // no-op.
+
+ // Ldrb
+ {
+ StreamBuilder m(this, MachineType::Uint64(), MachineType::Pointer(),
+ MachineType::Int32());
+ m.Return(m.ChangeUint32ToUint64(
+ m.Load(MachineType::Uint8(), m.Parameter(0), m.Parameter(1))));
+ Stream s = m.Build();
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArm64Ldrb, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_MRR, s[0]->addressing_mode());
+ EXPECT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+ }
+ // Ldrh
+ {
+ StreamBuilder m(this, MachineType::Uint64(), MachineType::Pointer(),
+ MachineType::Int32());
+ m.Return(m.ChangeUint32ToUint64(
+ m.Load(MachineType::Uint16(), m.Parameter(0), m.Parameter(1))));
+ Stream s = m.Build();
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArm64Ldrh, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_MRR, s[0]->addressing_mode());
+ EXPECT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+ }
+ // LdrW
+ {
+ StreamBuilder m(this, MachineType::Uint64(), MachineType::Pointer(),
+ MachineType::Int32());
+ m.Return(m.ChangeUint32ToUint64(
+ m.Load(MachineType::Uint32(), m.Parameter(0), m.Parameter(1))));
+ Stream s = m.Build();
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(kArm64LdrW, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_MRR, s[0]->addressing_mode());
+ EXPECT_EQ(2U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+ }
+}
// -----------------------------------------------------------------------------
// Memory access instructions.
@@ -2244,12 +2355,131 @@
EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
ASSERT_EQ(3U, s[0]->InputCount());
- ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(1)->kind());
- EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(1)));
+ ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(2)->kind());
+ EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(2)));
EXPECT_EQ(0U, s[0]->OutputCount());
}
}
+TEST_P(InstructionSelectorMemoryAccessTest, StoreZero) {
+ const MemoryAccess memacc = GetParam();
+ TRACED_FOREACH(int32_t, index, memacc.immediates) {
+ StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer());
+ m.Store(memacc.type.representation(), m.Parameter(0),
+ m.Int32Constant(index), m.Int32Constant(0), kNoWriteBarrier);
+ m.Return(m.Int32Constant(0));
+ Stream s = m.Build();
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_MRI, s[0]->addressing_mode());
+ ASSERT_EQ(3U, s[0]->InputCount());
+ ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(2)->kind());
+ EXPECT_EQ(index, s.ToInt32(s[0]->InputAt(2)));
+ ASSERT_EQ(InstructionOperand::IMMEDIATE, s[0]->InputAt(0)->kind());
+ EXPECT_EQ(0, s.ToInt64(s[0]->InputAt(0)));
+ EXPECT_EQ(0U, s[0]->OutputCount());
+ }
+}
+
+TEST_P(InstructionSelectorMemoryAccessTest, LoadWithShiftedIndex) {
+ const MemoryAccess memacc = GetParam();
+ TRACED_FORRANGE(int, immediate_shift, 0, 4) {
+ // 32 bit shift
+ {
+ StreamBuilder m(this, memacc.type, MachineType::Pointer(),
+ MachineType::Int32());
+ Node* const index =
+ m.Word32Shl(m.Parameter(1), m.Int32Constant(immediate_shift));
+ m.Return(m.Load(memacc.type, m.Parameter(0), index));
+ Stream s = m.Build();
+ if (immediate_shift == ElementSizeLog2Of(memacc.type.representation())) {
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ EXPECT_EQ(3U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+ } else {
+ // Make sure we haven't merged the shift into the load instruction.
+ ASSERT_NE(1U, s.size());
+ EXPECT_NE(memacc.ldr_opcode, s[0]->arch_opcode());
+ EXPECT_NE(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ }
+ }
+ // 64 bit shift
+ {
+ StreamBuilder m(this, memacc.type, MachineType::Pointer(),
+ MachineType::Int64());
+ Node* const index =
+ m.Word64Shl(m.Parameter(1), m.Int64Constant(immediate_shift));
+ m.Return(m.Load(memacc.type, m.Parameter(0), index));
+ Stream s = m.Build();
+ if (immediate_shift == ElementSizeLog2Of(memacc.type.representation())) {
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(memacc.ldr_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ EXPECT_EQ(3U, s[0]->InputCount());
+ EXPECT_EQ(1U, s[0]->OutputCount());
+ } else {
+ // Make sure we haven't merged the shift into the load instruction.
+ ASSERT_NE(1U, s.size());
+ EXPECT_NE(memacc.ldr_opcode, s[0]->arch_opcode());
+ EXPECT_NE(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ }
+ }
+ }
+}
+
+TEST_P(InstructionSelectorMemoryAccessTest, StoreWithShiftedIndex) {
+ const MemoryAccess memacc = GetParam();
+ TRACED_FORRANGE(int, immediate_shift, 0, 4) {
+ // 32 bit shift
+ {
+ StreamBuilder m(this, MachineType::Int32(), MachineType::Pointer(),
+ MachineType::Int32(), memacc.type);
+ Node* const index =
+ m.Word32Shl(m.Parameter(1), m.Int32Constant(immediate_shift));
+ m.Store(memacc.type.representation(), m.Parameter(0), index,
+ m.Parameter(2), kNoWriteBarrier);
+ m.Return(m.Int32Constant(0));
+ Stream s = m.Build();
+ if (immediate_shift == ElementSizeLog2Of(memacc.type.representation())) {
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ EXPECT_EQ(4U, s[0]->InputCount());
+ EXPECT_EQ(0U, s[0]->OutputCount());
+ } else {
+ // Make sure we haven't merged the shift into the store instruction.
+ ASSERT_NE(1U, s.size());
+ EXPECT_NE(memacc.str_opcode, s[0]->arch_opcode());
+ EXPECT_NE(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ }
+ }
+ // 64 bit shift
+ {
+ StreamBuilder m(this, MachineType::Int64(), MachineType::Pointer(),
+ MachineType::Int64(), memacc.type);
+ Node* const index =
+ m.Word64Shl(m.Parameter(1), m.Int64Constant(immediate_shift));
+ m.Store(memacc.type.representation(), m.Parameter(0), index,
+ m.Parameter(2), kNoWriteBarrier);
+ m.Return(m.Int64Constant(0));
+ Stream s = m.Build();
+ if (immediate_shift == ElementSizeLog2Of(memacc.type.representation())) {
+ ASSERT_EQ(1U, s.size());
+ EXPECT_EQ(memacc.str_opcode, s[0]->arch_opcode());
+ EXPECT_EQ(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ EXPECT_EQ(4U, s[0]->InputCount());
+ EXPECT_EQ(0U, s[0]->OutputCount());
+ } else {
+ // Make sure we haven't merged the shift into the store instruction.
+ ASSERT_NE(1U, s.size());
+ EXPECT_NE(memacc.str_opcode, s[0]->arch_opcode());
+ EXPECT_NE(kMode_Operand2_R_LSL_I, s[0]->addressing_mode());
+ }
+ }
+ }
+}
INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
InstructionSelectorMemoryAccessTest,
diff --git a/test/unittests/compiler/change-lowering-unittest.cc b/test/unittests/compiler/change-lowering-unittest.cc
deleted file mode 100644
index fd0766c..0000000
--- a/test/unittests/compiler/change-lowering-unittest.cc
+++ /dev/null
@@ -1,628 +0,0 @@
-// Copyright 2014 the V8 project authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "src/code-stubs.h"
-#include "src/compiler/change-lowering.h"
-#include "src/compiler/js-graph.h"
-#include "src/compiler/linkage.h"
-#include "src/compiler/node-properties.h"
-#include "src/compiler/simplified-operator.h"
-#include "test/unittests/compiler/compiler-test-utils.h"
-#include "test/unittests/compiler/graph-unittest.h"
-#include "test/unittests/compiler/node-test-utils.h"
-#include "testing/gmock-support.h"
-
-using testing::_;
-using testing::AllOf;
-using testing::BitEq;
-using testing::Capture;
-using testing::CaptureEq;
-
-namespace v8 {
-namespace internal {
-namespace compiler {
-
-class ChangeLoweringTest : public TypedGraphTest {
- public:
- ChangeLoweringTest() : simplified_(zone()) {}
-
- virtual MachineRepresentation WordRepresentation() const = 0;
-
- protected:
- bool Is32() const {
- return WordRepresentation() == MachineRepresentation::kWord32;
- }
- bool Is64() const {
- return WordRepresentation() == MachineRepresentation::kWord64;
- }
-
- Reduction Reduce(Node* node) {
- MachineOperatorBuilder machine(zone(), WordRepresentation());
- JSOperatorBuilder javascript(zone());
- JSGraph jsgraph(isolate(), graph(), common(), &javascript, nullptr,
- &machine);
- ChangeLowering reducer(&jsgraph);
- return reducer.Reduce(node);
- }
-
- SimplifiedOperatorBuilder* simplified() { return &simplified_; }
-
- Matcher<Node*> IsAllocateHeapNumber(const Matcher<Node*>& effect_matcher,
- const Matcher<Node*>& control_matcher) {
- return IsCall(
- _, IsHeapConstant(AllocateHeapNumberStub(isolate()).GetCode()),
- IsNumberConstant(BitEq(0.0)), effect_matcher, control_matcher);
- }
- Matcher<Node*> IsChangeInt32ToSmi(const Matcher<Node*>& value_matcher) {
- return Is64() ? IsWord64Shl(IsChangeInt32ToInt64(value_matcher),
- IsSmiShiftBitsConstant())
- : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant());
- }
- Matcher<Node*> IsChangeSmiToInt32(const Matcher<Node*>& value_matcher) {
- return Is64() ? IsTruncateInt64ToInt32(
- IsWord64Sar(value_matcher, IsSmiShiftBitsConstant()))
- : IsWord32Sar(value_matcher, IsSmiShiftBitsConstant());
- }
- Matcher<Node*> IsChangeUint32ToSmi(const Matcher<Node*>& value_matcher) {
- return Is64() ? IsWord64Shl(IsChangeUint32ToUint64(value_matcher),
- IsSmiShiftBitsConstant())
- : IsWord32Shl(value_matcher, IsSmiShiftBitsConstant());
- }
- Matcher<Node*> IsLoadHeapNumber(const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher) {
- return IsLoad(MachineType::Float64(), value_matcher,
- IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag),
- graph()->start(), control_matcher);
- }
- Matcher<Node*> IsIntPtrConstant(int value) {
- return Is32() ? IsInt32Constant(value) : IsInt64Constant(value);
- }
- Matcher<Node*> IsSmiShiftBitsConstant() {
- return IsIntPtrConstant(kSmiShiftSize + kSmiTagSize);
- }
- Matcher<Node*> IsWordEqual(const Matcher<Node*>& lhs_matcher,
- const Matcher<Node*>& rhs_matcher) {
- return Is32() ? IsWord32Equal(lhs_matcher, rhs_matcher)
- : IsWord64Equal(lhs_matcher, rhs_matcher);
- }
-
- private:
- SimplifiedOperatorBuilder simplified_;
-};
-
-
-// -----------------------------------------------------------------------------
-// Common.
-
-
-class ChangeLoweringCommonTest
- : public ChangeLoweringTest,
- public ::testing::WithParamInterface<MachineRepresentation> {
- public:
- ~ChangeLoweringCommonTest() override {}
-
- MachineRepresentation WordRepresentation() const final { return GetParam(); }
-};
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBitToBool) {
- Node* value = Parameter(Type::Boolean());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeBitToBool(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsSelect(MachineRepresentation::kTagged, value,
- IsTrueConstant(), IsFalseConstant()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeBoolToBit) {
- Node* value = Parameter(Type::Number());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsWordEqual(value, IsTrueConstant()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeInt32ToTaggedWithSignedSmall) {
- Node* value = Parameter(Type::SignedSmall());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeInt32ToTagged(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeUint32ToTaggedWithUnsignedSmall) {
- Node* value = Parameter(Type::UnsignedSmall());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeUint32ToTagged(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeUint32ToSmi(value));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedSigned) {
- Node* value = Parameter(Type::TaggedSigned());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeTaggedToInt32(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToInt32WithTaggedPointer) {
- Node* value = Parameter(Type::TaggedPointer());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeTaggedToInt32(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeFloat64ToInt32(
- IsLoadHeapNumber(value, graph()->start())));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedSigned) {
- Node* value = Parameter(Type::TaggedSigned());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeSmiToInt32(value));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, ChangeTaggedToUint32WithTaggedPointer) {
- Node* value = Parameter(Type::TaggedPointer());
- Reduction r =
- Reduce(graph()->NewNode(simplified()->ChangeTaggedToUint32(), value));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeFloat64ToUint32(
- IsLoadHeapNumber(value, graph()->start())));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldSmi) {
- FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Handle<Name>::null(), Type::Any(),
- MachineType::AnyTagged()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::TaggedSigned());
- Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
- graph()->start(), graph()->start());
- Reduction r = Reduce(store);
-
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsStore(StoreRepresentation(MachineRepresentation::kTagged,
- kNoWriteBarrier),
- p0, IsIntPtrConstant(access.offset - access.tag()), p1,
- graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, StoreFieldTagged) {
- FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Handle<Name>::null(), Type::Any(),
- MachineType::AnyTagged()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::Tagged());
- Node* store = graph()->NewNode(simplified()->StoreField(access), p0, p1,
- graph()->start(), graph()->start());
- Reduction r = Reduce(store);
-
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsStore(StoreRepresentation(MachineRepresentation::kTagged,
- kFullWriteBarrier),
- p0, IsIntPtrConstant(access.offset - access.tag()), p1,
- graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, LoadField) {
- FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Handle<Name>::null(), Type::Any(),
- MachineType::AnyTagged()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* load = graph()->NewNode(simplified()->LoadField(access), p0,
- graph()->start(), graph()->start());
- Reduction r = Reduce(load);
-
- ASSERT_TRUE(r.Changed());
- Matcher<Node*> index_match = IsIntPtrConstant(access.offset - access.tag());
- EXPECT_THAT(r.replacement(),
- IsLoad(MachineType::AnyTagged(), p0,
- IsIntPtrConstant(access.offset - access.tag()),
- graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementTagged) {
- ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- MachineType::AnyTagged()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::Signed32());
- Node* p2 = Parameter(Type::Tagged());
- Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2,
- graph()->start(), graph()->start());
- Reduction r = Reduce(store);
-
- const int element_size_shift =
- ElementSizeLog2Of(access.machine_type.representation());
- ASSERT_TRUE(r.Changed());
- Matcher<Node*> index_match =
- IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)),
- IsInt32Constant(access.header_size - access.tag()));
- if (!Is32()) {
- index_match = IsChangeUint32ToUint64(index_match);
- }
-
- EXPECT_THAT(r.replacement(),
- IsStore(StoreRepresentation(MachineRepresentation::kTagged,
- kFullWriteBarrier),
- p0, index_match, p2, graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, StoreElementUint8) {
- ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Type::Signed32(), MachineType::Uint8()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::Signed32());
- Node* p2 = Parameter(Type::Signed32());
- Node* store = graph()->NewNode(simplified()->StoreElement(access), p0, p1, p2,
- graph()->start(), graph()->start());
- Reduction r = Reduce(store);
-
- ASSERT_TRUE(r.Changed());
- Matcher<Node*> index_match =
- IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag()));
- if (!Is32()) {
- index_match = IsChangeUint32ToUint64(index_match);
- }
-
- EXPECT_THAT(r.replacement(),
- IsStore(StoreRepresentation(MachineRepresentation::kWord8,
- kNoWriteBarrier),
- p0, index_match, p2, graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementTagged) {
- ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize, Type::Any(),
- MachineType::AnyTagged()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::Signed32());
- Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
- graph()->start(), graph()->start());
- Reduction r = Reduce(load);
-
- const int element_size_shift =
- ElementSizeLog2Of(access.machine_type.representation());
- ASSERT_TRUE(r.Changed());
- Matcher<Node*> index_match =
- IsInt32Add(IsWord32Shl(p1, IsInt32Constant(element_size_shift)),
- IsInt32Constant(access.header_size - access.tag()));
- if (!Is32()) {
- index_match = IsChangeUint32ToUint64(index_match);
- }
-
- EXPECT_THAT(r.replacement(), IsLoad(MachineType::AnyTagged(), p0, index_match,
- graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, LoadElementInt8) {
- ElementAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
- Type::Signed32(), MachineType::Int8()};
- Node* p0 = Parameter(Type::TaggedPointer());
- Node* p1 = Parameter(Type::Signed32());
- Node* load = graph()->NewNode(simplified()->LoadElement(access), p0, p1,
- graph()->start(), graph()->start());
- Reduction r = Reduce(load);
-
- ASSERT_TRUE(r.Changed());
- Matcher<Node*> index_match =
- IsInt32Add(p1, IsInt32Constant(access.header_size - access.tag()));
- if (!Is32()) {
- index_match = IsChangeUint32ToUint64(index_match);
- }
-
- EXPECT_THAT(r.replacement(), IsLoad(MachineType::Int8(), p0, index_match,
- graph()->start(), graph()->start()));
-}
-
-
-TARGET_TEST_P(ChangeLoweringCommonTest, Allocate) {
- Node* p0 = Parameter(Type::Signed32());
- Node* alloc = graph()->NewNode(simplified()->Allocate(TENURED), p0,
- graph()->start(), graph()->start());
- Reduction r = Reduce(alloc);
-
- // Only check that we lowered, but do not specify the exact form since
- // this is subject to change.
- ASSERT_TRUE(r.Changed());
-}
-
-
-INSTANTIATE_TEST_CASE_P(ChangeLoweringTest, ChangeLoweringCommonTest,
- ::testing::Values(MachineRepresentation::kWord32,
- MachineRepresentation::kWord64));
-
-
-// -----------------------------------------------------------------------------
-// 32-bit
-
-
-class ChangeLowering32Test : public ChangeLoweringTest {
- public:
- ~ChangeLowering32Test() override {}
- MachineRepresentation WordRepresentation() const final {
- return MachineRepresentation::kWord32;
- }
-};
-
-
-TARGET_TEST_F(ChangeLowering32Test, ChangeInt32ToTagged) {
- Node* value = Parameter(Type::Integral32());
- Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> add, branch, heap_number, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(MachineRepresentation::kTagged,
- IsFinishRegion(
- AllOf(CaptureEq(&heap_number),
- IsAllocateHeapNumber(_, CaptureEq(&if_true))),
- IsStore(
- StoreRepresentation(MachineRepresentation::kFloat64,
- kNoWriteBarrier),
- CaptureEq(&heap_number),
- IsIntPtrConstant(HeapNumber::kValueOffset - kHeapObjectTag),
- IsChangeInt32ToFloat64(value), CaptureEq(&heap_number),
- CaptureEq(&if_true))),
- IsProjection(0, AllOf(CaptureEq(&add),
- IsInt32AddWithOverflow(value, value))),
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
- IsIfFalse(AllOf(CaptureEq(&branch),
- IsBranch(IsProjection(1, CaptureEq(&add)),
- graph()->start()))))));
-}
-
-
-TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToFloat64) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Number());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(MachineRepresentation::kFloat64,
- IsLoadHeapNumber(value, CaptureEq(&if_true)),
- IsChangeInt32ToFloat64(IsWord32Sar(
- value, IsInt32Constant(kSmiTagSize + kSmiShiftSize))),
- IsMerge(AllOf(CaptureEq(&if_true),
- IsIfTrue(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord32And(
- value, IsInt32Constant(kSmiTagMask)),
- graph()->start())))),
- IsIfFalse(CaptureEq(&branch)))));
-}
-
-
-TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToInt32) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Signed32());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kWord32,
- IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))),
- IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)),
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
- IsIfFalse(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)),
- graph()->start()))))));
-}
-
-
-TARGET_TEST_F(ChangeLowering32Test, ChangeTaggedToUint32) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Unsigned32());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kWord32,
- IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))),
- IsWord32Sar(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)),
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
- IsIfFalse(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord32And(value, IsInt32Constant(kSmiTagMask)),
- graph()->start()))))));
-}
-
-
-TARGET_TEST_F(ChangeLowering32Test, ChangeUint32ToTagged) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Number());
- Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, heap_number, if_false;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kTagged,
- IsWord32Shl(value, IsInt32Constant(kSmiTagSize + kSmiShiftSize)),
- IsFinishRegion(
- AllOf(CaptureEq(&heap_number),
- IsAllocateHeapNumber(_, CaptureEq(&if_false))),
- IsStore(
- StoreRepresentation(MachineRepresentation::kFloat64,
- kNoWriteBarrier),
- CaptureEq(&heap_number),
- IsInt32Constant(HeapNumber::kValueOffset - kHeapObjectTag),
- IsChangeUint32ToFloat64(value), CaptureEq(&heap_number),
- CaptureEq(&if_false))),
- IsMerge(IsIfTrue(AllOf(
- CaptureEq(&branch),
- IsBranch(IsUint32LessThanOrEqual(
- value, IsInt32Constant(Smi::kMaxValue)),
- graph()->start()))),
- AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
-}
-
-
-// -----------------------------------------------------------------------------
-// 64-bit
-
-
-class ChangeLowering64Test : public ChangeLoweringTest {
- public:
- ~ChangeLowering64Test() override {}
- MachineRepresentation WordRepresentation() const final {
- return MachineRepresentation::kWord64;
- }
-};
-
-
-TARGET_TEST_F(ChangeLowering64Test, ChangeInt32ToTagged) {
- Node* value = Parameter(Type::Signed32());
- Node* node = graph()->NewNode(simplified()->ChangeInt32ToTagged(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsChangeInt32ToSmi(value));
-}
-
-
-TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToFloat64) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Number());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToFloat64(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(MachineRepresentation::kFloat64,
- IsLoadHeapNumber(value, CaptureEq(&if_true)),
- IsChangeInt32ToFloat64(IsTruncateInt64ToInt32(IsWord64Sar(
- value, IsInt64Constant(kSmiTagSize + kSmiShiftSize)))),
- IsMerge(AllOf(CaptureEq(&if_true),
- IsIfTrue(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord64And(
- value, IsInt64Constant(kSmiTagMask)),
- graph()->start())))),
- IsIfFalse(CaptureEq(&branch)))));
-}
-
-
-TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToInt32) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Signed32());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToInt32(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kWord32,
- IsChangeFloat64ToInt32(IsLoadHeapNumber(value, CaptureEq(&if_true))),
- IsTruncateInt64ToInt32(
- IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))),
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
- IsIfFalse(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)),
- graph()->start()))))));
-}
-
-
-TARGET_TEST_F(ChangeLowering64Test, ChangeTaggedToUint32) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Unsigned32());
- Node* node = graph()->NewNode(simplified()->ChangeTaggedToUint32(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, if_true;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kWord32,
- IsChangeFloat64ToUint32(IsLoadHeapNumber(value, CaptureEq(&if_true))),
- IsTruncateInt64ToInt32(
- IsWord64Sar(value, IsInt64Constant(kSmiTagSize + kSmiShiftSize))),
- IsMerge(AllOf(CaptureEq(&if_true), IsIfTrue(CaptureEq(&branch))),
- IsIfFalse(AllOf(
- CaptureEq(&branch),
- IsBranch(IsWord64And(value, IsInt64Constant(kSmiTagMask)),
- graph()->start()))))));
-}
-
-
-TARGET_TEST_F(ChangeLowering64Test, ChangeUint32ToTagged) {
- STATIC_ASSERT(kSmiTag == 0);
- STATIC_ASSERT(kSmiTagSize == 1);
-
- Node* value = Parameter(Type::Number());
- Node* node = graph()->NewNode(simplified()->ChangeUint32ToTagged(), value);
- Reduction r = Reduce(node);
- ASSERT_TRUE(r.Changed());
- Capture<Node*> branch, heap_number, if_false;
- EXPECT_THAT(
- r.replacement(),
- IsPhi(
- MachineRepresentation::kTagged,
- IsWord64Shl(IsChangeUint32ToUint64(value),
- IsInt64Constant(kSmiTagSize + kSmiShiftSize)),
- IsFinishRegion(
- AllOf(CaptureEq(&heap_number),
- IsAllocateHeapNumber(_, CaptureEq(&if_false))),
- IsStore(
- StoreRepresentation(MachineRepresentation::kFloat64,
- kNoWriteBarrier),
- CaptureEq(&heap_number),
- IsInt64Constant(HeapNumber::kValueOffset - kHeapObjectTag),
- IsChangeUint32ToFloat64(value), CaptureEq(&heap_number),
- CaptureEq(&if_false))),
- IsMerge(IsIfTrue(AllOf(
- CaptureEq(&branch),
- IsBranch(IsUint32LessThanOrEqual(
- value, IsInt32Constant(Smi::kMaxValue)),
- graph()->start()))),
- AllOf(CaptureEq(&if_false), IsIfFalse(CaptureEq(&branch))))));
-}
-
-} // namespace compiler
-} // namespace internal
-} // namespace v8
diff --git a/test/unittests/compiler/common-operator-reducer-unittest.cc b/test/unittests/compiler/common-operator-reducer-unittest.cc
index 1c16370..510eaad 100644
--- a/test/unittests/compiler/common-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/common-operator-reducer-unittest.cc
@@ -105,40 +105,6 @@
}
-TEST_F(CommonOperatorReducerTest, BranchWithInt64ZeroConstant) {
- TRACED_FOREACH(BranchHint, hint, kBranchHints) {
- Node* const control = graph()->start();
- Node* const branch =
- graph()->NewNode(common()->Branch(hint), Int64Constant(0), control);
- Node* const if_true = graph()->NewNode(common()->IfTrue(), branch);
- Node* const if_false = graph()->NewNode(common()->IfFalse(), branch);
- StrictMock<MockAdvancedReducerEditor> editor;
- EXPECT_CALL(editor, Replace(if_true, IsDead()));
- EXPECT_CALL(editor, Replace(if_false, control));
- Reduction const r = Reduce(&editor, branch);
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsDead());
- }
-}
-
-
-TEST_F(CommonOperatorReducerTest, BranchWithInt64OneConstant) {
- TRACED_FOREACH(BranchHint, hint, kBranchHints) {
- Node* const control = graph()->start();
- Node* const branch =
- graph()->NewNode(common()->Branch(hint), Int64Constant(1), control);
- Node* const if_true = graph()->NewNode(common()->IfTrue(), branch);
- Node* const if_false = graph()->NewNode(common()->IfFalse(), branch);
- StrictMock<MockAdvancedReducerEditor> editor;
- EXPECT_CALL(editor, Replace(if_true, control));
- EXPECT_CALL(editor, Replace(if_false, IsDead()));
- Reduction const r = Reduce(&editor, branch);
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsDead());
- }
-}
-
-
TEST_F(CommonOperatorReducerTest, BranchWithFalseConstant) {
TRACED_FOREACH(BranchHint, hint, kBranchHints) {
Node* const control = graph()->start();
@@ -500,30 +466,6 @@
}
-TEST_F(CommonOperatorReducerTest, SelectWithInt64ZeroConstant) {
- Node* p0 = Parameter(0);
- Node* p1 = Parameter(1);
- Node* select =
- graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
- Int64Constant(0), p0, p1);
- Reduction r = Reduce(select);
- ASSERT_TRUE(r.Changed());
- EXPECT_EQ(p1, r.replacement());
-}
-
-
-TEST_F(CommonOperatorReducerTest, SelectWithInt64OneConstant) {
- Node* p0 = Parameter(0);
- Node* p1 = Parameter(1);
- Node* select =
- graph()->NewNode(common()->Select(MachineRepresentation::kTagged),
- Int64Constant(1), p0, p1);
- Reduction r = Reduce(select);
- ASSERT_TRUE(r.Changed());
- EXPECT_EQ(p0, r.replacement());
-}
-
-
TEST_F(CommonOperatorReducerTest, SelectWithFalseConstant) {
Node* p0 = Parameter(0);
Node* p1 = Parameter(1);
diff --git a/test/unittests/compiler/effect-control-linearizer-unittest.cc b/test/unittests/compiler/effect-control-linearizer-unittest.cc
new file mode 100644
index 0000000..417444e
--- /dev/null
+++ b/test/unittests/compiler/effect-control-linearizer-unittest.cc
@@ -0,0 +1,330 @@
+// Copyright 2015 the V8 project authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "src/compiler/effect-control-linearizer.h"
+#include "src/compiler/access-builder.h"
+#include "src/compiler/js-graph.h"
+#include "src/compiler/linkage.h"
+#include "src/compiler/node-properties.h"
+#include "src/compiler/schedule.h"
+#include "src/compiler/simplified-operator.h"
+#include "test/unittests/compiler/graph-unittest.h"
+#include "test/unittests/compiler/node-test-utils.h"
+#include "test/unittests/test-utils.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+namespace v8 {
+namespace internal {
+namespace compiler {
+
+class EffectControlLinearizerTest : public TypedGraphTest {
+ public:
+ EffectControlLinearizerTest()
+ : TypedGraphTest(3),
+ machine_(zone()),
+ javascript_(zone()),
+ simplified_(zone()),
+ jsgraph_(isolate(), graph(), common(), &javascript_, &simplified_,
+ &machine_) {}
+
+ JSGraph* jsgraph() { return &jsgraph_; }
+ SimplifiedOperatorBuilder* simplified() { return &simplified_; }
+
+ private:
+ MachineOperatorBuilder machine_;
+ JSOperatorBuilder javascript_;
+ SimplifiedOperatorBuilder simplified_;
+ JSGraph jsgraph_;
+};
+
+namespace {
+
+BasicBlock* AddBlockToSchedule(Schedule* schedule) {
+ BasicBlock* block = schedule->NewBasicBlock();
+ block->set_rpo_number(static_cast<int32_t>(schedule->rpo_order()->size()));
+ schedule->rpo_order()->push_back(block);
+ return block;
+}
+
+} // namespace
+
+TEST_F(EffectControlLinearizerTest, SimpleLoad) {
+ Schedule schedule(zone());
+
+ // Create the graph.
+ Node* heap_number = NumberConstant(0.5);
+ Node* load = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
+ graph()->start(), graph()->start());
+ Node* ret = graph()->NewNode(common()->Return(), load, graph()->start(),
+ graph()->start());
+
+ // Build the basic block structure.
+ BasicBlock* start = schedule.start();
+ schedule.rpo_order()->push_back(start);
+ start->set_rpo_number(0);
+
+ // Populate the basic blocks with nodes.
+ schedule.AddNode(start, graph()->start());
+ schedule.AddNode(start, heap_number);
+ schedule.AddNode(start, load);
+ schedule.AddReturn(start, ret);
+
+ // Run the state effect introducer.
+ EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
+ introducer.Run();
+
+ EXPECT_THAT(load,
+ IsLoadField(AccessBuilder::ForHeapNumberValue(), heap_number,
+ graph()->start(), graph()->start()));
+ // The return should have reconnected effect edge to the load.
+ EXPECT_THAT(ret, IsReturn(load, load, graph()->start()));
+}
+
+TEST_F(EffectControlLinearizerTest, DiamondLoad) {
+ Schedule schedule(zone());
+
+ // Create the graph.
+ Node* branch =
+ graph()->NewNode(common()->Branch(), Int32Constant(0), graph()->start());
+
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
+ Node* heap_number = NumberConstant(0.5);
+ Node* vtrue = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
+ graph()->start(), if_true);
+
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
+ Node* vfalse = Float64Constant(2);
+
+ Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false);
+ Node* phi = graph()->NewNode(
+ common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge);
+
+ Node* ret =
+ graph()->NewNode(common()->Return(), phi, graph()->start(), merge);
+
+ // Build the basic block structure.
+ BasicBlock* start = schedule.start();
+ schedule.rpo_order()->push_back(start);
+ start->set_rpo_number(0);
+
+ BasicBlock* tblock = AddBlockToSchedule(&schedule);
+ BasicBlock* fblock = AddBlockToSchedule(&schedule);
+ BasicBlock* mblock = AddBlockToSchedule(&schedule);
+
+ // Populate the basic blocks with nodes.
+ schedule.AddNode(start, graph()->start());
+ schedule.AddBranch(start, branch, tblock, fblock);
+
+ schedule.AddNode(tblock, if_true);
+ schedule.AddNode(tblock, heap_number);
+ schedule.AddNode(tblock, vtrue);
+ schedule.AddGoto(tblock, mblock);
+
+ schedule.AddNode(fblock, if_false);
+ schedule.AddNode(fblock, vfalse);
+ schedule.AddGoto(fblock, mblock);
+
+ schedule.AddNode(mblock, merge);
+ schedule.AddNode(mblock, phi);
+ schedule.AddReturn(mblock, ret);
+
+ // Run the state effect introducer.
+ EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
+ introducer.Run();
+
+ // The effect input to the return should be an effect phi with the
+ // newly introduced effectful change operators.
+ ASSERT_THAT(
+ ret, IsReturn(phi, IsEffectPhi(vtrue, graph()->start(), merge), merge));
+}
+
+TEST_F(EffectControlLinearizerTest, FloatingDiamondsControlWiring) {
+ Schedule schedule(zone());
+
+ // Create the graph and schedule. Roughly (omitting effects and unimportant
+ // nodes):
+ //
+ // BLOCK 0:
+ // r1: Start
+ // c1: Call
+ // b1: Branch(const0, s1)
+ // |
+ // +-------+------+
+ // | |
+ // BLOCK 1: BLOCK 2:
+ // t1: IfTrue(b1) f1: IfFalse(b1)
+ // | |
+ // +-------+------+
+ // |
+ // BLOCK 3:
+ // m1: Merge(t1, f1)
+ // c2: IfSuccess(c1)
+ // b2: Branch(const0 , s1)
+ // |
+ // +-------+------+
+ // | |
+ // BLOCK 4: BLOCK 5:
+ // t2: IfTrue(b2) f2:IfFalse(b2)
+ // | |
+ // +-------+------+
+ // |
+ // BLOCK 6:
+ // m2: Merge(t2, f2)
+ // r1: Return(c1, c2)
+ MachineType kMachineSignature[] = {MachineType::AnyTagged(),
+ MachineType::AnyTagged()};
+ LinkageLocation kLocationSignature[] = {LinkageLocation::ForRegister(0),
+ LinkageLocation::ForRegister(1)};
+ const CallDescriptor* kCallDescriptor = new (zone()) CallDescriptor(
+ CallDescriptor::kCallCodeObject, MachineType::AnyTagged(),
+ LinkageLocation::ForRegister(0),
+ new (zone()) MachineSignature(1, 1, kMachineSignature),
+ new (zone()) LocationSignature(1, 1, kLocationSignature), 0,
+ Operator::kNoProperties, 0, 0, CallDescriptor::kNoFlags);
+ Node* p0 = Parameter(0);
+ Node* p1 = Parameter(1);
+ Node* const0 = Int32Constant(0);
+ Node* call = graph()->NewNode(common()->Call(kCallDescriptor), p0, p1,
+ graph()->start(), graph()->start());
+ Node* if_success = graph()->NewNode(common()->IfSuccess(), call);
+
+ // First Floating diamond.
+ Node* branch1 =
+ graph()->NewNode(common()->Branch(), const0, graph()->start());
+ Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
+ Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
+ Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
+
+ // Second floating diamond.
+ Node* branch2 =
+ graph()->NewNode(common()->Branch(), const0, graph()->start());
+ Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2);
+ Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2);
+ Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2);
+
+ Node* ret =
+ graph()->NewNode(common()->Return(), call, graph()->start(), if_success);
+
+ // Build the basic block structure.
+ BasicBlock* start = schedule.start();
+ schedule.rpo_order()->push_back(start);
+ start->set_rpo_number(0);
+
+ BasicBlock* t1block = AddBlockToSchedule(&schedule);
+ BasicBlock* f1block = AddBlockToSchedule(&schedule);
+ BasicBlock* m1block = AddBlockToSchedule(&schedule);
+
+ BasicBlock* t2block = AddBlockToSchedule(&schedule);
+ BasicBlock* f2block = AddBlockToSchedule(&schedule);
+ BasicBlock* m2block = AddBlockToSchedule(&schedule);
+
+ // Populate the basic blocks with nodes.
+ schedule.AddNode(start, graph()->start());
+ schedule.AddNode(start, p0);
+ schedule.AddNode(start, p1);
+ schedule.AddNode(start, const0);
+ schedule.AddNode(start, call);
+ schedule.AddBranch(start, branch1, t1block, f1block);
+
+ schedule.AddNode(t1block, if_true1);
+ schedule.AddGoto(t1block, m1block);
+
+ schedule.AddNode(f1block, if_false1);
+ schedule.AddGoto(f1block, m1block);
+
+ schedule.AddNode(m1block, merge1);
+ // The scheduler does not always put the IfSuccess node to the corresponding
+ // call's block, simulate that here.
+ schedule.AddNode(m1block, if_success);
+ schedule.AddBranch(m1block, branch2, t2block, f2block);
+
+ schedule.AddNode(t2block, if_true2);
+ schedule.AddGoto(t2block, m2block);
+
+ schedule.AddNode(f2block, if_false2);
+ schedule.AddGoto(f2block, m2block);
+
+ schedule.AddNode(m2block, merge2);
+ schedule.AddReturn(m2block, ret);
+
+ // Run the state effect introducer.
+ EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
+ introducer.Run();
+
+ // The effect input to the return should be an effect phi with the
+ // newly introduced effectful change operators.
+ ASSERT_THAT(ret, IsReturn(call, call, merge2));
+ ASSERT_THAT(branch2, IsBranch(const0, merge1));
+ ASSERT_THAT(branch1, IsBranch(const0, if_success));
+ ASSERT_THAT(if_success, IsIfSuccess(call));
+}
+
+TEST_F(EffectControlLinearizerTest, LoopLoad) {
+ Schedule schedule(zone());
+
+ // Create the graph.
+ Node* loop = graph()->NewNode(common()->Loop(1), graph()->start());
+ Node* effect_phi =
+ graph()->NewNode(common()->EffectPhi(1), graph()->start(), loop);
+
+ Node* cond = Int32Constant(0);
+ Node* branch = graph()->NewNode(common()->Branch(), cond, loop);
+
+ Node* if_true = graph()->NewNode(common()->IfTrue(), branch);
+
+ Node* if_false = graph()->NewNode(common()->IfFalse(), branch);
+
+ loop->AppendInput(zone(), if_false);
+ NodeProperties::ChangeOp(loop, common()->Loop(2));
+
+ effect_phi->InsertInput(zone(), 1, effect_phi);
+ NodeProperties::ChangeOp(effect_phi, common()->EffectPhi(2));
+
+ Node* heap_number = NumberConstant(0.5);
+ Node* load = graph()->NewNode(
+ simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number,
+ graph()->start(), loop);
+
+ Node* ret = graph()->NewNode(common()->Return(), load, effect_phi, if_true);
+
+ // Build the basic block structure.
+ BasicBlock* start = schedule.start();
+ schedule.rpo_order()->push_back(start);
+ start->set_rpo_number(0);
+
+ BasicBlock* lblock = AddBlockToSchedule(&schedule);
+ BasicBlock* fblock = AddBlockToSchedule(&schedule);
+ BasicBlock* rblock = AddBlockToSchedule(&schedule);
+
+ // Populate the basic blocks with nodes.
+ schedule.AddNode(start, graph()->start());
+ schedule.AddGoto(start, lblock);
+
+ schedule.AddNode(lblock, loop);
+ schedule.AddNode(lblock, effect_phi);
+ schedule.AddNode(lblock, heap_number);
+ schedule.AddNode(lblock, load);
+ schedule.AddNode(lblock, cond);
+ schedule.AddBranch(lblock, branch, rblock, fblock);
+
+ schedule.AddNode(fblock, if_false);
+ schedule.AddGoto(fblock, lblock);
+
+ schedule.AddNode(rblock, if_true);
+ schedule.AddReturn(rblock, ret);
+
+ // Run the state effect introducer.
+ EffectControlLinearizer introducer(jsgraph(), &schedule, zone());
+ introducer.Run();
+
+ ASSERT_THAT(ret, IsReturn(load, load, if_true));
+ EXPECT_THAT(load, IsLoadField(AccessBuilder::ForHeapNumberValue(),
+ heap_number, effect_phi, loop));
+}
+
+} // namespace compiler
+} // namespace internal
+} // namespace v8
diff --git a/test/unittests/compiler/escape-analysis-unittest.cc b/test/unittests/compiler/escape-analysis-unittest.cc
index d5e12ba..4c17ef2 100644
--- a/test/unittests/compiler/escape-analysis-unittest.cc
+++ b/test/unittests/compiler/escape-analysis-unittest.cc
@@ -146,14 +146,18 @@
}
FieldAccess FieldAccessAtIndex(int offset) {
- FieldAccess access = {kTaggedBase, offset, MaybeHandle<Name>(), Type::Any(),
- MachineType::AnyTagged()};
+ FieldAccess access = {kTaggedBase,
+ offset,
+ MaybeHandle<Name>(),
+ Type::Any(),
+ MachineType::AnyTagged(),
+ kFullWriteBarrier};
return access;
}
ElementAccess MakeElementAccess(int header_size) {
ElementAccess access = {kTaggedBase, header_size, Type::Any(),
- MachineType::AnyTagged()};
+ MachineType::AnyTagged(), kFullWriteBarrier};
return access;
}
diff --git a/test/unittests/compiler/instruction-selector-unittest.cc b/test/unittests/compiler/instruction-selector-unittest.cc
index 16030f8..69ae768 100644
--- a/test/unittests/compiler/instruction-selector-unittest.cc
+++ b/test/unittests/compiler/instruction-selector-unittest.cc
@@ -199,11 +199,9 @@
// -----------------------------------------------------------------------------
// Conversions.
-
-TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToInt32WithParameter) {
+TARGET_TEST_F(InstructionSelectorTest, TruncateFloat64ToWord32WithParameter) {
StreamBuilder m(this, MachineType::Int32(), MachineType::Float64());
- m.Return(
- m.TruncateFloat64ToInt32(TruncationMode::kJavaScript, m.Parameter(0)));
+ m.Return(m.TruncateFloat64ToWord32(m.Parameter(0)));
Stream s = m.Build(kAllInstructions);
ASSERT_EQ(4U, s.size());
EXPECT_EQ(kArchNop, s[0]->arch_opcode());
diff --git a/test/unittests/compiler/instruction-sequence-unittest.cc b/test/unittests/compiler/instruction-sequence-unittest.cc
index 51112a6..9360ca4 100644
--- a/test/unittests/compiler/instruction-sequence-unittest.cc
+++ b/test/unittests/compiler/instruction-sequence-unittest.cc
@@ -15,10 +15,9 @@
static const char*
general_register_names_[RegisterConfiguration::kMaxGeneralRegisters];
static const char*
- double_register_names_[RegisterConfiguration::kMaxDoubleRegisters];
+ double_register_names_[RegisterConfiguration::kMaxFPRegisters];
static char register_names_[10 * (RegisterConfiguration::kMaxGeneralRegisters +
- RegisterConfiguration::kMaxDoubleRegisters)];
-
+ RegisterConfiguration::kMaxFPRegisters)];
namespace {
static int allocatable_codes[InstructionSequenceTest::kDefaultNRegs] = {
@@ -35,7 +34,7 @@
loc += base::OS::SNPrintF(loc, 100, "gp_%d", i);
*loc++ = 0;
}
- for (int i = 0; i < RegisterConfiguration::kMaxDoubleRegisters; ++i) {
+ for (int i = 0; i < RegisterConfiguration::kMaxFPRegisters; ++i) {
double_register_names_[i] = loc;
loc += base::OS::SNPrintF(loc, 100, "fp_%d", i) + 1;
*loc++ = 0;
diff --git a/test/unittests/compiler/int64-lowering-unittest.cc b/test/unittests/compiler/int64-lowering-unittest.cc
index 08f3038..8bc02c5 100644
--- a/test/unittests/compiler/int64-lowering-unittest.cc
+++ b/test/unittests/compiler/int64-lowering-unittest.cc
@@ -301,9 +301,6 @@
wasm::ModuleEnv::GetI32WasmCallDescriptor(zone(), desc));
}
-// todo(ahaas): I added a list of missing instructions here to make merging
-// easier when I do them one by one.
-// kExprI64Add:
TEST_F(Int64LoweringTest, Int64Add) {
LowerGraph(graph()->NewNode(machine()->Int64Add(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -319,7 +316,7 @@
IsProjection(1, AllOf(CaptureEq(&add), add_matcher)),
start(), start()));
}
-// kExprI64Sub:
+
TEST_F(Int64LoweringTest, Int64Sub) {
LowerGraph(graph()->NewNode(machine()->Int64Sub(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -336,7 +333,6 @@
start(), start()));
}
-// kExprI64Mul:
TEST_F(Int64LoweringTest, Int64Mul) {
LowerGraph(graph()->NewNode(machine()->Int64Mul(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -354,11 +350,6 @@
start(), start()));
}
-// kExprI64DivS:
-// kExprI64DivU:
-// kExprI64RemS:
-// kExprI64RemU:
-// kExprI64Ior:
TEST_F(Int64LoweringTest, Int64Ior) {
LowerGraph(graph()->NewNode(machine()->Word64Or(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -371,7 +362,6 @@
start(), start()));
}
-// kExprI64Xor:
TEST_F(Int64LoweringTest, Int64Xor) {
LowerGraph(graph()->NewNode(machine()->Word64Xor(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -383,7 +373,7 @@
IsInt32Constant(high_word_value(1))),
start(), start()));
}
-// kExprI64Shl:
+
TEST_F(Int64LoweringTest, Int64Shl) {
LowerGraph(graph()->NewNode(machine()->Word64Shl(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -399,7 +389,7 @@
IsProjection(1, AllOf(CaptureEq(&shl), shl_matcher)),
start(), start()));
}
-// kExprI64ShrU:
+
TEST_F(Int64LoweringTest, Int64ShrU) {
LowerGraph(graph()->NewNode(machine()->Word64Shr(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -415,7 +405,7 @@
IsProjection(1, AllOf(CaptureEq(&shr), shr_matcher)),
start(), start()));
}
-// kExprI64ShrS:
+
TEST_F(Int64LoweringTest, Int64ShrS) {
LowerGraph(graph()->NewNode(machine()->Word64Sar(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -431,7 +421,7 @@
IsProjection(1, AllOf(CaptureEq(&sar), sar_matcher)),
start(), start()));
}
-// kExprI64Eq:
+
TEST_F(Int64LoweringTest, Int64Eq) {
LowerGraph(graph()->NewNode(machine()->Word64Equal(), Int64Constant(value(0)),
Int64Constant(value(1))),
@@ -447,27 +437,25 @@
start(), start()));
}
-// kExprI64LtS:
TEST_F(Int64LoweringTest, Int64LtS) {
TestComparison(machine()->Int64LessThan(), IsInt32LessThan, IsUint32LessThan);
}
-// kExprI64LeS:
+
TEST_F(Int64LoweringTest, Int64LeS) {
TestComparison(machine()->Int64LessThanOrEqual(), IsInt32LessThan,
IsUint32LessThanOrEqual);
}
-// kExprI64LtU:
+
TEST_F(Int64LoweringTest, Int64LtU) {
TestComparison(machine()->Uint64LessThan(), IsUint32LessThan,
IsUint32LessThan);
}
-// kExprI64LeU:
+
TEST_F(Int64LoweringTest, Int64LeU) {
TestComparison(machine()->Uint64LessThanOrEqual(), IsUint32LessThan,
IsUint32LessThanOrEqual);
}
-// kExprI32ConvertI64:
TEST_F(Int64LoweringTest, I32ConvertI64) {
LowerGraph(graph()->NewNode(machine()->TruncateInt64ToInt32(),
Int64Constant(value(0))),
@@ -475,7 +463,7 @@
EXPECT_THAT(graph()->end()->InputAt(1),
IsReturn(IsInt32Constant(low_word_value(0)), start(), start()));
}
-// kExprI64SConvertI32:
+
TEST_F(Int64LoweringTest, I64SConvertI32) {
LowerGraph(graph()->NewNode(machine()->ChangeInt32ToInt64(),
Int32Constant(low_word_value(0))),
@@ -501,7 +489,7 @@
IsInt32Constant(31)),
start(), start()));
}
-// kExprI64UConvertI32:
+
TEST_F(Int64LoweringTest, I64UConvertI32) {
LowerGraph(graph()->NewNode(machine()->ChangeUint32ToUint64(),
Int32Constant(low_word_value(0))),
@@ -523,7 +511,7 @@
IsReturn2(IsInt32Constant(low_word_value(0)), IsInt32Constant(0),
start(), start()));
}
-// kExprF64ReinterpretI64:
+
TEST_F(Int64LoweringTest, F64ReinterpretI64) {
LowerGraph(graph()->NewNode(machine()->BitcastInt64ToFloat64(),
Int64Constant(value(0))),
@@ -554,7 +542,7 @@
AllOf(CaptureEq(&store_capture), store_matcher), start()),
start(), start()));
}
-// kExprI64ReinterpretF64:
+
TEST_F(Int64LoweringTest, I64ReinterpretF64) {
LowerGraph(graph()->NewNode(machine()->BitcastFloat64ToInt64(),
Float64Constant(bit_cast<double>(value(0)))),
@@ -583,7 +571,7 @@
AllOf(CaptureEq(&store), store_matcher), start()),
start(), start()));
}
-// kExprI64Clz:
+
TEST_F(Int64LoweringTest, I64Clz) {
LowerGraph(graph()->NewNode(machine()->Word64Clz(), Int64Constant(value(0))),
MachineRepresentation::kWord64);
@@ -606,7 +594,7 @@
AllOf(CaptureEq(&branch_capture), branch_matcher)))),
IsInt32Constant(0), start(), start()));
}
-// kExprI64Ctz:
+
TEST_F(Int64LoweringTest, I64Ctz) {
LowerGraph(graph()->NewNode(machine()->Word64CtzPlaceholder(),
Int64Constant(value(0))),
@@ -628,7 +616,6 @@
AllOf(CaptureEq(&branch_capture), branch_matcher)))),
IsInt32Constant(0), start(), start()));
}
-// kExprI64Popcnt:
TEST_F(Int64LoweringTest, Dfs) {
Node* common = Int64Constant(value(0));
diff --git a/test/unittests/compiler/js-create-lowering-unittest.cc b/test/unittests/compiler/js-create-lowering-unittest.cc
index 837c574..5d95d0d 100644
--- a/test/unittests/compiler/js-create-lowering-unittest.cc
+++ b/test/unittests/compiler/js-create-lowering-unittest.cc
@@ -80,95 +80,74 @@
// -----------------------------------------------------------------------------
// JSCreateArguments
-TEST_F(JSCreateLoweringTest, JSCreateArgumentsViaStub) {
- Node* const closure = Parameter(Type::Any());
- Node* const context = UndefinedConstant();
- Node* const effect = graph()->start();
- Node* const control = graph()->start();
- Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
- Node* const frame_state = FrameState(shared, graph()->start());
- Reduction r = Reduce(graph()->NewNode(
- javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments),
- closure, context, frame_state, effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsCall(_, IsHeapConstant(
- CodeFactory::FastNewStrictArguments(isolate()).code()),
- closure, context, frame_state, effect, control));
-}
-
-TEST_F(JSCreateLoweringTest, JSCreateArgumentsRestParameterViaStub) {
- Node* const closure = Parameter(Type::Any());
- Node* const context = UndefinedConstant();
- Node* const effect = graph()->start();
- Node* const control = graph()->start();
- Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
- Node* const frame_state = FrameState(shared, graph()->start());
- Reduction r = Reduce(graph()->NewNode(
- javascript()->CreateArguments(CreateArgumentsType::kRestParameter),
- closure, context, frame_state, effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsCall(_, IsHeapConstant(
- CodeFactory::FastNewRestParameter(isolate()).code()),
- closure, context, frame_state, effect, control));
-}
-
TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedMapped) {
Node* const closure = Parameter(Type::Any());
Node* const context = UndefinedConstant();
Node* const effect = graph()->start();
- Node* const control = graph()->start();
Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
Node* const frame_state_outer = FrameState(shared, graph()->start());
Node* const frame_state_inner = FrameState(shared, frame_state_outer);
Reduction r = Reduce(graph()->NewNode(
javascript()->CreateArguments(CreateArgumentsType::kMappedArguments),
- closure, context, frame_state_inner, effect, control));
+ closure, context, frame_state_inner, effect));
ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsFinishRegion(
- IsAllocate(IsNumberConstant(JSSloppyArgumentsObject::kSize),
- _, control),
- _));
+ EXPECT_THAT(
+ r.replacement(),
+ IsFinishRegion(
+ IsAllocate(IsNumberConstant(JSSloppyArgumentsObject::kSize), _, _),
+ _));
}
TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedUnmapped) {
Node* const closure = Parameter(Type::Any());
Node* const context = UndefinedConstant();
Node* const effect = graph()->start();
- Node* const control = graph()->start();
Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
Node* const frame_state_outer = FrameState(shared, graph()->start());
Node* const frame_state_inner = FrameState(shared, frame_state_outer);
Reduction r = Reduce(graph()->NewNode(
javascript()->CreateArguments(CreateArgumentsType::kUnmappedArguments),
- closure, context, frame_state_inner, effect, control));
+ closure, context, frame_state_inner, effect));
ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsFinishRegion(
- IsAllocate(IsNumberConstant(JSStrictArgumentsObject::kSize),
- _, control),
- _));
+ EXPECT_THAT(
+ r.replacement(),
+ IsFinishRegion(
+ IsAllocate(IsNumberConstant(JSStrictArgumentsObject::kSize), _, _),
+ _));
}
TEST_F(JSCreateLoweringTest, JSCreateArgumentsInlinedRestArray) {
Node* const closure = Parameter(Type::Any());
Node* const context = UndefinedConstant();
Node* const effect = graph()->start();
- Node* const control = graph()->start();
Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
Node* const frame_state_outer = FrameState(shared, graph()->start());
Node* const frame_state_inner = FrameState(shared, frame_state_outer);
Reduction r = Reduce(graph()->NewNode(
javascript()->CreateArguments(CreateArgumentsType::kRestParameter),
- closure, context, frame_state_inner, effect, control));
+ closure, context, frame_state_inner, effect));
+ ASSERT_TRUE(r.Changed());
+ EXPECT_THAT(
+ r.replacement(),
+ IsFinishRegion(IsAllocate(IsNumberConstant(JSArray::kSize), _, _), _));
+}
+
+// -----------------------------------------------------------------------------
+// JSCreateClosure
+
+TEST_F(JSCreateLoweringTest, JSCreateClosureViaInlinedAllocation) {
+ Node* const context = UndefinedConstant();
+ Node* const effect = graph()->start();
+ Node* const control = graph()->start();
+ Handle<SharedFunctionInfo> shared(isolate()->object_function()->shared());
+ Reduction r =
+ Reduce(graph()->NewNode(javascript()->CreateClosure(shared, NOT_TENURED),
+ context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
- IsFinishRegion(
- IsAllocate(IsNumberConstant(JSArray::kSize), _, control), _));
+ IsFinishRegion(IsAllocate(IsNumberConstant(JSFunction::kSize),
+ IsBeginRegion(_), control),
+ _));
}
// -----------------------------------------------------------------------------
diff --git a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
index de0eefc..7c2f459 100644
--- a/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
+++ b/test/unittests/compiler/js-intrinsic-lowering-unittest.cc
@@ -92,7 +92,7 @@
input, context, effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
- IsFloat64ExtractLowWord32(IsGuard(Type::Number(), input, _)));
+ IsFloat64ExtractLowWord32(IsTypeGuard(Type::Number(), input, _)));
}
@@ -109,8 +109,8 @@
graph()->NewNode(javascript()->CallRuntime(Runtime::kInlineDoubleHi, 1),
input, context, effect, control));
ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(),
- IsFloat64ExtractHighWord32(IsGuard(Type::Number(), input, _)));
+ EXPECT_THAT(r.replacement(), IsFloat64ExtractHighWord32(
+ IsTypeGuard(Type::Number(), input, _)));
}
@@ -284,23 +284,6 @@
AllOf(CaptureEq(&if_false0), IsIfFalse(CaptureEq(&branch0))))));
}
-// -----------------------------------------------------------------------------
-// %_GetOrdinaryHasInstance
-
-TEST_F(JSIntrinsicLoweringTest, InlineGetOrdinaryHasInstance) {
- Node* const context = Parameter(0);
- Node* const effect = graph()->start();
- Node* const control = graph()->start();
- Reduction const r = Reduce(graph()->NewNode(
- javascript()->CallRuntime(Runtime::kInlineGetOrdinaryHasInstance, 0),
- context, effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(
- r.replacement(),
- IsLoadContext(
- ContextAccess(0, Context::ORDINARY_HAS_INSTANCE_INDEX, true), _));
-}
-
} // namespace compiler
} // namespace internal
} // namespace v8
diff --git a/test/unittests/compiler/js-operator-unittest.cc b/test/unittests/compiler/js-operator-unittest.cc
index 15b1427..28df6a9 100644
--- a/test/unittests/compiler/js-operator-unittest.cc
+++ b/test/unittests/compiler/js-operator-unittest.cc
@@ -42,8 +42,8 @@
}
SHARED(Equal, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
SHARED(NotEqual, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
- SHARED(StrictEqual, Operator::kNoThrow, 2, 0, 1, 1, 1, 1, 0),
- SHARED(StrictNotEqual, Operator::kNoThrow, 2, 0, 1, 1, 1, 1, 0),
+ SHARED(StrictEqual, Operator::kPure, 2, 0, 0, 0, 1, 0, 0),
+ SHARED(StrictNotEqual, Operator::kPure, 2, 0, 0, 0, 1, 0, 0),
SHARED(LessThan, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
SHARED(GreaterThan, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
SHARED(LessThanOrEqual, Operator::kNoProperties, 2, 2, 1, 1, 1, 1, 2),
@@ -51,11 +51,10 @@
SHARED(ToNumber, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
SHARED(ToString, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
SHARED(ToName, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
- SHARED(ToObject, Operator::kNoProperties, 1, 1, 1, 1, 1, 1, 2),
- SHARED(Yield, Operator::kNoProperties, 1, 0, 1, 1, 1, 1, 2),
+ SHARED(ToObject, Operator::kFoldable, 1, 1, 1, 1, 1, 1, 2),
SHARED(Create, Operator::kEliminatable, 2, 1, 1, 0, 1, 1, 0),
SHARED(HasProperty, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
- SHARED(TypeOf, Operator::kEliminatable, 1, 0, 1, 0, 1, 1, 0),
+ SHARED(TypeOf, Operator::kPure, 1, 0, 0, 0, 1, 0, 0),
SHARED(InstanceOf, Operator::kNoProperties, 2, 1, 1, 1, 1, 1, 2),
SHARED(CreateWithContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2),
SHARED(CreateModuleContext, Operator::kNoProperties, 2, 0, 1, 1, 1, 1, 2),
diff --git a/test/unittests/compiler/js-typed-lowering-unittest.cc b/test/unittests/compiler/js-typed-lowering-unittest.cc
index 1adb5da..904d5f7 100644
--- a/test/unittests/compiler/js-typed-lowering-unittest.cc
+++ b/test/unittests/compiler/js-typed-lowering-unittest.cc
@@ -212,9 +212,8 @@
TEST_F(JSTypedLoweringTest, JSToBooleanWithBoolean) {
Node* input = Parameter(Type::Boolean(), 0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_EQ(input, r.replacement());
}
@@ -242,9 +241,8 @@
zone()),
0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFalseConstant());
}
@@ -258,9 +256,8 @@
zone()),
0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTrueConstant());
}
@@ -269,9 +266,8 @@
TEST_F(JSTypedLoweringTest, JSToBooleanWithNonZeroPlainNumber) {
Node* input = Parameter(Type::Range(1, V8_INFINITY, zone()), 0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsTrueConstant());
}
@@ -280,9 +276,8 @@
TEST_F(JSTypedLoweringTest, JSToBooleanWithOrderedNumber) {
Node* input = Parameter(Type::OrderedNumber(), 0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsBooleanNot(IsNumberEqual(input, IsNumberConstant(0.0))));
@@ -292,9 +287,8 @@
TEST_F(JSTypedLoweringTest, JSToBooleanWithString) {
Node* input = Parameter(Type::String(), 0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(
r.replacement(),
@@ -307,9 +301,8 @@
TEST_F(JSTypedLoweringTest, JSToBooleanWithAny) {
Node* input = Parameter(Type::Any(), 0);
Node* context = Parameter(Type::Any(), 1);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ToBoolean(ToBooleanHint::kAny),
- input, context, graph()->start()));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ToBoolean(ToBooleanHint::kAny), input, context));
ASSERT_FALSE(r.Changed());
}
@@ -391,9 +384,8 @@
Node* const context = UndefinedConstant();
TRACED_FOREACH(Type*, type, kJSTypes) {
Node* const lhs = Parameter(type);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole,
- context, graph()->start(), graph()->start()));
+ Reduction r = Reduce(
+ graph()->NewNode(javascript()->StrictEqual(), lhs, the_hole, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsFalseConstant());
}
@@ -405,8 +397,7 @@
Node* const rhs = Parameter(Type::Unique(), 1);
Node* const context = Parameter(Type::Any(), 2);
Reduction r =
- Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, rhs, context,
- graph()->start(), graph()->start()));
+ Reduce(graph()->NewNode(javascript()->StrictEqual(), lhs, rhs, context));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), IsReferenceEqual(Type::Unique(), lhs, rhs));
}
@@ -823,24 +814,6 @@
}
-TEST_F(JSTypedLoweringTest, JSLoadNamedFunctionPrototype) {
- VectorSlotPair feedback;
- Handle<Name> name = factory()->prototype_string();
- Handle<JSFunction> function = isolate()->object_function();
- Handle<JSObject> function_prototype(JSObject::cast(function->prototype()));
- Node* const receiver = Parameter(Type::Constant(function, zone()), 0);
- Node* const vector = Parameter(Type::Internal(), 1);
- Node* const context = Parameter(Type::Internal(), 2);
- Node* const effect = graph()->start();
- Node* const control = graph()->start();
- Reduction const r = Reduce(graph()->NewNode(
- javascript()->LoadNamed(name, feedback), receiver, vector, context,
- EmptyFrameState(), EmptyFrameState(), effect, control));
- ASSERT_TRUE(r.Changed());
- EXPECT_THAT(r.replacement(), IsHeapConstant(function_prototype));
-}
-
-
// -----------------------------------------------------------------------------
// JSAdd
diff --git a/test/unittests/compiler/load-elimination-unittest.cc b/test/unittests/compiler/load-elimination-unittest.cc
index 38bb151..721d6df 100644
--- a/test/unittests/compiler/load-elimination-unittest.cc
+++ b/test/unittests/compiler/load-elimination-unittest.cc
@@ -14,23 +14,20 @@
class LoadEliminationTest : public TypedGraphTest {
public:
- LoadEliminationTest()
- : TypedGraphTest(3), common_(zone()), simplified_(zone()) {}
+ LoadEliminationTest() : TypedGraphTest(3), simplified_(zone()) {}
~LoadEliminationTest() override {}
protected:
Reduction Reduce(Node* node) {
// TODO(titzer): mock the GraphReducer here for better unit testing.
GraphReducer graph_reducer(zone(), graph());
- LoadElimination reducer(&graph_reducer, graph(), common());
+ LoadElimination reducer(&graph_reducer, graph(), simplified());
return reducer.Reduce(node);
}
SimplifiedOperatorBuilder* simplified() { return &simplified_; }
- CommonOperatorBuilder* common() { return &common_; }
private:
- CommonOperatorBuilder common_;
SimplifiedOperatorBuilder simplified_;
};
diff --git a/test/unittests/compiler/machine-operator-reducer-unittest.cc b/test/unittests/compiler/machine-operator-reducer-unittest.cc
index 2feba2e..8b65e04 100644
--- a/test/unittests/compiler/machine-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/machine-operator-reducer-unittest.cc
@@ -236,10 +236,6 @@
0x00003fff, 0x00001fff, 0x00000fff, 0x000007ff, 0x000003ff, 0x000001ff};
-const TruncationMode kTruncationModes[] = {TruncationMode::kJavaScript,
- TruncationMode::kRoundToZero};
-
-
struct ComparisonBinaryOperator {
const Operator* (MachineOperatorBuilder::*constructor)();
const char* constructor_name;
@@ -413,51 +409,28 @@
// -----------------------------------------------------------------------------
-// TruncateFloat64ToInt32
-
+// TruncateFloat64ToWord32
TEST_F(MachineOperatorReducerTest,
- TruncateFloat64ToInt32WithChangeInt32ToFloat64) {
- TRACED_FOREACH(TruncationMode, mode, kTruncationModes) {
- Node* value = Parameter(0);
- Reduction reduction = Reduce(graph()->NewNode(
- machine()->TruncateFloat64ToInt32(mode),
- graph()->NewNode(machine()->ChangeInt32ToFloat64(), value)));
- ASSERT_TRUE(reduction.Changed());
- EXPECT_EQ(value, reduction.replacement());
- }
+ TruncateFloat64ToWord32WithChangeInt32ToFloat64) {
+ Node* value = Parameter(0);
+ Reduction reduction = Reduce(graph()->NewNode(
+ machine()->TruncateFloat64ToWord32(),
+ graph()->NewNode(machine()->ChangeInt32ToFloat64(), value)));
+ ASSERT_TRUE(reduction.Changed());
+ EXPECT_EQ(value, reduction.replacement());
}
-
-TEST_F(MachineOperatorReducerTest, TruncateFloat64ToInt32WithConstant) {
+TEST_F(MachineOperatorReducerTest, TruncateFloat64ToWord32WithConstant) {
TRACED_FOREACH(double, x, kFloat64Values) {
Reduction reduction = Reduce(graph()->NewNode(
- machine()->TruncateFloat64ToInt32(TruncationMode::kJavaScript),
- Float64Constant(x)));
+ machine()->TruncateFloat64ToWord32(), Float64Constant(x)));
ASSERT_TRUE(reduction.Changed());
EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(x)));
}
}
-TEST_F(MachineOperatorReducerTest, TruncateFloat64ToInt32WithPhi) {
- Node* const p0 = Parameter(0);
- Node* const p1 = Parameter(1);
- Node* const merge = graph()->start();
- TRACED_FOREACH(TruncationMode, mode, kTruncationModes) {
- Reduction reduction = Reduce(graph()->NewNode(
- machine()->TruncateFloat64ToInt32(mode),
- graph()->NewNode(common()->Phi(MachineRepresentation::kFloat64, 2), p0,
- p1, merge)));
- ASSERT_TRUE(reduction.Changed());
- EXPECT_THAT(
- reduction.replacement(),
- IsPhi(MachineRepresentation::kWord32, IsTruncateFloat64ToInt32(p0),
- IsTruncateFloat64ToInt32(p1), merge));
- }
-}
-
-
// -----------------------------------------------------------------------------
// TruncateInt64ToInt32
@@ -485,8 +458,30 @@
// -----------------------------------------------------------------------------
-// Word32And
+// RoundFloat64ToInt32
+TEST_F(MachineOperatorReducerTest,
+ RoundFloat64ToInt32WithChangeInt32ToFloat64) {
+ Node* value = Parameter(0);
+ Reduction reduction = Reduce(graph()->NewNode(
+ machine()->RoundFloat64ToInt32(),
+ graph()->NewNode(machine()->ChangeInt32ToFloat64(), value)));
+ ASSERT_TRUE(reduction.Changed());
+ EXPECT_EQ(value, reduction.replacement());
+}
+
+TEST_F(MachineOperatorReducerTest, RoundFloat64ToInt32WithConstant) {
+ TRACED_FOREACH(double, x, kFloat64Values) {
+ Reduction reduction = Reduce(
+ graph()->NewNode(machine()->RoundFloat64ToInt32(), Float64Constant(x)));
+ ASSERT_TRUE(reduction.Changed());
+ EXPECT_THAT(reduction.replacement(),
+ IsInt32Constant(static_cast<int32_t>(x)));
+ }
+}
+
+// -----------------------------------------------------------------------------
+// Word32And
TEST_F(MachineOperatorReducerTest, Word32AndWithWord32ShlWithConstant) {
Node* const p0 = Parameter(0);
diff --git a/test/unittests/compiler/node-test-utils.cc b/test/unittests/compiler/node-test-utils.cc
index 6e5d39f..6adacc1 100644
--- a/test/unittests/compiler/node-test-utils.cc
+++ b/test/unittests/compiler/node-test-utils.cc
@@ -612,49 +612,6 @@
};
-class IsEffectSetMatcher final : public NodeMatcher {
- public:
- IsEffectSetMatcher(const Matcher<Node*>& effect0_matcher,
- const Matcher<Node*>& effect1_matcher)
- : NodeMatcher(IrOpcode::kEffectSet),
- effect0_matcher_(effect0_matcher),
- effect1_matcher_(effect1_matcher) {}
-
- void DescribeTo(std::ostream* os) const final {
- NodeMatcher::DescribeTo(os);
- *os << "), effect0 (";
- effect0_matcher_.DescribeTo(os);
- *os << ") and effect1 (";
- effect1_matcher_.DescribeTo(os);
- *os << ")";
- }
-
- bool MatchAndExplain(Node* node, MatchResultListener* listener) const final {
- if (!NodeMatcher::MatchAndExplain(node, listener)) return false;
-
- Node* effect0 = NodeProperties::GetEffectInput(node, 0);
- Node* effect1 = NodeProperties::GetEffectInput(node, 1);
-
- {
- // Try matching in the reverse order first.
- StringMatchResultListener value_listener;
- if (effect0_matcher_.MatchAndExplain(effect1, &value_listener) &&
- effect1_matcher_.MatchAndExplain(effect0, &value_listener)) {
- return true;
- }
- }
-
- return PrintMatchAndExplain(effect0, "effect0", effect0_matcher_,
- listener) &&
- PrintMatchAndExplain(effect1, "effect1", effect1_matcher_, listener);
- }
-
- private:
- const Matcher<Node*> effect0_matcher_;
- const Matcher<Node*> effect1_matcher_;
-};
-
-
class IsProjectionMatcher final : public NodeMatcher {
public:
IsProjectionMatcher(const Matcher<size_t>& index_matcher,
@@ -1352,12 +1309,12 @@
const Matcher<MachineRepresentation> rep_matcher_;
};
-class IsGuardMatcher final : public NodeMatcher {
+class IsTypeGuardMatcher final : public NodeMatcher {
public:
- IsGuardMatcher(const Matcher<Type*>& type_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher)
- : NodeMatcher(IrOpcode::kGuard),
+ IsTypeGuardMatcher(const Matcher<Type*>& type_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher)
+ : NodeMatcher(IrOpcode::kTypeGuard),
type_matcher_(type_matcher),
value_matcher_(value_matcher),
control_matcher_(control_matcher) {}
@@ -1818,12 +1775,6 @@
}
-Matcher<Node*> IsEffectSet(const Matcher<Node*>& effect0_matcher,
- const Matcher<Node*>& effect1_matcher) {
- return MakeMatcher(new IsEffectSetMatcher(effect0_matcher, effect1_matcher));
-}
-
-
Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
const Matcher<Node*>& base_matcher) {
return MakeMatcher(new IsProjectionMatcher(index_matcher, base_matcher));
@@ -2064,11 +2015,11 @@
effect_matcher, control_matcher));
}
-Matcher<Node*> IsGuard(const Matcher<Type*>& type_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher) {
+Matcher<Node*> IsTypeGuard(const Matcher<Type*>& type_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher) {
return MakeMatcher(
- new IsGuardMatcher(type_matcher, value_matcher, control_matcher));
+ new IsTypeGuardMatcher(type_matcher, value_matcher, control_matcher));
}
Matcher<Node*> IsReferenceEqual(const Matcher<Type*>& type_matcher,
@@ -2204,6 +2155,10 @@
return MakeMatcher(new NodeMatcher(IrOpcode::kLoadFramePointer));
}
+Matcher<Node*> IsLoadParentFramePointer() {
+ return MakeMatcher(new NodeMatcher(IrOpcode::kLoadParentFramePointer));
+}
+
#define IS_QUADOP_MATCHER(Name) \
Matcher<Node*> Is##Name( \
const Matcher<Node*>& a_matcher, const Matcher<Node*>& b_matcher, \
@@ -2284,6 +2239,7 @@
return MakeMatcher(new IsUnopMatcher(IrOpcode::k##Name, input_matcher)); \
}
IS_UNOP_MATCHER(BooleanNot)
+IS_UNOP_MATCHER(TruncateFloat64ToWord32)
IS_UNOP_MATCHER(ChangeFloat64ToInt32)
IS_UNOP_MATCHER(ChangeFloat64ToUint32)
IS_UNOP_MATCHER(ChangeInt32ToFloat64)
@@ -2291,7 +2247,6 @@
IS_UNOP_MATCHER(ChangeUint32ToFloat64)
IS_UNOP_MATCHER(ChangeUint32ToUint64)
IS_UNOP_MATCHER(TruncateFloat64ToFloat32)
-IS_UNOP_MATCHER(TruncateFloat64ToInt32)
IS_UNOP_MATCHER(TruncateInt64ToInt32)
IS_UNOP_MATCHER(Float32Abs)
IS_UNOP_MATCHER(Float64Abs)
diff --git a/test/unittests/compiler/node-test-utils.h b/test/unittests/compiler/node-test-utils.h
index dd036c9..4979bd5 100644
--- a/test/unittests/compiler/node-test-utils.h
+++ b/test/unittests/compiler/node-test-utils.h
@@ -97,8 +97,6 @@
Matcher<Node*> IsEffectPhi(const Matcher<Node*>& effect0_matcher,
const Matcher<Node*>& effect1_matcher,
const Matcher<Node*>& merge_matcher);
-Matcher<Node*> IsEffectSet(const Matcher<Node*>& effect0_matcher,
- const Matcher<Node*>& effect1_matcher);
Matcher<Node*> IsProjection(const Matcher<size_t>& index_matcher,
const Matcher<Node*>& base_matcher);
Matcher<Node*> IsCall(const Matcher<const CallDescriptor*>& descriptor_matcher,
@@ -315,6 +313,7 @@
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsJSAdd(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
+Matcher<Node*> IsTruncateFloat64ToWord32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeFloat64ToInt32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeFloat64ToUint32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeInt32ToFloat64(const Matcher<Node*>& input_matcher);
@@ -322,7 +321,6 @@
Matcher<Node*> IsChangeUint32ToFloat64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsChangeUint32ToUint64(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsTruncateFloat64ToFloat32(const Matcher<Node*>& input_matcher);
-Matcher<Node*> IsTruncateFloat64ToInt32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsTruncateInt64ToInt32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsFloat32Max(const Matcher<Node*>& lhs_matcher,
const Matcher<Node*>& rhs_matcher);
@@ -362,6 +360,7 @@
Matcher<Node*> IsNumberToUint32(const Matcher<Node*>& input_matcher);
Matcher<Node*> IsParameter(const Matcher<int> index_matcher);
Matcher<Node*> IsLoadFramePointer();
+Matcher<Node*> IsLoadParentFramePointer();
Matcher<Node*> IsInt32PairAdd(const Matcher<Node*>& a_matcher,
const Matcher<Node*>& b_matcher,
@@ -388,9 +387,9 @@
const Matcher<Node*>& rhs_matcher);
Matcher<Node*> IsStackSlot();
-Matcher<Node*> IsGuard(const Matcher<Type*>& type_matcher,
- const Matcher<Node*>& value_matcher,
- const Matcher<Node*>& control_matcher);
+Matcher<Node*> IsTypeGuard(const Matcher<Type*>& type_matcher,
+ const Matcher<Node*>& value_matcher,
+ const Matcher<Node*>& control_matcher);
} // namespace compiler
} // namespace internal
diff --git a/test/unittests/compiler/simplified-operator-reducer-unittest.cc b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
index f571898..eec39ab 100644
--- a/test/unittests/compiler/simplified-operator-reducer-unittest.cc
+++ b/test/unittests/compiler/simplified-operator-reducer-unittest.cc
@@ -150,60 +150,54 @@
// -----------------------------------------------------------------------------
-// ChangeBoolToBit
+// ChangeTaggedToBit
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithChangeBoolToBit) {
+TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithChangeTaggedToBit) {
Node* param0 = Parameter(0);
Reduction reduction = Reduce(graph()->NewNode(
- simplified()->ChangeBitToBool(),
- graph()->NewNode(simplified()->ChangeBoolToBit(), param0)));
+ simplified()->ChangeBitToTagged(),
+ graph()->NewNode(simplified()->ChangeTaggedToBit(), param0)));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(param0, reduction.replacement());
}
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithZeroConstant) {
+TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithZeroConstant) {
Reduction reduction = Reduce(
- graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(0)));
+ graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(0)));
ASSERT_TRUE(reduction.Changed());
EXPECT_THAT(reduction.replacement(), IsFalseConstant());
}
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBitToBoolWithOneConstant) {
+TEST_F(SimplifiedOperatorReducerTest, ChangeBitToTaggedWithOneConstant) {
Reduction reduction = Reduce(
- graph()->NewNode(simplified()->ChangeBitToBool(), Int32Constant(1)));
+ graph()->NewNode(simplified()->ChangeBitToTagged(), Int32Constant(1)));
ASSERT_TRUE(reduction.Changed());
EXPECT_THAT(reduction.replacement(), IsTrueConstant());
}
// -----------------------------------------------------------------------------
-// ChangeBoolToBit
+// ChangeTaggedToBit
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithFalseConstant) {
+TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithFalseConstant) {
Reduction reduction = Reduce(
- graph()->NewNode(simplified()->ChangeBoolToBit(), FalseConstant()));
+ graph()->NewNode(simplified()->ChangeTaggedToBit(), FalseConstant()));
ASSERT_TRUE(reduction.Changed());
EXPECT_THAT(reduction.replacement(), IsInt32Constant(0));
}
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithTrueConstant) {
- Reduction reduction =
- Reduce(graph()->NewNode(simplified()->ChangeBoolToBit(), TrueConstant()));
+TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithTrueConstant) {
+ Reduction reduction = Reduce(
+ graph()->NewNode(simplified()->ChangeTaggedToBit(), TrueConstant()));
ASSERT_TRUE(reduction.Changed());
EXPECT_THAT(reduction.replacement(), IsInt32Constant(1));
}
-
-TEST_F(SimplifiedOperatorReducerTest, ChangeBoolToBitWithChangeBitToBool) {
+TEST_F(SimplifiedOperatorReducerTest, ChangeTaggedToBitWithChangeBitToTagged) {
Node* param0 = Parameter(0);
Reduction reduction = Reduce(graph()->NewNode(
- simplified()->ChangeBoolToBit(),
- graph()->NewNode(simplified()->ChangeBitToBool(), param0)));
+ simplified()->ChangeTaggedToBit(),
+ graph()->NewNode(simplified()->ChangeBitToTagged(), param0)));
ASSERT_TRUE(reduction.Changed());
EXPECT_EQ(param0, reduction.replacement());
}
@@ -401,6 +395,28 @@
}
}
+// -----------------------------------------------------------------------------
+// TruncateTaggedToWord32
+
+TEST_F(SimplifiedOperatorReducerTest,
+ TruncateTaggedToWord3WithChangeFloat64ToTagged) {
+ Node* param0 = Parameter(0);
+ Reduction reduction = Reduce(graph()->NewNode(
+ simplified()->TruncateTaggedToWord32(),
+ graph()->NewNode(simplified()->ChangeFloat64ToTagged(), param0)));
+ ASSERT_TRUE(reduction.Changed());
+ EXPECT_THAT(reduction.replacement(), IsTruncateFloat64ToWord32(param0));
+}
+
+TEST_F(SimplifiedOperatorReducerTest, TruncateTaggedToWord32WithConstant) {
+ TRACED_FOREACH(double, n, kFloat64Values) {
+ Reduction reduction = Reduce(graph()->NewNode(
+ simplified()->TruncateTaggedToWord32(), NumberConstant(n)));
+ ASSERT_TRUE(reduction.Changed());
+ EXPECT_THAT(reduction.replacement(), IsInt32Constant(DoubleToInt32(n)));
+ }
+}
+
} // namespace compiler
} // namespace internal
} // namespace v8
diff --git a/test/unittests/compiler/simplified-operator-unittest.cc b/test/unittests/compiler/simplified-operator-unittest.cc
index bd8509f..ba404a9 100644
--- a/test/unittests/compiler/simplified-operator-unittest.cc
+++ b/test/unittests/compiler/simplified-operator-unittest.cc
@@ -31,7 +31,6 @@
return os << IrOpcode::Mnemonic(pop.opcode);
}
-
const PureOperator kPureOperators[] = {
#define PURE(Name, properties, input_count) \
{ \
@@ -56,15 +55,16 @@
PURE(NumberShiftRightLogical, Operator::kNoProperties, 2),
PURE(NumberToInt32, Operator::kNoProperties, 1),
PURE(NumberToUint32, Operator::kNoProperties, 1),
- PURE(PlainPrimitiveToNumber, Operator::kNoProperties, 1),
+ PURE(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1),
PURE(ChangeTaggedToInt32, Operator::kNoProperties, 1),
PURE(ChangeTaggedToUint32, Operator::kNoProperties, 1),
PURE(ChangeTaggedToFloat64, Operator::kNoProperties, 1),
PURE(ChangeInt32ToTagged, Operator::kNoProperties, 1),
PURE(ChangeUint32ToTagged, Operator::kNoProperties, 1),
PURE(ChangeFloat64ToTagged, Operator::kNoProperties, 1),
- PURE(ChangeBoolToBit, Operator::kNoProperties, 1),
- PURE(ChangeBitToBool, Operator::kNoProperties, 1),
+ PURE(ChangeTaggedToBit, Operator::kNoProperties, 1),
+ PURE(ChangeBitToTagged, Operator::kNoProperties, 1),
+ PURE(TruncateTaggedToWord32, Operator::kNoProperties, 1),
PURE(ObjectIsNumber, Operator::kNoProperties, 1),
PURE(ObjectIsReceiver, Operator::kNoProperties, 1),
PURE(ObjectIsSmi, Operator::kNoProperties, 1)
@@ -203,39 +203,46 @@
const ElementAccess kElementAccesses[] = {
{kTaggedBase, FixedArray::kHeaderSize, Type::Any(),
- MachineType::AnyTagged()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Int8()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Int16()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Int32()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Uint8()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Uint16()},
- {kUntaggedBase, 0, Type::Any(), MachineType::Uint32()},
- {kUntaggedBase, 0, Type::Signed32(), MachineType::Int8()},
- {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint8()},
- {kUntaggedBase, 0, Type::Signed32(), MachineType::Int16()},
- {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint16()},
- {kUntaggedBase, 0, Type::Signed32(), MachineType::Int32()},
- {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint32()},
+ MachineType::AnyTagged(), kFullWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Int8(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Int16(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Int32(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Uint8(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Uint16(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Any(), MachineType::Uint32(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Signed32(), MachineType::Int8(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint8(),
+ kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Signed32(), MachineType::Int16(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint16(),
+ kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Signed32(), MachineType::Int32(), kNoWriteBarrier},
+ {kUntaggedBase, 0, Type::Unsigned32(), MachineType::Uint32(),
+ kNoWriteBarrier},
{kUntaggedBase, 0, Type::Number(),
- MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)},
+ MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
+ kNoWriteBarrier},
{kUntaggedBase, 0, Type::Number(),
- MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone)},
+ MachineType(MachineRepresentation::kFloat64, MachineSemantic::kNone),
+ kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
- MachineType::Int8()},
+ MachineType::Int8(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
- MachineType::Uint8()},
+ MachineType::Uint8(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
- MachineType::Int16()},
+ MachineType::Int16(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
- MachineType::Uint16()},
+ MachineType::Uint16(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Signed32(),
- MachineType::Int32()},
+ MachineType::Int32(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Unsigned32(),
- MachineType::Uint32()},
+ MachineType::Uint32(), kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
- MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)},
+ MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
+ kNoWriteBarrier},
{kTaggedBase, FixedTypedArrayBase::kDataOffset, Type::Number(),
- MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone)}};
+ MachineType(MachineRepresentation::kFloat32, MachineSemantic::kNone),
+ kNoWriteBarrier}};
} // namespace