Created
July 6, 2017 12:22
-
-
Save mcollina/a40c6c3820287a474e9943406385c738 to your computer and use it in GitHub Desktop.
endless deopt-opt cycle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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