Add mode to EndCatch
[hiphop-php.git] / hphp / runtime / vm / minstr-state.h
blob9e556816a97c1995561696e679144f56d7513a42
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_RUNTIME_VM_MINSTR_STATE_H_
18 #define incl_HPHP_RUNTIME_VM_MINSTR_STATE_H_
20 #include "hphp/runtime/base/tv-val.h"
21 #include "hphp/runtime/base/typed-value.h"
23 namespace HPHP {
26 * Member instruction property state. If we're checking property type-hints,
27 * this indicates whether the current base is a property. This is needed so we
28 * can forbid the base promoting to a type which isn't allowed by the
29 * type-hint. This state is only live in situations where we have not proven
30 * that promotion cannot happen.
32 * We use the lower bit of the Class* to store whether this property is static
33 * or not. Furthermore, in LOWPTR builds we can pack everything into 64-bits,
34 * which allows for efficient initialization from the TC.
36 struct MInstrPropState {
37 MInstrPropState(): m_cls{0} {}
38 MInstrPropState(const Class* cls, Slot slot, bool isStatic)
39 : m_cls{
40 static_cast<decltype(m_cls)>(
41 reinterpret_cast<uintptr_t>(cls) | (isStatic ? 0x1 : 0x0)
44 , m_slot{slot}
47 const Class* getClass() const {
48 return reinterpret_cast<const Class*>(
49 m_cls & ~static_cast<decltype(m_cls)>(0x1)
52 Slot getSlot() const { return m_slot; }
53 bool isStatic() const { return m_cls & 0x1; }
55 static constexpr ptrdiff_t slotOff() {
56 return offsetof(MInstrPropState, m_slot);
58 static constexpr ptrdiff_t clsOff() {
59 return offsetof(MInstrPropState, m_cls);
62 static constexpr size_t slotSize() {
63 return sizeof(m_slot);
65 static constexpr size_t clsSize() {
66 return sizeof(m_cls);
68 private:
69 LowPtr<const Class>::storage_type m_cls;
70 Slot m_slot;
74 * MInstrState contains VM registers used while executing member instructions.
75 * It lives with the other VM registers in the RDS header, and is also saved and
76 * restored with them when we reenter the VM.
78 struct MInstrState {
81 * This space is used for the return value of builtin functions that return by
82 * reference, and for storing $this as the base for the BaseH bytecode,
83 * without needing to acquire a reference to it. Since we don't ever use the
84 * two at the same time, it is okay to use a union.
86 union {
87 TypedValue tvBuiltinReturn;
88 TypedValue tvTempBase;
91 // The JIT passes &tvBuiltinReturn::m_data to builtins returning
92 // Array/Object/String, which perform RVO in C++, thus writing valid
93 // pointers without updating m_type, preventing the GC from scanning
94 // the pointer. But conservative scanning doesn't really hurt here
95 // (given that the pointer is also passed into a C++ function), and
96 // it allows us to keep rds::Header below 128 bytes.
97 TYPE_SCAN_CONSERVATIVE_FIELD(tvBuiltinReturn);
99 TypedValue tvRef;
100 TypedValue tvRef2;
101 tv_lval base;
103 // type-scan driven scanner
104 TYPE_SCAN_IGNORE_FIELD(base);
106 MInstrPropState propState;
111 #endif