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

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

Issue 1448913002: [Interpreter] Add support for keyed load / store ICs and named store IC to (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@graph_builder_load
Patch Set: Made the binding of return value of the store explicit. 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(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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 327
328 BytecodeGraphTester tester(isolate, zone, script.start()); 328 BytecodeGraphTester tester(isolate, zone, script.start());
329 auto callable = tester.GetCallable<Handle<Object>>(); 329 auto callable = tester.GetCallable<Handle<Object>>();
330 Handle<Object> return_value = 330 Handle<Object> return_value =
331 callable(snippets[i].parameter(0)).ToHandleChecked(); 331 callable(snippets[i].parameter(0)).ToHandleChecked();
332 CHECK(return_value->SameValue(*snippets[i].return_value())); 332 CHECK(return_value->SameValue(*snippets[i].return_value()));
333 } 333 }
334 } 334 }
335 335
336 336
337 TEST(BytecodeGraphBuilderKeyedLoad) {
338 HandleAndZoneScope scope;
339 Isolate* isolate = scope.main_isolate();
340 Zone* zone = scope.main_zone();
341 Factory* factory = isolate->factory();
342
343 ExpectedSnippet<2> snippets[] = {
344 {"return p1[p2];",
345 {factory->NewNumberFromInt(10),
346 BytecodeGraphTester::NewObject("({val : 10})"),
347 factory->NewStringFromStaticChars("val")}},
348 {"return p1[100];",
349 {factory->NewStringFromStaticChars("abc"),
350 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
351 factory->NewNumberFromInt(0)}},
352 {"var b = 100; return p1[b];",
353 {factory->NewStringFromStaticChars("abc"),
354 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
355 factory->NewNumberFromInt(0)}},
356 {"'use strict'; return p1[p2];",
357 {factory->NewNumberFromInt(10),
358 BytecodeGraphTester::NewObject("({val : 10 })"),
359 factory->NewStringFromStaticChars("val")}},
360 {"'use strict'; return p1[100];",
361 {factory->NewNumberFromInt(10),
362 BytecodeGraphTester::NewObject("({100 : 10})"),
363 factory->NewNumberFromInt(0)}},
364 {"'use strict'; var b = p2; return p1[b];",
365 {factory->NewStringFromStaticChars("abc"),
366 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
367 factory->NewNumberFromInt(100)}},
368 {"var b;\n" REPEAT_127(SPACE, " b = p1[p2]; ") " return p1[p2];\n",
369 {factory->NewStringFromStaticChars("abc"),
370 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
371 factory->NewNumberFromInt(100)}},
372 {"'use strict'; var b;\n" REPEAT_127(SPACE,
373 " b = p1[p2]; ") "return p1[p2];\n",
374 {factory->NewStringFromStaticChars("abc"),
375 BytecodeGraphTester::NewObject("({ 100 : 'abc'})"),
376 factory->NewNumberFromInt(100)}},
377 };
378
379 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
380 for (size_t i = 0; i < num_snippets; i++) {
381 ScopedVector<char> script(2048);
382 SNPrintF(script, "function %s(p1, p2) { %s };\n%s(0);", kFunctionName,
383 snippets[i].code_snippet, kFunctionName);
384
385 BytecodeGraphTester tester(isolate, zone, script.start());
386 auto callable = tester.GetCallable<Handle<Object>, Handle<Object>>();
387 Handle<Object> return_value =
388 callable(snippets[i].parameter(0), snippets[i].parameter(1))
389 .ToHandleChecked();
390 CHECK(return_value->SameValue(*snippets[i].return_value()));
391 }
392 }
393
394
395 TEST(BytecodeGraphBuilderNamedStore) {
396 HandleAndZoneScope scope;
397 Isolate* isolate = scope.main_isolate();
398 Zone* zone = scope.main_zone();
399 Factory* factory = isolate->factory();
400
401 ExpectedSnippet<1> snippets[] = {
402 {"return p1.val = 20;",
403 {factory->NewNumberFromInt(20),
404 BytecodeGraphTester::NewObject("({val : 10})")}},
405 {"p1.type = 'int'; return p1.type;",
406 {factory->NewStringFromStaticChars("int"),
407 BytecodeGraphTester::NewObject("({val : 10})")}},
408 {"p1.name = 'def'; return p1[\"name\"];",
409 {factory->NewStringFromStaticChars("def"),
410 BytecodeGraphTester::NewObject("({name : 'abc'})")}},
411 {"'use strict'; p1.val = 20; return p1.val;",
412 {factory->NewNumberFromInt(20),
413 BytecodeGraphTester::NewObject("({val : 10 })")}},
414 {"'use strict'; return p1.type = 'int';",
415 {factory->NewStringFromStaticChars("int"),
416 BytecodeGraphTester::NewObject("({val : 10})")}},
417 {"'use strict'; p1.val = 20; return p1[\"val\"];",
418 {factory->NewNumberFromInt(20),
419 BytecodeGraphTester::NewObject("({val : 10, name : 'abc'})")}},
420 {"var b = 'abc';\n" REPEAT_127(
421 SPACE, " p1.name = b; ") " p1.name = 'def'; return p1.name;\n",
422 {factory->NewStringFromStaticChars("def"),
423 BytecodeGraphTester::NewObject("({name : 'abc'})")}},
424 {"'use strict'; var b = 'def';\n" REPEAT_127(
425 SPACE, " p1.name = 'abc'; ") "p1.name = b; return p1.name;\n",
426 {factory->NewStringFromStaticChars("def"),
427 BytecodeGraphTester::NewObject("({ name : 'abc'})")}},
428 };
429
430 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
431 for (size_t i = 0; i < num_snippets; i++) {
432 ScopedVector<char> script(3072);
433 SNPrintF(script, "function %s(p1) { %s };\n%s({});", kFunctionName,
434 snippets[i].code_snippet, kFunctionName);
435
436 BytecodeGraphTester tester(isolate, zone, script.start());
437 auto callable = tester.GetCallable<Handle<Object>>();
438 Handle<Object> return_value =
439 callable(snippets[i].parameter(0)).ToHandleChecked();
440 CHECK(return_value->SameValue(*snippets[i].return_value()));
441 }
442 }
443
444
445 TEST(BytecodeGraphBuilderKeyedStore) {
446 HandleAndZoneScope scope;
447 Isolate* isolate = scope.main_isolate();
448 Zone* zone = scope.main_zone();
449 Factory* factory = isolate->factory();
450
451 ExpectedSnippet<2> snippets[] = {
452 {"p1[p2] = 20; return p1[p2];",
453 {factory->NewNumberFromInt(20),
454 BytecodeGraphTester::NewObject("({val : 10})"),
455 factory->NewStringFromStaticChars("val")}},
456 {"return p1[100] = 'def';",
457 {factory->NewStringFromStaticChars("def"),
458 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
459 factory->NewNumberFromInt(0)}},
460 {"var b = 100; p1[b] = 'def'; return p1[b];",
461 {factory->NewStringFromStaticChars("def"),
462 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
463 factory->NewNumberFromInt(0)}},
464 {"'use strict'; p1[p2] = 20; return p1[p2];",
465 {factory->NewNumberFromInt(20),
466 BytecodeGraphTester::NewObject("({val : 10 })"),
467 factory->NewStringFromStaticChars("val")}},
468 {"'use strict'; return p1[100] = 20;",
469 {factory->NewNumberFromInt(20),
470 BytecodeGraphTester::NewObject("({100 : 10})"),
471 factory->NewNumberFromInt(0)}},
472 {"'use strict'; var b = p2; p1[b] = 'def'; return p1[b];",
473 {factory->NewStringFromStaticChars("def"),
474 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
475 factory->NewNumberFromInt(100)}},
476 {"var b;\n" REPEAT_127(
477 SPACE, " b = p1[p2]; ") " p1[p2] = 'def'; return p1[p2];\n",
478 {factory->NewStringFromStaticChars("def"),
479 BytecodeGraphTester::NewObject("({100 : 'abc'})"),
480 factory->NewNumberFromInt(100)}},
481 {"'use strict'; var b;\n" REPEAT_127(
482 SPACE, " b = p1[p2]; ") " p1[p2] = 'def'; return p1[p2];\n",
483 {factory->NewStringFromStaticChars("def"),
484 BytecodeGraphTester::NewObject("({ 100 : 'abc'})"),
485 factory->NewNumberFromInt(100)}},
486 };
487
488 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
489 for (size_t i = 0; i < num_snippets; i++) {
490 ScopedVector<char> script(2048);
491 SNPrintF(script, "function %s(p1, p2) { %s };\n%s({});", kFunctionName,
492 snippets[i].code_snippet, kFunctionName);
493
494 BytecodeGraphTester tester(isolate, zone, script.start());
495 auto callable = tester.GetCallable<Handle<Object>>();
496 Handle<Object> return_value =
497 callable(snippets[i].parameter(0)).ToHandleChecked();
498 CHECK(return_value->SameValue(*snippets[i].return_value()));
499 }
500 }
501
502
337 TEST(BytecodeGraphBuilderPropertyCall) { 503 TEST(BytecodeGraphBuilderPropertyCall) {
338 HandleAndZoneScope scope; 504 HandleAndZoneScope scope;
339 Isolate* isolate = scope.main_isolate(); 505 Isolate* isolate = scope.main_isolate();
340 Zone* zone = scope.main_zone(); 506 Zone* zone = scope.main_zone();
341 Factory* factory = isolate->factory(); 507 Factory* factory = isolate->factory();
342 508
343 ExpectedSnippet<1> snippets[] = { 509 ExpectedSnippet<1> snippets[] = {
344 {"return p1.func();", 510 {"return p1.func();",
345 {factory->NewNumberFromInt(25), 511 {factory->NewNumberFromInt(25),
346 BytecodeGraphTester::NewObject("({func() { return 25; }})")}}, 512 BytecodeGraphTester::NewObject("({func() { return 25; }})")}},
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 auto callable = tester.GetCallable<Handle<Object>>(); 689 auto callable = tester.GetCallable<Handle<Object>>();
524 Handle<Object> return_value = 690 Handle<Object> return_value =
525 callable(snippets[i].parameter(0)).ToHandleChecked(); 691 callable(snippets[i].parameter(0)).ToHandleChecked();
526 CHECK(return_value->SameValue(*snippets[i].return_value())); 692 CHECK(return_value->SameValue(*snippets[i].return_value()));
527 } 693 }
528 } 694 }
529 695
530 } // namespace compiler 696 } // namespace compiler
531 } // namespace internal 697 } // namespace internal
532 } // namespace v8 698 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/bytecode-graph-builder.cc ('k') | test/unittests/compiler/bytecode-graph-builder-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698