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 "test/cctest/compiler/graph-builder-tester.h" | 5 #include "test/cctest/compiler/graph-builder-tester.h" |
6 | 6 |
7 #include "src/compiler/linkage.h" | 7 #include "src/compiler/linkage.h" |
8 #include "src/compiler/pipeline.h" | 8 #include "src/compiler/pipeline.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 namespace compiler { | 12 namespace compiler { |
13 | 13 |
14 MachineCallHelper::MachineCallHelper(Zone* zone, MachineSignature* machine_sig) | 14 MachineCallHelper::MachineCallHelper(Isolate* isolate, |
15 : CallHelper(zone->isolate(), machine_sig), | 15 MachineSignature* machine_sig) |
| 16 : CallHelper(isolate, machine_sig), |
16 parameters_(NULL), | 17 parameters_(NULL), |
| 18 isolate_(isolate), |
17 graph_(NULL) {} | 19 graph_(NULL) {} |
18 | 20 |
19 | 21 |
20 void MachineCallHelper::InitParameters(GraphBuilder* builder, | 22 void MachineCallHelper::InitParameters(GraphBuilder* builder, |
21 CommonOperatorBuilder* common) { | 23 CommonOperatorBuilder* common) { |
22 DCHECK_EQ(NULL, parameters_); | 24 DCHECK_EQ(NULL, parameters_); |
23 graph_ = builder->graph(); | 25 graph_ = builder->graph(); |
24 int param_count = static_cast<int>(parameter_count()); | 26 int param_count = static_cast<int>(parameter_count()); |
25 if (param_count == 0) return; | 27 if (param_count == 0) return; |
26 parameters_ = graph_->zone()->NewArray<Node*>(param_count); | 28 parameters_ = graph_->zone()->NewArray<Node*>(param_count); |
27 for (int i = 0; i < param_count; ++i) { | 29 for (int i = 0; i < param_count; ++i) { |
28 parameters_[i] = builder->NewNode(common->Parameter(i), graph_->start()); | 30 parameters_[i] = builder->NewNode(common->Parameter(i), graph_->start()); |
29 } | 31 } |
30 } | 32 } |
31 | 33 |
32 | 34 |
33 byte* MachineCallHelper::Generate() { | 35 byte* MachineCallHelper::Generate() { |
34 DCHECK(parameter_count() == 0 || parameters_ != NULL); | 36 DCHECK(parameter_count() == 0 || parameters_ != NULL); |
35 if (!Pipeline::SupportedBackend()) return NULL; | 37 if (!Pipeline::SupportedBackend()) return NULL; |
36 if (code_.is_null()) { | 38 if (code_.is_null()) { |
37 Zone* zone = graph_->zone(); | 39 Zone* zone = graph_->zone(); |
38 CallDescriptor* desc = | 40 CallDescriptor* desc = |
39 Linkage::GetSimplifiedCDescriptor(zone, machine_sig_); | 41 Linkage::GetSimplifiedCDescriptor(zone, machine_sig_); |
40 code_ = Pipeline::GenerateCodeForTesting(desc, graph_); | 42 code_ = Pipeline::GenerateCodeForTesting(isolate_, desc, graph_); |
41 } | 43 } |
42 return code_.ToHandleChecked()->entry(); | 44 return code_.ToHandleChecked()->entry(); |
43 } | 45 } |
44 | 46 |
45 | 47 |
46 Node* MachineCallHelper::Parameter(size_t index) { | 48 Node* MachineCallHelper::Parameter(size_t index) { |
47 DCHECK_NE(NULL, parameters_); | 49 DCHECK_NE(NULL, parameters_); |
48 DCHECK(index < parameter_count()); | 50 DCHECK(index < parameter_count()); |
49 return parameters_[index]; | 51 return parameters_[index]; |
50 } | 52 } |
51 | 53 |
52 } // namespace compiler | 54 } // namespace compiler |
53 } // namespace internal | 55 } // namespace internal |
54 } // namespace v8 | 56 } // namespace v8 |
OLD | NEW |