HHVM Runtime support for inout parameters
commitd8b8eabdda450bec0f9c12960b6404435f234e22
authorPaul Bissonnette <paulbiss@fb.com>
Tue, 24 Oct 2017 08:48:00 +0000 (24 01:48 -0700)
committerHhvm Bot <hhvm-bot@users.noreply.github.com>
Tue, 24 Oct 2017 08:55:19 +0000 (24 01:55 -0700)
tree5edccf6f8bc97fc60ddee9694da117fcb65aa8a6
parentf0c9424f7fa6de5a068a7bfe5aacf0c1c6275384
HHVM Runtime support for inout parameters

Summary:
Implements the runtime support required for inout parameters and compatibility wrappers. These new functions are implemented using name mangling (made possible because we require callsites to be annotated to indicate which parameters are inout). In addition the specification calls for the creation of interoperability wrappers for all inout and reference functions. A mangled inout function is created for each function taking at least one ref which would not result in an illegal inout function (e.g. no async functions). Similarly all inout functions have an associated ref wrapper which takes parameters by reference.

All inout functions must always have wrappers, however, for reference functions inout wrappers are only created when the runtime option Eval.CreateInOutWrapperFunctions is true. While inout functions must be invariant across method overrides the same is not true for by ref functions. A runtime option Eval.ReffinessInvariance has been added to force by ref functions to share this invariance. Wrappers for ref methods will only be created when this option is set to avoid creating illegal inout methods which do not preserve inout invariance.

The displayName, and fullDisplayName methods were used to unmangled names, and a new helper was added for raising undefined method and function errors which also performs any required unmangling.

Finally, to deal with dynamic function calls the FPushObjMethod, FPushFunc, FPushClsMethod, and FPushClsMethodF bytecodes were extended to take an immediate vector of parameters which were marked pass by inout, so that the name called may be mangled at runtime.

Reviewed By: swtaarrs

Differential Revision: D6002807

fbshipit-source-id: 4aaa707e3d48c8954ea4c160f457b88a7bc5e3c4
108 files changed:
hphp/compiler/analysis/emitter.cpp
hphp/compiler/analysis/function_scope.cpp
hphp/compiler/analysis/function_scope.h
hphp/compiler/expression/parameter_expression.h
hphp/compiler/statement/method_statement.cpp
hphp/compiler/statement/method_statement.h
hphp/hhbbc/bc.h
hphp/hhbbc/check.cpp
hphp/hhbbc/emit.cpp
hphp/hhbbc/index.cpp
hphp/hhbbc/interp-minstr.cpp
hphp/hhbbc/interp.cpp
hphp/hhbbc/main.cpp
hphp/hhbbc/parse.cpp
hphp/hhbbc/show.cpp
hphp/hhbbc/test/bc.cpp
hphp/php7/bytecode.h
hphp/php7/hhas.cpp
hphp/runtime/base/attr.h
hphp/runtime/base/autoload-handler.cpp
hphp/runtime/base/builtin-functions.cpp
hphp/runtime/base/builtin-functions.h
hphp/runtime/base/runtime-error.cpp
hphp/runtime/base/runtime-error.h
hphp/runtime/base/runtime-option.h
hphp/runtime/base/unit-cache.cpp
hphp/runtime/vm/as-shared.cpp
hphp/runtime/vm/as.cpp
hphp/runtime/vm/bytecode.cpp
hphp/runtime/vm/class.cpp
hphp/runtime/vm/disas.cpp
hphp/runtime/vm/func-emitter.cpp
hphp/runtime/vm/func-inl.h
hphp/runtime/vm/func.cpp
hphp/runtime/vm/func.h
hphp/runtime/vm/hhbc.cpp
hphp/runtime/vm/hhbc.h
hphp/runtime/vm/jit/irgen-call.cpp
hphp/runtime/vm/jit/irgen-interpone.cpp
hphp/runtime/vm/jit/irgen-minstr.cpp
hphp/runtime/vm/jit/irgen.h
hphp/runtime/vm/jit/irlower-lookup-cls-func.cpp
hphp/runtime/vm/jit/irlower-minstr-internal.h
hphp/runtime/vm/jit/minstr-helpers.h
hphp/runtime/vm/jit/target-cache.cpp
hphp/runtime/vm/jit/translator.cpp
hphp/runtime/vm/member-operations.h
hphp/runtime/vm/method-lookup.cpp
hphp/runtime/vm/repo-global-data.h
hphp/runtime/vm/repo.cpp
hphp/runtime/vm/type-constraint.cpp
hphp/runtime/vm/type-constraint.h
hphp/runtime/vm/unit-util.h
hphp/runtime/vm/verifier/check-func.cpp
hphp/runtime/vm/verifier/check-unit.cpp
hphp/test/hhcodegen_failing_tests_slow
hphp/test/run
hphp/test/slow/inout/autoloader.php [new file with mode: 0644]
hphp/test/slow/inout/autoloader.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-10.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-10.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-11.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-11.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-12.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-12.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-13.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-13.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-14.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-14.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/bad-call-15.php [new file with mode: 0644]
hphp/test/slow/inout/bad-call-15.php.expectf [new file with mode: 0644]
hphp/test/slow/inout/builtin-interop.php [new file with mode: 0644]
hphp/test/slow/inout/builtin-interop.php.expect [new file with mode: 0644]
hphp/test/slow/inout/call-dynamic.php [new file with mode: 0644]
hphp/test/slow/inout/call-dynamic.php.expect [new file with mode: 0644]
hphp/test/slow/inout/call-static.php [new file with mode: 0644]
hphp/test/slow/inout/call-static.php.expect [new file with mode: 0644]
hphp/test/slow/inout/closure.php [new file with mode: 0644]
hphp/test/slow/inout/closure.php.expect [new file with mode: 0644]
hphp/test/slow/inout/complex-expr.php [new file with mode: 0644]
hphp/test/slow/inout/complex-expr.php.expect [new file with mode: 0644]
hphp/test/slow/inout/def-func.php [new file with mode: 0644]
hphp/test/slow/inout/def-func.php.expect [new file with mode: 0644]
hphp/test/slow/inout/func-interop-dynamic.php [new file with mode: 0644]
hphp/test/slow/inout/func-interop-dynamic.php.expect [new file with mode: 0644]
hphp/test/slow/inout/func-interop-static.php [new file with mode: 0644]
hphp/test/slow/inout/func-interop-static.php.expect [new file with mode: 0644]
hphp/test/slow/inout/inout-decl.php
hphp/test/slow/inout/method-dynamic.php [new file with mode: 0644]
hphp/test/slow/inout/method-dynamic.php.expect [new file with mode: 0644]
hphp/test/slow/inout/method-interop-dynamic.php [new file with mode: 0644]
hphp/test/slow/inout/method-interop-dynamic.php.expect [new file with mode: 0644]
hphp/test/slow/inout/method-interop-dynamic.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/inout/method-interop-dynamic.php.opts [new file with mode: 0644]
hphp/test/slow/inout/method-interop-static.php [new file with mode: 0644]
hphp/test/slow/inout/method-interop-static.php.expect [new file with mode: 0644]
hphp/test/slow/inout/method-interop-static.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/inout/method-interop-static.php.opts [new file with mode: 0644]
hphp/test/slow/inout/method-static.php [new file with mode: 0644]
hphp/test/slow/inout/method-static.php.expect [new file with mode: 0644]
hphp/test/slow/inout/out-type-hints.php [new file with mode: 0644]
hphp/test/slow/inout/out-type-hints.php.expect [new file with mode: 0644]
hphp/test/slow/inout/side-effects.php [new file with mode: 0644]
hphp/test/slow/inout/side-effects.php.expect [new file with mode: 0644]
hphp/test/slow/inout/trait-magic.php [new file with mode: 0644]
hphp/test/slow/inout/trait-magic.php.expect [new file with mode: 0644]
hphp/test/slow/inout/trait-magic.php.hphp_opts [new file with mode: 0644]
hphp/test/slow/inout/trait-magic.php.opts [new file with mode: 0644]