Skip to content

Instantly share code, notes, and snippets.

@mcollina
Created July 6, 2017 12:22
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 mcollina/a40c6c3820287a474e9943406385c738 to your computer and use it in GitHub Desktop.
Save mcollina/a40c6c3820287a474e9943406385c738 to your computer and use it in GitHub Desktop.
endless deopt-opt cycle
'use strict'
var MAX = 1000000000
var factory = {
create() {
throw new Error('kaboom')
return {
something() {
return 'hello world'
}
}
}
}
function start () {
for (var i = 0; i < MAX; i++) {
test()
}
}
function test () {
var obj
var res
var error
try {
obj = factory.create()
} catch (e) {
error = true
}
try {
res = obj.something()
} catch (e) {
error = true
}
if (!error) {
return res
}
}
for (var i = 0; i < MAX; i++) {
start()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment