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