From 804edd6d4ae003d2883e3d01603d6c897e045516 Mon Sep 17 00:00:00 2001 From: Aaron Orenstein Date: Wed, 9 Mar 2022 23:49:47 -0800 Subject: [PATCH 1/2] Stop dune from depending on hackc Differential Revision: D34776630 fbshipit-source-id: e16f24f09a6d649771f72d650e0db0d0dce9fdd6 --- hphp/hack/src/facts/dune | 2 +- hphp/hack/src/facts/symbols/dune | 1 - hphp/hack/src/hackc/dune | 57 -------------------------------- 3 files changed, 1 insertion(+), 59 deletions(-) delete mode 100644 hphp/hack/src/hackc/dune diff --git a/hphp/hack/src/facts/dune b/hphp/hack/src/facts/dune index 0b9692cb12e5f..88cc80c8bae40 100644 --- a/hphp/hack/src/facts/dune +++ b/hphp/hack/src/facts/dune @@ -27,6 +27,6 @@ (name facts) (wrapped false) (modules facts facts_parser rust_facts_ffi) - (libraries core_kernel hhbc parser rust_facts_ffi utils_hash) + (libraries core_kernel parser rust_facts_ffi utils_hash) (preprocess (pps ppx_deriving.std))) diff --git a/hphp/hack/src/facts/symbols/dune b/hphp/hack/src/facts/symbols/dune index 01abeb293f161..71a2c4bf87674 100644 --- a/hphp/hack/src/facts/symbols/dune +++ b/hphp/hack/src/facts/symbols/dune @@ -6,7 +6,6 @@ facts folly_stubs heap_shared_mem_hash - hhbc hhi parser process diff --git a/hphp/hack/src/hackc/dune b/hphp/hack/src/hackc/dune deleted file mode 100644 index 16f755b3d3fa2..0000000000000 --- a/hphp/hack/src/hackc/dune +++ /dev/null @@ -1,57 +0,0 @@ -(data_only_dirs - bytecode_printer - compile_ffi - decl_provider - facebook - ffi_bridge - hhbc_by_ref - options_ffi) - -(library - (name hhbc) - (wrapped false) - (preprocess - (pps ppx_deriving.std)) - (libraries - annotated_ast - ast - core_kernel - full_fidelity - lru - mutable_accumulator - options_ffi - utils_php_escape)) - -(library - (name options_ffi) - (modules) - (wrapped false) - (foreign_archives options_ffi)) - -(rule - (targets liboptions_ffi.a) - (deps - (source_tree %{workspace_root}/src)) - (locks /cargo) - (action - (run - %{workspace_root}/scripts/build_rust_to_ocaml.sh - options_ffi - options_ffi))) - -(library - (name compile_ffi) - (modules) - (wrapped false) - (foreign_archives compile_ffi)) - -(rule - (targets libcompile_ffi.a) - (deps - (source_tree %{workspace_root}/src)) - (locks /cargo) - (action - (run - %{workspace_root}/scripts/build_rust_to_ocaml.sh - compile_ffi - compile_ffi))) From 55868afac369fba6972700aa2bd2b2adbfa14a9e Mon Sep 17 00:00:00 2001 From: Katy Voor Date: Wed, 9 Mar 2022 23:50:02 -0800 Subject: [PATCH 2/2] wip (#9030) Summary: Pull Request resolved: https://github.com/facebook/hhvm/pull/9030 Pull Request resolved: https://github.com/facebook/hhvm/pull/9029 Differential Revision: D34762816 fbshipit-source-id: 0625b4b3a8dff73b1c8560f832a6230552398d7d --- hphp/hack/CMakeLists.txt | 18 +- hphp/runtime/vm/hhbc.h | 268 +--------------------------- hphp/runtime/vm/opcodes.h | 292 +++++++++++++++++++++++++++++++ hphp/tools/hhbc-gen/gen-rust.cpp | 3 +- 4 files changed, 309 insertions(+), 272 deletions(-) create mode 100644 hphp/runtime/vm/opcodes.h diff --git a/hphp/hack/CMakeLists.txt b/hphp/hack/CMakeLists.txt index c818d8b9fcc35..9481fa8a1967f 100644 --- a/hphp/hack/CMakeLists.txt +++ b/hphp/hack/CMakeLists.txt @@ -119,6 +119,16 @@ invoke_dune(hack_dune all) set(CARGO_BUILD "${CMAKE_SOURCE_DIR}/hphp/hack/scripts/build_rust_to_ocaml.sh") +set(OPCODES "${CMAKE_SOURCE_DIR}/hphp/tools/hhbc-gen/opcodes.rs") + +add_executable(gen-rust1 "${CMAKE_SOURCE_DIR}/hphp/tools/hhbc-gen/gen-rust.cpp") +target_link_libraries(gen-rust1 folly) +add_custom_command( + OUTPUT "${OPCODES}" + COMMAND gen-rust1 >> "${OPCODES}" + COMMENT "Generating opcodes.rs" +) + if(DEFINED ENV{HACKDEBUG}) set(PROFILE "debug") else() @@ -196,7 +206,7 @@ add_custom_command( ${CARGO_BUILD} ffi_cbindgen ffi_cbindgen --exe --header "${HHBC_AST_HEADER}" --srcs "${HHBC_AST_SRC_ARG}" --namespaces "HPHP,hackc,hhbc" --includes "${FFI_HEADER},${NAMING_SPECIAL_NAMES_HEADER},${TYPE_CONSTRAINT_HEADER},${ATTR_HEADER},${FCALL_HEADER},${HHBC_HEADER}" - DEPENDS rustc cargo + DEPENDS rustc cargo "${OPCODES}" COMMENT "Generating hhbc-ast.h" ) @@ -230,7 +240,7 @@ function(build_cxx_bridge NAME FFI_BRIDGE_DIR) ${CMAKE_COMMAND} -E copy "${GENERATED}.rs.cc" "${RUST_PART_CXX}" && ${CMAKE_COMMAND} -E copy "${GENERATED}.rs.h" "${RUST_PART_HEADER}" WORKING_DIRECTORY ${FFI_BRIDGE_SRC} - DEPENDS rustc cargo + DEPENDS rustc cargo "${OPCODES}" ) add_custom_target( "${NAME}_cxx" @@ -264,8 +274,8 @@ endif() # you're working with Hack, but means that e.g. hhvm can't find # `hh_single_compile` in the source tree. Keep it around, but require it to be # explicitly used -add_custom_target(hack ALL DEPENDS hack_dune) -add_custom_target(hack_test DEPENDS hack_dune_test) +add_custom_target(hack ALL DEPENDS hack_dune "${OPCODES}") +add_custom_target(hack_test DEPENDS hack_dune_test "${OPCODES}") configure_file(dev_env.sh.in dev_env.sh ESCAPE_QUOTES @ONLY) configure_file(dev_env_common.sh.in dev_env_common.sh ESCAPE_QUOTES @ONLY) diff --git a/hphp/runtime/vm/hhbc.h b/hphp/runtime/vm/hhbc.h index 75b0158585fcf..797541d05e38f 100644 --- a/hphp/runtime/vm/hhbc.h +++ b/hphp/runtime/vm/hhbc.h @@ -29,6 +29,7 @@ #include "hphp/util/either.h" #include "hphp/util/functional.h" #include "hphp/util/hash-set.h" +#include "hphp/runtime/vm/opcodes.h" namespace HPHP { @@ -316,273 +317,6 @@ inline bool isIncDecO(IncDecOp op) { constexpr uint32_t kMaxConcatN = 4; -// name immediates inputs outputs flags -#define OPCODES \ - O(Nop, NA, NOV, NOV, NF) \ - O(EntryNop, NA, NOV, NOV, NF) \ - O(BreakTraceHint, NA, NOV, NOV, NF) \ - O(PopC, NA, ONE(CV), NOV, NF) \ - O(PopU, NA, ONE(UV), NOV, NF) \ - O(PopU2, NA, TWO(CV,UV), ONE(CV), NF) \ - O(PopL, ONE(LA), ONE(CV), NOV, NF) \ - O(Dup, NA, ONE(CV), TWO(CV,CV), NF) \ - O(CGetCUNop, NA, ONE(CUV), ONE(CV), NF) \ - O(UGetCUNop, NA, ONE(CUV), ONE(UV), NF) \ - O(Null, NA, NOV, ONE(CV), NF) \ - O(NullUninit, NA, NOV, ONE(UV), NF) \ - O(True, NA, NOV, ONE(CV), NF) \ - O(False, NA, NOV, ONE(CV), NF) \ - O(FuncCred, NA, NOV, ONE(CV), NF) \ - O(Int, ONE(I64A), NOV, ONE(CV), NF) \ - O(Double, ONE(DA), NOV, ONE(CV), NF) \ - O(String, ONE(SA), NOV, ONE(CV), NF) \ - O(Dict, ONE(AA), NOV, ONE(CV), NF) \ - O(Keyset, ONE(AA), NOV, ONE(CV), NF) \ - O(Vec, ONE(AA), NOV, ONE(CV), NF) \ - O(NewDictArray, ONE(IVA), NOV, ONE(CV), NF) \ - O(NewStructDict, ONE(VSA), SMANY, ONE(CV), NF) \ - O(NewVec, ONE(IVA), CMANY, ONE(CV), NF) \ - O(NewKeysetArray, ONE(IVA), CMANY, ONE(CV), NF) \ - O(AddElemC, NA, THREE(CV,CV,CV), ONE(CV), NF) \ - O(AddNewElemC, NA, TWO(CV,CV), ONE(CV), NF) \ - O(NewCol, ONE(OA(CollectionType)), \ - NOV, ONE(CV), NF) \ - O(NewPair, NA, TWO(CV,CV), ONE(CV), NF) \ - O(ColFromArray, ONE(OA(CollectionType)), \ - ONE(CV), ONE(CV), NF) \ - O(CnsE, ONE(SA), NOV, ONE(CV), NF) \ - O(ClsCns, ONE(SA), ONE(CV), ONE(CV), NF) \ - O(ClsCnsD, TWO(SA,SA), NOV, ONE(CV), NF) \ - O(ClsCnsL, ONE(LA), ONE(CV), ONE(CV), NF) \ - O(ClassName, NA, ONE(CV), ONE(CV), NF) \ - O(LazyClassFromClass, NA, ONE(CV), ONE(CV), NF) \ - O(File, NA, NOV, ONE(CV), NF) \ - O(Dir, NA, NOV, ONE(CV), NF) \ - O(Method, NA, NOV, ONE(CV), NF) \ - O(Concat, NA, TWO(CV,CV), ONE(CV), NF) \ - O(ConcatN, ONE(IVA), CMANY, ONE(CV), NF) \ - O(Add, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Sub, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Mul, NA, TWO(CV,CV), ONE(CV), NF) \ - O(AddO, NA, TWO(CV,CV), ONE(CV), NF) \ - O(SubO, NA, TWO(CV,CV), ONE(CV), NF) \ - O(MulO, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Div, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Mod, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Pow, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Not, NA, ONE(CV), ONE(CV), NF) \ - O(Same, NA, TWO(CV,CV), ONE(CV), NF) \ - O(NSame, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Eq, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Neq, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Lt, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Lte, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Gt, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Gte, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Cmp, NA, TWO(CV,CV), ONE(CV), NF) \ - O(BitAnd, NA, TWO(CV,CV), ONE(CV), NF) \ - O(BitOr, NA, TWO(CV,CV), ONE(CV), NF) \ - O(BitXor, NA, TWO(CV,CV), ONE(CV), NF) \ - O(BitNot, NA, ONE(CV), ONE(CV), NF) \ - O(Shl, NA, TWO(CV,CV), ONE(CV), NF) \ - O(Shr, NA, TWO(CV,CV), ONE(CV), NF) \ - O(CastBool, NA, ONE(CV), ONE(CV), NF) \ - O(CastInt, NA, ONE(CV), ONE(CV), NF) \ - O(CastDouble, NA, ONE(CV), ONE(CV), NF) \ - O(CastString, NA, ONE(CV), ONE(CV), NF) \ - O(CastDict, NA, ONE(CV), ONE(CV), NF) \ - O(CastKeyset, NA, ONE(CV), ONE(CV), NF) \ - O(CastVec, NA, ONE(CV), ONE(CV), NF) \ - O(DblAsBits, NA, ONE(CV), ONE(CV), NF) \ - O(InstanceOf, NA, TWO(CV,CV), ONE(CV), NF) \ - O(InstanceOfD, ONE(SA), ONE(CV), ONE(CV), NF) \ - O(IsLateBoundCls, NA, ONE(CV), ONE(CV), NF) \ - O(IsTypeStructC, ONE(OA(TypeStructResolveOp)), \ - TWO(CV,CV), ONE(CV), NF) \ - O(ThrowAsTypeStructException, \ - NA, TWO(CV,CV), NOV, TF) \ - O(CombineAndResolveTypeStruct, \ - ONE(IVA), CMANY, ONE(CV), NF) \ - O(Select, NA, THREE(CV,CV,CV), ONE(CV), NF) \ - O(Print, NA, ONE(CV), ONE(CV), NF) \ - O(Clone, NA, ONE(CV), ONE(CV), NF) \ - O(Exit, NA, ONE(CV), ONE(CV), TF) \ - O(Fatal, ONE(OA(FatalOp)), ONE(CV), NOV, TF) \ - O(Jmp, ONE(BA), NOV, NOV, CF_TF) \ - O(JmpNS, ONE(BA), NOV, NOV, CF_TF) \ - O(JmpZ, ONE(BA), ONE(CV), NOV, CF) \ - O(JmpNZ, ONE(BA), ONE(CV), NOV, CF) \ - O(Switch, THREE(OA(SwitchKind),I64A,BLA), \ - ONE(CV), NOV, CF_TF) \ - O(SSwitch, ONE(SLA), ONE(CV), NOV, CF_TF) \ - O(RetC, NA, ONE(CV), NOV, CF_TF) \ - O(RetM, ONE(IVA), CMANY, NOV, CF_TF) \ - O(RetCSuspended, NA, ONE(CV), NOV, CF_TF) \ - O(Throw, NA, ONE(CV), NOV, CF_TF) \ - O(CGetL, ONE(NLA), NOV, ONE(CV), NF) \ - O(CGetQuietL, ONE(LA), NOV, ONE(CV), NF) \ - O(CUGetL, ONE(LA), NOV, ONE(CUV), NF) \ - O(CGetL2, ONE(NLA), ONE(CV), TWO(CV,CV), NF) \ - O(PushL, ONE(LA), NOV, ONE(CV), NF) \ - O(CGetG, NA, ONE(CV), ONE(CV), NF) \ - O(CGetS, ONE(OA(ReadonlyOp)), \ - TWO(CV,CV), ONE(CV), NF) \ - O(ClassGetC, NA, ONE(CV), ONE(CV), NF) \ - O(ClassGetTS, NA, ONE(CV), TWO(CV,CV), NF) \ - O(GetMemoKeyL, ONE(NLA), NOV, ONE(CV), NF) \ - O(AKExists, NA, TWO(CV,CV), ONE(CV), NF) \ - O(IssetL, ONE(LA), NOV, ONE(CV), NF) \ - O(IssetG, NA, ONE(CV), ONE(CV), NF) \ - O(IssetS, NA, TWO(CV,CV), ONE(CV), NF) \ - O(IsUnsetL, ONE(LA), NOV, ONE(CV), NF) \ - O(IsTypeC, ONE(OA(IsTypeOp)),ONE(CV), ONE(CV), NF) \ - O(IsTypeL, TWO(NLA, \ - OA(IsTypeOp)), NOV, ONE(CV), NF) \ - O(AssertRATL, TWO(ILA,RATA), NOV, NOV, NF) \ - O(AssertRATStk, TWO(IVA,RATA), NOV, NOV, NF) \ - O(SetL, ONE(LA), ONE(CV), ONE(CV), NF) \ - O(SetG, NA, TWO(CV,CV), ONE(CV), NF) \ - O(SetS, ONE(OA(ReadonlyOp)), \ - THREE(CV,CV,CV), ONE(CV), NF) \ - O(SetOpL, TWO(LA, \ - OA(SetOpOp)), ONE(CV), ONE(CV), NF) \ - O(SetOpG, ONE(OA(SetOpOp)), TWO(CV,CV), ONE(CV), NF) \ - O(SetOpS, ONE(OA(SetOpOp)), THREE(CV,CV,CV), ONE(CV), NF) \ - O(IncDecL, TWO(NLA, OA(IncDecOp)), \ - NOV, ONE(CV), NF) \ - O(IncDecG, ONE(OA(IncDecOp)),ONE(CV), ONE(CV), NF) \ - O(IncDecS, ONE(OA(IncDecOp)),TWO(CV,CV), ONE(CV), NF) \ - O(UnsetL, ONE(LA), NOV, NOV, NF) \ - O(UnsetG, NA, ONE(CV), NOV, NF) \ - \ - O(ResolveFunc, ONE(SA), NOV, ONE(CV), NF) \ - O(ResolveMethCaller,ONE(SA), NOV, ONE(CV), NF) \ - O(ResolveRFunc, ONE(SA), ONE(CV), ONE(CV), NF) \ - O(ResolveClsMethod,ONE(SA), ONE(CV), ONE(CV), NF) \ - O(ResolveClsMethodD, \ - TWO(SA,SA), NOV, ONE(CV), NF) \ - O(ResolveClsMethodS, \ - TWO(OA(SpecialClsRef),SA), \ - NOV, ONE(CV), NF) \ - O(ResolveRClsMethod, \ - ONE(SA), TWO(CV,CV), ONE(CV), NF) \ - O(ResolveRClsMethodD, \ - TWO(SA,SA), ONE(CV), ONE(CV), NF) \ - O(ResolveRClsMethodS, \ - TWO(OA(SpecialClsRef),SA), \ - ONE(CV), ONE(CV), NF) \ - O(ResolveClass, ONE(SA), NOV, ONE(CV), NF) \ - O(LazyClass, ONE(SA), NOV, ONE(CV), NF) \ - O(NewObj, NA, ONE(CV), ONE(CV), NF) \ - O(NewObjR, NA, TWO(CV,CV), ONE(CV), NF) \ - O(NewObjD, ONE(SA), NOV, ONE(CV), NF) \ - O(NewObjRD, ONE(SA), ONE(CV), ONE(CV), NF) \ - O(NewObjS, ONE(OA(SpecialClsRef)), \ - NOV, ONE(CV), NF) \ - O(LockObj, NA, ONE(CV), ONE(CV), NF) \ - O(FCallClsMethod, THREE(FCA,SA,OA(IsLogAsDynamicCallOp)), \ - FCALL(2, 0), FCALL, CF) \ - O(FCallClsMethodD, FOUR(FCA,SA,SA,SA), \ - FCALL(0, 0), FCALL, CF) \ - O(FCallClsMethodS, THREE(FCA,SA,OA(SpecialClsRef)), \ - FCALL(1, 0), FCALL, CF) \ - O(FCallClsMethodSD,FOUR(FCA,SA,OA(SpecialClsRef),SA), \ - FCALL(0, 0), FCALL, CF) \ - O(FCallCtor, TWO(FCA,SA), FCALL(0, 1), FCALL, CF) \ - O(FCallFunc, ONE(FCA), FCALL(1, 0), FCALL, CF) \ - O(FCallFuncD, TWO(FCA,SA), FCALL(0, 0), FCALL, CF) \ - O(FCallObjMethod, THREE(FCA,SA,OA(ObjMethodOp)), \ - FCALL(1, 1), FCALL, CF) \ - O(FCallObjMethodD, FOUR(FCA,SA,OA(ObjMethodOp),SA), \ - FCALL(0, 1), FCALL, CF) \ - O(IterInit, TWO(ITA,BA), ONE(CV), NOV, CF) \ - O(LIterInit, THREE(ITA,LA,BA), NOV, NOV, CF) \ - O(IterNext, TWO(ITA,BA), NOV, NOV, CF) \ - O(LIterNext, THREE(ITA,LA,BA), NOV, NOV, CF) \ - O(IterFree, ONE(IA), NOV, NOV, NF) \ - O(LIterFree, TWO(IA,LA), NOV, NOV, NF) \ - O(Incl, NA, ONE(CV), ONE(CV), NF) \ - O(InclOnce, NA, ONE(CV), ONE(CV), NF) \ - O(Req, NA, ONE(CV), ONE(CV), NF) \ - O(ReqOnce, NA, ONE(CV), ONE(CV), NF) \ - O(ReqDoc, NA, ONE(CV), ONE(CV), NF) \ - O(Eval, NA, ONE(CV), ONE(CV), NF) \ - O(This, NA, NOV, ONE(CV), NF) \ - O(BareThis, ONE(OA(BareThisOp)), \ - NOV, ONE(CV), NF) \ - O(CheckThis, NA, NOV, NOV, NF) \ - O(ChainFaults, NA, TWO(CV,CV), ONE(CV), NF) \ - O(OODeclExists, ONE(OA(OODeclExistsOp)), \ - TWO(CV,CV), ONE(CV), NF) \ - O(VerifyOutType, ONE(IVA), ONE(CV), ONE(CV), NF) \ - O(VerifyParamType, ONE(ILA), NOV, NOV, NF) \ - O(VerifyParamTypeTS, ONE(ILA), ONE(CV), NOV, NF) \ - O(VerifyRetTypeC, NA, ONE(CV), ONE(CV), NF) \ - O(VerifyRetTypeTS, NA, TWO(CV,CV), ONE(CV), NF) \ - O(VerifyRetNonNullC, NA, ONE(CV), ONE(CV), NF) \ - O(SelfCls, NA, NOV, ONE(CV), NF) \ - O(ParentCls, NA, NOV, ONE(CV), NF) \ - O(LateBoundCls, NA, NOV, ONE(CV), NF) \ - O(RecordReifiedGeneric, NA, ONE(CV), ONE(CV), NF) \ - O(CheckReifiedGenericMismatch, NA, ONE(CV), NOV, NF) \ - O(NativeImpl, NA, NOV, NOV, CF_TF) \ - O(CreateCl, TWO(IVA,IVA), CUMANY, ONE(CV), NF) \ - O(CreateCont, NA, NOV, ONE(CV), CF) \ - O(ContEnter, NA, ONE(CV), ONE(CV), CF) \ - O(ContRaise, NA, ONE(CV), ONE(CV), CF) \ - O(Yield, NA, ONE(CV), ONE(CV), CF) \ - O(YieldK, NA, TWO(CV,CV), ONE(CV), CF) \ - O(ContCheck, ONE(OA(ContCheckOp)), NOV, NOV, NF) \ - O(ContValid, NA, NOV, ONE(CV), NF) \ - O(ContKey, NA, NOV, ONE(CV), NF) \ - O(ContCurrent, NA, NOV, ONE(CV), NF) \ - O(ContGetReturn, NA, NOV, ONE(CV), NF) \ - O(WHResult, NA, ONE(CV), ONE(CV), NF) \ - O(SetImplicitContextByValue, \ - NA, ONE(CV), ONE(CV), NF) \ - O(Await, NA, ONE(CV), ONE(CV), CF) \ - O(AwaitAll, ONE(LAR), NOV, ONE(CV), CF) \ - O(Idx, NA, THREE(CV,CV,CV), ONE(CV), NF) \ - O(ArrayIdx, NA, THREE(CV,CV,CV), ONE(CV), NF) \ - O(ArrayMarkLegacy, NA, TWO(CV,CV), ONE(CV), NF) \ - O(ArrayUnmarkLegacy, NA, TWO(CV,CV), ONE(CV), NF) \ - O(CheckProp, ONE(SA), NOV, ONE(CV), NF) \ - O(InitProp, TWO(SA, OA(InitPropOp)), \ - ONE(CV), NOV, NF) \ - O(Silence, TWO(LA,OA(SilenceOp)), \ - NOV, NOV, NF) \ - O(ThrowNonExhaustiveSwitch, NA, NOV, NOV, NF) \ - O(RaiseClassStringConversionWarning, \ - NA, NOV, NOV, NF) \ - O(BaseGC, TWO(IVA, OA(MOpMode)), \ - NOV, NOV, NF) \ - O(BaseGL, TWO(LA, OA(MOpMode)), \ - NOV, NOV, NF) \ - O(BaseSC, FOUR(IVA, IVA, OA(MOpMode), OA(ReadonlyOp)), \ - NOV, NOV, NF) \ - O(BaseL, THREE(NLA, OA(MOpMode), OA(ReadonlyOp)), \ - NOV, NOV, NF) \ - O(BaseC, TWO(IVA, OA(MOpMode)), \ - NOV, NOV, NF) \ - O(BaseH, NA, NOV, NOV, NF) \ - O(Dim, TWO(OA(MOpMode), KA), \ - NOV, NOV, NF) \ - O(QueryM, THREE(IVA, OA(QueryMOp), KA), \ - MFINAL, ONE(CV), NF) \ - O(SetM, TWO(IVA, KA), C_MFINAL(1), ONE(CV), NF) \ - O(SetRangeM, THREE(IVA, IVA, OA(SetRangeOp)), \ - C_MFINAL(3), NOV, NF) \ - O(IncDecM, THREE(IVA, OA(IncDecOp), KA), \ - MFINAL, ONE(CV), NF) \ - O(SetOpM, THREE(IVA, OA(SetOpOp), KA), \ - C_MFINAL(1), ONE(CV), NF) \ - O(UnsetM, TWO(IVA, KA), MFINAL, NOV, NF) \ - O(MemoGet, TWO(BA, LAR), NOV, ONE(CV), CF) \ - O(MemoGetEager, THREE(BA, BA, LAR), \ - NOV, ONE(CV), CF) \ - O(MemoSet, ONE(LAR), ONE(CV), ONE(CV), NF) \ - O(MemoSetEager, ONE(LAR), ONE(CV), ONE(CV), NF) - #define O(...) + 1 constexpr size_t Op_count = OPCODES; #undef O diff --git a/hphp/runtime/vm/opcodes.h b/hphp/runtime/vm/opcodes.h new file mode 100644 index 0000000000000..ca98dcbdd8265 --- /dev/null +++ b/hphp/runtime/vm/opcodes.h @@ -0,0 +1,292 @@ +/* + +----------------------------------------------------------------------+ + | HipHop for PHP | + +----------------------------------------------------------------------+ + | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) | + +----------------------------------------------------------------------+ + | This source file is subject to version 3.01 of the PHP license, | + | that is bundled with this package in the file LICENSE, and is | + | available through the world-wide-web at the following url: | + | http://www.php.net/license/3_01.txt | + | If you did not receive a copy of the PHP license and are unable to | + | obtain it through the world-wide-web, please send a note to | + | license@php.net so we can mail you a copy immediately. | + +----------------------------------------------------------------------+ +*/ + +#pragma once + +/* The OPCODES macro is used in many places across HHVM and HackC. Keeping it + * in this file allows us to keep includes lightweight. + */ + +namespace HPHP { + +// name immediates inputs outputs flags +#define OPCODES \ + O(Nop, NA, NOV, NOV, NF) \ + O(EntryNop, NA, NOV, NOV, NF) \ + O(BreakTraceHint, NA, NOV, NOV, NF) \ + O(PopC, NA, ONE(CV), NOV, NF) \ + O(PopU, NA, ONE(UV), NOV, NF) \ + O(PopU2, NA, TWO(CV,UV), ONE(CV), NF) \ + O(PopL, ONE(LA), ONE(CV), NOV, NF) \ + O(Dup, NA, ONE(CV), TWO(CV,CV), NF) \ + O(CGetCUNop, NA, ONE(CUV), ONE(CV), NF) \ + O(UGetCUNop, NA, ONE(CUV), ONE(UV), NF) \ + O(Null, NA, NOV, ONE(CV), NF) \ + O(NullUninit, NA, NOV, ONE(UV), NF) \ + O(True, NA, NOV, ONE(CV), NF) \ + O(False, NA, NOV, ONE(CV), NF) \ + O(FuncCred, NA, NOV, ONE(CV), NF) \ + O(Int, ONE(I64A), NOV, ONE(CV), NF) \ + O(Double, ONE(DA), NOV, ONE(CV), NF) \ + O(String, ONE(SA), NOV, ONE(CV), NF) \ + O(Dict, ONE(AA), NOV, ONE(CV), NF) \ + O(Keyset, ONE(AA), NOV, ONE(CV), NF) \ + O(Vec, ONE(AA), NOV, ONE(CV), NF) \ + O(NewDictArray, ONE(IVA), NOV, ONE(CV), NF) \ + O(NewStructDict, ONE(VSA), SMANY, ONE(CV), NF) \ + O(NewVec, ONE(IVA), CMANY, ONE(CV), NF) \ + O(NewKeysetArray, ONE(IVA), CMANY, ONE(CV), NF) \ + O(AddElemC, NA, THREE(CV,CV,CV), ONE(CV), NF) \ + O(AddNewElemC, NA, TWO(CV,CV), ONE(CV), NF) \ + O(NewCol, ONE(OA(CollectionType)), \ + NOV, ONE(CV), NF) \ + O(NewPair, NA, TWO(CV,CV), ONE(CV), NF) \ + O(ColFromArray, ONE(OA(CollectionType)), \ + ONE(CV), ONE(CV), NF) \ + O(CnsE, ONE(SA), NOV, ONE(CV), NF) \ + O(ClsCns, ONE(SA), ONE(CV), ONE(CV), NF) \ + O(ClsCnsD, TWO(SA,SA), NOV, ONE(CV), NF) \ + O(ClsCnsL, ONE(LA), ONE(CV), ONE(CV), NF) \ + O(ClassName, NA, ONE(CV), ONE(CV), NF) \ + O(LazyClassFromClass, NA, ONE(CV), ONE(CV), NF) \ + O(File, NA, NOV, ONE(CV), NF) \ + O(Dir, NA, NOV, ONE(CV), NF) \ + O(Method, NA, NOV, ONE(CV), NF) \ + O(Concat, NA, TWO(CV,CV), ONE(CV), NF) \ + O(ConcatN, ONE(IVA), CMANY, ONE(CV), NF) \ + O(Add, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Sub, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Mul, NA, TWO(CV,CV), ONE(CV), NF) \ + O(AddO, NA, TWO(CV,CV), ONE(CV), NF) \ + O(SubO, NA, TWO(CV,CV), ONE(CV), NF) \ + O(MulO, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Div, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Mod, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Pow, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Not, NA, ONE(CV), ONE(CV), NF) \ + O(Same, NA, TWO(CV,CV), ONE(CV), NF) \ + O(NSame, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Eq, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Neq, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Lt, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Lte, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Gt, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Gte, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Cmp, NA, TWO(CV,CV), ONE(CV), NF) \ + O(BitAnd, NA, TWO(CV,CV), ONE(CV), NF) \ + O(BitOr, NA, TWO(CV,CV), ONE(CV), NF) \ + O(BitXor, NA, TWO(CV,CV), ONE(CV), NF) \ + O(BitNot, NA, ONE(CV), ONE(CV), NF) \ + O(Shl, NA, TWO(CV,CV), ONE(CV), NF) \ + O(Shr, NA, TWO(CV,CV), ONE(CV), NF) \ + O(CastBool, NA, ONE(CV), ONE(CV), NF) \ + O(CastInt, NA, ONE(CV), ONE(CV), NF) \ + O(CastDouble, NA, ONE(CV), ONE(CV), NF) \ + O(CastString, NA, ONE(CV), ONE(CV), NF) \ + O(CastDict, NA, ONE(CV), ONE(CV), NF) \ + O(CastKeyset, NA, ONE(CV), ONE(CV), NF) \ + O(CastVec, NA, ONE(CV), ONE(CV), NF) \ + O(DblAsBits, NA, ONE(CV), ONE(CV), NF) \ + O(InstanceOf, NA, TWO(CV,CV), ONE(CV), NF) \ + O(InstanceOfD, ONE(SA), ONE(CV), ONE(CV), NF) \ + O(IsLateBoundCls, NA, ONE(CV), ONE(CV), NF) \ + O(IsTypeStructC, ONE(OA(TypeStructResolveOp)), \ + TWO(CV,CV), ONE(CV), NF) \ + O(ThrowAsTypeStructException, \ + NA, TWO(CV,CV), NOV, TF) \ + O(CombineAndResolveTypeStruct, \ + ONE(IVA), CMANY, ONE(CV), NF) \ + O(Select, NA, THREE(CV,CV,CV), ONE(CV), NF) \ + O(Print, NA, ONE(CV), ONE(CV), NF) \ + O(Clone, NA, ONE(CV), ONE(CV), NF) \ + O(Exit, NA, ONE(CV), ONE(CV), TF) \ + O(Fatal, ONE(OA(FatalOp)), ONE(CV), NOV, TF) \ + O(Jmp, ONE(BA), NOV, NOV, CF_TF) \ + O(JmpNS, ONE(BA), NOV, NOV, CF_TF) \ + O(JmpZ, ONE(BA), ONE(CV), NOV, CF) \ + O(JmpNZ, ONE(BA), ONE(CV), NOV, CF) \ + O(Switch, THREE(OA(SwitchKind),I64A,BLA), \ + ONE(CV), NOV, CF_TF) \ + O(SSwitch, ONE(SLA), ONE(CV), NOV, CF_TF) \ + O(RetC, NA, ONE(CV), NOV, CF_TF) \ + O(RetM, ONE(IVA), CMANY, NOV, CF_TF) \ + O(RetCSuspended, NA, ONE(CV), NOV, CF_TF) \ + O(Throw, NA, ONE(CV), NOV, CF_TF) \ + O(CGetL, ONE(NLA), NOV, ONE(CV), NF) \ + O(CGetQuietL, ONE(LA), NOV, ONE(CV), NF) \ + O(CUGetL, ONE(LA), NOV, ONE(CUV), NF) \ + O(CGetL2, ONE(NLA), ONE(CV), TWO(CV,CV), NF) \ + O(PushL, ONE(LA), NOV, ONE(CV), NF) \ + O(CGetG, NA, ONE(CV), ONE(CV), NF) \ + O(CGetS, ONE(OA(ReadonlyOp)), \ + TWO(CV,CV), ONE(CV), NF) \ + O(ClassGetC, NA, ONE(CV), ONE(CV), NF) \ + O(ClassGetTS, NA, ONE(CV), TWO(CV,CV), NF) \ + O(GetMemoKeyL, ONE(NLA), NOV, ONE(CV), NF) \ + O(AKExists, NA, TWO(CV,CV), ONE(CV), NF) \ + O(IssetL, ONE(LA), NOV, ONE(CV), NF) \ + O(IssetG, NA, ONE(CV), ONE(CV), NF) \ + O(IssetS, NA, TWO(CV,CV), ONE(CV), NF) \ + O(IsUnsetL, ONE(LA), NOV, ONE(CV), NF) \ + O(IsTypeC, ONE(OA(IsTypeOp)),ONE(CV), ONE(CV), NF) \ + O(IsTypeL, TWO(NLA, \ + OA(IsTypeOp)), NOV, ONE(CV), NF) \ + O(AssertRATL, TWO(ILA,RATA), NOV, NOV, NF) \ + O(AssertRATStk, TWO(IVA,RATA), NOV, NOV, NF) \ + O(SetL, ONE(LA), ONE(CV), ONE(CV), NF) \ + O(SetG, NA, TWO(CV,CV), ONE(CV), NF) \ + O(SetS, ONE(OA(ReadonlyOp)), \ + THREE(CV,CV,CV), ONE(CV), NF) \ + O(SetOpL, TWO(LA, \ + OA(SetOpOp)), ONE(CV), ONE(CV), NF) \ + O(SetOpG, ONE(OA(SetOpOp)), TWO(CV,CV), ONE(CV), NF) \ + O(SetOpS, ONE(OA(SetOpOp)), THREE(CV,CV,CV), ONE(CV), NF) \ + O(IncDecL, TWO(NLA, OA(IncDecOp)), \ + NOV, ONE(CV), NF) \ + O(IncDecG, ONE(OA(IncDecOp)),ONE(CV), ONE(CV), NF) \ + O(IncDecS, ONE(OA(IncDecOp)),TWO(CV,CV), ONE(CV), NF) \ + O(UnsetL, ONE(LA), NOV, NOV, NF) \ + O(UnsetG, NA, ONE(CV), NOV, NF) \ + \ + O(ResolveFunc, ONE(SA), NOV, ONE(CV), NF) \ + O(ResolveMethCaller,ONE(SA), NOV, ONE(CV), NF) \ + O(ResolveRFunc, ONE(SA), ONE(CV), ONE(CV), NF) \ + O(ResolveClsMethod,ONE(SA), ONE(CV), ONE(CV), NF) \ + O(ResolveClsMethodD, \ + TWO(SA,SA), NOV, ONE(CV), NF) \ + O(ResolveClsMethodS, \ + TWO(OA(SpecialClsRef),SA), \ + NOV, ONE(CV), NF) \ + O(ResolveRClsMethod, \ + ONE(SA), TWO(CV,CV), ONE(CV), NF) \ + O(ResolveRClsMethodD, \ + TWO(SA,SA), ONE(CV), ONE(CV), NF) \ + O(ResolveRClsMethodS, \ + TWO(OA(SpecialClsRef),SA), \ + ONE(CV), ONE(CV), NF) \ + O(ResolveClass, ONE(SA), NOV, ONE(CV), NF) \ + O(LazyClass, ONE(SA), NOV, ONE(CV), NF) \ + O(NewObj, NA, ONE(CV), ONE(CV), NF) \ + O(NewObjR, NA, TWO(CV,CV), ONE(CV), NF) \ + O(NewObjD, ONE(SA), NOV, ONE(CV), NF) \ + O(NewObjRD, ONE(SA), ONE(CV), ONE(CV), NF) \ + O(NewObjS, ONE(OA(SpecialClsRef)), \ + NOV, ONE(CV), NF) \ + O(LockObj, NA, ONE(CV), ONE(CV), NF) \ + O(FCallClsMethod, THREE(FCA,SA,OA(IsLogAsDynamicCallOp)), \ + FCALL(2, 0), FCALL, CF) \ + O(FCallClsMethodD, FOUR(FCA,SA,SA,SA), \ + FCALL(0, 0), FCALL, CF) \ + O(FCallClsMethodS, THREE(FCA,SA,OA(SpecialClsRef)), \ + FCALL(1, 0), FCALL, CF) \ + O(FCallClsMethodSD,FOUR(FCA,SA,OA(SpecialClsRef),SA), \ + FCALL(0, 0), FCALL, CF) \ + O(FCallCtor, TWO(FCA,SA), FCALL(0, 1), FCALL, CF) \ + O(FCallFunc, ONE(FCA), FCALL(1, 0), FCALL, CF) \ + O(FCallFuncD, TWO(FCA,SA), FCALL(0, 0), FCALL, CF) \ + O(FCallObjMethod, THREE(FCA,SA,OA(ObjMethodOp)), \ + FCALL(1, 1), FCALL, CF) \ + O(FCallObjMethodD, FOUR(FCA,SA,OA(ObjMethodOp),SA), \ + FCALL(0, 1), FCALL, CF) \ + O(IterInit, TWO(ITA,BA), ONE(CV), NOV, CF) \ + O(LIterInit, THREE(ITA,LA,BA), NOV, NOV, CF) \ + O(IterNext, TWO(ITA,BA), NOV, NOV, CF) \ + O(LIterNext, THREE(ITA,LA,BA), NOV, NOV, CF) \ + O(IterFree, ONE(IA), NOV, NOV, NF) \ + O(LIterFree, TWO(IA,LA), NOV, NOV, NF) \ + O(Incl, NA, ONE(CV), ONE(CV), NF) \ + O(InclOnce, NA, ONE(CV), ONE(CV), NF) \ + O(Req, NA, ONE(CV), ONE(CV), NF) \ + O(ReqOnce, NA, ONE(CV), ONE(CV), NF) \ + O(ReqDoc, NA, ONE(CV), ONE(CV), NF) \ + O(Eval, NA, ONE(CV), ONE(CV), NF) \ + O(This, NA, NOV, ONE(CV), NF) \ + O(BareThis, ONE(OA(BareThisOp)), \ + NOV, ONE(CV), NF) \ + O(CheckThis, NA, NOV, NOV, NF) \ + O(ChainFaults, NA, TWO(CV,CV), ONE(CV), NF) \ + O(OODeclExists, ONE(OA(OODeclExistsOp)), \ + TWO(CV,CV), ONE(CV), NF) \ + O(VerifyOutType, ONE(IVA), ONE(CV), ONE(CV), NF) \ + O(VerifyParamType, ONE(ILA), NOV, NOV, NF) \ + O(VerifyParamTypeTS, ONE(ILA), ONE(CV), NOV, NF) \ + O(VerifyRetTypeC, NA, ONE(CV), ONE(CV), NF) \ + O(VerifyRetTypeTS, NA, TWO(CV,CV), ONE(CV), NF) \ + O(VerifyRetNonNullC, NA, ONE(CV), ONE(CV), NF) \ + O(SelfCls, NA, NOV, ONE(CV), NF) \ + O(ParentCls, NA, NOV, ONE(CV), NF) \ + O(LateBoundCls, NA, NOV, ONE(CV), NF) \ + O(RecordReifiedGeneric, NA, ONE(CV), ONE(CV), NF) \ + O(CheckReifiedGenericMismatch, NA, ONE(CV), NOV, NF) \ + O(NativeImpl, NA, NOV, NOV, CF_TF) \ + O(CreateCl, TWO(IVA,IVA), CUMANY, ONE(CV), NF) \ + O(CreateCont, NA, NOV, ONE(CV), CF) \ + O(ContEnter, NA, ONE(CV), ONE(CV), CF) \ + O(ContRaise, NA, ONE(CV), ONE(CV), CF) \ + O(Yield, NA, ONE(CV), ONE(CV), CF) \ + O(YieldK, NA, TWO(CV,CV), ONE(CV), CF) \ + O(ContCheck, ONE(OA(ContCheckOp)), NOV, NOV, NF) \ + O(ContValid, NA, NOV, ONE(CV), NF) \ + O(ContKey, NA, NOV, ONE(CV), NF) \ + O(ContCurrent, NA, NOV, ONE(CV), NF) \ + O(ContGetReturn, NA, NOV, ONE(CV), NF) \ + O(WHResult, NA, ONE(CV), ONE(CV), NF) \ + O(SetImplicitContextByValue, \ + NA, ONE(CV), ONE(CV), NF) \ + O(Await, NA, ONE(CV), ONE(CV), CF) \ + O(AwaitAll, ONE(LAR), NOV, ONE(CV), CF) \ + O(Idx, NA, THREE(CV,CV,CV), ONE(CV), NF) \ + O(ArrayIdx, NA, THREE(CV,CV,CV), ONE(CV), NF) \ + O(ArrayMarkLegacy, NA, TWO(CV,CV), ONE(CV), NF) \ + O(ArrayUnmarkLegacy, NA, TWO(CV,CV), ONE(CV), NF) \ + O(CheckProp, ONE(SA), NOV, ONE(CV), NF) \ + O(InitProp, TWO(SA, OA(InitPropOp)), \ + ONE(CV), NOV, NF) \ + O(Silence, TWO(LA,OA(SilenceOp)), \ + NOV, NOV, NF) \ + O(ThrowNonExhaustiveSwitch, NA, NOV, NOV, NF) \ + O(RaiseClassStringConversionWarning, \ + NA, NOV, NOV, NF) \ + O(BaseGC, TWO(IVA, OA(MOpMode)), \ + NOV, NOV, NF) \ + O(BaseGL, TWO(LA, OA(MOpMode)), \ + NOV, NOV, NF) \ + O(BaseSC, FOUR(IVA, IVA, OA(MOpMode), OA(ReadonlyOp)), \ + NOV, NOV, NF) \ + O(BaseL, THREE(NLA, OA(MOpMode), OA(ReadonlyOp)), \ + NOV, NOV, NF) \ + O(BaseC, TWO(IVA, OA(MOpMode)), \ + NOV, NOV, NF) \ + O(BaseH, NA, NOV, NOV, NF) \ + O(Dim, TWO(OA(MOpMode), KA), \ + NOV, NOV, NF) \ + O(QueryM, THREE(IVA, OA(QueryMOp), KA), \ + MFINAL, ONE(CV), NF) \ + O(SetM, TWO(IVA, KA), C_MFINAL(1), ONE(CV), NF) \ + O(SetRangeM, THREE(IVA, IVA, OA(SetRangeOp)), \ + C_MFINAL(3), NOV, NF) \ + O(IncDecM, THREE(IVA, OA(IncDecOp), KA), \ + MFINAL, ONE(CV), NF) \ + O(SetOpM, THREE(IVA, OA(SetOpOp), KA), \ + C_MFINAL(1), ONE(CV), NF) \ + O(UnsetM, TWO(IVA, KA), MFINAL, NOV, NF) \ + O(MemoGet, TWO(BA, LAR), NOV, ONE(CV), CF) \ + O(MemoGetEager, THREE(BA, BA, LAR), \ + NOV, ONE(CV), CF) \ + O(MemoSet, ONE(LAR), ONE(CV), ONE(CV), NF) \ + O(MemoSetEager, ONE(LAR), ONE(CV), ONE(CV), NF) + +} diff --git a/hphp/tools/hhbc-gen/gen-rust.cpp b/hphp/tools/hhbc-gen/gen-rust.cpp index f6545a21084ef..1342a469f42e2 100644 --- a/hphp/tools/hhbc-gen/gen-rust.cpp +++ b/hphp/tools/hhbc-gen/gen-rust.cpp @@ -15,7 +15,8 @@ */ #include -#include "hphp/runtime/vm/hhbc.h" +#include +#include "hphp/runtime/vm/opcodes.h" using namespace HPHP;