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

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

Issue 1731253003: Revert of [Interpreter] Implements calls through CallICStub in the interpreter. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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
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 "src/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/compiler.h" 7 #include "src/compiler.h"
8 #include "src/interpreter/bytecode-array-iterator.h" 8 #include "src/interpreter/bytecode-array-iterator.h"
9 #include "src/interpreter/bytecode-generator.h" 9 #include "src/interpreter/bytecode-generator.h"
10 #include "src/interpreter/interpreter.h" 10 #include "src/interpreter/interpreter.h"
(...skipping 1494 matching lines...) Expand 10 before | Expand all | Expand 10 after
1505 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", 1505 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")",
1506 2 * kPointerSize, 1506 2 * kPointerSize,
1507 2, 1507 2,
1508 17, 1508 17,
1509 { 1509 {
1510 B(StackCheck), // 1510 B(StackCheck), //
1511 B(Ldar), A(1, 2), // 1511 B(Ldar), A(1, 2), //
1512 B(Star), R(1), // 1512 B(Star), R(1), //
1513 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1513 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1514 B(Star), R(0), // 1514 B(Star), R(0), //
1515 B(CallIC), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), // 1515 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), //
1516 B(Return), // 1516 B(Return), //
1517 }, 1517 },
1518 1, 1518 1,
1519 {"func"}}, 1519 {"func"}},
1520 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", 1520 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)",
1521 4 * kPointerSize, 1521 4 * kPointerSize,
1522 4, 1522 4,
1523 25, 1523 25,
1524 { 1524 {
1525 B(StackCheck), // 1525 B(StackCheck), //
1526 B(Ldar), A(1, 4), // 1526 B(Ldar), A(1, 4), //
1527 B(Star), R(1), // 1527 B(Star), R(1), //
1528 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1528 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1529 B(Star), R(0), // 1529 B(Star), R(0), //
1530 B(Ldar), A(2, 4), // 1530 B(Ldar), A(2, 4), //
1531 B(Star), R(2), // 1531 B(Star), R(2), //
1532 B(Ldar), A(3, 4), // 1532 B(Ldar), A(3, 4), //
1533 B(Star), R(3), // 1533 B(Star), R(3), //
1534 B(CallIC), R(0), R(1), U8(3), U8(vector->GetIndex(slot1)), // 1534 B(Call), R(0), R(1), U8(3), U8(vector->GetIndex(slot1)), //
1535 B(Return) // 1535 B(Return) //
1536 }, 1536 },
1537 1, 1537 1,
1538 {"func"}}, 1538 {"func"}},
1539 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", 1539 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)",
1540 4 * kPointerSize, 1540 4 * kPointerSize,
1541 3, 1541 3,
1542 31, 1542 31,
1543 { 1543 {
1544 B(StackCheck), // 1544 B(StackCheck), //
1545 B(Ldar), A(1, 3), // 1545 B(Ldar), A(1, 3), //
1546 B(Star), R(1), // 1546 B(Star), R(1), //
1547 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1547 B(LoadIC), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1548 B(Star), R(0), // 1548 B(Star), R(0), //
1549 B(Ldar), A(2, 3), // 1549 B(Ldar), A(2, 3), //
1550 B(Star), R(3), // 1550 B(Star), R(3), //
1551 B(Ldar), A(2, 3), // 1551 B(Ldar), A(2, 3), //
1552 B(Add), R(3), // 1552 B(Add), R(3), //
1553 B(Star), R(2), // 1553 B(Star), R(2), //
1554 B(Ldar), A(2, 3), // 1554 B(Ldar), A(2, 3), //
1555 B(Star), R(3), // 1555 B(Star), R(3), //
1556 B(CallIC), R(0), R(1), U8(3), U8(vector->GetIndex(slot1)), // 1556 B(Call), R(0), R(1), U8(3), U8(vector->GetIndex(slot1)), //
1557 B(Return), // 1557 B(Return), //
1558 }, 1558 },
1559 1, 1559 1,
1560 {"func"}}, 1560 {"func"}},
1561 {"function f(a) {\n" 1561 {"function f(a) {\n"
1562 " a.func;\n" REPEAT_127( 1562 " a.func;\n" REPEAT_127(
1563 SPACE, " a.func;\n") " return a.func(); }\nf(" FUNC_ARG ")", 1563 SPACE, " a.func;\n") " return a.func(); }\nf(" FUNC_ARG ")",
1564 2 * kPointerSize, 1564 2 * kPointerSize,
1565 2, 1565 2,
1566 1047, 1566 1047,
1567 { 1567 {
1568 B(StackCheck), // 1568 B(StackCheck), //
1569 B(Ldar), A(1, 2), // 1569 B(Ldar), A(1, 2), //
1570 B(Star), R(0), // 1570 B(Star), R(0), //
1571 B(LoadIC), R(0), U8(0), U8(wide_idx += 2), // 1571 B(LoadIC), R(0), U8(0), U8(wide_idx += 2), //
1572 REPEAT_127(COMMA, // 1572 REPEAT_127(COMMA, //
1573 B(Ldar), A(1, 2), // 1573 B(Ldar), A(1, 2), //
1574 B(Star), R(0), // 1574 B(Star), R(0), //
1575 B(LoadIC), R(0), U8(0), U8((wide_idx += 2))), // 1575 B(LoadIC), R(0), U8(0), U8((wide_idx += 2))), //
1576 B(Ldar), A(1, 2), // 1576 B(Ldar), A(1, 2), //
1577 B(Star), R(1), // 1577 B(Star), R(1), //
1578 B(LoadICWide), R(1), U16(0), U16(wide_idx + 4), // 1578 B(LoadICWide), R(1), U16(0), U16(wide_idx + 4), //
1579 B(Star), R(0), // 1579 B(Star), R(0), //
1580 B(CallICWide), R16(0), R16(1), U16(1), U16(wide_idx + 2), // 1580 B(CallWide), R16(0), R16(1), U16(1), U16(wide_idx + 2), //
1581 B(Return), // 1581 B(Return), //
1582 }, 1582 },
1583 1, 1583 1,
1584 {"func"}}, 1584 {"func"}},
1585 }; 1585 };
1586 // clang-format on 1586 // clang-format on
1587 1587
1588 for (size_t i = 0; i < arraysize(snippets); i++) { 1588 for (size_t i = 0; i < arraysize(snippets); i++) {
1589 Handle<BytecodeArray> bytecode_array = 1589 Handle<BytecodeArray> bytecode_array =
1590 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 1590 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
1819 Handle<i::TypeFeedbackVector> vector = 1819 Handle<i::TypeFeedbackVector> vector =
1820 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1820 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1821 1821
1822 // clang-format off 1822 // clang-format off
1823 ExpectedSnippet<const char*> snippets[] = { 1823 ExpectedSnippet<const char*> snippets[] = {
1824 {"function t() { }\nfunction f() { return t(); }\nf()", 1824 {"function t() { }\nfunction f() { return t(); }\nf()",
1825 2 * kPointerSize, 1825 2 * kPointerSize,
1826 1, 1826 1,
1827 15, 1827 15,
1828 { 1828 {
1829 B(StackCheck), // 1829 B(StackCheck), //
1830 B(LdaUndefined), // 1830 B(LdaUndefined), //
1831 B(Star), R(1), // 1831 B(Star), R(1), //
1832 B(LdaGlobal), U8(0), U8(vector->GetIndex(slot2)), // 1832 B(LdaGlobal), U8(0), U8(vector->GetIndex(slot2)), //
1833 B(Star), R(0), // 1833 B(Star), R(0), //
1834 B(CallIC), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), // 1834 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), //
1835 B(Return) // 1835 B(Return) //
1836 }, 1836 },
1837 1, 1837 1,
1838 {"t"}}, 1838 {"t"}},
1839 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()", 1839 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
1840 5 * kPointerSize, 1840 5 * kPointerSize,
1841 1, 1841 1,
1842 27, 1842 27,
1843 { 1843 {
1844 B(StackCheck), // 1844 B(StackCheck), //
1845 B(LdaUndefined), // 1845 B(LdaUndefined), //
1846 B(Star), R(1), // 1846 B(Star), R(1), //
1847 B(LdaGlobal), U8(0), U8(vector->GetIndex(slot2)), // 1847 B(LdaGlobal), U8(0), U8(vector->GetIndex(slot2)), //
1848 B(Star), R(0), // 1848 B(Star), R(0), //
1849 B(LdaSmi8), U8(1), // 1849 B(LdaSmi8), U8(1), //
1850 B(Star), R(2), // 1850 B(Star), R(2), //
1851 B(LdaSmi8), U8(2), // 1851 B(LdaSmi8), U8(2), //
1852 B(Star), R(3), // 1852 B(Star), R(3), //
1853 B(LdaSmi8), U8(3), // 1853 B(LdaSmi8), U8(3), //
1854 B(Star), R(4), // 1854 B(Star), R(4), //
1855 B(CallIC), R(0), R(1), U8(4), U8(vector->GetIndex(slot1)), // 1855 B(Call), R(0), R(1), U8(4), U8(vector->GetIndex(slot1)), //
1856 B(Return) // 1856 B(Return) //
1857 }, 1857 },
1858 1, 1858 1,
1859 {"t"}}, 1859 {"t"}},
1860 }; 1860 };
1861 // clang-format on 1861 // clang-format on
1862 1862
1863 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); 1863 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1864 for (size_t i = 0; i < num_snippets; i++) { 1864 for (size_t i = 0; i < num_snippets; i++) {
1865 Handle<BytecodeArray> bytecode_array = 1865 Handle<BytecodeArray> bytecode_array =
1866 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1866 helper.MakeBytecode(snippets[i].code_snippet, "f");
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 B(LdaConstant), U8(0), // 2293 B(LdaConstant), U8(0), //
2294 B(Star), R(1), // 2294 B(Star), R(1), //
2295 B(LdaZero), // 2295 B(LdaZero), //
2296 B(Star), R(2), // 2296 B(Star), R(2), //
2297 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 2297 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
2298 B(StackCheck), // 2298 B(StackCheck), //
2299 B(LdaUndefined), // 2299 B(LdaUndefined), //
2300 B(Star), R(2), // 2300 B(Star), R(2), //
2301 B(LdaGlobal), U8(1), U8(load_vector->GetIndex(load_slot_1)), // 2301 B(LdaGlobal), U8(1), U8(load_vector->GetIndex(load_slot_1)), //
2302 B(Star), R(1), // 2302 B(Star), R(1), //
2303 B(CallIC), R(1), R(2), U8(1), // 2303 B(Call), R(1), R(2), U8(1), //
2304 /* */ U8(load_vector->GetIndex(call_slot_1)), // 2304 /* */ U8(load_vector->GetIndex(call_slot_1)), //
2305 B(Star), R(0), // 2305 B(Star), R(0), //
2306 B(Return) // 2306 B(Return) //
2307 }, 2307 },
2308 2, 2308 2,
2309 {InstanceType::FIXED_ARRAY_TYPE, 2309 {InstanceType::FIXED_ARRAY_TYPE,
2310 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 2310 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
2311 }; 2311 };
2312 // clang-format on 2312 // clang-format on
2313 2313
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
3767 B(CreateClosure), U8(0), U8(0), // 3767 B(CreateClosure), U8(0), U8(0), //
3768 B(Return) // 3768 B(Return) //
3769 }, 3769 },
3770 1, 3770 1,
3771 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3771 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3772 {"return (function(){ })()", 3772 {"return (function(){ })()",
3773 2 * kPointerSize, 3773 2 * kPointerSize,
3774 1, 3774 1,
3775 15, 3775 15,
3776 { 3776 {
3777 B(StackCheck), // 3777 B(StackCheck), //
3778 B(LdaUndefined), // 3778 B(LdaUndefined), //
3779 B(Star), R(1), // 3779 B(Star), R(1), //
3780 B(CreateClosure), U8(0), U8(0), // 3780 B(CreateClosure), U8(0), U8(0), //
3781 B(Star), R(0), // 3781 B(Star), R(0), //
3782 B(CallIC), R(0), R(1), U8(1), U8(vector->GetIndex(slot)), // 3782 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot)), //
3783 B(Return) // 3783 B(Return) //
3784 }, 3784 },
3785 1, 3785 1,
3786 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3786 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3787 {"return (function(x){ return x; })(1)", 3787 {"return (function(x){ return x; })(1)",
3788 3 * kPointerSize, 3788 3 * kPointerSize,
3789 1, 3789 1,
3790 19, 3790 19,
3791 { 3791 {
3792 B(StackCheck), // 3792 B(StackCheck), //
3793 B(LdaUndefined), // 3793 B(LdaUndefined), //
3794 B(Star), R(1), // 3794 B(Star), R(1), //
3795 B(CreateClosure), U8(0), U8(0), // 3795 B(CreateClosure), U8(0), U8(0), //
3796 B(Star), R(0), // 3796 B(Star), R(0), //
3797 B(LdaSmi8), U8(1), // 3797 B(LdaSmi8), U8(1), //
3798 B(Star), R(2), // 3798 B(Star), R(2), //
3799 B(CallIC), R(0), R(1), U8(2), U8(vector->GetIndex(slot)), // 3799 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot)), //
3800 B(Return) // 3800 B(Return) //
3801 }, 3801 },
3802 1, 3802 1,
3803 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3803 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3804 }; 3804 };
3805 // clang-format on 3805 // clang-format on
3806 3806
3807 for (size_t i = 0; i < arraysize(snippets); i++) { 3807 for (size_t i = 0; i < arraysize(snippets); i++) {
3808 Handle<BytecodeArray> bytecode_array = 3808 Handle<BytecodeArray> bytecode_array =
3809 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3809 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
3810 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3810 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3854 1, 3854 1,
3855 23, 3855 23,
3856 { 3856 {
3857 B(StackCheck), // 3857 B(StackCheck), //
3858 B(CreateRegExpLiteral), U8(0), U8(0), U8(0), // 3858 B(CreateRegExpLiteral), U8(0), U8(0), U8(0), //
3859 B(Star), R(1), // 3859 B(Star), R(1), //
3860 B(LoadIC), R(1), U8(1), U8(vector->GetIndex(slot2)), // 3860 B(LoadIC), R(1), U8(1), U8(vector->GetIndex(slot2)), //
3861 B(Star), R(0), // 3861 B(Star), R(0), //
3862 B(LdaConstant), U8(2), // 3862 B(LdaConstant), U8(2), //
3863 B(Star), R(2), // 3863 B(Star), R(2), //
3864 B(CallIC), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), // 3864 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), //
3865 B(Return), // 3865 B(Return), //
3866 }, 3866 },
3867 3, 3867 3,
3868 {"ab+d", "exec", "abdd"}}, 3868 {"ab+d", "exec", "abdd"}},
3869 }; 3869 };
3870 // clang-format on 3870 // clang-format on
3871 3871
3872 for (size_t i = 0; i < arraysize(snippets); i++) { 3872 for (size_t i = 0; i < arraysize(snippets); i++) {
3873 Handle<BytecodeArray> bytecode_array = 3873 Handle<BytecodeArray> bytecode_array =
3874 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 3874 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
5029 B(CreateClosure), U8(0), U8(0), // 5029 B(CreateClosure), U8(0), U8(0), //
5030 B(Return), // 5030 B(Return), //
5031 }, 5031 },
5032 1, 5032 1,
5033 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 5033 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
5034 {"var a; (function() { a = 2; })(); return a;", 5034 {"var a; (function() { a = 2; })(); return a;",
5035 3 * kPointerSize, 5035 3 * kPointerSize,
5036 1, 5036 1,
5037 25, 5037 25,
5038 { 5038 {
5039 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 5039 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
5040 /* */ R(closure), U8(1), // 5040 /* */ R(closure), U8(1), //
5041 B(PushContext), R(0), // 5041 B(PushContext), R(0), //
5042 B(StackCheck), // 5042 B(StackCheck), //
5043 B(LdaUndefined), // 5043 B(LdaUndefined), //
5044 B(Star), R(2), // 5044 B(Star), R(2), //
5045 B(CreateClosure), U8(0), U8(0), // 5045 B(CreateClosure), U8(0), U8(0), //
5046 B(Star), R(1), // 5046 B(Star), R(1), //
5047 B(CallIC), R(1), R(2), U8(1), U8(vector->GetIndex(slot)), // 5047 B(Call), R(1), R(2), U8(1), U8(vector->GetIndex(slot)), //
5048 B(LdaContextSlot), R(context), U8(first_context_slot), // 5048 B(LdaContextSlot), R(context), U8(first_context_slot), //
5049 B(Return), // 5049 B(Return), //
5050 }, 5050 },
5051 1, 5051 1,
5052 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 5052 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
5053 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", 5053 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }",
5054 4 * kPointerSize, 5054 4 * kPointerSize,
5055 1, 5055 1,
5056 47, 5056 47,
5057 { 5057 {
5058 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 5058 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
5059 /* */ R(closure), U8(1), // 5059 /* */ R(closure), U8(1), //
(...skipping 20 matching lines...) Expand all
5080 2, 5080 2,
5081 {InstanceType::FIXED_ARRAY_TYPE, 5081 {InstanceType::FIXED_ARRAY_TYPE,
5082 InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 5082 InstanceType::SHARED_FUNCTION_INFO_TYPE}},
5083 {"'use strict';\n" 5083 {"'use strict';\n"
5084 REPEAT_249_UNIQUE_VARS() 5084 REPEAT_249_UNIQUE_VARS()
5085 "eval();" 5085 "eval();"
5086 "var b = 100;" 5086 "var b = 100;"
5087 "return b", 5087 "return b",
5088 3 * kPointerSize, 5088 3 * kPointerSize,
5089 1, 5089 1,
5090 1041, 5090 1042,
5091 { 5091 {
5092 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 5092 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
5093 /* */ U8(1), // 5093 /* */ U8(1), //
5094 B(PushContext), R(0), // 5094 B(PushContext), R(0), //
5095 B(Ldar), THIS(1), // 5095 B(Ldar), THIS(1), //
5096 B(StaContextSlot), R(context), U8(first_context_slot), // 5096 B(StaContextSlot), R(context), U8(first_context_slot), //
5097 B(CreateUnmappedArguments), // 5097 B(CreateUnmappedArguments), //
5098 B(StaContextSlot), R(context), U8(first_context_slot + 1), // 5098 B(StaContextSlot), R(context), U8(first_context_slot + 1), //
5099 B(Ldar), R(new_target), // 5099 B(Ldar), R(new_target), //
5100 B(StaContextSlot), R(context), U8(first_context_slot + 2), // 5100 B(StaContextSlot), R(context), U8(first_context_slot + 2), //
5101 B(StackCheck), // 5101 B(StackCheck), //
5102 REPEAT_249(COMMA, // 5102 REPEAT_249(COMMA, //
5103 B(LdaZero), // 5103 B(LdaZero), //
5104 B(StaContextSlot), R(context), U8(wide_slot++)), // 5104 B(StaContextSlot), R(context), U8(wide_slot++)), //
5105 B(LdaUndefined), // 5105 B(LdaUndefined), //
5106 B(Star), R(2), // 5106 B(Star), R(2), //
5107 B(LdaGlobal), U8(0), U8(1), // 5107 B(LdaGlobal), U8(0), U8(1), //
5108 B(Star), R(1), // 5108 B(Star), R(1), //
5109 B(Call), R(1), R(2), U8(1), // 5109 B(Call), R(1), R(2), U8(1), U8(0), //
5110 B(LdaSmi8), U8(100), // 5110 B(LdaSmi8), U8(100), //
5111 B(StaContextSlotWide), R(context), U16(256), // 5111 B(StaContextSlotWide), R(context), U16(256), //
5112 B(LdaContextSlotWide), R(context), U16(256), // 5112 B(LdaContextSlotWide), R(context), U16(256), //
5113 B(Return), // 5113 B(Return), //
5114 }, 5114 },
5115 1, 5115 1,
5116 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 5116 {InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
5117 }; 5117 };
5118 // clang-format on 5118 // clang-format on
5119 5119
(...skipping 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after
6317 7 * kPointerSize, 6317 7 * kPointerSize,
6318 1, 6318 1,
6319 86, 6319 86,
6320 { 6320 {
6321 B(StackCheck), // 6321 B(StackCheck), //
6322 B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), // 6322 B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), //
6323 B(Star), R(5), // 6323 B(Star), R(5), //
6324 B(LdaConstant), U8(1), // 6324 B(LdaConstant), U8(1), //
6325 B(KeyedLoadIC), R(5), U8(vector->GetIndex(slot2)), // 6325 B(KeyedLoadIC), R(5), U8(vector->GetIndex(slot2)), //
6326 B(Star), R(4), // 6326 B(Star), R(4), //
6327 B(CallIC), R(4), R(5), U8(1), U8(vector->GetIndex(slot1)), // 6327 B(Call), R(4), R(5), U8(1), U8(vector->GetIndex(slot1)), //
6328 B(Star), R(1), // 6328 B(Star), R(1), //
6329 B(Ldar), R(1), // 6329 B(Ldar), R(1), //
6330 B(Star), R(6), // 6330 B(Star), R(6), //
6331 B(LoadIC), R(6), U8(2), U8(vector->GetIndex(slot4)), // 6331 B(LoadIC), R(6), U8(2), U8(vector->GetIndex(slot4)), //
6332 B(Star), R(5), // 6332 B(Star), R(5), //
6333 B(CallIC), R(5), R(6), U8(1), U8(vector->GetIndex(slot3)), // 6333 B(Call), R(5), R(6), U8(1), U8(vector->GetIndex(slot3)), //
6334 B(Star), R(2), // 6334 B(Star), R(2), //
6335 B(Star), R(4), // 6335 B(Star), R(4), //
6336 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(4), U8(1), // 6336 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(4), U8(1), //
6337 B(LogicalNot), // 6337 B(LogicalNot), //
6338 B(JumpIfFalse), U8(11), // 6338 B(JumpIfFalse), U8(11), //
6339 B(Ldar), R(2), // 6339 B(Ldar), R(2), //
6340 B(Star), R(4), // 6340 B(Star), R(4), //
6341 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), // 6341 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), //
6342 /* */ R(4), U8(1), // 6342 /* */ R(4), U8(1), //
6343 B(Ldar), R(2), // 6343 B(Ldar), R(2), //
(...skipping 22 matching lines...) Expand all
6366 1, 6366 1,
6367 85, 6367 85,
6368 { 6368 {
6369 B(StackCheck), // 6369 B(StackCheck), //
6370 B(LdaConstant), U8(0), // 6370 B(LdaConstant), U8(0), //
6371 B(Star), R(3), // 6371 B(Star), R(3), //
6372 B(Star), R(6), // 6372 B(Star), R(6), //
6373 B(LdaConstant), U8(1), // 6373 B(LdaConstant), U8(1), //
6374 B(KeyedLoadIC), R(6), U8(vector->GetIndex(slot2)), // 6374 B(KeyedLoadIC), R(6), U8(vector->GetIndex(slot2)), //
6375 B(Star), R(5), // 6375 B(Star), R(5), //
6376 B(CallIC), R(5), R(6), U8(1), U8(vector->GetIndex(slot1)), // 6376 B(Call), R(5), R(6), U8(1), U8(vector->GetIndex(slot1)), //
6377 B(Star), R(1), // 6377 B(Star), R(1), //
6378 B(Ldar), R(1), // 6378 B(Ldar), R(1), //
6379 B(Star), R(7), // 6379 B(Star), R(7), //
6380 B(LoadIC), R(7), U8(2), U8(vector->GetIndex(slot4)), // 6380 B(LoadIC), R(7), U8(2), U8(vector->GetIndex(slot4)), //
6381 B(Star), R(6), // 6381 B(Star), R(6), //
6382 B(CallIC), R(6), R(7), U8(1), U8(vector->GetIndex(slot3)), // 6382 B(Call), R(6), R(7), U8(1), U8(vector->GetIndex(slot3)), //
6383 B(Star), R(2), // 6383 B(Star), R(2), //
6384 B(Star), R(5), // 6384 B(Star), R(5), //
6385 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(5), U8(1), // 6385 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(5), U8(1), //
6386 B(LogicalNot), // 6386 B(LogicalNot), //
6387 B(JumpIfFalse), U8(11), // 6387 B(JumpIfFalse), U8(11), //
6388 B(Ldar), R(2), // 6388 B(Ldar), R(2), //
6389 B(Star), R(5), // 6389 B(Star), R(5), //
6390 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), // 6390 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), //
6391 /* */ R(5), U8(1), // 6391 /* */ R(5), U8(1), //
6392 B(Ldar), R(2), // 6392 B(Ldar), R(2), //
(...skipping 24 matching lines...) Expand all
6417 7 * kPointerSize, 6417 7 * kPointerSize,
6418 1, 6418 1,
6419 108, 6419 108,
6420 { 6420 {
6421 B(StackCheck), // 6421 B(StackCheck), //
6422 B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), // 6422 B(CreateArrayLiteral), U8(0), U8(0), U8(array_literal_flags), //
6423 B(Star), R(5), // 6423 B(Star), R(5), //
6424 B(LdaConstant), U8(1), // 6424 B(LdaConstant), U8(1), //
6425 B(KeyedLoadIC), R(5), U8(vector->GetIndex(slot2)), // 6425 B(KeyedLoadIC), R(5), U8(vector->GetIndex(slot2)), //
6426 B(Star), R(4), // 6426 B(Star), R(4), //
6427 B(CallIC), R(4), R(5), U8(1), U8(vector->GetIndex(slot1)), // 6427 B(Call), R(4), R(5), U8(1), U8(vector->GetIndex(slot1)), //
6428 B(Star), R(1), // 6428 B(Star), R(1), //
6429 B(Ldar), R(1), // 6429 B(Ldar), R(1), //
6430 B(Star), R(6), // 6430 B(Star), R(6), //
6431 B(LoadIC), R(6), U8(2), U8(vector->GetIndex(slot4)), // 6431 B(LoadIC), R(6), U8(2), U8(vector->GetIndex(slot4)), //
6432 B(Star), R(5), // 6432 B(Star), R(5), //
6433 B(CallIC), R(5), R(6), U8(1), U8(vector->GetIndex(slot3)), // 6433 B(Call), R(5), R(6), U8(1), U8(vector->GetIndex(slot3)), //
6434 B(Star), R(2), // 6434 B(Star), R(2), //
6435 B(Star), R(4), // 6435 B(Star), R(4), //
6436 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(4), U8(1), // 6436 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(4), U8(1), //
6437 B(LogicalNot), // 6437 B(LogicalNot), //
6438 B(JumpIfFalse), U8(11), // 6438 B(JumpIfFalse), U8(11), //
6439 B(Ldar), R(2), // 6439 B(Ldar), R(2), //
6440 B(Star), R(4), // 6440 B(Star), R(4), //
6441 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), // 6441 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), //
6442 /* */ R(4), U8(1), // 6442 /* */ R(4), U8(1), //
6443 B(Ldar), R(2), // 6443 B(Ldar), R(2), //
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
6479 { 6479 {
6480 B(StackCheck), // 6480 B(StackCheck), //
6481 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), // 6481 B(CreateObjectLiteral), U8(0), U8(0), U8(object_literal_flags), //
6482 B(Star), R(3), // 6482 B(Star), R(3), //
6483 B(Star), R(2), // 6483 B(Star), R(2), //
6484 B(CreateArrayLiteral), U8(1), U8(1), U8(array_literal_flags), // 6484 B(CreateArrayLiteral), U8(1), U8(1), U8(array_literal_flags), //
6485 B(Star), R(4), // 6485 B(Star), R(4), //
6486 B(LdaConstant), U8(2), // 6486 B(LdaConstant), U8(2), //
6487 B(KeyedLoadIC), R(4), U8(vector->GetIndex(slot2)), // 6487 B(KeyedLoadIC), R(4), U8(vector->GetIndex(slot2)), //
6488 B(Star), R(3), // 6488 B(Star), R(3), //
6489 B(CallIC), R(3), R(4), U8(1), U8(vector->GetIndex(slot1)), // 6489 B(Call), R(3), R(4), U8(1), U8(vector->GetIndex(slot1)), //
6490 B(Star), R(0), // 6490 B(Star), R(0), //
6491 B(Ldar), R(0), // 6491 B(Ldar), R(0), //
6492 B(Star), R(5), // 6492 B(Star), R(5), //
6493 B(LoadIC), R(5), U8(3), U8(vector->GetIndex(slot4)), // 6493 B(LoadIC), R(5), U8(3), U8(vector->GetIndex(slot4)), //
6494 B(Star), R(4), // 6494 B(Star), R(4), //
6495 B(CallIC), R(4), R(5), U8(1), U8(vector->GetIndex(slot3)), // 6495 B(Call), R(4), R(5), U8(1), U8(vector->GetIndex(slot3)), //
6496 B(Star), R(1), // 6496 B(Star), R(1), //
6497 B(Star), R(3), // 6497 B(Star), R(3), //
6498 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(3), U8(1), // 6498 B(CallRuntime), U16(Runtime::kInlineIsJSReceiver), R(3), U8(1), //
6499 B(LogicalNot), // 6499 B(LogicalNot), //
6500 B(JumpIfFalse), U8(11), // 6500 B(JumpIfFalse), U8(11), //
6501 B(Ldar), R(1), // 6501 B(Ldar), R(1), //
6502 B(Star), R(3), // 6502 B(Star), R(3), //
6503 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), // 6503 B(CallRuntime), U16(Runtime::kThrowIteratorResultNotAnObject), //
6504 /* */ R(3), U8(1), // 6504 /* */ R(3), U8(1), //
6505 B(Ldar), R(1), // 6505 B(Ldar), R(1), //
(...skipping 927 matching lines...) Expand 10 before | Expand all | Expand 10 after
7433 int context = Register::current_context().index(); 7433 int context = Register::current_context().index();
7434 int new_target = Register::new_target().index(); 7434 int new_target = Register::new_target().index();
7435 7435
7436 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 7436 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
7437 7437
7438 // clang-format off 7438 // clang-format off
7439 ExpectedSnippet<const char*> snippets[] = { 7439 ExpectedSnippet<const char*> snippets[] = {
7440 {"return eval('1;');", 7440 {"return eval('1;');",
7441 9 * kPointerSize, 7441 9 * kPointerSize,
7442 1, 7442 1,
7443 64, 7443 65,
7444 { 7444 {
7445 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 7445 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
7446 /* */ U8(1), // 7446 /* */ U8(1), //
7447 B(PushContext), R(0), // 7447 B(PushContext), R(0), //
7448 B(Ldar), THIS(1), // 7448 B(Ldar), THIS(1), //
7449 B(StaContextSlot), R(context), U8(first_context_slot), // 7449 B(StaContextSlot), R(context), U8(first_context_slot), //
7450 B(CreateMappedArguments), // 7450 B(CreateMappedArguments), //
7451 B(StaContextSlot), R(context), U8(first_context_slot + 1), // 7451 B(StaContextSlot), R(context), U8(first_context_slot + 1), //
7452 B(Ldar), R(new_target), // 7452 B(Ldar), R(new_target), //
7453 B(StaContextSlot), R(context), U8(first_context_slot + 2), // 7453 B(StaContextSlot), R(context), U8(first_context_slot + 2), //
7454 B(StackCheck), // 7454 B(StackCheck), //
7455 B(LdaConstant), U8(0), // 7455 B(LdaConstant), U8(0), //
7456 B(Star), R(3), // 7456 B(Star), R(3), //
7457 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7457 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7458 /* */ R(3), U8(1), R(1), // 7458 /* */ R(3), U8(1), R(1), //
7459 B(LdaConstant), U8(1), // 7459 B(LdaConstant), U8(1), //
7460 B(Star), R(3), // 7460 B(Star), R(3), //
7461 B(Mov), R(1), R(4), // 7461 B(Mov), R(1), R(4), //
7462 B(Mov), R(3), R(5), // 7462 B(Mov), R(3), R(5), //
7463 B(Mov), R(closure), R(6), // 7463 B(Mov), R(closure), R(6), //
7464 B(LdaZero), // 7464 B(LdaZero), //
7465 B(Star), R(7), // 7465 B(Star), R(7), //
7466 B(LdaSmi8), U8(10), // 7466 B(LdaSmi8), U8(10), //
7467 B(Star), R(8), // 7467 B(Star), R(8), //
7468 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // 7468 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
7469 /* */ U8(5), // 7469 /* */ U8(5), //
7470 B(Star), R(1), // 7470 B(Star), R(1), //
7471 B(Call), R(1), R(2), U8(2), // 7471 B(Call), R(1), R(2), U8(2), U8(0), //
7472 B(Return), // 7472 B(Return), //
7473 }, 7473 },
7474 2, 7474 2,
7475 {"eval", "1;"}}, 7475 {"eval", "1;"}},
7476 }; 7476 };
7477 // clang-format on 7477 // clang-format on
7478 7478
7479 for (size_t i = 0; i < arraysize(snippets); i++) { 7479 for (size_t i = 0; i < arraysize(snippets); i++) {
7480 Handle<BytecodeArray> bytecode_array = 7480 Handle<BytecodeArray> bytecode_array =
7481 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 7481 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
7482 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 7482 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
7483 } 7483 }
7484 } 7484 }
7485 7485
7486 7486
7487 TEST(LookupSlot) { 7487 TEST(LookupSlot) {
7488 InitializedHandleScope handle_scope; 7488 InitializedHandleScope handle_scope;
7489 BytecodeGeneratorHelper helper; 7489 BytecodeGeneratorHelper helper;
7490 7490
7491 int closure = Register::function_closure().index(); 7491 int closure = Register::function_closure().index();
7492 int context = Register::current_context().index(); 7492 int context = Register::current_context().index();
7493 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 7493 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
7494 int new_target = Register::new_target().index(); 7494 int new_target = Register::new_target().index();
7495 7495
7496 // clang-format off 7496 // clang-format off
7497 ExpectedSnippet<const char*> snippets[] = { 7497 ExpectedSnippet<const char*> snippets[] = {
7498 {"eval('var x = 10;'); return x;", 7498 {"eval('var x = 10;'); return x;",
7499 9 * kPointerSize, 7499 9 * kPointerSize,
7500 1, 7500 1,
7501 66, 7501 67,
7502 { 7502 {
7503 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 7503 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
7504 /* */ U8(1), // 7504 /* */ U8(1), //
7505 B(PushContext), R(0), // 7505 B(PushContext), R(0), //
7506 B(Ldar), THIS(1), // 7506 B(Ldar), THIS(1), //
7507 B(StaContextSlot), R(context), U8(first_context_slot), // 7507 B(StaContextSlot), R(context), U8(first_context_slot), //
7508 B(CreateMappedArguments), // 7508 B(CreateMappedArguments), //
7509 B(StaContextSlot), R(context), U8(first_context_slot + 1), // 7509 B(StaContextSlot), R(context), U8(first_context_slot + 1), //
7510 B(Ldar), R(new_target), // 7510 B(Ldar), R(new_target), //
7511 B(StaContextSlot), R(context), U8(first_context_slot + 2), // 7511 B(StaContextSlot), R(context), U8(first_context_slot + 2), //
7512 B(StackCheck), // 7512 B(StackCheck), //
7513 B(LdaConstant), U8(0), // 7513 B(LdaConstant), U8(0), //
7514 B(Star), R(3), // 7514 B(Star), R(3), //
7515 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7515 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7516 R(3), U8(1), R(1), // 7516 R(3), U8(1), R(1), //
7517 B(LdaConstant), U8(1), // 7517 B(LdaConstant), U8(1), //
7518 B(Star), R(3), // 7518 B(Star), R(3), //
7519 B(Mov), R(1), R(4), // 7519 B(Mov), R(1), R(4), //
7520 B(Mov), R(3), R(5), // 7520 B(Mov), R(3), R(5), //
7521 B(Mov), R(closure), R(6), // 7521 B(Mov), R(closure), R(6), //
7522 B(LdaZero), // 7522 B(LdaZero), //
7523 B(Star), R(7), // 7523 B(Star), R(7), //
7524 B(LdaSmi8), U8(10), // 7524 B(LdaSmi8), U8(10), //
7525 B(Star), R(8), // 7525 B(Star), R(8), //
7526 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // 7526 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
7527 U8(5), // 7527 U8(5), //
7528 B(Star), R(1), // 7528 B(Star), R(1), //
7529 B(Call), R(1), R(2), U8(2), // 7529 B(Call), R(1), R(2), U8(2), U8(0), //
7530 B(LdaLookupSlot), U8(2), // 7530 B(LdaLookupSlot), U8(2), //
7531 B(Return), // 7531 B(Return), //
7532 }, 7532 },
7533 3, 7533 3,
7534 {"eval", "var x = 10;", "x"}}, 7534 {"eval", "var x = 10;", "x"}},
7535 {"eval('var x = 10;'); return typeof x;", 7535 {"eval('var x = 10;'); return typeof x;",
7536 9 * kPointerSize, 7536 9 * kPointerSize,
7537 1, 7537 1,
7538 67, 7538 68,
7539 { 7539 {
7540 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 7540 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
7541 /* */ U8(1), // 7541 /* */ U8(1), //
7542 B(PushContext), R(0), // 7542 B(PushContext), R(0), //
7543 B(Ldar), THIS(1), // 7543 B(Ldar), THIS(1), //
7544 B(StaContextSlot), R(context), U8(first_context_slot), // 7544 B(StaContextSlot), R(context), U8(first_context_slot), //
7545 B(CreateMappedArguments), // 7545 B(CreateMappedArguments), //
7546 B(StaContextSlot), R(context), U8(first_context_slot + 1), // 7546 B(StaContextSlot), R(context), U8(first_context_slot + 1), //
7547 B(Ldar), R(new_target), // 7547 B(Ldar), R(new_target), //
7548 B(StaContextSlot), R(context), U8(first_context_slot + 2), // 7548 B(StaContextSlot), R(context), U8(first_context_slot + 2), //
7549 B(StackCheck), // 7549 B(StackCheck), //
7550 B(LdaConstant), U8(0), // 7550 B(LdaConstant), U8(0), //
7551 B(Star), R(3), // 7551 B(Star), R(3), //
7552 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7552 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7553 /* */ R(3), U8(1), R(1), // 7553 /* */ R(3), U8(1), R(1), //
7554 B(LdaConstant), U8(1), // 7554 B(LdaConstant), U8(1), //
7555 B(Star), R(3), // 7555 B(Star), R(3), //
7556 B(Mov), R(1), R(4), // 7556 B(Mov), R(1), R(4), //
7557 B(Mov), R(3), R(5), // 7557 B(Mov), R(3), R(5), //
7558 B(Mov), R(closure), R(6), // 7558 B(Mov), R(closure), R(6), //
7559 B(LdaZero), // 7559 B(LdaZero), //
7560 B(Star), R(7), // 7560 B(Star), R(7), //
7561 B(LdaSmi8), U8(10), // 7561 B(LdaSmi8), U8(10), //
7562 B(Star), R(8), // 7562 B(Star), R(8), //
7563 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // 7563 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
7564 /* */ U8(5), // 7564 /* */ U8(5), //
7565 B(Star), R(1), // 7565 B(Star), R(1), //
7566 B(Call), R(1), R(2), U8(2), // 7566 B(Call), R(1), R(2), U8(2), U8(0), //
7567 B(LdaLookupSlotInsideTypeof), U8(2), // 7567 B(LdaLookupSlotInsideTypeof), U8(2), //
7568 B(TypeOf), // 7568 B(TypeOf), //
7569 B(Return), // 7569 B(Return), //
7570 }, 7570 },
7571 3, 7571 3,
7572 {"eval", "var x = 10;", "x"}}, 7572 {"eval", "var x = 10;", "x"}},
7573 {"x = 20; return eval('');", 7573 {"x = 20; return eval('');",
7574 9 * kPointerSize, 7574 9 * kPointerSize,
7575 1, 7575 1,
7576 68, 7576 69,
7577 { 7577 {
7578 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 7578 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
7579 U8(1), // 7579 U8(1), //
7580 B(PushContext), R(0), // 7580 B(PushContext), R(0), //
7581 B(Ldar), THIS(1), // 7581 B(Ldar), THIS(1), //
7582 B(StaContextSlot), R(context), U8(first_context_slot), // 7582 B(StaContextSlot), R(context), U8(first_context_slot), //
7583 B(CreateMappedArguments), // 7583 B(CreateMappedArguments), //
7584 B(StaContextSlot), R(context), U8(first_context_slot + 1), // 7584 B(StaContextSlot), R(context), U8(first_context_slot + 1), //
7585 B(Ldar), R(new_target), // 7585 B(Ldar), R(new_target), //
7586 B(StaContextSlot), R(context), U8(first_context_slot + 2), // 7586 B(StaContextSlot), R(context), U8(first_context_slot + 2), //
7587 B(StackCheck), // 7587 B(StackCheck), //
7588 B(LdaSmi8), U8(20), // 7588 B(LdaSmi8), U8(20), //
7589 B(StaLookupSlotSloppy), U8(0), // 7589 B(StaLookupSlotSloppy), U8(0), //
7590 B(LdaConstant), U8(1), // 7590 B(LdaConstant), U8(1), //
7591 B(Star), R(3), // 7591 B(Star), R(3), //
7592 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7592 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7593 /* */ R(3), U8(1), R(1), // 7593 /* */ R(3), U8(1), R(1), //
7594 B(LdaConstant), U8(2), // 7594 B(LdaConstant), U8(2), //
7595 B(Star), R(3), // 7595 B(Star), R(3), //
7596 B(Mov), R(1), R(4), // 7596 B(Mov), R(1), R(4), //
7597 B(Mov), R(3), R(5), // 7597 B(Mov), R(3), R(5), //
7598 B(Mov), R(closure), R(6), // 7598 B(Mov), R(closure), R(6), //
7599 B(LdaZero), // 7599 B(LdaZero), //
7600 B(Star), R(7), // 7600 B(Star), R(7), //
7601 B(LdaSmi8), U8(10), // 7601 B(LdaSmi8), U8(10), //
7602 B(Star), R(8), // 7602 B(Star), R(8), //
7603 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // 7603 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
7604 /* */ U8(5), // 7604 /* */ U8(5), //
7605 B(Star), R(1), // 7605 B(Star), R(1), //
7606 B(Call), R(1), R(2), U8(2), // 7606 B(Call), R(1), R(2), U8(2), U8(0), //
7607 B(Return), // 7607 B(Return), //
7608 }, 7608 },
7609 3, 7609 3,
7610 {"x", "eval", ""}}, 7610 {"x", "eval", ""}},
7611 }; 7611 };
7612 // clang-format on 7612 // clang-format on
7613 7613
7614 for (size_t i = 0; i < arraysize(snippets); i++) { 7614 for (size_t i = 0; i < arraysize(snippets); i++) {
7615 Handle<BytecodeArray> bytecode_array = 7615 Handle<BytecodeArray> bytecode_array =
7616 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 7616 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
(...skipping 17 matching lines...) Expand all
7634 7634
7635 int closure = Register::function_closure().index(); 7635 int closure = Register::function_closure().index();
7636 int context = Register::current_context().index(); 7636 int context = Register::current_context().index();
7637 int new_target = Register::new_target().index(); 7637 int new_target = Register::new_target().index();
7638 7638
7639 // clang-format off 7639 // clang-format off
7640 ExpectedSnippet<InstanceType> snippets[] = { 7640 ExpectedSnippet<InstanceType> snippets[] = {
7641 {"g = function(){}; eval(''); return g();", 7641 {"g = function(){}; eval(''); return g();",
7642 9 * kPointerSize, 7642 9 * kPointerSize,
7643 1, 7643 1,
7644 84, 7644 85,
7645 { 7645 {
7646 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), // 7646 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
7647 /* */ U8(1), // 7647 /* */ U8(1), //
7648 B(PushContext), R(0), // 7648 B(PushContext), R(0), //
7649 B(Ldar), THIS(1), // 7649 B(Ldar), THIS(1), //
7650 B(StaContextSlot), R(context), U8(4), // 7650 B(StaContextSlot), R(context), U8(4), //
7651 B(CreateMappedArguments), // 7651 B(CreateMappedArguments), //
7652 B(StaContextSlot), R(context), U8(5), // 7652 B(StaContextSlot), R(context), U8(5), //
7653 B(Ldar), R(new_target), // 7653 B(Ldar), R(new_target), //
7654 B(StaContextSlot), R(context), U8(6), // 7654 B(StaContextSlot), R(context), U8(6), //
7655 B(StackCheck), // 7655 B(StackCheck), //
7656 B(CreateClosure), U8(0), U8(0), // 7656 B(CreateClosure), U8(0), U8(0), //
7657 B(StaLookupSlotSloppy), U8(1), // 7657 B(StaLookupSlotSloppy), U8(1), //
7658 B(LdaConstant), U8(2), // 7658 B(LdaConstant), U8(2), //
7659 B(Star), R(3), // 7659 B(Star), R(3), //
7660 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7660 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7661 R(3), U8(1), R(1), // 7661 R(3), U8(1), R(1), //
7662 B(LdaConstant), U8(3), // 7662 B(LdaConstant), U8(3), //
7663 B(Star), R(3), // 7663 B(Star), R(3), //
7664 B(Mov), R(1), R(4), // 7664 B(Mov), R(1), R(4), //
7665 B(Mov), R(3), R(5), // 7665 B(Mov), R(3), R(5), //
7666 B(Mov), R(closure), R(6), // 7666 B(Mov), R(closure), R(6), //
7667 B(LdaZero), // 7667 B(LdaZero), //
7668 B(Star), R(7), // 7668 B(Star), R(7), //
7669 B(LdaSmi8), U8(10), // 7669 B(LdaSmi8), U8(10), //
7670 B(Star), R(8), // 7670 B(Star), R(8), //
7671 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), // 7671 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
7672 U8(5), // 7672 U8(5), //
7673 B(Star), R(1), // 7673 B(Star), R(1), //
7674 B(Call), R(1), R(2), U8(2), // 7674 B(Call), R(1), R(2), U8(2), U8(0), //
7675 B(LdaConstant), U8(1), // 7675 B(LdaConstant), U8(1), //
7676 B(Star), R(3), // 7676 B(Star), R(3), //
7677 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), // 7677 B(CallRuntimeForPair), U16(Runtime::kLoadLookupSlotForCall), //
7678 R(3), U8(1), R(1), // 7678 R(3), U8(1), R(1), //
7679 B(CallIC), R(1), R(2), U8(1), U8(vector->GetIndex(slot2)), // 7679 B(Call), R(1), R(2), U8(1), U8(vector->GetIndex(slot2)), //
7680 B(Return), // 7680 B(Return), //
7681 }, 7681 },
7682 4, 7682 4,
7683 {InstanceType::SHARED_FUNCTION_INFO_TYPE, 7683 {InstanceType::SHARED_FUNCTION_INFO_TYPE,
7684 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 7684 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
7685 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 7685 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
7686 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 7686 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
7687 }; 7687 };
7688 // clang-format on 7688 // clang-format on
7689 7689
(...skipping 1372 matching lines...) Expand 10 before | Expand all | Expand 10 after
9062 B(LdaTheHole), // 9062 B(LdaTheHole), //
9063 B(Star), R(3), // 9063 B(Star), R(3), //
9064 B(CreateClosure), U8(0), U8(0), // 9064 B(CreateClosure), U8(0), U8(0), //
9065 B(Star), R(4), // 9065 B(Star), R(4), //
9066 B(LdaSmi8), U8(30), // 9066 B(LdaSmi8), U8(30), //
9067 B(Star), R(5), // 9067 B(Star), R(5), //
9068 B(LdaSmi8), U8(67), // 9068 B(LdaSmi8), U8(67), //
9069 B(Star), R(6), // 9069 B(Star), R(6), //
9070 B(CallRuntime), U16(Runtime::kDefineClass), R(3), U8(4), // 9070 B(CallRuntime), U16(Runtime::kDefineClass), R(3), U8(4), //
9071 B(Star), R(3), // 9071 B(Star), R(3), //
9072 B(LoadIC), R(3), U8(1), U8(1), // 9072 B(LoadIC), R(3), U8(1), U8(1), //
9073 B(Star), R(4), // 9073 B(Star), R(4), //
9074 B(CallRuntime), U16(Runtime::kFinalizeClassDefinition), R(3), U8(2), // 9074 B(CallRuntime), U16(Runtime::kFinalizeClassDefinition), R(3), U8(2), //
9075 B(Star), R(0), // 9075 B(Star), R(0), //
9076 B(Star), R(1), // 9076 B(Star), R(1), //
9077 B(JumpIfNotHole), U8(11), // 9077 B(JumpIfNotHole), U8(11), //
9078 B(LdaConstant), U8(2), // 9078 B(LdaConstant), U8(2), //
9079 B(Star), R(4), // 9079 B(Star), R(4), //
9080 B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1), // 9080 B(CallRuntime), U16(Runtime::kThrowReferenceError), R(4), U8(1), //
9081 B(Star), R(3), // 9081 B(Star), R(3), //
9082 B(New), R(3), R(0), U8(0), // 9082 B(New), R(3), R(0), U8(0), //
9083 B(Return), // 9083 B(Return), //
9084 }, 9084 },
9085 3, 9085 3,
9086 { InstanceType::SHARED_FUNCTION_INFO_TYPE, 9086 { InstanceType::SHARED_FUNCTION_INFO_TYPE,
9087 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE, 9087 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE,
9088 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 9088 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
9089 }; 9089 };
9090 // clang-format on 9090 // clang-format on
9091 9091
9092 for (size_t i = 0; i < arraysize(snippets); i++) { 9092 for (size_t i = 0; i < arraysize(snippets); i++) {
9093 Handle<BytecodeArray> bytecode_array = 9093 Handle<BytecodeArray> bytecode_array =
9094 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 9094 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
9095 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 9095 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
9096 } 9096 }
9097 } 9097 }
9098 9098
9099 TEST(TailCall) {
9100 bool old_tailcall_flag = FLAG_harmony_tailcalls;
9101 FLAG_harmony_tailcalls = true;
9102
9103 InitializedHandleScope handle_scope;
9104 BytecodeGeneratorHelper helper;
9105
9106 int closure = Register::function_closure().index();
9107 int context = Register::current_context().index();
9108 int new_target = Register::new_target().index();
9109
9110 // clang-format off
9111 ExpectedSnippet<const char*> snippets[] = {
9112 {"function g() { throw new Error('foo'); };"
9113 "var eval = g;"
9114 "function f() {"
9115 " 'use strict';"
9116 " return eval('g()');"
9117 "}",
9118 9 * kPointerSize,
9119 1,
9120 63,
9121 {
9122 B(CallRuntime), U16(Runtime::kNewFunctionContext), R(closure), //
9123 U8(1), //
9124 B(PushContext), R(0), //
9125 B(Ldar), THIS(1), //
9126 B(StaContextSlot), R(context), U8(4), //
9127 B(CreateUnmappedArguments), //
9128 B(StaContextSlot), R(context), U8(5), //
9129 B(Ldar), R(new_target), //
9130 B(StaContextSlot), R(context), U8(6), //
9131 B(StackCheck), //
9132 B(LdaUndefined), //
9133 B(Star), R(2), //
9134 B(LdaGlobal), U8(0), U8(1), //
9135 B(Star), R(1), //
9136 B(LdaConstant), U8(1), //
9137 B(Star), R(3), //
9138 B(Mov), R(1), R(4), //
9139 B(Mov), R(3), R(5), //
9140 B(Mov), R(closure), R(6), //
9141 B(LdaSmi8), U8(1), //
9142 B(Star), R(7), //
9143 B(LdaSmi8), U8(64), //
9144 B(Star), R(8), //
9145 B(CallRuntime), U16(Runtime::kResolvePossiblyDirectEval), R(4), //
9146 U8(5), //
9147 B(Star), R(1), //
9148 B(TailCall), R(1), R(2), U8(2), //
9149 B(Return), //
9150 },
9151 2,
9152 {"eval",
9153 "g()"}}
9154 };
9155 // clang-format on
9156
9157 for (size_t i = 0; i < arraysize(snippets); i++) {
9158 Handle<BytecodeArray> bytecode_array =
9159 helper.MakeBytecodeForFunction(snippets[i].code_snippet);
9160 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
9161 }
9162
9163 FLAG_harmony_tailcalls = old_tailcall_flag;
9164 }
9165
9166 TEST(TailCallIC) {
9167 bool old_tailcall_flag = FLAG_harmony_tailcalls;
9168 FLAG_harmony_tailcalls = true;
9169
9170 InitializedHandleScope handle_scope;
9171 BytecodeGeneratorHelper helper;
9172
9173 // clang-format off
9174 ExpectedSnippet<const char*> snippets[] = {
9175 {"function g() { return 0; };"
9176 "function f() {"
9177 " 'use strict';"
9178 " return g();"
9179 "}",
9180 2 * kPointerSize,
9181 1,
9182 15,
9183 {
9184 B(StackCheck), //
9185 B(LdaUndefined), //
9186 B(Star), R(1), //
9187 B(LdaGlobal), U8(0), U8(3), //
9188 B(Star), R(0), //
9189 B(TailCallIC), R(0), R(1), U8(1), U8(1), //
9190 B(Return),
9191 },
9192 1,
9193 {"g"}}
9194 };
9195 // clang-format on
9196
9197 for (size_t i = 0; i < arraysize(snippets); i++) {
9198 Handle<BytecodeArray> bytecode_array =
9199 helper.MakeBytecodeForFunction(snippets[i].code_snippet);
9200 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
9201 }
9202
9203 FLAG_harmony_tailcalls = old_tailcall_flag;
9204 }
9205
9206 // TODO(oth): Add tests for super keyword. 9099 // TODO(oth): Add tests for super keyword.
9207 9100
9208 } // namespace interpreter 9101 } // namespace interpreter
9209 } // namespace internal 9102 } // namespace internal
9210 } // namespace v8 9103 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/cctest/interpreter/test-interpreter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698