1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 * vim: set ts=4 sw=4 et tw=99:
4 * ***** BEGIN LICENSE BLOCK *****
5 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
7 * The contents of this file are subject to the Mozilla Public License Version
8 * 1.1 (the "License"); you may not use this file except in compliance with
9 * the License. You may obtain a copy of the License at
10 * http://www.mozilla.org/MPL/
12 * Software distributed under the License is distributed on an "AS IS" basis,
13 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14 * for the specific language governing rights and limitations under the
17 * The Original Code is Mozilla SpiderMonkey JavaScript 1.9 code, released
20 * The Initial Developer of the Original Code is
21 * Brendan Eich <brendan@mozilla.org>
24 * David Anderson <danderson@mozilla.com>
26 * Alternatively, the contents of this file may be used under the terms of
27 * either of the GNU General Public License Version 2 or later (the "GPL"),
28 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #if !defined jsjaeger_valueinfo_h__ && defined JS_METHODJIT
41 #define jsjaeger_valueinfo_h__
44 #include "methodjit/MachineRegs.h"
45 #include "methodjit/RematInfo.h"
46 #include "assembler/assembler/MacroAssembler.h"
53 friend class FrameState
;
54 friend class ImmutableSync
;
57 bool isConstant() const {
58 return data
.isConstant();
61 const jsval_layout
&getConstant() const {
62 JS_ASSERT(isConstant());
66 const Value
&getValue() const {
67 JS_ASSERT(isConstant());
68 return Valueify(JSVAL_FROM_LAYOUT(v_
));
71 bool isTypeKnown() const {
72 return type
.isConstant();
75 JSValueType
getKnownType() const {
76 JS_ASSERT(isTypeKnown());
80 #if defined JS_NUNBOX32
81 JSValueTag
getKnownTag() const {
84 #elif defined JS_PUNBOX64
85 JSValueShiftedTag
getKnownShiftedTag() const {
86 return JSValueShiftedTag(v_
.asBits
& JSVAL_TAG_MASK
);
90 // Return true iff the type of this value is definitely known to be type_.
91 bool isType(JSValueType type_
) const {
92 return isTypeKnown() && getKnownType() == type_
;
95 // Return true iff the type of this value is definitely known not to be type_.
96 bool isNotType(JSValueType type_
) const {
97 return isTypeKnown() && getKnownType() != type_
;
100 #if defined JS_NUNBOX32
101 uint32
getPayload32() const {
102 //JS_ASSERT(!Valueify(v_.asBits).isDouble() || type.synced());
103 return v_
.s
.payload
.u32
;
105 #elif defined JS_PUNBOX64
106 uint64
getPayload64() const {
107 return v_
.asBits
& JSVAL_PAYLOAD_MASK
;
111 bool isCachedNumber() const {
116 void setType(JSValueType type_
) {
118 #if defined JS_NUNBOX32
119 v_
.s
.tag
= JSVAL_TYPE_TO_TAG(type_
);
120 #elif defined JS_PUNBOX64
121 v_
.asBits
&= JSVAL_PAYLOAD_MASK
;
122 v_
.asBits
|= JSVAL_TYPE_TO_SHIFTED_TAG(type_
);
125 JS_ASSERT(!isNumber
);
128 void track(uint32 index
) {
140 uint32
trackerIndex() {
145 * Marks the FE as unsynced & invalid.
147 void resetUnsynced() {
158 * Marks the FE as synced & in memory.
167 * Marks the FE as having a constant.
169 void setConstant(const jsval
&v
) {
175 v_
.asBits
= JSVAL_BITS(v
);
176 Value cv
= Valueify(v
);
178 knownType
= JSVAL_TYPE_DOUBLE
;
180 knownType
= cv
.extractNonDoubleType();
183 bool isCopied() const {
188 JS_ASSERT(!isCopy());
192 bool isCopy() const {
196 FrameEntry
*copyOf() const {
201 void setNotCopied() {
208 void setCopyOf(FrameEntry
*fe
) {
209 JS_ASSERT_IF(fe
, !fe
->isConstant());
210 JS_ASSERT(!isCopied());
214 inline bool isTracked() const {
218 inline void untrack() {
223 JSValueType knownType
;
235 } /* namespace mjit */
238 #endif /* jsjaeger_valueinfo_h__ */