Commit 92e7656c authored by whesse@chromium.org's avatar whesse@chromium.org

Clean up TranslationIterator and DeoptimizationInputDataPrint.

Without this refactoring, they break when we add alignment padding in the Translation info.

BUG=
TEST=

Review URL: http://codereview.chromium.org/7569009

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8851 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent caf493af
...@@ -1183,11 +1183,11 @@ void TranslationBuffer::Add(int32_t value) { ...@@ -1183,11 +1183,11 @@ void TranslationBuffer::Add(int32_t value) {
int32_t TranslationIterator::Next() { int32_t TranslationIterator::Next() {
ASSERT(HasNext());
// Run through the bytes until we reach one with a least significant // Run through the bytes until we reach one with a least significant
// bit of zero (marks the end). // bit of zero (marks the end).
uint32_t bits = 0; uint32_t bits = 0;
for (int i = 0; true; i += 7) { for (int i = 0; true; i += 7) {
ASSERT(HasNext());
uint8_t next = buffer_->get(index_++); uint8_t next = buffer_->get(index_++);
bits |= (next >> 1) << i; bits |= (next >> 1) << i;
if ((next & 1) == 0) break; if ((next & 1) == 0) break;
......
...@@ -497,9 +497,7 @@ class TranslationIterator BASE_EMBEDDED { ...@@ -497,9 +497,7 @@ class TranslationIterator BASE_EMBEDDED {
int32_t Next(); int32_t Next();
bool HasNext() const { return index_ >= 0; } bool HasNext() const { return index_ < buffer_->length(); }
void Done() { index_ = -1; }
void Skip(int n) { void Skip(int n) {
for (int i = 0; i < n; i++) Next(); for (int i = 0; i < n; i++) Next();
......
...@@ -601,8 +601,6 @@ void Deoptimizer::DoComputeFrame(TranslationIterator* iterator, ...@@ -601,8 +601,6 @@ void Deoptimizer::DoComputeFrame(TranslationIterator* iterator,
output_frame->SetContinuation( output_frame->SetContinuation(
reinterpret_cast<uint32_t>(continuation->entry())); reinterpret_cast<uint32_t>(continuation->entry()));
} }
if (output_count_ - 1 == frame_index) iterator->Done();
} }
......
...@@ -7070,124 +7070,93 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { ...@@ -7070,124 +7070,93 @@ void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
PrintF(out, "%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands"); PrintF(out, "%6s %6s %6s %12s\n", "index", "ast id", "argc", "commands");
for (int i = 0; i < deopt_count; i++) { for (int i = 0; i < deopt_count; i++) {
int command_count = 0;
PrintF(out, "%6d %6d %6d", PrintF(out, "%6d %6d %6d",
i, AstId(i)->value(), ArgumentsStackHeight(i)->value()); i, AstId(i)->value(), ArgumentsStackHeight(i)->value());
if (!FLAG_print_code_verbose) continue;
// Print details of the frame translation.
int translation_index = TranslationIndex(i)->value(); int translation_index = TranslationIndex(i)->value();
TranslationIterator iterator(TranslationByteArray(), translation_index); TranslationIterator iterator(TranslationByteArray(), translation_index);
Translation::Opcode opcode = Translation::Opcode opcode =
static_cast<Translation::Opcode>(iterator.Next()); static_cast<Translation::Opcode>(iterator.Next());
ASSERT(Translation::BEGIN == opcode); ASSERT(Translation::BEGIN == opcode);
int frame_count = iterator.Next(); int frame_count = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode), PrintF(out, " %s {count=%d}\n", Translation::StringFor(opcode),
frame_count); frame_count);
}
for (int i = 0; i < frame_count; ++i) { while (iterator.HasNext() &&
opcode = static_cast<Translation::Opcode>(iterator.Next()); Translation::BEGIN !=
ASSERT(Translation::FRAME == opcode); (opcode = static_cast<Translation::Opcode>(iterator.Next()))) {
PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
switch (opcode) {
case Translation::BEGIN:
UNREACHABLE();
break;
case Translation::FRAME: {
int ast_id = iterator.Next(); int ast_id = iterator.Next();
int function_id = iterator.Next(); int function_id = iterator.Next();
JSFunction* function = JSFunction* function =
JSFunction::cast(LiteralArray()->get(function_id)); JSFunction::cast(LiteralArray()->get(function_id));
unsigned height = iterator.Next(); unsigned height = iterator.Next();
if (FLAG_print_code_verbose) { PrintF(out, "{ast_id=%d, \nfunction=", ast_id);
PrintF(out, "%24s %s {ast_id=%d, function=",
"", Translation::StringFor(opcode), ast_id);
function->PrintName(out); function->PrintName(out);
PrintF(out, ", height=%u}\n", height); PrintF(out, ", height=%u}", height);
} break;
// Size of translation is height plus all incoming arguments including
// receiver.
int size = height + function->shared()->formal_parameter_count() + 1;
command_count += size;
for (int j = 0; j < size; ++j) {
opcode = static_cast<Translation::Opcode>(iterator.Next());
if (FLAG_print_code_verbose) {
PrintF(out, "%24s %s ", "", Translation::StringFor(opcode));
}
if (opcode == Translation::DUPLICATE) {
opcode = static_cast<Translation::Opcode>(iterator.Next());
if (FLAG_print_code_verbose) {
PrintF(out, "%s ", Translation::StringFor(opcode));
}
--j; // Two commands share the same frame index.
} }
switch (opcode) {
case Translation::BEGIN:
case Translation::FRAME:
case Translation::DUPLICATE: case Translation::DUPLICATE:
UNREACHABLE();
break; break;
case Translation::REGISTER: { case Translation::REGISTER: {
int reg_code = iterator.Next(); int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code)); PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
}
break; break;
} }
case Translation::INT32_REGISTER: { case Translation::INT32_REGISTER: {
int reg_code = iterator.Next(); int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code)); PrintF(out, "{input=%s}", converter.NameOfCPURegister(reg_code));
}
break; break;
} }
case Translation::DOUBLE_REGISTER: { case Translation::DOUBLE_REGISTER: {
int reg_code = iterator.Next(); int reg_code = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%s}", PrintF(out, "{input=%s}",
DoubleRegister::AllocationIndexToString(reg_code)); DoubleRegister::AllocationIndexToString(reg_code));
}
break; break;
} }
case Translation::STACK_SLOT: { case Translation::STACK_SLOT: {
int input_slot_index = iterator.Next(); int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%d}", input_slot_index); PrintF(out, "{input=%d}", input_slot_index);
}
break; break;
} }
case Translation::INT32_STACK_SLOT: { case Translation::INT32_STACK_SLOT: {
int input_slot_index = iterator.Next(); int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%d}", input_slot_index); PrintF(out, "{input=%d}", input_slot_index);
}
break; break;
} }
case Translation::DOUBLE_STACK_SLOT: { case Translation::DOUBLE_STACK_SLOT: {
int input_slot_index = iterator.Next(); int input_slot_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{input=%d}", input_slot_index); PrintF(out, "{input=%d}", input_slot_index);
}
break; break;
} }
case Translation::LITERAL: { case Translation::LITERAL: {
unsigned literal_index = iterator.Next(); unsigned literal_index = iterator.Next();
if (FLAG_print_code_verbose) {
PrintF(out, "{literal_id=%u}", literal_index); PrintF(out, "{literal_id=%u}", literal_index);
}
break; break;
} }
case Translation::ARGUMENTS_OBJECT: case Translation::ARGUMENTS_OBJECT:
break; break;
} }
if (FLAG_print_code_verbose) PrintF(out, "\n"); PrintF(out, "\n");
}
} }
if (!FLAG_print_code_verbose) PrintF(out, " %12d\n", command_count);
} }
} }
......
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