success_fn = (ret1, ret2, bytecode, advance_pc=true) =>
if bytecode
@meta_stack().push root.StackFrame.native_frame("async_op")
@curr_frame().runner = =>
@meta_stack().pop()
if bytecode and advance_pc
@curr_frame().pc += 1 + @curr_frame().method.code.opcodes[@curr_frame().pc].byte_count
unless ret1 is undefined
ret1 += 0 if typeof ret1 == 'boolean'
@push ret1
@push ret2 unless ret2 is undefined
@run_until_finished (->), no_threads, done_cb
failure_fn = (e_cb) =>
@meta_stack().push root.StackFrame.native_frame("async_op")
@curr_frame().runner = =>
@meta_stack().pop()
e_cb()
@run_until_finished (->), no_threads, done_cb
e.condition success_fn, failure_fn
else
stack = @meta_stack()
if e.method_catch_handler? and stack.length() > 1
frames_to_pop = 0
until e.method_catch_handler(@, stack.get_caller(frames_to_pop), frames_to_pop == 0)
if stack.length() == ++frames_to_pop
@dump_state() if jvm.dump_state
stack.pop_n stack.length() - 1
@handle_toplevel_exception e, no_threads, done_cb
return
stack.pop_n frames_to_pop
@run_until_finished (->), no_threads, done_cb
else
@dump_state() if jvm.dump_state
stack.pop_n Math.max(stack.length() - 1, 0)
@handle_toplevel_exception e, no_threads, done_cb
return
)