| OLD | NEW |
| 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. | 1 // Copyright (c) 1994-2006 Sun Microsystems Inc. |
| 2 // All Rights Reserved. | 2 // All Rights Reserved. |
| 3 // | 3 // |
| 4 // Redistribution and use in source and binary forms, with or without | 4 // Redistribution and use in source and binary forms, with or without |
| 5 // modification, are permitted provided that the following conditions are | 5 // modification, are permitted provided that the following conditions are |
| 6 // met: | 6 // met: |
| 7 // | 7 // |
| 8 // - Redistributions of source code must retain the above copyright notice, | 8 // - Redistributions of source code must retain the above copyright notice, |
| 9 // this list of conditions and the following disclaimer. | 9 // this list of conditions and the following disclaimer. |
| 10 // | 10 // |
| (...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 580 return answer; | 580 return answer; |
| 581 } | 581 } |
| 582 | 582 |
| 583 void* address_; | 583 void* address_; |
| 584 }; | 584 }; |
| 585 | 585 |
| 586 | 586 |
| 587 // ----------------------------------------------------------------------------- | 587 // ----------------------------------------------------------------------------- |
| 588 // Position recording support | 588 // Position recording support |
| 589 | 589 |
| 590 enum PositionRecordingType { FORCED_POSITION, NORMAL_POSITION }; | 590 struct PositionState { |
| 591 PositionState() : current_position(RelocInfo::kNoPosition), |
| 592 written_position(RelocInfo::kNoPosition), |
| 593 current_statement_position(RelocInfo::kNoPosition), |
| 594 written_statement_position(RelocInfo::kNoPosition) {} |
| 595 |
| 596 int current_position; |
| 597 int written_position; |
| 598 |
| 599 int current_statement_position; |
| 600 int written_statement_position; |
| 601 }; |
| 602 |
| 591 | 603 |
| 592 class PositionsRecorder BASE_EMBEDDED { | 604 class PositionsRecorder BASE_EMBEDDED { |
| 593 public: | 605 public: |
| 594 explicit PositionsRecorder(Assembler* assembler) | 606 explicit PositionsRecorder(Assembler* assembler) |
| 595 : assembler_(assembler), | 607 : assembler_(assembler) {} |
| 596 current_position_(RelocInfo::kNoPosition), | |
| 597 current_position_recording_type_(NORMAL_POSITION), | |
| 598 written_position_(RelocInfo::kNoPosition), | |
| 599 current_statement_position_(RelocInfo::kNoPosition), | |
| 600 written_statement_position_(RelocInfo::kNoPosition) { } | |
| 601 | 608 |
| 602 // Set current position to pos. If recording_type is FORCED_POSITION then | 609 // Set current position to pos. |
| 603 // WriteRecordedPositions will write this position even if it is equal to | 610 void RecordPosition(int pos); |
| 604 // statement position previously written for another pc. | |
| 605 void RecordPosition(int pos, | |
| 606 PositionRecordingType recording_type = NORMAL_POSITION); | |
| 607 | 611 |
| 608 // Set current statement position to pos. | 612 // Set current statement position to pos. |
| 609 void RecordStatementPosition(int pos); | 613 void RecordStatementPosition(int pos); |
| 610 | 614 |
| 611 // Write recorded positions to relocation information. | 615 // Write recorded positions to relocation information. |
| 612 bool WriteRecordedPositions(); | 616 bool WriteRecordedPositions(); |
| 613 | 617 |
| 614 int current_position() const { return current_position_; } | 618 int current_position() const { return state_.current_position; } |
| 615 | 619 |
| 616 int current_statement_position() const { return current_statement_position_; } | 620 int current_statement_position() const { |
| 621 return state_.current_statement_position; |
| 622 } |
| 617 | 623 |
| 618 private: | 624 private: |
| 619 Assembler* assembler_; | 625 Assembler* assembler_; |
| 626 PositionState state_; |
| 620 | 627 |
| 621 int current_position_; | 628 friend class PreservePositionScope; |
| 622 PositionRecordingType current_position_recording_type_; | |
| 623 int written_position_; | |
| 624 | 629 |
| 625 int current_statement_position_; | 630 DISALLOW_COPY_AND_ASSIGN(PositionsRecorder); |
| 626 int written_statement_position_; | |
| 627 }; | 631 }; |
| 628 | 632 |
| 629 | 633 |
| 630 class PreserveStatementPositionScope BASE_EMBEDDED { | 634 class PreservePositionScope BASE_EMBEDDED { |
| 631 public: | 635 public: |
| 632 explicit PreserveStatementPositionScope(PositionsRecorder* positions_recorder) | 636 explicit PreservePositionScope(PositionsRecorder* positions_recorder) |
| 633 : positions_recorder_(positions_recorder), | 637 : positions_recorder_(positions_recorder), |
| 634 statement_position_(positions_recorder->current_statement_position()) {} | 638 saved_state_(positions_recorder->state_) {} |
| 635 | 639 |
| 636 ~PreserveStatementPositionScope() { | 640 ~PreservePositionScope() { |
| 637 if (statement_position_ != RelocInfo::kNoPosition) { | 641 positions_recorder_->state_ = saved_state_; |
| 638 positions_recorder_->RecordStatementPosition(statement_position_); | |
| 639 } | |
| 640 } | 642 } |
| 641 | 643 |
| 642 private: | 644 private: |
| 643 PositionsRecorder* positions_recorder_; | 645 PositionsRecorder* positions_recorder_; |
| 644 int statement_position_; | 646 const PositionState saved_state_; |
| 647 |
| 648 DISALLOW_COPY_AND_ASSIGN(PreservePositionScope); |
| 645 }; | 649 }; |
| 646 | 650 |
| 647 | 651 |
| 648 // ----------------------------------------------------------------------------- | 652 // ----------------------------------------------------------------------------- |
| 649 // Utility functions | 653 // Utility functions |
| 650 | 654 |
| 651 static inline bool is_intn(int x, int n) { | 655 static inline bool is_intn(int x, int n) { |
| 652 return -(1 << (n-1)) <= x && x < (1 << (n-1)); | 656 return -(1 << (n-1)) <= x && x < (1 << (n-1)); |
| 653 } | 657 } |
| 654 | 658 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 678 unsigned int num_bits_set; | 682 unsigned int num_bits_set; |
| 679 for (num_bits_set = 0; x; x >>= 1) { | 683 for (num_bits_set = 0; x; x >>= 1) { |
| 680 num_bits_set += x & 1; | 684 num_bits_set += x & 1; |
| 681 } | 685 } |
| 682 return num_bits_set; | 686 return num_bits_set; |
| 683 } | 687 } |
| 684 | 688 |
| 685 } } // namespace v8::internal | 689 } } // namespace v8::internal |
| 686 | 690 |
| 687 #endif // V8_ASSEMBLER_H_ | 691 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |