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

Side by Side Diff: test/unittests/compiler/bytecode-graph-builder-unittest.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: Rebase. 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 #include <iostream> 5 #include <iostream>
6 6
7 #include "src/compiler/bytecode-graph-builder.h" 7 #include "src/compiler/bytecode-graph-builder.h"
8 #include "src/compiler/common-operator.h" 8 #include "src/compiler/common-operator.h"
9 #include "src/compiler/graph-visualizer.h" 9 #include "src/compiler/graph-visualizer.h"
10 #include "src/compiler/instruction.h" 10 #include "src/compiler/instruction.h"
(...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 call_inputs.push_back(IsParameter(1)); 433 call_inputs.push_back(IsParameter(1));
434 call_inputs.push_back(IsParameter(2)); 434 call_inputs.push_back(IsParameter(2));
435 call_inputs.push_back(IsParameter(3)); 435 call_inputs.push_back(IsParameter(3));
436 Matcher<Node*> call_matcher = 436 Matcher<Node*> call_matcher =
437 IsJSCallFunction(call_inputs, load_named_matcher, IsIfSuccess(_)); 437 IsJSCallFunction(call_inputs, load_named_matcher, IsIfSuccess(_));
438 438
439 EXPECT_THAT(ret, IsReturn(call_matcher, _, _)); 439 EXPECT_THAT(ret, IsReturn(call_matcher, _, _));
440 } 440 }
441 441
442 442
443 TEST_F(BytecodeGraphBuilderTest, LoadGlobal) {
444 const TypeofMode kTypeOfModes[] = {TypeofMode::NOT_INSIDE_TYPEOF,
445 TypeofMode::INSIDE_TYPEOF};
446 const bool kWideBytecode[] = {false, true};
447 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
448 TRACED_FOREACH(TypeofMode, typeof_mode, kTypeOfModes) {
449 TRACED_FOREACH(bool, wide_bytecode, kWideBytecode) {
450 FeedbackVectorSpec feedback_spec(zone());
451 if (wide_bytecode) {
452 for (int i = 0; i < 128; i++) {
453 feedback_spec.AddLoadICSlot();
454 }
455 }
456 FeedbackVectorSlot slot = feedback_spec.AddLoadICSlot();
457 Handle<TypeFeedbackVector> vector =
458 NewTypeFeedbackVector(isolate(), &feedback_spec);
459
460 interpreter::BytecodeArrayBuilder array_builder(isolate(), zone());
461 array_builder.set_locals_count(0);
462 array_builder.set_context_count(0);
463 array_builder.set_parameter_count(1);
464
465 Handle<Name> name = GetName(isolate(), "global");
466 size_t name_index = array_builder.GetConstantPoolEntry(name);
467
468 array_builder.LoadGlobal(name_index, vector->GetIndex(slot),
469 language_mode, typeof_mode)
470 .Return();
471 Graph* graph = GetCompletedGraph(array_builder.ToBytecodeArray(),
472 vector, language_mode);
473
474 Node* ret = graph->end()->InputAt(0);
475 Node* start = graph->start();
476
477 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
478 Matcher<Node*> load_global_matcher = IsJSLoadGlobal(
479 name, typeof_mode, feedback_vector_matcher, start, start);
480
481 EXPECT_THAT(ret, IsReturn(load_global_matcher, _, _));
482 }
483 }
484 }
485 }
486
487
488 TEST_F(BytecodeGraphBuilderTest, StoreGlobal) {
489 const bool kWideBytecode[] = {false, true};
490 TRACED_FOREACH(LanguageMode, language_mode, kLanguageModes) {
491 TRACED_FOREACH(bool, wide_bytecode, kWideBytecode) {
492 FeedbackVectorSpec feedback_spec(zone());
493 if (wide_bytecode) {
494 for (int i = 0; i < 128; i++) {
495 feedback_spec.AddStoreICSlot();
496 }
497 }
498 FeedbackVectorSlot slot = feedback_spec.AddStoreICSlot();
499 Handle<TypeFeedbackVector> vector =
500 NewTypeFeedbackVector(isolate(), &feedback_spec);
501
502 interpreter::BytecodeArrayBuilder array_builder(isolate(), zone());
503 array_builder.set_locals_count(0);
504 array_builder.set_context_count(0);
505 array_builder.set_parameter_count(1);
506
507 Handle<Name> name = GetName(isolate(), "global");
508 size_t name_index = array_builder.GetConstantPoolEntry(name);
509
510 array_builder.LoadLiteral(Smi::FromInt(321))
511 .StoreGlobal(name_index, vector->GetIndex(slot), language_mode)
512 .Return();
513 Graph* graph = GetCompletedGraph(array_builder.ToBytecodeArray(), vector,
514 language_mode);
515
516 Node* ret = graph->end()->InputAt(0);
517 Node* start = graph->start();
518
519 Matcher<Node*> value_matcher = IsNumberConstant(321);
520 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
521 Matcher<Node*> store_global_matcher = IsJSStoreGlobal(
522 name, value_matcher, feedback_vector_matcher, start, start);
523
524 EXPECT_THAT(ret, IsReturn(_, store_global_matcher, _));
525 }
526 }
527 }
528
529
443 } // namespace compiler 530 } // namespace compiler
444 } // namespace internal 531 } // namespace internal
445 } // namespace v8 532 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/test-run-bytecode-graph-builder.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698