2 +----------------------------------------------------------------------+
4 +----------------------------------------------------------------------+
5 | Copyright (c) 2010- 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 #include "hphp/runtime/vm/translator/immstack.h"
20 ///////////////////////////////////////////////////////////////////////////////
22 void ImmStack::processOpcode(const Opcode
* opcode
) {
23 StackTransInfo sti
= instrStackTransInfo(opcode
);
24 if (sti
.kind
== StackTransInfo::PushPop
) {
25 for (int i
= 0; i
< sti
.numPops
; i
++) {
28 for (int i
= 0; i
< sti
.numPushes
; i
++) {
31 } else if (sti
.kind
== StackTransInfo::InsertMid
) {
38 void ImmStack::pushUnknown() {
41 item
.type
= StackItem::StackType_Unknown
;
42 m_stack
.push_back(item
);
45 void ImmStack::insUnknown(int pos
) {
46 int k
= m_stack
.size() - 1 - pos
;
47 if (k
>= 0 && k
< (int)m_stack
.size()) {
49 item
.type
= StackItem::StackType_Unknown
;
50 m_stack
.insert(m_stack
.begin() + k
, item
);
54 void ImmStack::pop() {
55 // Since we only process on the basic block level, we obviously can pop
56 // locations that we don't track. We treat all these locations as unknowns.
58 if (!m_stack
.empty()) {
63 void ImmStack::pushInt(int64_t value
) {
66 item
.type
= StackItem::StackType_Int
;
69 m_stack
.push_back(item
);
72 void ImmStack::pushLitstr(Id value
) {
75 item
.type
= StackItem::StackType_Litstr
;
78 m_stack
.push_back(item
);
81 ImmStack::StackItem
&ImmStack::get(int above
) {
82 always_assert(above
>= 0 && (size_t)above
< m_stack
.size());
84 return m_stack
[m_stack
.size() - above
- 1];
87 bool ImmStack::isInt(int above
) {
88 if (above
>= (int)m_stack
.size()) {
92 return get(above
).type
== StackItem::StackType_Int
;
95 bool ImmStack::isLitstr(int above
) {
96 if (above
>= (int)m_stack
.size()) {
100 return get(above
).type
== StackItem::StackType_Litstr
;