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

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

Issue 1248743003: [turbofan] Get rid of overly abstract SimplifiedGraphBuilder. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 5 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
« no previous file with comments | « test/cctest/compiler/simplified-graph-builder.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "test/cctest/compiler/simplified-graph-builder.h"
6
7 #include "src/compiler/operator-properties.h"
8
9 namespace v8 {
10 namespace internal {
11 namespace compiler {
12
13 SimplifiedGraphBuilder::SimplifiedGraphBuilder(
14 Isolate* isolate, Graph* graph, CommonOperatorBuilder* common,
15 MachineOperatorBuilder* machine, SimplifiedOperatorBuilder* simplified)
16 : GraphBuilder(isolate, graph),
17 effect_(NULL),
18 return_(NULL),
19 common_(common),
20 machine_(machine),
21 simplified_(simplified) {}
22
23
24 void SimplifiedGraphBuilder::Begin(int num_parameters) {
25 DCHECK(graph()->start() == NULL);
26 Node* start = graph()->NewNode(common()->Start(num_parameters + 3));
27 graph()->SetStart(start);
28 effect_ = start;
29 }
30
31
32 void SimplifiedGraphBuilder::Return(Node* value) {
33 return_ =
34 graph()->NewNode(common()->Return(), value, effect_, graph()->start());
35 effect_ = NULL;
36 }
37
38
39 void SimplifiedGraphBuilder::End() {
40 Node* end = graph()->NewNode(common()->End(1), return_);
41 graph()->SetEnd(end);
42 }
43
44
45 Node* SimplifiedGraphBuilder::MakeNode(const Operator* op,
46 int value_input_count,
47 Node** value_inputs, bool incomplete) {
48 DCHECK(op->ValueInputCount() == value_input_count);
49
50 DCHECK(!OperatorProperties::HasContextInput(op));
51 DCHECK_EQ(0, OperatorProperties::GetFrameStateInputCount(op));
52 bool has_control = op->ControlInputCount() == 1;
53 bool has_effect = op->EffectInputCount() == 1;
54
55 DCHECK(op->ControlInputCount() < 2);
56 DCHECK(op->EffectInputCount() < 2);
57
58 Node* result = NULL;
59 if (!has_control && !has_effect) {
60 result = graph()->NewNode(op, value_input_count, value_inputs, incomplete);
61 } else {
62 int input_count_with_deps = value_input_count;
63 if (has_control) ++input_count_with_deps;
64 if (has_effect) ++input_count_with_deps;
65 Node** buffer = zone()->NewArray<Node*>(input_count_with_deps);
66 memcpy(buffer, value_inputs, kPointerSize * value_input_count);
67 Node** current_input = buffer + value_input_count;
68 if (has_effect) {
69 *current_input++ = effect_;
70 }
71 if (has_control) {
72 *current_input++ = graph()->start();
73 }
74 result = graph()->NewNode(op, input_count_with_deps, buffer, incomplete);
75 if (has_effect) {
76 effect_ = result;
77 }
78 // This graph builder does not support control flow.
79 CHECK_EQ(0, op->ControlOutputCount());
80 }
81
82 return result;
83 }
84
85 } // namespace compiler
86 } // namespace internal
87 } // namespace v8
OLDNEW
« no previous file with comments | « test/cctest/compiler/simplified-graph-builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698