Skip to content

Instantly share code, notes, and snippets.

@Ginden
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ginden/672cb07cc6445ad08615 to your computer and use it in GitHub Desktop.
Save Ginden/672cb07cc6445ad08615 to your computer and use it in GitHub Desktop.
function a(opt) {
opt = 3+opt;
return opt+1;
}
function b(opt) {
'use strict';
opt = 3+opt;
return opt+1;
}
function c(opt) {
'use strict';
var _opt = 3+opt;
return _opt+1;
}
function printStatus(fn) {
switch(%GetOptimizationStatus(fn)) {
case 1: console.log('Function is optimized'); break;
case 2: console.log('Function is not optimized'); break;
case 3: console.log('Function is always optimized'); break;
case 4: console.log('Function is never optimized'); break;
case 6: console.log('Function is maybe deoptimized'); break;
}
}
a(5);
b(4);
c(6);
%OptimizeFunctionOnNextCall(a);
%OptimizeFunctionOnNextCall(b);
%OptimizeFunctionOnNextCall(c);
a(4);
printStatus(a);
b(5);
printStatus(b);
c(7);
printStatus(c);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment