Store num args instead of offset in prologue and func entry SrcKeys
[hiphop-php.git] / hphp / runtime / vm / jit / translator-inl.h
blob7145e3d9ac2c84b2aa63b1b73f22b52afccb4c71
1 /*
2 +----------------------------------------------------------------------+
3 | HipHop for PHP |
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010-present Facebook, Inc. (http://www.facebook.com) |
6 +----------------------------------------------------------------------+
7 | This source file is subject to version 3.01 of the PHP license, |
8 | that is bundled with this package in the file LICENSE, and is |
9 | available through the world-wide-web at the following url: |
10 | http://www.php.net/license/3_01.txt |
11 | If you did not receive a copy of the PHP license and are unable to |
12 | obtain it through the world-wide-web, please send a note to |
13 | license@php.net so we can mail you a copy immediately. |
14 +----------------------------------------------------------------------+
17 #ifndef incl_HPHP_TRANSLATOR_INL_H_
18 #error "translator-inl.h should only be included by translator.h"
19 #endif
21 namespace HPHP::jit {
23 ///////////////////////////////////////////////////////////////////////////////
24 // Control flow information.
26 inline ControlFlowInfo opcodeControlFlowInfo(const Op op, bool inlining) {
27 switch (op) {
28 case Op::Enter:
29 case Op::Jmp:
30 case Op::JmpZ:
31 case Op::JmpNZ:
32 case Op::Switch:
33 case Op::SSwitch:
34 case Op::CreateCont:
35 case Op::Yield:
36 case Op::YieldK:
37 case Op::RetC:
38 case Op::RetM:
39 case Op::RetCSuspended:
40 case Op::Exit:
41 case Op::Fatal:
42 case Op::IterInit: // May branch to fail case.
43 case Op::LIterInit: // Ditto
44 case Op::IterNext: // Ditto
45 case Op::LIterNext: // Ditto
46 case Op::Throw:
47 case Op::NativeImpl:
48 case Op::BreakTraceHint:
49 case Op::MemoGet:
50 case Op::MemoGetEager:
51 return ControlFlowInfo::BreaksBB;
52 case Op::Await:
53 case Op::AwaitAll:
54 return inlining ? ControlFlowInfo::ChangesPC : ControlFlowInfo::BreaksBB;
55 case Op::FCallClsMethod:
56 case Op::FCallClsMethodM:
57 case Op::FCallClsMethodD:
58 case Op::FCallClsMethodS:
59 case Op::FCallClsMethodSD:
60 case Op::FCallCtor:
61 case Op::FCallFunc:
62 case Op::FCallFuncD:
63 case Op::FCallObjMethod:
64 case Op::FCallObjMethodD:
65 case Op::ContEnter:
66 case Op::ContRaise:
67 return ControlFlowInfo::ChangesPC;
68 default:
69 return ControlFlowInfo::None;
73 inline bool opcodeChangesPC(const Op op) {
74 return opcodeControlFlowInfo(op, false) >= ControlFlowInfo::ChangesPC;
77 inline bool opcodeBreaksBB(const Op op, bool inlining) {
78 if (op == Op::ClsCns || op == Op::CGetS) {
79 // side exits if it misses in the RDS, and may produce an overly
80 // specific type without guarding if the class comes from an
81 // object (during form_region, the class will appear to be a
82 // specific type, but during irgen, it will probably be a generic
83 // type).
85 // We can't mark it BreaksBB because BreaksBB => opcodeChangesPC
86 return true;
88 return opcodeControlFlowInfo(op, inlining) == ControlFlowInfo::BreaksBB;
91 inline bool opcodeIgnoresInnerType(const Op op) {
92 switch (op) {
93 case Op::RetC:
94 case Op::RetCSuspended:
95 case Op::RetM:
96 return true;
97 default:
98 return false;
102 ///////////////////////////////////////////////////////////////////////////////
103 // Input and output information.
105 inline std::string InputInfo::pretty() const {
106 std::string p = show(loc);
107 if (dontBreak) p += ":dc";
108 if (dontGuard) p += ":dg";
109 return p;
112 inline std::string InputInfoVec::pretty() const {
113 std::string retval;
114 for (size_t i = 0; i < size(); i++) {
115 retval += (*this)[i].pretty();
116 if (i != size() - 1) {
117 retval += std::string(" ");
120 return retval;
123 ///////////////////////////////////////////////////////////////////////////////
124 // InstrFlags.
126 namespace InstrFlags {
128 inline Operands operator|(const Operands& l, const Operands& r) {
129 return Operands(int(r) | int(l));
134 ///////////////////////////////////////////////////////////////////////////////