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

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

Issue 2343633002: [interpreter] Add a fast path for dynamic local load (Closed)
Patch Set: Rebase Created 4 years, 3 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 <utility> 5 #include <utility>
6 6
7 #include "src/compilation-info.h" 7 #include "src/compilation-info.h"
8 #include "src/compiler/pipeline.h" 8 #include "src/compiler/pipeline.h"
9 #include "src/execution.h" 9 #include "src/execution.h"
10 #include "src/handles.h" 10 #include "src/handles.h"
(...skipping 1049 matching lines...) Expand 10 before | Expand all | Expand 10 after
1060 SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet, 1060 SNPrintF(script, "%s %s %s", function_prologue, snippets[i].code_snippet,
1061 function_epilogue); 1061 function_epilogue);
1062 1062
1063 BytecodeGraphTester tester(isolate, zone, script.start(), "t"); 1063 BytecodeGraphTester tester(isolate, zone, script.start(), "t");
1064 auto callable = tester.GetCallable<>(); 1064 auto callable = tester.GetCallable<>();
1065 Handle<Object> return_value = callable().ToHandleChecked(); 1065 Handle<Object> return_value = callable().ToHandleChecked();
1066 CHECK(return_value->SameValue(*snippets[i].return_value())); 1066 CHECK(return_value->SameValue(*snippets[i].return_value()));
1067 } 1067 }
1068 } 1068 }
1069 1069
1070 TEST(BytecodeGraphBuilderLookupContextSlot) {
1071 HandleAndZoneScope scope;
1072 Isolate* isolate = scope.main_isolate();
1073 Zone* zone = scope.main_zone();
1074 Factory* factory = isolate->factory();
1075
1076 // Testing with eval called in the current context.
1077 const char* inner_eval_prologue = "var x = 0; function inner() {";
1078 const char* inner_eval_epilogue = "}; return inner();";
1079
1080 ExpectedSnippet<0> inner_eval_snippets[] = {
1081 {"eval(''); return x;", {factory->NewNumber(0)}},
1082 {"eval('var x = 1'); return x;", {factory->NewNumber(1)}},
1083 {"'use strict'; eval('var x = 1'); return x;", {factory->NewNumber(0)}}};
1084
1085 for (size_t i = 0; i < arraysize(inner_eval_snippets); i++) {
1086 ScopedVector<char> script(1024);
1087 SNPrintF(script, "function %s(p1) { %s %s %s } ; %s() ;", kFunctionName,
1088 inner_eval_prologue, inner_eval_snippets[i].code_snippet,
1089 inner_eval_epilogue, kFunctionName);
1090
1091 BytecodeGraphTester tester(isolate, zone, script.start());
1092 auto callable = tester.GetCallable<>();
1093 Handle<Object> return_value = callable().ToHandleChecked();
1094 CHECK(return_value->SameValue(*inner_eval_snippets[i].return_value()));
1095 }
1096
1097 // Testing with eval called in a parent context.
1098 const char* outer_eval_prologue = "";
1099 const char* outer_eval_epilogue =
1100 "function inner() { return x; }; return inner();";
1101
1102 ExpectedSnippet<0> outer_eval_snippets[] = {
1103 {"var x = 0; eval('');", {factory->NewNumber(0)}},
1104 {"var x = 0; eval('var x = 1');", {factory->NewNumber(1)}},
1105 {"'use strict'; var x = 0; eval('var x = 1');", {factory->NewNumber(0)}}};
1106
1107 for (size_t i = 0; i < arraysize(outer_eval_snippets); i++) {
1108 ScopedVector<char> script(1024);
1109 SNPrintF(script, "function %s() { %s %s %s } ; %s() ;", kFunctionName,
1110 outer_eval_prologue, outer_eval_snippets[i].code_snippet,
1111 outer_eval_epilogue, kFunctionName);
1112
1113 BytecodeGraphTester tester(isolate, zone, script.start());
1114 auto callable = tester.GetCallable<>();
1115 Handle<Object> return_value = callable().ToHandleChecked();
1116 CHECK(return_value->SameValue(*outer_eval_snippets[i].return_value()));
1117 }
1118 }
1070 1119
1071 TEST(BytecodeGraphBuilderLookupSlotWide) { 1120 TEST(BytecodeGraphBuilderLookupSlotWide) {
1072 HandleAndZoneScope scope; 1121 HandleAndZoneScope scope;
1073 Isolate* isolate = scope.main_isolate(); 1122 Isolate* isolate = scope.main_isolate();
1074 Zone* zone = scope.main_zone(); 1123 Zone* zone = scope.main_zone();
1075 Factory* factory = isolate->factory(); 1124 Factory* factory = isolate->factory();
1076 1125
1077 const char* function_prologue = 1126 const char* function_prologue =
1078 "var f;" 1127 "var f;"
1079 "var x = 12;" 1128 "var x = 12;"
(...skipping 1877 matching lines...) Expand 10 before | Expand all | Expand 10 after
2957 3006
2958 BytecodeGraphTester tester(isolate, zone, script.start()); 3007 BytecodeGraphTester tester(isolate, zone, script.start());
2959 auto callable = tester.GetCallable<>(); 3008 auto callable = tester.GetCallable<>();
2960 Handle<Object> return_value = callable().ToHandleChecked(); 3009 Handle<Object> return_value = callable().ToHandleChecked();
2961 CHECK(return_value->SameValue(*snippet.return_value())); 3010 CHECK(return_value->SameValue(*snippet.return_value()));
2962 } 3011 }
2963 3012
2964 } // namespace compiler 3013 } // namespace compiler
2965 } // namespace internal 3014 } // namespace internal
2966 } // namespace v8 3015 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698