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

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

Issue 1449373002: [Interpreter] Add support for global loads / stores / calls to BytecodeGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@rmcilroy-0000
Patch Set: Import from https://codereview.chromium.org/1441643002/ 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 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 template <int N> 150 template <int N>
151 struct ExpectedSnippet { 151 struct ExpectedSnippet {
152 const char* code_snippet; 152 const char* code_snippet;
153 Handle<Object> return_value_and_parameters[N + 1]; 153 Handle<Object> return_value_and_parameters[N + 1];
154 154
155 inline Handle<Object> return_value() const { 155 inline Handle<Object> return_value() const {
156 return return_value_and_parameters[0]; 156 return return_value_and_parameters[0];
157 } 157 }
158 158
159 inline Handle<Object> parameter(int i) const { 159 inline Handle<Object> parameter(int i) const {
160 DCHECK_GE(i, 0);
161 DCHECK_LT(i, N);
160 return return_value_and_parameters[1 + i]; 162 return return_value_and_parameters[1 + i];
161 } 163 }
162 }; 164 };
163 165
164 166
165 TEST(BytecodeGraphBuilderReturnStatements) { 167 TEST(BytecodeGraphBuilderReturnStatements) {
166 HandleAndZoneScope scope; 168 HandleAndZoneScope scope;
167 Isolate* isolate = scope.main_isolate(); 169 Isolate* isolate = scope.main_isolate();
168 Zone* zone = scope.main_zone(); 170 Zone* zone = scope.main_zone();
169 Factory* factory = isolate->factory(); 171 Factory* factory = isolate->factory();
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 snippets[i].code_snippet, kFunctionName); 362 snippets[i].code_snippet, kFunctionName);
361 363
362 BytecodeGraphTester tester(isolate, zone, script.start()); 364 BytecodeGraphTester tester(isolate, zone, script.start());
363 auto callable = tester.GetCallable<Handle<Object>>(); 365 auto callable = tester.GetCallable<Handle<Object>>();
364 Handle<Object> return_value = 366 Handle<Object> return_value =
365 callable(snippets[i].parameter(0)).ToHandleChecked(); 367 callable(snippets[i].parameter(0)).ToHandleChecked();
366 CHECK(return_value->SameValue(*snippets[i].return_value())); 368 CHECK(return_value->SameValue(*snippets[i].return_value()));
367 } 369 }
368 } 370 }
369 371
372
373 TEST(BytecodeGraphBuilderGlobals) {
374 HandleAndZoneScope scope;
375 Isolate* isolate = scope.main_isolate();
376 Zone* zone = scope.main_zone();
377 Factory* factory = isolate->factory();
378
379 ExpectedSnippet<0> snippets[] = {
380 {"var global = 321;\n function f() { return global; };\n f();",
381 {factory->NewNumberFromInt(321)}},
382 {"var global = 321;\n"
383 "function f() { global = 123; return global };\n f();",
384 {factory->NewNumberFromInt(123)}},
385 {"var global = function() { return 'abc'};\n"
386 "function f() { return global(); };\n f();",
387 {factory->NewStringFromStaticChars("abc")}},
388 {"var global = 456;\n"
389 "function f() { 'use strict'; return global; };\n f();",
390 {factory->NewNumberFromInt(456)}},
391 {"var global = 987;\n"
392 "function f() { 'use strict'; global = 789; return global };\n f();",
393 {factory->NewNumberFromInt(789)}},
394 {"var global = function() { return 'xyz'};\n"
395 "function f() { 'use strict'; return global(); };\n f();",
396 {factory->NewStringFromStaticChars("xyz")}},
397 {"var global = 'abc'; var global_obj = {val:123};\n"
398 "function f() {\n" REPEAT_127(
399 SPACE, " var b = global_obj.name;\n") "return global; };\n f();\n",
400 {factory->NewStringFromStaticChars("abc")}},
401 {"var global = 'abc'; var global_obj = {val:123};\n"
402 "function f() { 'use strict';\n" REPEAT_127(
403 SPACE, " var b = global_obj.name;\n") "global = 'xyz'; return "
404 "global };\n f();\n",
405 {factory->NewStringFromStaticChars("xyz")}},
406 // TODO(rmcilroy): Add tests for typeof_mode once we have typeof support.
407 };
408
409 size_t num_snippets = sizeof(snippets) / sizeof(snippets[0]);
410 for (size_t i = 0; i < num_snippets; i++) {
411 BytecodeGraphTester tester(isolate, zone, snippets[i].code_snippet);
412 auto callable = tester.GetCallable<>();
413 Handle<Object> return_value = callable().ToHandleChecked();
414 CHECK(return_value->SameValue(*snippets[i].return_value()));
415 }
416 }
417
370 } // namespace compiler 418 } // namespace compiler
371 } // namespace internal 419 } // namespace internal
372 } // namespace v8 420 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698