2011-01-06 14:13:40 +00:00
|
|
|
// Copyright 2011 the V8 project authors. All rights reserved.
|
2008-07-03 15:10:15 +00:00
|
|
|
// Redistribution and use in source and binary forms, with or without
|
|
|
|
// modification, are permitted provided that the following conditions are
|
|
|
|
// met:
|
|
|
|
//
|
|
|
|
// * Redistributions of source code must retain the above copyright
|
|
|
|
// notice, this list of conditions and the following disclaimer.
|
|
|
|
// * Redistributions in binary form must reproduce the above
|
|
|
|
// copyright notice, this list of conditions and the following
|
|
|
|
// disclaimer in the documentation and/or other materials provided
|
|
|
|
// with the distribution.
|
|
|
|
// * Neither the name of Google Inc. nor the names of its
|
|
|
|
// contributors may be used to endorse or promote products derived
|
|
|
|
// from this software without specific prior written permission.
|
|
|
|
//
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
|
|
|
#include "v8.h"
|
|
|
|
|
|
|
|
#include "code-stubs.h"
|
2011-04-07 14:42:37 +00:00
|
|
|
#include "codegen.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "debug.h"
|
2010-12-07 11:31:57 +00:00
|
|
|
#include "deoptimizer.h"
|
2008-07-03 15:10:15 +00:00
|
|
|
#include "disasm.h"
|
|
|
|
#include "disassembler.h"
|
|
|
|
#include "macro-assembler.h"
|
|
|
|
#include "serialize.h"
|
|
|
|
#include "string-stream.h"
|
|
|
|
|
2009-05-25 10:05:56 +00:00
|
|
|
namespace v8 {
|
|
|
|
namespace internal {
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
#ifdef ENABLE_DISASSEMBLER
|
|
|
|
|
|
|
|
void Disassembler::Dump(FILE* f, byte* begin, byte* end) {
|
|
|
|
for (byte* pc = begin; pc < end; pc++) {
|
|
|
|
if (f == NULL) {
|
2010-09-30 07:22:53 +00:00
|
|
|
PrintF("%" V8PRIxPTR " %4" V8PRIdPTR " %02x\n",
|
|
|
|
reinterpret_cast<intptr_t>(pc),
|
|
|
|
pc - begin,
|
|
|
|
*pc);
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
2013-04-10 09:18:41 +00:00
|
|
|
PrintF(f, "%" V8PRIxPTR " %4" V8PRIdPTR " %02x\n",
|
|
|
|
reinterpret_cast<uintptr_t>(pc), pc - begin, *pc);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class V8NameConverter: public disasm::NameConverter {
|
|
|
|
public:
|
|
|
|
explicit V8NameConverter(Code* code) : code_(code) {}
|
|
|
|
virtual const char* NameOfAddress(byte* pc) const;
|
2008-07-30 08:49:36 +00:00
|
|
|
virtual const char* NameInCode(byte* addr) const;
|
2008-07-03 15:10:15 +00:00
|
|
|
Code* code() const { return code_; }
|
|
|
|
private:
|
|
|
|
Code* code_;
|
2011-03-18 20:35:07 +00:00
|
|
|
|
|
|
|
EmbeddedVector<char, 128> v8_buffer_;
|
2008-07-03 15:10:15 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const char* V8NameConverter::NameOfAddress(byte* pc) const {
|
2013-09-03 06:59:01 +00:00
|
|
|
const char* name = code_->GetIsolate()->builtins()->Lookup(pc);
|
2008-07-03 15:10:15 +00:00
|
|
|
if (name != NULL) {
|
2011-03-18 20:35:07 +00:00
|
|
|
OS::SNPrintF(v8_buffer_, "%s (%p)", name, pc);
|
|
|
|
return v8_buffer_.start();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (code_ != NULL) {
|
2009-11-11 09:50:06 +00:00
|
|
|
int offs = static_cast<int>(pc - code_->instruction_start());
|
2008-07-03 15:10:15 +00:00
|
|
|
// print as code offset, if it seems reasonable
|
|
|
|
if (0 <= offs && offs < code_->instruction_size()) {
|
2011-03-18 20:35:07 +00:00
|
|
|
OS::SNPrintF(v8_buffer_, "%d (%p)", offs, pc);
|
|
|
|
return v8_buffer_.start();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return disasm::NameConverter::NameOfAddress(pc);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
const char* V8NameConverter::NameInCode(byte* addr) const {
|
|
|
|
// The V8NameConverter is used for well known code, so we can "safely"
|
|
|
|
// dereference pointers in generated code.
|
|
|
|
return (code_ != NULL) ? reinterpret_cast<const char*>(addr) : "";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-11 12:52:37 +00:00
|
|
|
static void DumpBuffer(FILE* f, StringBuilder* out) {
|
2008-07-30 08:49:36 +00:00
|
|
|
if (f == NULL) {
|
2011-08-11 12:52:37 +00:00
|
|
|
PrintF("%s\n", out->Finalize());
|
2008-07-30 08:49:36 +00:00
|
|
|
} else {
|
2013-04-10 09:18:41 +00:00
|
|
|
PrintF(f, "%s\n", out->Finalize());
|
2008-07-30 08:49:36 +00:00
|
|
|
}
|
2011-08-11 12:52:37 +00:00
|
|
|
out->Reset();
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-11 12:52:37 +00:00
|
|
|
|
2009-03-19 11:57:18 +00:00
|
|
|
static const int kOutBufferSize = 2048 + String::kMaxShortPrintLength;
|
2008-07-03 15:10:15 +00:00
|
|
|
static const int kRelocInfoPosition = 57;
|
|
|
|
|
2013-02-25 14:46:09 +00:00
|
|
|
static int DecodeIt(Isolate* isolate,
|
|
|
|
FILE* f,
|
2008-07-03 15:10:15 +00:00
|
|
|
const V8NameConverter& converter,
|
|
|
|
byte* begin,
|
|
|
|
byte* end) {
|
2013-06-03 15:32:22 +00:00
|
|
|
SealHandleScope shs(isolate);
|
|
|
|
DisallowHeapAllocation no_alloc;
|
2013-09-03 11:54:08 +00:00
|
|
|
ExternalReferenceEncoder ref_encoder(isolate);
|
2013-09-11 07:14:41 +00:00
|
|
|
Heap* heap = isolate->heap();
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-09-11 14:34:48 +00:00
|
|
|
v8::internal::EmbeddedVector<char, 128> decode_buffer;
|
|
|
|
v8::internal::EmbeddedVector<char, kOutBufferSize> out_buffer;
|
2011-08-11 13:59:29 +00:00
|
|
|
StringBuilder out(out_buffer.start(), out_buffer.length());
|
2008-07-03 15:10:15 +00:00
|
|
|
byte* pc = begin;
|
|
|
|
disasm::Disassembler d(converter);
|
|
|
|
RelocIterator* it = NULL;
|
|
|
|
if (converter.code() != NULL) {
|
|
|
|
it = new RelocIterator(converter.code());
|
|
|
|
} else {
|
|
|
|
// No relocation information when printing code stubs.
|
|
|
|
}
|
2008-07-30 08:49:36 +00:00
|
|
|
int constants = -1; // no constants being decoded at the start
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
while (pc < end) {
|
|
|
|
// First decode instruction so that we know its length.
|
|
|
|
byte* prev_pc = pc;
|
2008-07-30 08:49:36 +00:00
|
|
|
if (constants > 0) {
|
|
|
|
OS::SNPrintF(decode_buffer,
|
|
|
|
"%08x constant",
|
|
|
|
*reinterpret_cast<int32_t*>(pc));
|
|
|
|
constants--;
|
|
|
|
pc += 4;
|
|
|
|
} else {
|
|
|
|
int num_const = d.ConstantPoolSizeAt(pc);
|
|
|
|
if (num_const >= 0) {
|
|
|
|
OS::SNPrintF(decode_buffer,
|
|
|
|
"%08x constant pool begin",
|
|
|
|
*reinterpret_cast<int32_t*>(pc));
|
|
|
|
constants = num_const;
|
|
|
|
pc += 4;
|
2008-09-18 11:59:55 +00:00
|
|
|
} else if (it != NULL && !it->done() && it->rinfo()->pc() == pc &&
|
2008-09-22 13:57:03 +00:00
|
|
|
it->rinfo()->rmode() == RelocInfo::INTERNAL_REFERENCE) {
|
2008-09-18 11:59:55 +00:00
|
|
|
// raw pointer embedded in code stream, e.g., jump table
|
|
|
|
byte* ptr = *reinterpret_cast<byte**>(pc);
|
|
|
|
OS::SNPrintF(decode_buffer,
|
2009-05-12 10:33:40 +00:00
|
|
|
"%08" V8PRIxPTR " jump table entry %4" V8PRIdPTR,
|
|
|
|
ptr,
|
2008-09-18 11:59:55 +00:00
|
|
|
ptr - begin);
|
|
|
|
pc += 4;
|
2008-07-30 08:49:36 +00:00
|
|
|
} else {
|
|
|
|
decode_buffer[0] = '\0';
|
2008-09-11 14:34:48 +00:00
|
|
|
pc += d.InstructionDecode(decode_buffer, pc);
|
2008-07-30 08:49:36 +00:00
|
|
|
}
|
|
|
|
}
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Collect RelocInfo for this instruction (prev_pc .. pc-1)
|
|
|
|
List<const char*> comments(4);
|
|
|
|
List<byte*> pcs(1);
|
2008-09-22 13:57:03 +00:00
|
|
|
List<RelocInfo::Mode> rmodes(1);
|
2008-07-03 15:10:15 +00:00
|
|
|
List<intptr_t> datas(1);
|
|
|
|
if (it != NULL) {
|
|
|
|
while (!it->done() && it->rinfo()->pc() < pc) {
|
2008-09-22 13:57:03 +00:00
|
|
|
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
|
2008-07-03 15:10:15 +00:00
|
|
|
// For comments just collect the text.
|
|
|
|
comments.Add(reinterpret_cast<const char*>(it->rinfo()->data()));
|
|
|
|
} else {
|
|
|
|
// For other reloc info collect all data.
|
|
|
|
pcs.Add(it->rinfo()->pc());
|
|
|
|
rmodes.Add(it->rinfo()->rmode());
|
|
|
|
datas.Add(it->rinfo()->data());
|
|
|
|
}
|
|
|
|
it->next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Comments.
|
|
|
|
for (int i = 0; i < comments.length(); i++) {
|
2011-08-11 12:52:37 +00:00
|
|
|
out.AddFormatted(" %s", comments[i]);
|
|
|
|
DumpBuffer(f, &out);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Instruction address and instruction offset.
|
2008-07-30 08:49:36 +00:00
|
|
|
out.AddFormatted("%p %4d ", prev_pc, prev_pc - begin);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
// Instruction.
|
2008-09-11 14:34:48 +00:00
|
|
|
out.AddFormatted("%s", decode_buffer.start());
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Print all the reloc info for this instruction which are not comments.
|
|
|
|
for (int i = 0; i < pcs.length(); i++) {
|
|
|
|
// Put together the reloc info
|
2011-09-19 18:36:47 +00:00
|
|
|
RelocInfo relocinfo(pcs[i], rmodes[i], datas[i], NULL);
|
2008-07-03 15:10:15 +00:00
|
|
|
|
|
|
|
// Indent the printing of the reloc info.
|
|
|
|
if (i == 0) {
|
|
|
|
// The first reloc info is printed after the disassembled instruction.
|
2008-07-30 08:49:36 +00:00
|
|
|
out.AddPadding(' ', kRelocInfoPosition - out.position());
|
2008-07-03 15:10:15 +00:00
|
|
|
} else {
|
|
|
|
// Additional reloc infos are printed on separate lines.
|
2011-08-11 12:52:37 +00:00
|
|
|
DumpBuffer(f, &out);
|
2008-07-30 08:49:36 +00:00
|
|
|
out.AddPadding(' ', kRelocInfoPosition);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2008-09-22 13:57:03 +00:00
|
|
|
RelocInfo::Mode rmode = relocinfo.rmode();
|
|
|
|
if (RelocInfo::IsPosition(rmode)) {
|
|
|
|
if (RelocInfo::IsStatementPosition(rmode)) {
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted(" ;; debug: statement %d", relocinfo.data());
|
|
|
|
} else {
|
|
|
|
out.AddFormatted(" ;; debug: position %d", relocinfo.data());
|
|
|
|
}
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (rmode == RelocInfo::EMBEDDED_OBJECT) {
|
2008-07-03 15:10:15 +00:00
|
|
|
HeapStringAllocator allocator;
|
|
|
|
StringStream accumulator(&allocator);
|
|
|
|
relocinfo.target_object()->ShortPrint(&accumulator);
|
2011-09-09 22:39:47 +00:00
|
|
|
SmartArrayPointer<const char> obj_name = accumulator.ToCString();
|
2013-12-09 07:41:20 +00:00
|
|
|
out.AddFormatted(" ;; object: %s", obj_name.get());
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (rmode == RelocInfo::EXTERNAL_REFERENCE) {
|
2008-07-03 15:10:15 +00:00
|
|
|
const char* reference_name =
|
2013-11-05 09:22:35 +00:00
|
|
|
ref_encoder.NameOfAddress(relocinfo.target_reference());
|
2008-07-30 08:49:36 +00:00
|
|
|
out.AddFormatted(" ;; external reference (%s)", reference_name);
|
2008-09-22 13:57:03 +00:00
|
|
|
} else if (RelocInfo::IsCodeTarget(rmode)) {
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted(" ;; code:");
|
2008-09-22 13:57:03 +00:00
|
|
|
if (rmode == RelocInfo::CONSTRUCT_CALL) {
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted(" constructor,");
|
|
|
|
}
|
2008-12-09 12:53:59 +00:00
|
|
|
Code* code = Code::GetCodeFromTargetAddress(relocinfo.target_address());
|
2008-09-17 12:38:50 +00:00
|
|
|
Code::Kind kind = code->kind();
|
|
|
|
if (code->is_inline_cache_stub()) {
|
2014-01-17 11:08:24 +00:00
|
|
|
if (kind == Code::LOAD_IC &&
|
|
|
|
LoadIC::GetContextualMode(code->extra_ic_state()) == CONTEXTUAL) {
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted(" contextual,");
|
|
|
|
}
|
|
|
|
InlineCacheState ic_state = code->ic_state();
|
|
|
|
out.AddFormatted(" %s, %s", Code::Kind2String(kind),
|
|
|
|
Code::ICState2String(ic_state));
|
2009-06-30 10:05:36 +00:00
|
|
|
if (ic_state == MONOMORPHIC) {
|
2012-06-25 11:35:23 +00:00
|
|
|
Code::StubType type = code->type();
|
|
|
|
out.AddFormatted(", %s", Code::StubType2String(type));
|
2009-06-30 10:05:36 +00:00
|
|
|
}
|
2013-09-30 13:53:21 +00:00
|
|
|
} else if (kind == Code::STUB || kind == Code::HANDLER) {
|
2008-09-17 12:38:50 +00:00
|
|
|
// Reverse lookup required as the minor key cannot be retrieved
|
|
|
|
// from the code object.
|
2011-03-18 20:35:07 +00:00
|
|
|
Object* obj = heap->code_stubs()->SlowReverseLookup(code);
|
|
|
|
if (obj != heap->undefined_value()) {
|
2008-09-17 12:38:50 +00:00
|
|
|
ASSERT(obj->IsSmi());
|
|
|
|
// Get the STUB key and extract major and minor key.
|
|
|
|
uint32_t key = Smi::cast(obj)->value();
|
|
|
|
uint32_t minor_key = CodeStub::MinorKeyFromKey(key);
|
2010-08-30 11:48:07 +00:00
|
|
|
CodeStub::Major major_key = CodeStub::GetMajorKey(code);
|
|
|
|
ASSERT(major_key == CodeStub::MajorKeyFromKey(key));
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted(" %s, %s, ",
|
|
|
|
Code::Kind2String(kind),
|
2010-08-30 11:48:07 +00:00
|
|
|
CodeStub::MajorName(major_key, false));
|
|
|
|
switch (major_key) {
|
2011-01-06 14:13:40 +00:00
|
|
|
case CodeStub::CallFunction: {
|
|
|
|
int argc =
|
|
|
|
CallFunctionStub::ExtractArgcFromMinorKey(minor_key);
|
|
|
|
out.AddFormatted("argc = %d", argc);
|
2008-09-17 12:38:50 +00:00
|
|
|
break;
|
2011-01-06 14:13:40 +00:00
|
|
|
}
|
|
|
|
default:
|
2008-09-17 12:38:50 +00:00
|
|
|
out.AddFormatted("minor: %d", minor_key);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
2008-09-17 12:38:50 +00:00
|
|
|
} else {
|
|
|
|
out.AddFormatted(" %s", Code::Kind2String(kind));
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2011-04-27 15:02:59 +00:00
|
|
|
if (rmode == RelocInfo::CODE_TARGET_WITH_ID) {
|
|
|
|
out.AddFormatted(" (id = %d)", static_cast<int>(relocinfo.data()));
|
|
|
|
}
|
2013-03-13 11:40:26 +00:00
|
|
|
} else if (RelocInfo::IsRuntimeEntry(rmode) &&
|
2013-02-25 14:46:09 +00:00
|
|
|
isolate->deoptimizer_data() != NULL) {
|
2010-12-07 11:31:57 +00:00
|
|
|
// A runtime entry reloinfo might be a deoptimization bailout.
|
|
|
|
Address addr = relocinfo.target_address();
|
2013-03-18 13:57:49 +00:00
|
|
|
int id = Deoptimizer::GetDeoptimizationId(isolate,
|
|
|
|
addr,
|
|
|
|
Deoptimizer::EAGER);
|
2010-12-07 11:31:57 +00:00
|
|
|
if (id == Deoptimizer::kNotDeoptimizationEntry) {
|
2013-03-18 13:57:49 +00:00
|
|
|
id = Deoptimizer::GetDeoptimizationId(isolate,
|
|
|
|
addr,
|
|
|
|
Deoptimizer::LAZY);
|
2012-12-18 16:25:45 +00:00
|
|
|
if (id == Deoptimizer::kNotDeoptimizationEntry) {
|
2013-05-14 11:45:33 +00:00
|
|
|
id = Deoptimizer::GetDeoptimizationId(isolate,
|
|
|
|
addr,
|
|
|
|
Deoptimizer::SOFT);
|
|
|
|
if (id == Deoptimizer::kNotDeoptimizationEntry) {
|
|
|
|
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
|
|
|
|
} else {
|
|
|
|
out.AddFormatted(" ;; soft deoptimization bailout %d", id);
|
|
|
|
}
|
2012-12-18 16:25:45 +00:00
|
|
|
} else {
|
|
|
|
out.AddFormatted(" ;; lazy deoptimization bailout %d", id);
|
|
|
|
}
|
2010-12-07 11:31:57 +00:00
|
|
|
} else {
|
|
|
|
out.AddFormatted(" ;; deoptimization bailout %d", id);
|
|
|
|
}
|
2008-09-17 12:38:50 +00:00
|
|
|
} else {
|
|
|
|
out.AddFormatted(" ;; %s", RelocInfo::RelocModeName(rmode));
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
}
|
2011-08-11 12:52:37 +00:00
|
|
|
DumpBuffer(f, &out);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
2011-08-11 13:59:29 +00:00
|
|
|
// Emit comments following the last instruction (if any).
|
|
|
|
if (it != NULL) {
|
|
|
|
for ( ; !it->done(); it->next()) {
|
|
|
|
if (RelocInfo::IsComment(it->rinfo()->rmode())) {
|
|
|
|
out.AddFormatted(" %s",
|
|
|
|
reinterpret_cast<const char*>(it->rinfo()->data()));
|
|
|
|
DumpBuffer(f, &out);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
delete it;
|
2009-11-11 09:50:06 +00:00
|
|
|
return static_cast<int>(pc - begin);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-02-25 14:46:09 +00:00
|
|
|
int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) {
|
2008-07-03 15:10:15 +00:00
|
|
|
V8NameConverter defaultConverter(NULL);
|
2013-02-25 14:46:09 +00:00
|
|
|
return DecodeIt(isolate, f, defaultConverter, begin, end);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-07-30 08:49:36 +00:00
|
|
|
// Called by Code::CodePrint.
|
2008-07-03 15:10:15 +00:00
|
|
|
void Disassembler::Decode(FILE* f, Code* code) {
|
2013-02-25 14:46:09 +00:00
|
|
|
Isolate* isolate = code->GetIsolate();
|
2013-04-18 09:50:46 +00:00
|
|
|
int decode_size = code->is_crankshafted()
|
2011-02-03 10:07:22 +00:00
|
|
|
? static_cast<int>(code->safepoint_table_offset())
|
2010-12-07 11:31:57 +00:00
|
|
|
: code->instruction_size();
|
2013-04-10 09:24:31 +00:00
|
|
|
// If there might be a back edge table, stop before reaching it.
|
2010-12-07 11:31:57 +00:00
|
|
|
if (code->kind() == Code::FUNCTION) {
|
|
|
|
decode_size =
|
2013-04-10 09:24:31 +00:00
|
|
|
Min(decode_size, static_cast<int>(code->back_edge_table_offset()));
|
2010-12-07 11:31:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
byte* begin = code->instruction_start();
|
|
|
|
byte* end = begin + decode_size;
|
2008-07-03 15:10:15 +00:00
|
|
|
V8NameConverter v8NameConverter(code);
|
2013-02-25 14:46:09 +00:00
|
|
|
DecodeIt(isolate, f, v8NameConverter, begin, end);
|
2008-07-03 15:10:15 +00:00
|
|
|
}
|
2008-07-30 08:49:36 +00:00
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
#else // ENABLE_DISASSEMBLER
|
|
|
|
|
|
|
|
void Disassembler::Dump(FILE* f, byte* begin, byte* end) {}
|
2013-02-25 14:46:09 +00:00
|
|
|
int Disassembler::Decode(Isolate* isolate, FILE* f, byte* begin, byte* end) {
|
|
|
|
return 0;
|
|
|
|
}
|
2013-07-05 09:52:11 +00:00
|
|
|
|
|
|
|
|
2008-07-03 15:10:15 +00:00
|
|
|
void Disassembler::Decode(FILE* f, Code* code) {}
|
|
|
|
|
|
|
|
#endif // ENABLE_DISASSEMBLER
|
|
|
|
|
|
|
|
} } // namespace v8::internal
|