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