Introduce AwaitAll bytecode for genva
commit3d35c33297ceee77a824f325afccac750c08aa9e
authorPaul Bissonnette <paulbiss@fb.com>
Sat, 28 Oct 2017 05:24:43 +0000 (27 22:24 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Sat, 28 Oct 2017 05:31:01 +0000 (27 22:31 -0700)
treed4099f362cbb5c370b90d883d3b06383fca339d0
parentbcb691f62194cbb3d8821839e3d0d13cea8e7167
Introduce AwaitAll bytecode for genva

Summary:
Similar to D6158265, remove the other packed array (which contained the unawaited waithandles). We were constructing this array and passing it to `c_AwaitAllWaitHandle::fromArray()`, which extracted all of the waithandles, checked that they were instances of `c_WaitHandle` and stored them into a newly allocated `c_AwaitAllWaitHandle`. Because of the way we've structured our inlined genva bytecode we already know that all of these cells contain instances of `c_WaitHandle`, furthermore, we don't need the array at all as the values ultimately end up inside the `c_AwaitAllWaitHandle`. Lastly, in the case where all of the waithandles are already finished we still constructed the `c_AwaitAllWaitHandle` which simply produced a static waithandle with the value null.

Originally this code used a CMANY stack flavor for `AwaitAll`, however I observed that the refcount optimizer had trouble eliding IncRef/DecRef pairs on the fast path (no suspend), and worse, couldn't determine that all of the DecRefs were DecRefNZs (because the locals still held references to the waithandles). Instead this version uses a local-range (as the temporary locals were all allocated in sequence by the emitter), and the new `CreateAAWH` IR instruction extracts and IncRefs locals as necessary (this also prevented an extra unnecessary spill of all of the waithandles to the stack).

Reviewed By: jano

Differential Revision: D6159186

fbshipit-source-id: 5c48041c96c318909142fb663474b2502d02b8bc
20 files changed:
hphp/compiler/analysis/emitter.cpp
hphp/doc/bytecode.specification
hphp/doc/ir.specification
hphp/hhbbc/interp-internal.h
hphp/hhbbc/interp-minstr.cpp
hphp/hhbbc/interp.cpp
hphp/runtime/base/runtime-option.h
hphp/runtime/ext/asio/ext_await-all-wait-handle.cpp
hphp/runtime/ext/asio/ext_await-all-wait-handle.h
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/hhbc.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/jit/code-gen-cf.h
hphp/runtime/vm/jit/dce.cpp
hphp/runtime/vm/jit/extra-data.h
hphp/runtime/vm/jit/ir-instruction.cpp
hphp/runtime/vm/jit/irgen-resumable.cpp
hphp/runtime/vm/jit/irlower-resumable.cpp
hphp/runtime/vm/jit/memory-effects.cpp
hphp/runtime/vm/jit/translator.cpp