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_CALL_TESTER_H_ | 5 #ifndef V8_CCTEST_COMPILER_CALL_TESTER_H_ |
6 #define V8_CCTEST_COMPILER_CALL_TESTER_H_ | 6 #define V8_CCTEST_COMPILER_CALL_TESTER_H_ |
7 | 7 |
8 #include "src/simulator.h" | 8 #include "src/simulator.h" |
9 #include "test/cctest/compiler/c-signature.h" | 9 #include "test/cctest/compiler/c-signature.h" |
10 | 10 |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return static_cast<int64_t>(static_cast<int32_t>(r)); | 112 return static_cast<int64_t>(static_cast<int32_t>(r)); |
113 } | 113 } |
114 }; | 114 }; |
115 | 115 |
116 #endif // !V8_TARGET_ARCH_64_BIT | 116 #endif // !V8_TARGET_ARCH_64_BIT |
117 | 117 |
118 | 118 |
119 template <typename R> | 119 template <typename R> |
120 class CallHelper { | 120 class CallHelper { |
121 public: | 121 public: |
122 explicit CallHelper(Isolate* isolate, CSignature* csig) | 122 explicit CallHelper(Isolate* isolate, MachineSignature* csig) |
123 : csig_(csig), isolate_(isolate) { | 123 : csig_(csig), isolate_(isolate) { |
124 USE(isolate_); | 124 USE(isolate_); |
125 } | 125 } |
126 virtual ~CallHelper() {} | 126 virtual ~CallHelper() {} |
127 | 127 |
128 R Call() { | 128 R Call() { |
129 typedef R V8_CDECL FType(); | 129 typedef R V8_CDECL FType(); |
130 csig_->VerifyParams(); | 130 CSignature::VerifyParams(csig_); |
131 return DoCall(FUNCTION_CAST<FType*>(Generate())); | 131 return DoCall(FUNCTION_CAST<FType*>(Generate())); |
132 } | 132 } |
133 | 133 |
134 template <typename P1> | 134 template <typename P1> |
135 R Call(P1 p1) { | 135 R Call(P1 p1) { |
136 typedef R V8_CDECL FType(P1); | 136 typedef R V8_CDECL FType(P1); |
137 csig_->VerifyParams<P1>(); | 137 CSignature::VerifyParams<P1>(csig_); |
138 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1); | 138 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1); |
139 } | 139 } |
140 | 140 |
141 template <typename P1, typename P2> | 141 template <typename P1, typename P2> |
142 R Call(P1 p1, P2 p2) { | 142 R Call(P1 p1, P2 p2) { |
143 typedef R V8_CDECL FType(P1, P2); | 143 typedef R V8_CDECL FType(P1, P2); |
144 csig_->VerifyParams<P1, P2>(); | 144 CSignature::VerifyParams<P1, P2>(csig_); |
145 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2); | 145 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2); |
146 } | 146 } |
147 | 147 |
148 template <typename P1, typename P2, typename P3> | 148 template <typename P1, typename P2, typename P3> |
149 R Call(P1 p1, P2 p2, P3 p3) { | 149 R Call(P1 p1, P2 p2, P3 p3) { |
150 typedef R V8_CDECL FType(P1, P2, P3); | 150 typedef R V8_CDECL FType(P1, P2, P3); |
151 csig_->VerifyParams<P1, P2, P3>(); | 151 CSignature::VerifyParams<P1, P2, P3>(csig_); |
152 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3); | 152 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3); |
153 } | 153 } |
154 | 154 |
155 template <typename P1, typename P2, typename P3, typename P4> | 155 template <typename P1, typename P2, typename P3, typename P4> |
156 R Call(P1 p1, P2 p2, P3 p3, P4 p4) { | 156 R Call(P1 p1, P2 p2, P3 p3, P4 p4) { |
157 typedef R V8_CDECL FType(P1, P2, P3, P4); | 157 typedef R V8_CDECL FType(P1, P2, P3, P4); |
158 csig_->VerifyParams<P1, P2, P3, P4>(); | 158 CSignature::VerifyParams<P1, P2, P3, P4>(csig_); |
159 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4); | 159 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4); |
160 } | 160 } |
161 | 161 |
162 template <typename P1, typename P2, typename P3, typename P4, typename P5> | 162 template <typename P1, typename P2, typename P3, typename P4, typename P5> |
163 R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { | 163 R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) { |
164 typedef R V8_CDECL FType(P1, P2, P3, P4, P5); | 164 typedef R V8_CDECL FType(P1, P2, P3, P4, P5); |
165 csig_->VerifyParams<P1, P2, P3, P4, P5>(); | 165 CSignature::VerifyParams<P1, P2, P3, P4, P5>(csig_); |
166 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4, p5); | 166 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4, p5); |
167 } | 167 } |
168 | 168 |
169 protected: | 169 protected: |
170 CSignature* csig_; | 170 MachineSignature* csig_; |
171 | 171 |
172 virtual byte* Generate() = 0; | 172 virtual byte* Generate() = 0; |
173 | 173 |
174 private: | 174 private: |
175 #if USE_SIMULATOR && V8_TARGET_ARCH_ARM64 | 175 #if USE_SIMULATOR && V8_TARGET_ARCH_ARM64 |
176 uintptr_t CallSimulator(byte* f, Simulator::CallArgument* args) { | 176 uintptr_t CallSimulator(byte* f, Simulator::CallArgument* args) { |
177 Simulator* simulator = Simulator::current(isolate_); | 177 Simulator* simulator = Simulator::current(isolate_); |
178 return static_cast<uintptr_t>(simulator->CallInt64(f, args)); | 178 return static_cast<uintptr_t>(simulator->CallInt64(f, args)); |
179 } | 179 } |
180 | 180 |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
335 } | 335 } |
336 #endif | 336 #endif |
337 | 337 |
338 Isolate* isolate_; | 338 Isolate* isolate_; |
339 }; | 339 }; |
340 | 340 |
341 // A call helper that calls the given code object assuming C calling convention. | 341 // A call helper that calls the given code object assuming C calling convention. |
342 template <typename T> | 342 template <typename T> |
343 class CodeRunner : public CallHelper<T> { | 343 class CodeRunner : public CallHelper<T> { |
344 public: | 344 public: |
345 CodeRunner(Isolate* isolate, Handle<Code> code, CSignature* csig) | 345 CodeRunner(Isolate* isolate, Handle<Code> code, MachineSignature* csig) |
346 : CallHelper<T>(isolate, csig), code_(code) {} | 346 : CallHelper<T>(isolate, csig), code_(code) {} |
347 virtual ~CodeRunner() {} | 347 virtual ~CodeRunner() {} |
348 | 348 |
349 virtual byte* Generate() { return code_->entry(); } | 349 virtual byte* Generate() { return code_->entry(); } |
350 | 350 |
351 private: | 351 private: |
352 Handle<Code> code_; | 352 Handle<Code> code_; |
353 }; | 353 }; |
354 | 354 |
355 | 355 |
356 } // namespace compiler | 356 } // namespace compiler |
357 } // namespace internal | 357 } // namespace internal |
358 } // namespace v8 | 358 } // namespace v8 |
359 | 359 |
360 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_ | 360 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_ |
OLD | NEW |