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

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

Issue 1174693002: PPC64: Adjust simulator stack safety margin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Keep 32-bit simulator stack size at 1MB. Created 5 years, 6 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
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 <stdarg.h> 5 #include <stdarg.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after
787 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { 787 Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
788 i_cache_ = isolate_->simulator_i_cache(); 788 i_cache_ = isolate_->simulator_i_cache();
789 if (i_cache_ == NULL) { 789 if (i_cache_ == NULL) {
790 i_cache_ = new v8::internal::HashMap(&ICacheMatch); 790 i_cache_ = new v8::internal::HashMap(&ICacheMatch);
791 isolate_->set_simulator_i_cache(i_cache_); 791 isolate_->set_simulator_i_cache(i_cache_);
792 } 792 }
793 Initialize(isolate); 793 Initialize(isolate);
794 // Set up simulator support first. Some of this information is needed to 794 // Set up simulator support first. Some of this information is needed to
795 // setup the architecture state. 795 // setup the architecture state.
796 #if V8_TARGET_ARCH_PPC64 796 #if V8_TARGET_ARCH_PPC64
797 size_t stack_size = 2 * 1024 * 1024; // allocate 2MB for stack 797 size_t stack_size = FLAG_sim_stack_size * KB;
798 #else 798 #else
799 size_t stack_size = 1 * 1024 * 1024; // allocate 1MB for stack 799 size_t stack_size = MB; // allocate 1MB for stack
800 #endif 800 #endif
801 stack_size += 2 * stack_protection_size_;
801 stack_ = reinterpret_cast<char*>(malloc(stack_size)); 802 stack_ = reinterpret_cast<char*>(malloc(stack_size));
802 pc_modified_ = false; 803 pc_modified_ = false;
803 icount_ = 0; 804 icount_ = 0;
804 break_pc_ = NULL; 805 break_pc_ = NULL;
805 break_instr_ = 0; 806 break_instr_ = 0;
806 807
807 // Set up architecture state. 808 // Set up architecture state.
808 // All registers are initialized to zero to start with. 809 // All registers are initialized to zero to start with.
809 for (int i = 0; i < kNumGPRs; i++) { 810 for (int i = 0; i < kNumGPRs; i++) {
810 registers_[i] = 0; 811 registers_[i] = 0;
811 } 812 }
812 condition_reg_ = 0; 813 condition_reg_ = 0;
813 fp_condition_reg_ = 0; 814 fp_condition_reg_ = 0;
814 special_reg_pc_ = 0; 815 special_reg_pc_ = 0;
815 special_reg_lr_ = 0; 816 special_reg_lr_ = 0;
816 special_reg_ctr_ = 0; 817 special_reg_ctr_ = 0;
817 818
818 // Initializing FP registers. 819 // Initializing FP registers.
819 for (int i = 0; i < kNumFPRs; i++) { 820 for (int i = 0; i < kNumFPRs; i++) {
820 fp_registers_[i] = 0.0; 821 fp_registers_[i] = 0.0;
821 } 822 }
822 823
823 // The sp is initialized to point to the bottom (high address) of the 824 // The sp is initialized to point to the bottom (high address) of the
824 // allocated stack area. To be safe in potential stack underflows we leave 825 // allocated stack area. To be safe in potential stack underflows we leave
825 // some buffer below. 826 // some buffer below.
826 registers_[sp] = reinterpret_cast<intptr_t>(stack_) + stack_size - 64; 827 registers_[sp] =
828 reinterpret_cast<intptr_t>(stack_) + stack_size - stack_protection_size_;
827 InitializeCoverage(); 829 InitializeCoverage();
828 830
829 last_debugger_input_ = NULL; 831 last_debugger_input_ = NULL;
830 } 832 }
831 833
832 834
833 Simulator::~Simulator() { free(stack_); } 835 Simulator::~Simulator() { free(stack_); }
834 836
835 837
836 // When the generated code calls an external reference we need to catch that in 838 // When the generated code calls an external reference we need to catch that in
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
1100 1102
1101 void Simulator::WriteDW(intptr_t addr, int64_t value) { 1103 void Simulator::WriteDW(intptr_t addr, int64_t value) {
1102 int64_t* ptr = reinterpret_cast<int64_t*>(addr); 1104 int64_t* ptr = reinterpret_cast<int64_t*>(addr);
1103 *ptr = value; 1105 *ptr = value;
1104 return; 1106 return;
1105 } 1107 }
1106 1108
1107 1109
1108 // Returns the limit of the stack area to enable checking for stack overflows. 1110 // Returns the limit of the stack area to enable checking for stack overflows.
1109 uintptr_t Simulator::StackLimit() const { 1111 uintptr_t Simulator::StackLimit() const {
1110 // Leave a safety margin of 1024 bytes to prevent overrunning the stack when 1112 // Leave a safety margin to prevent overrunning the stack when pushing values.
1111 // pushing values. 1113 return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_;
1112 return reinterpret_cast<uintptr_t>(stack_) + 1024;
1113 } 1114 }
1114 1115
1115 1116
1116 // Unsupported instructions use Format to print an error and stop execution. 1117 // Unsupported instructions use Format to print an error and stop execution.
1117 void Simulator::Format(Instruction* instr, const char* format) { 1118 void Simulator::Format(Instruction* instr, const char* format) {
1118 PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", 1119 PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n",
1119 reinterpret_cast<intptr_t>(instr), format); 1120 reinterpret_cast<intptr_t>(instr), format);
1120 UNIMPLEMENTED(); 1121 UNIMPLEMENTED();
1121 } 1122 }
1122 1123
(...skipping 2773 matching lines...) Expand 10 before | Expand all | Expand 10 after
3896 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 3897 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3897 uintptr_t address = *stack_slot; 3898 uintptr_t address = *stack_slot;
3898 set_register(sp, current_sp + sizeof(uintptr_t)); 3899 set_register(sp, current_sp + sizeof(uintptr_t));
3899 return address; 3900 return address;
3900 } 3901 }
3901 } // namespace internal 3902 } // namespace internal
3902 } // namespace v8 3903 } // namespace v8
3903 3904
3904 #endif // USE_SIMULATOR 3905 #endif // USE_SIMULATOR
3905 #endif // V8_TARGET_ARCH_PPC 3906 #endif // V8_TARGET_ARCH_PPC
OLDNEW
« no previous file with comments | « src/ppc/simulator-ppc.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698