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

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

Issue 1458603012: [Interpreter] Add CreateClosure to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove unneeded includes. 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 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); 568 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
569 for (size_t i = 0; i < num_snippets; i++) { 569 for (size_t i = 0; i < num_snippets; i++) {
570 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); 570 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
571 auto callable = tester.GetCallable<>(); 571 auto callable = tester.GetCallable<>();
572 Handle<Object> return_value = callable().ToHandleChecked(); 572 Handle<Object> return_value = callable().ToHandleChecked();
573 CHECK(return_value->SameValue(*snippets[i].return_value())); 573 CHECK(return_value->SameValue(*snippets[i].return_value()));
574 } 574 }
575 } 575 }
576 576
577 577
578 TEST(BytecodeGraphBuilderCreateClosure) {
579 HandleAndZoneScope scope;
580 Isolate* isolate = scope.main_isolate();
581 Zone* zone = scope.main_zone();
582 Factory* factory = isolate->factory();
583
584 ExpectedSnippet<0> snippets[] = {
585 {"function f() {\n"
586 " function counter() { this.count = 20; }\n"
587 " var c = new counter();\n"
588 " return c.count;\n"
589 "}; f()",
590 {factory->NewNumberFromInt(20)}},
591 {"function f() {\n"
592 " function counter(arg0) { this.count = 17; this.x = arg0; }\n"
593 " var c = new counter(6);\n"
594 " return c.count + c.x;\n"
595 "}; f()",
596 {factory->NewNumberFromInt(23)}},
597 {"function f() {\n"
598 " function counter(arg0, arg1) {\n"
599 " this.count = 17; this.x = arg0; this.y = arg1;\n"
600 " }\n"
601 " var c = new counter(3, 5);\n"
602 " return c.count + c.x + c.y;\n"
603 "}; f()",
604 {factory->NewNumberFromInt(25)}},
605 };
606
607 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
608 for (size_t i = 0; i < num_snippets; i++) {
609 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
610 auto callable = tester.GetCallable<>();
611 Handle<Object> return_value = callable().ToHandleChecked();
612 CHECK(return_value->SameValue(*snippets[i].return_value()));
613 }
614 }
615
616
578 TEST(BytecodeGraphBuilderCallRuntime) { 617 TEST(BytecodeGraphBuilderCallRuntime) {
579 HandleAndZoneScope scope; 618 HandleAndZoneScope scope;
580 Isolate* isolate = scope.main_isolate(); 619 Isolate* isolate = scope.main_isolate();
581 Zone* zone = scope.main_zone(); 620 Zone* zone = scope.main_zone();
582 Factory* factory = isolate->factory(); 621 Factory* factory = isolate->factory();
583 622
584 ExpectedSnippet<1> snippets[] = { 623 ExpectedSnippet<1> snippets[] = {
585 {"function f(arg0) { return %MaxSmi(); }\nf()", 624 {"function f(arg0) { return %MaxSmi(); }\nf()",
586 {factory->NewNumberFromInt(Smi::kMaxValue), factory->undefined_value()}}, 625 {factory->NewNumberFromInt(Smi::kMaxValue), factory->undefined_value()}},
587 {"function f(arg0) { return %IsArray(arg0) }\nf(undefined)", 626 {"function f(arg0) { return %IsArray(arg0) }\nf(undefined)",
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 auto callable = tester.GetCallable<Handle<Object>>(); 797 auto callable = tester.GetCallable<Handle<Object>>();
759 Handle<Object> return_value = 798 Handle<Object> return_value =
760 callable(snippets[i].parameter(0)).ToHandleChecked(); 799 callable(snippets[i].parameter(0)).ToHandleChecked();
761 CHECK(return_value->SameValue(*snippets[i].return_value())); 800 CHECK(return_value->SameValue(*snippets[i].return_value()));
762 } 801 }
763 } 802 }
764 803
765 } // namespace compiler 804 } // namespace compiler
766 } // namespace internal 805 } // namespace internal
767 } // namespace v8 806 } // 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