Commit 0856ac59 authored by Simon Marlow's avatar Simon Marlow

micro-opt: replace stmGetEnclosingTRec() with a field access

While fixing #3578 I noticed that this function was just a field
access to StgTRecHeader, so I inlined it manually.
parent c5f93af1
......@@ -342,6 +342,8 @@ main(int argc, char *argv[])
closure_field(StgAtomicInvariant, code);
closure_field(StgTRecHeader, enclosing_trec);
closure_size(StgCatchSTMFrame);
closure_field(StgCatchSTMFrame, handler);
closure_field(StgCatchSTMFrame, code);
......
......@@ -398,7 +398,7 @@ retry_pop_stack:
W_ r;
trec = StgTSO_trec(CurrentTSO);
(r) = foreign "C" stmValidateNestOfTransactions(trec "ptr") [];
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
foreign "C" stmAbortTransaction(MyCapability() "ptr", trec "ptr") [];
foreign "C" stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr") [];
......@@ -498,7 +498,7 @@ retry_pop_stack:
} else {
W_ trec, outer;
trec = StgTSO_trec(CurrentTSO);
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
foreign "C" stmAbortTransaction(MyCapability() "ptr", trec "ptr") [];
foreign "C" stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr") [];
StgTSO_trec(CurrentTSO) = outer;
......
......@@ -650,7 +650,7 @@ INFO_TABLE_RET(stg_catch_retry_frame, CATCH_RETRY_FRAME,
frame = Sp;
trec = StgTSO_trec(CurrentTSO);
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
(r) = foreign "C" stmCommitNestedTransaction(MyCapability() "ptr", trec "ptr") [];
if (r != 0) {
/* Succeeded (either first branch or second branch) */
......@@ -685,7 +685,7 @@ INFO_TABLE_RET(stg_atomically_frame, ATOMICALLY_FRAME,
frame = Sp;
trec = StgTSO_trec(CurrentTSO);
result = R1;
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
if (outer == NO_TREC) {
/* First time back at the atomically frame -- pick up invariants */
......@@ -782,7 +782,7 @@ INFO_TABLE_RET(stg_catch_stm_frame, CATCH_STM_FRAME,
W_ r, frame, trec, outer;
frame = Sp;
trec = StgTSO_trec(CurrentTSO);
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
(r) = foreign "C" stmCommitNestedTransaction(MyCapability() "ptr", trec "ptr") [];
if (r != 0) {
/* Commit succeeded */
......@@ -917,7 +917,7 @@ retry_pop_stack:
Sp = StgTSO_sp(CurrentTSO);
frame = Sp;
trec = StgTSO_trec(CurrentTSO);
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
if (frame_type == CATCH_RETRY_FRAME) {
// The retry reaches a CATCH_RETRY_FRAME before the atomic frame
......@@ -950,7 +950,7 @@ retry_pop_stack:
foreign "C" stmFreeAbortedTRec(MyCapability() "ptr", trec "ptr") [];
trec = outer;
StgTSO_trec(CurrentTSO) = trec;
("ptr" outer) = foreign "C" stmGetEnclosingTRec(trec "ptr") [];
outer = StgTRecHeader_enclosing_trec(trec);
}
ASSERT(outer == NO_TREC);
......
......@@ -884,7 +884,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
case ATOMICALLY_FRAME:
if (stop_at_atomically) {
ASSERT(stmGetEnclosingTRec(tso->trec) == NO_TREC);
ASSERT(tso->trec->enclosing_trec == NO_TREC);
stmCondemnTransaction(cap, tso -> trec);
tso->sp = frame - 2;
// The ATOMICALLY_FRAME expects to be returned a
......@@ -914,7 +914,7 @@ raiseAsync(Capability *cap, StgTSO *tso, StgClosure *exception,
{
StgTRecHeader *trec = tso -> trec;
StgTRecHeader *outer = stmGetEnclosingTRec(trec);
StgTRecHeader *outer = trec -> enclosing_trec;
debugTrace(DEBUG_stm,
"found atomically block delivering async exception");
stmAbortTransaction(cap, trec);
......
......@@ -1026,16 +1026,6 @@ void stmCondemnTransaction(Capability *cap,
/*......................................................................*/
StgTRecHeader *stmGetEnclosingTRec(StgTRecHeader *trec) {
StgTRecHeader *outer;
TRACE("%p : stmGetEnclosingTRec", trec);
outer = trec -> enclosing_trec;
TRACE("%p : stmGetEnclosingTRec()=%p", trec, outer);
return outer;
}
/*......................................................................*/
StgBool stmValidateNestOfTransactions(StgTRecHeader *trec) {
StgTRecHeader *t;
StgBool result;
......
......@@ -83,13 +83,6 @@ void stmFreeAbortedTRec(Capability *cap, StgTRecHeader *trec);
void stmCondemnTransaction(Capability *cap, StgTRecHeader *trec);
/*
* Return the trec within which the specified trec was created (not
* valid if trec==NO_TREC).
*/
StgTRecHeader *stmGetEnclosingTRec(StgTRecHeader *trec);
/*----------------------------------------------------------------------
Validation
......
......@@ -1062,7 +1062,7 @@ schedulePostRunThread (Capability *cap, StgTSO *t)
// partially-evaluated thunks on the heap.
throwToSingleThreaded_(cap, t, NULL, rtsTrue);
ASSERT(get_itbl((StgClosure *)t->sp)->type == ATOMICALLY_FRAME);
// ASSERT(get_itbl((StgClosure *)t->sp)->type == ATOMICALLY_FRAME);
}
}
......@@ -2564,7 +2564,7 @@ findRetryFrameHelper (StgTSO *tso)
case CATCH_STM_FRAME: {
StgTRecHeader *trec = tso -> trec;
StgTRecHeader *outer = stmGetEnclosingTRec(trec);
StgTRecHeader *outer = trec -> enclosing_trec;
debugTrace(DEBUG_stm,
"found CATCH_STM_FRAME at %p during retry", p);
debugTrace(DEBUG_stm, "trec=%p outer=%p", trec, outer);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment