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

Side by Side Diff: src/arm64/simulator-arm64.cc

Issue 1457223005: Remove a bunch of Isolate::Current() callsites from simulators (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 | « src/arm64/simulator-arm64.h ('k') | src/assembler.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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 #include <stdlib.h> 5 #include <stdlib.h>
6 #include <cmath> 6 #include <cmath>
7 #include <cstdarg> 7 #include <cstdarg>
8 8
9 #if V8_TARGET_ARCH_ARM64 9 #if V8_TARGET_ARCH_ARM64
10 10
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 455
456 // When the generated code calls an external reference we need to catch that in 456 // When the generated code calls an external reference we need to catch that in
457 // the simulator. The external reference will be a function compiled for the 457 // the simulator. The external reference will be a function compiled for the
458 // host architecture. We need to call that function instead of trying to 458 // host architecture. We need to call that function instead of trying to
459 // execute it with the simulator. We do that by redirecting the external 459 // execute it with the simulator. We do that by redirecting the external
460 // reference to a svc (Supervisor Call) instruction that is handled by 460 // reference to a svc (Supervisor Call) instruction that is handled by
461 // the simulator. We write the original destination of the jump just at a known 461 // the simulator. We write the original destination of the jump just at a known
462 // offset from the svc instruction so the simulator knows what to call. 462 // offset from the svc instruction so the simulator knows what to call.
463 class Redirection { 463 class Redirection {
464 public: 464 public:
465 Redirection(void* external_function, ExternalReference::Type type) 465 Redirection(Isolate* isolate, void* external_function,
466 : external_function_(external_function), 466 ExternalReference::Type type)
467 type_(type), 467 : external_function_(external_function), type_(type), next_(NULL) {
468 next_(NULL) {
469 redirect_call_.SetInstructionBits( 468 redirect_call_.SetInstructionBits(
470 HLT | Assembler::ImmException(kImmExceptionIsRedirectedCall)); 469 HLT | Assembler::ImmException(kImmExceptionIsRedirectedCall));
471 Isolate* isolate = Isolate::Current();
472 next_ = isolate->simulator_redirection(); 470 next_ = isolate->simulator_redirection();
473 // TODO(all): Simulator flush I cache 471 // TODO(all): Simulator flush I cache
474 isolate->set_simulator_redirection(this); 472 isolate->set_simulator_redirection(this);
475 } 473 }
476 474
477 void* address_of_redirect_call() { 475 void* address_of_redirect_call() {
478 return reinterpret_cast<void*>(&redirect_call_); 476 return reinterpret_cast<void*>(&redirect_call_);
479 } 477 }
480 478
481 template <typename T> 479 template <typename T>
482 T external_function() { return reinterpret_cast<T>(external_function_); } 480 T external_function() { return reinterpret_cast<T>(external_function_); }
483 481
484 ExternalReference::Type type() { return type_; } 482 ExternalReference::Type type() { return type_; }
485 483
486 static Redirection* Get(void* external_function, 484 static Redirection* Get(Isolate* isolate, void* external_function,
487 ExternalReference::Type type) { 485 ExternalReference::Type type) {
488 Isolate* isolate = Isolate::Current();
489 Redirection* current = isolate->simulator_redirection(); 486 Redirection* current = isolate->simulator_redirection();
490 for (; current != NULL; current = current->next_) { 487 for (; current != NULL; current = current->next_) {
491 if (current->external_function_ == external_function) { 488 if (current->external_function_ == external_function) {
492 DCHECK_EQ(current->type(), type); 489 DCHECK_EQ(current->type(), type);
493 return current; 490 return current;
494 } 491 }
495 } 492 }
496 return new Redirection(external_function, type); 493 return new Redirection(isolate, external_function, type);
497 } 494 }
498 495
499 static Redirection* FromHltInstruction(Instruction* redirect_call) { 496 static Redirection* FromHltInstruction(Instruction* redirect_call) {
500 char* addr_of_hlt = reinterpret_cast<char*>(redirect_call); 497 char* addr_of_hlt = reinterpret_cast<char*>(redirect_call);
501 char* addr_of_redirection = 498 char* addr_of_redirection =
502 addr_of_hlt - offsetof(Redirection, redirect_call_); 499 addr_of_hlt - offsetof(Redirection, redirect_call_);
503 return reinterpret_cast<Redirection*>(addr_of_redirection); 500 return reinterpret_cast<Redirection*>(addr_of_redirection);
504 } 501 }
505 502
506 static void* ReverseRedirection(int64_t reg) { 503 static void* ReverseRedirection(int64_t reg) {
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
741 #endif 738 #endif
742 break; 739 break;
743 } 740 }
744 } 741 }
745 742
746 set_lr(return_address); 743 set_lr(return_address);
747 set_pc(return_address); 744 set_pc(return_address);
748 } 745 }
749 746
750 747
751 void* Simulator::RedirectExternalReference(void* external_function, 748 void* Simulator::RedirectExternalReference(Isolate* isolate,
749 void* external_function,
752 ExternalReference::Type type) { 750 ExternalReference::Type type) {
753 Redirection* redirection = Redirection::Get(external_function, type); 751 Redirection* redirection = Redirection::Get(isolate, external_function, type);
754 return redirection->address_of_redirect_call(); 752 return redirection->address_of_redirect_call();
755 } 753 }
756 754
757 755
758 const char* Simulator::xreg_names[] = { 756 const char* Simulator::xreg_names[] = {
759 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7", 757 "x0", "x1", "x2", "x3", "x4", "x5", "x6", "x7",
760 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15", 758 "x8", "x9", "x10", "x11", "x12", "x13", "x14", "x15",
761 "ip0", "ip1", "x18", "x19", "x20", "x21", "x22", "x23", 759 "ip0", "ip1", "x18", "x19", "x20", "x21", "x22", "x23",
762 "x24", "x25", "x26", "cp", "jssp", "fp", "lr", "xzr", "csp"}; 760 "x24", "x25", "x26", "cp", "jssp", "fp", "lr", "xzr", "csp"};
763 761
(...skipping 2739 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 } else { 3501 } else {
3504 UNREACHABLE(); 3502 UNREACHABLE();
3505 } 3503 }
3506 end = cur + words; 3504 end = cur + words;
3507 3505
3508 while (cur < end) { 3506 while (cur < end) {
3509 PrintF(" 0x%016" PRIx64 ": 0x%016" PRIx64 " %10" PRId64, 3507 PrintF(" 0x%016" PRIx64 ": 0x%016" PRIx64 " %10" PRId64,
3510 reinterpret_cast<uint64_t>(cur), *cur, *cur); 3508 reinterpret_cast<uint64_t>(cur), *cur, *cur);
3511 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); 3509 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur);
3512 int64_t value = *cur; 3510 int64_t value = *cur;
3513 Heap* current_heap = v8::internal::Isolate::Current()->heap(); 3511 Heap* current_heap = isolate_->heap();
3514 if (((value & 1) == 0) || current_heap->Contains(obj)) { 3512 if (((value & 1) == 0) || current_heap->Contains(obj)) {
3515 PrintF(" ("); 3513 PrintF(" (");
3516 if ((value & kSmiTagMask) == 0) { 3514 if ((value & kSmiTagMask) == 0) {
3517 STATIC_ASSERT(kSmiValueSize == 32); 3515 STATIC_ASSERT(kSmiValueSize == 32);
3518 int32_t untagged = (value >> kSmiShift) & 0xffffffff; 3516 int32_t untagged = (value >> kSmiShift) & 0xffffffff;
3519 PrintF("smi %" PRId32, untagged); 3517 PrintF("smi %" PRId32, untagged);
3520 } else { 3518 } else {
3521 obj->ShortPrint(); 3519 obj->ShortPrint();
3522 } 3520 }
3523 PrintF(")"); 3521 PrintF(")");
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
3838 delete[] format; 3836 delete[] format;
3839 } 3837 }
3840 3838
3841 3839
3842 #endif // USE_SIMULATOR 3840 #endif // USE_SIMULATOR
3843 3841
3844 } // namespace internal 3842 } // namespace internal
3845 } // namespace v8 3843 } // namespace v8
3846 3844
3847 #endif // V8_TARGET_ARCH_ARM64 3845 #endif // V8_TARGET_ARCH_ARM64
OLDNEW
« no previous file with comments | « src/arm64/simulator-arm64.h ('k') | src/assembler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698