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

Side by Side Diff: test/cctest/compiler/test-run-bytecode-graph-builder.cc

Issue 1503963002: [Interpreter] Adds wide variant of CreateLiterals. Adds CreateLiterals to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: renamed BuildLiteral to BuildCreateLiteral. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // TODO(jochen): Remove this after the setting is turned on globally. 5 // TODO(jochen): Remove this after the setting is turned on globally.
6 #define V8_IMMINENT_DEPRECATION_WARNINGS 6 #define V8_IMMINENT_DEPRECATION_WARNINGS
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "src/compiler/pipeline.h" 10 #include "src/compiler/pipeline.h"
(...skipping 1168 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 SNPrintF(script, "%s", snippets[i].code_snippet); 1179 SNPrintF(script, "%s", snippets[i].code_snippet);
1180 1180
1181 BytecodeGraphTester tester(isolate, zone, script.start(), "*"); 1181 BytecodeGraphTester tester(isolate, zone, script.start(), "*");
1182 auto callable = tester.GetCallable<Handle<Object>>("f"); 1182 auto callable = tester.GetCallable<Handle<Object>>("f");
1183 Handle<Object> return_value = 1183 Handle<Object> return_value =
1184 callable(snippets[i].parameter(0)).ToHandleChecked(); 1184 callable(snippets[i].parameter(0)).ToHandleChecked();
1185 CHECK(return_value->SameValue(*snippets[i].return_value())); 1185 CHECK(return_value->SameValue(*snippets[i].return_value()));
1186 } 1186 }
1187 } 1187 }
1188 1188
1189
1190 TEST(BytecodeGraphBuilderRegExpLiterals) {
1191 HandleAndZoneScope scope;
1192 Isolate* isolate = scope.main_isolate();
1193 Zone* zone = scope.main_zone();
1194 Factory* factory = isolate->factory();
1195
1196 ExpectedSnippet<0> snippets[] = {
1197 {"return /abd/.exec('cccabbdd');", {factory->null_value()}},
1198 {"return /ab+d/.exec('cccabbdd')[0];",
1199 {factory->NewStringFromStaticChars("abbd")}},
1200 {"var a = 3.1414;"
1201 REPEAT_256(SPACE, "a = 3.1414;")
1202 "return /ab+d/.exec('cccabbdd')[0];",
1203 {factory->NewStringFromStaticChars("abbd")}},
1204 {"return /ab+d/.exec('cccabbdd')[1];", {factory->undefined_value()}},
1205 {"return /AbC/i.exec('ssaBC')[0];",
1206 {factory->NewStringFromStaticChars("aBC")}},
1207 {"return 'ssaBC'.match(/AbC/i)[0];",
1208 {factory->NewStringFromStaticChars("aBC")}},
1209 {"return 'ssaBCtAbC'.match(/(AbC)/gi)[1];",
1210 {factory->NewStringFromStaticChars("AbC")}},
1211 };
1212
1213 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1214 for (size_t i = 0; i < num_snippets; i++) {
1215 ScopedVector<char> script(4096);
1216 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1217 snippets[i].code_snippet, kFunctionName);
1218
1219 BytecodeGraphTester tester(isolate, zone, script.start());
1220 auto callable = tester.GetCallable<>();
1221 Handle<Object> return_value = callable().ToHandleChecked();
1222 CHECK(return_value->SameValue(*snippets[i].return_value()));
1223 }
1224 }
1225
1226
1227 TEST(BytecodeGraphBuilderArrayLiterals) {
1228 HandleAndZoneScope scope;
1229 Isolate* isolate = scope.main_isolate();
1230 Zone* zone = scope.main_zone();
1231 Factory* factory = isolate->factory();
1232
1233 ExpectedSnippet<0> snippets[] = {
1234 {"return [][0];", {factory->undefined_value()}},
1235 {"return [1, 3, 2][1];", {factory->NewNumberFromInt(3)}},
1236 {"var a;" REPEAT_256(SPACE, "a = 9.87;") "return [1, 3, 2][1];",
1237 {factory->NewNumberFromInt(3)}},
1238 {"return ['a', 'b', 'c'][2];", {factory->NewStringFromStaticChars("c")}},
1239 {"var a = 100; return [a, a++, a + 2, a + 3][2];",
1240 {factory->NewNumberFromInt(103)}},
1241 {"var a = 100; return [a, ++a, a + 2, a + 3][1];",
1242 {factory->NewNumberFromInt(101)}},
1243 {"var a = 9.2;"
1244 REPEAT_256(SPACE, "a = 9.34;")
1245 "return [a, ++a, a + 2, a + 3][2];",
1246 {factory->NewHeapNumber(12.34)}},
1247 {"return [[1, 2, 3], ['a', 'b', 'c']][1][0];",
1248 {factory->NewStringFromStaticChars("a")}},
1249 {"var t = 't'; return [[t, t + 'est'], [1 + t]][0][1];",
1250 {factory->NewStringFromStaticChars("test")}},
1251 {"var t = 't'; return [[t, t + 'est'], [1 + t]][1][0];",
1252 {factory->NewStringFromStaticChars("1t")}}};
1253
1254 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1255 for (size_t i = 0; i < num_snippets; i++) {
1256 ScopedVector<char> script(4096);
1257 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1258 snippets[i].code_snippet, kFunctionName);
1259
1260 BytecodeGraphTester tester(isolate, zone, script.start());
1261 auto callable = tester.GetCallable<>();
1262 Handle<Object> return_value = callable().ToHandleChecked();
1263 CHECK(return_value->SameValue(*snippets[i].return_value()));
1264 }
1265 }
1266
1267
1268 TEST(BytecodeGraphBuilderObjectLiterals) {
1269 HandleAndZoneScope scope;
1270 Isolate* isolate = scope.main_isolate();
1271 Zone* zone = scope.main_zone();
1272 Factory* factory = isolate->factory();
1273
1274 ExpectedSnippet<0> snippets[] = {
1275 {"return { }.name;", {factory->undefined_value()}},
1276 {"return { name: 'string', val: 9.2 }.name;",
1277 {factory->NewStringFromStaticChars("string")}},
1278 {"var a;\n"
1279 REPEAT_256(SPACE, "a = 1.23;\n")
1280 "return { name: 'string', val: 9.2 }.name;",
1281 {factory->NewStringFromStaticChars("string")}},
1282 {"return { name: 'string', val: 9.2 }['name'];",
1283 {factory->NewStringFromStaticChars("string")}},
1284 {"var a = 15; return { name: 'string', val: a }.val;",
1285 {factory->NewNumberFromInt(15)}},
1286 {"var a;"
1287 REPEAT_256(SPACE, "a = 1.23;")
1288 "return { name: 'string', val: a }.val;",
1289 {factory->NewHeapNumber(1.23)}},
1290 {"var a = 15; var b = 'val'; return { name: 'string', val: a }[b];",
1291 {factory->NewNumberFromInt(15)}},
1292 {"var a = 5; return { val: a, val: a + 1 }.val;",
1293 {factory->NewNumberFromInt(6)}},
1294 {"return { func: function() { return 'test' } }.func();",
1295 {factory->NewStringFromStaticChars("test")}},
1296 {"return { func(a) { return a + 'st'; } }.func('te');",
1297 {factory->NewStringFromStaticChars("test")}},
1298 {"return { get a() { return 22; } }.a;", {factory->NewNumberFromInt(22)}},
1299 {"var a = { get b() { return this.x + 't'; },\n"
1300 " set b(val) { this.x = val + 's' } };\n"
1301 "a.b = 'te';\n"
1302 "return a.b;",
1303 {factory->NewStringFromStaticChars("test")}},
1304 {"var a = 123; return { 1: a }[1];", {factory->NewNumberFromInt(123)}},
1305 {"return Object.getPrototypeOf({ __proto__: null });",
1306 {factory->null_value()}},
1307 {"var a = 'test'; return { [a]: 1 }.test;",
1308 {factory->NewNumberFromInt(1)}},
1309 {"var a = 'test'; return { b: a, [a]: a + 'ing' }['test']",
1310 {factory->NewStringFromStaticChars("testing")}},
1311 {"var a = 'proto_str';\n"
1312 "var b = { [a]: 1, __proto__: { var : a } };\n"
1313 "return Object.getPrototypeOf(b).var",
1314 {factory->NewStringFromStaticChars("proto_str")}},
1315 {"var n = 'name';\n"
1316 "return { [n]: 'val', get a() { return 987 } }['a'];",
1317 {factory->NewNumberFromInt(987)}},
1318 };
1319
1320 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
1321 for (size_t i = 0; i < num_snippets; i++) {
1322 ScopedVector<char> script(4096);
1323 SNPrintF(script, "function %s() { %s }\n%s();", kFunctionName,
1324 snippets[i].code_snippet, kFunctionName);
1325
1326 BytecodeGraphTester tester(isolate, zone, script.start());
1327 auto callable = tester.GetCallable<>();
1328 Handle<Object> return_value = callable().ToHandleChecked();
1329 CHECK(return_value->SameValue(*snippets[i].return_value()));
1330 }
1331 }
1332
1189 } // namespace compiler 1333 } // namespace compiler
1190 } // namespace internal 1334 } // namespace internal
1191 } // namespace v8 1335 } // namespace v8
OLDNEW
« no previous file with comments | « src/interpreter/interpreter.cc ('k') | test/cctest/interpreter/test-bytecode-generator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698