Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Unified Diff: src/assembler.h

Issue 5277008: Save full source position state to avoid forced positions. (Closed)
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/assembler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/assembler.h
diff --git a/src/assembler.h b/src/assembler.h
index 4cf843a2a0ebddb29e558edc4b568dffe34034fe..da4ab21359aabf5fee61ee4790516bf10e7faa23 100644
--- a/src/assembler.h
+++ b/src/assembler.h
@@ -587,23 +587,27 @@ class ExternalReference BASE_EMBEDDED {
// -----------------------------------------------------------------------------
// Position recording support
-enum PositionRecordingType { FORCED_POSITION, NORMAL_POSITION };
+struct PositionState {
+ PositionState() : current_position(RelocInfo::kNoPosition),
+ written_position(RelocInfo::kNoPosition),
+ current_statement_position(RelocInfo::kNoPosition),
+ written_statement_position(RelocInfo::kNoPosition) {}
+
+ int current_position;
+ int written_position;
+
+ int current_statement_position;
+ int written_statement_position;
+};
+
class PositionsRecorder BASE_EMBEDDED {
public:
explicit PositionsRecorder(Assembler* assembler)
- : assembler_(assembler),
- current_position_(RelocInfo::kNoPosition),
- current_position_recording_type_(NORMAL_POSITION),
- written_position_(RelocInfo::kNoPosition),
- current_statement_position_(RelocInfo::kNoPosition),
- written_statement_position_(RelocInfo::kNoPosition) { }
-
- // Set current position to pos. If recording_type is FORCED_POSITION then
- // WriteRecordedPositions will write this position even if it is equal to
- // statement position previously written for another pc.
- void RecordPosition(int pos,
- PositionRecordingType recording_type = NORMAL_POSITION);
+ : assembler_(assembler) {}
+
+ // Set current position to pos.
+ void RecordPosition(int pos);
// Set current statement position to pos.
void RecordStatementPosition(int pos);
@@ -611,37 +615,37 @@ class PositionsRecorder BASE_EMBEDDED {
// Write recorded positions to relocation information.
bool WriteRecordedPositions();
- int current_position() const { return current_position_; }
+ int current_position() const { return state_.current_position; }
- int current_statement_position() const { return current_statement_position_; }
+ int current_statement_position() const {
+ return state_.current_statement_position;
+ }
private:
Assembler* assembler_;
+ PositionState state_;
- int current_position_;
- PositionRecordingType current_position_recording_type_;
- int written_position_;
+ friend class PreservePositionScope;
- int current_statement_position_;
- int written_statement_position_;
+ DISALLOW_COPY_AND_ASSIGN(PositionsRecorder);
};
-class PreserveStatementPositionScope BASE_EMBEDDED {
+class PreservePositionScope BASE_EMBEDDED {
public:
- explicit PreserveStatementPositionScope(PositionsRecorder* positions_recorder)
+ explicit PreservePositionScope(PositionsRecorder* positions_recorder)
: positions_recorder_(positions_recorder),
- statement_position_(positions_recorder->current_statement_position()) {}
+ saved_state_(positions_recorder->state_) {}
- ~PreserveStatementPositionScope() {
- if (statement_position_ != RelocInfo::kNoPosition) {
- positions_recorder_->RecordStatementPosition(statement_position_);
- }
+ ~PreservePositionScope() {
+ positions_recorder_->state_ = saved_state_;
}
private:
PositionsRecorder* positions_recorder_;
- int statement_position_;
+ const PositionState saved_state_;
+
+ DISALLOW_COPY_AND_ASSIGN(PreservePositionScope);
};
« no previous file with comments | « src/arm/full-codegen-arm.cc ('k') | src/assembler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698