OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 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 | 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 <limits> | 5 #include <limits> |
6 | 6 |
7 #include "src/compiler/control-builders.h" | 7 #include "src/compiler/control-builders.h" |
8 #include "src/compiler/generic-node-inl.h" | 8 #include "src/compiler/generic-node-inl.h" |
9 #include "src/compiler/node-properties-inl.h" | 9 #include "src/compiler/node-properties-inl.h" |
10 #include "src/compiler/pipeline.h" | 10 #include "src/compiler/pipeline.h" |
11 #include "src/compiler/simplified-lowering.h" | 11 #include "src/compiler/simplified-lowering.h" |
12 #include "src/compiler/simplified-node-factory.h" | 12 #include "src/compiler/simplified-node-factory.h" |
13 #include "src/compiler/typer.h" | |
14 #include "src/compiler/verifier.h" | 13 #include "src/compiler/verifier.h" |
15 #include "src/execution.h" | 14 #include "src/execution.h" |
16 #include "src/parser.h" | 15 #include "src/parser.h" |
17 #include "src/rewriter.h" | 16 #include "src/rewriter.h" |
18 #include "src/scopes.h" | 17 #include "src/scopes.h" |
19 #include "test/cctest/cctest.h" | 18 #include "test/cctest/cctest.h" |
20 #include "test/cctest/compiler/codegen-tester.h" | 19 #include "test/cctest/compiler/codegen-tester.h" |
21 #include "test/cctest/compiler/graph-builder-tester.h" | 20 #include "test/cctest/compiler/graph-builder-tester.h" |
22 #include "test/cctest/compiler/value-helper.h" | 21 #include "test/cctest/compiler/value-helper.h" |
23 | 22 |
24 using namespace v8::internal; | 23 using namespace v8::internal; |
25 using namespace v8::internal::compiler; | 24 using namespace v8::internal::compiler; |
26 | 25 |
27 template <typename ReturnType> | 26 template <typename ReturnType> |
28 class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { | 27 class ChangesLoweringTester : public GraphBuilderTester<ReturnType> { |
29 public: | 28 public: |
30 explicit ChangesLoweringTester(MachineType p0 = kMachNone) | 29 explicit ChangesLoweringTester(MachineType p0 = kMachNone) |
31 : GraphBuilderTester<ReturnType>(p0), | 30 : GraphBuilderTester<ReturnType>(p0), |
32 typer(this->zone()), | 31 jsgraph(this->graph(), this->common()), |
33 jsgraph(this->graph(), this->common(), &typer), | |
34 lowering(&jsgraph), | 32 lowering(&jsgraph), |
35 function(Handle<JSFunction>::null()) {} | 33 function(Handle<JSFunction>::null()) {} |
36 | 34 |
37 Typer typer; | |
38 JSGraph jsgraph; | 35 JSGraph jsgraph; |
39 SimplifiedLowering lowering; | 36 SimplifiedLowering lowering; |
40 Handle<JSFunction> function; | 37 Handle<JSFunction> function; |
41 | 38 |
42 Node* start() { return this->graph()->start(); } | 39 Node* start() { return this->graph()->start(); } |
43 | 40 |
44 template <typename T> | 41 template <typename T> |
45 T* CallWithPotentialGC() { | 42 T* CallWithPotentialGC() { |
46 // TODO(titzer): we need to wrap the code in a JSFunction and call it via | 43 // TODO(titzer): we need to wrap the code in a JSFunction and call it via |
47 // Execution::Call() so that the GC knows about the frame, can walk it, | 44 // Execution::Call() so that the GC knows about the frame, can walk it, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 void BuildAndLower(Operator* op) { | 100 void BuildAndLower(Operator* op) { |
104 // We build a graph by hand here, because the raw machine assembler | 101 // We build a graph by hand here, because the raw machine assembler |
105 // does not add the correct control and effect nodes. | 102 // does not add the correct control and effect nodes. |
106 Node* p0 = this->Parameter(0); | 103 Node* p0 = this->Parameter(0); |
107 Node* change = this->graph()->NewNode(op, p0); | 104 Node* change = this->graph()->NewNode(op, p0); |
108 Node* ret = this->graph()->NewNode(this->common()->Return(), change, | 105 Node* ret = this->graph()->NewNode(this->common()->Return(), change, |
109 this->start(), this->start()); | 106 this->start(), this->start()); |
110 Node* end = this->graph()->NewNode(this->common()->End(), ret); | 107 Node* end = this->graph()->NewNode(this->common()->End(), ret); |
111 this->graph()->SetEnd(end); | 108 this->graph()->SetEnd(end); |
112 this->lowering.LowerChange(change, this->start(), this->start()); | 109 this->lowering.LowerChange(change, this->start(), this->start()); |
113 Verifier::Run(this->graph()); | 110 Verifier::Run(this->graph(), Verifier::UNTYPED); |
114 } | 111 } |
115 | 112 |
116 void BuildStoreAndLower(Operator* op, Operator* store_op, void* location) { | 113 void BuildStoreAndLower(Operator* op, Operator* store_op, void* location) { |
117 // We build a graph by hand here, because the raw machine assembler | 114 // We build a graph by hand here, because the raw machine assembler |
118 // does not add the correct control and effect nodes. | 115 // does not add the correct control and effect nodes. |
119 Node* p0 = this->Parameter(0); | 116 Node* p0 = this->Parameter(0); |
120 Node* change = this->graph()->NewNode(op, p0); | 117 Node* change = this->graph()->NewNode(op, p0); |
121 Node* store = this->graph()->NewNode( | 118 Node* store = this->graph()->NewNode( |
122 store_op, this->PointerConstant(location), this->Int32Constant(0), | 119 store_op, this->PointerConstant(location), this->Int32Constant(0), |
123 change, this->start(), this->start()); | 120 change, this->start(), this->start()); |
124 Node* ret = this->graph()->NewNode( | 121 Node* ret = this->graph()->NewNode( |
125 this->common()->Return(), this->Int32Constant(0), store, this->start()); | 122 this->common()->Return(), this->Int32Constant(0), store, this->start()); |
126 Node* end = this->graph()->NewNode(this->common()->End(), ret); | 123 Node* end = this->graph()->NewNode(this->common()->End(), ret); |
127 this->graph()->SetEnd(end); | 124 this->graph()->SetEnd(end); |
128 this->lowering.LowerChange(change, this->start(), this->start()); | 125 this->lowering.LowerChange(change, this->start(), this->start()); |
129 Verifier::Run(this->graph()); | 126 Verifier::Run(this->graph(), Verifier::UNTYPED); |
130 } | 127 } |
131 | 128 |
132 void BuildLoadAndLower(Operator* op, Operator* load_op, void* location) { | 129 void BuildLoadAndLower(Operator* op, Operator* load_op, void* location) { |
133 // We build a graph by hand here, because the raw machine assembler | 130 // We build a graph by hand here, because the raw machine assembler |
134 // does not add the correct control and effect nodes. | 131 // does not add the correct control and effect nodes. |
135 Node* load = | 132 Node* load = |
136 this->graph()->NewNode(load_op, this->PointerConstant(location), | 133 this->graph()->NewNode(load_op, this->PointerConstant(location), |
137 this->Int32Constant(0), this->start()); | 134 this->Int32Constant(0), this->start()); |
138 Node* change = this->graph()->NewNode(op, load); | 135 Node* change = this->graph()->NewNode(op, load); |
139 Node* ret = this->graph()->NewNode(this->common()->Return(), change, | 136 Node* ret = this->graph()->NewNode(this->common()->Return(), change, |
140 this->start(), this->start()); | 137 this->start(), this->start()); |
141 Node* end = this->graph()->NewNode(this->common()->End(), ret); | 138 Node* end = this->graph()->NewNode(this->common()->End(), ret); |
142 this->graph()->SetEnd(end); | 139 this->graph()->SetEnd(end); |
143 this->lowering.LowerChange(change, this->start(), this->start()); | 140 this->lowering.LowerChange(change, this->start(), this->start()); |
144 Verifier::Run(this->graph()); | 141 Verifier::Run(this->graph(), Verifier::UNTYPED); |
145 } | 142 } |
146 | 143 |
147 Factory* factory() { return this->isolate()->factory(); } | 144 Factory* factory() { return this->isolate()->factory(); } |
148 Heap* heap() { return this->isolate()->heap(); } | 145 Heap* heap() { return this->isolate()->heap(); } |
149 }; | 146 }; |
150 | 147 |
151 | 148 |
152 TEST(RunChangeTaggedToInt32) { | 149 TEST(RunChangeTaggedToInt32) { |
153 // Build and lower a graph by hand. | 150 // Build and lower a graph by hand. |
154 ChangesLoweringTester<int32_t> t(kMachAnyTagged); | 151 ChangesLoweringTester<int32_t> t(kMachAnyTagged); |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 | 386 |
390 if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { | 387 if (TODO_FLOAT64_TO_TAGGED && Pipeline::SupportedTarget()) { |
391 FOR_FLOAT64_INPUTS(i) { | 388 FOR_FLOAT64_INPUTS(i) { |
392 input = *i; | 389 input = *i; |
393 SimulateFullSpace(CcTest::heap()->new_space()); | 390 SimulateFullSpace(CcTest::heap()->new_space()); |
394 Object* result = t.CallWithPotentialGC<Object>(); | 391 Object* result = t.CallWithPotentialGC<Object>(); |
395 t.CheckNumber(input, result); | 392 t.CheckNumber(input, result); |
396 } | 393 } |
397 } | 394 } |
398 } | 395 } |
OLD | NEW |