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