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 #ifndef V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
6 #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 #include "test/cctest/cctest.h" | 9 #include "test/cctest/cctest.h" |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 protected: | 30 protected: |
31 virtual Node* MakeNode(Operator* op, int value_input_count, | 31 virtual Node* MakeNode(Operator* op, int value_input_count, |
32 Node** value_inputs) { | 32 Node** value_inputs) { |
33 return graph()->NewNode(op, value_input_count, value_inputs); | 33 return graph()->NewNode(op, value_input_count, value_inputs); |
34 } | 34 } |
35 }; | 35 }; |
36 | 36 |
37 | 37 |
38 class MachineCallHelper : public CallHelper { | 38 class MachineCallHelper : public CallHelper { |
39 public: | 39 public: |
40 MachineCallHelper(Zone* zone, MachineCallDescriptorBuilder* builder); | 40 MachineCallHelper(Zone* zone, MachineSignature* machine_sig); |
41 | 41 |
42 Node* Parameter(int offset); | 42 Node* Parameter(size_t index); |
43 | 43 |
44 void GenerateCode() { Generate(); } | 44 void GenerateCode() { Generate(); } |
45 | 45 |
46 protected: | 46 protected: |
47 virtual byte* Generate(); | 47 virtual byte* Generate(); |
48 virtual void VerifyParameters(int parameter_count, MachineType* parameters); | |
49 void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common); | 48 void InitParameters(GraphBuilder* builder, CommonOperatorBuilder* common); |
50 | 49 |
51 protected: | 50 protected: |
52 int parameter_count() const { | 51 size_t parameter_count() const { return machine_sig_->parameter_count(); } |
53 return call_descriptor_builder_->parameter_count(); | |
54 } | |
55 | 52 |
56 private: | 53 private: |
57 MachineCallDescriptorBuilder* call_descriptor_builder_; | |
58 Node** parameters_; | 54 Node** parameters_; |
59 // TODO(dcarney): shouldn't need graph stored. | 55 // TODO(dcarney): shouldn't need graph stored. |
60 Graph* graph_; | 56 Graph* graph_; |
61 MaybeHandle<Code> code_; | 57 MaybeHandle<Code> code_; |
62 }; | 58 }; |
63 | 59 |
64 | 60 |
65 class GraphAndBuilders { | 61 class GraphAndBuilders { |
66 public: | 62 public: |
67 explicit GraphAndBuilders(Zone* zone) | 63 explicit GraphAndBuilders(Zone* zone) |
(...skipping 20 matching lines...) Expand all Loading... |
88 public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > { | 84 public CallHelper2<ReturnType, GraphBuilderTester<ReturnType> > { |
89 public: | 85 public: |
90 explicit GraphBuilderTester(MachineType p0 = kMachNone, | 86 explicit GraphBuilderTester(MachineType p0 = kMachNone, |
91 MachineType p1 = kMachNone, | 87 MachineType p1 = kMachNone, |
92 MachineType p2 = kMachNone, | 88 MachineType p2 = kMachNone, |
93 MachineType p3 = kMachNone, | 89 MachineType p3 = kMachNone, |
94 MachineType p4 = kMachNone) | 90 MachineType p4 = kMachNone) |
95 : GraphAndBuilders(main_zone()), | 91 : GraphAndBuilders(main_zone()), |
96 MachineCallHelper( | 92 MachineCallHelper( |
97 main_zone(), | 93 main_zone(), |
98 ToCallDescriptorBuilder( | 94 MakeMachineSignature( |
99 main_zone(), ReturnValueTraits<ReturnType>::Representation(), | 95 main_zone(), ReturnValueTraits<ReturnType>::Representation(), |
100 p0, p1, p2, p3, p4)), | 96 p0, p1, p2, p3, p4)), |
101 SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_, | 97 SimplifiedGraphBuilder(main_graph_, &main_common_, &main_machine_, |
102 &main_simplified_) { | 98 &main_simplified_) { |
103 Begin(parameter_count()); | 99 Begin(static_cast<int>(parameter_count())); |
104 InitParameters(this, &main_common_); | 100 InitParameters(this, &main_common_); |
105 } | 101 } |
106 virtual ~GraphBuilderTester() {} | 102 virtual ~GraphBuilderTester() {} |
107 | 103 |
108 Factory* factory() const { return isolate()->factory(); } | 104 Factory* factory() const { return isolate()->factory(); } |
109 }; | 105 }; |
110 } // namespace compiler | 106 } // namespace compiler |
111 } // namespace internal | 107 } // namespace internal |
112 } // namespace v8 | 108 } // namespace v8 |
113 | 109 |
114 #endif // V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ | 110 #endif // V8_CCTEST_COMPILER_GRAPH_BUILDER_TESTER_H_ |
OLD | NEW |