erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +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_MIPS_LITHIUM_MIPS_H_ |
| 29 | #define V8_MIPS_LITHIUM_MIPS_H_ |
| 30 | |
| 31 | #include "hydrogen.h" |
| 32 | #include "lithium-allocator.h" |
| 33 | #include "lithium.h" |
| 34 | #include "safepoint-table.h" |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 35 | #include "utils.h" |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 36 | |
| 37 | namespace v8 { |
| 38 | namespace internal { |
| 39 | |
| 40 | // Forward declarations. |
| 41 | class LCodeGen; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 42 | |
| 43 | #define LITHIUM_ALL_INSTRUCTION_LIST(V) \ |
| 44 | V(ControlInstruction) \ |
| 45 | V(Call) \ |
| 46 | LITHIUM_CONCRETE_INSTRUCTION_LIST(V) |
| 47 | |
| 48 | |
| 49 | #define LITHIUM_CONCRETE_INSTRUCTION_LIST(V) \ |
| 50 | V(AccessArgumentsAt) \ |
| 51 | V(AddI) \ |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 52 | V(AllocateObject) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 53 | V(ApplyArguments) \ |
| 54 | V(ArgumentsElements) \ |
| 55 | V(ArgumentsLength) \ |
| 56 | V(ArithmeticD) \ |
| 57 | V(ArithmeticT) \ |
| 58 | V(ArrayLiteral) \ |
| 59 | V(BitI) \ |
| 60 | V(BitNotI) \ |
| 61 | V(BoundsCheck) \ |
| 62 | V(Branch) \ |
| 63 | V(CallConstantFunction) \ |
| 64 | V(CallFunction) \ |
| 65 | V(CallGlobal) \ |
| 66 | V(CallKeyed) \ |
| 67 | V(CallKnownGlobal) \ |
| 68 | V(CallNamed) \ |
| 69 | V(CallNew) \ |
| 70 | V(CallRuntime) \ |
| 71 | V(CallStub) \ |
| 72 | V(CheckFunction) \ |
| 73 | V(CheckInstanceType) \ |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 74 | V(CheckMaps) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 75 | V(CheckNonSmi) \ |
| 76 | V(CheckPrototypeMaps) \ |
| 77 | V(CheckSmi) \ |
| 78 | V(ClampDToUint8) \ |
| 79 | V(ClampIToUint8) \ |
| 80 | V(ClampTToUint8) \ |
| 81 | V(ClassOfTestAndBranch) \ |
| 82 | V(CmpConstantEqAndBranch) \ |
| 83 | V(CmpIDAndBranch) \ |
| 84 | V(CmpObjectEqAndBranch) \ |
| 85 | V(CmpMapAndBranch) \ |
| 86 | V(CmpT) \ |
| 87 | V(ConstantD) \ |
| 88 | V(ConstantI) \ |
| 89 | V(ConstantT) \ |
| 90 | V(Context) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 91 | V(DeclareGlobals) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 92 | V(DeleteProperty) \ |
| 93 | V(Deoptimize) \ |
| 94 | V(DivI) \ |
| 95 | V(DoubleToI) \ |
| 96 | V(ElementsKind) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 97 | V(FastLiteral) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 98 | V(FixedArrayBaseLength) \ |
| 99 | V(FunctionLiteral) \ |
| 100 | V(GetCachedArrayIndex) \ |
| 101 | V(GlobalObject) \ |
| 102 | V(GlobalReceiver) \ |
| 103 | V(Goto) \ |
| 104 | V(HasCachedArrayIndexAndBranch) \ |
| 105 | V(HasInstanceTypeAndBranch) \ |
| 106 | V(In) \ |
| 107 | V(InstanceOf) \ |
| 108 | V(InstanceOfKnownGlobal) \ |
| 109 | V(InstructionGap) \ |
| 110 | V(Integer32ToDouble) \ |
| 111 | V(InvokeFunction) \ |
| 112 | V(IsConstructCallAndBranch) \ |
| 113 | V(IsNilAndBranch) \ |
| 114 | V(IsObjectAndBranch) \ |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 115 | V(IsStringAndBranch) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 116 | V(IsSmiAndBranch) \ |
| 117 | V(IsUndetectableAndBranch) \ |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 118 | V(StringCompareAndBranch) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 119 | V(JSArrayLength) \ |
| 120 | V(Label) \ |
| 121 | V(LazyBailout) \ |
| 122 | V(LoadContextSlot) \ |
| 123 | V(LoadElements) \ |
| 124 | V(LoadExternalArrayPointer) \ |
| 125 | V(LoadFunctionPrototype) \ |
| 126 | V(LoadGlobalCell) \ |
| 127 | V(LoadGlobalGeneric) \ |
| 128 | V(LoadKeyedFastDoubleElement) \ |
| 129 | V(LoadKeyedFastElement) \ |
| 130 | V(LoadKeyedGeneric) \ |
| 131 | V(LoadKeyedSpecializedArrayElement) \ |
| 132 | V(LoadNamedField) \ |
| 133 | V(LoadNamedFieldPolymorphic) \ |
| 134 | V(LoadNamedGeneric) \ |
| 135 | V(ModI) \ |
| 136 | V(MulI) \ |
| 137 | V(NumberTagD) \ |
| 138 | V(NumberTagI) \ |
| 139 | V(NumberUntagD) \ |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 140 | V(ObjectLiteral) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 141 | V(OsrEntry) \ |
| 142 | V(OuterContext) \ |
| 143 | V(Parameter) \ |
| 144 | V(Power) \ |
| 145 | V(PushArgument) \ |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 146 | V(Random) \ |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 147 | V(RegExpLiteral) \ |
| 148 | V(Return) \ |
| 149 | V(ShiftI) \ |
| 150 | V(SmiTag) \ |
| 151 | V(SmiUntag) \ |
| 152 | V(StackCheck) \ |
| 153 | V(StoreContextSlot) \ |
| 154 | V(StoreGlobalCell) \ |
| 155 | V(StoreGlobalGeneric) \ |
| 156 | V(StoreKeyedFastDoubleElement) \ |
| 157 | V(StoreKeyedFastElement) \ |
| 158 | V(StoreKeyedGeneric) \ |
| 159 | V(StoreKeyedSpecializedArrayElement) \ |
| 160 | V(StoreNamedField) \ |
| 161 | V(StoreNamedGeneric) \ |
| 162 | V(StringAdd) \ |
| 163 | V(StringCharCodeAt) \ |
| 164 | V(StringCharFromCode) \ |
| 165 | V(StringLength) \ |
| 166 | V(SubI) \ |
| 167 | V(TaggedToI) \ |
| 168 | V(ThisFunction) \ |
| 169 | V(Throw) \ |
| 170 | V(ToFastProperties) \ |
| 171 | V(TransitionElementsKind) \ |
| 172 | V(Typeof) \ |
| 173 | V(TypeofIsAndBranch) \ |
| 174 | V(UnaryMathOperation) \ |
| 175 | V(UnknownOSRValue) \ |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 176 | V(ValueOf) \ |
| 177 | V(ForInPrepareMap) \ |
| 178 | V(ForInCacheArray) \ |
| 179 | V(CheckMapValue) \ |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 180 | V(LoadFieldByIndex) \ |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 181 | V(DateField) \ |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 182 | V(WrapReceiver) \ |
| 183 | V(Drop) |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 184 | |
| 185 | #define DECLARE_CONCRETE_INSTRUCTION(type, mnemonic) \ |
| 186 | virtual Opcode opcode() const { return LInstruction::k##type; } \ |
| 187 | virtual void CompileToNative(LCodeGen* generator); \ |
| 188 | virtual const char* Mnemonic() const { return mnemonic; } \ |
| 189 | static L##type* cast(LInstruction* instr) { \ |
| 190 | ASSERT(instr->Is##type()); \ |
| 191 | return reinterpret_cast<L##type*>(instr); \ |
| 192 | } |
| 193 | |
| 194 | |
| 195 | #define DECLARE_HYDROGEN_ACCESSOR(type) \ |
| 196 | H##type* hydrogen() const { \ |
| 197 | return H##type::cast(hydrogen_value()); \ |
| 198 | } |
| 199 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 200 | |
| 201 | class LInstruction: public ZoneObject { |
| 202 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 203 | LInstruction() |
| 204 | : environment_(NULL), |
| 205 | hydrogen_value_(NULL), |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame^] | 206 | is_call_(false) { } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 207 | virtual ~LInstruction() { } |
| 208 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 209 | virtual void CompileToNative(LCodeGen* generator) = 0; |
| 210 | virtual const char* Mnemonic() const = 0; |
| 211 | virtual void PrintTo(StringStream* stream); |
mstarzinger@chromium.org | 88d326b | 2012-04-23 12:57:22 +0000 | [diff] [blame] | 212 | virtual void PrintDataTo(StringStream* stream); |
| 213 | virtual void PrintOutputOperandTo(StringStream* stream); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 214 | |
| 215 | enum Opcode { |
| 216 | // Declare a unique enum value for each instruction. |
| 217 | #define DECLARE_OPCODE(type) k##type, |
| 218 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_OPCODE) |
| 219 | kNumberOfInstructions |
| 220 | #undef DECLARE_OPCODE |
| 221 | }; |
| 222 | |
| 223 | virtual Opcode opcode() const = 0; |
| 224 | |
| 225 | // Declare non-virtual type testers for all leaf IR classes. |
| 226 | #define DECLARE_PREDICATE(type) \ |
| 227 | bool Is##type() const { return opcode() == k##type; } |
| 228 | LITHIUM_CONCRETE_INSTRUCTION_LIST(DECLARE_PREDICATE) |
| 229 | #undef DECLARE_PREDICATE |
| 230 | |
| 231 | // Declare virtual predicates for instructions that don't have |
| 232 | // an opcode. |
| 233 | virtual bool IsGap() const { return false; } |
| 234 | |
| 235 | virtual bool IsControl() const { return false; } |
| 236 | |
| 237 | void set_environment(LEnvironment* env) { environment_ = env; } |
| 238 | LEnvironment* environment() const { return environment_; } |
| 239 | bool HasEnvironment() const { return environment_ != NULL; } |
| 240 | |
| 241 | void set_pointer_map(LPointerMap* p) { pointer_map_.set(p); } |
| 242 | LPointerMap* pointer_map() const { return pointer_map_.get(); } |
| 243 | bool HasPointerMap() const { return pointer_map_.is_set(); } |
| 244 | |
| 245 | void set_hydrogen_value(HValue* value) { hydrogen_value_ = value; } |
| 246 | HValue* hydrogen_value() const { return hydrogen_value_; } |
| 247 | |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame^] | 248 | virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 249 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 250 | void MarkAsCall() { is_call_ = true; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 251 | |
| 252 | // Interface to the register allocator and iterators. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 253 | bool IsMarkedAsCall() const { return is_call_; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 254 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 255 | virtual bool HasResult() const = 0; |
| 256 | virtual LOperand* result() = 0; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 257 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 258 | virtual int InputCount() = 0; |
| 259 | virtual LOperand* InputAt(int i) = 0; |
| 260 | virtual int TempCount() = 0; |
| 261 | virtual LOperand* TempAt(int i) = 0; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 262 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 263 | LOperand* FirstInput() { return InputAt(0); } |
| 264 | LOperand* Output() { return HasResult() ? result() : NULL; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 265 | |
| 266 | #ifdef DEBUG |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 267 | void VerifyCall(); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 268 | #endif |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 269 | |
| 270 | private: |
| 271 | LEnvironment* environment_; |
| 272 | SetOncePointer<LPointerMap> pointer_map_; |
| 273 | HValue* hydrogen_value_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 274 | bool is_call_; |
| 275 | bool is_save_doubles_; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 276 | }; |
| 277 | |
| 278 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 279 | // R = number of result operands (0 or 1). |
| 280 | // I = number of input operands. |
| 281 | // T = number of temporary operands. |
| 282 | template<int R, int I, int T> |
| 283 | class LTemplateInstruction: public LInstruction { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 284 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 285 | // Allow 0 or 1 output operands. |
| 286 | STATIC_ASSERT(R == 0 || R == 1); |
| 287 | virtual bool HasResult() const { return R != 0; } |
| 288 | void set_result(LOperand* operand) { results_[0] = operand; } |
| 289 | LOperand* result() { return results_[0]; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 290 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 291 | int InputCount() { return I; } |
| 292 | LOperand* InputAt(int i) { return inputs_[i]; } |
| 293 | |
| 294 | int TempCount() { return T; } |
| 295 | LOperand* TempAt(int i) { return temps_[i]; } |
| 296 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 297 | protected: |
| 298 | EmbeddedContainer<LOperand*, R> results_; |
| 299 | EmbeddedContainer<LOperand*, I> inputs_; |
| 300 | EmbeddedContainer<LOperand*, T> temps_; |
| 301 | }; |
| 302 | |
| 303 | |
| 304 | class LGap: public LTemplateInstruction<0, 0, 0> { |
| 305 | public: |
| 306 | explicit LGap(HBasicBlock* block) |
| 307 | : block_(block) { |
| 308 | parallel_moves_[BEFORE] = NULL; |
| 309 | parallel_moves_[START] = NULL; |
| 310 | parallel_moves_[END] = NULL; |
| 311 | parallel_moves_[AFTER] = NULL; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 312 | } |
| 313 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 314 | // Can't use the DECLARE-macro here because of sub-classes. |
| 315 | virtual bool IsGap() const { return true; } |
| 316 | virtual void PrintDataTo(StringStream* stream); |
| 317 | static LGap* cast(LInstruction* instr) { |
| 318 | ASSERT(instr->IsGap()); |
| 319 | return reinterpret_cast<LGap*>(instr); |
| 320 | } |
| 321 | |
| 322 | bool IsRedundant() const; |
| 323 | |
| 324 | HBasicBlock* block() const { return block_; } |
| 325 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 326 | enum InnerPosition { |
| 327 | BEFORE, |
| 328 | START, |
| 329 | END, |
| 330 | AFTER, |
| 331 | FIRST_INNER_POSITION = BEFORE, |
| 332 | LAST_INNER_POSITION = AFTER |
| 333 | }; |
| 334 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 335 | LParallelMove* GetOrCreateParallelMove(InnerPosition pos) { |
| 336 | if (parallel_moves_[pos] == NULL) parallel_moves_[pos] = new LParallelMove; |
| 337 | return parallel_moves_[pos]; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 338 | } |
| 339 | |
| 340 | LParallelMove* GetParallelMove(InnerPosition pos) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 341 | return parallel_moves_[pos]; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 342 | } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 343 | |
| 344 | private: |
| 345 | LParallelMove* parallel_moves_[LAST_INNER_POSITION + 1]; |
| 346 | HBasicBlock* block_; |
| 347 | }; |
| 348 | |
| 349 | |
| 350 | class LInstructionGap: public LGap { |
| 351 | public: |
| 352 | explicit LInstructionGap(HBasicBlock* block) : LGap(block) { } |
| 353 | |
| 354 | DECLARE_CONCRETE_INSTRUCTION(InstructionGap, "gap") |
| 355 | }; |
| 356 | |
| 357 | |
| 358 | class LGoto: public LTemplateInstruction<0, 0, 0> { |
| 359 | public: |
| 360 | explicit LGoto(int block_id) : block_id_(block_id) { } |
| 361 | |
| 362 | DECLARE_CONCRETE_INSTRUCTION(Goto, "goto") |
| 363 | virtual void PrintDataTo(StringStream* stream); |
| 364 | virtual bool IsControl() const { return true; } |
| 365 | |
| 366 | int block_id() const { return block_id_; } |
| 367 | |
| 368 | private: |
| 369 | int block_id_; |
| 370 | }; |
| 371 | |
| 372 | |
| 373 | class LLazyBailout: public LTemplateInstruction<0, 0, 0> { |
| 374 | public: |
| 375 | LLazyBailout() : gap_instructions_size_(0) { } |
| 376 | |
| 377 | DECLARE_CONCRETE_INSTRUCTION(LazyBailout, "lazy-bailout") |
| 378 | |
| 379 | void set_gap_instructions_size(int gap_instructions_size) { |
| 380 | gap_instructions_size_ = gap_instructions_size; |
| 381 | } |
| 382 | int gap_instructions_size() { return gap_instructions_size_; } |
| 383 | |
| 384 | private: |
| 385 | int gap_instructions_size_; |
| 386 | }; |
| 387 | |
| 388 | |
| 389 | class LDeoptimize: public LTemplateInstruction<0, 0, 0> { |
| 390 | public: |
| 391 | DECLARE_CONCRETE_INSTRUCTION(Deoptimize, "deoptimize") |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 392 | }; |
| 393 | |
| 394 | |
| 395 | class LLabel: public LGap { |
| 396 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 397 | explicit LLabel(HBasicBlock* block) |
| 398 | : LGap(block), replacement_(NULL) { } |
| 399 | |
| 400 | DECLARE_CONCRETE_INSTRUCTION(Label, "label") |
| 401 | |
| 402 | virtual void PrintDataTo(StringStream* stream); |
| 403 | |
| 404 | int block_id() const { return block()->block_id(); } |
| 405 | bool is_loop_header() const { return block()->IsLoopHeader(); } |
| 406 | Label* label() { return &label_; } |
| 407 | LLabel* replacement() const { return replacement_; } |
| 408 | void set_replacement(LLabel* label) { replacement_ = label; } |
| 409 | bool HasReplacement() const { return replacement_ != NULL; } |
| 410 | |
| 411 | private: |
| 412 | Label label_; |
| 413 | LLabel* replacement_; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 414 | }; |
| 415 | |
| 416 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 417 | class LParameter: public LTemplateInstruction<1, 0, 0> { |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 418 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 419 | DECLARE_CONCRETE_INSTRUCTION(Parameter, "parameter") |
| 420 | }; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 421 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 422 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 423 | class LCallStub: public LTemplateInstruction<1, 0, 0> { |
| 424 | public: |
| 425 | DECLARE_CONCRETE_INSTRUCTION(CallStub, "call-stub") |
| 426 | DECLARE_HYDROGEN_ACCESSOR(CallStub) |
| 427 | |
| 428 | TranscendentalCache::Type transcendental_type() { |
| 429 | return hydrogen()->transcendental_type(); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 430 | } |
| 431 | }; |
| 432 | |
| 433 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 434 | class LUnknownOSRValue: public LTemplateInstruction<1, 0, 0> { |
| 435 | public: |
| 436 | DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue, "unknown-osr-value") |
| 437 | }; |
| 438 | |
| 439 | |
| 440 | template<int I, int T> |
| 441 | class LControlInstruction: public LTemplateInstruction<0, I, T> { |
| 442 | public: |
| 443 | virtual bool IsControl() const { return true; } |
| 444 | |
| 445 | int SuccessorCount() { return hydrogen()->SuccessorCount(); } |
| 446 | HBasicBlock* SuccessorAt(int i) { return hydrogen()->SuccessorAt(i); } |
| 447 | int true_block_id() { return hydrogen()->SuccessorAt(0)->block_id(); } |
| 448 | int false_block_id() { return hydrogen()->SuccessorAt(1)->block_id(); } |
| 449 | |
| 450 | private: |
| 451 | HControlInstruction* hydrogen() { |
| 452 | return HControlInstruction::cast(this->hydrogen_value()); |
| 453 | } |
| 454 | }; |
| 455 | |
| 456 | |
rossberg@chromium.org | 2c067b1 | 2012-03-19 11:01:52 +0000 | [diff] [blame] | 457 | class LWrapReceiver: public LTemplateInstruction<1, 2, 0> { |
| 458 | public: |
| 459 | LWrapReceiver(LOperand* receiver, LOperand* function) { |
| 460 | inputs_[0] = receiver; |
| 461 | inputs_[1] = function; |
| 462 | } |
| 463 | |
| 464 | DECLARE_CONCRETE_INSTRUCTION(WrapReceiver, "wrap-receiver") |
| 465 | |
| 466 | LOperand* receiver() { return inputs_[0]; } |
| 467 | LOperand* function() { return inputs_[1]; } |
| 468 | }; |
| 469 | |
| 470 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 471 | class LApplyArguments: public LTemplateInstruction<1, 4, 0> { |
| 472 | public: |
| 473 | LApplyArguments(LOperand* function, |
| 474 | LOperand* receiver, |
| 475 | LOperand* length, |
| 476 | LOperand* elements) { |
| 477 | inputs_[0] = function; |
| 478 | inputs_[1] = receiver; |
| 479 | inputs_[2] = length; |
| 480 | inputs_[3] = elements; |
| 481 | } |
| 482 | |
| 483 | DECLARE_CONCRETE_INSTRUCTION(ApplyArguments, "apply-arguments") |
| 484 | |
| 485 | LOperand* function() { return inputs_[0]; } |
| 486 | LOperand* receiver() { return inputs_[1]; } |
| 487 | LOperand* length() { return inputs_[2]; } |
| 488 | LOperand* elements() { return inputs_[3]; } |
| 489 | }; |
| 490 | |
| 491 | |
| 492 | class LAccessArgumentsAt: public LTemplateInstruction<1, 3, 0> { |
| 493 | public: |
| 494 | LAccessArgumentsAt(LOperand* arguments, LOperand* length, LOperand* index) { |
| 495 | inputs_[0] = arguments; |
| 496 | inputs_[1] = length; |
| 497 | inputs_[2] = index; |
| 498 | } |
| 499 | |
| 500 | DECLARE_CONCRETE_INSTRUCTION(AccessArgumentsAt, "access-arguments-at") |
| 501 | |
| 502 | LOperand* arguments() { return inputs_[0]; } |
| 503 | LOperand* length() { return inputs_[1]; } |
| 504 | LOperand* index() { return inputs_[2]; } |
| 505 | |
| 506 | virtual void PrintDataTo(StringStream* stream); |
| 507 | }; |
| 508 | |
| 509 | |
| 510 | class LArgumentsLength: public LTemplateInstruction<1, 1, 0> { |
| 511 | public: |
| 512 | explicit LArgumentsLength(LOperand* elements) { |
| 513 | inputs_[0] = elements; |
| 514 | } |
| 515 | |
| 516 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength, "arguments-length") |
| 517 | }; |
| 518 | |
| 519 | |
| 520 | class LArgumentsElements: public LTemplateInstruction<1, 0, 0> { |
| 521 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 522 | DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements, "arguments-elements") |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 523 | DECLARE_HYDROGEN_ACCESSOR(ArgumentsElements) |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 524 | }; |
| 525 | |
| 526 | |
| 527 | class LModI: public LTemplateInstruction<1, 2, 3> { |
| 528 | public: |
| 529 | // Used when the right hand is a constant power of 2. |
| 530 | LModI(LOperand* left, |
| 531 | LOperand* right) { |
| 532 | inputs_[0] = left; |
| 533 | inputs_[1] = right; |
| 534 | temps_[0] = NULL; |
| 535 | temps_[1] = NULL; |
| 536 | temps_[2] = NULL; |
| 537 | } |
| 538 | |
| 539 | // Used for the standard case. |
| 540 | LModI(LOperand* left, |
| 541 | LOperand* right, |
| 542 | LOperand* temp1, |
| 543 | LOperand* temp2, |
| 544 | LOperand* temp3) { |
| 545 | inputs_[0] = left; |
| 546 | inputs_[1] = right; |
| 547 | temps_[0] = temp1; |
| 548 | temps_[1] = temp2; |
| 549 | temps_[2] = temp3; |
| 550 | } |
| 551 | |
| 552 | DECLARE_CONCRETE_INSTRUCTION(ModI, "mod-i") |
| 553 | DECLARE_HYDROGEN_ACCESSOR(Mod) |
| 554 | }; |
| 555 | |
| 556 | |
| 557 | class LDivI: public LTemplateInstruction<1, 2, 0> { |
| 558 | public: |
| 559 | LDivI(LOperand* left, LOperand* right) { |
| 560 | inputs_[0] = left; |
| 561 | inputs_[1] = right; |
| 562 | } |
| 563 | |
| 564 | DECLARE_CONCRETE_INSTRUCTION(DivI, "div-i") |
| 565 | DECLARE_HYDROGEN_ACCESSOR(Div) |
| 566 | }; |
| 567 | |
| 568 | |
| 569 | class LMulI: public LTemplateInstruction<1, 2, 1> { |
| 570 | public: |
| 571 | LMulI(LOperand* left, LOperand* right, LOperand* temp) { |
| 572 | inputs_[0] = left; |
| 573 | inputs_[1] = right; |
| 574 | temps_[0] = temp; |
| 575 | } |
| 576 | |
| 577 | DECLARE_CONCRETE_INSTRUCTION(MulI, "mul-i") |
| 578 | DECLARE_HYDROGEN_ACCESSOR(Mul) |
| 579 | }; |
| 580 | |
| 581 | |
| 582 | class LCmpIDAndBranch: public LControlInstruction<2, 0> { |
| 583 | public: |
| 584 | LCmpIDAndBranch(LOperand* left, LOperand* right) { |
| 585 | inputs_[0] = left; |
| 586 | inputs_[1] = right; |
| 587 | } |
| 588 | |
| 589 | DECLARE_CONCRETE_INSTRUCTION(CmpIDAndBranch, "cmp-id-and-branch") |
| 590 | DECLARE_HYDROGEN_ACCESSOR(CompareIDAndBranch) |
| 591 | |
| 592 | Token::Value op() const { return hydrogen()->token(); } |
| 593 | bool is_double() const { |
| 594 | return hydrogen()->GetInputRepresentation().IsDouble(); |
| 595 | } |
| 596 | |
| 597 | virtual void PrintDataTo(StringStream* stream); |
| 598 | }; |
| 599 | |
| 600 | |
| 601 | class LUnaryMathOperation: public LTemplateInstruction<1, 1, 1> { |
| 602 | public: |
| 603 | LUnaryMathOperation(LOperand* value, LOperand* temp) { |
| 604 | inputs_[0] = value; |
| 605 | temps_[0] = temp; |
| 606 | } |
| 607 | |
| 608 | DECLARE_CONCRETE_INSTRUCTION(UnaryMathOperation, "unary-math-operation") |
| 609 | DECLARE_HYDROGEN_ACCESSOR(UnaryMathOperation) |
| 610 | |
| 611 | virtual void PrintDataTo(StringStream* stream); |
| 612 | BuiltinFunctionId op() const { return hydrogen()->op(); } |
| 613 | }; |
| 614 | |
| 615 | |
| 616 | class LCmpObjectEqAndBranch: public LControlInstruction<2, 0> { |
| 617 | public: |
| 618 | LCmpObjectEqAndBranch(LOperand* left, LOperand* right) { |
| 619 | inputs_[0] = left; |
| 620 | inputs_[1] = right; |
| 621 | } |
| 622 | |
| 623 | DECLARE_CONCRETE_INSTRUCTION(CmpObjectEqAndBranch, |
| 624 | "cmp-object-eq-and-branch") |
| 625 | DECLARE_HYDROGEN_ACCESSOR(CompareObjectEqAndBranch) |
| 626 | }; |
| 627 | |
| 628 | |
| 629 | class LCmpConstantEqAndBranch: public LControlInstruction<1, 0> { |
| 630 | public: |
| 631 | explicit LCmpConstantEqAndBranch(LOperand* left) { |
| 632 | inputs_[0] = left; |
| 633 | } |
| 634 | |
| 635 | DECLARE_CONCRETE_INSTRUCTION(CmpConstantEqAndBranch, |
| 636 | "cmp-constant-eq-and-branch") |
| 637 | DECLARE_HYDROGEN_ACCESSOR(CompareConstantEqAndBranch) |
| 638 | }; |
| 639 | |
| 640 | |
| 641 | class LIsNilAndBranch: public LControlInstruction<1, 0> { |
| 642 | public: |
| 643 | explicit LIsNilAndBranch(LOperand* value) { |
| 644 | inputs_[0] = value; |
| 645 | } |
| 646 | |
| 647 | DECLARE_CONCRETE_INSTRUCTION(IsNilAndBranch, "is-nil-and-branch") |
| 648 | DECLARE_HYDROGEN_ACCESSOR(IsNilAndBranch) |
| 649 | |
| 650 | EqualityKind kind() const { return hydrogen()->kind(); } |
| 651 | NilValue nil() const { return hydrogen()->nil(); } |
| 652 | |
| 653 | virtual void PrintDataTo(StringStream* stream); |
| 654 | }; |
| 655 | |
| 656 | |
| 657 | class LIsObjectAndBranch: public LControlInstruction<1, 1> { |
| 658 | public: |
| 659 | LIsObjectAndBranch(LOperand* value, LOperand* temp) { |
| 660 | inputs_[0] = value; |
| 661 | temps_[0] = temp; |
| 662 | } |
| 663 | |
| 664 | DECLARE_CONCRETE_INSTRUCTION(IsObjectAndBranch, "is-object-and-branch") |
| 665 | DECLARE_HYDROGEN_ACCESSOR(IsObjectAndBranch) |
| 666 | |
| 667 | virtual void PrintDataTo(StringStream* stream); |
| 668 | }; |
| 669 | |
| 670 | |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 671 | class LIsStringAndBranch: public LControlInstruction<1, 1> { |
| 672 | public: |
| 673 | LIsStringAndBranch(LOperand* value, LOperand* temp) { |
| 674 | inputs_[0] = value; |
| 675 | temps_[0] = temp; |
| 676 | } |
| 677 | |
| 678 | DECLARE_CONCRETE_INSTRUCTION(IsStringAndBranch, "is-string-and-branch") |
| 679 | DECLARE_HYDROGEN_ACCESSOR(IsStringAndBranch) |
| 680 | |
| 681 | virtual void PrintDataTo(StringStream* stream); |
| 682 | }; |
| 683 | |
| 684 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 685 | class LIsSmiAndBranch: public LControlInstruction<1, 0> { |
| 686 | public: |
| 687 | explicit LIsSmiAndBranch(LOperand* value) { |
| 688 | inputs_[0] = value; |
| 689 | } |
| 690 | |
| 691 | DECLARE_CONCRETE_INSTRUCTION(IsSmiAndBranch, "is-smi-and-branch") |
| 692 | DECLARE_HYDROGEN_ACCESSOR(IsSmiAndBranch) |
| 693 | |
| 694 | virtual void PrintDataTo(StringStream* stream); |
| 695 | }; |
| 696 | |
| 697 | |
| 698 | class LIsUndetectableAndBranch: public LControlInstruction<1, 1> { |
| 699 | public: |
| 700 | explicit LIsUndetectableAndBranch(LOperand* value, LOperand* temp) { |
| 701 | inputs_[0] = value; |
| 702 | temps_[0] = temp; |
| 703 | } |
| 704 | |
| 705 | DECLARE_CONCRETE_INSTRUCTION(IsUndetectableAndBranch, |
| 706 | "is-undetectable-and-branch") |
| 707 | DECLARE_HYDROGEN_ACCESSOR(IsUndetectableAndBranch) |
| 708 | |
| 709 | virtual void PrintDataTo(StringStream* stream); |
| 710 | }; |
| 711 | |
| 712 | |
mstarzinger@chromium.org | f8c6bd5 | 2011-11-23 12:13:52 +0000 | [diff] [blame] | 713 | class LStringCompareAndBranch: public LControlInstruction<2, 0> { |
| 714 | public: |
| 715 | LStringCompareAndBranch(LOperand* left, LOperand* right) { |
| 716 | inputs_[0] = left; |
| 717 | inputs_[1] = right; |
| 718 | } |
| 719 | |
| 720 | DECLARE_CONCRETE_INSTRUCTION(StringCompareAndBranch, |
| 721 | "string-compare-and-branch") |
| 722 | DECLARE_HYDROGEN_ACCESSOR(StringCompareAndBranch) |
| 723 | |
| 724 | Token::Value op() const { return hydrogen()->token(); } |
| 725 | |
| 726 | virtual void PrintDataTo(StringStream* stream); |
| 727 | }; |
| 728 | |
| 729 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 730 | class LHasInstanceTypeAndBranch: public LControlInstruction<1, 0> { |
| 731 | public: |
| 732 | explicit LHasInstanceTypeAndBranch(LOperand* value) { |
| 733 | inputs_[0] = value; |
| 734 | } |
| 735 | |
| 736 | DECLARE_CONCRETE_INSTRUCTION(HasInstanceTypeAndBranch, |
| 737 | "has-instance-type-and-branch") |
| 738 | DECLARE_HYDROGEN_ACCESSOR(HasInstanceTypeAndBranch) |
| 739 | |
| 740 | virtual void PrintDataTo(StringStream* stream); |
| 741 | }; |
| 742 | |
| 743 | |
| 744 | class LGetCachedArrayIndex: public LTemplateInstruction<1, 1, 0> { |
| 745 | public: |
| 746 | explicit LGetCachedArrayIndex(LOperand* value) { |
| 747 | inputs_[0] = value; |
| 748 | } |
| 749 | |
| 750 | DECLARE_CONCRETE_INSTRUCTION(GetCachedArrayIndex, "get-cached-array-index") |
| 751 | DECLARE_HYDROGEN_ACCESSOR(GetCachedArrayIndex) |
| 752 | }; |
| 753 | |
| 754 | |
| 755 | class LHasCachedArrayIndexAndBranch: public LControlInstruction<1, 0> { |
| 756 | public: |
| 757 | explicit LHasCachedArrayIndexAndBranch(LOperand* value) { |
| 758 | inputs_[0] = value; |
| 759 | } |
| 760 | |
| 761 | DECLARE_CONCRETE_INSTRUCTION(HasCachedArrayIndexAndBranch, |
| 762 | "has-cached-array-index-and-branch") |
| 763 | DECLARE_HYDROGEN_ACCESSOR(HasCachedArrayIndexAndBranch) |
| 764 | |
| 765 | virtual void PrintDataTo(StringStream* stream); |
| 766 | }; |
| 767 | |
| 768 | |
| 769 | class LClassOfTestAndBranch: public LControlInstruction<1, 1> { |
| 770 | public: |
| 771 | LClassOfTestAndBranch(LOperand* value, LOperand* temp) { |
| 772 | inputs_[0] = value; |
| 773 | temps_[0] = temp; |
| 774 | } |
| 775 | |
| 776 | DECLARE_CONCRETE_INSTRUCTION(ClassOfTestAndBranch, |
| 777 | "class-of-test-and-branch") |
| 778 | DECLARE_HYDROGEN_ACCESSOR(ClassOfTestAndBranch) |
| 779 | |
| 780 | virtual void PrintDataTo(StringStream* stream); |
| 781 | }; |
| 782 | |
| 783 | |
| 784 | class LCmpT: public LTemplateInstruction<1, 2, 0> { |
| 785 | public: |
| 786 | LCmpT(LOperand* left, LOperand* right) { |
| 787 | inputs_[0] = left; |
| 788 | inputs_[1] = right; |
| 789 | } |
| 790 | |
| 791 | DECLARE_CONCRETE_INSTRUCTION(CmpT, "cmp-t") |
| 792 | DECLARE_HYDROGEN_ACCESSOR(CompareGeneric) |
| 793 | |
| 794 | Token::Value op() const { return hydrogen()->token(); } |
| 795 | }; |
| 796 | |
| 797 | |
| 798 | class LInstanceOf: public LTemplateInstruction<1, 2, 0> { |
| 799 | public: |
| 800 | LInstanceOf(LOperand* left, LOperand* right) { |
| 801 | inputs_[0] = left; |
| 802 | inputs_[1] = right; |
| 803 | } |
| 804 | |
| 805 | DECLARE_CONCRETE_INSTRUCTION(InstanceOf, "instance-of") |
| 806 | }; |
| 807 | |
| 808 | |
| 809 | class LInstanceOfKnownGlobal: public LTemplateInstruction<1, 1, 1> { |
| 810 | public: |
| 811 | LInstanceOfKnownGlobal(LOperand* value, LOperand* temp) { |
| 812 | inputs_[0] = value; |
| 813 | temps_[0] = temp; |
| 814 | } |
| 815 | |
| 816 | DECLARE_CONCRETE_INSTRUCTION(InstanceOfKnownGlobal, |
| 817 | "instance-of-known-global") |
| 818 | DECLARE_HYDROGEN_ACCESSOR(InstanceOfKnownGlobal) |
| 819 | |
| 820 | Handle<JSFunction> function() const { return hydrogen()->function(); } |
danno@chromium.org | 1044a4d | 2012-04-30 12:34:39 +0000 | [diff] [blame^] | 821 | LEnvironment* GetDeferredLazyDeoptimizationEnvironment() { |
| 822 | return lazy_deopt_env_; |
| 823 | } |
| 824 | virtual void SetDeferredLazyDeoptimizationEnvironment(LEnvironment* env) { |
| 825 | lazy_deopt_env_ = env; |
| 826 | } |
| 827 | |
| 828 | private: |
| 829 | LEnvironment* lazy_deopt_env_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 830 | }; |
| 831 | |
| 832 | |
| 833 | class LBoundsCheck: public LTemplateInstruction<0, 2, 0> { |
| 834 | public: |
| 835 | LBoundsCheck(LOperand* index, LOperand* length) { |
| 836 | inputs_[0] = index; |
| 837 | inputs_[1] = length; |
| 838 | } |
| 839 | |
| 840 | LOperand* index() { return inputs_[0]; } |
| 841 | LOperand* length() { return inputs_[1]; } |
| 842 | |
| 843 | DECLARE_CONCRETE_INSTRUCTION(BoundsCheck, "bounds-check") |
| 844 | }; |
| 845 | |
| 846 | |
| 847 | class LBitI: public LTemplateInstruction<1, 2, 0> { |
| 848 | public: |
| 849 | LBitI(LOperand* left, LOperand* right) { |
| 850 | inputs_[0] = left; |
| 851 | inputs_[1] = right; |
| 852 | } |
| 853 | |
| 854 | Token::Value op() const { return hydrogen()->op(); } |
| 855 | |
| 856 | DECLARE_CONCRETE_INSTRUCTION(BitI, "bit-i") |
| 857 | DECLARE_HYDROGEN_ACCESSOR(Bitwise) |
| 858 | }; |
| 859 | |
| 860 | |
| 861 | class LShiftI: public LTemplateInstruction<1, 2, 0> { |
| 862 | public: |
| 863 | LShiftI(Token::Value op, LOperand* left, LOperand* right, bool can_deopt) |
| 864 | : op_(op), can_deopt_(can_deopt) { |
| 865 | inputs_[0] = left; |
| 866 | inputs_[1] = right; |
| 867 | } |
| 868 | |
| 869 | Token::Value op() const { return op_; } |
| 870 | |
| 871 | bool can_deopt() const { return can_deopt_; } |
| 872 | |
| 873 | DECLARE_CONCRETE_INSTRUCTION(ShiftI, "shift-i") |
| 874 | |
| 875 | private: |
| 876 | Token::Value op_; |
| 877 | bool can_deopt_; |
| 878 | }; |
| 879 | |
| 880 | |
| 881 | class LSubI: public LTemplateInstruction<1, 2, 0> { |
| 882 | public: |
| 883 | LSubI(LOperand* left, LOperand* right) { |
| 884 | inputs_[0] = left; |
| 885 | inputs_[1] = right; |
| 886 | } |
| 887 | |
| 888 | DECLARE_CONCRETE_INSTRUCTION(SubI, "sub-i") |
| 889 | DECLARE_HYDROGEN_ACCESSOR(Sub) |
| 890 | }; |
| 891 | |
| 892 | |
| 893 | class LConstantI: public LTemplateInstruction<1, 0, 0> { |
| 894 | public: |
| 895 | DECLARE_CONCRETE_INSTRUCTION(ConstantI, "constant-i") |
| 896 | DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 897 | |
| 898 | int32_t value() const { return hydrogen()->Integer32Value(); } |
| 899 | }; |
| 900 | |
| 901 | |
| 902 | class LConstantD: public LTemplateInstruction<1, 0, 0> { |
| 903 | public: |
| 904 | DECLARE_CONCRETE_INSTRUCTION(ConstantD, "constant-d") |
| 905 | DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 906 | |
| 907 | double value() const { return hydrogen()->DoubleValue(); } |
| 908 | }; |
| 909 | |
| 910 | |
| 911 | class LConstantT: public LTemplateInstruction<1, 0, 0> { |
| 912 | public: |
| 913 | DECLARE_CONCRETE_INSTRUCTION(ConstantT, "constant-t") |
| 914 | DECLARE_HYDROGEN_ACCESSOR(Constant) |
| 915 | |
| 916 | Handle<Object> value() const { return hydrogen()->handle(); } |
| 917 | }; |
| 918 | |
| 919 | |
| 920 | class LBranch: public LControlInstruction<1, 0> { |
| 921 | public: |
| 922 | explicit LBranch(LOperand* value) { |
| 923 | inputs_[0] = value; |
| 924 | } |
| 925 | |
| 926 | DECLARE_CONCRETE_INSTRUCTION(Branch, "branch") |
| 927 | DECLARE_HYDROGEN_ACCESSOR(Branch) |
| 928 | |
| 929 | virtual void PrintDataTo(StringStream* stream); |
| 930 | }; |
| 931 | |
| 932 | |
| 933 | class LCmpMapAndBranch: public LTemplateInstruction<0, 1, 1> { |
| 934 | public: |
| 935 | LCmpMapAndBranch(LOperand* value, LOperand* temp) { |
| 936 | inputs_[0] = value; |
| 937 | temps_[0] = temp; |
| 938 | } |
| 939 | |
| 940 | DECLARE_CONCRETE_INSTRUCTION(CmpMapAndBranch, "cmp-map-and-branch") |
| 941 | DECLARE_HYDROGEN_ACCESSOR(CompareMap) |
| 942 | |
| 943 | virtual bool IsControl() const { return true; } |
| 944 | |
| 945 | Handle<Map> map() const { return hydrogen()->map(); } |
| 946 | int true_block_id() const { |
| 947 | return hydrogen()->FirstSuccessor()->block_id(); |
| 948 | } |
| 949 | int false_block_id() const { |
| 950 | return hydrogen()->SecondSuccessor()->block_id(); |
| 951 | } |
| 952 | }; |
| 953 | |
| 954 | |
| 955 | class LJSArrayLength: public LTemplateInstruction<1, 1, 0> { |
| 956 | public: |
| 957 | explicit LJSArrayLength(LOperand* value) { |
| 958 | inputs_[0] = value; |
| 959 | } |
| 960 | |
| 961 | DECLARE_CONCRETE_INSTRUCTION(JSArrayLength, "js-array-length") |
| 962 | DECLARE_HYDROGEN_ACCESSOR(JSArrayLength) |
| 963 | }; |
| 964 | |
| 965 | |
| 966 | class LFixedArrayBaseLength: public LTemplateInstruction<1, 1, 0> { |
| 967 | public: |
| 968 | explicit LFixedArrayBaseLength(LOperand* value) { |
| 969 | inputs_[0] = value; |
| 970 | } |
| 971 | |
| 972 | DECLARE_CONCRETE_INSTRUCTION(FixedArrayBaseLength, |
| 973 | "fixed-array-base-length") |
| 974 | DECLARE_HYDROGEN_ACCESSOR(FixedArrayBaseLength) |
| 975 | }; |
| 976 | |
| 977 | |
| 978 | class LElementsKind: public LTemplateInstruction<1, 1, 0> { |
| 979 | public: |
| 980 | explicit LElementsKind(LOperand* value) { |
| 981 | inputs_[0] = value; |
| 982 | } |
| 983 | |
| 984 | DECLARE_CONCRETE_INSTRUCTION(ElementsKind, "elements-kind") |
| 985 | DECLARE_HYDROGEN_ACCESSOR(ElementsKind) |
| 986 | }; |
| 987 | |
| 988 | |
| 989 | class LValueOf: public LTemplateInstruction<1, 1, 1> { |
| 990 | public: |
| 991 | LValueOf(LOperand* value, LOperand* temp) { |
| 992 | inputs_[0] = value; |
| 993 | temps_[0] = temp; |
| 994 | } |
| 995 | |
| 996 | DECLARE_CONCRETE_INSTRUCTION(ValueOf, "value-of") |
| 997 | DECLARE_HYDROGEN_ACCESSOR(ValueOf) |
| 998 | }; |
| 999 | |
| 1000 | |
yangguo@chromium.org | 154ff99 | 2012-03-13 08:09:54 +0000 | [diff] [blame] | 1001 | class LDateField: public LTemplateInstruction<1, 1, 1> { |
| 1002 | public: |
| 1003 | LDateField(LOperand* date, LOperand* temp, Smi* index) : index_(index) { |
| 1004 | inputs_[0] = date; |
| 1005 | temps_[0] = temp; |
| 1006 | } |
| 1007 | |
| 1008 | DECLARE_CONCRETE_INSTRUCTION(ValueOf, "date-field") |
| 1009 | DECLARE_HYDROGEN_ACCESSOR(ValueOf) |
| 1010 | Smi* index() const { return index_; } |
| 1011 | |
| 1012 | private: |
| 1013 | Smi* index_; |
| 1014 | }; |
| 1015 | |
| 1016 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1017 | class LThrow: public LTemplateInstruction<0, 1, 0> { |
| 1018 | public: |
| 1019 | explicit LThrow(LOperand* value) { |
| 1020 | inputs_[0] = value; |
| 1021 | } |
| 1022 | |
| 1023 | DECLARE_CONCRETE_INSTRUCTION(Throw, "throw") |
| 1024 | }; |
| 1025 | |
| 1026 | |
| 1027 | class LBitNotI: public LTemplateInstruction<1, 1, 0> { |
| 1028 | public: |
| 1029 | explicit LBitNotI(LOperand* value) { |
| 1030 | inputs_[0] = value; |
| 1031 | } |
| 1032 | |
| 1033 | DECLARE_CONCRETE_INSTRUCTION(BitNotI, "bit-not-i") |
| 1034 | }; |
| 1035 | |
| 1036 | |
| 1037 | class LAddI: public LTemplateInstruction<1, 2, 0> { |
| 1038 | public: |
| 1039 | LAddI(LOperand* left, LOperand* right) { |
| 1040 | inputs_[0] = left; |
| 1041 | inputs_[1] = right; |
| 1042 | } |
| 1043 | |
| 1044 | DECLARE_CONCRETE_INSTRUCTION(AddI, "add-i") |
| 1045 | DECLARE_HYDROGEN_ACCESSOR(Add) |
| 1046 | }; |
| 1047 | |
| 1048 | |
| 1049 | class LPower: public LTemplateInstruction<1, 2, 0> { |
| 1050 | public: |
| 1051 | LPower(LOperand* left, LOperand* right) { |
| 1052 | inputs_[0] = left; |
| 1053 | inputs_[1] = right; |
| 1054 | } |
| 1055 | |
| 1056 | DECLARE_CONCRETE_INSTRUCTION(Power, "power") |
| 1057 | DECLARE_HYDROGEN_ACCESSOR(Power) |
| 1058 | }; |
| 1059 | |
| 1060 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1061 | class LRandom: public LTemplateInstruction<1, 1, 0> { |
| 1062 | public: |
| 1063 | explicit LRandom(LOperand* global_object) { |
| 1064 | inputs_[0] = global_object; |
| 1065 | } |
| 1066 | |
| 1067 | DECLARE_CONCRETE_INSTRUCTION(Random, "random") |
| 1068 | DECLARE_HYDROGEN_ACCESSOR(Random) |
| 1069 | }; |
| 1070 | |
| 1071 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1072 | class LArithmeticD: public LTemplateInstruction<1, 2, 0> { |
| 1073 | public: |
| 1074 | LArithmeticD(Token::Value op, LOperand* left, LOperand* right) |
| 1075 | : op_(op) { |
| 1076 | inputs_[0] = left; |
| 1077 | inputs_[1] = right; |
| 1078 | } |
| 1079 | |
| 1080 | Token::Value op() const { return op_; } |
| 1081 | |
| 1082 | virtual Opcode opcode() const { return LInstruction::kArithmeticD; } |
| 1083 | virtual void CompileToNative(LCodeGen* generator); |
| 1084 | virtual const char* Mnemonic() const; |
| 1085 | |
| 1086 | private: |
| 1087 | Token::Value op_; |
| 1088 | }; |
| 1089 | |
| 1090 | |
| 1091 | class LArithmeticT: public LTemplateInstruction<1, 2, 0> { |
| 1092 | public: |
| 1093 | LArithmeticT(Token::Value op, LOperand* left, LOperand* right) |
| 1094 | : op_(op) { |
| 1095 | inputs_[0] = left; |
| 1096 | inputs_[1] = right; |
| 1097 | } |
| 1098 | |
| 1099 | virtual Opcode opcode() const { return LInstruction::kArithmeticT; } |
| 1100 | virtual void CompileToNative(LCodeGen* generator); |
| 1101 | virtual const char* Mnemonic() const; |
| 1102 | |
| 1103 | Token::Value op() const { return op_; } |
| 1104 | |
| 1105 | private: |
| 1106 | Token::Value op_; |
| 1107 | }; |
| 1108 | |
| 1109 | |
| 1110 | class LReturn: public LTemplateInstruction<0, 1, 0> { |
| 1111 | public: |
| 1112 | explicit LReturn(LOperand* value) { |
| 1113 | inputs_[0] = value; |
| 1114 | } |
| 1115 | |
| 1116 | DECLARE_CONCRETE_INSTRUCTION(Return, "return") |
| 1117 | }; |
| 1118 | |
| 1119 | |
| 1120 | class LLoadNamedField: public LTemplateInstruction<1, 1, 0> { |
| 1121 | public: |
| 1122 | explicit LLoadNamedField(LOperand* object) { |
| 1123 | inputs_[0] = object; |
| 1124 | } |
| 1125 | |
| 1126 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field") |
| 1127 | DECLARE_HYDROGEN_ACCESSOR(LoadNamedField) |
| 1128 | }; |
| 1129 | |
| 1130 | |
| 1131 | class LLoadNamedFieldPolymorphic: public LTemplateInstruction<1, 1, 0> { |
| 1132 | public: |
| 1133 | explicit LLoadNamedFieldPolymorphic(LOperand* object) { |
| 1134 | inputs_[0] = object; |
| 1135 | } |
| 1136 | |
| 1137 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedField, "load-named-field-polymorphic") |
| 1138 | DECLARE_HYDROGEN_ACCESSOR(LoadNamedFieldPolymorphic) |
| 1139 | |
| 1140 | LOperand* object() { return inputs_[0]; } |
| 1141 | }; |
| 1142 | |
| 1143 | |
| 1144 | class LLoadNamedGeneric: public LTemplateInstruction<1, 1, 0> { |
| 1145 | public: |
| 1146 | explicit LLoadNamedGeneric(LOperand* object) { |
| 1147 | inputs_[0] = object; |
| 1148 | } |
| 1149 | |
| 1150 | DECLARE_CONCRETE_INSTRUCTION(LoadNamedGeneric, "load-named-generic") |
| 1151 | DECLARE_HYDROGEN_ACCESSOR(LoadNamedGeneric) |
| 1152 | |
| 1153 | LOperand* object() { return inputs_[0]; } |
| 1154 | Handle<Object> name() const { return hydrogen()->name(); } |
| 1155 | }; |
| 1156 | |
| 1157 | |
| 1158 | class LLoadFunctionPrototype: public LTemplateInstruction<1, 1, 0> { |
| 1159 | public: |
| 1160 | explicit LLoadFunctionPrototype(LOperand* function) { |
| 1161 | inputs_[0] = function; |
| 1162 | } |
| 1163 | |
| 1164 | DECLARE_CONCRETE_INSTRUCTION(LoadFunctionPrototype, "load-function-prototype") |
| 1165 | DECLARE_HYDROGEN_ACCESSOR(LoadFunctionPrototype) |
| 1166 | |
| 1167 | LOperand* function() { return inputs_[0]; } |
| 1168 | }; |
| 1169 | |
| 1170 | |
| 1171 | class LLoadElements: public LTemplateInstruction<1, 1, 0> { |
| 1172 | public: |
| 1173 | explicit LLoadElements(LOperand* object) { |
| 1174 | inputs_[0] = object; |
| 1175 | } |
| 1176 | |
| 1177 | DECLARE_CONCRETE_INSTRUCTION(LoadElements, "load-elements") |
| 1178 | }; |
| 1179 | |
| 1180 | |
| 1181 | class LLoadExternalArrayPointer: public LTemplateInstruction<1, 1, 0> { |
| 1182 | public: |
| 1183 | explicit LLoadExternalArrayPointer(LOperand* object) { |
| 1184 | inputs_[0] = object; |
| 1185 | } |
| 1186 | |
| 1187 | DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer, |
| 1188 | "load-external-array-pointer") |
| 1189 | }; |
| 1190 | |
| 1191 | |
| 1192 | class LLoadKeyedFastElement: public LTemplateInstruction<1, 2, 0> { |
| 1193 | public: |
| 1194 | LLoadKeyedFastElement(LOperand* elements, LOperand* key) { |
| 1195 | inputs_[0] = elements; |
| 1196 | inputs_[1] = key; |
| 1197 | } |
| 1198 | |
| 1199 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastElement, "load-keyed-fast-element") |
| 1200 | DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastElement) |
| 1201 | |
| 1202 | LOperand* elements() { return inputs_[0]; } |
| 1203 | LOperand* key() { return inputs_[1]; } |
| 1204 | }; |
| 1205 | |
| 1206 | |
| 1207 | class LLoadKeyedFastDoubleElement: public LTemplateInstruction<1, 2, 0> { |
| 1208 | public: |
| 1209 | LLoadKeyedFastDoubleElement(LOperand* elements, LOperand* key) { |
| 1210 | inputs_[0] = elements; |
| 1211 | inputs_[1] = key; |
| 1212 | } |
| 1213 | |
| 1214 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedFastDoubleElement, |
| 1215 | "load-keyed-fast-double-element") |
| 1216 | DECLARE_HYDROGEN_ACCESSOR(LoadKeyedFastDoubleElement) |
| 1217 | |
| 1218 | LOperand* elements() { return inputs_[0]; } |
| 1219 | LOperand* key() { return inputs_[1]; } |
| 1220 | }; |
| 1221 | |
| 1222 | |
| 1223 | class LLoadKeyedSpecializedArrayElement: public LTemplateInstruction<1, 2, 0> { |
| 1224 | public: |
| 1225 | LLoadKeyedSpecializedArrayElement(LOperand* external_pointer, |
| 1226 | LOperand* key) { |
| 1227 | inputs_[0] = external_pointer; |
| 1228 | inputs_[1] = key; |
| 1229 | } |
| 1230 | |
| 1231 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedSpecializedArrayElement, |
| 1232 | "load-keyed-specialized-array-element") |
| 1233 | DECLARE_HYDROGEN_ACCESSOR(LoadKeyedSpecializedArrayElement) |
| 1234 | |
| 1235 | LOperand* external_pointer() { return inputs_[0]; } |
| 1236 | LOperand* key() { return inputs_[1]; } |
| 1237 | ElementsKind elements_kind() const { |
| 1238 | return hydrogen()->elements_kind(); |
| 1239 | } |
| 1240 | }; |
| 1241 | |
| 1242 | |
| 1243 | class LLoadKeyedGeneric: public LTemplateInstruction<1, 2, 0> { |
| 1244 | public: |
| 1245 | LLoadKeyedGeneric(LOperand* obj, LOperand* key) { |
| 1246 | inputs_[0] = obj; |
| 1247 | inputs_[1] = key; |
| 1248 | } |
| 1249 | |
| 1250 | DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric, "load-keyed-generic") |
| 1251 | |
| 1252 | LOperand* object() { return inputs_[0]; } |
| 1253 | LOperand* key() { return inputs_[1]; } |
| 1254 | }; |
| 1255 | |
| 1256 | |
| 1257 | class LLoadGlobalCell: public LTemplateInstruction<1, 0, 0> { |
| 1258 | public: |
| 1259 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalCell, "load-global-cell") |
| 1260 | DECLARE_HYDROGEN_ACCESSOR(LoadGlobalCell) |
| 1261 | }; |
| 1262 | |
| 1263 | |
| 1264 | class LLoadGlobalGeneric: public LTemplateInstruction<1, 1, 0> { |
| 1265 | public: |
| 1266 | explicit LLoadGlobalGeneric(LOperand* global_object) { |
| 1267 | inputs_[0] = global_object; |
| 1268 | } |
| 1269 | |
| 1270 | DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric, "load-global-generic") |
| 1271 | DECLARE_HYDROGEN_ACCESSOR(LoadGlobalGeneric) |
| 1272 | |
| 1273 | LOperand* global_object() { return inputs_[0]; } |
| 1274 | Handle<Object> name() const { return hydrogen()->name(); } |
| 1275 | bool for_typeof() const { return hydrogen()->for_typeof(); } |
| 1276 | }; |
| 1277 | |
| 1278 | |
| 1279 | class LStoreGlobalCell: public LTemplateInstruction<0, 1, 1> { |
| 1280 | public: |
| 1281 | LStoreGlobalCell(LOperand* value, LOperand* temp) { |
| 1282 | inputs_[0] = value; |
| 1283 | temps_[0] = temp; |
| 1284 | } |
| 1285 | |
| 1286 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell, "store-global-cell") |
| 1287 | DECLARE_HYDROGEN_ACCESSOR(StoreGlobalCell) |
danno@chromium.org | e78f9fc | 2011-12-21 08:29:34 +0000 | [diff] [blame] | 1288 | |
| 1289 | LOperand* value() { return inputs_[0]; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1290 | }; |
| 1291 | |
| 1292 | |
| 1293 | class LStoreGlobalGeneric: public LTemplateInstruction<0, 2, 0> { |
| 1294 | public: |
| 1295 | explicit LStoreGlobalGeneric(LOperand* global_object, |
| 1296 | LOperand* value) { |
| 1297 | inputs_[0] = global_object; |
| 1298 | inputs_[1] = value; |
| 1299 | } |
| 1300 | |
| 1301 | DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric, "store-global-generic") |
| 1302 | DECLARE_HYDROGEN_ACCESSOR(StoreGlobalGeneric) |
| 1303 | |
| 1304 | LOperand* global_object() { return InputAt(0); } |
| 1305 | Handle<Object> name() const { return hydrogen()->name(); } |
| 1306 | LOperand* value() { return InputAt(1); } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1307 | StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1308 | }; |
| 1309 | |
| 1310 | |
| 1311 | class LLoadContextSlot: public LTemplateInstruction<1, 1, 0> { |
| 1312 | public: |
| 1313 | explicit LLoadContextSlot(LOperand* context) { |
| 1314 | inputs_[0] = context; |
| 1315 | } |
| 1316 | |
| 1317 | DECLARE_CONCRETE_INSTRUCTION(LoadContextSlot, "load-context-slot") |
| 1318 | DECLARE_HYDROGEN_ACCESSOR(LoadContextSlot) |
| 1319 | |
| 1320 | LOperand* context() { return InputAt(0); } |
| 1321 | int slot_index() { return hydrogen()->slot_index(); } |
| 1322 | |
| 1323 | virtual void PrintDataTo(StringStream* stream); |
| 1324 | }; |
| 1325 | |
| 1326 | |
| 1327 | class LStoreContextSlot: public LTemplateInstruction<0, 2, 0> { |
| 1328 | public: |
| 1329 | LStoreContextSlot(LOperand* context, LOperand* value) { |
| 1330 | inputs_[0] = context; |
| 1331 | inputs_[1] = value; |
| 1332 | } |
| 1333 | |
| 1334 | DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot, "store-context-slot") |
| 1335 | DECLARE_HYDROGEN_ACCESSOR(StoreContextSlot) |
| 1336 | |
| 1337 | LOperand* context() { return InputAt(0); } |
| 1338 | LOperand* value() { return InputAt(1); } |
| 1339 | int slot_index() { return hydrogen()->slot_index(); } |
| 1340 | |
| 1341 | virtual void PrintDataTo(StringStream* stream); |
| 1342 | }; |
| 1343 | |
| 1344 | |
| 1345 | class LPushArgument: public LTemplateInstruction<0, 1, 0> { |
| 1346 | public: |
| 1347 | explicit LPushArgument(LOperand* value) { |
| 1348 | inputs_[0] = value; |
| 1349 | } |
| 1350 | |
| 1351 | DECLARE_CONCRETE_INSTRUCTION(PushArgument, "push-argument") |
| 1352 | }; |
| 1353 | |
| 1354 | |
jkummerow@chromium.org | 28faa98 | 2012-04-13 09:58:30 +0000 | [diff] [blame] | 1355 | class LDrop: public LTemplateInstruction<0, 0, 0> { |
| 1356 | public: |
| 1357 | explicit LDrop(int count) : count_(count) { } |
| 1358 | |
| 1359 | int count() const { return count_; } |
| 1360 | |
| 1361 | DECLARE_CONCRETE_INSTRUCTION(Drop, "drop") |
| 1362 | |
| 1363 | private: |
| 1364 | int count_; |
| 1365 | }; |
| 1366 | |
| 1367 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1368 | class LThisFunction: public LTemplateInstruction<1, 0, 0> { |
| 1369 | public: |
| 1370 | DECLARE_CONCRETE_INSTRUCTION(ThisFunction, "this-function") |
| 1371 | DECLARE_HYDROGEN_ACCESSOR(ThisFunction) |
| 1372 | }; |
| 1373 | |
| 1374 | |
| 1375 | class LContext: public LTemplateInstruction<1, 0, 0> { |
| 1376 | public: |
| 1377 | DECLARE_CONCRETE_INSTRUCTION(Context, "context") |
| 1378 | }; |
| 1379 | |
| 1380 | |
| 1381 | class LOuterContext: public LTemplateInstruction<1, 1, 0> { |
| 1382 | public: |
| 1383 | explicit LOuterContext(LOperand* context) { |
| 1384 | inputs_[0] = context; |
| 1385 | } |
| 1386 | |
| 1387 | DECLARE_CONCRETE_INSTRUCTION(OuterContext, "outer-context") |
| 1388 | |
| 1389 | LOperand* context() { return InputAt(0); } |
| 1390 | }; |
| 1391 | |
| 1392 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 1393 | class LDeclareGlobals: public LTemplateInstruction<0, 0, 0> { |
| 1394 | public: |
| 1395 | DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals, "declare-globals") |
| 1396 | DECLARE_HYDROGEN_ACCESSOR(DeclareGlobals) |
| 1397 | }; |
| 1398 | |
| 1399 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1400 | class LGlobalObject: public LTemplateInstruction<1, 1, 0> { |
| 1401 | public: |
| 1402 | explicit LGlobalObject(LOperand* context) { |
| 1403 | inputs_[0] = context; |
| 1404 | } |
| 1405 | |
| 1406 | DECLARE_CONCRETE_INSTRUCTION(GlobalObject, "global-object") |
| 1407 | |
| 1408 | LOperand* context() { return InputAt(0); } |
| 1409 | }; |
| 1410 | |
| 1411 | |
| 1412 | class LGlobalReceiver: public LTemplateInstruction<1, 1, 0> { |
| 1413 | public: |
| 1414 | explicit LGlobalReceiver(LOperand* global_object) { |
| 1415 | inputs_[0] = global_object; |
| 1416 | } |
| 1417 | |
| 1418 | DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver, "global-receiver") |
| 1419 | |
| 1420 | LOperand* global() { return InputAt(0); } |
| 1421 | }; |
| 1422 | |
| 1423 | |
| 1424 | class LCallConstantFunction: public LTemplateInstruction<1, 0, 0> { |
| 1425 | public: |
| 1426 | DECLARE_CONCRETE_INSTRUCTION(CallConstantFunction, "call-constant-function") |
| 1427 | DECLARE_HYDROGEN_ACCESSOR(CallConstantFunction) |
| 1428 | |
| 1429 | virtual void PrintDataTo(StringStream* stream); |
| 1430 | |
| 1431 | Handle<JSFunction> function() { return hydrogen()->function(); } |
| 1432 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1433 | }; |
| 1434 | |
| 1435 | |
| 1436 | class LInvokeFunction: public LTemplateInstruction<1, 1, 0> { |
| 1437 | public: |
| 1438 | explicit LInvokeFunction(LOperand* function) { |
| 1439 | inputs_[0] = function; |
| 1440 | } |
| 1441 | |
| 1442 | DECLARE_CONCRETE_INSTRUCTION(InvokeFunction, "invoke-function") |
| 1443 | DECLARE_HYDROGEN_ACCESSOR(InvokeFunction) |
| 1444 | |
| 1445 | LOperand* function() { return inputs_[0]; } |
| 1446 | |
| 1447 | virtual void PrintDataTo(StringStream* stream); |
| 1448 | |
| 1449 | int arity() const { return hydrogen()->argument_count() - 1; } |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1450 | Handle<JSFunction> known_function() { return hydrogen()->known_function(); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1451 | }; |
| 1452 | |
| 1453 | |
| 1454 | class LCallKeyed: public LTemplateInstruction<1, 1, 0> { |
| 1455 | public: |
| 1456 | explicit LCallKeyed(LOperand* key) { |
| 1457 | inputs_[0] = key; |
| 1458 | } |
| 1459 | |
| 1460 | DECLARE_CONCRETE_INSTRUCTION(CallKeyed, "call-keyed") |
| 1461 | DECLARE_HYDROGEN_ACCESSOR(CallKeyed) |
| 1462 | |
| 1463 | virtual void PrintDataTo(StringStream* stream); |
| 1464 | |
| 1465 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1466 | }; |
| 1467 | |
| 1468 | |
| 1469 | |
| 1470 | class LCallNamed: public LTemplateInstruction<1, 0, 0> { |
| 1471 | public: |
| 1472 | DECLARE_CONCRETE_INSTRUCTION(CallNamed, "call-named") |
| 1473 | DECLARE_HYDROGEN_ACCESSOR(CallNamed) |
| 1474 | |
| 1475 | virtual void PrintDataTo(StringStream* stream); |
| 1476 | |
| 1477 | Handle<String> name() const { return hydrogen()->name(); } |
| 1478 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1479 | }; |
| 1480 | |
| 1481 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1482 | class LCallFunction: public LTemplateInstruction<1, 1, 0> { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1483 | public: |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1484 | explicit LCallFunction(LOperand* function) { |
| 1485 | inputs_[0] = function; |
| 1486 | } |
| 1487 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1488 | DECLARE_CONCRETE_INSTRUCTION(CallFunction, "call-function") |
| 1489 | DECLARE_HYDROGEN_ACCESSOR(CallFunction) |
| 1490 | |
danno@chromium.org | c612e02 | 2011-11-10 11:38:15 +0000 | [diff] [blame] | 1491 | LOperand* function() { return inputs_[0]; } |
| 1492 | int arity() const { return hydrogen()->argument_count() - 1; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1493 | }; |
| 1494 | |
| 1495 | |
| 1496 | class LCallGlobal: public LTemplateInstruction<1, 0, 0> { |
| 1497 | public: |
| 1498 | DECLARE_CONCRETE_INSTRUCTION(CallGlobal, "call-global") |
| 1499 | DECLARE_HYDROGEN_ACCESSOR(CallGlobal) |
| 1500 | |
| 1501 | virtual void PrintDataTo(StringStream* stream); |
| 1502 | |
| 1503 | Handle<String> name() const {return hydrogen()->name(); } |
| 1504 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1505 | }; |
| 1506 | |
| 1507 | |
| 1508 | class LCallKnownGlobal: public LTemplateInstruction<1, 0, 0> { |
| 1509 | public: |
| 1510 | DECLARE_CONCRETE_INSTRUCTION(CallKnownGlobal, "call-known-global") |
| 1511 | DECLARE_HYDROGEN_ACCESSOR(CallKnownGlobal) |
| 1512 | |
| 1513 | virtual void PrintDataTo(StringStream* stream); |
| 1514 | |
| 1515 | Handle<JSFunction> target() const { return hydrogen()->target(); } |
| 1516 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1517 | }; |
| 1518 | |
| 1519 | |
| 1520 | class LCallNew: public LTemplateInstruction<1, 1, 0> { |
| 1521 | public: |
| 1522 | explicit LCallNew(LOperand* constructor) { |
| 1523 | inputs_[0] = constructor; |
| 1524 | } |
| 1525 | |
| 1526 | DECLARE_CONCRETE_INSTRUCTION(CallNew, "call-new") |
| 1527 | DECLARE_HYDROGEN_ACCESSOR(CallNew) |
| 1528 | |
| 1529 | virtual void PrintDataTo(StringStream* stream); |
| 1530 | |
| 1531 | int arity() const { return hydrogen()->argument_count() - 1; } |
| 1532 | }; |
| 1533 | |
| 1534 | |
| 1535 | class LCallRuntime: public LTemplateInstruction<1, 0, 0> { |
| 1536 | public: |
| 1537 | DECLARE_CONCRETE_INSTRUCTION(CallRuntime, "call-runtime") |
| 1538 | DECLARE_HYDROGEN_ACCESSOR(CallRuntime) |
| 1539 | |
| 1540 | const Runtime::Function* function() const { return hydrogen()->function(); } |
| 1541 | int arity() const { return hydrogen()->argument_count(); } |
| 1542 | }; |
| 1543 | |
| 1544 | |
| 1545 | class LInteger32ToDouble: public LTemplateInstruction<1, 1, 0> { |
| 1546 | public: |
| 1547 | explicit LInteger32ToDouble(LOperand* value) { |
| 1548 | inputs_[0] = value; |
| 1549 | } |
| 1550 | |
| 1551 | DECLARE_CONCRETE_INSTRUCTION(Integer32ToDouble, "int32-to-double") |
| 1552 | }; |
| 1553 | |
| 1554 | |
| 1555 | class LNumberTagI: public LTemplateInstruction<1, 1, 0> { |
| 1556 | public: |
| 1557 | explicit LNumberTagI(LOperand* value) { |
| 1558 | inputs_[0] = value; |
| 1559 | } |
| 1560 | |
| 1561 | DECLARE_CONCRETE_INSTRUCTION(NumberTagI, "number-tag-i") |
| 1562 | }; |
| 1563 | |
| 1564 | |
| 1565 | class LNumberTagD: public LTemplateInstruction<1, 1, 2> { |
| 1566 | public: |
| 1567 | LNumberTagD(LOperand* value, LOperand* temp1, LOperand* temp2) { |
| 1568 | inputs_[0] = value; |
| 1569 | temps_[0] = temp1; |
| 1570 | temps_[1] = temp2; |
| 1571 | } |
| 1572 | |
| 1573 | DECLARE_CONCRETE_INSTRUCTION(NumberTagD, "number-tag-d") |
| 1574 | }; |
| 1575 | |
| 1576 | |
| 1577 | // Sometimes truncating conversion from a tagged value to an int32. |
| 1578 | class LDoubleToI: public LTemplateInstruction<1, 1, 2> { |
| 1579 | public: |
| 1580 | LDoubleToI(LOperand* value, LOperand* temp1, LOperand* temp2) { |
| 1581 | inputs_[0] = value; |
| 1582 | temps_[0] = temp1; |
| 1583 | temps_[1] = temp2; |
| 1584 | } |
| 1585 | |
| 1586 | DECLARE_CONCRETE_INSTRUCTION(DoubleToI, "double-to-i") |
| 1587 | DECLARE_HYDROGEN_ACCESSOR(UnaryOperation) |
| 1588 | |
| 1589 | bool truncating() { return hydrogen()->CanTruncateToInt32(); } |
| 1590 | }; |
| 1591 | |
| 1592 | |
| 1593 | // Truncating conversion from a tagged value to an int32. |
| 1594 | class LTaggedToI: public LTemplateInstruction<1, 1, 3> { |
| 1595 | public: |
| 1596 | LTaggedToI(LOperand* value, |
| 1597 | LOperand* temp1, |
| 1598 | LOperand* temp2, |
| 1599 | LOperand* temp3) { |
| 1600 | inputs_[0] = value; |
| 1601 | temps_[0] = temp1; |
| 1602 | temps_[1] = temp2; |
| 1603 | temps_[2] = temp3; |
| 1604 | } |
| 1605 | |
| 1606 | DECLARE_CONCRETE_INSTRUCTION(TaggedToI, "tagged-to-i") |
| 1607 | DECLARE_HYDROGEN_ACCESSOR(UnaryOperation) |
| 1608 | |
| 1609 | bool truncating() { return hydrogen()->CanTruncateToInt32(); } |
| 1610 | }; |
| 1611 | |
| 1612 | |
| 1613 | class LSmiTag: public LTemplateInstruction<1, 1, 0> { |
| 1614 | public: |
| 1615 | explicit LSmiTag(LOperand* value) { |
| 1616 | inputs_[0] = value; |
| 1617 | } |
| 1618 | |
| 1619 | DECLARE_CONCRETE_INSTRUCTION(SmiTag, "smi-tag") |
| 1620 | }; |
| 1621 | |
| 1622 | |
| 1623 | class LNumberUntagD: public LTemplateInstruction<1, 1, 0> { |
| 1624 | public: |
| 1625 | explicit LNumberUntagD(LOperand* value) { |
| 1626 | inputs_[0] = value; |
| 1627 | } |
| 1628 | |
| 1629 | DECLARE_CONCRETE_INSTRUCTION(NumberUntagD, "double-untag") |
| 1630 | DECLARE_HYDROGEN_ACCESSOR(Change) |
| 1631 | }; |
| 1632 | |
| 1633 | |
| 1634 | class LSmiUntag: public LTemplateInstruction<1, 1, 0> { |
| 1635 | public: |
| 1636 | LSmiUntag(LOperand* value, bool needs_check) |
| 1637 | : needs_check_(needs_check) { |
| 1638 | inputs_[0] = value; |
| 1639 | } |
| 1640 | |
| 1641 | DECLARE_CONCRETE_INSTRUCTION(SmiUntag, "smi-untag") |
| 1642 | |
| 1643 | bool needs_check() const { return needs_check_; } |
| 1644 | |
| 1645 | private: |
| 1646 | bool needs_check_; |
| 1647 | }; |
| 1648 | |
| 1649 | |
| 1650 | class LStoreNamedField: public LTemplateInstruction<0, 2, 0> { |
| 1651 | public: |
| 1652 | LStoreNamedField(LOperand* obj, LOperand* val) { |
| 1653 | inputs_[0] = obj; |
| 1654 | inputs_[1] = val; |
| 1655 | } |
| 1656 | |
| 1657 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedField, "store-named-field") |
| 1658 | DECLARE_HYDROGEN_ACCESSOR(StoreNamedField) |
| 1659 | |
| 1660 | virtual void PrintDataTo(StringStream* stream); |
| 1661 | |
| 1662 | LOperand* object() { return inputs_[0]; } |
| 1663 | LOperand* value() { return inputs_[1]; } |
| 1664 | |
| 1665 | Handle<Object> name() const { return hydrogen()->name(); } |
| 1666 | bool is_in_object() { return hydrogen()->is_in_object(); } |
| 1667 | int offset() { return hydrogen()->offset(); } |
| 1668 | Handle<Map> transition() const { return hydrogen()->transition(); } |
| 1669 | }; |
| 1670 | |
| 1671 | |
| 1672 | class LStoreNamedGeneric: public LTemplateInstruction<0, 2, 0> { |
| 1673 | public: |
| 1674 | LStoreNamedGeneric(LOperand* obj, LOperand* val) { |
| 1675 | inputs_[0] = obj; |
| 1676 | inputs_[1] = val; |
| 1677 | } |
| 1678 | |
| 1679 | DECLARE_CONCRETE_INSTRUCTION(StoreNamedGeneric, "store-named-generic") |
| 1680 | DECLARE_HYDROGEN_ACCESSOR(StoreNamedGeneric) |
| 1681 | |
| 1682 | virtual void PrintDataTo(StringStream* stream); |
| 1683 | |
| 1684 | LOperand* object() { return inputs_[0]; } |
| 1685 | LOperand* value() { return inputs_[1]; } |
| 1686 | Handle<Object> name() const { return hydrogen()->name(); } |
| 1687 | StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1688 | }; |
| 1689 | |
| 1690 | |
| 1691 | class LStoreKeyedFastElement: public LTemplateInstruction<0, 3, 0> { |
| 1692 | public: |
| 1693 | LStoreKeyedFastElement(LOperand* obj, LOperand* key, LOperand* val) { |
| 1694 | inputs_[0] = obj; |
| 1695 | inputs_[1] = key; |
| 1696 | inputs_[2] = val; |
| 1697 | } |
| 1698 | |
| 1699 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastElement, |
| 1700 | "store-keyed-fast-element") |
| 1701 | DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastElement) |
| 1702 | |
| 1703 | virtual void PrintDataTo(StringStream* stream); |
| 1704 | |
| 1705 | LOperand* object() { return inputs_[0]; } |
| 1706 | LOperand* key() { return inputs_[1]; } |
| 1707 | LOperand* value() { return inputs_[2]; } |
| 1708 | }; |
| 1709 | |
| 1710 | |
| 1711 | class LStoreKeyedFastDoubleElement: public LTemplateInstruction<0, 3, 0> { |
| 1712 | public: |
| 1713 | LStoreKeyedFastDoubleElement(LOperand* elements, |
| 1714 | LOperand* key, |
| 1715 | LOperand* val) { |
| 1716 | inputs_[0] = elements; |
| 1717 | inputs_[1] = key; |
| 1718 | inputs_[2] = val; |
| 1719 | } |
| 1720 | |
| 1721 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedFastDoubleElement, |
| 1722 | "store-keyed-fast-double-element") |
| 1723 | DECLARE_HYDROGEN_ACCESSOR(StoreKeyedFastDoubleElement) |
| 1724 | |
| 1725 | virtual void PrintDataTo(StringStream* stream); |
| 1726 | |
| 1727 | LOperand* elements() { return inputs_[0]; } |
| 1728 | LOperand* key() { return inputs_[1]; } |
| 1729 | LOperand* value() { return inputs_[2]; } |
svenpanne@chromium.org | fb04633 | 2012-04-19 12:02:44 +0000 | [diff] [blame] | 1730 | |
| 1731 | bool NeedsCanonicalization() { return hydrogen()->NeedsCanonicalization(); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1732 | }; |
| 1733 | |
| 1734 | |
| 1735 | class LStoreKeyedGeneric: public LTemplateInstruction<0, 3, 0> { |
| 1736 | public: |
| 1737 | LStoreKeyedGeneric(LOperand* obj, LOperand* key, LOperand* val) { |
| 1738 | inputs_[0] = obj; |
| 1739 | inputs_[1] = key; |
| 1740 | inputs_[2] = val; |
| 1741 | } |
| 1742 | |
| 1743 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric, "store-keyed-generic") |
| 1744 | DECLARE_HYDROGEN_ACCESSOR(StoreKeyedGeneric) |
| 1745 | |
| 1746 | virtual void PrintDataTo(StringStream* stream); |
| 1747 | |
| 1748 | LOperand* object() { return inputs_[0]; } |
| 1749 | LOperand* key() { return inputs_[1]; } |
| 1750 | LOperand* value() { return inputs_[2]; } |
mstarzinger@chromium.org | 1b3afd1 | 2011-11-29 14:28:56 +0000 | [diff] [blame] | 1751 | StrictModeFlag strict_mode_flag() { return hydrogen()->strict_mode_flag(); } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1752 | }; |
| 1753 | |
| 1754 | class LStoreKeyedSpecializedArrayElement: public LTemplateInstruction<0, 3, 0> { |
| 1755 | public: |
| 1756 | LStoreKeyedSpecializedArrayElement(LOperand* external_pointer, |
| 1757 | LOperand* key, |
| 1758 | LOperand* val) { |
| 1759 | inputs_[0] = external_pointer; |
| 1760 | inputs_[1] = key; |
| 1761 | inputs_[2] = val; |
| 1762 | } |
| 1763 | |
| 1764 | DECLARE_CONCRETE_INSTRUCTION(StoreKeyedSpecializedArrayElement, |
| 1765 | "store-keyed-specialized-array-element") |
| 1766 | DECLARE_HYDROGEN_ACCESSOR(StoreKeyedSpecializedArrayElement) |
| 1767 | |
| 1768 | LOperand* external_pointer() { return inputs_[0]; } |
| 1769 | LOperand* key() { return inputs_[1]; } |
| 1770 | LOperand* value() { return inputs_[2]; } |
| 1771 | ElementsKind elements_kind() const { |
| 1772 | return hydrogen()->elements_kind(); |
| 1773 | } |
| 1774 | }; |
| 1775 | |
| 1776 | |
| 1777 | class LTransitionElementsKind: public LTemplateInstruction<1, 1, 2> { |
| 1778 | public: |
| 1779 | LTransitionElementsKind(LOperand* object, |
| 1780 | LOperand* new_map_temp, |
| 1781 | LOperand* temp_reg) { |
| 1782 | inputs_[0] = object; |
| 1783 | temps_[0] = new_map_temp; |
| 1784 | temps_[1] = temp_reg; |
| 1785 | } |
| 1786 | |
| 1787 | DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind, |
| 1788 | "transition-elements-kind") |
| 1789 | DECLARE_HYDROGEN_ACCESSOR(TransitionElementsKind) |
| 1790 | |
| 1791 | virtual void PrintDataTo(StringStream* stream); |
| 1792 | |
| 1793 | LOperand* object() { return inputs_[0]; } |
| 1794 | LOperand* new_map_reg() { return temps_[0]; } |
| 1795 | LOperand* temp_reg() { return temps_[1]; } |
| 1796 | Handle<Map> original_map() { return hydrogen()->original_map(); } |
| 1797 | Handle<Map> transitioned_map() { return hydrogen()->transitioned_map(); } |
| 1798 | }; |
| 1799 | |
| 1800 | |
| 1801 | class LStringAdd: public LTemplateInstruction<1, 2, 0> { |
| 1802 | public: |
| 1803 | LStringAdd(LOperand* left, LOperand* right) { |
| 1804 | inputs_[0] = left; |
| 1805 | inputs_[1] = right; |
| 1806 | } |
| 1807 | |
| 1808 | DECLARE_CONCRETE_INSTRUCTION(StringAdd, "string-add") |
| 1809 | DECLARE_HYDROGEN_ACCESSOR(StringAdd) |
| 1810 | |
| 1811 | LOperand* left() { return inputs_[0]; } |
| 1812 | LOperand* right() { return inputs_[1]; } |
| 1813 | }; |
| 1814 | |
| 1815 | |
| 1816 | |
| 1817 | class LStringCharCodeAt: public LTemplateInstruction<1, 2, 0> { |
| 1818 | public: |
| 1819 | LStringCharCodeAt(LOperand* string, LOperand* index) { |
| 1820 | inputs_[0] = string; |
| 1821 | inputs_[1] = index; |
| 1822 | } |
| 1823 | |
| 1824 | DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt, "string-char-code-at") |
| 1825 | DECLARE_HYDROGEN_ACCESSOR(StringCharCodeAt) |
| 1826 | |
| 1827 | LOperand* string() { return inputs_[0]; } |
| 1828 | LOperand* index() { return inputs_[1]; } |
| 1829 | }; |
| 1830 | |
| 1831 | |
| 1832 | class LStringCharFromCode: public LTemplateInstruction<1, 1, 0> { |
| 1833 | public: |
| 1834 | explicit LStringCharFromCode(LOperand* char_code) { |
| 1835 | inputs_[0] = char_code; |
| 1836 | } |
| 1837 | |
| 1838 | DECLARE_CONCRETE_INSTRUCTION(StringCharFromCode, "string-char-from-code") |
| 1839 | DECLARE_HYDROGEN_ACCESSOR(StringCharFromCode) |
| 1840 | |
| 1841 | LOperand* char_code() { return inputs_[0]; } |
| 1842 | }; |
| 1843 | |
| 1844 | |
| 1845 | class LStringLength: public LTemplateInstruction<1, 1, 0> { |
| 1846 | public: |
| 1847 | explicit LStringLength(LOperand* string) { |
| 1848 | inputs_[0] = string; |
| 1849 | } |
| 1850 | |
| 1851 | DECLARE_CONCRETE_INSTRUCTION(StringLength, "string-length") |
| 1852 | DECLARE_HYDROGEN_ACCESSOR(StringLength) |
| 1853 | |
| 1854 | LOperand* string() { return inputs_[0]; } |
| 1855 | }; |
| 1856 | |
| 1857 | |
| 1858 | class LCheckFunction: public LTemplateInstruction<0, 1, 0> { |
| 1859 | public: |
| 1860 | explicit LCheckFunction(LOperand* value) { |
| 1861 | inputs_[0] = value; |
| 1862 | } |
| 1863 | |
ricow@chromium.org | 64e3a4b | 2011-12-13 08:07:27 +0000 | [diff] [blame] | 1864 | LOperand* value() { return InputAt(0); } |
| 1865 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1866 | DECLARE_CONCRETE_INSTRUCTION(CheckFunction, "check-function") |
| 1867 | DECLARE_HYDROGEN_ACCESSOR(CheckFunction) |
| 1868 | }; |
| 1869 | |
| 1870 | |
| 1871 | class LCheckInstanceType: public LTemplateInstruction<0, 1, 0> { |
| 1872 | public: |
| 1873 | explicit LCheckInstanceType(LOperand* value) { |
| 1874 | inputs_[0] = value; |
| 1875 | } |
| 1876 | |
| 1877 | DECLARE_CONCRETE_INSTRUCTION(CheckInstanceType, "check-instance-type") |
| 1878 | DECLARE_HYDROGEN_ACCESSOR(CheckInstanceType) |
| 1879 | }; |
| 1880 | |
| 1881 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 1882 | class LCheckMaps: public LTemplateInstruction<0, 1, 0> { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1883 | public: |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 1884 | explicit LCheckMaps(LOperand* value) { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1885 | inputs_[0] = value; |
| 1886 | } |
| 1887 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 1888 | DECLARE_CONCRETE_INSTRUCTION(CheckMaps, "check-maps") |
| 1889 | DECLARE_HYDROGEN_ACCESSOR(CheckMaps) |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1890 | }; |
| 1891 | |
| 1892 | |
| 1893 | class LCheckPrototypeMaps: public LTemplateInstruction<0, 0, 2> { |
| 1894 | public: |
| 1895 | LCheckPrototypeMaps(LOperand* temp1, LOperand* temp2) { |
| 1896 | temps_[0] = temp1; |
| 1897 | temps_[1] = temp2; |
| 1898 | } |
| 1899 | |
| 1900 | DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps, "check-prototype-maps") |
| 1901 | DECLARE_HYDROGEN_ACCESSOR(CheckPrototypeMaps) |
| 1902 | |
| 1903 | Handle<JSObject> prototype() const { return hydrogen()->prototype(); } |
| 1904 | Handle<JSObject> holder() const { return hydrogen()->holder(); } |
| 1905 | }; |
| 1906 | |
| 1907 | |
| 1908 | class LCheckSmi: public LTemplateInstruction<0, 1, 0> { |
| 1909 | public: |
| 1910 | explicit LCheckSmi(LOperand* value) { |
| 1911 | inputs_[0] = value; |
| 1912 | } |
| 1913 | |
| 1914 | DECLARE_CONCRETE_INSTRUCTION(CheckSmi, "check-smi") |
| 1915 | }; |
| 1916 | |
| 1917 | |
| 1918 | class LCheckNonSmi: public LTemplateInstruction<0, 1, 0> { |
| 1919 | public: |
| 1920 | explicit LCheckNonSmi(LOperand* value) { |
| 1921 | inputs_[0] = value; |
| 1922 | } |
| 1923 | |
| 1924 | DECLARE_CONCRETE_INSTRUCTION(CheckNonSmi, "check-non-smi") |
| 1925 | }; |
| 1926 | |
| 1927 | |
| 1928 | class LClampDToUint8: public LTemplateInstruction<1, 1, 1> { |
| 1929 | public: |
| 1930 | LClampDToUint8(LOperand* value, LOperand* temp) { |
| 1931 | inputs_[0] = value; |
| 1932 | temps_[0] = temp; |
| 1933 | } |
| 1934 | |
| 1935 | LOperand* unclamped() { return inputs_[0]; } |
| 1936 | |
| 1937 | DECLARE_CONCRETE_INSTRUCTION(ClampDToUint8, "clamp-d-to-uint8") |
| 1938 | }; |
| 1939 | |
| 1940 | |
| 1941 | class LClampIToUint8: public LTemplateInstruction<1, 1, 0> { |
| 1942 | public: |
| 1943 | explicit LClampIToUint8(LOperand* value) { |
| 1944 | inputs_[0] = value; |
| 1945 | } |
| 1946 | |
| 1947 | LOperand* unclamped() { return inputs_[0]; } |
| 1948 | |
| 1949 | DECLARE_CONCRETE_INSTRUCTION(ClampIToUint8, "clamp-i-to-uint8") |
| 1950 | }; |
| 1951 | |
| 1952 | |
| 1953 | class LClampTToUint8: public LTemplateInstruction<1, 1, 1> { |
| 1954 | public: |
| 1955 | LClampTToUint8(LOperand* value, LOperand* temp) { |
| 1956 | inputs_[0] = value; |
| 1957 | temps_[0] = temp; |
| 1958 | } |
| 1959 | |
| 1960 | LOperand* unclamped() { return inputs_[0]; } |
| 1961 | |
| 1962 | DECLARE_CONCRETE_INSTRUCTION(ClampTToUint8, "clamp-t-to-uint8") |
| 1963 | }; |
| 1964 | |
| 1965 | |
fschneider@chromium.org | 35814e5 | 2012-03-01 15:43:35 +0000 | [diff] [blame] | 1966 | class LAllocateObject: public LTemplateInstruction<1, 0, 2> { |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1967 | public: |
fschneider@chromium.org | 35814e5 | 2012-03-01 15:43:35 +0000 | [diff] [blame] | 1968 | LAllocateObject(LOperand* temp1, LOperand* temp2) { |
| 1969 | temps_[0] = temp1; |
| 1970 | temps_[1] = temp2; |
| 1971 | } |
| 1972 | |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 1973 | DECLARE_CONCRETE_INSTRUCTION(AllocateObject, "allocate-object") |
| 1974 | DECLARE_HYDROGEN_ACCESSOR(AllocateObject) |
| 1975 | }; |
| 1976 | |
| 1977 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 1978 | class LFastLiteral: public LTemplateInstruction<1, 0, 0> { |
| 1979 | public: |
| 1980 | DECLARE_CONCRETE_INSTRUCTION(FastLiteral, "fast-literal") |
| 1981 | DECLARE_HYDROGEN_ACCESSOR(FastLiteral) |
| 1982 | }; |
| 1983 | |
| 1984 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1985 | class LArrayLiteral: public LTemplateInstruction<1, 0, 0> { |
| 1986 | public: |
| 1987 | DECLARE_CONCRETE_INSTRUCTION(ArrayLiteral, "array-literal") |
| 1988 | DECLARE_HYDROGEN_ACCESSOR(ArrayLiteral) |
| 1989 | }; |
| 1990 | |
| 1991 | |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 1992 | class LObjectLiteral: public LTemplateInstruction<1, 0, 0> { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1993 | public: |
jkummerow@chromium.org | f7a5884 | 2012-02-21 10:08:21 +0000 | [diff] [blame] | 1994 | DECLARE_CONCRETE_INSTRUCTION(ObjectLiteral, "object-literal") |
| 1995 | DECLARE_HYDROGEN_ACCESSOR(ObjectLiteral) |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 1996 | }; |
| 1997 | |
| 1998 | |
| 1999 | class LRegExpLiteral: public LTemplateInstruction<1, 0, 0> { |
| 2000 | public: |
| 2001 | DECLARE_CONCRETE_INSTRUCTION(RegExpLiteral, "regexp-literal") |
| 2002 | DECLARE_HYDROGEN_ACCESSOR(RegExpLiteral) |
| 2003 | }; |
| 2004 | |
| 2005 | |
| 2006 | class LFunctionLiteral: public LTemplateInstruction<1, 0, 0> { |
| 2007 | public: |
| 2008 | DECLARE_CONCRETE_INSTRUCTION(FunctionLiteral, "function-literal") |
| 2009 | DECLARE_HYDROGEN_ACCESSOR(FunctionLiteral) |
| 2010 | |
| 2011 | Handle<SharedFunctionInfo> shared_info() { return hydrogen()->shared_info(); } |
| 2012 | }; |
| 2013 | |
| 2014 | |
| 2015 | class LToFastProperties: public LTemplateInstruction<1, 1, 0> { |
| 2016 | public: |
| 2017 | explicit LToFastProperties(LOperand* value) { |
| 2018 | inputs_[0] = value; |
| 2019 | } |
| 2020 | |
| 2021 | DECLARE_CONCRETE_INSTRUCTION(ToFastProperties, "to-fast-properties") |
| 2022 | DECLARE_HYDROGEN_ACCESSOR(ToFastProperties) |
| 2023 | }; |
| 2024 | |
| 2025 | |
| 2026 | class LTypeof: public LTemplateInstruction<1, 1, 0> { |
| 2027 | public: |
| 2028 | explicit LTypeof(LOperand* value) { |
| 2029 | inputs_[0] = value; |
| 2030 | } |
| 2031 | |
| 2032 | DECLARE_CONCRETE_INSTRUCTION(Typeof, "typeof") |
| 2033 | }; |
| 2034 | |
| 2035 | |
| 2036 | class LTypeofIsAndBranch: public LControlInstruction<1, 0> { |
| 2037 | public: |
| 2038 | explicit LTypeofIsAndBranch(LOperand* value) { |
| 2039 | inputs_[0] = value; |
| 2040 | } |
| 2041 | |
| 2042 | DECLARE_CONCRETE_INSTRUCTION(TypeofIsAndBranch, "typeof-is-and-branch") |
| 2043 | DECLARE_HYDROGEN_ACCESSOR(TypeofIsAndBranch) |
| 2044 | |
| 2045 | Handle<String> type_literal() { return hydrogen()->type_literal(); } |
| 2046 | |
| 2047 | virtual void PrintDataTo(StringStream* stream); |
| 2048 | }; |
| 2049 | |
| 2050 | |
| 2051 | class LIsConstructCallAndBranch: public LControlInstruction<0, 1> { |
| 2052 | public: |
| 2053 | explicit LIsConstructCallAndBranch(LOperand* temp) { |
| 2054 | temps_[0] = temp; |
| 2055 | } |
| 2056 | |
| 2057 | DECLARE_CONCRETE_INSTRUCTION(IsConstructCallAndBranch, |
| 2058 | "is-construct-call-and-branch") |
| 2059 | }; |
| 2060 | |
| 2061 | |
| 2062 | class LDeleteProperty: public LTemplateInstruction<1, 2, 0> { |
| 2063 | public: |
| 2064 | LDeleteProperty(LOperand* obj, LOperand* key) { |
| 2065 | inputs_[0] = obj; |
| 2066 | inputs_[1] = key; |
| 2067 | } |
| 2068 | |
| 2069 | DECLARE_CONCRETE_INSTRUCTION(DeleteProperty, "delete-property") |
| 2070 | |
| 2071 | LOperand* object() { return inputs_[0]; } |
| 2072 | LOperand* key() { return inputs_[1]; } |
| 2073 | }; |
| 2074 | |
| 2075 | |
| 2076 | class LOsrEntry: public LTemplateInstruction<0, 0, 0> { |
| 2077 | public: |
| 2078 | LOsrEntry(); |
| 2079 | |
| 2080 | DECLARE_CONCRETE_INSTRUCTION(OsrEntry, "osr-entry") |
| 2081 | |
| 2082 | LOperand** SpilledRegisterArray() { return register_spills_; } |
| 2083 | LOperand** SpilledDoubleRegisterArray() { return double_register_spills_; } |
| 2084 | |
| 2085 | void MarkSpilledRegister(int allocation_index, LOperand* spill_operand); |
| 2086 | void MarkSpilledDoubleRegister(int allocation_index, |
| 2087 | LOperand* spill_operand); |
| 2088 | |
| 2089 | private: |
| 2090 | // Arrays of spill slot operands for registers with an assigned spill |
| 2091 | // slot, i.e., that must also be restored to the spill slot on OSR entry. |
| 2092 | // NULL if the register has no assigned spill slot. Indexed by allocation |
| 2093 | // index. |
| 2094 | LOperand* register_spills_[Register::kNumAllocatableRegisters]; |
| 2095 | LOperand* double_register_spills_[DoubleRegister::kNumAllocatableRegisters]; |
| 2096 | }; |
| 2097 | |
| 2098 | |
| 2099 | class LStackCheck: public LTemplateInstruction<0, 0, 0> { |
| 2100 | public: |
| 2101 | DECLARE_CONCRETE_INSTRUCTION(StackCheck, "stack-check") |
| 2102 | DECLARE_HYDROGEN_ACCESSOR(StackCheck) |
| 2103 | |
| 2104 | Label* done_label() { return &done_label_; } |
| 2105 | |
| 2106 | private: |
| 2107 | Label done_label_; |
| 2108 | }; |
| 2109 | |
| 2110 | |
| 2111 | class LIn: public LTemplateInstruction<1, 2, 0> { |
| 2112 | public: |
| 2113 | LIn(LOperand* key, LOperand* object) { |
| 2114 | inputs_[0] = key; |
| 2115 | inputs_[1] = object; |
| 2116 | } |
| 2117 | |
| 2118 | LOperand* key() { return inputs_[0]; } |
| 2119 | LOperand* object() { return inputs_[1]; } |
| 2120 | |
| 2121 | DECLARE_CONCRETE_INSTRUCTION(In, "in") |
| 2122 | }; |
| 2123 | |
| 2124 | |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2125 | class LForInPrepareMap: public LTemplateInstruction<1, 1, 0> { |
| 2126 | public: |
| 2127 | explicit LForInPrepareMap(LOperand* object) { |
| 2128 | inputs_[0] = object; |
| 2129 | } |
| 2130 | |
| 2131 | LOperand* object() { return inputs_[0]; } |
| 2132 | |
| 2133 | DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap, "for-in-prepare-map") |
| 2134 | }; |
| 2135 | |
| 2136 | |
| 2137 | class LForInCacheArray: public LTemplateInstruction<1, 1, 0> { |
| 2138 | public: |
| 2139 | explicit LForInCacheArray(LOperand* map) { |
| 2140 | inputs_[0] = map; |
| 2141 | } |
| 2142 | |
| 2143 | LOperand* map() { return inputs_[0]; } |
| 2144 | |
| 2145 | DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray, "for-in-cache-array") |
| 2146 | |
| 2147 | int idx() { |
| 2148 | return HForInCacheArray::cast(this->hydrogen_value())->idx(); |
| 2149 | } |
| 2150 | }; |
| 2151 | |
| 2152 | |
| 2153 | class LCheckMapValue: public LTemplateInstruction<0, 2, 0> { |
| 2154 | public: |
| 2155 | LCheckMapValue(LOperand* value, LOperand* map) { |
| 2156 | inputs_[0] = value; |
| 2157 | inputs_[1] = map; |
| 2158 | } |
| 2159 | |
| 2160 | LOperand* value() { return inputs_[0]; } |
| 2161 | LOperand* map() { return inputs_[1]; } |
| 2162 | |
| 2163 | DECLARE_CONCRETE_INSTRUCTION(CheckMapValue, "check-map-value") |
| 2164 | }; |
| 2165 | |
| 2166 | |
| 2167 | class LLoadFieldByIndex: public LTemplateInstruction<1, 2, 0> { |
| 2168 | public: |
| 2169 | LLoadFieldByIndex(LOperand* object, LOperand* index) { |
| 2170 | inputs_[0] = object; |
| 2171 | inputs_[1] = index; |
| 2172 | } |
| 2173 | |
| 2174 | LOperand* object() { return inputs_[0]; } |
| 2175 | LOperand* index() { return inputs_[1]; } |
| 2176 | |
| 2177 | DECLARE_CONCRETE_INSTRUCTION(LoadFieldByIndex, "load-field-by-index") |
| 2178 | }; |
| 2179 | |
| 2180 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2181 | class LChunkBuilder; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2182 | class LChunk: public ZoneObject { |
| 2183 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2184 | explicit LChunk(CompilationInfo* info, HGraph* graph); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2185 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2186 | void AddInstruction(LInstruction* instruction, HBasicBlock* block); |
| 2187 | LConstantOperand* DefineConstantOperand(HConstant* constant); |
| 2188 | Handle<Object> LookupLiteral(LConstantOperand* operand) const; |
| 2189 | Representation LookupLiteralRepresentation(LConstantOperand* operand) const; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2190 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2191 | int GetNextSpillIndex(bool is_double); |
| 2192 | LOperand* GetNextSpillSlot(bool is_double); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2193 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2194 | int ParameterAt(int index); |
| 2195 | int GetParameterStackSlot(int index) const; |
| 2196 | int spill_slot_count() const { return spill_slot_count_; } |
| 2197 | CompilationInfo* info() const { return info_; } |
| 2198 | HGraph* graph() const { return graph_; } |
| 2199 | const ZoneList<LInstruction*>* instructions() const { return &instructions_; } |
| 2200 | void AddGapMove(int index, LOperand* from, LOperand* to); |
| 2201 | LGap* GetGapAt(int index) const; |
| 2202 | bool IsGapAt(int index) const; |
| 2203 | int NearestGapPos(int index) const; |
| 2204 | void MarkEmptyBlocks(); |
| 2205 | const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2206 | LLabel* GetLabel(int block_id) const { |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2207 | HBasicBlock* block = graph_->blocks()->at(block_id); |
| 2208 | int first_instruction = block->first_instruction_index(); |
| 2209 | return LLabel::cast(instructions_[first_instruction]); |
| 2210 | } |
| 2211 | int LookupDestination(int block_id) const { |
| 2212 | LLabel* cur = GetLabel(block_id); |
| 2213 | while (cur->replacement() != NULL) { |
| 2214 | cur = cur->replacement(); |
| 2215 | } |
| 2216 | return cur->block_id(); |
| 2217 | } |
| 2218 | Label* GetAssemblyLabel(int block_id) const { |
| 2219 | LLabel* label = GetLabel(block_id); |
| 2220 | ASSERT(!label->HasReplacement()); |
| 2221 | return label->label(); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2222 | } |
| 2223 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2224 | const ZoneList<Handle<JSFunction> >* inlined_closures() const { |
| 2225 | return &inlined_closures_; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2226 | } |
| 2227 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2228 | void AddInlinedClosure(Handle<JSFunction> closure) { |
| 2229 | inlined_closures_.Add(closure); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2230 | } |
| 2231 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2232 | private: |
| 2233 | int spill_slot_count_; |
| 2234 | CompilationInfo* info_; |
| 2235 | HGraph* const graph_; |
| 2236 | ZoneList<LInstruction*> instructions_; |
| 2237 | ZoneList<LPointerMap*> pointer_maps_; |
| 2238 | ZoneList<Handle<JSFunction> > inlined_closures_; |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2239 | }; |
| 2240 | |
| 2241 | |
| 2242 | class LChunkBuilder BASE_EMBEDDED { |
| 2243 | public: |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2244 | LChunkBuilder(CompilationInfo* info, HGraph* graph, LAllocator* allocator) |
| 2245 | : chunk_(NULL), |
| 2246 | info_(info), |
| 2247 | graph_(graph), |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2248 | zone_(graph->isolate()->zone()), |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2249 | status_(UNUSED), |
| 2250 | current_instruction_(NULL), |
| 2251 | current_block_(NULL), |
| 2252 | next_block_(NULL), |
| 2253 | argument_count_(0), |
| 2254 | allocator_(allocator), |
| 2255 | position_(RelocInfo::kNoPosition), |
| 2256 | instruction_pending_deoptimization_environment_(NULL), |
| 2257 | pending_deoptimization_ast_id_(AstNode::kNoNumber) { } |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2258 | |
| 2259 | // Build the sequence for the graph. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2260 | LChunk* Build(); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2261 | |
| 2262 | // Declare methods that deal with the individual node types. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2263 | #define DECLARE_DO(type) LInstruction* Do##type(H##type* node); |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2264 | HYDROGEN_CONCRETE_INSTRUCTION_LIST(DECLARE_DO) |
| 2265 | #undef DECLARE_DO |
| 2266 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2267 | private: |
| 2268 | enum Status { |
| 2269 | UNUSED, |
| 2270 | BUILDING, |
| 2271 | DONE, |
| 2272 | ABORTED |
| 2273 | }; |
| 2274 | |
| 2275 | LChunk* chunk() const { return chunk_; } |
| 2276 | CompilationInfo* info() const { return info_; } |
| 2277 | HGraph* graph() const { return graph_; } |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2278 | Zone* zone() const { return zone_; } |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2279 | |
| 2280 | bool is_unused() const { return status_ == UNUSED; } |
| 2281 | bool is_building() const { return status_ == BUILDING; } |
| 2282 | bool is_done() const { return status_ == DONE; } |
| 2283 | bool is_aborted() const { return status_ == ABORTED; } |
| 2284 | |
| 2285 | void Abort(const char* format, ...); |
| 2286 | |
| 2287 | // Methods for getting operands for Use / Define / Temp. |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2288 | LUnallocated* ToUnallocated(Register reg); |
| 2289 | LUnallocated* ToUnallocated(DoubleRegister reg); |
| 2290 | |
| 2291 | // Methods for setting up define-use relationships. |
| 2292 | MUST_USE_RESULT LOperand* Use(HValue* value, LUnallocated* operand); |
| 2293 | MUST_USE_RESULT LOperand* UseFixed(HValue* value, Register fixed_register); |
| 2294 | MUST_USE_RESULT LOperand* UseFixedDouble(HValue* value, |
| 2295 | DoubleRegister fixed_register); |
| 2296 | |
| 2297 | // A value that is guaranteed to be allocated to a register. |
| 2298 | // Operand created by UseRegister is guaranteed to be live until the end of |
| 2299 | // instruction. This means that register allocator will not reuse it's |
| 2300 | // register for any other operand inside instruction. |
| 2301 | // Operand created by UseRegisterAtStart is guaranteed to be live only at |
| 2302 | // instruction start. Register allocator is free to assign the same register |
| 2303 | // to some other operand used inside instruction (i.e. temporary or |
| 2304 | // output). |
| 2305 | MUST_USE_RESULT LOperand* UseRegister(HValue* value); |
| 2306 | MUST_USE_RESULT LOperand* UseRegisterAtStart(HValue* value); |
| 2307 | |
| 2308 | // An input operand in a register that may be trashed. |
| 2309 | MUST_USE_RESULT LOperand* UseTempRegister(HValue* value); |
| 2310 | |
| 2311 | // An input operand in a register or stack slot. |
| 2312 | MUST_USE_RESULT LOperand* Use(HValue* value); |
| 2313 | MUST_USE_RESULT LOperand* UseAtStart(HValue* value); |
| 2314 | |
| 2315 | // An input operand in a register, stack slot or a constant operand. |
| 2316 | MUST_USE_RESULT LOperand* UseOrConstant(HValue* value); |
| 2317 | MUST_USE_RESULT LOperand* UseOrConstantAtStart(HValue* value); |
| 2318 | |
| 2319 | // An input operand in a register or a constant operand. |
| 2320 | MUST_USE_RESULT LOperand* UseRegisterOrConstant(HValue* value); |
| 2321 | MUST_USE_RESULT LOperand* UseRegisterOrConstantAtStart(HValue* value); |
| 2322 | |
| 2323 | // An input operand in register, stack slot or a constant operand. |
| 2324 | // Will not be moved to a register even if one is freely available. |
| 2325 | MUST_USE_RESULT LOperand* UseAny(HValue* value); |
| 2326 | |
| 2327 | // Temporary operand that must be in a register. |
| 2328 | MUST_USE_RESULT LUnallocated* TempRegister(); |
| 2329 | MUST_USE_RESULT LOperand* FixedTemp(Register reg); |
| 2330 | MUST_USE_RESULT LOperand* FixedTemp(DoubleRegister reg); |
| 2331 | |
| 2332 | // Methods for setting up define-use relationships. |
| 2333 | // Return the same instruction that they are passed. |
| 2334 | template<int I, int T> |
| 2335 | LInstruction* Define(LTemplateInstruction<1, I, T>* instr, |
| 2336 | LUnallocated* result); |
| 2337 | template<int I, int T> |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2338 | LInstruction* DefineAsRegister(LTemplateInstruction<1, I, T>* instr); |
| 2339 | template<int I, int T> |
| 2340 | LInstruction* DefineAsSpilled(LTemplateInstruction<1, I, T>* instr, |
| 2341 | int index); |
| 2342 | template<int I, int T> |
| 2343 | LInstruction* DefineSameAsFirst(LTemplateInstruction<1, I, T>* instr); |
| 2344 | template<int I, int T> |
| 2345 | LInstruction* DefineFixed(LTemplateInstruction<1, I, T>* instr, |
| 2346 | Register reg); |
| 2347 | template<int I, int T> |
| 2348 | LInstruction* DefineFixedDouble(LTemplateInstruction<1, I, T>* instr, |
| 2349 | DoubleRegister reg); |
| 2350 | LInstruction* AssignEnvironment(LInstruction* instr); |
| 2351 | LInstruction* AssignPointerMap(LInstruction* instr); |
| 2352 | |
| 2353 | enum CanDeoptimize { CAN_DEOPTIMIZE_EAGERLY, CANNOT_DEOPTIMIZE_EAGERLY }; |
| 2354 | |
| 2355 | // By default we assume that instruction sequences generated for calls |
| 2356 | // cannot deoptimize eagerly and we do not attach environment to this |
| 2357 | // instruction. |
| 2358 | LInstruction* MarkAsCall( |
| 2359 | LInstruction* instr, |
| 2360 | HInstruction* hinstr, |
| 2361 | CanDeoptimize can_deoptimize = CANNOT_DEOPTIMIZE_EAGERLY); |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2362 | |
| 2363 | LEnvironment* CreateEnvironment(HEnvironment* hydrogen_env, |
| 2364 | int* argument_index_accumulator); |
| 2365 | |
| 2366 | void VisitInstruction(HInstruction* current); |
| 2367 | |
| 2368 | void DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block); |
| 2369 | LInstruction* DoBit(Token::Value op, HBitwiseBinaryOperation* instr); |
| 2370 | LInstruction* DoShift(Token::Value op, HBitwiseBinaryOperation* instr); |
| 2371 | LInstruction* DoArithmeticD(Token::Value op, |
| 2372 | HArithmeticBinaryOperation* instr); |
| 2373 | LInstruction* DoArithmeticT(Token::Value op, |
| 2374 | HArithmeticBinaryOperation* instr); |
| 2375 | |
| 2376 | LChunk* chunk_; |
| 2377 | CompilationInfo* info_; |
| 2378 | HGraph* const graph_; |
ulan@chromium.org | 812308e | 2012-02-29 15:58:45 +0000 | [diff] [blame] | 2379 | Zone* zone_; |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2380 | Status status_; |
| 2381 | HInstruction* current_instruction_; |
| 2382 | HBasicBlock* current_block_; |
| 2383 | HBasicBlock* next_block_; |
| 2384 | int argument_count_; |
| 2385 | LAllocator* allocator_; |
| 2386 | int position_; |
| 2387 | LInstruction* instruction_pending_deoptimization_environment_; |
| 2388 | int pending_deoptimization_ast_id_; |
| 2389 | |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2390 | DISALLOW_COPY_AND_ASSIGN(LChunkBuilder); |
| 2391 | }; |
| 2392 | |
jkummerow@chromium.org | c3b3712 | 2011-11-07 10:14:12 +0000 | [diff] [blame] | 2393 | #undef DECLARE_HYDROGEN_ACCESSOR |
| 2394 | #undef DECLARE_CONCRETE_INSTRUCTION |
lrn@chromium.org | 7516f05 | 2011-03-30 08:52:27 +0000 | [diff] [blame] | 2395 | |
| 2396 | } } // namespace v8::internal |
| 2397 | |
| 2398 | #endif // V8_MIPS_LITHIUM_MIPS_H_ |