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