erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 1 | // Copyright 2012 the V8 project authors. All rights reserved. |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +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_LITHIUM_H_ |
| 29 | #define V8_LITHIUM_H_ |
| 30 | |
lrn@chromium.org | 1c09276 | 2011-05-09 09:42:16 +0000 | [diff] [blame] | 31 | #include "allocation.h" |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 32 | #include "hydrogen.h" |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 33 | #include "safepoint-table.h" |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 34 | |
| 35 | namespace v8 { |
| 36 | namespace internal { |
| 37 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 38 | #define LITHIUM_OPERAND_LIST(V) \ |
| 39 | V(ConstantOperand, CONSTANT_OPERAND) \ |
| 40 | V(StackSlot, STACK_SLOT) \ |
| 41 | V(DoubleStackSlot, DOUBLE_STACK_SLOT) \ |
| 42 | V(Register, REGISTER) \ |
| 43 | V(DoubleRegister, DOUBLE_REGISTER) |
| 44 | |
| 45 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 46 | class LOperand: public ZoneObject { |
| 47 | public: |
| 48 | enum Kind { |
| 49 | INVALID, |
| 50 | UNALLOCATED, |
| 51 | CONSTANT_OPERAND, |
| 52 | STACK_SLOT, |
| 53 | DOUBLE_STACK_SLOT, |
| 54 | REGISTER, |
| 55 | DOUBLE_REGISTER, |
| 56 | ARGUMENT |
| 57 | }; |
| 58 | |
| 59 | LOperand() : value_(KindField::encode(INVALID)) { } |
| 60 | |
| 61 | Kind kind() const { return KindField::decode(value_); } |
| 62 | int index() const { return static_cast<int>(value_) >> kKindFieldWidth; } |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 63 | #define LITHIUM_OPERAND_PREDICATE(name, type) \ |
| 64 | bool Is##name() const { return kind() == type; } |
| 65 | LITHIUM_OPERAND_LIST(LITHIUM_OPERAND_PREDICATE) |
| 66 | LITHIUM_OPERAND_PREDICATE(Argument, ARGUMENT) |
| 67 | LITHIUM_OPERAND_PREDICATE(Unallocated, UNALLOCATED) |
| 68 | LITHIUM_OPERAND_PREDICATE(Ignored, INVALID) |
| 69 | #undef LITHIUM_OPERAND_PREDICATE |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 70 | bool Equals(LOperand* other) const { return value_ == other->value_; } |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 71 | |
| 72 | void PrintTo(StringStream* stream); |
| 73 | void ConvertTo(Kind kind, int index) { |
| 74 | value_ = KindField::encode(kind); |
| 75 | value_ |= index << kKindFieldWidth; |
| 76 | ASSERT(this->index() == index); |
| 77 | } |
| 78 | |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 79 | // Calls SetUpCache()/TearDownCache() for each subclass. |
| 80 | static void SetUpCaches(); |
| 81 | static void TearDownCaches(); |
| 82 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 83 | protected: |
| 84 | static const int kKindFieldWidth = 3; |
| 85 | class KindField : public BitField<Kind, 0, kKindFieldWidth> { }; |
| 86 | |
| 87 | LOperand(Kind kind, int index) { ConvertTo(kind, index); } |
| 88 | |
| 89 | unsigned value_; |
| 90 | }; |
| 91 | |
| 92 | |
| 93 | class LUnallocated: public LOperand { |
| 94 | public: |
| 95 | enum Policy { |
| 96 | NONE, |
| 97 | ANY, |
| 98 | FIXED_REGISTER, |
| 99 | FIXED_DOUBLE_REGISTER, |
| 100 | FIXED_SLOT, |
| 101 | MUST_HAVE_REGISTER, |
| 102 | WRITABLE_REGISTER, |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 103 | SAME_AS_FIRST_INPUT |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 104 | }; |
| 105 | |
| 106 | // Lifetime of operand inside the instruction. |
| 107 | enum Lifetime { |
| 108 | // USED_AT_START operand is guaranteed to be live only at |
| 109 | // instruction start. Register allocator is free to assign the same register |
| 110 | // to some other operand used inside instruction (i.e. temporary or |
| 111 | // output). |
| 112 | USED_AT_START, |
| 113 | |
| 114 | // USED_AT_END operand is treated as live until the end of |
| 115 | // instruction. This means that register allocator will not reuse it's |
| 116 | // register for any other operand inside instruction. |
| 117 | USED_AT_END |
| 118 | }; |
| 119 | |
| 120 | explicit LUnallocated(Policy policy) : LOperand(UNALLOCATED, 0) { |
| 121 | Initialize(policy, 0, USED_AT_END); |
| 122 | } |
| 123 | |
| 124 | LUnallocated(Policy policy, int fixed_index) : LOperand(UNALLOCATED, 0) { |
| 125 | Initialize(policy, fixed_index, USED_AT_END); |
| 126 | } |
| 127 | |
| 128 | LUnallocated(Policy policy, Lifetime lifetime) : LOperand(UNALLOCATED, 0) { |
| 129 | Initialize(policy, 0, lifetime); |
| 130 | } |
| 131 | |
| 132 | // The superclass has a KindField. Some policies have a signed fixed |
| 133 | // index in the upper bits. |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 134 | static const int kPolicyWidth = 3; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 135 | static const int kLifetimeWidth = 1; |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 136 | static const int kVirtualRegisterWidth = 15; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 137 | |
| 138 | static const int kPolicyShift = kKindFieldWidth; |
| 139 | static const int kLifetimeShift = kPolicyShift + kPolicyWidth; |
| 140 | static const int kVirtualRegisterShift = kLifetimeShift + kLifetimeWidth; |
| 141 | static const int kFixedIndexShift = |
| 142 | kVirtualRegisterShift + kVirtualRegisterWidth; |
verwaest@chromium.org | 33e09c8 | 2012-10-10 17:07:22 +0000 | [diff] [blame] | 143 | static const int kFixedIndexWidth = 32 - kFixedIndexShift; |
| 144 | STATIC_ASSERT(kFixedIndexWidth > 5); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 145 | |
| 146 | class PolicyField : public BitField<Policy, kPolicyShift, kPolicyWidth> { }; |
| 147 | |
| 148 | class LifetimeField |
| 149 | : public BitField<Lifetime, kLifetimeShift, kLifetimeWidth> { |
| 150 | }; |
| 151 | |
| 152 | class VirtualRegisterField |
| 153 | : public BitField<unsigned, |
| 154 | kVirtualRegisterShift, |
| 155 | kVirtualRegisterWidth> { |
| 156 | }; |
| 157 | |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 158 | static const int kMaxVirtualRegisters = 1 << kVirtualRegisterWidth; |
rossberg@chromium.org | cddc71f | 2012-12-07 12:40:13 +0000 | [diff] [blame] | 159 | static const int kMaxFixedIndex = (1 << (kFixedIndexWidth - 1)) - 1; |
| 160 | static const int kMinFixedIndex = -(1 << (kFixedIndexWidth - 1)); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 161 | |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 162 | bool HasAnyPolicy() const { |
| 163 | return policy() == ANY; |
| 164 | } |
| 165 | bool HasFixedPolicy() const { |
| 166 | return policy() == FIXED_REGISTER || |
| 167 | policy() == FIXED_DOUBLE_REGISTER || |
| 168 | policy() == FIXED_SLOT; |
| 169 | } |
| 170 | bool HasRegisterPolicy() const { |
| 171 | return policy() == WRITABLE_REGISTER || policy() == MUST_HAVE_REGISTER; |
| 172 | } |
| 173 | bool HasSameAsInputPolicy() const { |
| 174 | return policy() == SAME_AS_FIRST_INPUT; |
| 175 | } |
| 176 | Policy policy() const { return PolicyField::decode(value_); } |
| 177 | void set_policy(Policy policy) { |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 178 | value_ = PolicyField::update(value_, policy); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 179 | } |
| 180 | int fixed_index() const { |
| 181 | return static_cast<int>(value_) >> kFixedIndexShift; |
| 182 | } |
| 183 | |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 184 | int virtual_register() const { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 185 | return VirtualRegisterField::decode(value_); |
| 186 | } |
| 187 | |
| 188 | void set_virtual_register(unsigned id) { |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 189 | value_ = VirtualRegisterField::update(value_, id); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 190 | } |
| 191 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 192 | LUnallocated* CopyUnconstrained(Zone* zone) { |
| 193 | LUnallocated* result = new(zone) LUnallocated(ANY); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 194 | result->set_virtual_register(virtual_register()); |
| 195 | return result; |
| 196 | } |
| 197 | |
| 198 | static LUnallocated* cast(LOperand* op) { |
| 199 | ASSERT(op->IsUnallocated()); |
| 200 | return reinterpret_cast<LUnallocated*>(op); |
| 201 | } |
| 202 | |
| 203 | bool IsUsedAtStart() { |
| 204 | return LifetimeField::decode(value_) == USED_AT_START; |
| 205 | } |
| 206 | |
| 207 | private: |
| 208 | void Initialize(Policy policy, int fixed_index, Lifetime lifetime) { |
| 209 | value_ |= PolicyField::encode(policy); |
| 210 | value_ |= LifetimeField::encode(lifetime); |
| 211 | value_ |= fixed_index << kFixedIndexShift; |
| 212 | ASSERT(this->fixed_index() == fixed_index); |
| 213 | } |
| 214 | }; |
| 215 | |
| 216 | |
| 217 | class LMoveOperands BASE_EMBEDDED { |
| 218 | public: |
| 219 | LMoveOperands(LOperand* source, LOperand* destination) |
| 220 | : source_(source), destination_(destination) { |
| 221 | } |
| 222 | |
| 223 | LOperand* source() const { return source_; } |
| 224 | void set_source(LOperand* operand) { source_ = operand; } |
| 225 | |
| 226 | LOperand* destination() const { return destination_; } |
| 227 | void set_destination(LOperand* operand) { destination_ = operand; } |
| 228 | |
| 229 | // The gap resolver marks moves as "in-progress" by clearing the |
| 230 | // destination (but not the source). |
| 231 | bool IsPending() const { |
| 232 | return destination_ == NULL && source_ != NULL; |
| 233 | } |
| 234 | |
| 235 | // True if this move a move into the given destination operand. |
| 236 | bool Blocks(LOperand* operand) const { |
| 237 | return !IsEliminated() && source()->Equals(operand); |
| 238 | } |
| 239 | |
| 240 | // A move is redundant if it's been eliminated, if its source and |
| 241 | // destination are the same, or if its destination is unneeded. |
| 242 | bool IsRedundant() const { |
| 243 | return IsEliminated() || source_->Equals(destination_) || IsIgnored(); |
| 244 | } |
| 245 | |
| 246 | bool IsIgnored() const { |
yangguo@chromium.org | 659ceec | 2012-01-26 07:37:54 +0000 | [diff] [blame] | 247 | return destination_ != NULL && destination_->IsIgnored(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 248 | } |
| 249 | |
| 250 | // We clear both operands to indicate move that's been eliminated. |
| 251 | void Eliminate() { source_ = destination_ = NULL; } |
| 252 | bool IsEliminated() const { |
| 253 | ASSERT(source_ != NULL || destination_ == NULL); |
| 254 | return source_ == NULL; |
| 255 | } |
| 256 | |
| 257 | private: |
| 258 | LOperand* source_; |
| 259 | LOperand* destination_; |
| 260 | }; |
| 261 | |
| 262 | |
| 263 | class LConstantOperand: public LOperand { |
| 264 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 265 | static LConstantOperand* Create(int index, Zone* zone) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 266 | ASSERT(index >= 0); |
| 267 | if (index < kNumCachedOperands) return &cache[index]; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 268 | return new(zone) LConstantOperand(index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 269 | } |
| 270 | |
| 271 | static LConstantOperand* cast(LOperand* op) { |
| 272 | ASSERT(op->IsConstantOperand()); |
| 273 | return reinterpret_cast<LConstantOperand*>(op); |
| 274 | } |
| 275 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 276 | static void SetUpCache(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 277 | static void TearDownCache(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 278 | |
| 279 | private: |
| 280 | static const int kNumCachedOperands = 128; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 281 | static LConstantOperand* cache; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 282 | |
| 283 | LConstantOperand() : LOperand() { } |
| 284 | explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } |
| 285 | }; |
| 286 | |
| 287 | |
| 288 | class LArgument: public LOperand { |
| 289 | public: |
| 290 | explicit LArgument(int index) : LOperand(ARGUMENT, index) { } |
| 291 | |
| 292 | static LArgument* cast(LOperand* op) { |
| 293 | ASSERT(op->IsArgument()); |
| 294 | return reinterpret_cast<LArgument*>(op); |
| 295 | } |
| 296 | }; |
| 297 | |
| 298 | |
| 299 | class LStackSlot: public LOperand { |
| 300 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 301 | static LStackSlot* Create(int index, Zone* zone) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 302 | ASSERT(index >= 0); |
| 303 | if (index < kNumCachedOperands) return &cache[index]; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 304 | return new(zone) LStackSlot(index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 305 | } |
| 306 | |
| 307 | static LStackSlot* cast(LOperand* op) { |
| 308 | ASSERT(op->IsStackSlot()); |
| 309 | return reinterpret_cast<LStackSlot*>(op); |
| 310 | } |
| 311 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 312 | static void SetUpCache(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 313 | static void TearDownCache(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 314 | |
| 315 | private: |
| 316 | static const int kNumCachedOperands = 128; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 317 | static LStackSlot* cache; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 318 | |
| 319 | LStackSlot() : LOperand() { } |
| 320 | explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { } |
| 321 | }; |
| 322 | |
| 323 | |
| 324 | class LDoubleStackSlot: public LOperand { |
| 325 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 326 | static LDoubleStackSlot* Create(int index, Zone* zone) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 327 | ASSERT(index >= 0); |
| 328 | if (index < kNumCachedOperands) return &cache[index]; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 329 | return new(zone) LDoubleStackSlot(index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 330 | } |
| 331 | |
| 332 | static LDoubleStackSlot* cast(LOperand* op) { |
| 333 | ASSERT(op->IsStackSlot()); |
| 334 | return reinterpret_cast<LDoubleStackSlot*>(op); |
| 335 | } |
| 336 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 337 | static void SetUpCache(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 338 | static void TearDownCache(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 339 | |
| 340 | private: |
| 341 | static const int kNumCachedOperands = 128; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 342 | static LDoubleStackSlot* cache; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 343 | |
| 344 | LDoubleStackSlot() : LOperand() { } |
| 345 | explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { } |
| 346 | }; |
| 347 | |
| 348 | |
| 349 | class LRegister: public LOperand { |
| 350 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 351 | static LRegister* Create(int index, Zone* zone) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 352 | ASSERT(index >= 0); |
| 353 | if (index < kNumCachedOperands) return &cache[index]; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 354 | return new(zone) LRegister(index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | static LRegister* cast(LOperand* op) { |
| 358 | ASSERT(op->IsRegister()); |
| 359 | return reinterpret_cast<LRegister*>(op); |
| 360 | } |
| 361 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 362 | static void SetUpCache(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 363 | static void TearDownCache(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 364 | |
| 365 | private: |
| 366 | static const int kNumCachedOperands = 16; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 367 | static LRegister* cache; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 368 | |
| 369 | LRegister() : LOperand() { } |
| 370 | explicit LRegister(int index) : LOperand(REGISTER, index) { } |
| 371 | }; |
| 372 | |
| 373 | |
| 374 | class LDoubleRegister: public LOperand { |
| 375 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 376 | static LDoubleRegister* Create(int index, Zone* zone) { |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 377 | ASSERT(index >= 0); |
| 378 | if (index < kNumCachedOperands) return &cache[index]; |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 379 | return new(zone) LDoubleRegister(index); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | static LDoubleRegister* cast(LOperand* op) { |
| 383 | ASSERT(op->IsDoubleRegister()); |
| 384 | return reinterpret_cast<LDoubleRegister*>(op); |
| 385 | } |
| 386 | |
erik.corry@gmail.com | f2038fb | 2012-01-16 11:42:08 +0000 | [diff] [blame] | 387 | static void SetUpCache(); |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 388 | static void TearDownCache(); |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 389 | |
| 390 | private: |
| 391 | static const int kNumCachedOperands = 16; |
jkummerow@chromium.org | 1456e70 | 2012-03-30 08:38:13 +0000 | [diff] [blame] | 392 | static LDoubleRegister* cache; |
vegorov@chromium.org | 0a4e901 | 2011-01-24 12:33:13 +0000 | [diff] [blame] | 393 | |
| 394 | LDoubleRegister() : LOperand() { } |
| 395 | explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { } |
| 396 | }; |
| 397 | |
| 398 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 399 | class LParallelMove : public ZoneObject { |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 400 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 401 | explicit LParallelMove(Zone* zone) : move_operands_(4, zone) { } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 402 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 403 | void AddMove(LOperand* from, LOperand* to, Zone* zone) { |
| 404 | move_operands_.Add(LMoveOperands(from, to), zone); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 405 | } |
| 406 | |
| 407 | bool IsRedundant() const; |
| 408 | |
| 409 | const ZoneList<LMoveOperands>* move_operands() const { |
| 410 | return &move_operands_; |
| 411 | } |
| 412 | |
| 413 | void PrintDataTo(StringStream* stream) const; |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 414 | |
| 415 | private: |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 416 | ZoneList<LMoveOperands> move_operands_; |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 417 | }; |
| 418 | |
| 419 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 420 | class LPointerMap: public ZoneObject { |
| 421 | public: |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 422 | explicit LPointerMap(int position, Zone* zone) |
| 423 | : pointer_operands_(8, zone), |
| 424 | untagged_operands_(0, zone), |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 425 | position_(position), |
| 426 | lithium_position_(-1) { } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 427 | |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 428 | const ZoneList<LOperand*>* GetNormalizedOperands() { |
| 429 | for (int i = 0; i < untagged_operands_.length(); ++i) { |
| 430 | RemovePointer(untagged_operands_[i]); |
| 431 | } |
| 432 | untagged_operands_.Clear(); |
| 433 | return &pointer_operands_; |
| 434 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 435 | int position() const { return position_; } |
| 436 | int lithium_position() const { return lithium_position_; } |
| 437 | |
| 438 | void set_lithium_position(int pos) { |
| 439 | ASSERT(lithium_position_ == -1); |
| 440 | lithium_position_ = pos; |
| 441 | } |
| 442 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 443 | void RecordPointer(LOperand* op, Zone* zone); |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 444 | void RemovePointer(LOperand* op); |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 445 | void RecordUntagged(LOperand* op, Zone* zone); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 446 | void PrintTo(StringStream* stream); |
| 447 | |
| 448 | private: |
| 449 | ZoneList<LOperand*> pointer_operands_; |
erik.corry@gmail.com | c3b670f | 2011-10-05 21:44:48 +0000 | [diff] [blame] | 450 | ZoneList<LOperand*> untagged_operands_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 451 | int position_; |
| 452 | int lithium_position_; |
| 453 | }; |
| 454 | |
| 455 | |
| 456 | class LEnvironment: public ZoneObject { |
| 457 | public: |
| 458 | LEnvironment(Handle<JSFunction> closure, |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 459 | FrameType frame_type, |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 460 | BailoutId ast_id, |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 461 | int parameter_count, |
| 462 | int argument_count, |
| 463 | int value_count, |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 464 | LEnvironment* outer, |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 465 | HEnterInlined* entry, |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 466 | Zone* zone) |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 467 | : closure_(closure), |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 468 | frame_type_(frame_type), |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 469 | arguments_stack_height_(argument_count), |
| 470 | deoptimization_index_(Safepoint::kNoDeoptimizationIndex), |
| 471 | translation_index_(-1), |
| 472 | ast_id_(ast_id), |
| 473 | parameter_count_(parameter_count), |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 474 | pc_offset_(-1), |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 475 | values_(value_count, zone), |
yangguo@chromium.org | 5a11aaf | 2012-06-20 11:29:00 +0000 | [diff] [blame] | 476 | is_tagged_(value_count, zone), |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 477 | is_uint32_(value_count, zone), |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 478 | spilled_registers_(NULL), |
| 479 | spilled_double_registers_(NULL), |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 480 | outer_(outer), |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 481 | entry_(entry), |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 482 | zone_(zone) { } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 483 | |
| 484 | Handle<JSFunction> closure() const { return closure_; } |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 485 | FrameType frame_type() const { return frame_type_; } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 486 | int arguments_stack_height() const { return arguments_stack_height_; } |
| 487 | int deoptimization_index() const { return deoptimization_index_; } |
| 488 | int translation_index() const { return translation_index_; } |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 489 | BailoutId ast_id() const { return ast_id_; } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 490 | int parameter_count() const { return parameter_count_; } |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 491 | int pc_offset() const { return pc_offset_; } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 492 | LOperand** spilled_registers() const { return spilled_registers_; } |
| 493 | LOperand** spilled_double_registers() const { |
| 494 | return spilled_double_registers_; |
| 495 | } |
| 496 | const ZoneList<LOperand*>* values() const { return &values_; } |
| 497 | LEnvironment* outer() const { return outer_; } |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 498 | HEnterInlined* entry() { return entry_; } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 499 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 500 | void AddValue(LOperand* operand, |
| 501 | Representation representation, |
| 502 | bool is_uint32) { |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 503 | values_.Add(operand, zone()); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 504 | if (representation.IsTagged()) { |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 505 | ASSERT(!is_uint32); |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 506 | is_tagged_.Add(values_.length() - 1); |
| 507 | } |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 508 | |
| 509 | if (is_uint32) { |
| 510 | is_uint32_.Add(values_.length() - 1); |
| 511 | } |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | bool HasTaggedValueAt(int index) const { |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 515 | return is_tagged_.Contains(index); |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 516 | } |
| 517 | |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 518 | bool HasUint32ValueAt(int index) const { |
| 519 | return is_uint32_.Contains(index); |
| 520 | } |
| 521 | |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 522 | void Register(int deoptimization_index, |
| 523 | int translation_index, |
| 524 | int pc_offset) { |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 525 | ASSERT(!HasBeenRegistered()); |
| 526 | deoptimization_index_ = deoptimization_index; |
| 527 | translation_index_ = translation_index; |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 528 | pc_offset_ = pc_offset; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 529 | } |
| 530 | bool HasBeenRegistered() const { |
| 531 | return deoptimization_index_ != Safepoint::kNoDeoptimizationIndex; |
| 532 | } |
| 533 | |
| 534 | void SetSpilledRegisters(LOperand** registers, |
| 535 | LOperand** double_registers) { |
| 536 | spilled_registers_ = registers; |
| 537 | spilled_double_registers_ = double_registers; |
| 538 | } |
| 539 | |
| 540 | void PrintTo(StringStream* stream); |
| 541 | |
mmassi@chromium.org | 7028c05 | 2012-06-13 11:51:58 +0000 | [diff] [blame] | 542 | Zone* zone() const { return zone_; } |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 543 | |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 544 | private: |
| 545 | Handle<JSFunction> closure_; |
ulan@chromium.org | 967e270 | 2012-02-28 09:49:15 +0000 | [diff] [blame] | 546 | FrameType frame_type_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 547 | int arguments_stack_height_; |
| 548 | int deoptimization_index_; |
| 549 | int translation_index_; |
mstarzinger@chromium.org | 471f2f1 | 2012-08-10 14:46:33 +0000 | [diff] [blame] | 550 | BailoutId ast_id_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 551 | int parameter_count_; |
ricow@chromium.org | 27bf288 | 2011-11-17 08:34:43 +0000 | [diff] [blame] | 552 | int pc_offset_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 553 | ZoneList<LOperand*> values_; |
danno@chromium.org | fa458e4 | 2012-02-01 10:48:36 +0000 | [diff] [blame] | 554 | BitVector is_tagged_; |
yangguo@chromium.org | 46839fb | 2012-08-28 09:06:19 +0000 | [diff] [blame] | 555 | BitVector is_uint32_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 556 | |
| 557 | // Allocation index indexed arrays of spill slot operands for registers |
| 558 | // that are also in spill slots at an OSR entry. NULL for environments |
| 559 | // that do not correspond to an OSR entry. |
| 560 | LOperand** spilled_registers_; |
| 561 | LOperand** spilled_double_registers_; |
| 562 | |
| 563 | LEnvironment* outer_; |
ulan@chromium.org | 56c14af | 2012-09-20 12:51:09 +0000 | [diff] [blame] | 564 | HEnterInlined* entry_; |
rossberg@chromium.org | 400388e | 2012-06-06 09:29:22 +0000 | [diff] [blame] | 565 | |
| 566 | Zone* zone_; |
sgjesse@chromium.org | c6c5718 | 2011-01-17 12:24:25 +0000 | [diff] [blame] | 567 | }; |
| 568 | |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 569 | |
| 570 | // Iterates over the non-null, non-constant operands in an environment. |
| 571 | class ShallowIterator BASE_EMBEDDED { |
| 572 | public: |
| 573 | explicit ShallowIterator(LEnvironment* env) |
| 574 | : env_(env), |
| 575 | limit_(env != NULL ? env->values()->length() : 0), |
| 576 | current_(0) { |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 577 | SkipUninteresting(); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 578 | } |
| 579 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 580 | bool Done() { return current_ >= limit_; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 581 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 582 | LOperand* Current() { |
| 583 | ASSERT(!Done()); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 584 | ASSERT(env_->values()->at(current_) != NULL); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 585 | return env_->values()->at(current_); |
| 586 | } |
| 587 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 588 | void Advance() { |
| 589 | ASSERT(!Done()); |
| 590 | ++current_; |
| 591 | SkipUninteresting(); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 592 | } |
| 593 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 594 | LEnvironment* env() { return env_; } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 595 | |
| 596 | private: |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 597 | bool ShouldSkip(LOperand* op) { |
fschneider@chromium.org | 3a5fd78 | 2011-02-24 10:10:44 +0000 | [diff] [blame] | 598 | return op == NULL || op->IsConstantOperand() || op->IsArgument(); |
| 599 | } |
| 600 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 601 | // Skip until something interesting, beginning with and including current_. |
| 602 | void SkipUninteresting() { |
| 603 | while (current_ < limit_ && ShouldSkip(env_->values()->at(current_))) { |
| 604 | ++current_; |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 605 | } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 606 | } |
| 607 | |
| 608 | LEnvironment* env_; |
| 609 | int limit_; |
| 610 | int current_; |
| 611 | }; |
| 612 | |
| 613 | |
| 614 | // Iterator for non-null, non-constant operands incl. outer environments. |
| 615 | class DeepIterator BASE_EMBEDDED { |
| 616 | public: |
| 617 | explicit DeepIterator(LEnvironment* env) |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 618 | : current_iterator_(env) { |
| 619 | SkipUninteresting(); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 620 | } |
| 621 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 622 | bool Done() { return current_iterator_.Done(); } |
| 623 | |
| 624 | LOperand* Current() { |
| 625 | ASSERT(!current_iterator_.Done()); |
yangguo@chromium.org | 4cd70b4 | 2013-01-04 08:57:54 +0000 | [diff] [blame] | 626 | ASSERT(current_iterator_.Current() != NULL); |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 627 | return current_iterator_.Current(); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 628 | } |
| 629 | |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 630 | void Advance() { |
| 631 | current_iterator_.Advance(); |
| 632 | SkipUninteresting(); |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 633 | } |
| 634 | |
| 635 | private: |
jkummerow@chromium.org | e297f59 | 2011-06-08 10:05:15 +0000 | [diff] [blame] | 636 | void SkipUninteresting() { |
| 637 | while (current_iterator_.env() != NULL && current_iterator_.Done()) { |
| 638 | current_iterator_ = ShallowIterator(current_iterator_.env()->outer()); |
| 639 | } |
ricow@chromium.org | 83aa549 | 2011-02-07 12:42:56 +0000 | [diff] [blame] | 640 | } |
| 641 | |
| 642 | ShallowIterator current_iterator_; |
| 643 | }; |
| 644 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 645 | |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 646 | class LPlatformChunk; |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 647 | class LGap; |
| 648 | class LLabel; |
| 649 | |
| 650 | // Superclass providing data and behavior common to all the |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 651 | // arch-specific LPlatformChunk classes. |
| 652 | class LChunk: public ZoneObject { |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 653 | public: |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 654 | static LChunk* NewChunk(HGraph* graph); |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 655 | |
| 656 | void AddInstruction(LInstruction* instruction, HBasicBlock* block); |
| 657 | LConstantOperand* DefineConstantOperand(HConstant* constant); |
| 658 | HConstant* LookupConstant(LConstantOperand* operand) const; |
| 659 | Representation LookupLiteralRepresentation(LConstantOperand* operand) const; |
| 660 | |
| 661 | int ParameterAt(int index); |
| 662 | int GetParameterStackSlot(int index) const; |
| 663 | int spill_slot_count() const { return spill_slot_count_; } |
| 664 | CompilationInfo* info() const { return info_; } |
| 665 | HGraph* graph() const { return graph_; } |
| 666 | const ZoneList<LInstruction*>* instructions() const { return &instructions_; } |
| 667 | void AddGapMove(int index, LOperand* from, LOperand* to); |
| 668 | LGap* GetGapAt(int index) const; |
| 669 | bool IsGapAt(int index) const; |
| 670 | int NearestGapPos(int index) const; |
| 671 | void MarkEmptyBlocks(); |
| 672 | const ZoneList<LPointerMap*>* pointer_maps() const { return &pointer_maps_; } |
| 673 | LLabel* GetLabel(int block_id) const; |
| 674 | int LookupDestination(int block_id) const; |
| 675 | Label* GetAssemblyLabel(int block_id) const; |
| 676 | |
| 677 | const ZoneList<Handle<JSFunction> >* inlined_closures() const { |
| 678 | return &inlined_closures_; |
| 679 | } |
| 680 | |
| 681 | void AddInlinedClosure(Handle<JSFunction> closure) { |
| 682 | inlined_closures_.Add(closure, zone()); |
| 683 | } |
| 684 | |
| 685 | Zone* zone() const { return info_->zone(); } |
| 686 | |
yangguo@chromium.org | a6bbcc8 | 2012-12-21 12:35:02 +0000 | [diff] [blame] | 687 | Handle<Code> Codegen(Code::Kind kind); |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 688 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 689 | void set_allocated_double_registers(BitVector* allocated_registers); |
| 690 | BitVector* allocated_double_registers() { |
| 691 | return allocated_double_registers_; |
| 692 | } |
| 693 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 694 | protected: |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 695 | LChunk(CompilationInfo* info, HGraph* graph); |
jkummerow@chromium.org | 28583c9 | 2012-07-16 11:31:55 +0000 | [diff] [blame] | 696 | |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 697 | int spill_slot_count_; |
| 698 | |
| 699 | private: |
| 700 | CompilationInfo* info_; |
| 701 | HGraph* const graph_; |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 702 | BitVector* allocated_double_registers_; |
rossberg@chromium.org | 657d53b | 2012-07-12 11:06:03 +0000 | [diff] [blame] | 703 | ZoneList<LInstruction*> instructions_; |
| 704 | ZoneList<LPointerMap*> pointer_maps_; |
| 705 | ZoneList<Handle<JSFunction> > inlined_closures_; |
| 706 | }; |
| 707 | |
| 708 | |
kmillikin@chromium.org | 83e1682 | 2011-09-13 08:21:47 +0000 | [diff] [blame] | 709 | int ElementsKindToShiftSize(ElementsKind elements_kind); |
jkummerow@chromium.org | ac36071 | 2013-02-11 09:00:07 +0000 | [diff] [blame] | 710 | int StackSlotOffset(int index); |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 711 | |
danno@chromium.org | 94b0d6f | 2013-02-04 13:33:20 +0000 | [diff] [blame] | 712 | enum NumberUntagDMode { |
| 713 | NUMBER_CANDIDATE_IS_SMI, |
| 714 | NUMBER_CANDIDATE_IS_SMI_OR_HOLE, |
| 715 | NUMBER_CANDIDATE_IS_SMI_CONVERT_HOLE, |
| 716 | NUMBER_CANDIDATE_IS_ANY_TAGGED |
| 717 | }; |
| 718 | |
karlklose@chromium.org | 83a4728 | 2011-05-11 11:54:09 +0000 | [diff] [blame] | 719 | |
kmillikin@chromium.org | d2c22f0 | 2011-01-10 08:15:37 +0000 | [diff] [blame] | 720 | } } // namespace v8::internal |
| 721 | |
| 722 | #endif // V8_LITHIUM_H_ |