Reviewers: dstence, joransiu, john.yan, Michael Starzinger,
Description:
PPC: Make Simulator respect C stack limits as well.
Port 7fb31bdba4f2a0320507956a085f083d76bce48c
Original commit message:
The simulator uses a separate JS stack, exhaustion of the C stack
however is not caught by JS limit checks. This change now lowers the
limit of the JS stack accordingly on function calls.
[email protected], [email protected], [email protected],
[email protected]
BUG=chromium:522380
LOG=n
Please review this at https://codereview.chromium.org/1309303005/
Base URL: https://chromium.googlesource.com/v8/v8.git@master
Affected files (+18, -9 lines):
M src/ppc/simulator-ppc.h
M src/ppc/simulator-ppc.cc
Index: src/ppc/simulator-ppc.cc
diff --git a/src/ppc/simulator-ppc.cc b/src/ppc/simulator-ppc.cc
index
bcc775370e79fac78092b316559f49db78955712..518f8fae758e682ff847a4184b8653054c51b3c8
100644
--- a/src/ppc/simulator-ppc.cc
+++ b/src/ppc/simulator-ppc.cc
@@ -1106,8 +1106,15 @@ void Simulator::WriteDW(intptr_t addr, int64_t
value) {
// Returns the limit of the stack area to enable checking for stack
overflows.
-uintptr_t Simulator::StackLimit() const {
- // Leave a safety margin to prevent overrunning the stack when pushing
values.
+uintptr_t Simulator::StackLimit(uintptr_t c_limit) const {
+ // The simulator uses a separate JS stack. If we have exhausted the C
stack,
+ // we also drop down the JS limit to reflect the exhaustion on the JS
stack.
+ if (GetCurrentStackPosition() < c_limit) {
+ return reinterpret_cast<uintptr_t>(get_sp());
+ }
+
+ // Otherwise the limit is the JS stack. Leave a safety margin to prevent
+ // overrunning the stack when pushing values.
return reinterpret_cast<uintptr_t>(stack_) + stack_protection_size_;
}
@@ -3698,6 +3705,9 @@ void Simulator::Execute() {
void Simulator::CallInternal(byte* entry) {
+ // Adjust JS-based stack limit to C-based stack limit.
+ isolate_->stack_guard()->AdjustStackLimitForSimulator();
+
// Prepare to execute the code at entry
#if ABI_USES_FUNCTION_DESCRIPTORS
// entry is the function descriptor
Index: src/ppc/simulator-ppc.h
diff --git a/src/ppc/simulator-ppc.h b/src/ppc/simulator-ppc.h
index
fe655ff582cdb6eefd8c3efd4c214505f24f8563..042b2ada2c6edf51d9489870c36395cf52f0a81c
100644
--- a/src/ppc/simulator-ppc.h
+++ b/src/ppc/simulator-ppc.h
@@ -199,12 +199,12 @@ class Simulator {
void set_pc(intptr_t value);
intptr_t get_pc() const;
- Address get_sp() {
+ Address get_sp() const {
return
reinterpret_cast<Address>(static_cast<intptr_t>(get_register(sp)));
}
// Accessor to the internal simulator stack area.
- uintptr_t StackLimit() const;
+ uintptr_t StackLimit(uintptr_t c_limit) const;
// Executes PPC instructions until the PC reaches end_sim_pc.
void Execute();
@@ -403,15 +403,14 @@ class Simulator {
// The simulator has its own stack. Thus it has a different stack limit
from
-// the C-based native code. Setting the c_limit to indicate a very small
-// stack cause stack overflow errors, since the simulator ignores the
input.
-// This is unlikely to be an issue in practice, though it might cause
testing
-// trouble down the line.
+// the C-based native code. The JS-based limit normally points near the
end of
+// the simulator stack. When the C-based limit is exhausted we reflect
that by
+// lowering the JS-based limit as well, to make stack checks trigger.
class SimulatorStack : public v8::internal::AllStatic {
public:
static inline uintptr_t JsLimitFromCLimit(v8::internal::Isolate* isolate,
uintptr_t c_limit) {
- return Simulator::current(isolate)->StackLimit();
+ return Simulator::current(isolate)->StackLimit(c_limit);
}
static inline uintptr_t RegisterCTryCatch(uintptr_t try_catch_address) {
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.