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