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

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

Issue 1474103002: Re-reland "[Interpreter] Add CreateClosure to BytecodeGraphBuilder." (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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 564 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]); 575 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
576 for (size_t i = 0; i < num_snippets; i++) { 576 for (size_t i = 0; i < num_snippets; i++) {
577 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet); 577 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
578 auto callable = tester.GetCallable<>(); 578 auto callable = tester.GetCallable<>();
579 Handle<Object> return_value = callable().ToHandleChecked(); 579 Handle<Object> return_value = callable().ToHandleChecked();
580 CHECK(return_value->SameValue(*snippets[i].return_value())); 580 CHECK(return_value->SameValue(*snippets[i].return_value()));
581 } 581 }
582 } 582 }
583 583
584 584
585 TEST(BytecodeGraphBuilderCreateClosure) {
586 HandleAndZoneScope scope;
587 Isolate* isolate = scope.main_isolate();
588 Zone* zone = scope.main_zone();
589 Factory* factory = isolate->factory();
590
591 ExpectedSnippet<0> snippets[] = {
592 {"function f() {\n"
593 " function counter() { this.count = 20; }\n"
594 " var c = new counter();\n"
595 " return c.count;\n"
596 "}; f()",
597 {factory->NewNumberFromInt(20)}},
598 {"function f() {\n"
599 " function counter(arg0) { this.count = 17; this.x = arg0; }\n"
600 " var c = new counter(6);\n"
601 " return c.count + c.x;\n"
602 "}; f()",
603 {factory->NewNumberFromInt(23)}},
604 {"function f() {\n"
605 " function counter(arg0, arg1) {\n"
606 " this.count = 17; this.x = arg0; this.y = arg1;\n"
607 " }\n"
608 " var c = new counter(3, 5);\n"
609 " return c.count + c.x + c.y;\n"
610 "}; f()",
611 {factory->NewNumberFromInt(25)}},
612 };
613
614 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
615 for (size_t i = 0; i < num_snippets; i++) {
616 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
617 auto callable = tester.GetCallable<>();
618 Handle<Object> return_value = callable().ToHandleChecked();
619 CHECK(return_value->SameValue(*snippets[i].return_value()));
620 }
621 }
622
623
585 TEST(BytecodeGraphBuilderCallRuntime) { 624 TEST(BytecodeGraphBuilderCallRuntime) {
586 HandleAndZoneScope scope; 625 HandleAndZoneScope scope;
587 Isolate* isolate = scope.main_isolate(); 626 Isolate* isolate = scope.main_isolate();
588 Zone* zone = scope.main_zone(); 627 Zone* zone = scope.main_zone();
589 Factory* factory = isolate->factory(); 628 Factory* factory = isolate->factory();
590 629
591 ExpectedSnippet<1> snippets[] = { 630 ExpectedSnippet<1> snippets[] = {
592 {"function f(arg0) { return %MaxSmi(); }\nf()", 631 {"function f(arg0) { return %MaxSmi(); }\nf()",
593 {factory->NewNumberFromInt(Smi::kMaxValue), factory->undefined_value()}}, 632 {factory->NewNumberFromInt(Smi::kMaxValue), factory->undefined_value()}},
594 {"function f(arg0) { return %IsArray(arg0) }\nf(undefined)", 633 {"function f(arg0) { return %IsArray(arg0) }\nf(undefined)",
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
908 } 947 }
909 948
910 949
911 TEST(BytecodeGraphBuilderTestInstanceOf) { 950 TEST(BytecodeGraphBuilderTestInstanceOf) {
912 // TODO(mythria): Add tests when CreateLiterals/CreateClousre are supported. 951 // TODO(mythria): Add tests when CreateLiterals/CreateClousre are supported.
913 } 952 }
914 953
915 } // namespace compiler 954 } // namespace compiler
916 } // namespace internal 955 } // namespace internal
917 } // namespace v8 956 } // 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