Add missing features to hhas/hackc and enable new round-trip tests
commit0936bce3183e11e859825e7a75891d40d3b037e5
authorPaul Bissonnette <paulbiss@fb.com>
Sun, 25 Jun 2017 00:00:51 +0000 (24 17:00 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Sun, 25 Jun 2017 00:01:58 +0000 (24 17:01 -0700)
treeebb899f173ec6a8d7773f38b3d85c33be2532279
parentb61a767316053434f0e794bd84de54b35a237dea
Add missing features to hhas/hackc and enable new round-trip tests

Summary:
This diff adds a variety of missing features to hhas as either new directives or extensions to existing directives, these include

 - Proper support for statics (via `.static`)
 - Type structures attached to aliases (via a new optional component of the `.alias` directive)
 - Support for annotating which functions and classes are not top level and therefore not possibly hoistable via a new `nontop` attribute
 - Gated support for doc-comments (enabled via `Eval.DisassemblerDocComments`, and defaulted on)
 - Gated support for line number/source position mapping (via `.srcloc` directive and optional line pairs on class and function declarations, enabled via `Eval.DisassemblerSourceMapping`)
 - Support for loading filepaths from the bytecode repo (required to get round tripped testes to pass, enabled via `Eval.LoadFilepathFromUnitCache` and only used for testing)

Additionally changes were made to the way that the assembler handles unreachable code to be more inline with the hphpc emitter. In particular all instructions will now unconditionally force themselves to be reachable with an initial stack depth of 0. This isn't an ideal solution but it most closely matches what we do elsewhere which should ease writing new code generators as the existing frontend functioned this way. It was also necessary to force the hphpc frontend to assume that the bytecodes following an Exit instruction were unconditionally reachable as it was only sometimes eliding pops confusing the assembler and breaking round-trip tests.

These new features have all been implemented in hackc as well, with the exception of doc comments and source mapping, which will come in follow-up diffs. Notably, these features exposed a few latent bugs that had been missed by our incomplete disassembler, these tests are now marked as failing (a handful of tests are newly passing). Many of the ~30 tests marked as failing in this diff are semantically equivalent, however, the phpCode encoded alongside `.static` directives was not always identical.

Reviewed By: andrewjkennedy

Differential Revision: D5291798

fbshipit-source-id: 20f20d97c00502003536862e423e1af85564dad7
38 files changed:
hphp/compiler/analysis/emitter.cpp
hphp/hack/src/hhbc/closure_convert.ml
hphp/hack/src/hhbc/closure_convert.mli
hphp/hack/src/hhbc/emit_body.ml
hphp/hack/src/hhbc/emit_body.mli
hphp/hack/src/hhbc/emit_class.ml
hphp/hack/src/hhbc/emit_expression.ml
hphp/hack/src/hhbc/emit_function.ml
hphp/hack/src/hhbc/emit_memoize_function.ml
hphp/hack/src/hhbc/emit_memoize_method.ml
hphp/hack/src/hhbc/emit_param.ml
hphp/hack/src/hhbc/emit_property.ml
hphp/hack/src/hhbc/emit_statement.ml
hphp/hack/src/hhbc/emit_typedef.ml
hphp/hack/src/hhbc/hhas_body.ml
hphp/hack/src/hhbc/hhas_class.ml
hphp/hack/src/hhbc/hhas_constant.ml
hphp/hack/src/hhbc/hhas_function.ml
hphp/hack/src/hhbc/hhas_parser.mly
hphp/hack/src/hhbc/hhas_program.ml
hphp/hack/src/hhbc/hhas_property.ml
hphp/hack/src/hhbc/hhas_type_constant.ml
hphp/hack/src/hhbc/hhas_typedef.ml
hphp/hack/src/hhbc/hhbc_hhas.ml
hphp/runtime/base/program-functions.cpp
hphp/runtime/base/runtime-option.h
hphp/runtime/base/unit-cache.cpp
hphp/runtime/vm/as.cpp
hphp/runtime/vm/disas.cpp
hphp/runtime/vm/preclass-emitter.h
hphp/runtime/vm/unit-emitter.cpp
hphp/runtime/vm/unit.cpp
hphp/runtime/vm/unit.h
hphp/test/hhcodegen_failing_tests_quick
hphp/test/hhcodegen_failing_tests_slow
hphp/test/hhcodegen_failing_tests_zend_tests
hphp/test/quick/asm_stack_depth_and_jmp.hhas
hphp/test/run