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

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

Issue 2395743004: Revert of [interpreter] Add string type feedback to add (Closed)
Patch Set: Created 4 years, 2 months 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
« no previous file with comments | « src/type-feedback-vector-inl.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include <tuple> 5 #include <tuple>
6 6
7 #include "src/v8.h" 7 #include "src/v8.h"
8 8
9 #include "src/execution.h" 9 #include "src/execution.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 TEST(InterpreterStringAdd) { 379 TEST(InterpreterStringAdd) {
380 HandleAndZoneScope handles; 380 HandleAndZoneScope handles;
381 Isolate* isolate = handles.main_isolate(); 381 Isolate* isolate = handles.main_isolate();
382 Factory* factory = isolate->factory(); 382 Factory* factory = isolate->factory();
383 Zone zone(isolate->allocator()); 383 Zone zone(isolate->allocator());
384 384
385 struct TestCase { 385 struct TestCase {
386 Handle<Object> lhs; 386 Handle<Object> lhs;
387 Handle<Object> rhs; 387 Handle<Object> rhs;
388 Handle<Object> expected_value; 388 Handle<Object> expected_value;
389 int32_t expected_feedback;
390 } test_cases[] = { 389 } test_cases[] = {
391 {factory->NewStringFromStaticChars("a"), 390 {factory->NewStringFromStaticChars("a"),
392 factory->NewStringFromStaticChars("b"), 391 factory->NewStringFromStaticChars("b"),
393 factory->NewStringFromStaticChars("ab"), 392 factory->NewStringFromStaticChars("ab")},
394 BinaryOperationFeedback::kString},
395 {factory->NewStringFromStaticChars("aaaaaa"), 393 {factory->NewStringFromStaticChars("aaaaaa"),
396 factory->NewStringFromStaticChars("b"), 394 factory->NewStringFromStaticChars("b"),
397 factory->NewStringFromStaticChars("aaaaaab"), 395 factory->NewStringFromStaticChars("aaaaaab")},
398 BinaryOperationFeedback::kString},
399 {factory->NewStringFromStaticChars("aaa"), 396 {factory->NewStringFromStaticChars("aaa"),
400 factory->NewStringFromStaticChars("bbbbb"), 397 factory->NewStringFromStaticChars("bbbbb"),
401 factory->NewStringFromStaticChars("aaabbbbb"), 398 factory->NewStringFromStaticChars("aaabbbbb")},
402 BinaryOperationFeedback::kString},
403 {factory->NewStringFromStaticChars(""), 399 {factory->NewStringFromStaticChars(""),
404 factory->NewStringFromStaticChars("b"), 400 factory->NewStringFromStaticChars("b"),
405 factory->NewStringFromStaticChars("b"), 401 factory->NewStringFromStaticChars("b")},
406 BinaryOperationFeedback::kString},
407 {factory->NewStringFromStaticChars("a"), 402 {factory->NewStringFromStaticChars("a"),
408 factory->NewStringFromStaticChars(""), 403 factory->NewStringFromStaticChars(""),
409 factory->NewStringFromStaticChars("a"), 404 factory->NewStringFromStaticChars("a")},
410 BinaryOperationFeedback::kString},
411 {factory->NewStringFromStaticChars("1.11"), factory->NewHeapNumber(2.5), 405 {factory->NewStringFromStaticChars("1.11"), factory->NewHeapNumber(2.5),
412 factory->NewStringFromStaticChars("1.112.5"), 406 factory->NewStringFromStaticChars("1.112.5")},
413 BinaryOperationFeedback::kAny},
414 {factory->NewStringFromStaticChars("-1.11"), factory->NewHeapNumber(2.56), 407 {factory->NewStringFromStaticChars("-1.11"), factory->NewHeapNumber(2.56),
415 factory->NewStringFromStaticChars("-1.112.56"), 408 factory->NewStringFromStaticChars("-1.112.56")},
416 BinaryOperationFeedback::kAny},
417 {factory->NewStringFromStaticChars(""), factory->NewHeapNumber(2.5), 409 {factory->NewStringFromStaticChars(""), factory->NewHeapNumber(2.5),
418 factory->NewStringFromStaticChars("2.5"), BinaryOperationFeedback::kAny}, 410 factory->NewStringFromStaticChars("2.5")},
419 }; 411 };
420 412
421 for (size_t i = 0; i < arraysize(test_cases); i++) { 413 for (size_t i = 0; i < arraysize(test_cases); i++) {
422 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1); 414 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 1);
423 FeedbackVectorSpec feedback_spec(&zone); 415 FeedbackVectorSpec feedback_spec(&zone);
424 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot(); 416 FeedbackVectorSlot slot = feedback_spec.AddInterpreterBinaryOpICSlot();
425 Handle<i::TypeFeedbackVector> vector = 417 Handle<i::TypeFeedbackVector> vector =
426 NewTypeFeedbackVector(isolate, &feedback_spec); 418 NewTypeFeedbackVector(isolate, &feedback_spec);
427 419
428 Register reg(0); 420 Register reg(0);
429 builder.LoadLiteral(test_cases[i].lhs) 421 builder.LoadLiteral(test_cases[i].lhs)
430 .StoreAccumulatorInRegister(reg) 422 .StoreAccumulatorInRegister(reg)
431 .LoadLiteral(test_cases[i].rhs) 423 .LoadLiteral(test_cases[i].rhs)
432 .BinaryOperation(Token::Value::ADD, reg, vector->GetIndex(slot)) 424 .BinaryOperation(Token::Value::ADD, reg, vector->GetIndex(slot))
433 .Return(); 425 .Return();
434 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); 426 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
435 427
436 InterpreterTester tester(isolate, bytecode_array, vector); 428 InterpreterTester tester(isolate, bytecode_array, vector);
437 auto callable = tester.GetCallable<>(); 429 auto callable = tester.GetCallable<>();
438 Handle<Object> return_value = callable().ToHandleChecked(); 430 Handle<Object> return_value = callable().ToHandleChecked();
439 CHECK(return_value->SameValue(*test_cases[i].expected_value)); 431 CHECK(return_value->SameValue(*test_cases[i].expected_value));
440
441 Object* feedback = vector->Get(slot);
442 CHECK(feedback->IsSmi());
443 CHECK_EQ(test_cases[i].expected_feedback,
444 static_cast<Smi*>(feedback)->value());
445 } 432 }
446 } 433 }
447 434
448 435
449 TEST(InterpreterParameter1) { 436 TEST(InterpreterParameter1) {
450 HandleAndZoneScope handles; 437 HandleAndZoneScope handles;
451 Isolate* isolate = handles.main_isolate(); 438 Isolate* isolate = handles.main_isolate();
452 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0); 439 BytecodeArrayBuilder builder(isolate, handles.main_zone(), 1, 0, 0);
453 440
454 builder.LoadAccumulatorWithRegister(builder.Parameter(0)).Return(); 441 builder.LoadAccumulatorWithRegister(builder.Parameter(0)).Return();
(...skipping 1254 matching lines...) Expand 10 before | Expand all | Expand 10 after
1709 1696
1710 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); 1697 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
1711 InterpreterTester tester(isolate, bytecode_array, vector); 1698 InterpreterTester tester(isolate, bytecode_array, vector);
1712 auto callable = tester.GetCallable<>(); 1699 auto callable = tester.GetCallable<>();
1713 Handle<Object> return_value = callable().ToHandleChecked(); 1700 Handle<Object> return_value = callable().ToHandleChecked();
1714 CHECK(return_value->IsBoolean()); 1701 CHECK(return_value->IsBoolean());
1715 CHECK_EQ(return_value->BooleanValue(), 1702 CHECK_EQ(return_value->BooleanValue(),
1716 CompareC(comparison, inputs[i], inputs[j])); 1703 CompareC(comparison, inputs[i], inputs[j]));
1717 Object* feedback = vector->Get(slot); 1704 Object* feedback = vector->Get(slot);
1718 CHECK(feedback->IsSmi()); 1705 CHECK(feedback->IsSmi());
1719 CHECK_EQ(CompareOperationFeedback::kSignedSmall, 1706 CHECK_EQ(BinaryOperationFeedback::kSignedSmall,
1720 static_cast<Smi*>(feedback)->value()); 1707 static_cast<Smi*>(feedback)->value());
1721 } 1708 }
1722 } 1709 }
1723 } 1710 }
1724 } 1711 }
1725 1712
1726 1713
1727 TEST(InterpreterHeapNumberComparisons) { 1714 TEST(InterpreterHeapNumberComparisons) {
1728 double inputs[] = {std::numeric_limits<double>::min(), 1715 double inputs[] = {std::numeric_limits<double>::min(),
1729 std::numeric_limits<double>::max(), 1716 std::numeric_limits<double>::max(),
(...skipping 26 matching lines...) Expand all
1756 1743
1757 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); 1744 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
1758 InterpreterTester tester(isolate, bytecode_array, vector); 1745 InterpreterTester tester(isolate, bytecode_array, vector);
1759 auto callable = tester.GetCallable<>(); 1746 auto callable = tester.GetCallable<>();
1760 Handle<Object> return_value = callable().ToHandleChecked(); 1747 Handle<Object> return_value = callable().ToHandleChecked();
1761 CHECK(return_value->IsBoolean()); 1748 CHECK(return_value->IsBoolean());
1762 CHECK_EQ(return_value->BooleanValue(), 1749 CHECK_EQ(return_value->BooleanValue(),
1763 CompareC(comparison, inputs[i], inputs[j])); 1750 CompareC(comparison, inputs[i], inputs[j]));
1764 Object* feedback = vector->Get(slot); 1751 Object* feedback = vector->Get(slot);
1765 CHECK(feedback->IsSmi()); 1752 CHECK(feedback->IsSmi());
1766 CHECK_EQ(CompareOperationFeedback::kNumber, 1753 CHECK_EQ(BinaryOperationFeedback::kNumber,
1767 static_cast<Smi*>(feedback)->value()); 1754 static_cast<Smi*>(feedback)->value());
1768 } 1755 }
1769 } 1756 }
1770 } 1757 }
1771 } 1758 }
1772 1759
1773 1760
1774 TEST(InterpreterStringComparisons) { 1761 TEST(InterpreterStringComparisons) {
1775 HandleAndZoneScope handles; 1762 HandleAndZoneScope handles;
1776 Isolate* isolate = handles.main_isolate(); 1763 Isolate* isolate = handles.main_isolate();
(...skipping 25 matching lines...) Expand all
1802 1789
1803 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate); 1790 Handle<BytecodeArray> bytecode_array = builder.ToBytecodeArray(isolate);
1804 InterpreterTester tester(isolate, bytecode_array, vector); 1791 InterpreterTester tester(isolate, bytecode_array, vector);
1805 auto callable = tester.GetCallable<>(); 1792 auto callable = tester.GetCallable<>();
1806 Handle<Object> return_value = callable().ToHandleChecked(); 1793 Handle<Object> return_value = callable().ToHandleChecked();
1807 CHECK(return_value->IsBoolean()); 1794 CHECK(return_value->IsBoolean());
1808 CHECK_EQ(return_value->BooleanValue(), 1795 CHECK_EQ(return_value->BooleanValue(),
1809 CompareC(comparison, inputs[i], inputs[j])); 1796 CompareC(comparison, inputs[i], inputs[j]));
1810 Object* feedback = vector->Get(slot); 1797 Object* feedback = vector->Get(slot);
1811 CHECK(feedback->IsSmi()); 1798 CHECK(feedback->IsSmi());
1812 CHECK_EQ(CompareOperationFeedback::kAny, 1799 CHECK_EQ(BinaryOperationFeedback::kAny,
1813 static_cast<Smi*>(feedback)->value()); 1800 static_cast<Smi*>(feedback)->value());
1814 } 1801 }
1815 } 1802 }
1816 } 1803 }
1817 } 1804 }
1818 1805
1819 1806
1820 TEST(InterpreterMixedComparisons) { 1807 TEST(InterpreterMixedComparisons) {
1821 // This test compares a HeapNumber with a String. The latter is 1808 // This test compares a HeapNumber with a String. The latter is
1822 // convertible to a HeapNumber so comparison will be between numeric 1809 // convertible to a HeapNumber so comparison will be between numeric
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 Handle<BytecodeArray> bytecode_array = 1855 Handle<BytecodeArray> bytecode_array =
1869 builder.ToBytecodeArray(isolate); 1856 builder.ToBytecodeArray(isolate);
1870 InterpreterTester tester(isolate, bytecode_array, vector); 1857 InterpreterTester tester(isolate, bytecode_array, vector);
1871 auto callable = tester.GetCallable<>(); 1858 auto callable = tester.GetCallable<>();
1872 Handle<Object> return_value = callable().ToHandleChecked(); 1859 Handle<Object> return_value = callable().ToHandleChecked();
1873 CHECK(return_value->IsBoolean()); 1860 CHECK(return_value->IsBoolean());
1874 CHECK_EQ(return_value->BooleanValue(), 1861 CHECK_EQ(return_value->BooleanValue(),
1875 CompareC(comparison, lhs, rhs, true)); 1862 CompareC(comparison, lhs, rhs, true));
1876 Object* feedback = vector->Get(slot); 1863 Object* feedback = vector->Get(slot);
1877 CHECK(feedback->IsSmi()); 1864 CHECK(feedback->IsSmi());
1878 CHECK_EQ(CompareOperationFeedback::kAny, 1865 CHECK_EQ(BinaryOperationFeedback::kAny,
1879 static_cast<Smi*>(feedback)->value()); 1866 static_cast<Smi*>(feedback)->value());
1880 } 1867 }
1881 } 1868 }
1882 } 1869 }
1883 } 1870 }
1884 } 1871 }
1885 1872
1886 TEST(InterpreterStrictNotEqual) { 1873 TEST(InterpreterStrictNotEqual) {
1887 HandleAndZoneScope handles; 1874 HandleAndZoneScope handles;
1888 Isolate* isolate = handles.main_isolate(); 1875 Isolate* isolate = handles.main_isolate();
(...skipping 2936 matching lines...) Expand 10 before | Expand all | Expand 10 after
4825 auto callable = tester.GetCallable<>(); 4812 auto callable = tester.GetCallable<>();
4826 4813
4827 Handle<i::Object> return_value = callable().ToHandleChecked(); 4814 Handle<i::Object> return_value = callable().ToHandleChecked();
4828 CHECK(return_value->SameValue(*tests[i].second)); 4815 CHECK(return_value->SameValue(*tests[i].second));
4829 } 4816 }
4830 } 4817 }
4831 4818
4832 } // namespace interpreter 4819 } // namespace interpreter
4833 } // namespace internal 4820 } // namespace internal
4834 } // namespace v8 4821 } // namespace v8
OLDNEW
« no previous file with comments | « src/type-feedback-vector-inl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698