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

Side by Side Diff: test/unittests/compiler/bytecode-graph-builder-unittest.cc

Issue 1437873002: [Interpreter] Add support for Call bytecode to bytecode graph builder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@mythri_load
Patch Set: 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 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start); 478 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
479 Matcher<Node*> preceeding_load = IsJSLoadNamed( 479 Matcher<Node*> preceeding_load = IsJSLoadNamed(
480 GraphGeneratorHelper::GetName(isolate(), "val_prev"), _, _, _, _); 480 GraphGeneratorHelper::GetName(isolate(), "val_prev"), _, _, _, _);
481 Matcher<Node*> load_named_matcher_wide = 481 Matcher<Node*> load_named_matcher_wide =
482 IsJSLoadNamed(name, IsParameter(1), feedback_vector_matcher, 482 IsJSLoadNamed(name, IsParameter(1), feedback_vector_matcher,
483 preceeding_load, IsIfSuccess(_)); 483 preceeding_load, IsIfSuccess(_));
484 484
485 EXPECT_THAT(ret, IsReturn(load_named_matcher_wide, _, _)); 485 EXPECT_THAT(ret, IsReturn(load_named_matcher_wide, _, _));
486 } 486 }
487 487
488
489 TEST_F(BytecodeGraphBuilderTest, CallProperty0) {
490 const char* code_snippet =
491 "function f(p1) {return p1.func();}; f({func(){}});";
492 GraphGeneratorHelper helper(isolate(), zone(), code_snippet);
493 Graph* graph = helper.GetCompletedGraph();
494
495 Node* ret = graph->end()->InputAt(0);
496 Node* start = graph->start();
497
498 Handle<Name> name = GraphGeneratorHelper::GetName(isolate(), "func");
499 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
500 Matcher<Node*> load_named_matcher = IsJSLoadNamed(
501 name, IsParameter(1), feedback_vector_matcher, start, start);
502 std::vector<Matcher<Node*>> call_inputs;
503 call_inputs.push_back(load_named_matcher);
504 call_inputs.push_back(IsParameter(1));
505 Matcher<Node*> call_matcher =
506 IsJSCallFunction(call_inputs, load_named_matcher, IsIfSuccess(_));
507
508 EXPECT_THAT(ret, IsReturn(call_matcher, _, _));
509 }
510
511
512 TEST_F(BytecodeGraphBuilderTest, CallProperty2) {
513 const char* code_snippet =
514 "function f(p1, p2, p3) {return p1.func(p2, p3);}; f({func(a){}}, 1, 2);";
515 GraphGeneratorHelper helper(isolate(), zone(), code_snippet);
516 Graph* graph = helper.GetCompletedGraph();
517
518 Node* ret = graph->end()->InputAt(0);
519 Node* start = graph->start();
520
521 Handle<Name> name = GraphGeneratorHelper::GetName(isolate(), "func");
522 Matcher<Node*> feedback_vector_matcher = IsFeedbackVector(start, start);
523 Matcher<Node*> load_named_matcher = IsJSLoadNamed(
524 name, IsParameter(1), feedback_vector_matcher, start, start);
525 std::vector<Matcher<Node*>> call_inputs;
526 call_inputs.push_back(load_named_matcher);
527 call_inputs.push_back(IsParameter(1));
528 call_inputs.push_back(IsParameter(2));
529 call_inputs.push_back(IsParameter(3));
530 Matcher<Node*> call_matcher =
531 IsJSCallFunction(call_inputs, load_named_matcher, IsIfSuccess(_));
532
533 EXPECT_THAT(ret, IsReturn(call_matcher, _, _));
534 }
535
488 } // namespace compiler 536 } // namespace compiler
489 } // namespace internal 537 } // namespace internal
490 } // namespace v8 538 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698