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

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

Issue 1456453002: [Interpreter] Add support for Call bytecode to bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Compilation fix (signed/unsigned). 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/compiler.h" 10 #include "src/compiler.h"
(...skipping 1192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1203 1203
1204 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()" 1204 #define FUNC_ARG "new (function Obj() { this.func = function() { return; }})()"
1205 1205
1206 1206
1207 TEST(PropertyCall) { 1207 TEST(PropertyCall) {
1208 InitializedHandleScope handle_scope; 1208 InitializedHandleScope handle_scope;
1209 BytecodeGeneratorHelper helper; 1209 BytecodeGeneratorHelper helper;
1210 Zone zone; 1210 Zone zone;
1211 1211
1212 FeedbackVectorSpec feedback_spec(&zone); 1212 FeedbackVectorSpec feedback_spec(&zone);
1213 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); 1213 FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
1214 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 1214 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
1215 USE(slot1); 1215 USE(slot1);
1216 1216
1217 Handle<i::TypeFeedbackVector> vector = 1217 Handle<i::TypeFeedbackVector> vector =
1218 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1218 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1219 1219
1220 // These are a hack used by the CallWide test below.
1221 int wide_idx = vector->GetIndex(slot1) - 2;
1222
1220 ExpectedSnippet<const char*> snippets[] = { 1223 ExpectedSnippet<const char*> snippets[] = {
1221 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")", 1224 {"function f(a) { return a.func(); }\nf(" FUNC_ARG ")",
1222 2 * kPointerSize, 1225 2 * kPointerSize,
1223 2, 1226 2,
1224 15, 1227 16,
1225 { 1228 {
1226 B(Ldar), A(1, 2), // 1229 B(Ldar), A(1, 2), //
1227 B(Star), R(1), // 1230 B(Star), R(1), //
1228 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1231 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1229 B(Star), R(0), // 1232 B(Star), R(0), //
1230 B(Call), R(0), R(1), U8(0), // 1233 B(Call), R(0), R(1), U8(0), U8(vector->GetIndex(slot1)), //
1231 B(Return), // 1234 B(Return), //
1232 }, 1235 },
1233 1, 1236 1,
1234 {"func"}}, 1237 {"func"}},
1235 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)", 1238 {"function f(a, b, c) { return a.func(b, c); }\nf(" FUNC_ARG ", 1, 2)",
1236 4 * kPointerSize, 1239 4 * kPointerSize,
1237 4, 1240 4,
1238 23, 1241 24,
1239 { 1242 {
1240 B(Ldar), A(1, 4), // 1243 B(Ldar), A(1, 4), //
1241 B(Star), R(1), // 1244 B(Star), R(1), //
1242 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1245 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1243 B(Star), R(0), // 1246 B(Star), R(0), //
1244 B(Ldar), A(2, 4), // 1247 B(Ldar), A(2, 4), //
1245 B(Star), R(2), // 1248 B(Star), R(2), //
1246 B(Ldar), A(3, 4), // 1249 B(Ldar), A(3, 4), //
1247 B(Star), R(3), // 1250 B(Star), R(3), //
1248 B(Call), R(0), R(1), U8(2), // 1251 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), //
1249 B(Return) // 1252 B(Return) //
1250 }, 1253 },
1251 1, 1254 1,
1252 {"func"}}, 1255 {"func"}},
1253 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)", 1256 {"function f(a, b) { return a.func(b + b, b); }\nf(" FUNC_ARG ", 1)",
1254 4 * kPointerSize, 1257 4 * kPointerSize,
1255 3, 1258 3,
1256 25, 1259 26,
1257 { 1260 {
1258 B(Ldar), A(1, 3), // 1261 B(Ldar), A(1, 3), //
1259 B(Star), R(1), // 1262 B(Star), R(1), //
1260 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), // 1263 B(LoadICSloppy), R(1), U8(0), U8(vector->GetIndex(slot2)), //
1261 B(Star), R(0), // 1264 B(Star), R(0), //
1262 B(Ldar), A(2, 3), // 1265 B(Ldar), A(2, 3), //
1263 B(Add), A(2, 3), // 1266 B(Add), A(2, 3), //
1264 B(Star), R(2), // 1267 B(Star), R(2), //
1265 B(Ldar), A(2, 3), // 1268 B(Ldar), A(2, 3), //
1266 B(Star), R(3), // 1269 B(Star), R(3), //
1267 B(Call), R(0), R(1), U8(2), // 1270 B(Call), R(0), R(1), U8(2), U8(vector->GetIndex(slot1)), //
1268 B(Return), // 1271 B(Return), //
1269 }, 1272 },
1270 1, 1273 1,
1271 {"func"}}}; 1274 {"func"}},
1275 {"function f(a) {\n"
1276 REPEAT_127(SPACE, " a.func;\n")
1277 " return a.func(); }\nf(" FUNC_ARG ")",
1278 2 * kPointerSize,
1279 2,
1280 528,
1281 {
1282 REPEAT_127(COMMA, //
1283 B(LoadICSloppy), A(1, 2), U8(0), U8((wide_idx += 2))), //
1284 B(Ldar), A(1, 2), //
1285 B(Star), R(1), //
1286 B(LoadICSloppyWide), R(1), U16(0), U16(wide_idx + 4), //
1287 B(Star), R(0), //
1288 B(CallWide), R(0), R(1), U16(0), U16(wide_idx + 2), //
1289 B(Return), //
1290 },
1291 1,
1292 {"func"}},
1293 };
1272 for (size_t i = 0; i < arraysize(snippets); i++) { 1294 for (size_t i = 0; i < arraysize(snippets); i++) {
1273 Handle<BytecodeArray> bytecode_array = 1295 Handle<BytecodeArray> bytecode_array =
1274 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName); 1296 helper.MakeBytecode(snippets[i].code_snippet, helper.kFunctionName);
1275 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1297 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1276 } 1298 }
1277 } 1299 }
1278 1300
1279 1301
1280 TEST(LoadGlobal) { 1302 TEST(LoadGlobal) {
1281 InitializedHandleScope handle_scope; 1303 InitializedHandleScope handle_scope;
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
1478 } 1500 }
1479 } 1501 }
1480 1502
1481 1503
1482 TEST(CallGlobal) { 1504 TEST(CallGlobal) {
1483 InitializedHandleScope handle_scope; 1505 InitializedHandleScope handle_scope;
1484 BytecodeGeneratorHelper helper; 1506 BytecodeGeneratorHelper helper;
1485 Zone zone; 1507 Zone zone;
1486 1508
1487 FeedbackVectorSpec feedback_spec(&zone); 1509 FeedbackVectorSpec feedback_spec(&zone);
1488 FeedbackVectorSlot slot1 = feedback_spec.AddLoadICSlot(); 1510 FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
1489 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 1511 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
1490 USE(slot1); 1512 USE(slot1);
1491 1513
1492 Handle<i::TypeFeedbackVector> vector = 1514 Handle<i::TypeFeedbackVector> vector =
1493 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 1515 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
1494 1516
1495 ExpectedSnippet<const char*> snippets[] = { 1517 ExpectedSnippet<const char*> snippets[] = {
1496 {"function t() { }\nfunction f() { return t(); }\nf()", 1518 {"function t() { }\nfunction f() { return t(); }\nf()",
1497 2 * kPointerSize, 1519 2 * kPointerSize,
1498 1, 1520 1,
1499 13, 1521 14,
1500 { 1522 {
1501 B(LdaUndefined), // 1523 B(LdaUndefined), //
1502 B(Star), R(1), // 1524 B(Star), R(1), //
1503 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // 1525 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
1504 B(Star), R(0), // 1526 B(Star), R(0), //
1505 B(Call), R(0), R(1), U8(0), // 1527 B(Call), R(0), R(1), U8(0), U8(vector->GetIndex(slot1)), //
1506 B(Return) // 1528 B(Return) //
1507 }, 1529 },
1508 1, 1530 1,
1509 {"t"}}, 1531 {"t"}},
1510 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()", 1532 {"function t(a, b, c) { }\nfunction f() { return t(1, 2, 3); }\nf()",
1511 5 * kPointerSize, 1533 5 * kPointerSize,
1512 1, 1534 1,
1513 25, 1535 26,
1514 { 1536 {
1515 B(LdaUndefined), // 1537 B(LdaUndefined), //
1516 B(Star), R(1), // 1538 B(Star), R(1), //
1517 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), // 1539 B(LdaGlobalSloppy), U8(0), U8(vector->GetIndex(slot2)), //
1518 B(Star), R(0), // 1540 B(Star), R(0), //
1519 B(LdaSmi8), U8(1), // 1541 B(LdaSmi8), U8(1), //
1520 B(Star), R(2), // 1542 B(Star), R(2), //
1521 B(LdaSmi8), U8(2), // 1543 B(LdaSmi8), U8(2), //
1522 B(Star), R(3), // 1544 B(Star), R(3), //
1523 B(LdaSmi8), U8(3), // 1545 B(LdaSmi8), U8(3), //
1524 B(Star), R(4), // 1546 B(Star), R(4), //
1525 B(Call), R(0), R(1), U8(3), // 1547 B(Call), R(0), R(1), U8(3), U8(vector->GetIndex(slot1)), //
1526 B(Return) // 1548 B(Return) //
1527 }, 1549 },
1528 1, 1550 1,
1529 {"t"}}, 1551 {"t"}},
1530 }; 1552 };
1531 1553
1532 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); 1554 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1533 for (size_t i = 0; i < num_snippets; i++) { 1555 for (size_t i = 0; i < num_snippets; i++) {
1534 Handle<BytecodeArray> bytecode_array = 1556 Handle<BytecodeArray> bytecode_array =
1535 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1557 helper.MakeBytecode(snippets[i].code_snippet, "f");
1536 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1558 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after
1844 FeedbackVectorSpec feedback_spec_stores(&zone); 1866 FeedbackVectorSpec feedback_spec_stores(&zone);
1845 FeedbackVectorSlot store_slot_1 = feedback_spec_stores.AddStoreICSlot(); 1867 FeedbackVectorSlot store_slot_1 = feedback_spec_stores.AddStoreICSlot();
1846 FeedbackVectorSlot store_slot_2 = feedback_spec_stores.AddStoreICSlot(); 1868 FeedbackVectorSlot store_slot_2 = feedback_spec_stores.AddStoreICSlot();
1847 USE(store_slot_1); 1869 USE(store_slot_1);
1848 1870
1849 Handle<i::TypeFeedbackVector> store_vector = 1871 Handle<i::TypeFeedbackVector> store_vector =
1850 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_stores); 1872 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_stores);
1851 1873
1852 FeedbackVectorSpec feedback_spec_loads(&zone); 1874 FeedbackVectorSpec feedback_spec_loads(&zone);
1853 FeedbackVectorSlot load_slot_1 = feedback_spec_loads.AddLoadICSlot(); 1875 FeedbackVectorSlot load_slot_1 = feedback_spec_loads.AddLoadICSlot();
1876 FeedbackVectorSlot call_slot_1 = feedback_spec_loads.AddCallICSlot();
1854 1877
1855 Handle<i::TypeFeedbackVector> load_vector = 1878 Handle<i::TypeFeedbackVector> load_vector =
1856 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_loads); 1879 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec_loads);
1857 1880
1858 ExpectedSnippet<InstanceType> snippets[] = { 1881 ExpectedSnippet<InstanceType> snippets[] = {
1859 {"var a = 1;", 1882 {"var a = 1;",
1860 4 * kPointerSize, 1883 4 * kPointerSize,
1861 1, 1884 1,
1862 30, 1885 30,
1863 { 1886 {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1916 U8(store_vector->GetIndex(store_slot_2)), // 1939 U8(store_vector->GetIndex(store_slot_2)), //
1917 B(Star), R(0), // 1940 B(Star), R(0), //
1918 B(Return) // 1941 B(Return) //
1919 }, 1942 },
1920 2, 1943 2,
1921 {InstanceType::FIXED_ARRAY_TYPE, 1944 {InstanceType::FIXED_ARRAY_TYPE,
1922 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 1945 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
1923 {"function f() {}\nf();", 1946 {"function f() {}\nf();",
1924 3 * kPointerSize, 1947 3 * kPointerSize,
1925 1, 1948 1,
1926 27, 1949 28,
1927 { 1950 {
1928 B(LdaConstant), U8(0), // 1951 B(LdaConstant), U8(0), //
1929 B(Star), R(1), // 1952 B(Star), R(1), //
1930 B(LdaZero), // 1953 B(LdaZero), //
1931 B(Star), R(2), // 1954 B(Star), R(2), //
1932 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1955 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1933 B(LdaUndefined), // 1956 B(LdaUndefined), //
1934 B(Star), R(2), // 1957 B(Star), R(2), //
1935 B(LdaGlobalSloppy), U8(1), // 1958 B(LdaGlobalSloppy), U8(1), //
1936 U8(load_vector->GetIndex(load_slot_1)), // 1959 U8(load_vector->GetIndex(load_slot_1)), //
1937 B(Star), R(1), // 1960 B(Star), R(1), //
1938 B(Call), R(1), R(2), U8(0), // 1961 B(Call), R(1), R(2), U8(0), //
1939 B(Star), R(0), // 1962 U8(load_vector->GetIndex(call_slot_1)), //
1940 B(Return) // 1963 B(Star), R(0), //
1964 B(Return) //
1941 }, 1965 },
1942 2, 1966 2,
1943 {InstanceType::FIXED_ARRAY_TYPE, 1967 {InstanceType::FIXED_ARRAY_TYPE,
1944 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}}, 1968 InstanceType::ONE_BYTE_INTERNALIZED_STRING_TYPE}},
1945 }; 1969 };
1946 1970
1947 for (size_t i = 0; i < arraysize(snippets); i++) { 1971 for (size_t i = 0; i < arraysize(snippets); i++) {
1948 Handle<BytecodeArray> bytecode_array = 1972 Handle<BytecodeArray> bytecode_array =
1949 helper.MakeTopLevelBytecode(snippets[i].code_snippet); 1973 helper.MakeTopLevelBytecode(snippets[i].code_snippet);
1950 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1974 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
2754 Handle<BytecodeArray> bytecode_array = 2778 Handle<BytecodeArray> bytecode_array =
2755 helper.MakeBytecode(snippets[i].code_snippet, "f"); 2779 helper.MakeBytecode(snippets[i].code_snippet, "f");
2756 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2780 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2757 } 2781 }
2758 } 2782 }
2759 2783
2760 2784
2761 TEST(FunctionLiterals) { 2785 TEST(FunctionLiterals) {
2762 InitializedHandleScope handle_scope; 2786 InitializedHandleScope handle_scope;
2763 BytecodeGeneratorHelper helper; 2787 BytecodeGeneratorHelper helper;
2788 Zone zone;
2789
2790 FeedbackVectorSpec feedback_spec(&zone);
2791 FeedbackVectorSlot slot = feedback_spec.AddCallICSlot();
2792
2793 Handle<i::TypeFeedbackVector> vector =
2794 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2764 2795
2765 ExpectedSnippet<InstanceType> snippets[] = { 2796 ExpectedSnippet<InstanceType> snippets[] = {
2766 {"return function(){ }", 2797 {"return function(){ }",
2767 0, 2798 0,
2768 1, 2799 1,
2769 5, 2800 5,
2770 { 2801 {
2771 B(LdaConstant), U8(0), // 2802 B(LdaConstant), U8(0), //
2772 B(CreateClosure), U8(0), // 2803 B(CreateClosure), U8(0), //
2773 B(Return) // 2804 B(Return) //
2774 }, 2805 },
2775 1, 2806 1,
2776 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2807 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2777 {"return (function(){ })()", 2808 {"return (function(){ })()",
2778 2 * kPointerSize, 2809 2 * kPointerSize,
2779 1, 2810 1,
2780 14, 2811 15,
2781 { 2812 {
2782 B(LdaUndefined), // 2813 B(LdaUndefined), //
2783 B(Star), R(1), // 2814 B(Star), R(1), //
2784 B(LdaConstant), U8(0), // 2815 B(LdaConstant), U8(0), //
2785 B(CreateClosure), U8(0), // 2816 B(CreateClosure), U8(0), //
2786 B(Star), R(0), // 2817 B(Star), R(0), //
2787 B(Call), R(0), R(1), U8(0), // 2818 B(Call), R(0), R(1), U8(0), U8(vector->GetIndex(slot)), //
2788 B(Return) // 2819 B(Return) //
2789 }, 2820 },
2790 1, 2821 1,
2791 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2822 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2792 {"return (function(x){ return x; })(1)", 2823 {"return (function(x){ return x; })(1)",
2793 3 * kPointerSize, 2824 3 * kPointerSize,
2794 1, 2825 1,
2795 18, 2826 19,
2796 { 2827 {
2797 B(LdaUndefined), // 2828 B(LdaUndefined), //
2798 B(Star), R(1), // 2829 B(Star), R(1), //
2799 B(LdaConstant), U8(0), // 2830 B(LdaConstant), U8(0), //
2800 B(CreateClosure), U8(0), // 2831 B(CreateClosure), U8(0), //
2801 B(Star), R(0), // 2832 B(Star), R(0), //
2802 B(LdaSmi8), U8(1), // 2833 B(LdaSmi8), U8(1), //
2803 B(Star), R(2), // 2834 B(Star), R(2), //
2804 B(Call), R(0), R(1), U8(1), // 2835 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot)), //
2805 B(Return) // 2836 B(Return) //
2806 }, 2837 },
2807 1, 2838 1,
2808 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 2839 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
2809 }; 2840 };
2810 2841
2811 for (size_t i = 0; i < arraysize(snippets); i++) { 2842 for (size_t i = 0; i < arraysize(snippets); i++) {
2812 Handle<BytecodeArray> bytecode_array = 2843 Handle<BytecodeArray> bytecode_array =
2813 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2844 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2814 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2845 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
2815 } 2846 }
2816 } 2847 }
2817 2848
2818 2849
2819 TEST(RegExpLiterals) { 2850 TEST(RegExpLiterals) {
2820 InitializedHandleScope handle_scope; 2851 InitializedHandleScope handle_scope;
2821 BytecodeGeneratorHelper helper; 2852 BytecodeGeneratorHelper helper;
2822 Zone zone; 2853 Zone zone;
2823 2854
2824 FeedbackVectorSpec feedback_spec(&zone); 2855 FeedbackVectorSpec feedback_spec(&zone);
2825 feedback_spec.AddLoadICSlot(); 2856 FeedbackVectorSlot slot1 = feedback_spec.AddCallICSlot();
2826 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot(); 2857 FeedbackVectorSlot slot2 = feedback_spec.AddLoadICSlot();
2827 2858
2828 Handle<i::TypeFeedbackVector> vector = 2859 Handle<i::TypeFeedbackVector> vector =
2829 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec); 2860 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
2830 2861
2831 ExpectedSnippet<const char*> snippets[] = { 2862 ExpectedSnippet<const char*> snippets[] = {
2832 {"return /ab+d/;", 2863 {"return /ab+d/;",
2833 1 * kPointerSize, 2864 1 * kPointerSize,
2834 1, 2865 1,
2835 10, 2866 10,
(...skipping 15 matching lines...) Expand all
2851 B(Star), R(0), // 2882 B(Star), R(0), //
2852 B(LdaConstant), U8(1), // 2883 B(LdaConstant), U8(1), //
2853 B(CreateRegExpLiteral), U8(0), R(0), // 2884 B(CreateRegExpLiteral), U8(0), R(0), //
2854 B(Return), // 2885 B(Return), //
2855 }, 2886 },
2856 2, 2887 2,
2857 {"i", "(\\w+)\\s(\\w+)"}}, 2888 {"i", "(\\w+)\\s(\\w+)"}},
2858 {"return /ab+d/.exec('abdd');", 2889 {"return /ab+d/.exec('abdd');",
2859 3 * kPointerSize, 2890 3 * kPointerSize,
2860 1, 2891 1,
2861 26, 2892 27,
2862 { 2893 {
2863 B(LdaConstant), U8(0), // 2894 B(LdaConstant), U8(0), //
2864 B(Star), R(2), // 2895 B(Star), R(2), //
2865 B(LdaConstant), U8(1), // 2896 B(LdaConstant), U8(1), //
2866 B(CreateRegExpLiteral), U8(0), R(2), // 2897 B(CreateRegExpLiteral), U8(0), R(2), //
2867 B(Star), R(1), // 2898 B(Star), R(1), //
2868 B(LoadICSloppy), R(1), U8(2), U8(vector->GetIndex(slot2)), // 2899 B(LoadICSloppy), R(1), U8(2), U8(vector->GetIndex(slot2)), //
2869 B(Star), R(0), // 2900 B(Star), R(0), //
2870 B(LdaConstant), U8(3), // 2901 B(LdaConstant), U8(3), //
2871 B(Star), R(2), // 2902 B(Star), R(2), //
2872 B(Call), R(0), R(1), U8(1), // 2903 B(Call), R(0), R(1), U8(1), U8(vector->GetIndex(slot1)), //
2873 B(Return), // 2904 B(Return), //
2874 }, 2905 },
2875 4, 2906 4,
2876 {"", "ab+d", "exec", "abdd"}}, 2907 {"", "ab+d", "exec", "abdd"}},
2877 }; 2908 };
2878 2909
2879 for (size_t i = 0; i < arraysize(snippets); i++) { 2910 for (size_t i = 0; i < arraysize(snippets); i++) {
2880 Handle<BytecodeArray> bytecode_array = 2911 Handle<BytecodeArray> bytecode_array =
2881 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 2912 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
2882 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 2913 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
(...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 Handle<BytecodeArray> bytecode_array = 3644 Handle<BytecodeArray> bytecode_array =
3614 helper.MakeBytecode(snippets[i].code_snippet, "f"); 3645 helper.MakeBytecode(snippets[i].code_snippet, "f");
3615 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 3646 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
3616 } 3647 }
3617 } 3648 }
3618 3649
3619 3650
3620 TEST(ContextVariables) { 3651 TEST(ContextVariables) {
3621 InitializedHandleScope handle_scope; 3652 InitializedHandleScope handle_scope;
3622 BytecodeGeneratorHelper helper; 3653 BytecodeGeneratorHelper helper;
3654 Zone zone;
3655
3656 FeedbackVectorSpec feedback_spec(&zone);
3657 FeedbackVectorSlot slot = feedback_spec.AddCallICSlot();
3658
3659 Handle<i::TypeFeedbackVector> vector =
3660 i::NewTypeFeedbackVector(helper.isolate(), &feedback_spec);
3623 3661
3624 int closure = Register::function_closure().index(); 3662 int closure = Register::function_closure().index();
3625 int first_context_slot = Context::MIN_CONTEXT_SLOTS; 3663 int first_context_slot = Context::MIN_CONTEXT_SLOTS;
3626 ExpectedSnippet<InstanceType> snippets[] = { 3664 ExpectedSnippet<InstanceType> snippets[] = {
3627 {"var a; return function() { a = 1; };", 3665 {"var a; return function() { a = 1; };",
3628 1 * kPointerSize, 3666 1 * kPointerSize,
3629 1, 3667 1,
3630 12, 3668 12,
3631 { 3669 {
3632 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 3670 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
3668 B(StaContextSlot), R(0), U8(first_context_slot + 1), // 3706 B(StaContextSlot), R(0), U8(first_context_slot + 1), //
3669 B(LdaConstant), U8(0), // 3707 B(LdaConstant), U8(0), //
3670 B(CreateClosure), U8(0), // 3708 B(CreateClosure), U8(0), //
3671 B(Return), // 3709 B(Return), //
3672 }, 3710 },
3673 1, 3711 1,
3674 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3712 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3675 {"var a; (function() { a = 2; })(); return a;", 3713 {"var a; (function() { a = 2; })(); return a;",
3676 3 * kPointerSize, 3714 3 * kPointerSize,
3677 1, 3715 1,
3678 24, 3716 25,
3679 { 3717 {
3680 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 3718 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
3681 R(closure), U8(1), // 3719 R(closure), U8(1), //
3682 B(PushContext), R(0), // 3720 B(PushContext), R(0), //
3683 B(LdaUndefined), // 3721 B(LdaUndefined), //
3684 B(Star), R(2), // 3722 B(Star), R(2), //
3685 B(LdaConstant), U8(0), // 3723 B(LdaConstant), U8(0), //
3686 B(CreateClosure), U8(0), // 3724 B(CreateClosure), U8(0), //
3687 B(Star), R(1), // 3725 B(Star), R(1), //
3688 B(Call), R(1), R(2), U8(0), // 3726 B(Call), R(1), R(2), U8(0), U8(vector->GetIndex(slot)), //
3689 B(LdaContextSlot), R(0), U8(first_context_slot), // 3727 B(LdaContextSlot), R(0), U8(first_context_slot), //
3690 B(Return), // 3728 B(Return), //
3691 }, 3729 },
3692 1, 3730 1,
3693 {InstanceType::SHARED_FUNCTION_INFO_TYPE}}, 3731 {InstanceType::SHARED_FUNCTION_INFO_TYPE}},
3694 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }", 3732 {"'use strict'; let a = 1; { let b = 2; return function() { a + b; }; }",
3695 4 * kPointerSize, 3733 4 * kPointerSize,
3696 1, 3734 1,
3697 45, 3735 45,
3698 { 3736 {
3699 B(CallRuntime), U16(Runtime::kNewFunctionContext), // 3737 B(CallRuntime), U16(Runtime::kNewFunctionContext), //
3700 R(closure), U8(1), // 3738 R(closure), U8(1), //
(...skipping 1523 matching lines...) Expand 10 before | Expand all | Expand 10 after
5224 for (size_t i = 0; i < arraysize(snippets); i++) { 5262 for (size_t i = 0; i < arraysize(snippets); i++) {
5225 Handle<BytecodeArray> bytecode_array = 5263 Handle<BytecodeArray> bytecode_array =
5226 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 5264 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
5227 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 5265 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
5228 } 5266 }
5229 } 5267 }
5230 5268
5231 } // namespace interpreter 5269 } // namespace interpreter
5232 } // namespace internal 5270 } // namespace internal
5233 } // namespace v8 5271 } // 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