| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_LITHIUM_H_ | 5 #ifndef V8_LITHIUM_H_ |
| 6 #define V8_LITHIUM_H_ | 6 #define V8_LITHIUM_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 } | 247 } |
| 248 | 248 |
| 249 // [lifetime]: Only for non-FIXED_SLOT. | 249 // [lifetime]: Only for non-FIXED_SLOT. |
| 250 bool IsUsedAtStart() { | 250 bool IsUsedAtStart() { |
| 251 DCHECK(basic_policy() == EXTENDED_POLICY); | 251 DCHECK(basic_policy() == EXTENDED_POLICY); |
| 252 return LifetimeField::decode(value_) == USED_AT_START; | 252 return LifetimeField::decode(value_) == USED_AT_START; |
| 253 } | 253 } |
| 254 }; | 254 }; |
| 255 | 255 |
| 256 | 256 |
| 257 class LMoveOperands V8_FINAL BASE_EMBEDDED { | 257 class LMoveOperands FINAL BASE_EMBEDDED { |
| 258 public: | 258 public: |
| 259 LMoveOperands(LOperand* source, LOperand* destination) | 259 LMoveOperands(LOperand* source, LOperand* destination) |
| 260 : source_(source), destination_(destination) { | 260 : source_(source), destination_(destination) { |
| 261 } | 261 } |
| 262 | 262 |
| 263 LOperand* source() const { return source_; } | 263 LOperand* source() const { return source_; } |
| 264 void set_source(LOperand* operand) { source_ = operand; } | 264 void set_source(LOperand* operand) { source_ = operand; } |
| 265 | 265 |
| 266 LOperand* destination() const { return destination_; } | 266 LOperand* destination() const { return destination_; } |
| 267 void set_destination(LOperand* operand) { destination_ = operand; } | 267 void set_destination(LOperand* operand) { destination_ = operand; } |
| (...skipping 27 matching lines...) Expand all Loading... |
| 295 return source_ == NULL; | 295 return source_ == NULL; |
| 296 } | 296 } |
| 297 | 297 |
| 298 private: | 298 private: |
| 299 LOperand* source_; | 299 LOperand* source_; |
| 300 LOperand* destination_; | 300 LOperand* destination_; |
| 301 }; | 301 }; |
| 302 | 302 |
| 303 | 303 |
| 304 template<LOperand::Kind kOperandKind, int kNumCachedOperands> | 304 template<LOperand::Kind kOperandKind, int kNumCachedOperands> |
| 305 class LSubKindOperand V8_FINAL : public LOperand { | 305 class LSubKindOperand FINAL : public LOperand { |
| 306 public: | 306 public: |
| 307 static LSubKindOperand* Create(int index, Zone* zone) { | 307 static LSubKindOperand* Create(int index, Zone* zone) { |
| 308 DCHECK(index >= 0); | 308 DCHECK(index >= 0); |
| 309 if (index < kNumCachedOperands) return &cache[index]; | 309 if (index < kNumCachedOperands) return &cache[index]; |
| 310 return new(zone) LSubKindOperand(index); | 310 return new(zone) LSubKindOperand(index); |
| 311 } | 311 } |
| 312 | 312 |
| 313 static LSubKindOperand* cast(LOperand* op) { | 313 static LSubKindOperand* cast(LOperand* op) { |
| 314 DCHECK(op->kind() == kOperandKind); | 314 DCHECK(op->kind() == kOperandKind); |
| 315 return reinterpret_cast<LSubKindOperand*>(op); | 315 return reinterpret_cast<LSubKindOperand*>(op); |
| 316 } | 316 } |
| 317 | 317 |
| 318 static void SetUpCache(); | 318 static void SetUpCache(); |
| 319 static void TearDownCache(); | 319 static void TearDownCache(); |
| 320 | 320 |
| 321 private: | 321 private: |
| 322 static LSubKindOperand* cache; | 322 static LSubKindOperand* cache; |
| 323 | 323 |
| 324 LSubKindOperand() : LOperand() { } | 324 LSubKindOperand() : LOperand() { } |
| 325 explicit LSubKindOperand(int index) : LOperand(kOperandKind, index) { } | 325 explicit LSubKindOperand(int index) : LOperand(kOperandKind, index) { } |
| 326 }; | 326 }; |
| 327 | 327 |
| 328 | 328 |
| 329 #define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number) \ | 329 #define LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS(name, type, number) \ |
| 330 typedef LSubKindOperand<LOperand::type, number> L##name; | 330 typedef LSubKindOperand<LOperand::type, number> L##name; |
| 331 LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS) | 331 LITHIUM_OPERAND_LIST(LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS) |
| 332 #undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS | 332 #undef LITHIUM_TYPEDEF_SUBKIND_OPERAND_CLASS |
| 333 | 333 |
| 334 | 334 |
| 335 class LParallelMove V8_FINAL : public ZoneObject { | 335 class LParallelMove FINAL : public ZoneObject { |
| 336 public: | 336 public: |
| 337 explicit LParallelMove(Zone* zone) : move_operands_(4, zone) { } | 337 explicit LParallelMove(Zone* zone) : move_operands_(4, zone) { } |
| 338 | 338 |
| 339 void AddMove(LOperand* from, LOperand* to, Zone* zone) { | 339 void AddMove(LOperand* from, LOperand* to, Zone* zone) { |
| 340 move_operands_.Add(LMoveOperands(from, to), zone); | 340 move_operands_.Add(LMoveOperands(from, to), zone); |
| 341 } | 341 } |
| 342 | 342 |
| 343 bool IsRedundant() const; | 343 bool IsRedundant() const; |
| 344 | 344 |
| 345 ZoneList<LMoveOperands>* move_operands() { return &move_operands_; } | 345 ZoneList<LMoveOperands>* move_operands() { return &move_operands_; } |
| 346 | 346 |
| 347 void PrintDataTo(StringStream* stream) const; | 347 void PrintDataTo(StringStream* stream) const; |
| 348 | 348 |
| 349 private: | 349 private: |
| 350 ZoneList<LMoveOperands> move_operands_; | 350 ZoneList<LMoveOperands> move_operands_; |
| 351 }; | 351 }; |
| 352 | 352 |
| 353 | 353 |
| 354 class LPointerMap V8_FINAL : public ZoneObject { | 354 class LPointerMap FINAL : public ZoneObject { |
| 355 public: | 355 public: |
| 356 explicit LPointerMap(Zone* zone) | 356 explicit LPointerMap(Zone* zone) |
| 357 : pointer_operands_(8, zone), | 357 : pointer_operands_(8, zone), |
| 358 untagged_operands_(0, zone), | 358 untagged_operands_(0, zone), |
| 359 lithium_position_(-1) { } | 359 lithium_position_(-1) { } |
| 360 | 360 |
| 361 const ZoneList<LOperand*>* GetNormalizedOperands() { | 361 const ZoneList<LOperand*>* GetNormalizedOperands() { |
| 362 for (int i = 0; i < untagged_operands_.length(); ++i) { | 362 for (int i = 0; i < untagged_operands_.length(); ++i) { |
| 363 RemovePointer(untagged_operands_[i]); | 363 RemovePointer(untagged_operands_[i]); |
| 364 } | 364 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 377 void RecordUntagged(LOperand* op, Zone* zone); | 377 void RecordUntagged(LOperand* op, Zone* zone); |
| 378 void PrintTo(StringStream* stream); | 378 void PrintTo(StringStream* stream); |
| 379 | 379 |
| 380 private: | 380 private: |
| 381 ZoneList<LOperand*> pointer_operands_; | 381 ZoneList<LOperand*> pointer_operands_; |
| 382 ZoneList<LOperand*> untagged_operands_; | 382 ZoneList<LOperand*> untagged_operands_; |
| 383 int lithium_position_; | 383 int lithium_position_; |
| 384 }; | 384 }; |
| 385 | 385 |
| 386 | 386 |
| 387 class LEnvironment V8_FINAL : public ZoneObject { | 387 class LEnvironment FINAL : public ZoneObject { |
| 388 public: | 388 public: |
| 389 LEnvironment(Handle<JSFunction> closure, | 389 LEnvironment(Handle<JSFunction> closure, |
| 390 FrameType frame_type, | 390 FrameType frame_type, |
| 391 BailoutId ast_id, | 391 BailoutId ast_id, |
| 392 int parameter_count, | 392 int parameter_count, |
| 393 int argument_count, | 393 int argument_count, |
| 394 int value_count, | 394 int value_count, |
| 395 LEnvironment* outer, | 395 LEnvironment* outer, |
| 396 HEnterInlined* entry, | 396 HEnterInlined* entry, |
| 397 Zone* zone) | 397 Zone* zone) |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 527 ZoneList<uint32_t> object_mapping_; | 527 ZoneList<uint32_t> object_mapping_; |
| 528 | 528 |
| 529 LEnvironment* outer_; | 529 LEnvironment* outer_; |
| 530 HEnterInlined* entry_; | 530 HEnterInlined* entry_; |
| 531 Zone* zone_; | 531 Zone* zone_; |
| 532 bool has_been_used_; | 532 bool has_been_used_; |
| 533 }; | 533 }; |
| 534 | 534 |
| 535 | 535 |
| 536 // Iterates over the non-null, non-constant operands in an environment. | 536 // Iterates over the non-null, non-constant operands in an environment. |
| 537 class ShallowIterator V8_FINAL BASE_EMBEDDED { | 537 class ShallowIterator FINAL BASE_EMBEDDED { |
| 538 public: | 538 public: |
| 539 explicit ShallowIterator(LEnvironment* env) | 539 explicit ShallowIterator(LEnvironment* env) |
| 540 : env_(env), | 540 : env_(env), |
| 541 limit_(env != NULL ? env->values()->length() : 0), | 541 limit_(env != NULL ? env->values()->length() : 0), |
| 542 current_(0) { | 542 current_(0) { |
| 543 SkipUninteresting(); | 543 SkipUninteresting(); |
| 544 } | 544 } |
| 545 | 545 |
| 546 bool Done() { return current_ >= limit_; } | 546 bool Done() { return current_ >= limit_; } |
| 547 | 547 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 571 } | 571 } |
| 572 } | 572 } |
| 573 | 573 |
| 574 LEnvironment* env_; | 574 LEnvironment* env_; |
| 575 int limit_; | 575 int limit_; |
| 576 int current_; | 576 int current_; |
| 577 }; | 577 }; |
| 578 | 578 |
| 579 | 579 |
| 580 // Iterator for non-null, non-constant operands incl. outer environments. | 580 // Iterator for non-null, non-constant operands incl. outer environments. |
| 581 class DeepIterator V8_FINAL BASE_EMBEDDED { | 581 class DeepIterator FINAL BASE_EMBEDDED { |
| 582 public: | 582 public: |
| 583 explicit DeepIterator(LEnvironment* env) | 583 explicit DeepIterator(LEnvironment* env) |
| 584 : current_iterator_(env) { | 584 : current_iterator_(env) { |
| 585 SkipUninteresting(); | 585 SkipUninteresting(); |
| 586 } | 586 } |
| 587 | 587 |
| 588 bool Done() { return current_iterator_.Done(); } | 588 bool Done() { return current_iterator_.Done(); } |
| 589 | 589 |
| 590 LOperand* Current() { | 590 LOperand* Current() { |
| 591 DCHECK(!current_iterator_.Done()); | 591 DCHECK(!current_iterator_.Done()); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 private: | 797 private: |
| 798 InputIterator input_iterator_; | 798 InputIterator input_iterator_; |
| 799 DeepIterator env_iterator_; | 799 DeepIterator env_iterator_; |
| 800 }; | 800 }; |
| 801 | 801 |
| 802 class LInstruction; | 802 class LInstruction; |
| 803 class LCodeGen; | 803 class LCodeGen; |
| 804 } } // namespace v8::internal | 804 } } // namespace v8::internal |
| 805 | 805 |
| 806 #endif // V8_LITHIUM_H_ | 806 #endif // V8_LITHIUM_H_ |
| OLD | NEW |