summaryrefslogtreecommitdiff
path: root/rts
diff options
context:
space:
mode:
authorSimon Marlow <simonmar@microsoft.com>2007-05-03 15:19:41 +0000
committerSimon Marlow <simonmar@microsoft.com>2007-05-03 15:19:41 +0000
commitefb02b428941021771c9b9b955bba3ec0214dbaf (patch)
tree184324c0ea010c2d1afc5f7cb94b051b31d31ab0 /rts
parent10406dfbd1a90e0ca813cc2809719263642d9a97 (diff)
downloadhaskell-efb02b428941021771c9b9b955bba3ec0214dbaf.tar.gz
Use a primop for getting the fields of the AP_STACK rather than an FFI call
This means we can avoid some StablePtrs, and also catch cases where the AP_STACK has been evaluated (this can happen with :history, see the hist001 test).
Diffstat (limited to 'rts')
-rw-r--r--rts/Interpreter.c19
-rw-r--r--rts/PrimOps.cmm15
2 files changed, 10 insertions, 24 deletions
diff --git a/rts/Interpreter.c b/rts/Interpreter.c
index c40d894613..fbbda9d14f 100644
--- a/rts/Interpreter.c
+++ b/rts/Interpreter.c
@@ -1375,25 +1375,6 @@ run_BCO:
barf("interpretBCO: fell off end of the interpreter");
}
-/* temporary code for peeking inside a AP_STACK and pulling out values
- based on their stack offset - used in the debugger for inspecting
- the local values of a breakpoint
-*/
-HsStablePtr rts_getApStackVal (HsStablePtr, int);
-HsStablePtr rts_getApStackVal (HsStablePtr apStackSptr, int offset)
-{
- HsStablePtr resultSptr;
- StgAP_STACK *apStack;
- StgClosure **payload;
- StgClosure *val;
-
- apStack = (StgAP_STACK *) deRefStablePtr (apStackSptr);
- payload = apStack->payload;
- val = (StgClosure *) payload[offset+2];
- resultSptr = getStablePtr ((P_)val);
- return resultSptr;
-}
-
/* set the single step flag for the debugger to True -
it gets set back to false in the interpreter everytime
we hit a breakpoint
diff --git a/rts/PrimOps.cmm b/rts/PrimOps.cmm
index bb9faddef5..cd34846925 100644
--- a/rts/PrimOps.cmm
+++ b/rts/PrimOps.cmm
@@ -2165,13 +2165,18 @@ noDuplicatezh_fast
getApStackValzh_fast
{
- W_ ap_stack, offset, val;
+ W_ ap_stack, offset, val, ok;
- /* args: R1 = tso, R2 = offset */
+ /* args: R1 = AP_STACK, R2 = offset */
ap_stack = R1;
offset = R2;
- val = StgClosure_payload(ap_stack,offset);
-
- RET_P(val);
+ if (%INFO_PTR(ap_stack) == stg_AP_STACK_info) {
+ ok = 1;
+ val = StgAP_STACK_payload(ap_stack,offset);
+ } else {
+ ok = 0;
+ val = R1;
+ }
+ RET_NP(ok,val);
}