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

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

Issue 1379793004: [Interpreter] Add support for new local function context creation. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@int_decl
Patch Set: Fix interpreter-assembler-unittest Created 5 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
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 1084 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 B(LdaConstant), U8(0), // 1095 B(LdaConstant), U8(0), //
1096 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 1096 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
1097 B(Return)}, 1097 B(Return)},
1098 1, 1098 1,
1099 {"t"}}, 1099 {"t"}},
1100 }; 1100 };
1101 1101
1102 for (size_t i = 0; i < arraysize(snippets); i++) { 1102 for (size_t i = 0; i < arraysize(snippets); i++) {
1103 Handle<BytecodeArray> bytecode_array = 1103 Handle<BytecodeArray> bytecode_array =
1104 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1104 helper.MakeBytecode(snippets[i].code_snippet, "f");
1105 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1105 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1106 } 1106 }
1107 } 1107 }
1108 1108
1109 1109
1110 TEST(StoreUnallocated) { 1110 TEST(StoreUnallocated) {
1111 InitializedHandleScope handle_scope; 1111 InitializedHandleScope handle_scope;
1112 BytecodeGeneratorHelper helper; 1112 BytecodeGeneratorHelper helper;
1113 Zone zone; 1113 Zone zone;
1114 1114
1115 int context_reg = Register::function_context().index(); 1115 int context_reg = Register::function_context().index();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // 1152 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
1153 B(LdaUndefined), // 1153 B(LdaUndefined), //
1154 B(Return)}, 1154 B(Return)},
1155 1, 1155 1,
1156 {"t"}}, 1156 {"t"}},
1157 }; 1157 };
1158 1158
1159 for (size_t i = 0; i < arraysize(snippets); i++) { 1159 for (size_t i = 0; i < arraysize(snippets); i++) {
1160 Handle<BytecodeArray> bytecode_array = 1160 Handle<BytecodeArray> bytecode_array =
1161 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1161 helper.MakeBytecode(snippets[i].code_snippet, "f");
1162 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1162 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1163 } 1163 }
1164 } 1164 }
1165 1165
1166 1166
1167 TEST(CallRuntime) { 1167 TEST(CallRuntime) {
1168 InitializedHandleScope handle_scope; 1168 InitializedHandleScope handle_scope;
1169 BytecodeGeneratorHelper helper; 1169 BytecodeGeneratorHelper helper;
1170 1170
1171 ExpectedSnippet<int> snippets[] = { 1171 ExpectedSnippet<int> snippets[] = {
1172 { 1172 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 B(Star), R(1), // 1204 B(Star), R(1), //
1205 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), // 1205 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), //
1206 B(Return) // 1206 B(Return) //
1207 }, 1207 },
1208 }, 1208 },
1209 }; 1209 };
1210 1210
1211 for (size_t i = 0; i < arraysize(snippets); i++) { 1211 for (size_t i = 0; i < arraysize(snippets); i++) {
1212 Handle<BytecodeArray> bytecode_array = 1212 Handle<BytecodeArray> bytecode_array =
1213 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1213 helper.MakeBytecode(snippets[i].code_snippet, "f");
1214 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1214 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1215 } 1215 }
1216 } 1216 }
1217 1217
1218 1218
1219 TEST(IfConditions) { 1219 TEST(IfConditions) {
1220 InitializedHandleScope handle_scope; 1220 InitializedHandleScope handle_scope;
1221 BytecodeGeneratorHelper helper; 1221 BytecodeGeneratorHelper helper;
1222 1222
1223 Handle<Object> unused = helper.factory()->undefined_value(); 1223 Handle<Object> unused = helper.factory()->undefined_value();
1224 1224
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1386 } 1386 }
1387 } 1387 }
1388 1388
1389 1389
1390 TEST(DeclareGlobals) { 1390 TEST(DeclareGlobals) {
1391 InitializedHandleScope handle_scope; 1391 InitializedHandleScope handle_scope;
1392 BytecodeGeneratorHelper helper; 1392 BytecodeGeneratorHelper helper;
1393 1393
1394 ExpectedSnippet<int> snippets[] = { 1394 ExpectedSnippet<int> snippets[] = {
1395 {"var a = 1;", 1395 {"var a = 1;",
1396 4 * kPointerSize, 1396 5 * kPointerSize,
1397 1, 1397 1,
1398 30, 1398 45,
1399 { 1399 {
1400 B(LdaConstant), U8(0), // 1400 B(Ldar), R(Register::function_closure().index()), //
1401 B(Star), R(1), // 1401 B(Star), R(2), //
1402 B(LdaZero), // 1402 B(LdaConstant), U8(0), //
1403 B(Star), R(2), // 1403 B(Star), R(3), //
1404 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1404 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1405 B(LdaConstant), U8(1), // 1405 B(PushContext), R(1), //
1406 B(Star), R(1), // 1406 B(LdaConstant), U8(1), //
1407 B(LdaZero), // 1407 B(Star), R(2), //
1408 B(Star), R(2), // 1408 B(LdaZero), //
1409 B(LdaSmi8), U8(1), // 1409 B(Star), R(3), //
1410 B(Star), R(3), // 1410 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1411 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // 1411 B(LdaConstant), U8(2), //
1412 U8(3), // 1412 B(Star), R(2), //
1413 B(LdaUndefined), // 1413 B(LdaZero), //
1414 B(Return) // 1414 B(Star), R(3), //
1415 B(LdaSmi8), U8(1), //
1416 B(Star), R(4), //
1417 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
1418 U8(3), //
1419 B(LdaUndefined), //
1420 B(Return) //
1415 }, 1421 },
1416 -1}, 1422 -1},
1417 {"function f() {}", 1423 {"function f() {}",
1418 2 * kPointerSize, 1424 3 * kPointerSize,
1419 1, 1425 1,
1420 14, 1426 29,
1421 { 1427 {
1422 B(LdaConstant), U8(0), // 1428 B(Ldar), R(Register::function_closure().index()), //
1423 B(Star), R(0), // 1429 B(Star), R(1), //
1424 B(LdaZero), // 1430 B(LdaConstant), U8(0), //
1425 B(Star), R(1), // 1431 B(Star), R(2), //
1426 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // 1432 B(CallRuntime), U16(Runtime::kNewScriptContext), R(1), U8(2), //
1427 B(LdaUndefined), // 1433 B(PushContext), R(0), //
1428 B(Return) // 1434 B(LdaConstant), U8(1), //
1435 B(Star), R(1), //
1436 B(LdaZero), //
1437 B(Star), R(2), //
1438 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1439 B(LdaUndefined), //
1440 B(Return) //
1441 },
1442 -1},
1443 {"var a = 1;\na=2;",
1444 5 * kPointerSize,
1445 1,
1446 52,
1447 {
1448 B(Ldar), R(Register::function_closure().index()), //
1449 B(Star), R(2), //
1450 B(LdaConstant), U8(0), //
1451 B(Star), R(3), //
1452 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1453 B(PushContext), R(1), //
1454 B(LdaConstant), U8(1), //
1455 B(Star), R(2), //
1456 B(LdaZero), //
1457 B(Star), R(3), //
1458 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1459 B(LdaConstant), U8(2), //
1460 B(Star), R(2), //
1461 B(LdaZero), //
1462 B(Star), R(3), //
1463 B(LdaSmi8), U8(1), //
1464 B(Star), R(4), //
1465 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
1466 U8(3), //
1467 B(LdaSmi8), U8(2), //
1468 B(StaGlobal), _, //
1469 B(Star), R(0), //
1470 B(Ldar), R(0), //
1471 B(Return) //
1472 },
1473 -1},
1474 {"function f() {}\nf();",
1475 4 * kPointerSize,
1476 1,
1477 43,
1478 {
1479 B(Ldar), R(Register::function_closure().index()), //
1480 B(Star), R(2), //
1481 B(LdaConstant), U8(0), //
1482 B(Star), R(3), //
1483 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1484 B(PushContext), R(1), //
1485 B(LdaConstant), U8(1), //
1486 B(Star), R(2), //
1487 B(LdaZero), //
1488 B(Star), R(3), //
1489 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1490 B(LdaUndefined), //
1491 B(Star), R(3), //
1492 B(LdaGlobal), _, //
1493 B(Star), R(2), //
1494 B(Call), R(2), R(3), U8(0), //
1495 B(Star), R(0), //
1496 B(Ldar), R(0), //
1497 B(Return) //
1429 }, 1498 },
1430 -1}, 1499 -1},
1431 }; 1500 };
1432 1501
1433 for (size_t i = 0; i < arraysize(snippets); i++) { 1502 for (size_t i = 0; i < arraysize(snippets); i++) {
1434 Handle<BytecodeArray> bytecode_array = 1503 Handle<BytecodeArray> bytecode_array =
1435 helper.MakeTopLevelBytecode(snippets[i].code_snippet); 1504 helper.MakeTopLevelBytecode(snippets[i].code_snippet);
1436 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1505 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1437 } 1506 }
1438 } 1507 }
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
1871 for (size_t i = 0; i < arraysize(snippets); i++) { 1940 for (size_t i = 0; i < arraysize(snippets); i++) {
1872 Handle<BytecodeArray> bytecode_array = 1941 Handle<BytecodeArray> bytecode_array =
1873 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1942 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
1874 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1943 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1875 } 1944 }
1876 } 1945 }
1877 1946
1878 } // namespace interpreter 1947 } // namespace interpreter
1879 } // namespace internal 1948 } // namespace internal
1880 } // namespace v8 1949 } // namespace v8
OLDNEW
« no previous file with comments | « src/x87/macro-assembler-x87.h ('k') | test/unittests/interpreter/bytecode-array-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698