vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 1 | // Copyright 2011 the V8 project authors. All rights reserved. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2 | // Redistribution and use in source and binary forms, with or without |
| 3 | // modification, are permitted provided that the following conditions are |
| 4 | // met: |
| 5 | // |
| 6 | // * Redistributions of source code must retain the above copyright |
| 7 | // notice, this list of conditions and the following disclaimer. |
| 8 | // * Redistributions in binary form must reproduce the above |
| 9 | // copyright notice, this list of conditions and the following |
| 10 | // disclaimer in the documentation and/or other materials provided |
| 11 | // with the distribution. |
| 12 | // * Neither the name of Google Inc. nor the names of its |
| 13 | // contributors may be used to endorse or promote products derived |
| 14 | // from this software without specific prior written permission. |
| 15 | // |
| 16 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 17 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 18 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 19 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 20 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 21 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 22 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | |
| 28 | #ifndef V8_HYDROGEN_INSTRUCTIONS_H_ |
| 29 | #define V8_HYDROGEN_INSTRUCTIONS_H_ |
| 30 | |
| 31 | #include "v8.h" |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 32 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 33 | #include "allocation.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 34 | #include "code-stubs.h" |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 35 | #include "data-flow.h" |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 36 | #include "small-pointer-list.h" |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 37 | #include "string-stream.h" |
| 38 | #include "zone.h" |
| 39 | |
| 40 | namespace v8 { |
| 41 | namespace internal { |
| 42 | |
| 43 | // Forward declarations. |
| 44 | class HBasicBlock; |
| 45 | class HEnvironment; |
| 46 | class HInstruction; |
| 47 | class HLoopInformation; |
| 48 | class HValue; |
| 49 | class LInstruction; |
| 50 | class LChunkBuilder; |
| 51 | |
| 52 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 53 | #define HYDROGEN_ABSTRACT_INSTRUCTION_LIST(V) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 54 | V(BitwiseBinaryOperation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 55 | V(ControlInstruction) \ |
| 56 | V(Instruction) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 57 | |
| 58 | |
| 59 | #define HYDROGEN_CONCRETE_INSTRUCTION_LIST(V) \ |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 60 | V(AbnormalExit) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 61 | V(AccessArgumentsAt) \ |
| 62 | V(Add) \ |
| 63 | V(ApplyArguments) \ |
| 64 | V(ArgumentsElements) \ |
| 65 | V(ArgumentsLength) \ |
| 66 | V(ArgumentsObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 67 | V(ArrayLiteral) \ |
| 68 | V(BitAnd) \ |
| 69 | V(BitNot) \ |
| 70 | V(BitOr) \ |
| 71 | V(BitXor) \ |
| 72 | V(BlockEntry) \ |
| 73 | V(BoundsCheck) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 74 | V(CallConstantFunction) \ |
| 75 | V(CallFunction) \ |
| 76 | V(CallGlobal) \ |
| 77 | V(CallKeyed) \ |
| 78 | V(CallKnownGlobal) \ |
| 79 | V(CallNamed) \ |
| 80 | V(CallNew) \ |
| 81 | V(CallRuntime) \ |
| 82 | V(CallStub) \ |
| 83 | V(Change) \ |
| 84 | V(CheckFunction) \ |
| 85 | V(CheckInstanceType) \ |
| 86 | V(CheckMap) \ |
| 87 | V(CheckNonSmi) \ |
| 88 | V(CheckPrototypeMaps) \ |
| 89 | V(CheckSmi) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 90 | V(ClampToUint8) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 91 | V(ClassOfTest) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 92 | V(Compare) \ |
| 93 | V(CompareJSObjectEq) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 94 | V(CompareMap) \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 95 | V(CompareSymbolEq) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 96 | V(Constant) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 97 | V(Context) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 98 | V(DeleteProperty) \ |
| 99 | V(Deoptimize) \ |
| 100 | V(Div) \ |
| 101 | V(EnterInlined) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 102 | V(ExternalArrayLength) \ |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 103 | V(FixedArrayLength) \ |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame^] | 104 | V(ToInt32) \ |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 105 | V(ForceRepresentation) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 106 | V(FunctionLiteral) \ |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 107 | V(GetCachedArrayIndex) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 108 | V(GlobalObject) \ |
| 109 | V(GlobalReceiver) \ |
| 110 | V(Goto) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 111 | V(HasInstanceType) \ |
| 112 | V(HasCachedArrayIndex) \ |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 113 | V(In) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 114 | V(InstanceOf) \ |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 115 | V(InstanceOfKnownGlobal) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 116 | V(InvokeFunction) \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 117 | V(IsConstructCall) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 118 | V(IsNull) \ |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 119 | V(IsObject) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 120 | V(IsSmi) \ |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 121 | V(IsUndetectable) \ |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 122 | V(JSArrayLength) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 123 | V(LeaveInlined) \ |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 124 | V(LoadContextSlot) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 125 | V(LoadElements) \ |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 126 | V(LoadExternalArrayPointer) \ |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 127 | V(LoadFunctionPrototype) \ |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 128 | V(LoadGlobalCell) \ |
| 129 | V(LoadGlobalGeneric) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 130 | V(LoadKeyedFastElement) \ |
| 131 | V(LoadKeyedGeneric) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 132 | V(LoadKeyedSpecializedArrayElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 133 | V(LoadNamedField) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 134 | V(LoadNamedFieldPolymorphic) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 135 | V(LoadNamedGeneric) \ |
| 136 | V(Mod) \ |
| 137 | V(Mul) \ |
| 138 | V(ObjectLiteral) \ |
| 139 | V(OsrEntry) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 140 | V(OuterContext) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 141 | V(Parameter) \ |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 142 | V(Power) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 143 | V(PushArgument) \ |
| 144 | V(RegExpLiteral) \ |
| 145 | V(Return) \ |
| 146 | V(Sar) \ |
| 147 | V(Shl) \ |
| 148 | V(Shr) \ |
| 149 | V(Simulate) \ |
| 150 | V(StackCheck) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 151 | V(StoreContextSlot) \ |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 152 | V(StoreGlobalCell) \ |
| 153 | V(StoreGlobalGeneric) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 154 | V(StoreKeyedFastElement) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 155 | V(StoreKeyedSpecializedArrayElement) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 156 | V(StoreKeyedGeneric) \ |
| 157 | V(StoreNamedField) \ |
| 158 | V(StoreNamedGeneric) \ |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 159 | V(StringAdd) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 160 | V(StringCharCodeAt) \ |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 161 | V(StringCharFromCode) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 162 | V(StringLength) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 163 | V(Sub) \ |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 164 | V(Test) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 165 | V(Throw) \ |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 166 | V(ToFastProperties) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 167 | V(Typeof) \ |
| 168 | V(TypeofIs) \ |
| 169 | V(UnaryMathOperation) \ |
| 170 | V(UnknownOSRValue) \ |
| 171 | V(ValueOf) |
| 172 | |
| 173 | #define GVN_FLAG_LIST(V) \ |
| 174 | V(Calls) \ |
| 175 | V(InobjectFields) \ |
| 176 | V(BackingStoreFields) \ |
| 177 | V(ArrayElements) \ |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 178 | V(SpecializedArrayElements) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 179 | V(GlobalVars) \ |
| 180 | V(Maps) \ |
| 181 | V(ArrayLengths) \ |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 182 | V(ContextSlots) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 183 | V(OsrEntries) |
| 184 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 185 | #define DECLARE_ABSTRACT_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 186 | virtual bool Is##type() const { return true; } \ |
| 187 | static H##type* cast(HValue* value) { \ |
| 188 | ASSERT(value->Is##type()); \ |
| 189 | return reinterpret_cast<H##type*>(value); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 190 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 191 | |
| 192 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 193 | #define DECLARE_CONCRETE_INSTRUCTION(type) \ |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 194 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder); \ |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 195 | static H##type* cast(HValue* value) { \ |
| 196 | ASSERT(value->Is##type()); \ |
| 197 | return reinterpret_cast<H##type*>(value); \ |
| 198 | } \ |
| 199 | virtual Opcode opcode() const { return HValue::k##type; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 200 | |
| 201 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 202 | class Range: public ZoneObject { |
| 203 | public: |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 204 | Range() |
| 205 | : lower_(kMinInt), |
| 206 | upper_(kMaxInt), |
| 207 | next_(NULL), |
| 208 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 209 | |
| 210 | Range(int32_t lower, int32_t upper) |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 211 | : lower_(lower), |
| 212 | upper_(upper), |
| 213 | next_(NULL), |
| 214 | can_be_minus_zero_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 215 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 216 | int32_t upper() const { return upper_; } |
| 217 | int32_t lower() const { return lower_; } |
| 218 | Range* next() const { return next_; } |
| 219 | Range* CopyClearLower() const { return new Range(kMinInt, upper_); } |
| 220 | Range* CopyClearUpper() const { return new Range(lower_, kMaxInt); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 221 | Range* Copy() const { return new Range(lower_, upper_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 222 | int32_t Mask() const; |
| 223 | void set_can_be_minus_zero(bool b) { can_be_minus_zero_ = b; } |
| 224 | bool CanBeMinusZero() const { return CanBeZero() && can_be_minus_zero_; } |
| 225 | bool CanBeZero() const { return upper_ >= 0 && lower_ <= 0; } |
| 226 | bool CanBeNegative() const { return lower_ < 0; } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 227 | bool Includes(int value) const { return lower_ <= value && upper_ >= value; } |
| 228 | bool IsMostGeneric() const { return lower_ == kMinInt && upper_ == kMaxInt; } |
| 229 | bool IsInSmiRange() const { |
| 230 | return lower_ >= Smi::kMinValue && upper_ <= Smi::kMaxValue; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 231 | } |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 232 | void KeepOrder(); |
| 233 | void Verify() const; |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 234 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 235 | void StackUpon(Range* other) { |
| 236 | Intersect(other); |
| 237 | next_ = other; |
| 238 | } |
| 239 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 240 | void Intersect(Range* other); |
| 241 | void Union(Range* other); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 242 | |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 243 | void AddConstant(int32_t value); |
| 244 | void Sar(int32_t value); |
| 245 | void Shl(int32_t value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 246 | bool AddAndCheckOverflow(Range* other); |
| 247 | bool SubAndCheckOverflow(Range* other); |
| 248 | bool MulAndCheckOverflow(Range* other); |
| 249 | |
| 250 | private: |
| 251 | int32_t lower_; |
| 252 | int32_t upper_; |
| 253 | Range* next_; |
| 254 | bool can_be_minus_zero_; |
| 255 | }; |
| 256 | |
| 257 | |
| 258 | class Representation { |
| 259 | public: |
| 260 | enum Kind { |
| 261 | kNone, |
| 262 | kTagged, |
| 263 | kDouble, |
| 264 | kInteger32, |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 265 | kExternal, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 266 | kNumRepresentations |
| 267 | }; |
| 268 | |
| 269 | Representation() : kind_(kNone) { } |
| 270 | |
| 271 | static Representation None() { return Representation(kNone); } |
| 272 | static Representation Tagged() { return Representation(kTagged); } |
| 273 | static Representation Integer32() { return Representation(kInteger32); } |
| 274 | static Representation Double() { return Representation(kDouble); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 275 | static Representation External() { return Representation(kExternal); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 276 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 277 | bool Equals(const Representation& other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 278 | return kind_ == other.kind_; |
| 279 | } |
| 280 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 281 | Kind kind() const { return static_cast<Kind>(kind_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 282 | bool IsNone() const { return kind_ == kNone; } |
| 283 | bool IsTagged() const { return kind_ == kTagged; } |
| 284 | bool IsInteger32() const { return kind_ == kInteger32; } |
| 285 | bool IsDouble() const { return kind_ == kDouble; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 286 | bool IsExternal() const { return kind_ == kExternal; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 287 | bool IsSpecialization() const { |
| 288 | return kind_ == kInteger32 || kind_ == kDouble; |
| 289 | } |
| 290 | const char* Mnemonic() const; |
| 291 | |
| 292 | private: |
| 293 | explicit Representation(Kind k) : kind_(k) { } |
| 294 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 295 | // Make sure kind fits in int8. |
| 296 | STATIC_ASSERT(kNumRepresentations <= (1 << kBitsPerByte)); |
| 297 | |
| 298 | int8_t kind_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 299 | }; |
| 300 | |
| 301 | |
| 302 | class HType { |
| 303 | public: |
| 304 | HType() : type_(kUninitialized) { } |
| 305 | |
| 306 | static HType Tagged() { return HType(kTagged); } |
| 307 | static HType TaggedPrimitive() { return HType(kTaggedPrimitive); } |
| 308 | static HType TaggedNumber() { return HType(kTaggedNumber); } |
| 309 | static HType Smi() { return HType(kSmi); } |
| 310 | static HType HeapNumber() { return HType(kHeapNumber); } |
| 311 | static HType String() { return HType(kString); } |
| 312 | static HType Boolean() { return HType(kBoolean); } |
| 313 | static HType NonPrimitive() { return HType(kNonPrimitive); } |
| 314 | static HType JSArray() { return HType(kJSArray); } |
| 315 | static HType JSObject() { return HType(kJSObject); } |
| 316 | static HType Uninitialized() { return HType(kUninitialized); } |
| 317 | |
| 318 | // Return the weakest (least precise) common type. |
| 319 | HType Combine(HType other) { |
| 320 | return HType(static_cast<Type>(type_ & other.type_)); |
| 321 | } |
| 322 | |
| 323 | bool Equals(const HType& other) { |
| 324 | return type_ == other.type_; |
| 325 | } |
| 326 | |
| 327 | bool IsSubtypeOf(const HType& other) { |
| 328 | return Combine(other).Equals(other); |
| 329 | } |
| 330 | |
| 331 | bool IsTagged() { |
| 332 | ASSERT(type_ != kUninitialized); |
| 333 | return ((type_ & kTagged) == kTagged); |
| 334 | } |
| 335 | |
| 336 | bool IsTaggedPrimitive() { |
| 337 | ASSERT(type_ != kUninitialized); |
| 338 | return ((type_ & kTaggedPrimitive) == kTaggedPrimitive); |
| 339 | } |
| 340 | |
| 341 | bool IsTaggedNumber() { |
| 342 | ASSERT(type_ != kUninitialized); |
| 343 | return ((type_ & kTaggedNumber) == kTaggedNumber); |
| 344 | } |
| 345 | |
| 346 | bool IsSmi() { |
| 347 | ASSERT(type_ != kUninitialized); |
| 348 | return ((type_ & kSmi) == kSmi); |
| 349 | } |
| 350 | |
| 351 | bool IsHeapNumber() { |
| 352 | ASSERT(type_ != kUninitialized); |
| 353 | return ((type_ & kHeapNumber) == kHeapNumber); |
| 354 | } |
| 355 | |
| 356 | bool IsString() { |
| 357 | ASSERT(type_ != kUninitialized); |
| 358 | return ((type_ & kString) == kString); |
| 359 | } |
| 360 | |
| 361 | bool IsBoolean() { |
| 362 | ASSERT(type_ != kUninitialized); |
| 363 | return ((type_ & kBoolean) == kBoolean); |
| 364 | } |
| 365 | |
| 366 | bool IsNonPrimitive() { |
| 367 | ASSERT(type_ != kUninitialized); |
| 368 | return ((type_ & kNonPrimitive) == kNonPrimitive); |
| 369 | } |
| 370 | |
| 371 | bool IsJSArray() { |
| 372 | ASSERT(type_ != kUninitialized); |
| 373 | return ((type_ & kJSArray) == kJSArray); |
| 374 | } |
| 375 | |
| 376 | bool IsJSObject() { |
| 377 | ASSERT(type_ != kUninitialized); |
| 378 | return ((type_ & kJSObject) == kJSObject); |
| 379 | } |
| 380 | |
| 381 | bool IsUninitialized() { |
| 382 | return type_ == kUninitialized; |
| 383 | } |
| 384 | |
| 385 | static HType TypeFromValue(Handle<Object> value); |
| 386 | |
| 387 | const char* ToString(); |
| 388 | const char* ToShortString(); |
| 389 | |
| 390 | private: |
| 391 | enum Type { |
| 392 | kTagged = 0x1, // 0000 0000 0000 0001 |
| 393 | kTaggedPrimitive = 0x5, // 0000 0000 0000 0101 |
| 394 | kTaggedNumber = 0xd, // 0000 0000 0000 1101 |
| 395 | kSmi = 0x1d, // 0000 0000 0001 1101 |
| 396 | kHeapNumber = 0x2d, // 0000 0000 0010 1101 |
| 397 | kString = 0x45, // 0000 0000 0100 0101 |
| 398 | kBoolean = 0x85, // 0000 0000 1000 0101 |
| 399 | kNonPrimitive = 0x101, // 0000 0001 0000 0001 |
| 400 | kJSObject = 0x301, // 0000 0011 0000 0001 |
| 401 | kJSArray = 0x701, // 0000 0111 1000 0001 |
| 402 | kUninitialized = 0x1fff // 0001 1111 1111 1111 |
| 403 | }; |
| 404 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 405 | // Make sure type fits in int16. |
| 406 | STATIC_ASSERT(kUninitialized < (1 << (2 * kBitsPerByte))); |
| 407 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 408 | explicit HType(Type t) : type_(t) { } |
| 409 | |
ager@chromium.org | a9aa5fa | 2011-04-13 08:46:07 +0000 | [diff] [blame] | 410 | int16_t type_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 411 | }; |
| 412 | |
| 413 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 414 | class HUseListNode: public ZoneObject { |
| 415 | public: |
| 416 | HUseListNode(HValue* value, int index, HUseListNode* tail) |
| 417 | : tail_(tail), value_(value), index_(index) { |
| 418 | } |
| 419 | |
| 420 | HUseListNode* tail() const { return tail_; } |
| 421 | HValue* value() const { return value_; } |
| 422 | int index() const { return index_; } |
| 423 | |
| 424 | void set_tail(HUseListNode* list) { tail_ = list; } |
| 425 | |
| 426 | #ifdef DEBUG |
| 427 | void Zap() { |
| 428 | tail_ = reinterpret_cast<HUseListNode*>(1); |
| 429 | value_ = NULL; |
| 430 | index_ = -1; |
| 431 | } |
| 432 | #endif |
| 433 | |
| 434 | private: |
| 435 | HUseListNode* tail_; |
| 436 | HValue* value_; |
| 437 | int index_; |
| 438 | }; |
| 439 | |
| 440 | |
| 441 | // We reuse use list nodes behind the scenes as uses are added and deleted. |
| 442 | // This class is the safe way to iterate uses while deleting them. |
| 443 | class HUseIterator BASE_EMBEDDED { |
| 444 | public: |
| 445 | bool Done() { return current_ == NULL; } |
| 446 | void Advance(); |
| 447 | |
| 448 | HValue* value() { |
| 449 | ASSERT(!Done()); |
| 450 | return value_; |
| 451 | } |
| 452 | |
| 453 | int index() { |
| 454 | ASSERT(!Done()); |
| 455 | return index_; |
| 456 | } |
| 457 | |
| 458 | private: |
| 459 | explicit HUseIterator(HUseListNode* head); |
| 460 | |
| 461 | HUseListNode* current_; |
| 462 | HUseListNode* next_; |
| 463 | HValue* value_; |
| 464 | int index_; |
| 465 | |
| 466 | friend class HValue; |
| 467 | }; |
| 468 | |
| 469 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 470 | class HValue: public ZoneObject { |
| 471 | public: |
| 472 | static const int kNoNumber = -1; |
| 473 | |
| 474 | // There must be one corresponding kDepends flag for every kChanges flag and |
| 475 | // the order of the kChanges flags must be exactly the same as of the kDepends |
| 476 | // flags. |
| 477 | enum Flag { |
| 478 | // Declare global value numbering flags. |
| 479 | #define DECLARE_DO(type) kChanges##type, kDependsOn##type, |
| 480 | GVN_FLAG_LIST(DECLARE_DO) |
| 481 | #undef DECLARE_DO |
| 482 | kFlexibleRepresentation, |
| 483 | kUseGVN, |
| 484 | kCanOverflow, |
| 485 | kBailoutOnMinusZero, |
| 486 | kCanBeDivByZero, |
| 487 | kIsArguments, |
| 488 | kTruncatingToInt32, |
| 489 | kLastFlag = kTruncatingToInt32 |
| 490 | }; |
| 491 | |
| 492 | STATIC_ASSERT(kLastFlag < kBitsPerInt); |
| 493 | |
| 494 | static const int kChangesToDependsFlagsLeftShift = 1; |
| 495 | |
| 496 | static int ChangesFlagsMask() { |
| 497 | int result = 0; |
| 498 | // Create changes mask. |
| 499 | #define DECLARE_DO(type) result |= (1 << kChanges##type); |
| 500 | GVN_FLAG_LIST(DECLARE_DO) |
| 501 | #undef DECLARE_DO |
| 502 | return result; |
| 503 | } |
| 504 | |
| 505 | static int DependsFlagsMask() { |
| 506 | return ConvertChangesToDependsFlags(ChangesFlagsMask()); |
| 507 | } |
| 508 | |
| 509 | static int ConvertChangesToDependsFlags(int flags) { |
| 510 | return flags << kChangesToDependsFlagsLeftShift; |
| 511 | } |
| 512 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 513 | static HValue* cast(HValue* value) { return value; } |
| 514 | |
| 515 | enum Opcode { |
| 516 | // Declare a unique enum value for each hydrogen instruction. |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 517 | #define DECLARE_OPCODE(type) k##type, |
| 518 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 519 | kPhi |
| 520 | #undef DECLARE_OPCODE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 521 | }; |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 522 | virtual Opcode opcode() const = 0; |
| 523 | |
| 524 | // Declare a non-virtual predicates for each concrete HInstruction or HValue. |
| 525 | #define DECLARE_PREDICATE(type) \ |
| 526 | bool Is##type() const { return opcode() == k##type; } |
| 527 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 528 | #undef DECLARE_PREDICATE |
| 529 | bool IsPhi() const { return opcode() == kPhi; } |
| 530 | |
| 531 | // Declare virtual predicates for abstract HInstruction or HValue |
| 532 | #define DECLARE_PREDICATE(type) \ |
| 533 | virtual bool Is##type() const { return false; } |
| 534 | HYDROGEN_ABSTRACT_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 535 | #undef DECLARE_PREDICATE |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 536 | |
| 537 | HValue() : block_(NULL), |
| 538 | id_(kNoNumber), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 539 | type_(HType::Tagged()), |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 540 | use_list_(NULL), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 541 | range_(NULL), |
| 542 | flags_(0) {} |
| 543 | virtual ~HValue() {} |
| 544 | |
| 545 | HBasicBlock* block() const { return block_; } |
| 546 | void SetBlock(HBasicBlock* block); |
| 547 | |
| 548 | int id() const { return id_; } |
| 549 | void set_id(int id) { id_ = id; } |
| 550 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 551 | HUseIterator uses() const { return HUseIterator(use_list_); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 552 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 553 | virtual bool EmitAtUses() { return false; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 554 | Representation representation() const { return representation_; } |
| 555 | void ChangeRepresentation(Representation r) { |
| 556 | // Representation was already set and is allowed to be changed. |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 557 | ASSERT(!r.IsNone()); |
| 558 | ASSERT(CheckFlag(kFlexibleRepresentation)); |
| 559 | RepresentationChanged(r); |
| 560 | representation_ = r; |
| 561 | } |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 562 | void AssumeRepresentation(Representation r); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 563 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 564 | virtual bool IsConvertibleToInteger() const { return true; } |
| 565 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 566 | HType type() const { return type_; } |
| 567 | void set_type(HType type) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 568 | ASSERT(HasNoUses()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 569 | type_ = type; |
| 570 | } |
| 571 | |
| 572 | // An operation needs to override this function iff: |
| 573 | // 1) it can produce an int32 output. |
| 574 | // 2) the true value of its output can potentially be minus zero. |
| 575 | // The implementation must set a flag so that it bails out in the case where |
| 576 | // it would otherwise output what should be a minus zero as an int32 zero. |
| 577 | // If the operation also exists in a form that takes int32 and outputs int32 |
| 578 | // then the operation should return its input value so that we can propagate |
| 579 | // back. There are two operations that need to propagate back to more than |
| 580 | // one input. They are phi and binary add. They always return NULL and |
| 581 | // expect the caller to take care of things. |
| 582 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited) { |
| 583 | visited->Add(id()); |
| 584 | return NULL; |
| 585 | } |
| 586 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 587 | bool IsDefinedAfter(HBasicBlock* other) const; |
| 588 | |
| 589 | // Operands. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 590 | virtual int OperandCount() = 0; |
| 591 | virtual HValue* OperandAt(int index) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 592 | void SetOperandAt(int index, HValue* value); |
| 593 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 594 | void DeleteAndReplaceWith(HValue* other); |
| 595 | bool HasNoUses() const { return use_list_ == NULL; } |
| 596 | bool HasMultipleUses() const { |
| 597 | return use_list_ != NULL && use_list_->tail() != NULL; |
| 598 | } |
| 599 | int UseCount() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 600 | void ClearOperands(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 601 | |
| 602 | int flags() const { return flags_; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 603 | void SetFlag(Flag f) { flags_ |= (1 << f); } |
| 604 | void ClearFlag(Flag f) { flags_ &= ~(1 << f); } |
| 605 | bool CheckFlag(Flag f) const { return (flags_ & (1 << f)) != 0; } |
| 606 | |
| 607 | void SetAllSideEffects() { flags_ |= AllSideEffects(); } |
| 608 | void ClearAllSideEffects() { flags_ &= ~AllSideEffects(); } |
| 609 | bool HasSideEffects() const { return (flags_ & AllSideEffects()) != 0; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 610 | |
| 611 | Range* range() const { return range_; } |
| 612 | bool HasRange() const { return range_ != NULL; } |
| 613 | void AddNewRange(Range* r); |
| 614 | void RemoveLastAddedRange(); |
| 615 | void ComputeInitialRange(); |
| 616 | |
| 617 | // Representation helpers. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 618 | virtual Representation RequiredInputRepresentation(int index) const = 0; |
| 619 | |
| 620 | virtual Representation InferredRepresentation() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 621 | return representation(); |
| 622 | } |
| 623 | |
| 624 | // This gives the instruction an opportunity to replace itself with an |
| 625 | // instruction that does the same in some better way. To replace an |
| 626 | // instruction with a new one, first add the new instruction to the graph, |
| 627 | // then return it. Return NULL to have the instruction deleted. |
| 628 | virtual HValue* Canonicalize() { return this; } |
| 629 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 630 | bool Equals(HValue* other); |
| 631 | virtual intptr_t Hashcode(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 632 | |
| 633 | // Printing support. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 634 | virtual void PrintTo(StringStream* stream) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 635 | void PrintNameTo(StringStream* stream); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 636 | void PrintTypeTo(StringStream* stream); |
| 637 | void PrintRangeTo(StringStream* stream); |
| 638 | void PrintChangesTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 639 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 640 | const char* Mnemonic() const; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 641 | |
| 642 | // Updated the inferred type of this instruction and returns true if |
| 643 | // it has changed. |
| 644 | bool UpdateInferredType(); |
| 645 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 646 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 647 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 648 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 649 | virtual void Verify() = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 650 | #endif |
| 651 | |
| 652 | protected: |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 653 | // This function must be overridden for instructions with flag kUseGVN, to |
| 654 | // compare the non-Operand parts of the instruction. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 655 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 656 | UNREACHABLE(); |
| 657 | return false; |
| 658 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 659 | virtual void RepresentationChanged(Representation to) { } |
| 660 | virtual Range* InferRange(); |
| 661 | virtual void DeleteFromGraph() = 0; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 662 | virtual void InternalSetOperandAt(int index, HValue* value) = 0; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 663 | void clear_block() { |
| 664 | ASSERT(block_ != NULL); |
| 665 | block_ = NULL; |
| 666 | } |
| 667 | |
| 668 | void set_representation(Representation r) { |
| 669 | // Representation is set-once. |
| 670 | ASSERT(representation_.IsNone() && !r.IsNone()); |
| 671 | representation_ = r; |
| 672 | } |
| 673 | |
| 674 | private: |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 675 | // A flag mask to mark an instruction as having arbitrary side effects. |
| 676 | static int AllSideEffects() { |
| 677 | return ChangesFlagsMask() & ~(1 << kChangesOsrEntries); |
| 678 | } |
| 679 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 680 | // Remove the matching use from the use list if present. Returns the |
| 681 | // removed list node or NULL. |
| 682 | HUseListNode* RemoveUse(HValue* value, int index); |
| 683 | |
| 684 | void ReplaceAllUsesWith(HValue* other); |
| 685 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 686 | void RegisterUse(int index, HValue* new_value); |
| 687 | |
| 688 | HBasicBlock* block_; |
| 689 | |
| 690 | // The id of this instruction in the hydrogen graph, assigned when first |
| 691 | // added to the graph. Reflects creation order. |
| 692 | int id_; |
| 693 | |
| 694 | Representation representation_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 695 | HType type_; |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 696 | HUseListNode* use_list_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 697 | Range* range_; |
| 698 | int flags_; |
| 699 | |
| 700 | DISALLOW_COPY_AND_ASSIGN(HValue); |
| 701 | }; |
| 702 | |
| 703 | |
| 704 | class HInstruction: public HValue { |
| 705 | public: |
| 706 | HInstruction* next() const { return next_; } |
| 707 | HInstruction* previous() const { return previous_; } |
| 708 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 709 | virtual void PrintTo(StringStream* stream); |
| 710 | virtual void PrintDataTo(StringStream* stream) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 711 | |
| 712 | bool IsLinked() const { return block() != NULL; } |
| 713 | void Unlink(); |
| 714 | void InsertBefore(HInstruction* next); |
| 715 | void InsertAfter(HInstruction* previous); |
| 716 | |
| 717 | int position() const { return position_; } |
| 718 | bool has_position() const { return position_ != RelocInfo::kNoPosition; } |
| 719 | void set_position(int position) { position_ = position; } |
| 720 | |
| 721 | virtual LInstruction* CompileToLithium(LChunkBuilder* builder) = 0; |
| 722 | |
| 723 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 724 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 725 | #endif |
| 726 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 727 | // Returns whether this is some kind of deoptimizing check |
| 728 | // instruction. |
| 729 | virtual bool IsCheckInstruction() const { return false; } |
| 730 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 731 | virtual bool IsCall() { return false; } |
| 732 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 733 | DECLARE_ABSTRACT_INSTRUCTION(Instruction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 734 | |
| 735 | protected: |
| 736 | HInstruction() |
| 737 | : next_(NULL), |
| 738 | previous_(NULL), |
| 739 | position_(RelocInfo::kNoPosition) { |
| 740 | SetFlag(kDependsOnOsrEntries); |
| 741 | } |
| 742 | |
| 743 | virtual void DeleteFromGraph() { Unlink(); } |
| 744 | |
| 745 | private: |
| 746 | void InitializeAsFirst(HBasicBlock* block) { |
| 747 | ASSERT(!IsLinked()); |
| 748 | SetBlock(block); |
| 749 | } |
| 750 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 751 | void PrintMnemonicTo(StringStream* stream); |
| 752 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 753 | HInstruction* next_; |
| 754 | HInstruction* previous_; |
| 755 | int position_; |
| 756 | |
| 757 | friend class HBasicBlock; |
| 758 | }; |
| 759 | |
| 760 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 761 | class HControlInstruction: public HInstruction { |
| 762 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 763 | HControlInstruction(HBasicBlock* first, HBasicBlock* second) |
| 764 | : first_successor_(first), second_successor_(second) { |
| 765 | } |
| 766 | |
| 767 | HBasicBlock* FirstSuccessor() const { return first_successor_; } |
| 768 | HBasicBlock* SecondSuccessor() const { return second_successor_; } |
| 769 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 770 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 771 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 772 | DECLARE_ABSTRACT_INSTRUCTION(ControlInstruction) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 773 | |
| 774 | private: |
| 775 | HBasicBlock* first_successor_; |
| 776 | HBasicBlock* second_successor_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 777 | }; |
| 778 | |
| 779 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 780 | template<int NumElements> |
| 781 | class HOperandContainer { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 782 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 783 | HOperandContainer() : elems_() { } |
| 784 | |
| 785 | int length() { return NumElements; } |
| 786 | HValue*& operator[](int i) { |
| 787 | ASSERT(i < length()); |
| 788 | return elems_[i]; |
| 789 | } |
| 790 | |
| 791 | private: |
| 792 | HValue* elems_[NumElements]; |
| 793 | }; |
| 794 | |
| 795 | |
| 796 | template<> |
| 797 | class HOperandContainer<0> { |
| 798 | public: |
| 799 | int length() { return 0; } |
| 800 | HValue*& operator[](int i) { |
| 801 | UNREACHABLE(); |
| 802 | static HValue* t = 0; |
| 803 | return t; |
| 804 | } |
| 805 | }; |
| 806 | |
| 807 | |
| 808 | template<int V> |
| 809 | class HTemplateInstruction : public HInstruction { |
| 810 | public: |
| 811 | int OperandCount() { return V; } |
| 812 | HValue* OperandAt(int i) { return inputs_[i]; } |
| 813 | |
| 814 | protected: |
| 815 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 816 | |
| 817 | private: |
| 818 | HOperandContainer<V> inputs_; |
| 819 | }; |
| 820 | |
| 821 | |
| 822 | template<int V> |
| 823 | class HTemplateControlInstruction : public HControlInstruction { |
| 824 | public: |
| 825 | HTemplateControlInstruction<V>(HBasicBlock* first, HBasicBlock* second) |
| 826 | : HControlInstruction(first, second) { } |
| 827 | int OperandCount() { return V; } |
| 828 | HValue* OperandAt(int i) { return inputs_[i]; } |
| 829 | |
| 830 | protected: |
| 831 | void InternalSetOperandAt(int i, HValue* value) { inputs_[i] = value; } |
| 832 | |
| 833 | private: |
| 834 | HOperandContainer<V> inputs_; |
| 835 | }; |
| 836 | |
| 837 | |
| 838 | class HBlockEntry: public HTemplateInstruction<0> { |
| 839 | public: |
| 840 | virtual Representation RequiredInputRepresentation(int index) const { |
| 841 | return Representation::None(); |
| 842 | } |
| 843 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 844 | DECLARE_CONCRETE_INSTRUCTION(BlockEntry) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 845 | }; |
| 846 | |
| 847 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 848 | class HDeoptimize: public HControlInstruction { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 849 | public: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 850 | explicit HDeoptimize(int environment_length) |
| 851 | : HControlInstruction(NULL, NULL), |
| 852 | values_(environment_length) { } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 853 | |
| 854 | virtual Representation RequiredInputRepresentation(int index) const { |
| 855 | return Representation::None(); |
| 856 | } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 857 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 858 | virtual int OperandCount() { return values_.length(); } |
| 859 | virtual HValue* OperandAt(int index) { return values_[index]; } |
| 860 | |
| 861 | void AddEnvironmentValue(HValue* value) { |
| 862 | values_.Add(NULL); |
| 863 | SetOperandAt(values_.length() - 1, value); |
| 864 | } |
| 865 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 866 | DECLARE_CONCRETE_INSTRUCTION(Deoptimize) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 867 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 868 | enum UseEnvironment { |
| 869 | kNoUses, |
| 870 | kUseAll |
| 871 | }; |
| 872 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 873 | protected: |
| 874 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 875 | values_[index] = value; |
| 876 | } |
| 877 | |
| 878 | private: |
| 879 | ZoneList<HValue*> values_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 880 | }; |
| 881 | |
| 882 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 883 | class HGoto: public HTemplateControlInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 884 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 885 | explicit HGoto(HBasicBlock* target) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 886 | : HTemplateControlInstruction<0>(target, NULL), |
| 887 | include_stack_check_(false) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 888 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 889 | void set_include_stack_check(bool include_stack_check) { |
| 890 | include_stack_check_ = include_stack_check; |
| 891 | } |
| 892 | bool include_stack_check() const { return include_stack_check_; } |
| 893 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 894 | virtual Representation RequiredInputRepresentation(int index) const { |
| 895 | return Representation::None(); |
| 896 | } |
| 897 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 898 | DECLARE_CONCRETE_INSTRUCTION(Goto) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 899 | |
| 900 | private: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 901 | bool include_stack_check_; |
| 902 | }; |
| 903 | |
| 904 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 905 | class HUnaryControlInstruction: public HTemplateControlInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 906 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 907 | explicit HUnaryControlInstruction(HValue* value, |
| 908 | HBasicBlock* true_target, |
| 909 | HBasicBlock* false_target) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 910 | : HTemplateControlInstruction<1>(true_target, false_target) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 911 | SetOperandAt(0, value); |
| 912 | } |
| 913 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 914 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 915 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 916 | HValue* value() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 917 | }; |
| 918 | |
| 919 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 920 | class HTest: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 921 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 922 | HTest(HValue* value, HBasicBlock* true_target, HBasicBlock* false_target) |
| 923 | : HUnaryControlInstruction(value, true_target, false_target) { |
| 924 | ASSERT(true_target != NULL && false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 925 | } |
| 926 | |
| 927 | virtual Representation RequiredInputRepresentation(int index) const { |
| 928 | return Representation::None(); |
| 929 | } |
| 930 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 931 | DECLARE_CONCRETE_INSTRUCTION(Test) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 932 | }; |
| 933 | |
| 934 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 935 | class HCompareMap: public HUnaryControlInstruction { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 936 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 937 | HCompareMap(HValue* value, |
| 938 | Handle<Map> map, |
| 939 | HBasicBlock* true_target, |
| 940 | HBasicBlock* false_target) |
| 941 | : HUnaryControlInstruction(value, true_target, false_target), |
| 942 | map_(map) { |
| 943 | ASSERT(true_target != NULL); |
| 944 | ASSERT(false_target != NULL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 945 | ASSERT(!map.is_null()); |
| 946 | } |
| 947 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 948 | virtual void PrintDataTo(StringStream* stream); |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 949 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 950 | Handle<Map> map() const { return map_; } |
| 951 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 952 | virtual Representation RequiredInputRepresentation(int index) const { |
| 953 | return Representation::Tagged(); |
| 954 | } |
| 955 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 956 | DECLARE_CONCRETE_INSTRUCTION(CompareMap) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 957 | |
| 958 | private: |
| 959 | Handle<Map> map_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 960 | }; |
| 961 | |
| 962 | |
| 963 | class HReturn: public HUnaryControlInstruction { |
| 964 | public: |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 965 | explicit HReturn(HValue* value) |
| 966 | : HUnaryControlInstruction(value, NULL, NULL) { |
| 967 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 968 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 969 | virtual Representation RequiredInputRepresentation(int index) const { |
| 970 | return Representation::Tagged(); |
| 971 | } |
| 972 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 973 | DECLARE_CONCRETE_INSTRUCTION(Return) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 974 | }; |
| 975 | |
| 976 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 977 | class HAbnormalExit: public HTemplateControlInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 978 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 979 | HAbnormalExit() : HTemplateControlInstruction<0>(NULL, NULL) { } |
| 980 | |
| 981 | virtual Representation RequiredInputRepresentation(int index) const { |
| 982 | return Representation::None(); |
| 983 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 984 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 985 | DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 986 | }; |
| 987 | |
| 988 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 989 | class HUnaryOperation: public HTemplateInstruction<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 990 | public: |
| 991 | explicit HUnaryOperation(HValue* value) { |
| 992 | SetOperandAt(0, value); |
| 993 | } |
| 994 | |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame^] | 995 | static HUnaryOperation* cast(HValue* value) { |
| 996 | return reinterpret_cast<HUnaryOperation*>(value); |
| 997 | } |
| 998 | |
| 999 | virtual bool CanTruncateToInt32() const { |
| 1000 | return CheckFlag(kTruncatingToInt32); |
| 1001 | } |
| 1002 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1003 | HValue* value() { return OperandAt(0); } |
| 1004 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1005 | }; |
| 1006 | |
| 1007 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1008 | class HThrow: public HUnaryOperation { |
| 1009 | public: |
| 1010 | explicit HThrow(HValue* value) : HUnaryOperation(value) { |
| 1011 | SetAllSideEffects(); |
| 1012 | } |
| 1013 | |
| 1014 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1015 | return Representation::Tagged(); |
| 1016 | } |
| 1017 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1018 | DECLARE_CONCRETE_INSTRUCTION(Throw) |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 1019 | }; |
| 1020 | |
| 1021 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1022 | class HForceRepresentation: public HTemplateInstruction<1> { |
| 1023 | public: |
| 1024 | HForceRepresentation(HValue* value, Representation required_representation) { |
| 1025 | SetOperandAt(0, value); |
| 1026 | set_representation(required_representation); |
| 1027 | } |
| 1028 | |
| 1029 | HValue* value() { return OperandAt(0); } |
| 1030 | |
| 1031 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1032 | |
| 1033 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1034 | return representation(); // Same as the output representation. |
| 1035 | } |
| 1036 | |
| 1037 | DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation) |
| 1038 | }; |
| 1039 | |
| 1040 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1041 | class HChange: public HUnaryOperation { |
| 1042 | public: |
| 1043 | HChange(HValue* value, |
| 1044 | Representation from, |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1045 | Representation to, |
| 1046 | bool is_truncating) |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1047 | : HUnaryOperation(value), from_(from) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1048 | ASSERT(!from.IsNone() && !to.IsNone()); |
| 1049 | ASSERT(!from.Equals(to)); |
| 1050 | set_representation(to); |
| 1051 | SetFlag(kUseGVN); |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1052 | if (is_truncating) SetFlag(kTruncatingToInt32); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1053 | if (from.IsInteger32() && to.IsTagged() && value->range() != NULL && |
| 1054 | value->range()->IsInSmiRange()) { |
| 1055 | set_type(HType::Smi()); |
| 1056 | } |
| 1057 | } |
| 1058 | |
| 1059 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1060 | |
| 1061 | Representation from() const { return from_; } |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1062 | Representation to() const { return representation(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1063 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1064 | return from_; |
| 1065 | } |
| 1066 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1067 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1068 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1069 | DECLARE_CONCRETE_INSTRUCTION(Change) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1070 | |
| 1071 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1072 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1073 | if (!other->IsChange()) return false; |
| 1074 | HChange* change = HChange::cast(other); |
| 1075 | return value() == change->value() |
karlklose@chromium.org | 8f806e8 | 2011-03-07 14:06:08 +0000 | [diff] [blame] | 1076 | && to().Equals(change->to()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1077 | } |
| 1078 | |
| 1079 | private: |
| 1080 | Representation from_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1081 | }; |
| 1082 | |
| 1083 | |
kmillikin@chromium.org | c53e10d | 2011-05-18 09:12:58 +0000 | [diff] [blame] | 1084 | class HClampToUint8: public HUnaryOperation { |
| 1085 | public: |
| 1086 | explicit HClampToUint8(HValue* value) |
| 1087 | : HUnaryOperation(value), |
| 1088 | input_rep_(Representation::None()) { |
| 1089 | SetFlag(kFlexibleRepresentation); |
| 1090 | set_representation(Representation::Tagged()); |
| 1091 | SetFlag(kUseGVN); |
| 1092 | } |
| 1093 | |
| 1094 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1095 | return input_rep_; |
| 1096 | } |
| 1097 | |
| 1098 | virtual Representation InferredRepresentation() { |
| 1099 | // TODO(danno): Inference on input types should happen separately from |
| 1100 | // return representation. |
| 1101 | Representation new_rep = value()->representation(); |
| 1102 | if (input_rep_.IsNone()) { |
| 1103 | if (!new_rep.IsNone()) { |
| 1104 | input_rep_ = new_rep; |
| 1105 | return Representation::Integer32(); |
| 1106 | } else { |
| 1107 | return Representation::None(); |
| 1108 | } |
| 1109 | } else { |
| 1110 | return Representation::Integer32(); |
| 1111 | } |
| 1112 | } |
| 1113 | |
| 1114 | DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) |
| 1115 | |
| 1116 | protected: |
| 1117 | virtual bool DataEquals(HValue* other) { return true; } |
| 1118 | |
| 1119 | private: |
| 1120 | Representation input_rep_; |
| 1121 | }; |
| 1122 | |
| 1123 | |
ricow@chromium.org | c54d365 | 2011-05-30 09:20:16 +0000 | [diff] [blame^] | 1124 | class HToInt32: public HUnaryOperation { |
| 1125 | public: |
| 1126 | explicit HToInt32(HValue* value) |
| 1127 | : HUnaryOperation(value) { |
| 1128 | set_representation(Representation::Integer32()); |
| 1129 | SetFlag(kUseGVN); |
| 1130 | } |
| 1131 | |
| 1132 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1133 | return Representation::None(); |
| 1134 | } |
| 1135 | |
| 1136 | virtual bool CanTruncateToInt32() const { |
| 1137 | return true; |
| 1138 | } |
| 1139 | |
| 1140 | virtual HValue* Canonicalize() { |
| 1141 | if (value()->representation().IsInteger32()) { |
| 1142 | return value(); |
| 1143 | } else { |
| 1144 | return this; |
| 1145 | } |
| 1146 | } |
| 1147 | |
| 1148 | DECLARE_CONCRETE_INSTRUCTION(ToInt32) |
| 1149 | |
| 1150 | protected: |
| 1151 | virtual bool DataEquals(HValue* other) { return true; } |
| 1152 | }; |
| 1153 | |
| 1154 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1155 | class HSimulate: public HInstruction { |
| 1156 | public: |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 1157 | HSimulate(int ast_id, int pop_count) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1158 | : ast_id_(ast_id), |
| 1159 | pop_count_(pop_count), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1160 | values_(2), |
| 1161 | assigned_indexes_(2) {} |
| 1162 | virtual ~HSimulate() {} |
| 1163 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1164 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1165 | |
| 1166 | bool HasAstId() const { return ast_id_ != AstNode::kNoNumber; } |
| 1167 | int ast_id() const { return ast_id_; } |
| 1168 | void set_ast_id(int id) { |
| 1169 | ASSERT(!HasAstId()); |
| 1170 | ast_id_ = id; |
| 1171 | } |
| 1172 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1173 | int pop_count() const { return pop_count_; } |
| 1174 | const ZoneList<HValue*>* values() const { return &values_; } |
| 1175 | int GetAssignedIndexAt(int index) const { |
| 1176 | ASSERT(HasAssignedIndexAt(index)); |
| 1177 | return assigned_indexes_[index]; |
| 1178 | } |
| 1179 | bool HasAssignedIndexAt(int index) const { |
| 1180 | return assigned_indexes_[index] != kNoIndex; |
| 1181 | } |
| 1182 | void AddAssignedValue(int index, HValue* value) { |
| 1183 | AddValue(index, value); |
| 1184 | } |
| 1185 | void AddPushedValue(HValue* value) { |
| 1186 | AddValue(kNoIndex, value); |
| 1187 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1188 | virtual int OperandCount() { return values_.length(); } |
| 1189 | virtual HValue* OperandAt(int index) { return values_[index]; } |
| 1190 | |
| 1191 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1192 | return Representation::None(); |
| 1193 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1194 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1195 | DECLARE_CONCRETE_INSTRUCTION(Simulate) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1196 | |
| 1197 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1198 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1199 | #endif |
| 1200 | |
| 1201 | protected: |
| 1202 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 1203 | values_[index] = value; |
| 1204 | } |
| 1205 | |
| 1206 | private: |
| 1207 | static const int kNoIndex = -1; |
| 1208 | void AddValue(int index, HValue* value) { |
| 1209 | assigned_indexes_.Add(index); |
| 1210 | // Resize the list of pushed values. |
| 1211 | values_.Add(NULL); |
| 1212 | // Set the operand through the base method in HValue to make sure that the |
| 1213 | // use lists are correctly updated. |
| 1214 | SetOperandAt(values_.length() - 1, value); |
| 1215 | } |
| 1216 | int ast_id_; |
| 1217 | int pop_count_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1218 | ZoneList<HValue*> values_; |
| 1219 | ZoneList<int> assigned_indexes_; |
| 1220 | }; |
| 1221 | |
| 1222 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1223 | class HStackCheck: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1224 | public: |
| 1225 | HStackCheck() { } |
| 1226 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1227 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1228 | return Representation::None(); |
| 1229 | } |
| 1230 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1231 | DECLARE_CONCRETE_INSTRUCTION(StackCheck) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1232 | }; |
| 1233 | |
| 1234 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1235 | class HEnterInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1236 | public: |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1237 | HEnterInlined(Handle<JSFunction> closure, |
| 1238 | FunctionLiteral* function, |
| 1239 | CallKind call_kind) |
| 1240 | : closure_(closure), |
| 1241 | function_(function), |
| 1242 | call_kind_(call_kind) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1243 | } |
| 1244 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1245 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1246 | |
| 1247 | Handle<JSFunction> closure() const { return closure_; } |
| 1248 | FunctionLiteral* function() const { return function_; } |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1249 | CallKind call_kind() const { return call_kind_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1250 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1251 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1252 | return Representation::None(); |
| 1253 | } |
| 1254 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1255 | DECLARE_CONCRETE_INSTRUCTION(EnterInlined) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1256 | |
| 1257 | private: |
| 1258 | Handle<JSFunction> closure_; |
| 1259 | FunctionLiteral* function_; |
danno@chromium.org | 40cb878 | 2011-05-25 07:58:50 +0000 | [diff] [blame] | 1260 | CallKind call_kind_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1261 | }; |
| 1262 | |
| 1263 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1264 | class HLeaveInlined: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1265 | public: |
| 1266 | HLeaveInlined() {} |
| 1267 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1268 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1269 | return Representation::None(); |
| 1270 | } |
| 1271 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1272 | DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1273 | }; |
| 1274 | |
| 1275 | |
| 1276 | class HPushArgument: public HUnaryOperation { |
| 1277 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1278 | explicit HPushArgument(HValue* value) : HUnaryOperation(value) { |
| 1279 | set_representation(Representation::Tagged()); |
| 1280 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1281 | |
| 1282 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1283 | return Representation::Tagged(); |
| 1284 | } |
| 1285 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1286 | HValue* argument() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1287 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1288 | DECLARE_CONCRETE_INSTRUCTION(PushArgument) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1289 | }; |
| 1290 | |
| 1291 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1292 | class HContext: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1293 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1294 | HContext() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1295 | set_representation(Representation::Tagged()); |
| 1296 | SetFlag(kUseGVN); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1297 | } |
| 1298 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1299 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1300 | return Representation::None(); |
| 1301 | } |
| 1302 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1303 | DECLARE_CONCRETE_INSTRUCTION(Context); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1304 | |
| 1305 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1306 | virtual bool DataEquals(HValue* other) { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1307 | }; |
| 1308 | |
| 1309 | |
| 1310 | class HOuterContext: public HUnaryOperation { |
| 1311 | public: |
| 1312 | explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { |
| 1313 | set_representation(Representation::Tagged()); |
| 1314 | SetFlag(kUseGVN); |
| 1315 | } |
| 1316 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1317 | DECLARE_CONCRETE_INSTRUCTION(OuterContext); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1318 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1319 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1320 | return Representation::Tagged(); |
| 1321 | } |
| 1322 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1323 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1324 | virtual bool DataEquals(HValue* other) { return true; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1325 | }; |
| 1326 | |
| 1327 | |
| 1328 | class HGlobalObject: public HUnaryOperation { |
| 1329 | public: |
| 1330 | explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { |
| 1331 | set_representation(Representation::Tagged()); |
| 1332 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1333 | } |
| 1334 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1335 | DECLARE_CONCRETE_INSTRUCTION(GlobalObject) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1336 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1337 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1338 | return Representation::Tagged(); |
| 1339 | } |
| 1340 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1341 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1342 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1343 | }; |
| 1344 | |
| 1345 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1346 | class HGlobalReceiver: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1347 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 1348 | explicit HGlobalReceiver(HValue* global_object) |
| 1349 | : HUnaryOperation(global_object) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1350 | set_representation(Representation::Tagged()); |
| 1351 | SetFlag(kUseGVN); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1352 | } |
| 1353 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1354 | DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1355 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1356 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1357 | return Representation::Tagged(); |
| 1358 | } |
| 1359 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1360 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1361 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1362 | }; |
| 1363 | |
| 1364 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1365 | template <int V> |
| 1366 | class HCall: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1367 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1368 | // The argument count includes the receiver. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1369 | explicit HCall<V>(int argument_count) : argument_count_(argument_count) { |
| 1370 | this->set_representation(Representation::Tagged()); |
| 1371 | this->SetAllSideEffects(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1372 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1373 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1374 | virtual HType CalculateInferredType() { return HType::Tagged(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1375 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1376 | virtual int argument_count() const { return argument_count_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1377 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1378 | virtual bool IsCall() { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1379 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1380 | private: |
| 1381 | int argument_count_; |
| 1382 | }; |
| 1383 | |
| 1384 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1385 | class HUnaryCall: public HCall<1> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1386 | public: |
| 1387 | HUnaryCall(HValue* value, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1388 | : HCall<1>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1389 | SetOperandAt(0, value); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1390 | } |
| 1391 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1392 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1393 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1394 | } |
| 1395 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1396 | virtual void PrintDataTo(StringStream* stream); |
| 1397 | |
| 1398 | HValue* value() { return OperandAt(0); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1399 | }; |
| 1400 | |
| 1401 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1402 | class HBinaryCall: public HCall<2> { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1403 | public: |
| 1404 | HBinaryCall(HValue* first, HValue* second, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1405 | : HCall<2>(argument_count) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1406 | SetOperandAt(0, first); |
| 1407 | SetOperandAt(1, second); |
| 1408 | } |
| 1409 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1410 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1411 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1412 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1413 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1414 | } |
| 1415 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1416 | HValue* first() { return OperandAt(0); } |
| 1417 | HValue* second() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1418 | }; |
| 1419 | |
| 1420 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1421 | class HInvokeFunction: public HBinaryCall { |
| 1422 | public: |
| 1423 | HInvokeFunction(HValue* context, HValue* function, int argument_count) |
| 1424 | : HBinaryCall(context, function, argument_count) { |
| 1425 | } |
| 1426 | |
| 1427 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1428 | return Representation::Tagged(); |
| 1429 | } |
| 1430 | |
| 1431 | HValue* context() { return first(); } |
| 1432 | HValue* function() { return second(); } |
| 1433 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1434 | DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1435 | }; |
| 1436 | |
| 1437 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1438 | class HCallConstantFunction: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1439 | public: |
| 1440 | HCallConstantFunction(Handle<JSFunction> function, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1441 | : HCall<0>(argument_count), function_(function) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1442 | |
| 1443 | Handle<JSFunction> function() const { return function_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1444 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1445 | bool IsApplyFunction() const { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1446 | return function_->code() == |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1447 | Isolate::Current()->builtins()->builtin(Builtins::kFunctionApply); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1448 | } |
| 1449 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1450 | virtual void PrintDataTo(StringStream* stream); |
| 1451 | |
| 1452 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1453 | return Representation::None(); |
| 1454 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1455 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1456 | DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1457 | |
| 1458 | private: |
| 1459 | Handle<JSFunction> function_; |
| 1460 | }; |
| 1461 | |
| 1462 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1463 | class HCallKeyed: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1464 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1465 | HCallKeyed(HValue* context, HValue* key, int argument_count) |
| 1466 | : HBinaryCall(context, key, argument_count) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1467 | } |
| 1468 | |
| 1469 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1470 | return Representation::Tagged(); |
| 1471 | } |
| 1472 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1473 | HValue* context() { return first(); } |
| 1474 | HValue* key() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1475 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1476 | DECLARE_CONCRETE_INSTRUCTION(CallKeyed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1477 | }; |
| 1478 | |
| 1479 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1480 | class HCallNamed: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1481 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1482 | HCallNamed(HValue* context, Handle<String> name, int argument_count) |
| 1483 | : HUnaryCall(context, argument_count), name_(name) { |
| 1484 | } |
| 1485 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1486 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1487 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1488 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1489 | Handle<String> name() const { return name_; } |
| 1490 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1491 | DECLARE_CONCRETE_INSTRUCTION(CallNamed) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1492 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1493 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1494 | return Representation::Tagged(); |
| 1495 | } |
| 1496 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1497 | private: |
| 1498 | Handle<String> name_; |
| 1499 | }; |
| 1500 | |
| 1501 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1502 | class HCallFunction: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1503 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1504 | HCallFunction(HValue* context, int argument_count) |
| 1505 | : HUnaryCall(context, argument_count) { |
| 1506 | } |
| 1507 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1508 | HValue* context() { return value(); } |
| 1509 | |
| 1510 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1511 | return Representation::Tagged(); |
| 1512 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1513 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1514 | DECLARE_CONCRETE_INSTRUCTION(CallFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1515 | }; |
| 1516 | |
| 1517 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1518 | class HCallGlobal: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1519 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1520 | HCallGlobal(HValue* context, Handle<String> name, int argument_count) |
| 1521 | : HUnaryCall(context, argument_count), name_(name) { |
| 1522 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1523 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1524 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1525 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1526 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1527 | Handle<String> name() const { return name_; } |
| 1528 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1529 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1530 | return Representation::Tagged(); |
| 1531 | } |
| 1532 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1533 | DECLARE_CONCRETE_INSTRUCTION(CallGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1534 | |
| 1535 | private: |
| 1536 | Handle<String> name_; |
| 1537 | }; |
| 1538 | |
| 1539 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1540 | class HCallKnownGlobal: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1541 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1542 | HCallKnownGlobal(Handle<JSFunction> target, int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1543 | : HCall<0>(argument_count), target_(target) { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1544 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1545 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1546 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1547 | Handle<JSFunction> target() const { return target_; } |
| 1548 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1549 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1550 | return Representation::None(); |
| 1551 | } |
| 1552 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1553 | DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1554 | |
| 1555 | private: |
| 1556 | Handle<JSFunction> target_; |
| 1557 | }; |
| 1558 | |
| 1559 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1560 | class HCallNew: public HBinaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1561 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1562 | HCallNew(HValue* context, HValue* constructor, int argument_count) |
| 1563 | : HBinaryCall(context, constructor, argument_count) { |
| 1564 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1565 | |
| 1566 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1567 | return Representation::Tagged(); |
| 1568 | } |
| 1569 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1570 | HValue* context() { return first(); } |
| 1571 | HValue* constructor() { return second(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1572 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1573 | DECLARE_CONCRETE_INSTRUCTION(CallNew) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1574 | }; |
| 1575 | |
| 1576 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1577 | class HCallRuntime: public HCall<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1578 | public: |
| 1579 | HCallRuntime(Handle<String> name, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1580 | const Runtime::Function* c_function, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1581 | int argument_count) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1582 | : HCall<0>(argument_count), c_function_(c_function), name_(name) { } |
| 1583 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1584 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1585 | const Runtime::Function* function() const { return c_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1586 | Handle<String> name() const { return name_; } |
| 1587 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1588 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1589 | return Representation::None(); |
| 1590 | } |
| 1591 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1592 | DECLARE_CONCRETE_INSTRUCTION(CallRuntime) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1593 | |
| 1594 | private: |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 1595 | const Runtime::Function* c_function_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1596 | Handle<String> name_; |
| 1597 | }; |
| 1598 | |
| 1599 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1600 | class HJSArrayLength: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1601 | public: |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1602 | explicit HJSArrayLength(HValue* value) : HUnaryOperation(value) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1603 | // The length of an array is stored as a tagged value in the array |
| 1604 | // object. It is guaranteed to be 32 bit integer, but it can be |
| 1605 | // represented as either a smi or heap number. |
| 1606 | set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1607 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1608 | SetFlag(kDependsOnArrayLengths); |
| 1609 | SetFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1610 | } |
| 1611 | |
| 1612 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1613 | return Representation::Tagged(); |
| 1614 | } |
| 1615 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1616 | DECLARE_CONCRETE_INSTRUCTION(JSArrayLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1617 | |
| 1618 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1619 | virtual bool DataEquals(HValue* other) { return true; } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1620 | }; |
| 1621 | |
| 1622 | |
| 1623 | class HFixedArrayLength: public HUnaryOperation { |
| 1624 | public: |
| 1625 | explicit HFixedArrayLength(HValue* value) : HUnaryOperation(value) { |
| 1626 | set_representation(Representation::Tagged()); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1627 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1628 | SetFlag(kDependsOnArrayLengths); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 1629 | } |
| 1630 | |
| 1631 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1632 | return Representation::Tagged(); |
| 1633 | } |
| 1634 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1635 | DECLARE_CONCRETE_INSTRUCTION(FixedArrayLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1636 | |
| 1637 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1638 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1639 | }; |
| 1640 | |
| 1641 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1642 | class HExternalArrayLength: public HUnaryOperation { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1643 | public: |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1644 | explicit HExternalArrayLength(HValue* value) : HUnaryOperation(value) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1645 | set_representation(Representation::Integer32()); |
| 1646 | // The result of this instruction is idempotent as long as its inputs don't |
| 1647 | // change. The length of a pixel array cannot change once set, so it's not |
| 1648 | // necessary to introduce a kDependsOnArrayLengths or any other dependency. |
| 1649 | SetFlag(kUseGVN); |
| 1650 | } |
| 1651 | |
| 1652 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1653 | return Representation::Tagged(); |
| 1654 | } |
| 1655 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1656 | DECLARE_CONCRETE_INSTRUCTION(ExternalArrayLength) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1657 | |
| 1658 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1659 | virtual bool DataEquals(HValue* other) { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1660 | }; |
| 1661 | |
| 1662 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1663 | class HBitNot: public HUnaryOperation { |
| 1664 | public: |
| 1665 | explicit HBitNot(HValue* value) : HUnaryOperation(value) { |
| 1666 | set_representation(Representation::Integer32()); |
| 1667 | SetFlag(kUseGVN); |
| 1668 | SetFlag(kTruncatingToInt32); |
| 1669 | } |
| 1670 | |
| 1671 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1672 | return Representation::Integer32(); |
| 1673 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1674 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1675 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1676 | DECLARE_CONCRETE_INSTRUCTION(BitNot) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1677 | |
| 1678 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1679 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1680 | }; |
| 1681 | |
| 1682 | |
| 1683 | class HUnaryMathOperation: public HUnaryOperation { |
| 1684 | public: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1685 | HUnaryMathOperation(HValue* value, BuiltinFunctionId op) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1686 | : HUnaryOperation(value), op_(op) { |
| 1687 | switch (op) { |
| 1688 | case kMathFloor: |
| 1689 | case kMathRound: |
| 1690 | case kMathCeil: |
| 1691 | set_representation(Representation::Integer32()); |
| 1692 | break; |
| 1693 | case kMathAbs: |
| 1694 | set_representation(Representation::Tagged()); |
| 1695 | SetFlag(kFlexibleRepresentation); |
| 1696 | break; |
| 1697 | case kMathSqrt: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1698 | case kMathPowHalf: |
| 1699 | case kMathLog: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 1700 | case kMathSin: |
| 1701 | case kMathCos: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1702 | set_representation(Representation::Double()); |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1703 | break; |
| 1704 | default: |
| 1705 | UNREACHABLE(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1706 | } |
| 1707 | SetFlag(kUseGVN); |
| 1708 | } |
| 1709 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1710 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1711 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1712 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1713 | |
| 1714 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 1715 | |
| 1716 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1717 | switch (op_) { |
| 1718 | case kMathFloor: |
| 1719 | case kMathRound: |
| 1720 | case kMathCeil: |
| 1721 | case kMathSqrt: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1722 | case kMathPowHalf: |
| 1723 | case kMathLog: |
whesse@chromium.org | 023421e | 2010-12-21 12:19:12 +0000 | [diff] [blame] | 1724 | case kMathSin: |
| 1725 | case kMathCos: |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1726 | return Representation::Double(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1727 | case kMathAbs: |
| 1728 | return representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1729 | default: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1730 | UNREACHABLE(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1731 | return Representation::None(); |
| 1732 | } |
| 1733 | } |
| 1734 | |
| 1735 | virtual HValue* Canonicalize() { |
| 1736 | // If the input is integer32 then we replace the floor instruction |
| 1737 | // with its inputs. This happens before the representation changes are |
| 1738 | // introduced. |
| 1739 | if (op() == kMathFloor) { |
| 1740 | if (value()->representation().IsInteger32()) return value(); |
| 1741 | } |
| 1742 | return this; |
| 1743 | } |
| 1744 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1745 | BuiltinFunctionId op() const { return op_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1746 | const char* OpName() const; |
| 1747 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1748 | DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1749 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1750 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1751 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1752 | HUnaryMathOperation* b = HUnaryMathOperation::cast(other); |
| 1753 | return op_ == b->op(); |
| 1754 | } |
| 1755 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1756 | private: |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 1757 | BuiltinFunctionId op_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1758 | }; |
| 1759 | |
| 1760 | |
| 1761 | class HLoadElements: public HUnaryOperation { |
| 1762 | public: |
| 1763 | explicit HLoadElements(HValue* value) : HUnaryOperation(value) { |
| 1764 | set_representation(Representation::Tagged()); |
| 1765 | SetFlag(kUseGVN); |
| 1766 | SetFlag(kDependsOnMaps); |
| 1767 | } |
| 1768 | |
| 1769 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1770 | return Representation::Tagged(); |
| 1771 | } |
| 1772 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1773 | DECLARE_CONCRETE_INSTRUCTION(LoadElements) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1774 | |
| 1775 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1776 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1777 | }; |
| 1778 | |
| 1779 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1780 | class HLoadExternalArrayPointer: public HUnaryOperation { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1781 | public: |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 1782 | explicit HLoadExternalArrayPointer(HValue* value) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1783 | : HUnaryOperation(value) { |
| 1784 | set_representation(Representation::External()); |
| 1785 | // The result of this instruction is idempotent as long as its inputs don't |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 1786 | // change. The external array of a specialized array elements object cannot |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1787 | // change once set, so it's no necessary to introduce any additional |
| 1788 | // dependencies on top of the inputs. |
| 1789 | SetFlag(kUseGVN); |
| 1790 | } |
| 1791 | |
| 1792 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1793 | return Representation::Tagged(); |
| 1794 | } |
| 1795 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1796 | DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1797 | |
| 1798 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1799 | virtual bool DataEquals(HValue* other) { return true; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 1800 | }; |
| 1801 | |
| 1802 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1803 | class HCheckMap: public HUnaryOperation { |
| 1804 | public: |
| 1805 | HCheckMap(HValue* value, Handle<Map> map) |
| 1806 | : HUnaryOperation(value), map_(map) { |
| 1807 | set_representation(Representation::Tagged()); |
| 1808 | SetFlag(kUseGVN); |
| 1809 | SetFlag(kDependsOnMaps); |
| 1810 | } |
| 1811 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1812 | virtual bool IsCheckInstruction() const { return true; } |
| 1813 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1814 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1815 | return Representation::Tagged(); |
| 1816 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1817 | virtual void PrintDataTo(StringStream* stream); |
| 1818 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1819 | |
| 1820 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1821 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1822 | #endif |
| 1823 | |
| 1824 | Handle<Map> map() const { return map_; } |
| 1825 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1826 | DECLARE_CONCRETE_INSTRUCTION(CheckMap) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1827 | |
| 1828 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1829 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1830 | HCheckMap* b = HCheckMap::cast(other); |
| 1831 | return map_.is_identical_to(b->map()); |
| 1832 | } |
| 1833 | |
| 1834 | private: |
| 1835 | Handle<Map> map_; |
| 1836 | }; |
| 1837 | |
| 1838 | |
| 1839 | class HCheckFunction: public HUnaryOperation { |
| 1840 | public: |
| 1841 | HCheckFunction(HValue* value, Handle<JSFunction> function) |
| 1842 | : HUnaryOperation(value), target_(function) { |
| 1843 | set_representation(Representation::Tagged()); |
| 1844 | SetFlag(kUseGVN); |
| 1845 | } |
| 1846 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1847 | virtual bool IsCheckInstruction() const { return true; } |
| 1848 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1849 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1850 | return Representation::Tagged(); |
| 1851 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1852 | virtual void PrintDataTo(StringStream* stream); |
| 1853 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1854 | |
| 1855 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1856 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1857 | #endif |
| 1858 | |
| 1859 | Handle<JSFunction> target() const { return target_; } |
| 1860 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1861 | DECLARE_CONCRETE_INSTRUCTION(CheckFunction) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1862 | |
| 1863 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1864 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1865 | HCheckFunction* b = HCheckFunction::cast(other); |
| 1866 | return target_.is_identical_to(b->target()); |
| 1867 | } |
| 1868 | |
| 1869 | private: |
| 1870 | Handle<JSFunction> target_; |
| 1871 | }; |
| 1872 | |
| 1873 | |
| 1874 | class HCheckInstanceType: public HUnaryOperation { |
| 1875 | public: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1876 | static HCheckInstanceType* NewIsJSObjectOrJSFunction(HValue* value) { |
| 1877 | return new HCheckInstanceType(value, IS_JS_OBJECT_OR_JS_FUNCTION); |
| 1878 | } |
| 1879 | static HCheckInstanceType* NewIsJSArray(HValue* value) { |
| 1880 | return new HCheckInstanceType(value, IS_JS_ARRAY); |
| 1881 | } |
| 1882 | static HCheckInstanceType* NewIsString(HValue* value) { |
| 1883 | return new HCheckInstanceType(value, IS_STRING); |
| 1884 | } |
| 1885 | static HCheckInstanceType* NewIsSymbol(HValue* value) { |
| 1886 | return new HCheckInstanceType(value, IS_SYMBOL); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1887 | } |
| 1888 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1889 | virtual bool IsCheckInstruction() const { return true; } |
| 1890 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1891 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1892 | return Representation::Tagged(); |
| 1893 | } |
| 1894 | |
| 1895 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1896 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1897 | #endif |
| 1898 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1899 | virtual HValue* Canonicalize() { |
| 1900 | if (!value()->type().IsUninitialized() && |
| 1901 | value()->type().IsString() && |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1902 | check_ == IS_STRING) { |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1903 | return NULL; |
| 1904 | } |
| 1905 | return this; |
| 1906 | } |
| 1907 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1908 | bool is_interval_check() const { return check_ <= LAST_INTERVAL_CHECK; } |
| 1909 | void GetCheckInterval(InstanceType* first, InstanceType* last); |
| 1910 | void GetCheckMaskAndTag(uint8_t* mask, uint8_t* tag); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1911 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1912 | DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1913 | |
| 1914 | protected: |
| 1915 | // TODO(ager): It could be nice to allow the ommision of instance |
| 1916 | // type checks if we have already performed an instance type check |
| 1917 | // with a larger range. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1918 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1919 | HCheckInstanceType* b = HCheckInstanceType::cast(other); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1920 | return check_ == b->check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1921 | } |
| 1922 | |
| 1923 | private: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 1924 | enum Check { |
| 1925 | IS_JS_OBJECT_OR_JS_FUNCTION, |
| 1926 | IS_JS_ARRAY, |
| 1927 | IS_STRING, |
| 1928 | IS_SYMBOL, |
| 1929 | LAST_INTERVAL_CHECK = IS_JS_ARRAY |
| 1930 | }; |
| 1931 | |
| 1932 | HCheckInstanceType(HValue* value, Check check) |
| 1933 | : HUnaryOperation(value), check_(check) { |
| 1934 | set_representation(Representation::Tagged()); |
| 1935 | SetFlag(kUseGVN); |
| 1936 | } |
| 1937 | |
| 1938 | const Check check_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1939 | }; |
| 1940 | |
| 1941 | |
| 1942 | class HCheckNonSmi: public HUnaryOperation { |
| 1943 | public: |
| 1944 | explicit HCheckNonSmi(HValue* value) : HUnaryOperation(value) { |
| 1945 | set_representation(Representation::Tagged()); |
| 1946 | SetFlag(kUseGVN); |
| 1947 | } |
| 1948 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1949 | virtual bool IsCheckInstruction() const { return true; } |
| 1950 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1951 | virtual Representation RequiredInputRepresentation(int index) const { |
| 1952 | return Representation::Tagged(); |
| 1953 | } |
| 1954 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1955 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1956 | |
| 1957 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1958 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1959 | #endif |
| 1960 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 1961 | virtual HValue* Canonicalize() { |
| 1962 | HType value_type = value()->type(); |
| 1963 | if (!value_type.IsUninitialized() && |
| 1964 | (value_type.IsHeapNumber() || |
| 1965 | value_type.IsString() || |
| 1966 | value_type.IsBoolean() || |
| 1967 | value_type.IsNonPrimitive())) { |
| 1968 | return NULL; |
| 1969 | } |
| 1970 | return this; |
| 1971 | } |
| 1972 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1973 | DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1974 | |
| 1975 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1976 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1977 | }; |
| 1978 | |
| 1979 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1980 | class HCheckPrototypeMaps: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1981 | public: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1982 | HCheckPrototypeMaps(Handle<JSObject> prototype, Handle<JSObject> holder) |
| 1983 | : prototype_(prototype), holder_(holder) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1984 | SetFlag(kUseGVN); |
| 1985 | SetFlag(kDependsOnMaps); |
| 1986 | } |
| 1987 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 1988 | virtual bool IsCheckInstruction() const { return true; } |
| 1989 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1990 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 1991 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1992 | #endif |
| 1993 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 1994 | Handle<JSObject> prototype() const { return prototype_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1995 | Handle<JSObject> holder() const { return holder_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1996 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 1997 | DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 1998 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 1999 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2000 | return Representation::None(); |
| 2001 | } |
| 2002 | |
| 2003 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2004 | ASSERT(!HEAP->IsAllocationAllowed()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2005 | intptr_t hash = reinterpret_cast<intptr_t>(*prototype()); |
| 2006 | hash = 17 * hash + reinterpret_cast<intptr_t>(*holder()); |
| 2007 | return hash; |
| 2008 | } |
| 2009 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2010 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2011 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2012 | HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2013 | return prototype_.is_identical_to(b->prototype()) && |
| 2014 | holder_.is_identical_to(b->holder()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2015 | } |
| 2016 | |
| 2017 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 2018 | Handle<JSObject> prototype_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2019 | Handle<JSObject> holder_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2020 | }; |
| 2021 | |
| 2022 | |
| 2023 | class HCheckSmi: public HUnaryOperation { |
| 2024 | public: |
| 2025 | explicit HCheckSmi(HValue* value) : HUnaryOperation(value) { |
| 2026 | set_representation(Representation::Tagged()); |
| 2027 | SetFlag(kUseGVN); |
| 2028 | } |
| 2029 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2030 | virtual bool IsCheckInstruction() const { return true; } |
| 2031 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2032 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2033 | return Representation::Tagged(); |
| 2034 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2035 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2036 | |
| 2037 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2038 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2039 | #endif |
| 2040 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2041 | DECLARE_CONCRETE_INSTRUCTION(CheckSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2042 | |
| 2043 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2044 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2045 | }; |
| 2046 | |
| 2047 | |
| 2048 | class HPhi: public HValue { |
| 2049 | public: |
| 2050 | explicit HPhi(int merged_index) |
| 2051 | : inputs_(2), |
| 2052 | merged_index_(merged_index), |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2053 | phi_id_(-1), |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2054 | is_live_(false), |
| 2055 | is_convertible_to_integer_(true) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2056 | for (int i = 0; i < Representation::kNumRepresentations; i++) { |
| 2057 | non_phi_uses_[i] = 0; |
| 2058 | indirect_uses_[i] = 0; |
| 2059 | } |
| 2060 | ASSERT(merged_index >= 0); |
| 2061 | set_representation(Representation::Tagged()); |
| 2062 | SetFlag(kFlexibleRepresentation); |
| 2063 | } |
| 2064 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2065 | virtual Representation InferredRepresentation() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2066 | bool double_occurred = false; |
| 2067 | bool int32_occurred = false; |
| 2068 | for (int i = 0; i < OperandCount(); ++i) { |
| 2069 | HValue* value = OperandAt(i); |
| 2070 | if (value->representation().IsDouble()) double_occurred = true; |
| 2071 | if (value->representation().IsInteger32()) int32_occurred = true; |
| 2072 | if (value->representation().IsTagged()) return Representation::Tagged(); |
| 2073 | } |
| 2074 | |
| 2075 | if (double_occurred) return Representation::Double(); |
| 2076 | if (int32_occurred) return Representation::Integer32(); |
| 2077 | return Representation::None(); |
| 2078 | } |
| 2079 | |
| 2080 | virtual Range* InferRange(); |
| 2081 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2082 | return representation(); |
| 2083 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2084 | virtual HType CalculateInferredType(); |
| 2085 | virtual int OperandCount() { return inputs_.length(); } |
| 2086 | virtual HValue* OperandAt(int index) { return inputs_[index]; } |
| 2087 | HValue* GetRedundantReplacement(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2088 | void AddInput(HValue* value); |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2089 | bool HasRealUses(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2090 | |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2091 | bool IsReceiver() { return merged_index_ == 0; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2092 | |
| 2093 | int merged_index() const { return merged_index_; } |
| 2094 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2095 | virtual void PrintTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2096 | |
| 2097 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2098 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2099 | #endif |
| 2100 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2101 | void InitRealUses(int id); |
| 2102 | void AddNonPhiUsesFrom(HPhi* other); |
| 2103 | void AddIndirectUsesTo(int* use_count); |
| 2104 | |
| 2105 | int tagged_non_phi_uses() const { |
| 2106 | return non_phi_uses_[Representation::kTagged]; |
| 2107 | } |
| 2108 | int int32_non_phi_uses() const { |
| 2109 | return non_phi_uses_[Representation::kInteger32]; |
| 2110 | } |
| 2111 | int double_non_phi_uses() const { |
| 2112 | return non_phi_uses_[Representation::kDouble]; |
| 2113 | } |
| 2114 | int tagged_indirect_uses() const { |
| 2115 | return indirect_uses_[Representation::kTagged]; |
| 2116 | } |
| 2117 | int int32_indirect_uses() const { |
| 2118 | return indirect_uses_[Representation::kInteger32]; |
| 2119 | } |
| 2120 | int double_indirect_uses() const { |
| 2121 | return indirect_uses_[Representation::kDouble]; |
| 2122 | } |
| 2123 | int phi_id() { return phi_id_; } |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2124 | bool is_live() { return is_live_; } |
| 2125 | void set_is_live(bool b) { is_live_ = b; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2126 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2127 | static HPhi* cast(HValue* value) { |
| 2128 | ASSERT(value->IsPhi()); |
| 2129 | return reinterpret_cast<HPhi*>(value); |
| 2130 | } |
| 2131 | virtual Opcode opcode() const { return HValue::kPhi; } |
| 2132 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2133 | virtual bool IsConvertibleToInteger() const { |
| 2134 | return is_convertible_to_integer_; |
| 2135 | } |
| 2136 | |
| 2137 | void set_is_convertible_to_integer(bool b) { |
| 2138 | is_convertible_to_integer_ = b; |
| 2139 | } |
| 2140 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2141 | protected: |
| 2142 | virtual void DeleteFromGraph(); |
| 2143 | virtual void InternalSetOperandAt(int index, HValue* value) { |
| 2144 | inputs_[index] = value; |
| 2145 | } |
| 2146 | |
| 2147 | private: |
| 2148 | ZoneList<HValue*> inputs_; |
| 2149 | int merged_index_; |
| 2150 | |
| 2151 | int non_phi_uses_[Representation::kNumRepresentations]; |
| 2152 | int indirect_uses_[Representation::kNumRepresentations]; |
| 2153 | int phi_id_; |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2154 | bool is_live_; |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2155 | bool is_convertible_to_integer_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2156 | }; |
| 2157 | |
| 2158 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2159 | class HArgumentsObject: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2160 | public: |
| 2161 | HArgumentsObject() { |
| 2162 | set_representation(Representation::Tagged()); |
| 2163 | SetFlag(kIsArguments); |
| 2164 | } |
| 2165 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2166 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2167 | return Representation::None(); |
| 2168 | } |
| 2169 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2170 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2171 | }; |
| 2172 | |
| 2173 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2174 | class HConstant: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2175 | public: |
| 2176 | HConstant(Handle<Object> handle, Representation r); |
| 2177 | |
| 2178 | Handle<Object> handle() const { return handle_; } |
| 2179 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2180 | bool InOldSpace() const { return !HEAP->InNewSpace(*handle_); } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 2181 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2182 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2183 | return Representation::None(); |
| 2184 | } |
| 2185 | |
fschneider@chromium.org | fb144a0 | 2011-05-04 12:43:48 +0000 | [diff] [blame] | 2186 | virtual bool IsConvertibleToInteger() const { |
| 2187 | if (handle_->IsSmi()) return true; |
| 2188 | if (handle_->IsHeapNumber() && |
| 2189 | (HeapNumber::cast(*handle_)->value() == |
| 2190 | static_cast<double>(NumberToInt32(*handle_)))) return true; |
| 2191 | return false; |
| 2192 | } |
| 2193 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2194 | virtual bool EmitAtUses() { return !representation().IsDouble(); } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2195 | virtual void PrintDataTo(StringStream* stream); |
| 2196 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2197 | bool IsInteger() const { return handle_->IsSmi(); } |
| 2198 | HConstant* CopyToRepresentation(Representation r) const; |
| 2199 | HConstant* CopyToTruncatedInt32() const; |
| 2200 | bool HasInteger32Value() const { return has_int32_value_; } |
| 2201 | int32_t Integer32Value() const { |
| 2202 | ASSERT(HasInteger32Value()); |
| 2203 | return int32_value_; |
| 2204 | } |
| 2205 | bool HasDoubleValue() const { return has_double_value_; } |
| 2206 | double DoubleValue() const { |
| 2207 | ASSERT(HasDoubleValue()); |
| 2208 | return double_value_; |
| 2209 | } |
| 2210 | bool HasStringValue() const { return handle_->IsString(); } |
| 2211 | |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 2212 | bool ToBoolean() const; |
| 2213 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2214 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 2215 | ASSERT(!HEAP->allow_allocation(false)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2216 | return reinterpret_cast<intptr_t>(*handle()); |
| 2217 | } |
| 2218 | |
| 2219 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2220 | virtual void Verify() { } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2221 | #endif |
| 2222 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2223 | DECLARE_CONCRETE_INSTRUCTION(Constant) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2224 | |
| 2225 | protected: |
| 2226 | virtual Range* InferRange(); |
| 2227 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2228 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2229 | HConstant* other_constant = HConstant::cast(other); |
| 2230 | return handle().is_identical_to(other_constant->handle()); |
| 2231 | } |
| 2232 | |
| 2233 | private: |
| 2234 | Handle<Object> handle_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2235 | |
| 2236 | // The following two values represent the int32 and the double value of the |
| 2237 | // given constant if there is a lossless conversion between the constant |
| 2238 | // and the specific representation. |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 2239 | bool has_int32_value_ : 1; |
| 2240 | bool has_double_value_ : 1; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2241 | int32_t int32_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2242 | double double_value_; |
| 2243 | }; |
| 2244 | |
| 2245 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2246 | class HBinaryOperation: public HTemplateInstruction<2> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2247 | public: |
| 2248 | HBinaryOperation(HValue* left, HValue* right) { |
| 2249 | ASSERT(left != NULL && right != NULL); |
| 2250 | SetOperandAt(0, left); |
| 2251 | SetOperandAt(1, right); |
| 2252 | } |
| 2253 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2254 | HValue* left() { return OperandAt(0); } |
| 2255 | HValue* right() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2256 | |
| 2257 | // TODO(kasperl): Move these helpers to the IA-32 Lithium |
| 2258 | // instruction sequence builder. |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2259 | HValue* LeastConstantOperand() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2260 | if (IsCommutative() && left()->IsConstant()) return right(); |
| 2261 | return left(); |
| 2262 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2263 | HValue* MostConstantOperand() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2264 | if (IsCommutative() && left()->IsConstant()) return left(); |
| 2265 | return right(); |
| 2266 | } |
| 2267 | |
| 2268 | virtual bool IsCommutative() const { return false; } |
| 2269 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2270 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2271 | }; |
| 2272 | |
| 2273 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2274 | class HApplyArguments: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2275 | public: |
| 2276 | HApplyArguments(HValue* function, |
| 2277 | HValue* receiver, |
| 2278 | HValue* length, |
| 2279 | HValue* elements) { |
| 2280 | set_representation(Representation::Tagged()); |
| 2281 | SetOperandAt(0, function); |
| 2282 | SetOperandAt(1, receiver); |
| 2283 | SetOperandAt(2, length); |
| 2284 | SetOperandAt(3, elements); |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 2285 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2286 | } |
| 2287 | |
| 2288 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2289 | // The length is untagged, all other inputs are tagged. |
| 2290 | return (index == 2) |
| 2291 | ? Representation::Integer32() |
| 2292 | : Representation::Tagged(); |
| 2293 | } |
| 2294 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2295 | HValue* function() { return OperandAt(0); } |
| 2296 | HValue* receiver() { return OperandAt(1); } |
| 2297 | HValue* length() { return OperandAt(2); } |
| 2298 | HValue* elements() { return OperandAt(3); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2299 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2300 | DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2301 | }; |
| 2302 | |
| 2303 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2304 | class HArgumentsElements: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2305 | public: |
| 2306 | HArgumentsElements() { |
| 2307 | // The value produced by this instruction is a pointer into the stack |
| 2308 | // that looks as if it was a smi because of alignment. |
| 2309 | set_representation(Representation::Tagged()); |
| 2310 | SetFlag(kUseGVN); |
| 2311 | } |
| 2312 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2313 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2314 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2315 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2316 | return Representation::None(); |
| 2317 | } |
| 2318 | |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2319 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2320 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2321 | }; |
| 2322 | |
| 2323 | |
| 2324 | class HArgumentsLength: public HUnaryOperation { |
| 2325 | public: |
| 2326 | explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { |
| 2327 | set_representation(Representation::Integer32()); |
| 2328 | SetFlag(kUseGVN); |
| 2329 | } |
| 2330 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2331 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2332 | return Representation::Tagged(); |
| 2333 | } |
| 2334 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2335 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2336 | |
| 2337 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2338 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2339 | }; |
| 2340 | |
| 2341 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2342 | class HAccessArgumentsAt: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2343 | public: |
| 2344 | HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { |
| 2345 | set_representation(Representation::Tagged()); |
| 2346 | SetFlag(kUseGVN); |
| 2347 | SetOperandAt(0, arguments); |
| 2348 | SetOperandAt(1, length); |
| 2349 | SetOperandAt(2, index); |
| 2350 | } |
| 2351 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2352 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2353 | |
| 2354 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2355 | // The arguments elements is considered tagged. |
| 2356 | return index == 0 |
| 2357 | ? Representation::Tagged() |
| 2358 | : Representation::Integer32(); |
| 2359 | } |
| 2360 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2361 | HValue* arguments() { return OperandAt(0); } |
| 2362 | HValue* length() { return OperandAt(1); } |
| 2363 | HValue* index() { return OperandAt(2); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2364 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2365 | DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2366 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2367 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2368 | }; |
| 2369 | |
| 2370 | |
| 2371 | class HBoundsCheck: public HBinaryOperation { |
| 2372 | public: |
| 2373 | HBoundsCheck(HValue* index, HValue* length) |
| 2374 | : HBinaryOperation(index, length) { |
| 2375 | SetFlag(kUseGVN); |
| 2376 | } |
| 2377 | |
erik.corry@gmail.com | 0511e24 | 2011-01-19 11:11:08 +0000 | [diff] [blame] | 2378 | virtual bool IsCheckInstruction() const { return true; } |
| 2379 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2380 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2381 | return Representation::Integer32(); |
| 2382 | } |
| 2383 | |
| 2384 | #ifdef DEBUG |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2385 | virtual void Verify(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2386 | #endif |
| 2387 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2388 | HValue* index() { return left(); } |
| 2389 | HValue* length() { return right(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2390 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2391 | DECLARE_CONCRETE_INSTRUCTION(BoundsCheck) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2392 | |
| 2393 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2394 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2395 | }; |
| 2396 | |
| 2397 | |
| 2398 | class HBitwiseBinaryOperation: public HBinaryOperation { |
| 2399 | public: |
| 2400 | HBitwiseBinaryOperation(HValue* left, HValue* right) |
| 2401 | : HBinaryOperation(left, right) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2402 | set_representation(Representation::Tagged()); |
| 2403 | SetFlag(kFlexibleRepresentation); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2404 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2405 | } |
| 2406 | |
| 2407 | virtual Representation RequiredInputRepresentation(int index) const { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2408 | return representation(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2409 | } |
| 2410 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2411 | virtual void RepresentationChanged(Representation to) { |
| 2412 | if (!to.IsTagged()) { |
| 2413 | ASSERT(to.IsInteger32()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2414 | ClearAllSideEffects(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2415 | SetFlag(kTruncatingToInt32); |
| 2416 | SetFlag(kUseGVN); |
| 2417 | } |
| 2418 | } |
| 2419 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2420 | virtual HType CalculateInferredType(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 2421 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2422 | DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2423 | }; |
| 2424 | |
| 2425 | |
| 2426 | class HArithmeticBinaryOperation: public HBinaryOperation { |
| 2427 | public: |
| 2428 | HArithmeticBinaryOperation(HValue* left, HValue* right) |
| 2429 | : HBinaryOperation(left, right) { |
| 2430 | set_representation(Representation::Tagged()); |
| 2431 | SetFlag(kFlexibleRepresentation); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2432 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2433 | } |
| 2434 | |
| 2435 | virtual void RepresentationChanged(Representation to) { |
| 2436 | if (!to.IsTagged()) { |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2437 | ClearAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2438 | SetFlag(kUseGVN); |
| 2439 | } |
| 2440 | } |
| 2441 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2442 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2443 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2444 | return representation(); |
| 2445 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2446 | virtual Representation InferredRepresentation() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2447 | if (left()->representation().Equals(right()->representation())) { |
| 2448 | return left()->representation(); |
| 2449 | } |
| 2450 | return HValue::InferredRepresentation(); |
| 2451 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2452 | }; |
| 2453 | |
| 2454 | |
| 2455 | class HCompare: public HBinaryOperation { |
| 2456 | public: |
| 2457 | HCompare(HValue* left, HValue* right, Token::Value token) |
| 2458 | : HBinaryOperation(left, right), token_(token) { |
| 2459 | ASSERT(Token::IsCompareOp(token)); |
| 2460 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2461 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2462 | } |
| 2463 | |
| 2464 | void SetInputRepresentation(Representation r); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2465 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2466 | virtual bool EmitAtUses() { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 2467 | return !HasSideEffects() && !HasMultipleUses(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2468 | } |
| 2469 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2470 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2471 | return input_representation_; |
| 2472 | } |
| 2473 | Representation GetInputRepresentation() const { |
| 2474 | return input_representation_; |
| 2475 | } |
| 2476 | Token::Value token() const { return token_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2477 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2478 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2479 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2480 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2481 | virtual intptr_t Hashcode() { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2482 | return HValue::Hashcode() * 7 + token_; |
| 2483 | } |
| 2484 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2485 | DECLARE_CONCRETE_INSTRUCTION(Compare) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2486 | |
| 2487 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2488 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2489 | HCompare* comp = HCompare::cast(other); |
| 2490 | return token_ == comp->token(); |
| 2491 | } |
| 2492 | |
| 2493 | private: |
| 2494 | Representation input_representation_; |
| 2495 | Token::Value token_; |
| 2496 | }; |
| 2497 | |
| 2498 | |
| 2499 | class HCompareJSObjectEq: public HBinaryOperation { |
| 2500 | public: |
| 2501 | HCompareJSObjectEq(HValue* left, HValue* right) |
| 2502 | : HBinaryOperation(left, right) { |
| 2503 | set_representation(Representation::Tagged()); |
| 2504 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 2505 | SetFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2506 | } |
| 2507 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2508 | virtual bool EmitAtUses() { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 2509 | return !HasSideEffects() && !HasMultipleUses(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2510 | } |
| 2511 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2512 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2513 | return Representation::Tagged(); |
| 2514 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2515 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2516 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2517 | DECLARE_CONCRETE_INSTRUCTION(CompareJSObjectEq) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2518 | |
| 2519 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2520 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2521 | }; |
| 2522 | |
| 2523 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 2524 | class HCompareSymbolEq: public HBinaryOperation { |
| 2525 | public: |
| 2526 | HCompareSymbolEq(HValue* left, HValue* right, Token::Value op) |
| 2527 | : HBinaryOperation(left, right), op_(op) { |
| 2528 | ASSERT(op == Token::EQ || op == Token::EQ_STRICT); |
| 2529 | set_representation(Representation::Tagged()); |
| 2530 | SetFlag(kUseGVN); |
| 2531 | SetFlag(kDependsOnMaps); |
| 2532 | } |
| 2533 | |
| 2534 | Token::Value op() const { return op_; } |
| 2535 | |
| 2536 | virtual bool EmitAtUses() { |
| 2537 | return !HasSideEffects() && !HasMultipleUses(); |
| 2538 | } |
| 2539 | |
| 2540 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2541 | return Representation::Tagged(); |
| 2542 | } |
| 2543 | |
| 2544 | virtual HType CalculateInferredType() { return HType::Boolean(); } |
| 2545 | |
| 2546 | DECLARE_CONCRETE_INSTRUCTION(CompareSymbolEq); |
| 2547 | |
| 2548 | protected: |
| 2549 | virtual bool DataEquals(HValue* other) { |
| 2550 | return op_ == HCompareSymbolEq::cast(other)->op_; |
| 2551 | } |
| 2552 | |
| 2553 | private: |
| 2554 | const Token::Value op_; |
| 2555 | }; |
| 2556 | |
| 2557 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2558 | class HUnaryPredicate: public HUnaryOperation { |
| 2559 | public: |
| 2560 | explicit HUnaryPredicate(HValue* value) : HUnaryOperation(value) { |
| 2561 | set_representation(Representation::Tagged()); |
| 2562 | SetFlag(kUseGVN); |
| 2563 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2564 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2565 | virtual bool EmitAtUses() { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 2566 | return !HasSideEffects() && !HasMultipleUses(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2567 | } |
| 2568 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2569 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2570 | return Representation::Tagged(); |
| 2571 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2572 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2573 | }; |
| 2574 | |
| 2575 | |
| 2576 | class HIsNull: public HUnaryPredicate { |
| 2577 | public: |
| 2578 | HIsNull(HValue* value, bool is_strict) |
| 2579 | : HUnaryPredicate(value), is_strict_(is_strict) { } |
| 2580 | |
| 2581 | bool is_strict() const { return is_strict_; } |
| 2582 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2583 | DECLARE_CONCRETE_INSTRUCTION(IsNull) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2584 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2585 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2586 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2587 | HIsNull* b = HIsNull::cast(other); |
| 2588 | return is_strict_ == b->is_strict(); |
| 2589 | } |
| 2590 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2591 | private: |
| 2592 | bool is_strict_; |
| 2593 | }; |
| 2594 | |
| 2595 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2596 | class HIsObject: public HUnaryPredicate { |
| 2597 | public: |
| 2598 | explicit HIsObject(HValue* value) : HUnaryPredicate(value) { } |
| 2599 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2600 | DECLARE_CONCRETE_INSTRUCTION(IsObject) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2601 | |
| 2602 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2603 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2604 | }; |
| 2605 | |
| 2606 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2607 | class HIsSmi: public HUnaryPredicate { |
| 2608 | public: |
| 2609 | explicit HIsSmi(HValue* value) : HUnaryPredicate(value) { } |
| 2610 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2611 | DECLARE_CONCRETE_INSTRUCTION(IsSmi) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2612 | |
| 2613 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2614 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2615 | }; |
| 2616 | |
| 2617 | |
vegorov@chromium.org | 7304bca | 2011-05-16 12:14:13 +0000 | [diff] [blame] | 2618 | class HIsUndetectable: public HUnaryPredicate { |
| 2619 | public: |
| 2620 | explicit HIsUndetectable(HValue* value) : HUnaryPredicate(value) { } |
| 2621 | |
| 2622 | DECLARE_CONCRETE_INSTRUCTION(IsUndetectable) |
| 2623 | |
| 2624 | protected: |
| 2625 | virtual bool DataEquals(HValue* other) { return true; } |
| 2626 | }; |
| 2627 | |
| 2628 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2629 | class HIsConstructCall: public HTemplateInstruction<0> { |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2630 | public: |
| 2631 | HIsConstructCall() { |
| 2632 | set_representation(Representation::Tagged()); |
| 2633 | SetFlag(kUseGVN); |
| 2634 | } |
| 2635 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2636 | virtual bool EmitAtUses() { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 2637 | return !HasSideEffects() && !HasMultipleUses(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2638 | } |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2639 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2640 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2641 | return Representation::None(); |
| 2642 | } |
| 2643 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2644 | DECLARE_CONCRETE_INSTRUCTION(IsConstructCall) |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2645 | |
| 2646 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2647 | virtual bool DataEquals(HValue* other) { return true; } |
erik.corry@gmail.com | d91075f | 2011-02-10 07:45:38 +0000 | [diff] [blame] | 2648 | }; |
| 2649 | |
| 2650 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2651 | class HHasInstanceType: public HUnaryPredicate { |
| 2652 | public: |
| 2653 | HHasInstanceType(HValue* value, InstanceType type) |
| 2654 | : HUnaryPredicate(value), from_(type), to_(type) { } |
| 2655 | HHasInstanceType(HValue* value, InstanceType from, InstanceType to) |
| 2656 | : HUnaryPredicate(value), from_(from), to_(to) { |
| 2657 | ASSERT(to == LAST_TYPE); // Others not implemented yet in backend. |
| 2658 | } |
| 2659 | |
| 2660 | InstanceType from() { return from_; } |
| 2661 | InstanceType to() { return to_; } |
| 2662 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2663 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2664 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2665 | DECLARE_CONCRETE_INSTRUCTION(HasInstanceType) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2666 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2667 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2668 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2669 | HHasInstanceType* b = HHasInstanceType::cast(other); |
| 2670 | return (from_ == b->from()) && (to_ == b->to()); |
| 2671 | } |
| 2672 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2673 | private: |
| 2674 | InstanceType from_; |
| 2675 | InstanceType to_; // Inclusive range, not all combinations work. |
| 2676 | }; |
| 2677 | |
| 2678 | |
| 2679 | class HHasCachedArrayIndex: public HUnaryPredicate { |
| 2680 | public: |
| 2681 | explicit HHasCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { } |
| 2682 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2683 | DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndex) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2684 | |
| 2685 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2686 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2687 | }; |
| 2688 | |
| 2689 | |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2690 | class HGetCachedArrayIndex: public HUnaryPredicate { |
| 2691 | public: |
| 2692 | explicit HGetCachedArrayIndex(HValue* value) : HUnaryPredicate(value) { } |
| 2693 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2694 | DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex) |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2695 | |
| 2696 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2697 | virtual bool DataEquals(HValue* other) { return true; } |
kmillikin@chromium.org | 49edbdf | 2011-02-16 12:32:18 +0000 | [diff] [blame] | 2698 | }; |
| 2699 | |
| 2700 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2701 | class HClassOfTest: public HUnaryPredicate { |
| 2702 | public: |
| 2703 | HClassOfTest(HValue* value, Handle<String> class_name) |
| 2704 | : HUnaryPredicate(value), class_name_(class_name) { } |
| 2705 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2706 | DECLARE_CONCRETE_INSTRUCTION(ClassOfTest) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2707 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2708 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2709 | |
| 2710 | Handle<String> class_name() const { return class_name_; } |
| 2711 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2712 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2713 | virtual bool DataEquals(HValue* other) { |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2714 | HClassOfTest* b = HClassOfTest::cast(other); |
| 2715 | return class_name_.is_identical_to(b->class_name_); |
| 2716 | } |
| 2717 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2718 | private: |
| 2719 | Handle<String> class_name_; |
| 2720 | }; |
| 2721 | |
| 2722 | |
| 2723 | class HTypeofIs: public HUnaryPredicate { |
| 2724 | public: |
| 2725 | HTypeofIs(HValue* value, Handle<String> type_literal) |
| 2726 | : HUnaryPredicate(value), type_literal_(type_literal) { } |
| 2727 | |
| 2728 | Handle<String> type_literal() { return type_literal_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2729 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2730 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2731 | DECLARE_CONCRETE_INSTRUCTION(TypeofIs) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2732 | |
| 2733 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2734 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2735 | HTypeofIs* b = HTypeofIs::cast(other); |
| 2736 | return type_literal_.is_identical_to(b->type_literal_); |
| 2737 | } |
| 2738 | |
| 2739 | private: |
| 2740 | Handle<String> type_literal_; |
| 2741 | }; |
| 2742 | |
| 2743 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2744 | class HInstanceOf: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2745 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2746 | HInstanceOf(HValue* context, HValue* left, HValue* right) { |
| 2747 | SetOperandAt(0, context); |
| 2748 | SetOperandAt(1, left); |
| 2749 | SetOperandAt(2, right); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2750 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2751 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2752 | } |
| 2753 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2754 | HValue* context() { return OperandAt(0); } |
| 2755 | HValue* left() { return OperandAt(1); } |
| 2756 | HValue* right() { return OperandAt(2); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2757 | |
danno@chromium.org | 4d3fe4e | 2011-03-10 10:14:28 +0000 | [diff] [blame] | 2758 | virtual bool EmitAtUses() { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 2759 | return !HasSideEffects() && !HasMultipleUses(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2760 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2761 | |
| 2762 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2763 | return Representation::Tagged(); |
| 2764 | } |
| 2765 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2766 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 2767 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2768 | DECLARE_CONCRETE_INSTRUCTION(InstanceOf) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2769 | }; |
| 2770 | |
| 2771 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 2772 | class HInstanceOfKnownGlobal: public HUnaryOperation { |
| 2773 | public: |
| 2774 | HInstanceOfKnownGlobal(HValue* left, Handle<JSFunction> right) |
| 2775 | : HUnaryOperation(left), function_(right) { |
| 2776 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2777 | SetAllSideEffects(); |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 2778 | } |
| 2779 | |
| 2780 | Handle<JSFunction> function() { return function_; } |
| 2781 | |
| 2782 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2783 | return Representation::Tagged(); |
| 2784 | } |
| 2785 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2786 | DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal) |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 2787 | |
| 2788 | private: |
| 2789 | Handle<JSFunction> function_; |
| 2790 | }; |
| 2791 | |
| 2792 | |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2793 | class HPower: public HBinaryOperation { |
| 2794 | public: |
| 2795 | HPower(HValue* left, HValue* right) |
| 2796 | : HBinaryOperation(left, right) { |
| 2797 | set_representation(Representation::Double()); |
| 2798 | SetFlag(kUseGVN); |
| 2799 | } |
| 2800 | |
| 2801 | virtual Representation RequiredInputRepresentation(int index) const { |
| 2802 | return (index == 1) ? Representation::None() : Representation::Double(); |
| 2803 | } |
| 2804 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2805 | DECLARE_CONCRETE_INSTRUCTION(Power) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2806 | |
| 2807 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2808 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 5f0c45f | 2010-12-17 08:51:21 +0000 | [diff] [blame] | 2809 | }; |
| 2810 | |
| 2811 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2812 | class HAdd: public HArithmeticBinaryOperation { |
| 2813 | public: |
| 2814 | HAdd(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { |
| 2815 | SetFlag(kCanOverflow); |
| 2816 | } |
| 2817 | |
| 2818 | // Add is only commutative if two integer values are added and not if two |
| 2819 | // tagged values are added (because it might be a String concatenation). |
| 2820 | virtual bool IsCommutative() const { |
| 2821 | return !representation().IsTagged(); |
| 2822 | } |
| 2823 | |
| 2824 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2825 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2826 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2827 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2828 | DECLARE_CONCRETE_INSTRUCTION(Add) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2829 | |
| 2830 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2831 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2832 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2833 | virtual Range* InferRange(); |
| 2834 | }; |
| 2835 | |
| 2836 | |
| 2837 | class HSub: public HArithmeticBinaryOperation { |
| 2838 | public: |
| 2839 | HSub(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { |
| 2840 | SetFlag(kCanOverflow); |
| 2841 | } |
| 2842 | |
| 2843 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2844 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2845 | DECLARE_CONCRETE_INSTRUCTION(Sub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2846 | |
| 2847 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2848 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2849 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2850 | virtual Range* InferRange(); |
| 2851 | }; |
| 2852 | |
| 2853 | |
| 2854 | class HMul: public HArithmeticBinaryOperation { |
| 2855 | public: |
| 2856 | HMul(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { |
| 2857 | SetFlag(kCanOverflow); |
| 2858 | } |
| 2859 | |
| 2860 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2861 | |
| 2862 | // Only commutative if it is certain that not two objects are multiplicated. |
| 2863 | virtual bool IsCommutative() const { |
| 2864 | return !representation().IsTagged(); |
| 2865 | } |
| 2866 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2867 | DECLARE_CONCRETE_INSTRUCTION(Mul) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2868 | |
| 2869 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2870 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2871 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2872 | virtual Range* InferRange(); |
| 2873 | }; |
| 2874 | |
| 2875 | |
| 2876 | class HMod: public HArithmeticBinaryOperation { |
| 2877 | public: |
| 2878 | HMod(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { |
| 2879 | SetFlag(kCanBeDivByZero); |
| 2880 | } |
| 2881 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 2882 | bool HasPowerOf2Divisor() { |
| 2883 | if (right()->IsConstant() && |
| 2884 | HConstant::cast(right())->HasInteger32Value()) { |
| 2885 | int32_t value = HConstant::cast(right())->Integer32Value(); |
| 2886 | return value != 0 && (IsPowerOf2(value) || IsPowerOf2(-value)); |
| 2887 | } |
| 2888 | |
| 2889 | return false; |
| 2890 | } |
| 2891 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2892 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2893 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2894 | DECLARE_CONCRETE_INSTRUCTION(Mod) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2895 | |
| 2896 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2897 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2898 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2899 | virtual Range* InferRange(); |
| 2900 | }; |
| 2901 | |
| 2902 | |
| 2903 | class HDiv: public HArithmeticBinaryOperation { |
| 2904 | public: |
| 2905 | HDiv(HValue* left, HValue* right) : HArithmeticBinaryOperation(left, right) { |
| 2906 | SetFlag(kCanBeDivByZero); |
| 2907 | SetFlag(kCanOverflow); |
| 2908 | } |
| 2909 | |
| 2910 | virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); |
| 2911 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2912 | DECLARE_CONCRETE_INSTRUCTION(Div) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2913 | |
| 2914 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2915 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2916 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2917 | virtual Range* InferRange(); |
| 2918 | }; |
| 2919 | |
| 2920 | |
| 2921 | class HBitAnd: public HBitwiseBinaryOperation { |
| 2922 | public: |
| 2923 | HBitAnd(HValue* left, HValue* right) |
| 2924 | : HBitwiseBinaryOperation(left, right) { } |
| 2925 | |
| 2926 | virtual bool IsCommutative() const { return true; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2927 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2928 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2929 | DECLARE_CONCRETE_INSTRUCTION(BitAnd) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2930 | |
| 2931 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2932 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2933 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2934 | virtual Range* InferRange(); |
| 2935 | }; |
| 2936 | |
| 2937 | |
| 2938 | class HBitXor: public HBitwiseBinaryOperation { |
| 2939 | public: |
| 2940 | HBitXor(HValue* left, HValue* right) |
| 2941 | : HBitwiseBinaryOperation(left, right) { } |
| 2942 | |
| 2943 | virtual bool IsCommutative() const { return true; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2944 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2945 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2946 | DECLARE_CONCRETE_INSTRUCTION(BitXor) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2947 | |
| 2948 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2949 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2950 | }; |
| 2951 | |
| 2952 | |
| 2953 | class HBitOr: public HBitwiseBinaryOperation { |
| 2954 | public: |
| 2955 | HBitOr(HValue* left, HValue* right) |
| 2956 | : HBitwiseBinaryOperation(left, right) { } |
| 2957 | |
| 2958 | virtual bool IsCommutative() const { return true; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2959 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2960 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2961 | DECLARE_CONCRETE_INSTRUCTION(BitOr) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2962 | |
| 2963 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2964 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2965 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2966 | virtual Range* InferRange(); |
| 2967 | }; |
| 2968 | |
| 2969 | |
| 2970 | class HShl: public HBitwiseBinaryOperation { |
| 2971 | public: |
| 2972 | HShl(HValue* left, HValue* right) |
| 2973 | : HBitwiseBinaryOperation(left, right) { } |
| 2974 | |
| 2975 | virtual Range* InferRange(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2976 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2977 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2978 | DECLARE_CONCRETE_INSTRUCTION(Shl) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2979 | |
| 2980 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2981 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2982 | }; |
| 2983 | |
| 2984 | |
| 2985 | class HShr: public HBitwiseBinaryOperation { |
| 2986 | public: |
| 2987 | HShr(HValue* left, HValue* right) |
| 2988 | : HBitwiseBinaryOperation(left, right) { } |
| 2989 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2990 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2991 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 2992 | DECLARE_CONCRETE_INSTRUCTION(Shr) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 2993 | |
| 2994 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 2995 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 2996 | }; |
| 2997 | |
| 2998 | |
| 2999 | class HSar: public HBitwiseBinaryOperation { |
| 3000 | public: |
| 3001 | HSar(HValue* left, HValue* right) |
| 3002 | : HBitwiseBinaryOperation(left, right) { } |
| 3003 | |
| 3004 | virtual Range* InferRange(); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3005 | virtual HType CalculateInferredType(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3006 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3007 | DECLARE_CONCRETE_INSTRUCTION(Sar) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3008 | |
| 3009 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3010 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3011 | }; |
| 3012 | |
| 3013 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3014 | class HOsrEntry: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3015 | public: |
| 3016 | explicit HOsrEntry(int ast_id) : ast_id_(ast_id) { |
| 3017 | SetFlag(kChangesOsrEntries); |
| 3018 | } |
| 3019 | |
| 3020 | int ast_id() const { return ast_id_; } |
| 3021 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3022 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3023 | return Representation::None(); |
| 3024 | } |
| 3025 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3026 | DECLARE_CONCRETE_INSTRUCTION(OsrEntry) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3027 | |
| 3028 | private: |
| 3029 | int ast_id_; |
| 3030 | }; |
| 3031 | |
| 3032 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3033 | class HParameter: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3034 | public: |
| 3035 | explicit HParameter(unsigned index) : index_(index) { |
| 3036 | set_representation(Representation::Tagged()); |
| 3037 | } |
| 3038 | |
| 3039 | unsigned index() const { return index_; } |
| 3040 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3041 | virtual void PrintDataTo(StringStream* stream); |
| 3042 | |
| 3043 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3044 | return Representation::None(); |
| 3045 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3046 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3047 | DECLARE_CONCRETE_INSTRUCTION(Parameter) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3048 | |
| 3049 | private: |
| 3050 | unsigned index_; |
| 3051 | }; |
| 3052 | |
| 3053 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3054 | class HCallStub: public HUnaryCall { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3055 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3056 | HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) |
| 3057 | : HUnaryCall(context, argument_count), |
| 3058 | major_key_(major_key), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3059 | transcendental_type_(TranscendentalCache::kNumberOfCaches) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3060 | } |
| 3061 | |
| 3062 | CodeStub::Major major_key() { return major_key_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3063 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3064 | HValue* context() { return value(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3065 | |
| 3066 | void set_transcendental_type(TranscendentalCache::Type transcendental_type) { |
| 3067 | transcendental_type_ = transcendental_type; |
| 3068 | } |
| 3069 | TranscendentalCache::Type transcendental_type() { |
| 3070 | return transcendental_type_; |
| 3071 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3072 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3073 | virtual void PrintDataTo(StringStream* stream); |
| 3074 | |
| 3075 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3076 | return Representation::Tagged(); |
| 3077 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3078 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3079 | DECLARE_CONCRETE_INSTRUCTION(CallStub) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3080 | |
| 3081 | private: |
| 3082 | CodeStub::Major major_key_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3083 | TranscendentalCache::Type transcendental_type_; |
| 3084 | }; |
| 3085 | |
| 3086 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3087 | class HUnknownOSRValue: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3088 | public: |
| 3089 | HUnknownOSRValue() { set_representation(Representation::Tagged()); } |
| 3090 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3091 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3092 | return Representation::None(); |
| 3093 | } |
| 3094 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3095 | DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3096 | }; |
| 3097 | |
| 3098 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3099 | class HLoadGlobalCell: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3100 | public: |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3101 | HLoadGlobalCell(Handle<JSGlobalPropertyCell> cell, bool check_hole_value) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3102 | : cell_(cell), check_hole_value_(check_hole_value) { |
| 3103 | set_representation(Representation::Tagged()); |
| 3104 | SetFlag(kUseGVN); |
| 3105 | SetFlag(kDependsOnGlobalVars); |
| 3106 | } |
| 3107 | |
| 3108 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
| 3109 | bool check_hole_value() const { return check_hole_value_; } |
| 3110 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3111 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3112 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3113 | virtual intptr_t Hashcode() { |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3114 | ASSERT(!HEAP->allow_allocation(false)); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3115 | return reinterpret_cast<intptr_t>(*cell_); |
| 3116 | } |
| 3117 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3118 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3119 | return Representation::None(); |
| 3120 | } |
| 3121 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3122 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3123 | |
| 3124 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3125 | virtual bool DataEquals(HValue* other) { |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3126 | HLoadGlobalCell* b = HLoadGlobalCell::cast(other); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3127 | return cell_.is_identical_to(b->cell()); |
| 3128 | } |
| 3129 | |
| 3130 | private: |
| 3131 | Handle<JSGlobalPropertyCell> cell_; |
| 3132 | bool check_hole_value_; |
| 3133 | }; |
| 3134 | |
| 3135 | |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3136 | class HLoadGlobalGeneric: public HBinaryOperation { |
| 3137 | public: |
| 3138 | HLoadGlobalGeneric(HValue* context, |
| 3139 | HValue* global_object, |
| 3140 | Handle<Object> name, |
| 3141 | bool for_typeof) |
| 3142 | : HBinaryOperation(context, global_object), |
| 3143 | name_(name), |
| 3144 | for_typeof_(for_typeof) { |
| 3145 | set_representation(Representation::Tagged()); |
| 3146 | SetAllSideEffects(); |
| 3147 | } |
| 3148 | |
| 3149 | HValue* context() { return OperandAt(0); } |
| 3150 | HValue* global_object() { return OperandAt(1); } |
| 3151 | Handle<Object> name() const { return name_; } |
| 3152 | bool for_typeof() const { return for_typeof_; } |
| 3153 | |
| 3154 | virtual void PrintDataTo(StringStream* stream); |
| 3155 | |
| 3156 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3157 | return Representation::Tagged(); |
| 3158 | } |
| 3159 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3160 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) |
kmillikin@chromium.org | c36ce6e | 2011-04-04 08:25:31 +0000 | [diff] [blame] | 3161 | |
| 3162 | private: |
| 3163 | Handle<Object> name_; |
| 3164 | bool for_typeof_; |
| 3165 | }; |
| 3166 | |
| 3167 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3168 | class HStoreGlobalCell: public HUnaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3169 | public: |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3170 | HStoreGlobalCell(HValue* value, |
| 3171 | Handle<JSGlobalPropertyCell> cell, |
| 3172 | bool check_hole_value) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3173 | : HUnaryOperation(value), |
| 3174 | cell_(cell), |
| 3175 | check_hole_value_(check_hole_value) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3176 | SetFlag(kChangesGlobalVars); |
| 3177 | } |
| 3178 | |
| 3179 | Handle<JSGlobalPropertyCell> cell() const { return cell_; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3180 | bool check_hole_value() const { return check_hole_value_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3181 | |
| 3182 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3183 | return Representation::Tagged(); |
| 3184 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3185 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3186 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3187 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3188 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3189 | private: |
| 3190 | Handle<JSGlobalPropertyCell> cell_; |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3191 | bool check_hole_value_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3192 | }; |
| 3193 | |
| 3194 | |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3195 | class HStoreGlobalGeneric: public HTemplateInstruction<3> { |
| 3196 | public: |
| 3197 | HStoreGlobalGeneric(HValue* context, |
| 3198 | HValue* global_object, |
| 3199 | Handle<Object> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3200 | HValue* value, |
| 3201 | bool strict_mode) |
| 3202 | : name_(name), |
| 3203 | strict_mode_(strict_mode) { |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3204 | SetOperandAt(0, context); |
| 3205 | SetOperandAt(1, global_object); |
| 3206 | SetOperandAt(2, value); |
| 3207 | set_representation(Representation::Tagged()); |
| 3208 | SetAllSideEffects(); |
| 3209 | } |
| 3210 | |
| 3211 | HValue* context() { return OperandAt(0); } |
| 3212 | HValue* global_object() { return OperandAt(1); } |
| 3213 | Handle<Object> name() const { return name_; } |
| 3214 | HValue* value() { return OperandAt(2); } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3215 | bool strict_mode() { return strict_mode_; } |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3216 | |
| 3217 | virtual void PrintDataTo(StringStream* stream); |
| 3218 | |
| 3219 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3220 | return Representation::Tagged(); |
| 3221 | } |
| 3222 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3223 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3224 | |
| 3225 | private: |
| 3226 | Handle<Object> name_; |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3227 | bool strict_mode_; |
vegorov@chromium.org | 74f333b | 2011-04-06 11:17:46 +0000 | [diff] [blame] | 3228 | }; |
| 3229 | |
| 3230 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3231 | class HLoadContextSlot: public HUnaryOperation { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3232 | public: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3233 | HLoadContextSlot(HValue* context , int slot_index) |
| 3234 | : HUnaryOperation(context), slot_index_(slot_index) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3235 | set_representation(Representation::Tagged()); |
| 3236 | SetFlag(kUseGVN); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3237 | SetFlag(kDependsOnContextSlots); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3238 | } |
| 3239 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3240 | int slot_index() const { return slot_index_; } |
| 3241 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3242 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3243 | return Representation::Tagged(); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3244 | } |
| 3245 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3246 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3247 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3248 | DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot) |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3249 | |
| 3250 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3251 | virtual bool DataEquals(HValue* other) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3252 | HLoadContextSlot* b = HLoadContextSlot::cast(other); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3253 | return (slot_index() == b->slot_index()); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3254 | } |
| 3255 | |
| 3256 | private: |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3257 | int slot_index_; |
| 3258 | }; |
| 3259 | |
| 3260 | |
| 3261 | static inline bool StoringValueNeedsWriteBarrier(HValue* value) { |
| 3262 | return !value->type().IsSmi() && |
| 3263 | !(value->IsConstant() && HConstant::cast(value)->InOldSpace()); |
| 3264 | } |
| 3265 | |
| 3266 | |
| 3267 | class HStoreContextSlot: public HBinaryOperation { |
| 3268 | public: |
| 3269 | HStoreContextSlot(HValue* context, int slot_index, HValue* value) |
| 3270 | : HBinaryOperation(context, value), slot_index_(slot_index) { |
| 3271 | SetFlag(kChangesContextSlots); |
| 3272 | } |
| 3273 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3274 | HValue* context() { return OperandAt(0); } |
| 3275 | HValue* value() { return OperandAt(1); } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3276 | int slot_index() const { return slot_index_; } |
| 3277 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3278 | bool NeedsWriteBarrier() { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3279 | return StoringValueNeedsWriteBarrier(value()); |
| 3280 | } |
| 3281 | |
| 3282 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3283 | return Representation::Tagged(); |
| 3284 | } |
| 3285 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3286 | virtual void PrintDataTo(StringStream* stream); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3287 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3288 | DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3289 | |
| 3290 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 3291 | int slot_index_; |
| 3292 | }; |
| 3293 | |
| 3294 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3295 | class HLoadNamedField: public HUnaryOperation { |
| 3296 | public: |
| 3297 | HLoadNamedField(HValue* object, bool is_in_object, int offset) |
| 3298 | : HUnaryOperation(object), |
| 3299 | is_in_object_(is_in_object), |
| 3300 | offset_(offset) { |
| 3301 | set_representation(Representation::Tagged()); |
| 3302 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3303 | SetFlag(kDependsOnMaps); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3304 | if (is_in_object) { |
| 3305 | SetFlag(kDependsOnInobjectFields); |
| 3306 | } else { |
| 3307 | SetFlag(kDependsOnBackingStoreFields); |
| 3308 | } |
| 3309 | } |
| 3310 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3311 | HValue* object() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3312 | bool is_in_object() const { return is_in_object_; } |
| 3313 | int offset() const { return offset_; } |
| 3314 | |
| 3315 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3316 | return Representation::Tagged(); |
| 3317 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3318 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3319 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3320 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3321 | |
| 3322 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3323 | virtual bool DataEquals(HValue* other) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3324 | HLoadNamedField* b = HLoadNamedField::cast(other); |
| 3325 | return is_in_object_ == b->is_in_object_ && offset_ == b->offset_; |
| 3326 | } |
| 3327 | |
| 3328 | private: |
| 3329 | bool is_in_object_; |
| 3330 | int offset_; |
| 3331 | }; |
| 3332 | |
| 3333 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3334 | class HLoadNamedFieldPolymorphic: public HUnaryOperation { |
| 3335 | public: |
| 3336 | HLoadNamedFieldPolymorphic(HValue* object, |
| 3337 | ZoneMapList* types, |
| 3338 | Handle<String> name); |
| 3339 | |
| 3340 | HValue* object() { return OperandAt(0); } |
| 3341 | ZoneMapList* types() { return &types_; } |
| 3342 | Handle<String> name() { return name_; } |
| 3343 | bool need_generic() { return need_generic_; } |
| 3344 | |
| 3345 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3346 | return Representation::Tagged(); |
| 3347 | } |
| 3348 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3349 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedFieldPolymorphic) |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3350 | |
| 3351 | static const int kMaxLoadPolymorphism = 4; |
| 3352 | |
| 3353 | protected: |
| 3354 | virtual bool DataEquals(HValue* value); |
| 3355 | |
| 3356 | private: |
| 3357 | ZoneMapList types_; |
| 3358 | Handle<String> name_; |
| 3359 | bool need_generic_; |
| 3360 | }; |
| 3361 | |
| 3362 | |
| 3363 | |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3364 | class HLoadNamedGeneric: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3365 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3366 | HLoadNamedGeneric(HValue* context, HValue* object, Handle<Object> name) |
| 3367 | : HBinaryOperation(context, object), name_(name) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3368 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3369 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3370 | } |
| 3371 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3372 | HValue* context() { return OperandAt(0); } |
| 3373 | HValue* object() { return OperandAt(1); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3374 | Handle<Object> name() const { return name_; } |
| 3375 | |
| 3376 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3377 | return Representation::Tagged(); |
| 3378 | } |
| 3379 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3380 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3381 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3382 | private: |
| 3383 | Handle<Object> name_; |
| 3384 | }; |
| 3385 | |
| 3386 | |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3387 | class HLoadFunctionPrototype: public HUnaryOperation { |
| 3388 | public: |
| 3389 | explicit HLoadFunctionPrototype(HValue* function) |
| 3390 | : HUnaryOperation(function) { |
| 3391 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3392 | SetFlag(kUseGVN); |
| 3393 | SetFlag(kDependsOnCalls); |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3394 | } |
| 3395 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3396 | HValue* function() { return OperandAt(0); } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3397 | |
| 3398 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3399 | return Representation::Tagged(); |
| 3400 | } |
| 3401 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3402 | DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype) |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3403 | |
| 3404 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3405 | virtual bool DataEquals(HValue* other) { return true; } |
fschneider@chromium.org | 9e3e0b6 | 2011-01-03 10:16:46 +0000 | [diff] [blame] | 3406 | }; |
| 3407 | |
| 3408 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3409 | class HLoadKeyedFastElement: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3410 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3411 | HLoadKeyedFastElement(HValue* obj, HValue* key) : HBinaryOperation(obj, key) { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3412 | set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3413 | SetFlag(kDependsOnArrayElements); |
| 3414 | SetFlag(kUseGVN); |
| 3415 | } |
| 3416 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3417 | HValue* object() { return OperandAt(0); } |
| 3418 | HValue* key() { return OperandAt(1); } |
| 3419 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3420 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3421 | // The key is supposed to be Integer32. |
| 3422 | return (index == 1) ? Representation::Integer32() |
| 3423 | : Representation::Tagged(); |
| 3424 | } |
| 3425 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3426 | virtual void PrintDataTo(StringStream* stream); |
| 3427 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 3428 | bool RequiresHoleCheck() const; |
| 3429 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3430 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement) |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3431 | |
| 3432 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3433 | virtual bool DataEquals(HValue* other) { return true; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3434 | }; |
| 3435 | |
| 3436 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3437 | class HLoadKeyedSpecializedArrayElement: public HBinaryOperation { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3438 | public: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3439 | HLoadKeyedSpecializedArrayElement(HValue* external_elements, |
| 3440 | HValue* key, |
| 3441 | ExternalArrayType array_type) |
| 3442 | : HBinaryOperation(external_elements, key), |
| 3443 | array_type_(array_type) { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 3444 | if (array_type == kExternalFloatArray || |
| 3445 | array_type == kExternalDoubleArray) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3446 | set_representation(Representation::Double()); |
| 3447 | } else { |
| 3448 | set_representation(Representation::Integer32()); |
| 3449 | } |
| 3450 | SetFlag(kDependsOnSpecializedArrayElements); |
| 3451 | // Native code could change the specialized array. |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3452 | SetFlag(kDependsOnCalls); |
| 3453 | SetFlag(kUseGVN); |
| 3454 | } |
| 3455 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3456 | virtual void PrintDataTo(StringStream* stream); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3457 | |
| 3458 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3459 | // The key is supposed to be Integer32, but the base pointer |
| 3460 | // for the element load is a naked pointer. |
| 3461 | return (index == 1) ? Representation::Integer32() |
| 3462 | : Representation::External(); |
| 3463 | } |
| 3464 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3465 | HValue* external_pointer() { return OperandAt(0); } |
| 3466 | HValue* key() { return OperandAt(1); } |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3467 | ExternalArrayType array_type() const { return array_type_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3468 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3469 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement) |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3470 | |
| 3471 | protected: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3472 | virtual bool DataEquals(HValue* other) { |
| 3473 | if (!other->IsLoadKeyedSpecializedArrayElement()) return false; |
| 3474 | HLoadKeyedSpecializedArrayElement* cast_other = |
| 3475 | HLoadKeyedSpecializedArrayElement::cast(other); |
| 3476 | return array_type_ == cast_other->array_type(); |
| 3477 | } |
| 3478 | |
| 3479 | private: |
| 3480 | ExternalArrayType array_type_; |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3481 | }; |
| 3482 | |
| 3483 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3484 | class HLoadKeyedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3485 | public: |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 3486 | HLoadKeyedGeneric(HValue* context, HValue* obj, HValue* key) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3487 | set_representation(Representation::Tagged()); |
| 3488 | SetOperandAt(0, obj); |
| 3489 | SetOperandAt(1, key); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3490 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3491 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3492 | } |
| 3493 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3494 | HValue* object() { return OperandAt(0); } |
| 3495 | HValue* key() { return OperandAt(1); } |
| 3496 | HValue* context() { return OperandAt(2); } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3497 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3498 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3499 | |
| 3500 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3501 | return Representation::Tagged(); |
| 3502 | } |
| 3503 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3504 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3505 | }; |
| 3506 | |
| 3507 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3508 | class HStoreNamedField: public HBinaryOperation { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3509 | public: |
| 3510 | HStoreNamedField(HValue* obj, |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3511 | Handle<String> name, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3512 | HValue* val, |
| 3513 | bool in_object, |
| 3514 | int offset) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3515 | : HBinaryOperation(obj, val), |
| 3516 | name_(name), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3517 | is_in_object_(in_object), |
| 3518 | offset_(offset) { |
| 3519 | if (is_in_object_) { |
| 3520 | SetFlag(kChangesInobjectFields); |
| 3521 | } else { |
| 3522 | SetFlag(kChangesBackingStoreFields); |
| 3523 | } |
| 3524 | } |
| 3525 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3526 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3527 | |
| 3528 | virtual Representation RequiredInputRepresentation(int index) const { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3529 | return Representation::Tagged(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3530 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3531 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3532 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3533 | HValue* object() { return OperandAt(0); } |
| 3534 | HValue* value() { return OperandAt(1); } |
| 3535 | |
| 3536 | Handle<String> name() const { return name_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3537 | bool is_in_object() const { return is_in_object_; } |
| 3538 | int offset() const { return offset_; } |
| 3539 | Handle<Map> transition() const { return transition_; } |
| 3540 | void set_transition(Handle<Map> map) { transition_ = map; } |
| 3541 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3542 | bool NeedsWriteBarrier() { |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 3543 | return StoringValueNeedsWriteBarrier(value()); |
| 3544 | } |
| 3545 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3546 | private: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3547 | Handle<String> name_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3548 | bool is_in_object_; |
| 3549 | int offset_; |
| 3550 | Handle<Map> transition_; |
| 3551 | }; |
| 3552 | |
| 3553 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3554 | class HStoreNamedGeneric: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3555 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3556 | HStoreNamedGeneric(HValue* context, |
| 3557 | HValue* object, |
| 3558 | Handle<String> name, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3559 | HValue* value, |
| 3560 | bool strict_mode) |
| 3561 | : name_(name), |
| 3562 | strict_mode_(strict_mode) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3563 | SetOperandAt(0, object); |
| 3564 | SetOperandAt(1, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3565 | SetOperandAt(2, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3566 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3567 | } |
| 3568 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3569 | HValue* object() { return OperandAt(0); } |
| 3570 | HValue* value() { return OperandAt(1); } |
| 3571 | HValue* context() { return OperandAt(2); } |
| 3572 | Handle<String> name() { return name_; } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3573 | bool strict_mode() { return strict_mode_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3574 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3575 | virtual void PrintDataTo(StringStream* stream); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3576 | |
| 3577 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3578 | return Representation::Tagged(); |
| 3579 | } |
| 3580 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3581 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3582 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3583 | private: |
| 3584 | Handle<String> name_; |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3585 | bool strict_mode_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3586 | }; |
| 3587 | |
| 3588 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3589 | class HStoreKeyedFastElement: public HTemplateInstruction<3> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3590 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3591 | HStoreKeyedFastElement(HValue* obj, HValue* key, HValue* val) { |
| 3592 | SetOperandAt(0, obj); |
| 3593 | SetOperandAt(1, key); |
| 3594 | SetOperandAt(2, val); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3595 | SetFlag(kChangesArrayElements); |
| 3596 | } |
| 3597 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3598 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3599 | // The key is supposed to be Integer32. |
| 3600 | return (index == 1) ? Representation::Integer32() |
| 3601 | : Representation::Tagged(); |
| 3602 | } |
| 3603 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3604 | HValue* object() { return OperandAt(0); } |
| 3605 | HValue* key() { return OperandAt(1); } |
| 3606 | HValue* value() { return OperandAt(2); } |
| 3607 | |
| 3608 | bool NeedsWriteBarrier() { |
| 3609 | return StoringValueNeedsWriteBarrier(value()); |
| 3610 | } |
| 3611 | |
| 3612 | virtual void PrintDataTo(StringStream* stream); |
| 3613 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3614 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3615 | }; |
| 3616 | |
| 3617 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3618 | class HStoreKeyedSpecializedArrayElement: public HTemplateInstruction<3> { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3619 | public: |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3620 | HStoreKeyedSpecializedArrayElement(HValue* external_elements, |
| 3621 | HValue* key, |
| 3622 | HValue* val, |
| 3623 | ExternalArrayType array_type) |
| 3624 | : array_type_(array_type) { |
| 3625 | SetFlag(kChangesSpecializedArrayElements); |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3626 | SetOperandAt(0, external_elements); |
| 3627 | SetOperandAt(1, key); |
| 3628 | SetOperandAt(2, val); |
| 3629 | } |
| 3630 | |
| 3631 | virtual void PrintDataTo(StringStream* stream); |
| 3632 | |
| 3633 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3634 | if (index == 0) { |
| 3635 | return Representation::External(); |
| 3636 | } else { |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 3637 | if (index == 2 && (array_type() == kExternalFloatArray || |
| 3638 | array_type() == kExternalDoubleArray)) { |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3639 | return Representation::Double(); |
| 3640 | } else { |
| 3641 | return Representation::Integer32(); |
| 3642 | } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3643 | } |
| 3644 | } |
| 3645 | |
| 3646 | HValue* external_pointer() { return OperandAt(0); } |
| 3647 | HValue* key() { return OperandAt(1); } |
| 3648 | HValue* value() { return OperandAt(2); } |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3649 | ExternalArrayType array_type() const { return array_type_; } |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3650 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3651 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement) |
| 3652 | |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3653 | private: |
| 3654 | ExternalArrayType array_type_; |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3655 | }; |
| 3656 | |
| 3657 | |
| 3658 | class HStoreKeyedGeneric: public HTemplateInstruction<4> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3659 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3660 | HStoreKeyedGeneric(HValue* context, |
| 3661 | HValue* object, |
| 3662 | HValue* key, |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3663 | HValue* value, |
| 3664 | bool strict_mode) |
| 3665 | : strict_mode_(strict_mode) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3666 | SetOperandAt(0, object); |
| 3667 | SetOperandAt(1, key); |
| 3668 | SetOperandAt(2, value); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3669 | SetOperandAt(3, context); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3670 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3671 | } |
| 3672 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3673 | HValue* object() { return OperandAt(0); } |
| 3674 | HValue* key() { return OperandAt(1); } |
| 3675 | HValue* value() { return OperandAt(2); } |
| 3676 | HValue* context() { return OperandAt(3); } |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3677 | bool strict_mode() { return strict_mode_; } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3678 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3679 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3680 | return Representation::Tagged(); |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3681 | } |
| 3682 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3683 | virtual void PrintDataTo(StringStream* stream); |
| 3684 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3685 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) |
karlklose@chromium.org | 44bc708 | 2011-04-11 12:33:05 +0000 | [diff] [blame] | 3686 | |
| 3687 | private: |
| 3688 | bool strict_mode_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3689 | }; |
| 3690 | |
| 3691 | |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3692 | class HStringAdd: public HBinaryOperation { |
| 3693 | public: |
| 3694 | HStringAdd(HValue* left, HValue* right) : HBinaryOperation(left, right) { |
| 3695 | set_representation(Representation::Tagged()); |
| 3696 | SetFlag(kUseGVN); |
| 3697 | SetFlag(kDependsOnMaps); |
| 3698 | } |
| 3699 | |
| 3700 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3701 | return Representation::Tagged(); |
| 3702 | } |
| 3703 | |
| 3704 | virtual HType CalculateInferredType() { |
| 3705 | return HType::String(); |
| 3706 | } |
| 3707 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3708 | DECLARE_CONCRETE_INSTRUCTION(StringAdd) |
danno@chromium.org | 160a7b0 | 2011-04-18 15:51:38 +0000 | [diff] [blame] | 3709 | |
| 3710 | protected: |
| 3711 | virtual bool DataEquals(HValue* other) { return true; } |
| 3712 | }; |
| 3713 | |
| 3714 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3715 | class HStringCharCodeAt: public HBinaryOperation { |
| 3716 | public: |
| 3717 | HStringCharCodeAt(HValue* string, HValue* index) |
| 3718 | : HBinaryOperation(string, index) { |
| 3719 | set_representation(Representation::Integer32()); |
| 3720 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3721 | SetFlag(kDependsOnMaps); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3722 | } |
| 3723 | |
| 3724 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3725 | // The index is supposed to be Integer32. |
| 3726 | return (index == 1) ? Representation::Integer32() |
| 3727 | : Representation::Tagged(); |
| 3728 | } |
| 3729 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3730 | HValue* string() { return OperandAt(0); } |
| 3731 | HValue* index() { return OperandAt(1); } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3732 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3733 | DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3734 | |
| 3735 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3736 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3737 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3738 | virtual Range* InferRange() { |
| 3739 | return new Range(0, String::kMaxUC16CharCode); |
| 3740 | } |
| 3741 | }; |
| 3742 | |
| 3743 | |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 3744 | class HStringCharFromCode: public HUnaryOperation { |
| 3745 | public: |
| 3746 | explicit HStringCharFromCode(HValue* char_code) : HUnaryOperation(char_code) { |
| 3747 | set_representation(Representation::Tagged()); |
| 3748 | SetFlag(kUseGVN); |
| 3749 | } |
| 3750 | |
| 3751 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3752 | return Representation::Integer32(); |
| 3753 | } |
| 3754 | |
| 3755 | virtual bool DataEquals(HValue* other) { return true; } |
| 3756 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3757 | DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode) |
whesse@chromium.org | b08986c | 2011-03-14 16:13:42 +0000 | [diff] [blame] | 3758 | }; |
| 3759 | |
| 3760 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3761 | class HStringLength: public HUnaryOperation { |
| 3762 | public: |
| 3763 | explicit HStringLength(HValue* string) : HUnaryOperation(string) { |
| 3764 | set_representation(Representation::Tagged()); |
| 3765 | SetFlag(kUseGVN); |
fschneider@chromium.org | 7979bbb | 2011-03-28 10:47:03 +0000 | [diff] [blame] | 3766 | SetFlag(kDependsOnMaps); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3767 | } |
| 3768 | |
| 3769 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3770 | return Representation::Tagged(); |
| 3771 | } |
| 3772 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3773 | virtual HType CalculateInferredType() { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3774 | STATIC_ASSERT(String::kMaxLength <= Smi::kMaxValue); |
| 3775 | return HType::Smi(); |
| 3776 | } |
| 3777 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3778 | DECLARE_CONCRETE_INSTRUCTION(StringLength) |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3779 | |
| 3780 | protected: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3781 | virtual bool DataEquals(HValue* other) { return true; } |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3782 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 3783 | virtual Range* InferRange() { |
| 3784 | return new Range(0, String::kMaxLength); |
| 3785 | } |
| 3786 | }; |
| 3787 | |
| 3788 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3789 | template <int V> |
| 3790 | class HMaterializedLiteral: public HTemplateInstruction<V> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3791 | public: |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3792 | HMaterializedLiteral<V>(int index, int depth) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3793 | : literal_index_(index), depth_(depth) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3794 | this->set_representation(Representation::Tagged()); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3795 | } |
| 3796 | |
| 3797 | int literal_index() const { return literal_index_; } |
| 3798 | int depth() const { return depth_; } |
| 3799 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3800 | private: |
| 3801 | int literal_index_; |
| 3802 | int depth_; |
| 3803 | }; |
| 3804 | |
| 3805 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3806 | class HArrayLiteral: public HMaterializedLiteral<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3807 | public: |
| 3808 | HArrayLiteral(Handle<FixedArray> constant_elements, |
| 3809 | int length, |
| 3810 | int literal_index, |
| 3811 | int depth) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3812 | : HMaterializedLiteral<0>(literal_index, depth), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3813 | length_(length), |
| 3814 | constant_elements_(constant_elements) {} |
| 3815 | |
| 3816 | Handle<FixedArray> constant_elements() const { return constant_elements_; } |
| 3817 | int length() const { return length_; } |
| 3818 | |
| 3819 | bool IsCopyOnWrite() const; |
| 3820 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3821 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3822 | return Representation::None(); |
| 3823 | } |
| 3824 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3825 | DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3826 | |
| 3827 | private: |
| 3828 | int length_; |
| 3829 | Handle<FixedArray> constant_elements_; |
| 3830 | }; |
| 3831 | |
| 3832 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3833 | class HObjectLiteral: public HMaterializedLiteral<1> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3834 | public: |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3835 | HObjectLiteral(HValue* context, |
| 3836 | Handle<FixedArray> constant_properties, |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3837 | bool fast_elements, |
| 3838 | int literal_index, |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3839 | int depth, |
| 3840 | bool has_function) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3841 | : HMaterializedLiteral<1>(literal_index, depth), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3842 | constant_properties_(constant_properties), |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3843 | fast_elements_(fast_elements), |
| 3844 | has_function_(has_function) { |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3845 | SetOperandAt(0, context); |
| 3846 | } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3847 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3848 | HValue* context() { return OperandAt(0); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3849 | Handle<FixedArray> constant_properties() const { |
| 3850 | return constant_properties_; |
| 3851 | } |
| 3852 | bool fast_elements() const { return fast_elements_; } |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3853 | bool has_function() const { return has_function_; } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3854 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3855 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3856 | return Representation::Tagged(); |
| 3857 | } |
sgjesse@chromium.org | 496c03a | 2011-02-14 12:05:43 +0000 | [diff] [blame] | 3858 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3859 | DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3860 | |
| 3861 | private: |
| 3862 | Handle<FixedArray> constant_properties_; |
| 3863 | bool fast_elements_; |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3864 | bool has_function_; |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3865 | }; |
| 3866 | |
| 3867 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3868 | class HRegExpLiteral: public HMaterializedLiteral<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3869 | public: |
| 3870 | HRegExpLiteral(Handle<String> pattern, |
| 3871 | Handle<String> flags, |
| 3872 | int literal_index) |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3873 | : HMaterializedLiteral<0>(literal_index, 0), |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3874 | pattern_(pattern), |
| 3875 | flags_(flags) { } |
| 3876 | |
| 3877 | Handle<String> pattern() { return pattern_; } |
| 3878 | Handle<String> flags() { return flags_; } |
| 3879 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3880 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3881 | return Representation::None(); |
| 3882 | } |
| 3883 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3884 | DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3885 | |
| 3886 | private: |
| 3887 | Handle<String> pattern_; |
| 3888 | Handle<String> flags_; |
| 3889 | }; |
| 3890 | |
| 3891 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3892 | class HFunctionLiteral: public HTemplateInstruction<0> { |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3893 | public: |
| 3894 | HFunctionLiteral(Handle<SharedFunctionInfo> shared, bool pretenure) |
| 3895 | : shared_info_(shared), pretenure_(pretenure) { |
| 3896 | set_representation(Representation::Tagged()); |
| 3897 | } |
| 3898 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3899 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3900 | return Representation::None(); |
| 3901 | } |
| 3902 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3903 | DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3904 | |
| 3905 | Handle<SharedFunctionInfo> shared_info() const { return shared_info_; } |
| 3906 | bool pretenure() const { return pretenure_; } |
| 3907 | |
| 3908 | private: |
| 3909 | Handle<SharedFunctionInfo> shared_info_; |
| 3910 | bool pretenure_; |
| 3911 | }; |
| 3912 | |
| 3913 | |
| 3914 | class HTypeof: public HUnaryOperation { |
| 3915 | public: |
| 3916 | explicit HTypeof(HValue* value) : HUnaryOperation(value) { |
| 3917 | set_representation(Representation::Tagged()); |
| 3918 | } |
| 3919 | |
kmillikin@chromium.org | 31b1277 | 2011-02-02 16:08:26 +0000 | [diff] [blame] | 3920 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3921 | return Representation::Tagged(); |
| 3922 | } |
| 3923 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3924 | DECLARE_CONCRETE_INSTRUCTION(Typeof) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3925 | }; |
| 3926 | |
| 3927 | |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3928 | class HToFastProperties: public HUnaryOperation { |
| 3929 | public: |
| 3930 | explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { |
| 3931 | // This instruction is not marked as having side effects, but |
| 3932 | // changes the map of the input operand. Use it only when creating |
| 3933 | // object literals. |
| 3934 | ASSERT(value->IsObjectLiteral()); |
| 3935 | set_representation(Representation::Tagged()); |
| 3936 | } |
| 3937 | |
| 3938 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3939 | return Representation::Tagged(); |
| 3940 | } |
| 3941 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3942 | DECLARE_CONCRETE_INSTRUCTION(ToFastProperties) |
sgjesse@chromium.org | ea88ce9 | 2011-03-23 11:19:56 +0000 | [diff] [blame] | 3943 | }; |
| 3944 | |
| 3945 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3946 | class HValueOf: public HUnaryOperation { |
| 3947 | public: |
| 3948 | explicit HValueOf(HValue* value) : HUnaryOperation(value) { |
| 3949 | set_representation(Representation::Tagged()); |
| 3950 | } |
| 3951 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3952 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3953 | return Representation::Tagged(); |
| 3954 | } |
| 3955 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3956 | DECLARE_CONCRETE_INSTRUCTION(ValueOf) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3957 | }; |
| 3958 | |
| 3959 | |
| 3960 | class HDeleteProperty: public HBinaryOperation { |
| 3961 | public: |
| 3962 | HDeleteProperty(HValue* obj, HValue* key) |
| 3963 | : HBinaryOperation(obj, key) { |
| 3964 | set_representation(Representation::Tagged()); |
ager@chromium.org | 378b34e | 2011-01-28 08:04:38 +0000 | [diff] [blame] | 3965 | SetAllSideEffects(); |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3966 | } |
| 3967 | |
| 3968 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3969 | return Representation::Tagged(); |
| 3970 | } |
| 3971 | |
ricow@chromium.org | dcebac0 | 2011-04-20 09:44:50 +0000 | [diff] [blame] | 3972 | DECLARE_CONCRETE_INSTRUCTION(DeleteProperty) |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3973 | |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 3974 | HValue* object() { return left(); } |
| 3975 | HValue* key() { return right(); } |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 3976 | }; |
| 3977 | |
erik.corry@gmail.com | 3847bd5 | 2011-04-27 10:38:56 +0000 | [diff] [blame] | 3978 | |
| 3979 | class HIn: public HTemplateInstruction<2> { |
| 3980 | public: |
| 3981 | HIn(HValue* key, HValue* object) { |
| 3982 | SetOperandAt(0, key); |
| 3983 | SetOperandAt(1, object); |
| 3984 | set_representation(Representation::Tagged()); |
| 3985 | SetAllSideEffects(); |
| 3986 | } |
| 3987 | |
| 3988 | HValue* key() { return OperandAt(0); } |
| 3989 | HValue* object() { return OperandAt(1); } |
| 3990 | |
| 3991 | virtual Representation RequiredInputRepresentation(int index) const { |
| 3992 | return Representation::Tagged(); |
| 3993 | } |
| 3994 | |
| 3995 | virtual HType CalculateInferredType() { |
| 3996 | return HType::Boolean(); |
| 3997 | } |
| 3998 | |
| 3999 | virtual void PrintDataTo(StringStream* stream); |
| 4000 | |
| 4001 | DECLARE_CONCRETE_INSTRUCTION(In) |
| 4002 | }; |
| 4003 | |
kasperl@chromium.org | a555126 | 2010-12-07 12:49:48 +0000 | [diff] [blame] | 4004 | #undef DECLARE_INSTRUCTION |
| 4005 | #undef DECLARE_CONCRETE_INSTRUCTION |
| 4006 | |
| 4007 | } } // namespace v8::internal |
| 4008 | |
| 4009 | #endif // V8_HYDROGEN_INSTRUCTIONS_H_ |