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

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 ia32 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 941 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 B(LdaConstant), U8(0), // 952 B(LdaConstant), U8(0), //
953 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), // 953 B(LoadICSloppy), R(0), U8(vector->GetIndex(slot1)), //
954 B(Return)}, 954 B(Return)},
955 1, 955 1,
956 {"t"}}, 956 {"t"}},
957 }; 957 };
958 958
959 for (size_t i = 0; i < arraysize(snippets); i++) { 959 for (size_t i = 0; i < arraysize(snippets); i++) {
960 Handle<BytecodeArray> bytecode_array = 960 Handle<BytecodeArray> bytecode_array =
961 helper.MakeBytecode(snippets[i].code_snippet, "f"); 961 helper.MakeBytecode(snippets[i].code_snippet, "f");
962 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 962 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
963 } 963 }
964 } 964 }
965 965
966 966
967 TEST(StoreUnallocated) { 967 TEST(StoreUnallocated) {
968 InitializedHandleScope handle_scope; 968 InitializedHandleScope handle_scope;
969 BytecodeGeneratorHelper helper; 969 BytecodeGeneratorHelper helper;
970 Zone zone; 970 Zone zone;
971 971
972 int context_reg = Register::function_context().index(); 972 int context_reg = Register::function_context().index();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1009 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), // 1009 B(StoreICSloppy), R(1), R(2), U8(vector->GetIndex(slot1)), //
1010 B(LdaUndefined), // 1010 B(LdaUndefined), //
1011 B(Return)}, 1011 B(Return)},
1012 1, 1012 1,
1013 {"t"}}, 1013 {"t"}},
1014 }; 1014 };
1015 1015
1016 for (size_t i = 0; i < arraysize(snippets); i++) { 1016 for (size_t i = 0; i < arraysize(snippets); i++) {
1017 Handle<BytecodeArray> bytecode_array = 1017 Handle<BytecodeArray> bytecode_array =
1018 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1018 helper.MakeBytecode(snippets[i].code_snippet, "f");
1019 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1019 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1020 } 1020 }
1021 } 1021 }
1022 1022
1023 1023
1024 TEST(CallRuntime) { 1024 TEST(CallRuntime) {
1025 InitializedHandleScope handle_scope; 1025 InitializedHandleScope handle_scope;
1026 BytecodeGeneratorHelper helper; 1026 BytecodeGeneratorHelper helper;
1027 1027
1028 ExpectedSnippet<int> snippets[] = { 1028 ExpectedSnippet<int> snippets[] = {
1029 { 1029 {
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 B(Star), R(1), // 1061 B(Star), R(1), //
1062 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), // 1062 B(CallRuntime), U16(Runtime::kAdd), R(0), U8(2), //
1063 B(Return) // 1063 B(Return) //
1064 }, 1064 },
1065 }, 1065 },
1066 }; 1066 };
1067 1067
1068 for (size_t i = 0; i < arraysize(snippets); i++) { 1068 for (size_t i = 0; i < arraysize(snippets); i++) {
1069 Handle<BytecodeArray> bytecode_array = 1069 Handle<BytecodeArray> bytecode_array =
1070 helper.MakeBytecode(snippets[i].code_snippet, "f"); 1070 helper.MakeBytecode(snippets[i].code_snippet, "f");
1071 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1071 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1072 } 1072 }
1073 } 1073 }
1074 1074
1075 1075
1076 TEST(IfConditions) { 1076 TEST(IfConditions) {
1077 InitializedHandleScope handle_scope; 1077 InitializedHandleScope handle_scope;
1078 BytecodeGeneratorHelper helper; 1078 BytecodeGeneratorHelper helper;
1079 1079
1080 Handle<Object> unused = helper.factory()->undefined_value(); 1080 Handle<Object> unused = helper.factory()->undefined_value();
1081 1081
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
1243 } 1243 }
1244 } 1244 }
1245 1245
1246 1246
1247 TEST(DeclareGlobals) { 1247 TEST(DeclareGlobals) {
1248 InitializedHandleScope handle_scope; 1248 InitializedHandleScope handle_scope;
1249 BytecodeGeneratorHelper helper; 1249 BytecodeGeneratorHelper helper;
1250 1250
1251 ExpectedSnippet<int> snippets[] = { 1251 ExpectedSnippet<int> snippets[] = {
1252 {"var a = 1;", 1252 {"var a = 1;",
1253 4 * kPointerSize, 1253 5 * kPointerSize,
1254 1, 1254 1,
1255 30, 1255 45,
1256 { 1256 {
1257 B(LdaConstant), U8(0), // 1257 B(Ldar), R(Register::function_closure().index()), //
1258 B(Star), R(1), // 1258 B(Star), R(2), //
1259 B(LdaZero), // 1259 B(LdaConstant), U8(0), //
1260 B(Star), R(2), // 1260 B(Star), R(3), //
1261 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), // 1261 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1262 B(LdaConstant), U8(1), // 1262 B(PushContext), R(1), //
1263 B(Star), R(1), // 1263 B(LdaConstant), U8(1), //
1264 B(LdaZero), // 1264 B(Star), R(2), //
1265 B(Star), R(2), // 1265 B(LdaZero), //
1266 B(LdaSmi8), U8(1), // 1266 B(Star), R(3), //
1267 B(Star), R(3), // 1267 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1268 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(1), // 1268 B(LdaConstant), U8(2), //
1269 U8(3), // 1269 B(Star), R(2), //
1270 B(LdaUndefined), // 1270 B(LdaZero), //
1271 B(Return) // 1271 B(Star), R(3), //
1272 B(LdaSmi8), U8(1), //
1273 B(Star), R(4), //
1274 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
1275 U8(3), //
1276 B(LdaUndefined), //
1277 B(Return) //
1272 }, 1278 },
1273 -1}, 1279 -1},
1274 {"function f() {}", 1280 {"function f() {}",
1275 2 * kPointerSize, 1281 3 * kPointerSize,
1276 1, 1282 1,
1277 14, 1283 29,
1278 { 1284 {
1279 B(LdaConstant), U8(0), // 1285 B(Ldar), R(Register::function_closure().index()), //
1280 B(Star), R(0), // 1286 B(Star), R(1), //
1281 B(LdaZero), // 1287 B(LdaConstant), U8(0), //
1282 B(Star), R(1), // 1288 B(Star), R(2), //
1283 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(0), U8(2), // 1289 B(CallRuntime), U16(Runtime::kNewScriptContext), R(1), U8(2), //
1284 B(LdaUndefined), // 1290 B(PushContext), R(0), //
1285 B(Return) // 1291 B(LdaConstant), U8(1), //
1292 B(Star), R(1), //
1293 B(LdaZero), //
1294 B(Star), R(2), //
1295 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(1), U8(2), //
1296 B(LdaUndefined), //
1297 B(Return) //
1298 },
1299 -1},
1300 {"var a = 1;\na=2;",
1301 5 * kPointerSize,
1302 1,
1303 52,
1304 {
1305 B(Ldar), R(Register::function_closure().index()), //
1306 B(Star), R(2), //
1307 B(LdaConstant), U8(0), //
1308 B(Star), R(3), //
1309 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1310 B(PushContext), R(1), //
1311 B(LdaConstant), U8(1), //
1312 B(Star), R(2), //
1313 B(LdaZero), //
1314 B(Star), R(3), //
1315 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1316 B(LdaConstant), U8(2), //
1317 B(Star), R(2), //
1318 B(LdaZero), //
1319 B(Star), R(3), //
1320 B(LdaSmi8), U8(1), //
1321 B(Star), R(4), //
1322 B(CallRuntime), U16(Runtime::kInitializeVarGlobal), R(2), //
1323 U8(3), //
1324 B(LdaSmi8), U8(2), //
1325 B(StaGlobal), _, //
1326 B(Star), R(0), //
1327 B(Ldar), R(0), //
1328 B(Return) //
1329 },
1330 -1},
1331 {"function f() {}\nf();",
1332 4 * kPointerSize,
1333 1,
1334 43,
1335 {
1336 B(Ldar), R(Register::function_closure().index()), //
1337 B(Star), R(2), //
1338 B(LdaConstant), U8(0), //
1339 B(Star), R(3), //
1340 B(CallRuntime), U16(Runtime::kNewScriptContext), R(2), U8(2), //
1341 B(PushContext), R(1), //
1342 B(LdaConstant), U8(1), //
1343 B(Star), R(2), //
1344 B(LdaZero), //
1345 B(Star), R(3), //
1346 B(CallRuntime), U16(Runtime::kDeclareGlobals), R(2), U8(2), //
1347 B(LdaUndefined), //
1348 B(Star), R(3), //
1349 B(LdaGlobal), _, //
1350 B(Star), R(2), //
1351 B(Call), R(2), R(3), U8(0), //
1352 B(Star), R(0), //
1353 B(Ldar), R(0), //
1354 B(Return) //
1286 }, 1355 },
1287 -1}, 1356 -1},
1288 }; 1357 };
1289 1358
1290 for (size_t i = 0; i < arraysize(snippets); i++) { 1359 for (size_t i = 0; i < arraysize(snippets); i++) {
1291 Handle<BytecodeArray> bytecode_array = 1360 Handle<BytecodeArray> bytecode_array =
1292 helper.MakeTopLevelBytecode(snippets[i].code_snippet); 1361 helper.MakeTopLevelBytecode(snippets[i].code_snippet);
1293 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true); 1362 CheckBytecodeArrayEqual(snippets[i], bytecode_array, true);
1294 } 1363 }
1295 } 1364 }
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after
1671 Handle<BytecodeArray> bytecode_array = 1740 Handle<BytecodeArray> bytecode_array =
1672 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet); 1741 helper.MakeBytecodeForFunctionBody(snippets[i].code_snippet);
1673 CheckBytecodeArrayEqual(snippets[i], bytecode_array); 1742 CheckBytecodeArrayEqual(snippets[i], bytecode_array);
1674 } 1743 }
1675 } 1744 }
1676 1745
1677 1746
1678 } // namespace interpreter 1747 } // namespace interpreter
1679 } // namespace internal 1748 } // namespace internal
1680 } // namespace v8 1749 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698