Index: src/disassembler.cc |
diff --git a/src/disassembler.cc b/src/disassembler.cc |
index d9448cec532172d5030a03036cfb65e363f604c3..78a0d1c6ffdbf9019491637e7b6d7b21fab1f5e7 100644 |
--- a/src/disassembler.cc |
+++ b/src/disassembler.cc |
@@ -19,21 +19,6 @@ namespace internal { |
#ifdef ENABLE_DISASSEMBLER |
-void Disassembler::Dump(FILE* f, byte* begin, byte* end) { |
- for (byte* pc = begin; pc < end; pc++) { |
- if (f == NULL) { |
- PrintF("%" V8PRIxPTR " %4" V8PRIdPTR " %02x\n", |
- reinterpret_cast<intptr_t>(pc), |
- pc - begin, |
- *pc); |
- } else { |
- PrintF(f, "%" V8PRIxPTR " %4" V8PRIdPTR " %02x\n", |
- reinterpret_cast<uintptr_t>(pc), pc - begin, *pc); |
- } |
- } |
-} |
- |
- |
class V8NameConverter: public disasm::NameConverter { |
public: |
explicit V8NameConverter(Code* code) : code_(code) {} |
@@ -74,12 +59,8 @@ const char* V8NameConverter::NameInCode(byte* addr) const { |
} |
-static void DumpBuffer(FILE* f, StringBuilder* out) { |
- if (f == NULL) { |
- PrintF("%s\n", out->Finalize()); |
- } else { |
- PrintF(f, "%s\n", out->Finalize()); |
- } |
+static void DumpBuffer(OStream* os, StringBuilder* out) { |
+ (*os) << out->Finalize() << endl; |
out->Reset(); |
} |
@@ -87,11 +68,8 @@ static void DumpBuffer(FILE* f, StringBuilder* out) { |
static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength; |
static const int kRelocInfoPosition = 57; |
-static int DecodeIt(Isolate* isolate, |
- FILE* f, |
- const V8NameConverter& converter, |
- byte* begin, |
- byte* end) { |
+static int DecodeIt(Isolate* isolate, OStream* os, |
+ const V8NameConverter& converter, byte* begin, byte* end) { |
SealHandleScope shs(isolate); |
DisallowHeapAllocation no_alloc; |
ExternalReferenceEncoder ref_encoder(isolate); |
@@ -164,7 +142,7 @@ static int DecodeIt(Isolate* isolate, |
// Comments. |
for (int i = 0; i < comments.length(); i++) { |
out.AddFormatted(" %s", comments[i]); |
- DumpBuffer(f, &out); |
+ DumpBuffer(os, &out); |
} |
// Instruction address and instruction offset. |
@@ -184,7 +162,7 @@ static int DecodeIt(Isolate* isolate, |
out.AddPadding(' ', kRelocInfoPosition - out.position()); |
} else { |
// Additional reloc infos are printed on separate lines. |
- DumpBuffer(f, &out); |
+ DumpBuffer(os, &out); |
out.AddPadding(' ', kRelocInfoPosition); |
} |
@@ -278,7 +256,7 @@ static int DecodeIt(Isolate* isolate, |
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode)); |
} |
} |
- DumpBuffer(f, &out); |
+ DumpBuffer(os, &out); |
} |
// Emit comments following the last instruction (if any). |
@@ -287,7 +265,7 @@ static int DecodeIt(Isolate* isolate, |
if (RelocInfo::IsComment(it->rinfo()->rmode())) { |
out.AddFormatted(" %s", |
reinterpret_cast<const char*>(it->rinfo()->data())); |
- DumpBuffer(f, &out); |
+ DumpBuffer(os, &out); |
} |
} |
} |
@@ -297,40 +275,19 @@ static int DecodeIt(Isolate* isolate, |
} |
-int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { |
- V8NameConverter defaultConverter(NULL); |
- return DecodeIt(isolate, f, defaultConverter, begin, end); |
-} |
- |
- |
-// Called by Code::CodePrint. |
-void Disassembler::Decode(FILE* f, Code* code) { |
- Isolate* isolate = code->GetIsolate(); |
- int decode_size = code->is_crankshafted() |
- ? static_cast<int>(code->safepoint_table_offset()) |
- : code->instruction_size(); |
- // If there might be a back edge table, stop before reaching it. |
- if (code->kind() == Code::FUNCTION) { |
- decode_size = |
- Min(decode_size, static_cast<int>(code->back_edge_table_offset())); |
- } |
- |
- byte* begin = code->instruction_start(); |
- byte* end = begin + decode_size; |
+int Disassembler::Decode(Isolate* isolate, OStream* os, byte* begin, byte* end, |
+ Code* code) { |
V8NameConverter v8NameConverter(code); |
- DecodeIt(isolate, f, v8NameConverter, begin, end); |
+ return DecodeIt(isolate, os, v8NameConverter, begin, end); |
} |
#else // ENABLE_DISASSEMBLER |
-void Disassembler::Dump(FILE* f, byte* begin, byte* end) {} |
-int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) { |
+int Disassembler::Decode(Isolate* isolate, OStream* os, byte* begin, byte* end, |
+ Code* code) { |
return 0; |
} |
- |
-void Disassembler::Decode(FILE* f, Code* code) {} |
- |
#endif // ENABLE_DISASSEMBLER |
} } // namespace v8::internal |