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

Side by Side Diff: test/cctest/compiler/call-tester.h

Issue 1423133005: Implemented the BufferedRawMachineAssemblerTester. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fixed the test case parameter values. Created 5 years, 1 month 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/c-signature.h ('k') | test/cctest/compiler/codegen-tester.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 csig_->VerifyParams<P1, P2, P3, P4>();
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>
163 R Call(P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
164 typedef R V8_CDECL FType(P1, P2, P3, P4, P5);
165 csig_->VerifyParams<P1, P2, P3, P4, P5>();
166 return DoCall(FUNCTION_CAST<FType*>(Generate()), p1, p2, p3, p4, p5);
167 }
168
162 protected: 169 protected:
163 CSignature* csig_; 170 CSignature* csig_;
164 171
165 virtual byte* Generate() = 0; 172 virtual byte* Generate() = 0;
166 173
167 private: 174 private:
168 #if USE_SIMULATOR && V8_TARGET_ARCH_ARM64 175 #if USE_SIMULATOR && V8_TARGET_ARCH_ARM64
169 uintptr_t CallSimulator(byte* f, Simulator::CallArgument* args) { 176 uintptr_t CallSimulator(byte* f, Simulator::CallArgument* args) {
170 Simulator* simulator = Simulator::current(isolate_); 177 Simulator* simulator = Simulator::current(isolate_);
171 return static_cast<uintptr_t>(simulator->CallInt64(f, args)); 178 return static_cast<uintptr_t>(simulator->CallInt64(f, args));
(...skipping 25 matching lines...) Expand all
197 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args)); 204 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args));
198 } 205 }
199 template <typename F, typename P1, typename P2, typename P3, typename P4> 206 template <typename F, typename P1, typename P2, typename P3, typename P4>
200 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { 207 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) {
201 Simulator::CallArgument args[] = { 208 Simulator::CallArgument args[] = {
202 Simulator::CallArgument(p1), Simulator::CallArgument(p2), 209 Simulator::CallArgument(p1), Simulator::CallArgument(p2),
203 Simulator::CallArgument(p3), Simulator::CallArgument(p4), 210 Simulator::CallArgument(p3), Simulator::CallArgument(p4),
204 Simulator::CallArgument::End()}; 211 Simulator::CallArgument::End()};
205 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args)); 212 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args));
206 } 213 }
214 template <typename F, typename P1, typename P2, typename P3, typename P4,
215 typename P5>
216 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
217 Simulator::CallArgument args[] = {
218 Simulator::CallArgument(p1), Simulator::CallArgument(p2),
219 Simulator::CallArgument(p3), Simulator::CallArgument(p4),
220 Simulator::CallArgument(p5), Simulator::CallArgument::End()};
221 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), args));
222 }
207 #elif USE_SIMULATOR && (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64) 223 #elif USE_SIMULATOR && (V8_TARGET_ARCH_MIPS64 || V8_TARGET_ARCH_PPC64)
208 uintptr_t CallSimulator(byte* f, int64_t p1 = 0, int64_t p2 = 0, 224 uintptr_t CallSimulator(byte* f, int64_t p1 = 0, int64_t p2 = 0,
209 int64_t p3 = 0, int64_t p4 = 0) { 225 int64_t p3 = 0, int64_t p4 = 0, int64_t p5 = 0) {
210 Simulator* simulator = Simulator::current(isolate_); 226 Simulator* simulator = Simulator::current(isolate_);
211 return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); 227 return static_cast<uintptr_t>(simulator->Call(f, 5, p1, p2, p3, p4, p5));
212 } 228 }
213 229
214 230
215 template <typename F> 231 template <typename F>
216 R DoCall(F* f) { 232 R DoCall(F* f) {
217 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f))); 233 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f)));
218 } 234 }
219 template <typename F, typename P1> 235 template <typename F, typename P1>
220 R DoCall(F* f, P1 p1) { 236 R DoCall(F* f, P1 p1) {
221 return CastReturnValue<R>( 237 return CastReturnValue<R>(
(...skipping 11 matching lines...) Expand all
233 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), 249 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
234 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3))); 250 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3)));
235 } 251 }
236 template <typename F, typename P1, typename P2, typename P3, typename P4> 252 template <typename F, typename P1, typename P2, typename P3, typename P4>
237 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { 253 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) {
238 return CastReturnValue<R>(CallSimulator( 254 return CastReturnValue<R>(CallSimulator(
239 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), 255 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
240 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), 256 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3),
241 ParameterTraits<P4>::Cast(p4))); 257 ParameterTraits<P4>::Cast(p4)));
242 } 258 }
259 template <typename F, typename P1, typename P2, typename P3, typename P4,
260 typename P5>
261 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
262 return CastReturnValue<R>(CallSimulator(
263 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
264 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3),
265 ParameterTraits<P4>::Cast(p4), ParameterTraits<P5>::Cast(p5)));
266 }
243 #elif USE_SIMULATOR && \ 267 #elif USE_SIMULATOR && \
244 (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC) 268 (V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_PPC)
245 uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0, 269 uintptr_t CallSimulator(byte* f, int32_t p1 = 0, int32_t p2 = 0,
246 int32_t p3 = 0, int32_t p4 = 0) { 270 int32_t p3 = 0, int32_t p4 = 0, int32_t p5 = 0) {
247 Simulator* simulator = Simulator::current(isolate_); 271 Simulator* simulator = Simulator::current(isolate_);
248 return static_cast<uintptr_t>(simulator->Call(f, 4, p1, p2, p3, p4)); 272 return static_cast<uintptr_t>(simulator->Call(f, 5, p1, p2, p3, p4, p5));
249 } 273 }
250 template <typename F> 274 template <typename F>
251 R DoCall(F* f) { 275 R DoCall(F* f) {
252 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f))); 276 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f)));
253 } 277 }
254 template <typename F, typename P1> 278 template <typename F, typename P1>
255 R DoCall(F* f, P1 p1) { 279 R DoCall(F* f, P1 p1) {
256 return CastReturnValue<R>( 280 return CastReturnValue<R>(
257 CallSimulator(FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1))); 281 CallSimulator(FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1)));
258 } 282 }
259 template <typename F, typename P1, typename P2> 283 template <typename F, typename P1, typename P2>
260 R DoCall(F* f, P1 p1, P2 p2) { 284 R DoCall(F* f, P1 p1, P2 p2) {
261 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f), 285 return CastReturnValue<R>(CallSimulator(FUNCTION_ADDR(f),
262 ParameterTraits<P1>::Cast(p1), 286 ParameterTraits<P1>::Cast(p1),
263 ParameterTraits<P2>::Cast(p2))); 287 ParameterTraits<P2>::Cast(p2)));
264 } 288 }
265 template <typename F, typename P1, typename P2, typename P3> 289 template <typename F, typename P1, typename P2, typename P3>
266 R DoCall(F* f, P1 p1, P2 p2, P3 p3) { 290 R DoCall(F* f, P1 p1, P2 p2, P3 p3) {
267 return CastReturnValue<R>(CallSimulator( 291 return CastReturnValue<R>(CallSimulator(
268 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), 292 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
269 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3))); 293 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3)));
270 } 294 }
271 template <typename F, typename P1, typename P2, typename P3, typename P4> 295 template <typename F, typename P1, typename P2, typename P3, typename P4>
272 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { 296 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) {
273 return CastReturnValue<R>(CallSimulator( 297 return CastReturnValue<R>(CallSimulator(
274 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1), 298 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
275 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3), 299 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3),
276 ParameterTraits<P4>::Cast(p4))); 300 ParameterTraits<P4>::Cast(p4)));
277 } 301 }
302 template <typename F, typename P1, typename P2, typename P3, typename P4,
303 typename P5>
304 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
305 return CastReturnValue<R>(CallSimulator(
306 FUNCTION_ADDR(f), ParameterTraits<P1>::Cast(p1),
307 ParameterTraits<P2>::Cast(p2), ParameterTraits<P3>::Cast(p3),
308 ParameterTraits<P4>::Cast(p4), ParameterTraits<P5>::Cast(p5)));
309 }
278 #else 310 #else
279 template <typename F> 311 template <typename F>
280 R DoCall(F* f) { 312 R DoCall(F* f) {
281 return f(); 313 return f();
282 } 314 }
283 template <typename F, typename P1> 315 template <typename F, typename P1>
284 R DoCall(F* f, P1 p1) { 316 R DoCall(F* f, P1 p1) {
285 return f(p1); 317 return f(p1);
286 } 318 }
287 template <typename F, typename P1, typename P2> 319 template <typename F, typename P1, typename P2>
288 R DoCall(F* f, P1 p1, P2 p2) { 320 R DoCall(F* f, P1 p1, P2 p2) {
289 return f(p1, p2); 321 return f(p1, p2);
290 } 322 }
291 template <typename F, typename P1, typename P2, typename P3> 323 template <typename F, typename P1, typename P2, typename P3>
292 R DoCall(F* f, P1 p1, P2 p2, P3 p3) { 324 R DoCall(F* f, P1 p1, P2 p2, P3 p3) {
293 return f(p1, p2, p3); 325 return f(p1, p2, p3);
294 } 326 }
295 template <typename F, typename P1, typename P2, typename P3, typename P4> 327 template <typename F, typename P1, typename P2, typename P3, typename P4>
296 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) { 328 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4) {
297 return f(p1, p2, p3, p4); 329 return f(p1, p2, p3, p4);
298 } 330 }
331 template <typename F, typename P1, typename P2, typename P3, typename P4,
332 typename P5>
333 R DoCall(F* f, P1 p1, P2 p2, P3 p3, P4 p4, P5 p5) {
334 return f(p1, p2, p3, p4, p5);
335 }
299 #endif 336 #endif
300 337
301 Isolate* isolate_; 338 Isolate* isolate_;
302 }; 339 };
303 340
304 // 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.
305 template <typename T> 342 template <typename T>
306 class CodeRunner : public CallHelper<T> { 343 class CodeRunner : public CallHelper<T> {
307 public: 344 public:
308 CodeRunner(Isolate* isolate, Handle<Code> code, CSignature* csig) 345 CodeRunner(Isolate* isolate, Handle<Code> code, CSignature* csig)
309 : CallHelper<T>(isolate, csig), code_(code) {} 346 : CallHelper<T>(isolate, csig), code_(code) {}
310 virtual ~CodeRunner() {} 347 virtual ~CodeRunner() {}
311 348
312 virtual byte* Generate() { return code_->entry(); } 349 virtual byte* Generate() { return code_->entry(); }
313 350
314 private: 351 private:
315 Handle<Code> code_; 352 Handle<Code> code_;
316 }; 353 };
317 354
318 355
319 } // namespace compiler 356 } // namespace compiler
320 } // namespace internal 357 } // namespace internal
321 } // namespace v8 358 } // namespace v8
322 359
323 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_ 360 #endif // V8_CCTEST_COMPILER_CALL_TESTER_H_
OLDNEW
« no previous file with comments | « test/cctest/compiler/c-signature.h ('k') | test/cctest/compiler/codegen-tester.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698