Skip to content

Instantly share code, notes, and snippets.

@andre487
Created March 7, 2015 23:10
Show Gist options
  • Save andre487/66d4d7b00d35bb564755 to your computer and use it in GitHub Desktop.
Save andre487/66d4d7b00d35bb564755 to your computer and use it in GitHub Desktop.
V8 checks
exports.fastElements = function(obj) {
if (%HasFastSmiElements(obj)) {
console.log('Fast SMI elements');
}
if (%HasFastSmiOrObjectElements(obj)) {
console.log('Fast SMI or Object elements');
}
if (%HasFastObjectElements(obj)) {
console.log('Fast Object elements');
}
if (%HasFastDoubleElements(obj)) {
console.log('Fast double elements');
}
if (%HasFastHoleyElements(obj)) {
console.log('Fast holey elements');
}
};
exports.smi = function(x) {
%_IsSmi(x) ?
console.log('X is SMI') :
console.log('X is not SMI');
};
exports.funcOptimization = function(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;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment