Skip to content

Commit

Permalink
Avoid generating getSelf/setSelf instructions for class with lock…
Browse files Browse the repository at this point in the history
…ing.
  • Loading branch information
kennytm committed Sep 21, 2014
1 parent 625270b commit d329869
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
29 changes: 8 additions & 21 deletions lib/compiler/CodeGen.oz
Original file line number Diff line number Diff line change
Expand Up @@ -861,8 +861,7 @@ define
StateReg = none
end
case @toCopy of unit then
FormalRegs AllRegs AllRegs2 BodyVInter BodyVInstr GRegs Code VInter
Cont1 Cont2
FormalRegs AllRegs AllRegs2 BodyVInter GRegs Code Cont1 Cont2
in
{CS startDefinition()}
FormalRegs = {Map @formalArgs
Expand All @@ -876,21 +875,16 @@ define
elseof Vs then {GetRegs Vs}
end
case StateReg of none then
BodyVInstr = BodyVInter
VHd0 = VInter
AllRegs2 = AllRegs
else
BodyVInstr = vSetSelf(_ StateReg BodyVInter)
VHd0 = vGetSelf(_ StateReg VInter)
AllRegs2 = StateReg|AllRegs
end
{CS endDefinition(BodyVInstr FormalRegs AllRegs2 ?GRegs ?Code
{CS endDefinition(BodyVInter FormalRegs AllRegs2 ?GRegs ?Code
?OuterNLiveRegs)}
VInter = vDefinition(_ {V reg($)} PredId @procedureRef
GRegs Code VTl0)
VHd0 = vDefinition(_ {V reg($)} PredId @procedureRef
GRegs Code VTl0)
else
VInter FormalRegs AllRegs
InnerBodyVInter InnerBodyVInstr InnerGRegs InnerCode
FormalRegs AllRegs InnerBodyVInter InnerGRegs InnerCode
InnerDefinitionReg InnerPredId InnerNLiveRegs
OuterBodyVInstr OuterBodyVInter2 OuterGRegs OuterCode
in
Expand All @@ -905,14 +899,7 @@ define
AllRegs = case @allVariables of nil then nil
elseof Vs then {GetRegs Vs}
end
case StateReg of none then
InnerBodyVInstr = InnerBodyVInter
VHd0 = VInter
else
InnerBodyVInstr = vSetSelf(_ StateReg InnerBodyVInter)
VHd0 = vGetSelf(_ StateReg VInter)
end
{CS endDefinition(InnerBodyVInstr nil AllRegs
{CS endDefinition(InnerBodyVInter nil AllRegs
?InnerGRegs ?InnerCode ?InnerNLiveRegs)}
{CS newReg(?InnerDefinitionReg)}
InnerPredId = {Adjoin PredId
Expand Down Expand Up @@ -964,8 +951,8 @@ define
OuterBodyVInter2 = vCall(_ InnerDefinitionReg nil unit nil)
{CS endDefinition(OuterBodyVInstr FormalRegs AllRegs
?OuterGRegs ?OuterCode ?OuterNLiveRegs)}
VInter = vDefinition(_ {V reg($)} PredId @procedureRef
OuterGRegs OuterCode VTl0)
VHd0 = vDefinition(_ {V reg($)} PredId @procedureRef
OuterGRegs OuterCode VTl0)
end
{StepPoint @coord 'definition' VHd VTl VHd0 VTl0}
statements <- unit % hand them to the garbage collector
Expand Down
23 changes: 21 additions & 2 deletions platform-test/debug/stacktrace_line_num.oz
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,23 @@ functor
export
Return
define
EnsureFailureLineNumber = 29
FunctionFailureLineNumber = 31
ClassFailureLineNumber = 39

proc {EnsureFailure}
2 + 2 = 5
end

class ClassFailure
prop locking

meth something
lock
2 + 2 = 5
end
end
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

fun {CreateTestCase P LineNumber Key}
Expand All @@ -45,8 +57,15 @@ define
keys: [Key stacktraceLineNum]
)
end

Return = stacktraceLineNum([
{CreateTestCase EnsureFailure EnsureFailureLineNumber simpleFunctionCall}
{CreateTestCase EnsureFailure
FunctionFailureLineNumber
simpleFunctionCall}

{CreateTestCase (proc {$} _ = {New ClassFailure something} end)
ClassFailureLineNumber
simpleMethodCall}
])
end

0 comments on commit d329869

Please sign in to comment.