Chromium Code Reviews| 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 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 578 address : | 578 address : |
| 579 (*redirector_)(address, fp_return); | 579 (*redirector_)(address, fp_return); |
| 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 | |
| 589 | |
| 590 enum PositionRecordingType { FORCED_POSITION, NORMAL_POSITION }; | |
|
Søren Thygesen Gjesse
2010/11/04 15:08:24
Thanks for using an enum instead of a boolean.
| |
| 591 | |
| 592 class PositionsRecorder BASE_EMBEDDED { | |
| 593 public: | |
| 594 explicit PositionsRecorder(Assembler* assembler) | |
| 595 : 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 | |
| 602 // Set current position to pos. If recording_type is FORCED_POSITION then | |
| 603 // WriteRecordedPositions will write this position even if it is equal to | |
| 604 // statement position previously written for another pc. | |
| 605 void RecordPosition(int pos, | |
| 606 PositionRecordingType recording_type = NORMAL_POSITION); | |
| 607 | |
| 608 // Set current statement position to pos. | |
| 609 void RecordStatementPosition(int pos); | |
| 610 | |
| 611 // Write recorded positions to relocation information. | |
| 612 bool WriteRecordedPositions(); | |
| 613 | |
| 614 int current_position() const { return current_position_; } | |
| 615 | |
| 616 int current_statement_position() const { return current_statement_position_; } | |
| 617 | |
| 618 private: | |
| 619 Assembler* assembler_; | |
| 620 | |
| 621 int current_position_; | |
| 622 PositionRecordingType current_position_recording_type_; | |
| 623 int written_position_; | |
| 624 | |
| 625 int current_statement_position_; | |
| 626 int written_statement_position_; | |
| 627 }; | |
| 628 | |
| 629 | |
| 630 class PreserveStatementPositionScope BASE_EMBEDDED { | |
| 631 public: | |
| 632 PreserveStatementPositionScope(PositionsRecorder* positions_recorder) | |
| 633 : positions_recorder_(positions_recorder), | |
| 634 statement_position_(positions_recorder->current_statement_position()) {} | |
| 635 | |
| 636 ~PreserveStatementPositionScope() { | |
| 637 if (statement_position_ != RelocInfo::kNoPosition) { | |
| 638 positions_recorder_->RecordStatementPosition(statement_position_); | |
| 639 } | |
| 640 } | |
| 641 | |
| 642 private: | |
| 643 PositionsRecorder* positions_recorder_; | |
| 644 int statement_position_; | |
| 645 }; | |
| 646 | |
| 647 | |
| 648 // ----------------------------------------------------------------------------- | |
| 588 // Utility functions | 649 // Utility functions |
| 589 | 650 |
| 590 static inline bool is_intn(int x, int n) { | 651 static inline bool is_intn(int x, int n) { |
| 591 return -(1 << (n-1)) <= x && x < (1 << (n-1)); | 652 return -(1 << (n-1)) <= x && x < (1 << (n-1)); |
| 592 } | 653 } |
| 593 | 654 |
| 594 static inline bool is_int8(int x) { return is_intn(x, 8); } | 655 static inline bool is_int8(int x) { return is_intn(x, 8); } |
| 595 static inline bool is_int16(int x) { return is_intn(x, 16); } | 656 static inline bool is_int16(int x) { return is_intn(x, 16); } |
| 596 static inline bool is_int18(int x) { return is_intn(x, 18); } | 657 static inline bool is_int18(int x) { return is_intn(x, 18); } |
| 597 static inline bool is_int24(int x) { return is_intn(x, 24); } | 658 static inline bool is_int24(int x) { return is_intn(x, 24); } |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 617 unsigned int num_bits_set; | 678 unsigned int num_bits_set; |
| 618 for (num_bits_set = 0; x; x >>= 1) { | 679 for (num_bits_set = 0; x; x >>= 1) { |
| 619 num_bits_set += x & 1; | 680 num_bits_set += x & 1; |
| 620 } | 681 } |
| 621 return num_bits_set; | 682 return num_bits_set; |
| 622 } | 683 } |
| 623 | 684 |
| 624 } } // namespace v8::internal | 685 } } // namespace v8::internal |
| 625 | 686 |
| 626 #endif // V8_ASSEMBLER_H_ | 687 #endif // V8_ASSEMBLER_H_ |
| OLD | NEW |