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,56 +258,55 @@ 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;
// The current frame will be swapped out for a JIT frame, so pop it off the interpreter stack.
frames.pop();
// Remember the return kind since we'll need it later.
var returnKind = mi.getReturnKind();
// Set the global OSR frame to the current frame.
O = frame;
var blockMap = O.methodInfo.blockMap;
if (!blockMap) { if (!blockMap) {
blockMap = new BlockMap(O.methodInfo); blockMap = new BlockMap(mi);
blockMap.build(); blockMap.build();
O.methodInfo.blockMap = blockMap; mi.blockMap = blockMap;
} }
// Convert between PC and block ID which is what the baseline JIT expects as the PC. if (blockMap.getBlock(frame.pc).isLoopHeader) {
O.pc = blockMap.getBlock(O.pc).blockID; profile && onStackReplacementCount++;
// Set the current frame before doing the OSR in case an exception is thrown. // The current frame will be swapped out for a JIT frame, so pop it off the interpreter stack.
frame = frames[frames.length - 1]; frames.pop();
// Perform OSR, the callee reads the frame stored in |O| and updates its own state. // Remember the return kind since we'll need it later.
returnValue = O.methodInfo.fn(); var returnKind = mi.getReturnKind();
if (U) {
return;
}
// Usual code to return from the interpreter or push the return value. // Set the global OSR frame to the current frame.
if (Frame.isMarker(frame)) { O = frame;
return returnValue;
}
mi = frame.methodInfo;
ci = mi.classInfo;
rp = ci.resolved_constant_pool;
stack = frame.stack;
lastPC = -1;
if (returnKind !== Kind.Void) { // Set the current frame before doing the OSR in case an exception is thrown.
if (isTwoSlot(returnKind)) { frame = frames[frames.length - 1];
stack.push2(returnValue);
} else { // Perform OSR, the callee reads the frame stored in |O| and updates its own state.
stack.push(returnValue); returnValue = O.methodInfo.fn();
if (U) {
return;
}
// Usual code to return from the interpreter or push the return value.
if (Frame.isMarker(frame)) {
return returnValue;
}
mi = frame.methodInfo;
ci = mi.classInfo;
rp = ci.resolved_constant_pool;
stack = frame.stack;
lastPC = -1;
if (returnKind !== Kind.Void) {
if (isTwoSlot(returnKind)) {
stack.push2(returnValue);
} else {
stack.push(returnValue);
}
} }
} }
} }

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

@ -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.
*/ */