| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ARM) | 9 #if defined(TARGET_ARCH_ARM) |
| 10 | 10 |
| (...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 return new Redirection(external_function, call_kind, argument_count); | 820 return new Redirection(external_function, call_kind, argument_count); |
| 821 } | 821 } |
| 822 | 822 |
| 823 static Redirection* FromSvcInstruction(Instr* svc_instruction) { | 823 static Redirection* FromSvcInstruction(Instr* svc_instruction) { |
| 824 char* addr_of_svc = reinterpret_cast<char*>(svc_instruction); | 824 char* addr_of_svc = reinterpret_cast<char*>(svc_instruction); |
| 825 char* addr_of_redirection = | 825 char* addr_of_redirection = |
| 826 addr_of_svc - OFFSET_OF(Redirection, svc_instruction_); | 826 addr_of_svc - OFFSET_OF(Redirection, svc_instruction_); |
| 827 return reinterpret_cast<Redirection*>(addr_of_redirection); | 827 return reinterpret_cast<Redirection*>(addr_of_redirection); |
| 828 } | 828 } |
| 829 | 829 |
| 830 static uword FunctionForRedirect(uword address_of_svc) { |
| 831 Redirection* current; |
| 832 for (current = list_; current != NULL; current = current->next_) { |
| 833 if (current->address_of_svc_instruction() == address_of_svc) { |
| 834 return current->external_function_; |
| 835 } |
| 836 } |
| 837 return 0; |
| 838 } |
| 839 |
| 830 private: | 840 private: |
| 831 static const int32_t kRedirectSvcInstruction = | 841 static const int32_t kRedirectSvcInstruction = |
| 832 ((AL << kConditionShift) | (0xf << 24) | kRedirectionSvcCode); | 842 ((AL << kConditionShift) | (0xf << 24) | kRedirectionSvcCode); |
| 833 Redirection(uword external_function, | 843 Redirection(uword external_function, |
| 834 Simulator::CallKind call_kind, | 844 Simulator::CallKind call_kind, |
| 835 int argument_count) | 845 int argument_count) |
| 836 : external_function_(external_function), | 846 : external_function_(external_function), |
| 837 call_kind_(call_kind), | 847 call_kind_(call_kind), |
| 838 argument_count_(argument_count), | 848 argument_count_(argument_count), |
| 839 svc_instruction_(kRedirectSvcInstruction), | 849 svc_instruction_(kRedirectSvcInstruction), |
| (...skipping 15 matching lines...) Expand all Loading... |
| 855 | 865 |
| 856 uword Simulator::RedirectExternalReference(uword function, | 866 uword Simulator::RedirectExternalReference(uword function, |
| 857 CallKind call_kind, | 867 CallKind call_kind, |
| 858 int argument_count) { | 868 int argument_count) { |
| 859 Redirection* redirection = | 869 Redirection* redirection = |
| 860 Redirection::Get(function, call_kind, argument_count); | 870 Redirection::Get(function, call_kind, argument_count); |
| 861 return redirection->address_of_svc_instruction(); | 871 return redirection->address_of_svc_instruction(); |
| 862 } | 872 } |
| 863 | 873 |
| 864 | 874 |
| 875 uword Simulator::FunctionForRedirect(uword redirect) { |
| 876 return Redirection::FunctionForRedirect(redirect); |
| 877 } |
| 878 |
| 879 |
| 865 // Get the active Simulator for the current isolate. | 880 // Get the active Simulator for the current isolate. |
| 866 Simulator* Simulator::Current() { | 881 Simulator* Simulator::Current() { |
| 867 Simulator* simulator = Isolate::Current()->simulator(); | 882 Simulator* simulator = Isolate::Current()->simulator(); |
| 868 if (simulator == NULL) { | 883 if (simulator == NULL) { |
| 869 simulator = new Simulator(); | 884 simulator = new Simulator(); |
| 870 Isolate::Current()->set_simulator(simulator); | 885 Isolate::Current()->set_simulator(simulator); |
| 871 } | 886 } |
| 872 return simulator; | 887 return simulator; |
| 873 } | 888 } |
| 874 | 889 |
| (...skipping 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3859 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); | 3874 set_register(kExceptionObjectReg, bit_cast<int32_t>(raw_exception)); |
| 3860 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); | 3875 set_register(kStackTraceObjectReg, bit_cast<int32_t>(raw_stacktrace)); |
| 3861 buf->Longjmp(); | 3876 buf->Longjmp(); |
| 3862 } | 3877 } |
| 3863 | 3878 |
| 3864 } // namespace dart | 3879 } // namespace dart |
| 3865 | 3880 |
| 3866 #endif // !defined(HOST_ARCH_ARM) | 3881 #endif // !defined(HOST_ARCH_ARM) |
| 3867 | 3882 |
| 3868 #endif // defined TARGET_ARCH_ARM | 3883 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |