OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/compiler/js-builtin-reducer.h" | 5 #include "src/compiler/js-builtin-reducer.h" |
6 #include "src/compiler/js-graph.h" | 6 #include "src/compiler/js-graph.h" |
7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
8 #include "src/compiler/simplified-operator.h" | 8 #include "src/compiler/simplified-operator.h" |
9 #include "src/compiler/typer.h" | 9 #include "src/compiler/typer.h" |
10 #include "src/isolate-inl.h" | 10 #include "src/isolate-inl.h" |
(...skipping 1499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1510 Node* context = UndefinedConstant(); | 1510 Node* context = UndefinedConstant(); |
1511 Node* frame_state = graph()->start(); | 1511 Node* frame_state = graph()->start(); |
1512 TRACED_FOREACH(Type*, t0, kIntegral32Types) { | 1512 TRACED_FOREACH(Type*, t0, kIntegral32Types) { |
1513 Node* p0 = Parameter(t0, 0); | 1513 Node* p0 = Parameter(t0, 0); |
1514 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, | 1514 Node* call = graph()->NewNode(javascript()->CallFunction(3), function, |
1515 UndefinedConstant(), p0, context, frame_state, | 1515 UndefinedConstant(), p0, context, frame_state, |
1516 effect, control); | 1516 effect, control); |
1517 Reduction r = Reduce(call); | 1517 Reduction r = Reduce(call); |
1518 | 1518 |
1519 ASSERT_TRUE(r.Changed()); | 1519 ASSERT_TRUE(r.Changed()); |
1520 EXPECT_THAT(r.replacement(), IsNumberToInt32(p0)); | 1520 EXPECT_EQ(p0, r.replacement()); |
1521 } | 1521 } |
1522 } | 1522 } |
1523 | 1523 |
1524 TEST_F(JSBuiltinReducerTest, NumberParseIntWithIntegral32AndUndefined) { | 1524 TEST_F(JSBuiltinReducerTest, NumberParseIntWithIntegral32AndUndefined) { |
1525 Node* function = NumberFunction("parseInt"); | 1525 Node* function = NumberFunction("parseInt"); |
1526 | 1526 |
1527 Node* effect = graph()->start(); | 1527 Node* effect = graph()->start(); |
1528 Node* control = graph()->start(); | 1528 Node* control = graph()->start(); |
1529 Node* context = UndefinedConstant(); | 1529 Node* context = UndefinedConstant(); |
1530 Node* frame_state = graph()->start(); | 1530 Node* frame_state = graph()->start(); |
1531 TRACED_FOREACH(Type*, t0, kIntegral32Types) { | 1531 TRACED_FOREACH(Type*, t0, kIntegral32Types) { |
1532 Node* p0 = Parameter(t0, 0); | 1532 Node* p0 = Parameter(t0, 0); |
1533 Node* p1 = Parameter(Type::Undefined(), 1); | 1533 Node* p1 = Parameter(Type::Undefined(), 1); |
1534 Node* call = graph()->NewNode(javascript()->CallFunction(4), function, | 1534 Node* call = graph()->NewNode(javascript()->CallFunction(4), function, |
1535 UndefinedConstant(), p0, p1, context, | 1535 UndefinedConstant(), p0, p1, context, |
1536 frame_state, effect, control); | 1536 frame_state, effect, control); |
1537 Reduction r = Reduce(call); | 1537 Reduction r = Reduce(call); |
1538 | 1538 |
1539 ASSERT_TRUE(r.Changed()); | 1539 ASSERT_TRUE(r.Changed()); |
1540 EXPECT_THAT(r.replacement(), IsNumberToInt32(p0)); | 1540 EXPECT_EQ(p0, r.replacement()); |
1541 } | 1541 } |
1542 } | 1542 } |
1543 | 1543 |
1544 // ----------------------------------------------------------------------------- | 1544 // ----------------------------------------------------------------------------- |
1545 // String.fromCharCode | 1545 // String.fromCharCode |
1546 | 1546 |
1547 TEST_F(JSBuiltinReducerTest, StringFromCharCodeWithNumber) { | 1547 TEST_F(JSBuiltinReducerTest, StringFromCharCodeWithNumber) { |
1548 Node* function = StringFunction("fromCharCode"); | 1548 Node* function = StringFunction("fromCharCode"); |
1549 | 1549 |
1550 Node* effect = graph()->start(); | 1550 Node* effect = graph()->start(); |
(...skipping 26 matching lines...) Expand all Loading... |
1577 Reduction r = Reduce(call); | 1577 Reduction r = Reduce(call); |
1578 | 1578 |
1579 ASSERT_TRUE(r.Changed()); | 1579 ASSERT_TRUE(r.Changed()); |
1580 EXPECT_THAT(r.replacement(), | 1580 EXPECT_THAT(r.replacement(), |
1581 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); | 1581 IsStringFromCharCode(IsPlainPrimitiveToNumber(p0))); |
1582 } | 1582 } |
1583 | 1583 |
1584 } // namespace compiler | 1584 } // namespace compiler |
1585 } // namespace internal | 1585 } // namespace internal |
1586 } // namespace v8 | 1586 } // namespace v8 |
OLD | NEW |