Last active
May 16, 2018 22:37
-
-
Save schmee/fe0dae7cb9463134679377c9c02b61ab to your computer and use it in GitHub Desktop.
Escape analysis woes
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Specialization(guards = "isLong(vframe)") | |
public long readLong(VirtualFrame vframe) { | |
try { | |
return vframe.getLong(getSlot()); | |
} catch (FrameSlotTypeException e) { } | |
MaterializedFrame frame = getLexicalScope(vframe); | |
while (true) { | |
try { | |
return frame.getLong(getSlot()); | |
} catch (FrameSlotTypeException e) { | |
frame = getLexicalScope(frame); | |
if (frame == null) { | |
throw new RuntimeException("Undefined variable " + getSlot().getIdentifier()); | |
} | |
} | |
} | |
} | |
@Specialization(replaces = {"readLong"}) | |
public Object readObject(VirtualFrame vframe) { | |
Object value = vframe.getValue(getSlot()); | |
if (value != null) | |
return value; | |
MaterializedFrame frame = getLexicalScope(vframe); | |
value = frame.getValue(getSlot()); | |
if (value != null) | |
return value; | |
while (value == null) { | |
frame = getLexicalScope(frame); | |
if (frame == null) { | |
throw new RuntimeException("Undefined variable " + getSlot().getIdentifier()); | |
} else { | |
value = frame.getValue(getSlot()); | |
} | |
} | |
return value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Specialization(guards = "isLong(vframe)") | |
public long readLong(VirtualFrame vframe) { | |
Frame frame = vframe; | |
while (true) { | |
try { | |
return frame.getLong(getSlot()); | |
} catch (FrameSlotTypeException e) { | |
frame = getLexicalScope(frame); | |
if (frame == null) { | |
throw new RuntimeException("Undefined variable " + getSlot().getIdentifier()); | |
} | |
} | |
} | |
} | |
@Specialization(replaces = {"readLong"}) | |
public Object readObject(VirtualFrame vframe) { | |
Frame frame = vframe; | |
Object value = frame.getValue(getSlot()); | |
while (value == null) { | |
frame = getLexicalScope(frame); | |
if (frame == null) { | |
throw new RuntimeException("Undefined variable " + getSlot().getIdentifier()); | |
} else { | |
value = frame.getValue(getSlot()); | |
} | |
} | |
return value; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public MaterializedFrame getLexicalScope(Frame frame) { | |
Object[] args = frame.getArguments(); | |
if (args.length > 0) | |
return (MaterializedFrame) args[0]; | |
else { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment