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

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

Issue 1309303005: PPC: Make Simulator respect C stack limits as well. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 3 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 #if V8_TARGET_ARCH_PPC 9 #if V8_TARGET_ARCH_PPC
10 10
(...skipping 1088 matching lines...) Expand 10 before | Expand all | Expand 10 after
1099 1099
1100 1100
1101 void Simulator::WriteDW(intptr_t addr, int64_t value) { 1101 void Simulator::WriteDW(intptr_t addr, int64_t value) {
1102 int64_t* ptr = reinterpret_cast<int64_t*>(addr); 1102 int64_t* ptr = reinterpret_cast<int64_t*>(addr);
1103 *ptr = value; 1103 *ptr = value;
1104 return; 1104 return;
1105 } 1105 }
1106 1106
1107 1107
1108 // Returns the limit of the stack area to enable checking for stack overflows. 1108 // Returns the limit of the stack area to enable checking for stack overflows.
1109 uintptr_t Simulator::StackLimit() const { 1109 uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
1110 // Leave a safety margin to prevent overrunning the stack when pushing values. 1110 // The simulator uses a separate JS stack. If we have exhausted the C stack,
1111 // we also drop down the JS limit to reflect the exhaustion on the JS stack.
1112 if (GetCurrentStackPosition() < c_limit) {
1113 return reinterpret_cast<uintptr_t>(get_sp());
1114 }
1115
1116 // Otherwise the limit is the JS stack. Leave a safety margin to prevent
1117 // overrunning the stack when pushing values.
1111 return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_; 1118 return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_;
1112 } 1119 }
1113 1120
1114 1121
1115 // Unsupported instructions use Format to print an error and stop execution. 1122 // Unsupported instructions use Format to print an error and stop execution.
1116 void Simulator::Format(Instruction* instr, const char* format) { 1123 void Simulator::Format(Instruction* instr, const char* format) {
1117 PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", 1124 PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n",
1118 reinterpret_cast<intptr_t>(instr), format); 1125 reinterpret_cast<intptr_t>(instr), format);
1119 UNIMPLEMENTED(); 1126 UNIMPLEMENTED();
1120 } 1127 }
(...skipping 2570 matching lines...) Expand 10 before | Expand all | Expand 10 after
3691 } else { 3698 } else {
3692 ExecuteInstruction(instr); 3699 ExecuteInstruction(instr);
3693 } 3700 }
3694 program_counter = get_pc(); 3701 program_counter = get_pc();
3695 } 3702 }
3696 } 3703 }
3697 } 3704 }
3698 3705
3699 3706
3700 void Simulator::CallInternal(byte* entry) { 3707 void Simulator::CallInternal(byte* entry) {
3708 // Adjust JS-based stack limit to C-based stack limit.
3709 isolate_->stack_guard()->AdjustStackLimitForSimulator();
3710
3701 // Prepare to execute the code at entry 3711 // Prepare to execute the code at entry
3702 #if ABI_USES_FUNCTION_DESCRIPTORS 3712 #if ABI_USES_FUNCTION_DESCRIPTORS
3703 // entry is the function descriptor 3713 // entry is the function descriptor
3704 set_pc(*(reinterpret_cast<intptr_t*>(entry))); 3714 set_pc(*(reinterpret_cast<intptr_t*>(entry)));
3705 #else 3715 #else
3706 // entry is the instruction address 3716 // entry is the instruction address
3707 set_pc(reinterpret_cast<intptr_t>(entry)); 3717 set_pc(reinterpret_cast<intptr_t>(entry));
3708 #endif 3718 #endif
3709 3719
3710 // Put down marker for end of simulation. The simulator will stop simulation 3720 // Put down marker for end of simulation. The simulator will stop simulation
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
3883 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 3893 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
3884 uintptr_t address = *stack_slot; 3894 uintptr_t address = *stack_slot;
3885 set_register(sp, current_sp + sizeof(uintptr_t)); 3895 set_register(sp, current_sp + sizeof(uintptr_t));
3886 return address; 3896 return address;
3887 } 3897 }
3888 } // namespace internal 3898 } // namespace internal
3889 } // namespace v8 3899 } // namespace v8
3890 3900
3891 #endif // USE_SIMULATOR 3901 #endif // USE_SIMULATOR
3892 #endif // V8_TARGET_ARCH_PPC 3902 #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