This commit is contained in:
Michael Bebenita 2015-01-25 13:41:37 -08:00
Родитель 71840372e6
Коммит a042426843
2 изменённых файлов: 42 добавлений и 40 удалений

Просмотреть файл

@ -108,8 +108,6 @@ module J2ME {
export var onStackReplacementCount = 0; export var onStackReplacementCount = 0;
export var onStackReplacementIsEnabled = true;
/** /**
* Temporarily used for fn.apply. * Temporarily used for fn.apply.
*/ */
@ -260,12 +258,20 @@ module J2ME {
try { try {
if (frame.pc < lastPC) { if (frame.pc < lastPC) {
mi.backwardsBranchCount ++; mi.backwardsBranchCount ++;
if (onStackReplacementIsEnabled && mi.state === MethodState.Compiled) { if (enableOnStackReplacement && mi.state === MethodState.Compiled) {
// Just because we've jumped backwards doesn't mean we are at a loop header but it does mean that we are // Just because we've jumped backwards doesn't mean we are at a loop header but it does mean that we are
// at the beggining of a basic block. This is a really cheap test and a convenient place to perform an // at the beggining of a basic block. This is a really cheap test and a convenient place to perform an
// on stack replacement. // on stack replacement.
profile && onStackReplacementCount ++; var blockMap = mi.blockMap;
if (!blockMap) {
blockMap = new BlockMap(mi);
blockMap.build();
mi.blockMap = blockMap;
}
if (blockMap.getBlock(frame.pc).isLoopHeader) {
profile && onStackReplacementCount++;
// The current frame will be swapped out for a JIT frame, so pop it off the interpreter stack. // The current frame will be swapped out for a JIT frame, so pop it off the interpreter stack.
frames.pop(); frames.pop();
@ -276,16 +282,6 @@ module J2ME {
// Set the global OSR frame to the current frame. // Set the global OSR frame to the current frame.
O = frame; O = frame;
var blockMap = O.methodInfo.blockMap;
if (!blockMap) {
blockMap = new BlockMap(O.methodInfo);
blockMap.build();
O.methodInfo.blockMap = blockMap;
}
// Convert between PC and block ID which is what the baseline JIT expects as the PC.
O.pc = blockMap.getBlock(O.pc).blockID;
// Set the current frame before doing the OSR in case an exception is thrown. // Set the current frame before doing the OSR in case an exception is thrown.
frame = frames[frames.length - 1]; frame = frames[frames.length - 1];
@ -314,6 +310,7 @@ module J2ME {
} }
} }
} }
}
lastPC = frame.opPC = frame.pc; lastPC = frame.opPC = frame.pc;
var op: Bytecodes = frame.read8(); var op: Bytecodes = frame.read8();

Просмотреть файл

@ -28,6 +28,11 @@ module J2ME {
*/ */
export var enableRuntimeCompilation = true; export var enableRuntimeCompilation = true;
/**
* Turns on onStackReplacement
*/
export var enableOnStackReplacement = true;
/** /**
* Enables more compact mangled names. This helps reduce code size but may cause naming collisions. * Enables more compact mangled names. This helps reduce code size but may cause naming collisions.
*/ */