OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 bool IsIgnored() const { return kind() == INVALID; } | 62 bool IsIgnored() const { return kind() == INVALID; } |
63 bool Equals(LOperand* other) const { return value_ == other->value_; } | 63 bool Equals(LOperand* other) const { return value_ == other->value_; } |
64 | 64 |
65 void PrintTo(StringStream* stream); | 65 void PrintTo(StringStream* stream); |
66 void ConvertTo(Kind kind, int index) { | 66 void ConvertTo(Kind kind, int index) { |
67 value_ = KindField::encode(kind); | 67 value_ = KindField::encode(kind); |
68 value_ |= index << kKindFieldWidth; | 68 value_ |= index << kKindFieldWidth; |
69 ASSERT(this->index() == index); | 69 ASSERT(this->index() == index); |
70 } | 70 } |
71 | 71 |
72 // Calls SetUpCache() for each subclass. Don't forget to update this method | |
73 // if you add a new LOperand subclass. | |
74 static void SetUpCaches(); | |
75 | |
76 protected: | 72 protected: |
77 static const int kKindFieldWidth = 3; | 73 static const int kKindFieldWidth = 3; |
78 class KindField : public BitField<Kind, 0, kKindFieldWidth> { }; | 74 class KindField : public BitField<Kind, 0, kKindFieldWidth> { }; |
79 | 75 |
80 LOperand(Kind kind, int index) { ConvertTo(kind, index); } | 76 LOperand(Kind kind, int index) { ConvertTo(kind, index); } |
81 | 77 |
82 unsigned value_; | 78 unsigned value_; |
83 }; | 79 }; |
84 | 80 |
85 | 81 |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 | 257 |
262 static LConstantOperand* cast(LOperand* op) { | 258 static LConstantOperand* cast(LOperand* op) { |
263 ASSERT(op->IsConstantOperand()); | 259 ASSERT(op->IsConstantOperand()); |
264 return reinterpret_cast<LConstantOperand*>(op); | 260 return reinterpret_cast<LConstantOperand*>(op); |
265 } | 261 } |
266 | 262 |
267 static void SetUpCache(); | 263 static void SetUpCache(); |
268 | 264 |
269 private: | 265 private: |
270 static const int kNumCachedOperands = 128; | 266 static const int kNumCachedOperands = 128; |
271 static LConstantOperand* cache; | 267 static LConstantOperand cache[]; |
272 | 268 |
273 LConstantOperand() : LOperand() { } | 269 LConstantOperand() : LOperand() { } |
274 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } | 270 explicit LConstantOperand(int index) : LOperand(CONSTANT_OPERAND, index) { } |
275 }; | 271 }; |
276 | 272 |
277 | 273 |
278 class LArgument: public LOperand { | 274 class LArgument: public LOperand { |
279 public: | 275 public: |
280 explicit LArgument(int index) : LOperand(ARGUMENT, index) { } | 276 explicit LArgument(int index) : LOperand(ARGUMENT, index) { } |
281 | 277 |
(...skipping 14 matching lines...) Expand all Loading... |
296 | 292 |
297 static LStackSlot* cast(LOperand* op) { | 293 static LStackSlot* cast(LOperand* op) { |
298 ASSERT(op->IsStackSlot()); | 294 ASSERT(op->IsStackSlot()); |
299 return reinterpret_cast<LStackSlot*>(op); | 295 return reinterpret_cast<LStackSlot*>(op); |
300 } | 296 } |
301 | 297 |
302 static void SetUpCache(); | 298 static void SetUpCache(); |
303 | 299 |
304 private: | 300 private: |
305 static const int kNumCachedOperands = 128; | 301 static const int kNumCachedOperands = 128; |
306 static LStackSlot* cache; | 302 static LStackSlot cache[]; |
307 | 303 |
308 LStackSlot() : LOperand() { } | 304 LStackSlot() : LOperand() { } |
309 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { } | 305 explicit LStackSlot(int index) : LOperand(STACK_SLOT, index) { } |
310 }; | 306 }; |
311 | 307 |
312 | 308 |
313 class LDoubleStackSlot: public LOperand { | 309 class LDoubleStackSlot: public LOperand { |
314 public: | 310 public: |
315 static LDoubleStackSlot* Create(int index) { | 311 static LDoubleStackSlot* Create(int index) { |
316 ASSERT(index >= 0); | 312 ASSERT(index >= 0); |
317 if (index < kNumCachedOperands) return &cache[index]; | 313 if (index < kNumCachedOperands) return &cache[index]; |
318 return new LDoubleStackSlot(index); | 314 return new LDoubleStackSlot(index); |
319 } | 315 } |
320 | 316 |
321 static LDoubleStackSlot* cast(LOperand* op) { | 317 static LDoubleStackSlot* cast(LOperand* op) { |
322 ASSERT(op->IsStackSlot()); | 318 ASSERT(op->IsStackSlot()); |
323 return reinterpret_cast<LDoubleStackSlot*>(op); | 319 return reinterpret_cast<LDoubleStackSlot*>(op); |
324 } | 320 } |
325 | 321 |
326 static void SetUpCache(); | 322 static void SetUpCache(); |
327 | 323 |
328 private: | 324 private: |
329 static const int kNumCachedOperands = 128; | 325 static const int kNumCachedOperands = 128; |
330 static LDoubleStackSlot* cache; | 326 static LDoubleStackSlot cache[]; |
331 | 327 |
332 LDoubleStackSlot() : LOperand() { } | 328 LDoubleStackSlot() : LOperand() { } |
333 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { } | 329 explicit LDoubleStackSlot(int index) : LOperand(DOUBLE_STACK_SLOT, index) { } |
334 }; | 330 }; |
335 | 331 |
336 | 332 |
337 class LRegister: public LOperand { | 333 class LRegister: public LOperand { |
338 public: | 334 public: |
339 static LRegister* Create(int index) { | 335 static LRegister* Create(int index) { |
340 ASSERT(index >= 0); | 336 ASSERT(index >= 0); |
341 if (index < kNumCachedOperands) return &cache[index]; | 337 if (index < kNumCachedOperands) return &cache[index]; |
342 return new LRegister(index); | 338 return new LRegister(index); |
343 } | 339 } |
344 | 340 |
345 static LRegister* cast(LOperand* op) { | 341 static LRegister* cast(LOperand* op) { |
346 ASSERT(op->IsRegister()); | 342 ASSERT(op->IsRegister()); |
347 return reinterpret_cast<LRegister*>(op); | 343 return reinterpret_cast<LRegister*>(op); |
348 } | 344 } |
349 | 345 |
350 static void SetUpCache(); | 346 static void SetUpCache(); |
351 | 347 |
352 private: | 348 private: |
353 static const int kNumCachedOperands = 16; | 349 static const int kNumCachedOperands = 16; |
354 static LRegister* cache; | 350 static LRegister cache[]; |
355 | 351 |
356 LRegister() : LOperand() { } | 352 LRegister() : LOperand() { } |
357 explicit LRegister(int index) : LOperand(REGISTER, index) { } | 353 explicit LRegister(int index) : LOperand(REGISTER, index) { } |
358 }; | 354 }; |
359 | 355 |
360 | 356 |
361 class LDoubleRegister: public LOperand { | 357 class LDoubleRegister: public LOperand { |
362 public: | 358 public: |
363 static LDoubleRegister* Create(int index) { | 359 static LDoubleRegister* Create(int index) { |
364 ASSERT(index >= 0); | 360 ASSERT(index >= 0); |
365 if (index < kNumCachedOperands) return &cache[index]; | 361 if (index < kNumCachedOperands) return &cache[index]; |
366 return new LDoubleRegister(index); | 362 return new LDoubleRegister(index); |
367 } | 363 } |
368 | 364 |
369 static LDoubleRegister* cast(LOperand* op) { | 365 static LDoubleRegister* cast(LOperand* op) { |
370 ASSERT(op->IsDoubleRegister()); | 366 ASSERT(op->IsDoubleRegister()); |
371 return reinterpret_cast<LDoubleRegister*>(op); | 367 return reinterpret_cast<LDoubleRegister*>(op); |
372 } | 368 } |
373 | 369 |
374 static void SetUpCache(); | 370 static void SetUpCache(); |
375 | 371 |
376 private: | 372 private: |
377 static const int kNumCachedOperands = 16; | 373 static const int kNumCachedOperands = 16; |
378 static LDoubleRegister* cache; | 374 static LDoubleRegister cache[]; |
379 | 375 |
380 LDoubleRegister() : LOperand() { } | 376 LDoubleRegister() : LOperand() { } |
381 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { } | 377 explicit LDoubleRegister(int index) : LOperand(DOUBLE_REGISTER, index) { } |
382 }; | 378 }; |
383 | 379 |
384 | 380 |
385 class LParallelMove : public ZoneObject { | 381 class LParallelMove : public ZoneObject { |
386 public: | 382 public: |
387 LParallelMove() : move_operands_(4) { } | 383 LParallelMove() : move_operands_(4) { } |
388 | 384 |
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
603 ShallowIterator current_iterator_; | 599 ShallowIterator current_iterator_; |
604 }; | 600 }; |
605 | 601 |
606 | 602 |
607 int ElementsKindToShiftSize(ElementsKind elements_kind); | 603 int ElementsKindToShiftSize(ElementsKind elements_kind); |
608 | 604 |
609 | 605 |
610 } } // namespace v8::internal | 606 } } // namespace v8::internal |
611 | 607 |
612 #endif // V8_LITHIUM_H_ | 608 #endif // V8_LITHIUM_H_ |
OLD | NEW |