Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(492)

Side by Side Diff: test/cctest/interpreter/test-interpreter.cc

Issue 1406983010: [Interpreter] Ensure ToBoolean bytecodes are correctly emitted at the start of basic blocks (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Review comments. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 // TODO(rmcilroy): Remove this define after this flag is turned on globally 5 // TODO(rmcilroy): Remove this define after this flag is turned on globally
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/execution.h" 10 #include "src/execution.h"
(...skipping 1509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1520 1520
1521 TEST(InterpreterUnaryNot) { 1521 TEST(InterpreterUnaryNot) {
1522 HandleAndZoneScope handles; 1522 HandleAndZoneScope handles;
1523 for (size_t i = 1; i < 10; i++) { 1523 for (size_t i = 1; i < 10; i++) {
1524 bool expected_value = ((i & 1) == 1); 1524 bool expected_value = ((i & 1) == 1);
1525 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); 1525 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
1526 Register r0(0); 1526 Register r0(0);
1527 builder.set_locals_count(0); 1527 builder.set_locals_count(0);
1528 builder.set_context_count(0); 1528 builder.set_context_count(0);
1529 builder.set_parameter_count(0); 1529 builder.set_parameter_count(0);
1530 builder.EnterBlock();
1531 builder.LoadFalse(); 1530 builder.LoadFalse();
1532 for (size_t j = 0; j < i; j++) { 1531 for (size_t j = 0; j < i; j++) {
1533 builder.LogicalNot(); 1532 builder.LogicalNot();
1534 } 1533 }
1535 builder.LeaveBlock().Return(); 1534 builder.Return();
1536 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1535 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1537 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1536 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1538 auto callable = tester.GetCallable<>(); 1537 auto callable = tester.GetCallable<>();
1539 Handle<Object> return_value = callable().ToHandleChecked(); 1538 Handle<Object> return_value = callable().ToHandleChecked();
1540 CHECK(return_value->IsBoolean()); 1539 CHECK(return_value->IsBoolean());
1541 CHECK_EQ(return_value->BooleanValue(), expected_value); 1540 CHECK_EQ(return_value->BooleanValue(), expected_value);
1542 } 1541 }
1543 } 1542 }
1544 1543
1545 1544
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
1584 std::make_pair( 1583 std::make_pair(
1585 Handle<Object>::cast(factory->NewStringFromStaticChars("")), false), 1584 Handle<Object>::cast(factory->NewStringFromStaticChars("")), false),
1586 }; 1585 };
1587 1586
1588 for (size_t i = 0; i < arraysize(object_type_tuples); i++) { 1587 for (size_t i = 0; i < arraysize(object_type_tuples); i++) {
1589 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); 1588 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
1590 Register r0(0); 1589 Register r0(0);
1591 builder.set_locals_count(0); 1590 builder.set_locals_count(0);
1592 builder.set_context_count(0); 1591 builder.set_context_count(0);
1593 builder.set_parameter_count(0); 1592 builder.set_parameter_count(0);
1594 builder.EnterBlock();
1595 LoadAny(&builder, factory, object_type_tuples[i].first); 1593 LoadAny(&builder, factory, object_type_tuples[i].first);
1596 builder.CastAccumulatorToBoolean(); 1594 builder.CastAccumulatorToBoolean();
1597 builder.LeaveBlock().Return(); 1595 builder.Return();
1598 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1596 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1599 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1597 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1600 auto callable = tester.GetCallable<>(); 1598 auto callable = tester.GetCallable<>();
1601 Handle<Object> return_value = callable().ToHandleChecked(); 1599 Handle<Object> return_value = callable().ToHandleChecked();
1602 CHECK(return_value->IsBoolean()); 1600 CHECK(return_value->IsBoolean());
1603 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second); 1601 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second);
1604 } 1602 }
1605 } 1603 }
1606 1604
1607 1605
(...skipping 14 matching lines...) Expand all
1622 std::make_pair( 1620 std::make_pair(
1623 Handle<Object>::cast(factory->NewStringFromStaticChars("")), true), 1621 Handle<Object>::cast(factory->NewStringFromStaticChars("")), true),
1624 }; 1622 };
1625 1623
1626 for (size_t i = 0; i < arraysize(object_type_tuples); i++) { 1624 for (size_t i = 0; i < arraysize(object_type_tuples); i++) {
1627 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); 1625 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
1628 Register r0(0); 1626 Register r0(0);
1629 builder.set_locals_count(0); 1627 builder.set_locals_count(0);
1630 builder.set_context_count(0); 1628 builder.set_context_count(0);
1631 builder.set_parameter_count(0); 1629 builder.set_parameter_count(0);
1632 builder.EnterBlock();
1633 LoadAny(&builder, factory, object_type_tuples[i].first); 1630 LoadAny(&builder, factory, object_type_tuples[i].first);
1634 builder.LogicalNot(); 1631 builder.LogicalNot();
1635 builder.LeaveBlock().Return(); 1632 builder.Return();
1636 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1633 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1637 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1634 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1638 auto callable = tester.GetCallable<>(); 1635 auto callable = tester.GetCallable<>();
1639 Handle<Object> return_value = callable().ToHandleChecked(); 1636 Handle<Object> return_value = callable().ToHandleChecked();
1640 CHECK(return_value->IsBoolean()); 1637 CHECK(return_value->IsBoolean());
1641 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second); 1638 CHECK_EQ(return_value->BooleanValue(), object_type_tuples[i].second);
1642 } 1639 }
1643 } 1640 }
1644 1641
1645 1642
(...skipping 12 matching lines...) Expand all
1658 Handle<Object>::cast(factory->NewStringFromStaticChars("hello")), 1655 Handle<Object>::cast(factory->NewStringFromStaticChars("hello")),
1659 "string"), 1656 "string"),
1660 }; 1657 };
1661 1658
1662 for (size_t i = 0; i < arraysize(object_type_tuples); i++) { 1659 for (size_t i = 0; i < arraysize(object_type_tuples); i++) {
1663 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone()); 1660 BytecodeArrayBuilder builder(handles.main_isolate(), handles.main_zone());
1664 Register r0(0); 1661 Register r0(0);
1665 builder.set_locals_count(0); 1662 builder.set_locals_count(0);
1666 builder.set_context_count(0); 1663 builder.set_context_count(0);
1667 builder.set_parameter_count(0); 1664 builder.set_parameter_count(0);
1668 builder.EnterBlock();
1669 LoadAny(&builder, factory, object_type_tuples[i].first); 1665 LoadAny(&builder, factory, object_type_tuples[i].first);
1670 builder.TypeOf(); 1666 builder.TypeOf();
1671 builder.LeaveBlock().Return(); 1667 builder.Return();
1672 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(); 1668 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray();
1673 InterpreterTester tester(handles.main_isolate(), bytecode_array); 1669 InterpreterTester tester(handles.main_isolate(), bytecode_array);
1674 auto callable = tester.GetCallable<>(); 1670 auto callable = tester.GetCallable<>();
1675 Handle<v8::internal::String> return_value = 1671 Handle<v8::internal::String> return_value =
1676 Handle<v8::internal::String>::cast(callable().ToHandleChecked()); 1672 Handle<v8::internal::String>::cast(callable().ToHandleChecked());
1677 auto actual = return_value->ToCString(); 1673 auto actual = return_value->ToCString();
1678 CHECK_EQ(strcmp(&actual[0], object_type_tuples[i].second), 0); 1674 CHECK_EQ(strcmp(&actual[0], object_type_tuples[i].second), 0);
1679 } 1675 }
1680 } 1676 }
1681 1677
(...skipping 1212 matching lines...) Expand 10 before | Expand all | Expand 10 after
2894 auto callable = tester.GetCallable<>(); 2890 auto callable = tester.GetCallable<>();
2895 2891
2896 Handle<i::Object> return_value = callable().ToHandleChecked(); 2892 Handle<i::Object> return_value = callable().ToHandleChecked();
2897 CHECK(return_value->SameValue(*switch_ops[i].second)); 2893 CHECK(return_value->SameValue(*switch_ops[i].second));
2898 } 2894 }
2899 } 2895 }
2900 2896
2901 } // namespace interpreter 2897 } // namespace interpreter
2902 } // namespace internal 2898 } // namespace internal
2903 } // namespace v8 2899 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/interpreter/test-bytecode-generator.cc ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698