Commit b3dd6b68 authored by sgjesse@chromium.org's avatar sgjesse@chromium.org

Refactored the recording of source position in the generated code. The code...

Refactored the recording of source position in the generated code. The code generator now has two methods

  void CodeForStatement(Node* node)
  void CodeForSourcePosition(int pos)

The first is used to indicate that code is about to be generated for the given statement and the second is used to indicate that code is about to be generated for the given source position.

Added position information for some statements which was missing whem.

Updated the code generator for ARM to emit source position the same way as for IA-32.

Added an assert to ensure that deferred code stubs will always have a source source position as if it has not it will take whatever source position before which makes no sense.

The passing test on ARM has only been tested using the simulator.
Review URL: http://codereview.chromium.org/14170

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@985 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 028e3414
......@@ -320,8 +320,10 @@ Assembler::Assembler(void* buffer, int buffer_size) {
no_const_pool_before_ = 0;
last_const_pool_end_ = 0;
last_bound_pos_ = 0;
last_position_ = RelocInfo::kNoPosition;
last_position_is_statement_ = false;
current_statement_position_ = RelocInfo::kNoPosition;
current_position_ = RelocInfo::kNoPosition;
written_statement_position_ = current_statement_position_;
written_position_ = current_position_;
}
......@@ -1306,20 +1308,36 @@ void Assembler::RecordComment(const char* msg) {
void Assembler::RecordPosition(int pos) {
if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos >= 0);
if (pos == last_position_) return;
CheckBuffer();
RecordRelocInfo(RelocInfo::POSITION, pos);
last_position_ = pos;
last_position_is_statement_ = false;
current_position_ = pos;
WriteRecordedPositions();
}
void Assembler::RecordStatementPosition(int pos) {
if (pos == last_position_) return;
CheckBuffer();
RecordRelocInfo(RelocInfo::STATEMENT_POSITION, pos);
last_position_ = pos;
last_position_is_statement_ = true;
if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos >= 0);
current_statement_position_ = pos;
WriteRecordedPositions();
}
void Assembler::WriteRecordedPositions() {
// Write the statement position if it is different from what was written last
// time.
if (current_statement_position_ != written_statement_position_) {
CheckBuffer();
RecordRelocInfo(RelocInfo::STATEMENT_POSITION, current_statement_position_);
written_statement_position_ = current_statement_position_;
}
// Write the position if it is different from what was written last time and
// also diferent from the written statement position.
if (current_position_ != written_position_ &&
current_position_ != written_statement_position_) {
CheckBuffer();
RecordRelocInfo(RelocInfo::POSITION, current_position_);
written_position_ = current_position_;
}
}
......
......@@ -643,15 +643,11 @@ class Assembler : public Malloced {
void RecordPosition(int pos);
void RecordStatementPosition(int pos);
void WriteRecordedPositions();
int pc_offset() const { return pc_ - buffer_; }
int last_position() const { return last_position_; }
bool last_position_is_statement() const {
return last_position_is_statement_;
}
// Temporary helper function. Used by codegen.cc.
int last_statement_position() const { return last_position_; }
int current_position() const { return current_position_; }
int current_statement_position() const { return current_position_; }
protected:
int buffer_space() const { return reloc_info_writer.pos() - pc_; }
......@@ -754,8 +750,10 @@ class Assembler : public Malloced {
int last_bound_pos_;
// source position information
int last_position_;
bool last_position_is_statement_;
int current_position_;
int current_statement_position_;
int written_position_;
int written_statement_position_;
// Code emission
inline void CheckBuffer();
......
......@@ -316,8 +316,10 @@ Assembler::Assembler(void* buffer, int buffer_size) {
reloc_info_writer.Reposition(buffer_ + buffer_size, pc_);
last_pc_ = NULL;
last_position_ = RelocInfo::kNoPosition;
last_statement_position_ = RelocInfo::kNoPosition;
current_statement_position_ = RelocInfo::kNoPosition;
current_position_ = RelocInfo::kNoPosition;
written_statement_position_ = current_statement_position_;
written_position_ = current_position_;
}
......@@ -1964,31 +1966,36 @@ void Assembler::RecordComment(const char* msg) {
void Assembler::RecordPosition(int pos) {
if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0);
last_position_ = pos;
current_position_ = pos;
}
void Assembler::RecordStatementPosition(int pos) {
if (pos == RelocInfo::kNoPosition) return;
ASSERT(pos != RelocInfo::kNoPosition);
ASSERT(pos >= 0);
last_statement_position_ = pos;
current_statement_position_ = pos;
}
void Assembler::WriteRecordedPositions() {
if (last_statement_position_ != RelocInfo::kNoPosition) {
// Write the statement position if it is different from what was written last
// time.
if (current_statement_position_ != written_statement_position_) {
EnsureSpace ensure_space(this);
RecordRelocInfo(RelocInfo::STATEMENT_POSITION, last_statement_position_);
RecordRelocInfo(RelocInfo::STATEMENT_POSITION, current_statement_position_);
written_statement_position_ = current_statement_position_;
}
if ((last_position_ != RelocInfo::kNoPosition) &&
(last_position_ != last_statement_position_)) {
// Write the position if it is different from what was written last time and
// also diferent from the written statement position.
if (current_position_ != written_position_ &&
current_position_ != written_statement_position_) {
EnsureSpace ensure_space(this);
RecordRelocInfo(RelocInfo::POSITION, last_position_);
RecordRelocInfo(RelocInfo::POSITION, current_position_);
written_position_ = current_position_;
}
last_statement_position_ = RelocInfo::kNoPosition;
last_position_ = RelocInfo::kNoPosition;
}
......
......@@ -712,8 +712,8 @@ class Assembler : public Malloced {
void WriteInternalReference(int position, const Label& bound_label);
int pc_offset() const { return pc_ - buffer_; }
int last_statement_position() const { return last_statement_position_; }
int last_position() const { return last_position_; }
int current_statement_position() const { return current_statement_position_; }
int current_position() const { return current_position_; }
// Check if there is less than kGap bytes available in the buffer.
// If this is the case, we need to grow the buffer before emitting
......@@ -800,8 +800,10 @@ class Assembler : public Malloced {
byte* last_pc_;
// source position information
int last_position_;
int last_statement_position_;
int current_statement_position_;
int current_position_;
int written_statement_position_;
int written_position_;
};
......
This diff is collapsed.
......@@ -376,10 +376,11 @@ class CodeGenerator: public AstVisitor {
bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node);
// Bottle-neck interface to call the Assembler to generate the statement
// position. This allows us to easily control whether statement positions
// should be generated or not.
void RecordStatementPosition(Node* node);
// Methods used to indicate which source code is generated for. Source
// positions are collected by the assembler and emitted with the relocation
// information.
void CodeForStatement(Node* node);
void CodeForSourcePosition(int pos);
bool is_eval_; // Tells whether code is generated for eval.
Handle<Script> script_;
......
This diff is collapsed.
......@@ -400,11 +400,11 @@ class CodeGenerator: public AstVisitor {
// Returns true if the fast-case switch was generated, and false if not.
bool TryGenerateFastCaseSwitchStatement(SwitchStatement* node);
// Bottle-neck interface to call the Assembler to generate the statement
// position. This allows us to easily control whether statement positions
// should be generated or not.
void RecordStatementPosition(Node* node);
// Methods used to indicate which source code is generated for. Source
// positions are collected by the assembler and emitted with the relocation
// information.
void CodeForStatement(Node* node);
void CodeForSourcePosition(int pos);
bool is_eval_; // Tells whether code is generated for eval.
Handle<Script> script_;
......
......@@ -40,9 +40,11 @@ namespace v8 { namespace internal {
DeferredCode::DeferredCode(CodeGenerator* generator)
: masm_(generator->masm()),
generator_(generator),
statement_position_(masm_->last_statement_position()),
position_(masm_->last_position()) {
statement_position_(masm_->current_statement_position()),
position_(masm_->current_position()) {
generator->AddDeferred(this);
ASSERT(statement_position_ != RelocInfo::kNoPosition);
ASSERT(position_ != RelocInfo::kNoPosition);
#ifdef DEBUG
comment_ = "";
#endif
......@@ -54,9 +56,7 @@ void CodeGenerator::ProcessDeferred() {
DeferredCode* code = deferred_.RemoveLast();
MacroAssembler* masm = code->masm();
// Record position of deferred code stub.
if (code->statement_position() != RelocInfo::kNoPosition) {
masm->RecordStatementPosition(code->statement_position());
}
masm->RecordStatementPosition(code->statement_position());
if (code->position() != RelocInfo::kNoPosition) {
masm->RecordPosition(code->position());
}
......@@ -464,6 +464,26 @@ bool CodeGenerator::TryGenerateFastCaseSwitchStatement(SwitchStatement* node) {
}
void CodeGenerator::CodeForStatement(Node* node) {
if (FLAG_debug_info) {
int pos = node->statement_pos();
if (pos != RelocInfo::kNoPosition) {
masm()->RecordStatementPosition(pos);
CodeForSourcePosition(pos);
}
}
}
void CodeGenerator::CodeForSourcePosition(int pos) {
if (FLAG_debug_info) {
if (pos != RelocInfo::kNoPosition) {
masm()->RecordPosition(pos);
}
}
}
const char* RuntimeStub::GetName() {
return Runtime::FunctionForId(id_)->stub_name;
}
......
......@@ -1320,6 +1320,9 @@ Statement* Parser::ParseStatement(ZoneStringList* labels, bool* ok) {
Block* result = NEW(Block(labels, 1, false));
Target target(this, result);
TryStatement* statement = ParseTryStatement(CHECK_OK);
if (statement) {
statement->set_statement_pos(statement_pos);
}
if (result) result->AddStatement(statement);
return result;
}
......
......@@ -47,7 +47,6 @@ debug-scripts-request: PASS, SKIP if $mode == debug
# Bug number 1020483: Debug tests fail on ARM.
debug-constructor: CRASH, FAIL
debug-continue: SKIP
debug-backtrace: FAIL
debug-evaluate-recursive: CRASH, FAIL if $mode == debug
debug-changebreakpoint: CRASH, FAIL if $mode == debug
debug-clearbreakpoint: CRASH, FAIL if $mode == debug
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment