2 * Copyright (c) 2017, Facebook, Inc.
5 * This source code is licensed under the BSD-style license found in the
6 * LICENSE file in the "hack" directory of this source tree. An additional grant
7 * of patent rights can be found in the PATENTS file in the same directory.
17 type repo_auth_type
= string (* see see runtime/base/repo-auth-type.h *)
18 type local_id
= Local.t
21 | Param_unnamed
of int
22 | Param_named
of string
24 type stack_index
= int
25 type class_id
= Hhbc_id.Class.t
27 type function_num
= int
28 type typedef_num
= int
29 type function_id
= Hhbc_id.Function.t
30 type method_id
= Hhbc_id.Method.t
31 type const_id
= Hhbc_id.Const.t
32 type prop_id
= Hhbc_id.Prop.t
34 type classref_id
= int
35 type collection_type
= int
36 (* Conventionally this is "A_" followed by an integer *)
37 type adata_id
= string
39 (* These are the three flavors of value that can live on the stack:
43 * F = function argument
45 * Note: Function argument and uninit are not added to the type
46 * as they are handled separately
48 module Flavor
= struct
49 type t
= Cell
| Ref
| ReturnVal
52 (* When using the PassX instructions we need to emit the right kind *)
53 module PassByRefKind
= struct
54 type t
= AllowCell
| WarnOnCell
| ErrorOnCell
57 module MemberOpMode
= struct
72 end (* of MemberOpMode *)
74 module QueryOp
= struct
84 | CGetQuiet
-> "CGetQuiet"
90 module FatalOp
= struct
99 | Runtime
-> "Runtime"
100 | RuntimeOmitFrame
-> "RuntimeOmitFrame"
104 module MemberKey
= struct
115 end (* Of MemberKey *)
117 type instruct_basic
=
132 type instruct_lit_const
=
141 (* Pseudo instruction that will get translated into appropraite literal
142 * bytecode, with possible reference to .adata *)
143 | TypedValue
of Typed_value.t
148 | NewArray
of int (* capacity hint *)
149 | NewMixedArray
of int (* capacity hint *)
150 | NewDictArray
of int (* capacity hint *)
151 | NewMIArray
of int (* capacity hint *)
152 | NewMSArray
of int (* capacity hint *)
153 | NewLikeArrayL
of local_id
* int (* capacity hint *)
154 | NewPackedArray
of int
155 | NewStructArray
of Litstr.id list
157 | NewKeysetArray
of int
163 | NewCol
of collection_type
164 | ColFromArray
of collection_type
168 | CnsU
of const_id
* Litstr.id
169 | ClsCns
of const_id
* classref_id
170 | ClsCnsD
of const_id
* class_id
176 type instruct_operator
=
218 | InstanceOfD
of class_id
228 type instruct_control_flow
=
233 (* bounded, base, offset vector *)
234 | Switch
of switchkind
* int * Label.t list
235 (* litstr id / offset vector *)
236 | SSwitch
of (Litstr.id
* Label.t
) list
242 type instruct_special_flow
=
243 | Continue
of int * int (* This will be rewritten *)
244 | Break
of int * int * (bool * Iterator.t
) list
(* This will be rewritten *)
248 | CGetQuietL
of local_id
257 | CGetS
of classref_id
261 | VGetS
of classref_id
262 | ClsRefGetL
of local_id
* classref_id
263 | ClsRefGetC
of classref_id
273 | OpScalar
(* Int or Dbl or Str or Bool *)
278 type instruct_isset
=
283 | IssetS
of classref_id
287 | EmptyS
of classref_id
288 | IsTypeC
of istype_op
289 | IsTypeL
of local_id
* istype_op
322 type instruct_mutator
=
326 | SetS
of classref_id
327 | SetOpL
of local_id
* eq_op
330 | SetOpS
of eq_op
* classref_id
331 | IncDecL
of local_id
* incdec_op
332 | IncDecN
of incdec_op
333 | IncDecG
of incdec_op
334 | IncDecS
of incdec_op
* classref_id
338 | BindS
of classref_id
342 | CheckProp
of prop_id
343 | InitProp
of prop_id
* initprop_op
346 | FPushFunc
of num_params
347 | FPushFuncD
of num_params
* function_id
348 | FPushFuncU
of num_params
* function_id
* Litstr.id
349 | FPushObjMethod
of num_params
* Ast.og_null_flavor
350 | FPushObjMethodD
of num_params
* method_id
* Ast.og_null_flavor
351 | FPushClsMethod
of num_params
* classref_id
352 | FPushClsMethodF
of num_params
* classref_id
353 | FPushClsMethodD
of num_params
* method_id
* class_id
354 | FPushCtor
of num_params
* classref_id
355 | FPushCtorD
of num_params
* class_id
356 | FPushCtorI
of num_params
* classref_id
357 | DecodeCufIter
of num_params
* Label.t
358 | FPushCufIter
of num_params
* Iterator.t
359 | FPushCuf
of num_params
360 | FPushCufF
of num_params
361 | FPushCufSafe
of num_params
364 | FPassC
of param_num
365 | FPassCW
of param_num
366 | FPassCE
of param_num
367 | FPassV
of param_num
368 | FPassVNop
of param_num
369 | FPassR
of param_num
370 | FPassL
of param_num
* local_id
371 | FPassN
of param_num
372 | FPassG
of param_num
373 | FPassS
of param_num
* classref_id
374 | FCall
of num_params
375 | FCallD
of num_params
* class_id
* function_id
377 | FCallAwait
of num_params
* class_id
* function_id
378 | FCallUnpack
of num_params
379 | FCallBuiltin
of num_params
* num_params
* Litstr.id
382 | BaseNC
of stack_index
* MemberOpMode.t
383 | BaseNL
of local_id
* MemberOpMode.t
384 | FPassBaseNC
of param_num
* stack_index
385 | FPassBaseNL
of param_num
* local_id
386 | BaseGC
of stack_index
* MemberOpMode.t
387 | BaseGL
of local_id
* MemberOpMode.t
388 | FPassBaseGC
of param_num
* stack_index
389 | FPassBaseGL
of param_num
* local_id
390 | BaseSC
of stack_index
* classref_id
391 | BaseSL
of local_id
* stack_index
392 | BaseL
of local_id
* MemberOpMode.t
393 | FPassBaseL
of param_num
* local_id
394 | BaseC
of stack_index
395 | BaseR
of stack_index
397 | Dim
of MemberOpMode.t
* MemberKey.t
398 | FPassDim
of param_num
* MemberKey.t
400 type instruct_final
=
401 | QueryM
of num_params
* QueryOp.t
* MemberKey.t
402 | VGetM
of num_params
* MemberKey.t
403 | FPassM
of param_num
* num_params
* MemberKey.t
404 | SetM
of num_params
* MemberKey.t
405 | IncDecM
of num_params
* incdec_op
* MemberKey.t
406 | SetOpM
of num_params
* eq_op
* MemberKey.t
407 | BindM
of num_params
* MemberKey.t
408 | UnsetM
of num_params
* MemberKey.t
409 | SetWithRefLML
of local_id
* local_id
410 | SetWithRefRML
of local_id
412 type instruct_iterator
=
413 | IterInit
of Iterator.t
* Label.t
* local_id
414 | IterInitK
of Iterator.t
* Label.t
* local_id
* local_id
415 | WIterInit
of Iterator.t
* Label.t
* local_id
416 | WIterInitK
of Iterator.t
* Label.t
* local_id
* local_id
417 | MIterInit
of Iterator.t
* Label.t
* local_id
418 | MIterInitK
of Iterator.t
* Label.t
* local_id
* local_id
419 | IterNext
of Iterator.t
* Label.t
* local_id
420 | IterNextK
of Iterator.t
* Label.t
* local_id
* local_id
421 | WIterNext
of Iterator.t
* Label.t
* local_id
422 | WIterNextK
of Iterator.t
* Label.t
* local_id
* local_id
423 | MIterNext
of Iterator.t
* Label.t
* local_id
424 | MIterNextK
of Iterator.t
* Label.t
* local_id
* local_id
425 | IterFree
of Iterator.t
426 | MIterFree
of Iterator.t
427 | CIterFree
of Iterator.t
428 | IterBreak
of Label.t
* (bool * Iterator.t
) list
430 type instruct_include_eval_define
=
437 | AliasCls
of Litstr.id
* Litstr.id
438 | DefFunc
of function_num
439 | DefCls
of class_num
440 | DefClsNop
of class_num
442 | DefTypeAlias
of typedef_num
459 | BareThis
of bare_this_op
461 | InitThisLoc
of local_id
462 | StaticLoc
of local_id
* Litstr.id
463 | StaticLocInit
of local_id
* Litstr.id
465 | OODeclExists
of class_kind
466 | VerifyParamType
of param_id
469 | Self
of classref_id
470 | Parent
of classref_id
471 | LateBoundCls
of classref_id
472 | ClsRefName
of classref_id
474 | IncStat
of int * int (* counter id, value *)
476 | CreateCl
of num_params
* class_num
479 | AssertRATL
of local_id
* repo_auth_type
480 | AssertRATStk
of stack_index
* repo_auth_type
482 | Silence
of local_id
* op_silence
483 | GetMemoKeyL
of local_id
488 | MemoSet
of int * local_id
* int
489 | MemoGet
of int * local_id
* int
493 type gen_creation_execution
=
499 | ContCheck
of check_started
505 type gen_delegation
=
509 | ContUnsetDelegate
of free_iterator
511 type async_functions
=
519 | TryCatchLegacyBegin
of Label.t
521 | TryFaultBegin
of Label.t
525 | IBasic
of instruct_basic
526 | IIterator
of instruct_iterator
527 | ILitConst
of instruct_lit_const
528 | IOp
of instruct_operator
529 | IContFlow
of instruct_control_flow
530 | ISpecialFlow
of instruct_special_flow
531 | ICall
of instruct_call
532 | IMisc
of instruct_misc
533 | IGet
of instruct_get
534 | IMutator
of instruct_mutator
535 | IIsset
of instruct_isset
536 | IBase
of instruct_base
537 | IFinal
of instruct_final
539 | ITry
of instruct_try
541 | IAsync
of async_functions
542 | IGenerator
of gen_creation_execution
543 | IIncludeEvalDefine
of instruct_include_eval_define