void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
Arm64OperandGenerator g(this);
Node* value = node->InputAt(0);
- if (CanCover(node, value)) {
+ if (CanCover(node, value) && value->InputCount() >= 2) {
Int64BinopMatcher m(value);
if ((m.IsWord64Sar() && m.right().HasValue() &&
(m.right().Value() == 32)) ||
NodeId id() const { return id_; }
int InputCount() const { return input_count(); }
- Node* InputAt(int index) const { return GetInputRecordPtr(index)->to; }
+ Node* InputAt(int index) const {
+#if DEBUG
+ if (index < 0 || index >= InputCount()) {
+ V8_Fatal(__FILE__, __LINE__, "Node #%d:%s->InputAt(%d) out of bounds",
+ id(), op()->mnemonic(), index);
+ }
+#endif
+ return GetInputRecordPtr(index)->to;
+ }
inline void ReplaceInput(int index, Node* new_to);
void AppendInput(Zone* zone, Node* new_to);
void InsertInput(Zone* zone, int index, Node* new_to);
for (size_t i = 0; i < arraysize(types); i++) {
Node* n = R.Parameter(types[i]);
- Node* c = R.graph.NewNode(R.javascript.ToNumber(), n, R.context(),
- R.start(), R.start());
+ Node* c =
+ R.graph.NewNode(R.javascript.ToNumber(), n, R.context(),
+ R.EmptyFrameState(R.context()), R.start(), R.start());
Node* effect_use = R.UseForEffect(c);
Node* add = R.graph.NewNode(R.simplified.ReferenceEqual(Type::Any()), n, c);
// middle loop.
Node* loop1 = T.graph.NewNode(T.common.Loop(2), loop0.if_true, T.self);
loop1->ReplaceInput(0, loop0.if_true);
- Node* loop1_phi =
- T.graph.NewNode(T.common.Phi(kMachAnyTagged, 2), loop0_cntr, loop0_cntr);
+ Node* loop1_phi = T.graph.NewNode(T.common.Phi(kMachAnyTagged, 2), loop0_cntr,
+ loop0_cntr, loop1);
// innermost (OSR) loop.
While loop2(T, T.p0, true, 1);
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(), kMachineReps[i]};
- Node* load =
- t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
+ Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
+ t.start, t.start);
Node* use = t.Use(load, kMachineReps[i]);
t.Return(use);
t.Lower();
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), Type::Any(), kMachFloat64};
- Node* load =
- t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
+ Node* load = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
+ t.start, t.start);
t.Return(load);
t.Lower();
CHECK_EQ(IrOpcode::kLoad, load->opcode());
FieldAccess access = {kTaggedBase, FixedArrayBase::kHeaderSize,
Handle<Name>::null(), kTypes[i], kMachineTypes[i]};
- Node* load0 =
- t.graph()->NewNode(t.simplified()->LoadField(access), t.p0, t.start);
- Node* load1 =
- t.graph()->NewNode(t.simplified()->LoadField(access), t.p1, t.start);
+ Node* load0 = t.graph()->NewNode(t.simplified()->LoadField(access), t.p0,
+ t.start, t.start);
+ Node* load1 = t.graph()->NewNode(t.simplified()->LoadField(access), t.p1,
+ t.start, t.start);
Node* phi = t.graph()->NewNode(t.common()->Phi(kMachAnyTagged, 2), load0,
load1, t.start);
t.Return(t.Use(phi, kMachineTypes[i]));
TEST_F(JSBuiltinReducerTest, MathMax0) {
Node* function = MathFunction("max");
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
Node* call = graph()->NewNode(
javascript()->CallFunction(2, NO_CALL_FUNCTION_FLAGS, language_mode),
- function, UndefinedConstant());
+ function, UndefinedConstant(), frame_state, frame_state, effect,
+ control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
TEST_F(JSBuiltinReducerTest, MathMax1) {
Node* function = MathFunction("max");
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call = graph()->NewNode(
javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS, language_mode),
- function, UndefinedConstant(), p0);
+ function, UndefinedConstant(), p0, frame_state, frame_state, effect,
+ control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
TEST_F(JSBuiltinReducerTest, MathMax2) {
Node* function = MathFunction("max");
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* call =
graph()->NewNode(javascript()->CallFunction(
4, NO_CALL_FUNCTION_FLAGS, language_mode),
- function, UndefinedConstant(), p0, p1);
+ function, UndefinedConstant(), p0, p1, frame_state,
+ frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
TEST_F(JSBuiltinReducerTest, MathImul) {
Node* function = MathFunction("imul");
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kIntegral32Types) {
TRACED_FOREACH(Type*, t1, kIntegral32Types) {
Node* call =
graph()->NewNode(javascript()->CallFunction(
4, NO_CALL_FUNCTION_FLAGS, language_mode),
- function, UndefinedConstant(), p0, p1);
+ function, UndefinedConstant(), p0, p1, frame_state,
+ frame_state, effect, control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
TEST_F(JSBuiltinReducerTest, MathFround) {
Node* function = MathFunction("fround");
+ Node* effect = graph()->start();
+ Node* control = graph()->start();
+ Node* frame_state = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
TRACED_FOREACH(Type*, t0, kNumberTypes) {
Node* p0 = Parameter(t0, 0);
Node* call = graph()->NewNode(
javascript()->CallFunction(3, NO_CALL_FUNCTION_FLAGS, language_mode),
- function, UndefinedConstant(), p0);
+ function, UndefinedConstant(), p0, frame_state, frame_state, effect,
+ control);
Reduction r = Reduce(call);
ASSERT_TRUE(r.Changed());
Node* const control = graph()->start();
TRACED_FORRANGE(double, rhs, 0, 31) {
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs,
- NumberConstant(rhs), context, effect,
- control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ShiftLeft(language_mode), lhs, NumberConstant(rhs),
+ context, EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Shl(lhs, IsNumberConstant(BitEq(rhs))));
Node* const effect = graph()->start();
Node* const control = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r =
- Reduce(graph()->NewNode(javascript()->ShiftLeft(language_mode), lhs,
- rhs, context, effect, control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ShiftLeft(language_mode), lhs, rhs, context,
+ EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Shl(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
Node* const control = graph()->start();
TRACED_FORRANGE(double, rhs, 0, 31) {
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r =
- Reduce(graph()->NewNode(javascript()-> ShiftRight(language_mode), lhs,
- NumberConstant(rhs), context, effect,
- control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ShiftRight(language_mode), lhs, NumberConstant(rhs),
+ context, EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Sar(lhs, IsNumberConstant(BitEq(rhs))));
Node* const effect = graph()->start();
Node* const control = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r = Reduce(graph()->NewNode(javascript()->
- ShiftRight(language_mode), lhs, rhs,
- context, effect, control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ShiftRight(language_mode), lhs, rhs, context,
+ EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Sar(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
Node* const control = graph()->start();
TRACED_FORRANGE(double, rhs, 0, 31) {
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r =
- Reduce(graph()->NewNode(javascript()->
- ShiftRightLogical(language_mode), lhs,
- NumberConstant(rhs), context, effect,
- control));
+ Reduction r = Reduce(
+ graph()->NewNode(javascript()->ShiftRightLogical(language_mode), lhs,
+ NumberConstant(rhs), context, EmptyFrameState(),
+ EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Shr(lhs, IsNumberConstant(BitEq(rhs))));
Node* const effect = graph()->start();
Node* const control = graph()->start();
TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
- Reduction r = Reduce(graph()->NewNode(javascript()->
- ShiftRightLogical(language_mode), lhs,
- rhs, context, effect, control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->ShiftRightLogical(language_mode), lhs, rhs, context,
+ EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(),
IsWord32Shr(lhs, IsWord32And(rhs, IsInt32Constant(0x1f))));
for (size_t i = 0; i < arraysize(names); i++) {
Unique<Name> name = Unique<Name>::CreateImmovable(names[i]);
- Reduction r =
- Reduce(graph()->NewNode(javascript()->LoadNamed(name, feedback), global,
- context, EmptyFrameState(), effect, control));
+ Reduction r = Reduce(graph()->NewNode(
+ javascript()->LoadNamed(name, feedback), global, context,
+ EmptyFrameState(), EmptyFrameState(), effect, control));
ASSERT_TRUE(r.Changed());
EXPECT_THAT(r.replacement(), matches[i]);
Node* p3 = graph()->NewNode(common()->Parameter(2), graph()->start());
Node* p4 = graph()->NewNode(common()->Parameter(3), graph()->start());
Node* p5 = graph()->NewNode(common()->Parameter(4), graph()->start());
- Node* cmp = graph()->NewNode(js()->LessThanOrEqual(LanguageMode::SLOPPY), p1,
- p2, p3, p4, graph()->start(), graph()->start());
+ Node* cmp =
+ graph()->NewNode(js()->LessThanOrEqual(LanguageMode::SLOPPY), p1, p2, p3,
+ p4, p5, graph()->start(), graph()->start());
Node* branch = graph()->NewNode(common()->Branch(), cmp, graph()->start());
Node* true_branch = graph()->NewNode(common()->IfTrue(), branch);
Node* false_branch = graph()->NewNode(common()->IfFalse(), branch);