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

Side by Side Diff: runtime/vm/unit_test.h

Issue 1192103004: VM: New calling convention for generated code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: preserve CODE_REG in ARM Integer_shl intrinsic. Created 5 years, 3 months 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
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef VM_UNIT_TEST_H_ 5 #ifndef VM_UNIT_TEST_H_
6 #define VM_UNIT_TEST_H_ 6 #define VM_UNIT_TEST_H_
7 7
8 #include "include/dart_native_api.h" 8 #include "include/dart_native_api.h"
9 9
10 #include "platform/globals.h" 10 #include "platform/globals.h"
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 ASSERT(assembler != NULL); 353 ASSERT(assembler != NULL);
354 } 354 }
355 ~AssemblerTest() { } 355 ~AssemblerTest() { }
356 356
357 Assembler* assembler() const { return assembler_; } 357 Assembler* assembler() const { return assembler_; }
358 358
359 const Code& code() const { return code_; } 359 const Code& code() const { return code_; }
360 360
361 uword entry() const { return code_.EntryPoint(); } 361 uword entry() const { return code_.EntryPoint(); }
362 362
363 // Invoke is used to call assembler test functions using the ABI calling 363 // Invoke/InvokeWithCode is used to call assembler test functions using the
364 // convention. 364 // ABI calling convention.
365 // ResultType is the return type of the assembler test function. 365 // ResultType is the return type of the assembler test function.
366 // ArgNType is the type of the Nth argument. 366 // ArgNType is the type of the Nth argument.
367 #if defined(USING_SIMULATOR) 367 #if defined(USING_SIMULATOR)
368 368
369 #if defined(ARCH_IS_64_BIT) 369 #if defined(ARCH_IS_64_BIT)
370 // TODO(fschneider): Make Invoke<> more general and work on 32-bit platforms. 370 // TODO(fschneider): Make InvokeWithCode<> more general and work on 32-bit.
371 // Since Simulator::Call always return a int64_t, bit_cast does not work 371 // Since Simulator::Call always return a int64_t, bit_cast does not work
372 // on 32-bit platforms when returning an int32_t. Since template functions 372 // on 32-bit platforms when returning an int32_t. Since template functions
373 // don't support partial specialization, we'd need to introduce a helper 373 // don't support partial specialization, we'd need to introduce a helper
374 // class to support 32-bit return types. 374 // class to support 32-bit return types.
375 template<typename ResultType> ResultType Invoke() { 375 template<typename ResultType> ResultType InvokeWithCode() {
376 const bool fp_return = is_double<ResultType>::value; 376 const bool fp_return = is_double<ResultType>::value;
377 const bool fp_args = false; 377 const bool fp_args = false;
378 return bit_cast<ResultType, int64_t>(Simulator::Current()->Call( 378 return bit_cast<ResultType, int64_t>(Simulator::Current()->Call(
379 bit_cast<intptr_t, uword>(entry()), 0, 0, 0, 0, fp_return, fp_args)); 379 bit_cast<intptr_t, uword>(entry()),
380 reinterpret_cast<intptr_t>(&code_), 0, 0, 0, fp_return, fp_args));
380 } 381 }
381 template<typename ResultType, typename Arg1Type> 382 template<typename ResultType, typename Arg1Type>
382 ResultType Invoke(Arg1Type arg1) { 383 ResultType InvokeWithCode(Arg1Type arg1) {
383 const bool fp_return = is_double<ResultType>::value; 384 const bool fp_return = is_double<ResultType>::value;
384 const bool fp_args = is_double<Arg1Type>::value; 385 const bool fp_args = is_double<Arg1Type>::value;
385 // TODO(fschneider): Support double arguments for simulator calls. 386 // TODO(fschneider): Support double arguments for simulator calls.
386 COMPILE_ASSERT(!fp_args); 387 COMPILE_ASSERT(!fp_args);
387 return bit_cast<ResultType, int64_t>(Simulator::Current()->Call( 388 return bit_cast<ResultType, int64_t>(Simulator::Current()->Call(
388 bit_cast<intptr_t, uword>(entry()), 389 bit_cast<intptr_t, uword>(entry()),
390 reinterpret_cast<intptr_t>(&code_),
389 reinterpret_cast<intptr_t>(arg1), 391 reinterpret_cast<intptr_t>(arg1),
390 0, 0, 0, fp_return, fp_args)); 392 0, 0, fp_return, fp_args));
391 } 393 }
392 #endif // ARCH_IS_64_BIT 394 #endif // ARCH_IS_64_BIT
393 395
394 template<typename ResultType, 396 template<typename ResultType,
395 typename Arg1Type, 397 typename Arg1Type,
396 typename Arg2Type, 398 typename Arg2Type,
397 typename Arg3Type> 399 typename Arg3Type>
398 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) { 400 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) {
399 // TODO(fschneider): Support double arguments for simulator calls. 401 // TODO(fschneider): Support double arguments for simulator calls.
400 COMPILE_ASSERT(is_void<ResultType>::value); 402 COMPILE_ASSERT(is_void<ResultType>::value);
401 COMPILE_ASSERT(!is_double<Arg1Type>::value); 403 COMPILE_ASSERT(!is_double<Arg1Type>::value);
402 COMPILE_ASSERT(!is_double<Arg2Type>::value); 404 COMPILE_ASSERT(!is_double<Arg2Type>::value);
403 COMPILE_ASSERT(!is_double<Arg3Type>::value); 405 COMPILE_ASSERT(!is_double<Arg3Type>::value);
404 const bool fp_args = false; 406 const bool fp_args = false;
405 const bool fp_return = false; 407 const bool fp_return = false;
406 Simulator::Current()->Call( 408 Simulator::Current()->Call(
407 bit_cast<intptr_t, uword>(entry()), 409 bit_cast<intptr_t, uword>(entry()),
408 reinterpret_cast<intptr_t>(arg1), 410 reinterpret_cast<intptr_t>(arg1),
409 reinterpret_cast<intptr_t>(arg2), 411 reinterpret_cast<intptr_t>(arg2),
410 reinterpret_cast<intptr_t>(arg3), 412 reinterpret_cast<intptr_t>(arg3),
411 0, fp_return, fp_args); 413 0, fp_return, fp_args);
412 } 414 }
413 #else 415 #else
414 template<typename ResultType> ResultType Invoke() { 416 template<typename ResultType> ResultType InvokeWithCode() {
415 typedef ResultType (*FunctionType) (); 417 typedef ResultType (*FunctionType) (const Code&);
416 return reinterpret_cast<FunctionType>(entry())(); 418 return reinterpret_cast<FunctionType>(entry())(code_);
417 } 419 }
418 420
419 template<typename ResultType, typename Arg1Type> 421 template<typename ResultType, typename Arg1Type>
420 ResultType Invoke(Arg1Type arg1) { 422 ResultType InvokeWithCode(Arg1Type arg1) {
421 typedef ResultType (*FunctionType) (Arg1Type); 423 typedef ResultType (*FunctionType) (const Code&, Arg1Type);
422 return reinterpret_cast<FunctionType>(entry())(arg1); 424 return reinterpret_cast<FunctionType>(entry())(code_, arg1);
423 } 425 }
424 426
425 template<typename ResultType, 427 template<typename ResultType,
426 typename Arg1Type, 428 typename Arg1Type,
427 typename Arg2Type, 429 typename Arg2Type,
428 typename Arg3Type> 430 typename Arg3Type>
429 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) { 431 ResultType Invoke(Arg1Type arg1, Arg2Type arg2, Arg3Type arg3) {
430 typedef ResultType (*FunctionType) (Arg1Type, Arg2Type, Arg3Type); 432 typedef ResultType (*FunctionType) (Arg1Type, Arg2Type, Arg3Type);
431 return reinterpret_cast<FunctionType>(entry())(arg1, arg2, arg3); 433 return reinterpret_cast<FunctionType>(entry())(arg1, arg2, arg3);
432 } 434 }
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 // Yields: 537 // Yields:
536 // 538 //
537 // out = "\"id\":\"\"" 539 // out = "\"id\":\"\""
538 // 540 //
539 void ElideJSONSubstring(const char* prefix, const char* in, char* out); 541 void ElideJSONSubstring(const char* prefix, const char* in, char* out);
540 542
541 543
542 } // namespace dart 544 } // namespace dart
543 545
544 #endif // VM_UNIT_TEST_H_ 546 #endif // VM_UNIT_TEST_H_
OLDNEW
« runtime/vm/stub_code_arm.cc ('K') | « runtime/vm/thread.h ('k') | runtime/vm/weak_code.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698