| 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 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return new Redirection(external_function, call_kind, argument_count); | 623 return new Redirection(external_function, call_kind, argument_count); |
| 624 } | 624 } |
| 625 | 625 |
| 626 static Redirection* FromHltInstruction(Instr* hlt_instruction) { | 626 static Redirection* FromHltInstruction(Instr* hlt_instruction) { |
| 627 char* addr_of_hlt = reinterpret_cast<char*>(hlt_instruction); | 627 char* addr_of_hlt = reinterpret_cast<char*>(hlt_instruction); |
| 628 char* addr_of_redirection = | 628 char* addr_of_redirection = |
| 629 addr_of_hlt - OFFSET_OF(Redirection, hlt_instruction_); | 629 addr_of_hlt - OFFSET_OF(Redirection, hlt_instruction_); |
| 630 return reinterpret_cast<Redirection*>(addr_of_redirection); | 630 return reinterpret_cast<Redirection*>(addr_of_redirection); |
| 631 } | 631 } |
| 632 | 632 |
| 633 static uword FunctionForRedirect(uword address_of_hlt) { |
| 634 Redirection* current; |
| 635 for (current = list_; current != NULL; current = current->next_) { |
| 636 if (current->address_of_hlt_instruction() == address_of_hlt) { |
| 637 return current->external_function_; |
| 638 } |
| 639 } |
| 640 return 0; |
| 641 } |
| 642 |
| 633 private: | 643 private: |
| 634 static const int32_t kRedirectInstruction = Instr::kRedirectInstruction; | 644 static const int32_t kRedirectInstruction = Instr::kRedirectInstruction; |
| 635 Redirection(uword external_function, | 645 Redirection(uword external_function, |
| 636 Simulator::CallKind call_kind, | 646 Simulator::CallKind call_kind, |
| 637 int argument_count) | 647 int argument_count) |
| 638 : external_function_(external_function), | 648 : external_function_(external_function), |
| 639 call_kind_(call_kind), | 649 call_kind_(call_kind), |
| 640 argument_count_(argument_count), | 650 argument_count_(argument_count), |
| 641 hlt_instruction_(kRedirectInstruction), | 651 hlt_instruction_(kRedirectInstruction), |
| 642 next_(list_) { | 652 next_(list_) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 657 | 667 |
| 658 uword Simulator::RedirectExternalReference(uword function, | 668 uword Simulator::RedirectExternalReference(uword function, |
| 659 CallKind call_kind, | 669 CallKind call_kind, |
| 660 int argument_count) { | 670 int argument_count) { |
| 661 Redirection* redirection = | 671 Redirection* redirection = |
| 662 Redirection::Get(function, call_kind, argument_count); | 672 Redirection::Get(function, call_kind, argument_count); |
| 663 return redirection->address_of_hlt_instruction(); | 673 return redirection->address_of_hlt_instruction(); |
| 664 } | 674 } |
| 665 | 675 |
| 666 | 676 |
| 677 uword Simulator::FunctionForRedirect(uword redirect) { |
| 678 return Redirection::FunctionForRedirect(redirect); |
| 679 } |
| 680 |
| 681 |
| 667 // Get the active Simulator for the current isolate. | 682 // Get the active Simulator for the current isolate. |
| 668 Simulator* Simulator::Current() { | 683 Simulator* Simulator::Current() { |
| 669 Simulator* simulator = Isolate::Current()->simulator(); | 684 Simulator* simulator = Isolate::Current()->simulator(); |
| 670 if (simulator == NULL) { | 685 if (simulator == NULL) { |
| 671 simulator = new Simulator(); | 686 simulator = new Simulator(); |
| 672 Isolate::Current()->set_simulator(simulator); | 687 Isolate::Current()->set_simulator(simulator); |
| 673 } | 688 } |
| 674 return simulator; | 689 return simulator; |
| 675 } | 690 } |
| 676 | 691 |
| (...skipping 2577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3254 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); | 3269 set_register(NULL, kExceptionObjectReg, bit_cast<int64_t>(raw_exception)); |
| 3255 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); | 3270 set_register(NULL, kStackTraceObjectReg, bit_cast<int64_t>(raw_stacktrace)); |
| 3256 buf->Longjmp(); | 3271 buf->Longjmp(); |
| 3257 } | 3272 } |
| 3258 | 3273 |
| 3259 } // namespace dart | 3274 } // namespace dart |
| 3260 | 3275 |
| 3261 #endif // !defined(HOST_ARCH_ARM64) | 3276 #endif // !defined(HOST_ARCH_ARM64) |
| 3262 | 3277 |
| 3263 #endif // defined TARGET_ARCH_ARM64 | 3278 #endif // defined TARGET_ARCH_ARM64 |
| OLD | NEW |