OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, 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 #include <setjmp.h> | 5 #include <setjmp.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 | 7 |
8 #include "vm/globals.h" | 8 #include "vm/globals.h" |
9 #if defined(TARGET_ARCH_ARM64) | 9 #if defined(TARGET_ARCH_ARM64) |
10 | 10 |
(...skipping 598 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 return new Redirection(external_function, call_kind, argument_count); | 609 return new Redirection(external_function, call_kind, argument_count); |
610 } | 610 } |
611 | 611 |
612 static Redirection* FromHltInstruction(Instr* hlt_instruction) { | 612 static Redirection* FromHltInstruction(Instr* hlt_instruction) { |
613 char* addr_of_hlt = reinterpret_cast<char*>(hlt_instruction); | 613 char* addr_of_hlt = reinterpret_cast<char*>(hlt_instruction); |
614 char* addr_of_redirection = | 614 char* addr_of_redirection = |
615 addr_of_hlt - OFFSET_OF(Redirection, hlt_instruction_); | 615 addr_of_hlt - OFFSET_OF(Redirection, hlt_instruction_); |
616 return reinterpret_cast<Redirection*>(addr_of_redirection); | 616 return reinterpret_cast<Redirection*>(addr_of_redirection); |
617 } | 617 } |
618 | 618 |
| 619 static uword FunctionForRedirect(uword address_of_hlt) { |
| 620 Redirection* current; |
| 621 for (current = list_; current != NULL; current = current->next_) { |
| 622 if (current->address_of_hlt_instruction() == address_of_hlt) { |
| 623 return current->external_function_; |
| 624 } |
| 625 } |
| 626 return 0; |
| 627 } |
| 628 |
619 private: | 629 private: |
620 static const int32_t kRedirectInstruction = Instr::kRedirectInstruction; | 630 static const int32_t kRedirectInstruction = Instr::kRedirectInstruction; |
621 Redirection(uword external_function, | 631 Redirection(uword external_function, |
622 Simulator::CallKind call_kind, | 632 Simulator::CallKind call_kind, |
623 int argument_count) | 633 int argument_count) |
624 : external_function_(external_function), | 634 : external_function_(external_function), |
625 call_kind_(call_kind), | 635 call_kind_(call_kind), |
626 argument_count_(argument_count), | 636 argument_count_(argument_count), |
627 hlt_instruction_(kRedirectInstruction), | 637 hlt_instruction_(kRedirectInstruction), |
628 next_(list_) { | 638 next_(list_) { |
(...skipping 14 matching lines...) Expand all Loading... |
643 | 653 |
644 uword Simulator::RedirectExternalReference(uword function, | 654 uword Simulator::RedirectExternalReference(uword function, |
645 CallKind call_kind, | 655 CallKind call_kind, |
646 int argument_count) { | 656 int argument_count) { |
647 Redirection* redirection = | 657 Redirection* redirection = |
648 Redirection::Get(function, call_kind, argument_count); | 658 Redirection::Get(function, call_kind, argument_count); |
649 return redirection->address_of_hlt_instruction(); | 659 return redirection->address_of_hlt_instruction(); |
650 } | 660 } |
651 | 661 |
652 | 662 |
| 663 uword Simulator::FunctionForRedirect(uword redirect) { |
| 664 return Redirection::FunctionForRedirect(redirect); |
| 665 } |
| 666 |
| 667 |
653 // Get the active Simulator for the current isolate. | 668 // Get the active Simulator for the current isolate. |
654 Simulator* Simulator::Current() { | 669 Simulator* Simulator::Current() { |
655 Simulator* simulator = Isolate::Current()->simulator(); | 670 Simulator* simulator = Isolate::Current()->simulator(); |
656 if (simulator == NULL) { | 671 if (simulator == NULL) { |
657 simulator = new Simulator(); | 672 simulator = new Simulator(); |
658 Isolate::Current()->set_simulator(simulator); | 673 Isolate::Current()->set_simulator(simulator); |
659 } | 674 } |
660 return simulator; | 675 return simulator; |
661 } | 676 } |
662 | 677 |
(...skipping 2478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3141 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3156 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
3142 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3157 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
3143 buf->Longjmp(); | 3158 buf->Longjmp(); |
3144 } | 3159 } |
3145 | 3160 |
3146 } // namespace dart | 3161 } // namespace dart |
3147 | 3162 |
3148 #endif // !defined(HOST_ARCH_ARM64) | 3163 #endif // !defined(HOST_ARCH_ARM64) |
3149 | 3164 |
3150 #endif // defined TARGET_ARCH_ARM64 | 3165 #endif // defined TARGET_ARCH_ARM64 |
OLD | NEW |