Emit func prologues using HHIR and vasm
commitf97eb007eebe2995a47d21690e3913d34b7b8b9b
authorMax Wang <mwang@fb.com>
Tue, 26 May 2015 21:46:27 +0000 (26 14:46 -0700)
committerhhvm-bot <hhvm-bot@fb.com>
Tue, 26 May 2015 22:00:39 +0000 (26 15:00 -0700)
treec7062970317f0288f4026efa3b2ab3a5a0cc905c
parent0036fa46c4b04a37bd454169d65d6ae5d72bf174
Emit func prologues using HHIR and vasm

Summary: First step towards making func prologues coalescable with PGO regions:
Emit them using the HHIR and vasm machinery instead of with raw
assemblers.

This diff only handles non-closure, non-magic functions.  Support for
closures may come after some of the cleanup described in t6779320.

Changes include the following:
- Add a CodeKind argument to genCode() and a cross-trace ABI to support
  func prologue codegen.
- Add HHIR opcodes for supporting func prologues: RaiseMissingArg,
  StLocRange, EnterFrame, CheckStackOverflow, InitExtraArgs{,X}, and
  CheckSurpriseFlagsEnter.
- Introduce vasm instructions to support func guards: cmpqims and
  ldimmqs for emitting smashable instructions, jcci for conditional
  jumps with immediate targets, and popm for func entry.
- Squeeze an extra bit into SrcKey to indicate whether it corresponds to
  the func prologue occurring before the source location.

The genFuncPrologue() interface should be considered temporary, to be
replaced by a mechanism for spitting out an IRUnit and gluing it into a
profiled region.

Reviewed By: @jdelong

Differential Revision: D2062303
42 files changed:
hphp/doc/ir.specification
hphp/runtime/vm/bytecode.h
hphp/runtime/vm/jit/abi-x64.h
hphp/runtime/vm/jit/back-end-arm.cpp
hphp/runtime/vm/jit/back-end-x64.cpp
hphp/runtime/vm/jit/back-end-x64.h
hphp/runtime/vm/jit/back-end.h
hphp/runtime/vm/jit/code-gen-arm.cpp
hphp/runtime/vm/jit/code-gen-helpers-x64.cpp
hphp/runtime/vm/jit/code-gen-helpers-x64.h
hphp/runtime/vm/jit/code-gen-x64.cpp
hphp/runtime/vm/jit/code-gen.cpp
hphp/runtime/vm/jit/code-gen.h
hphp/runtime/vm/jit/dce.cpp
hphp/runtime/vm/jit/extra-data.h
hphp/runtime/vm/jit/func-prologue.cpp [new file with mode: 0644]
hphp/runtime/vm/jit/func-prologue.h [copied from hphp/runtime/vm/jit/back-end-x64.h with 60% similarity]
hphp/runtime/vm/jit/irgen-func-prologue.cpp [new file with mode: 0644]
hphp/runtime/vm/jit/irgen-func-prologue.h [copied from hphp/runtime/vm/jit/back-end-x64.h with 64% similarity]
hphp/runtime/vm/jit/irgen-internal.h
hphp/runtime/vm/jit/mc-generator.cpp
hphp/runtime/vm/jit/memory-effects.cpp
hphp/runtime/vm/jit/native-calls.cpp
hphp/runtime/vm/jit/target-cache.cpp
hphp/runtime/vm/jit/target-cache.h
hphp/runtime/vm/jit/translator-inl.h
hphp/runtime/vm/jit/translator-inline.h
hphp/runtime/vm/jit/translator.h
hphp/runtime/vm/jit/types.h
hphp/runtime/vm/jit/vasm-arm.cpp
hphp/runtime/vm/jit/vasm-dead.cpp
hphp/runtime/vm/jit/vasm-fold-imms.cpp
hphp/runtime/vm/jit/vasm-instr.cpp
hphp/runtime/vm/jit/vasm-instr.h
hphp/runtime/vm/jit/vasm-llvm.cpp
hphp/runtime/vm/jit/vasm-x64.cpp
hphp/runtime/vm/jit/vasm-xls.cpp
hphp/runtime/vm/jit/vasm.cpp
hphp/runtime/vm/srckey-inl.h
hphp/runtime/vm/srckey.h
hphp/test/quick/exceptions8.php
hphp/util/asm-x64.h