Commit 6898ff27 authored by lrn@chromium.org's avatar lrn@chromium.org

Remove one static initializer from disasm.

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@9752 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 215c26e3
...@@ -179,6 +179,10 @@ class InstructionTable { ...@@ -179,6 +179,10 @@ class InstructionTable {
public: public:
InstructionTable(); InstructionTable();
const InstructionDesc& Get(byte x) const { return instructions_[x]; } const InstructionDesc& Get(byte x) const { return instructions_[x]; }
static InstructionTable* get_instance() {
static InstructionTable table;
return &table;
}
private: private:
InstructionDesc instructions_[256]; InstructionDesc instructions_[256];
...@@ -259,15 +263,13 @@ void InstructionTable::AddJumpConditionalShort() { ...@@ -259,15 +263,13 @@ void InstructionTable::AddJumpConditionalShort() {
} }
static InstructionTable instruction_table;
// The IA32 disassembler implementation. // The IA32 disassembler implementation.
class DisassemblerIA32 { class DisassemblerIA32 {
public: public:
DisassemblerIA32(const NameConverter& converter, DisassemblerIA32(const NameConverter& converter,
bool abort_on_unimplemented = true) bool abort_on_unimplemented = true)
: converter_(converter), : instruction_table_(InstructionTabel::get_instance()),
converter_(converter),
tmp_buffer_pos_(0), tmp_buffer_pos_(0),
abort_on_unimplemented_(abort_on_unimplemented) { abort_on_unimplemented_(abort_on_unimplemented) {
tmp_buffer_[0] = '\0'; tmp_buffer_[0] = '\0';
...@@ -281,11 +283,11 @@ class DisassemblerIA32 { ...@@ -281,11 +283,11 @@ class DisassemblerIA32 {
private: private:
const NameConverter& converter_; const NameConverter& converter_;
InstructionTable* instruction_table_;
v8::internal::EmbeddedVector<char, 128> tmp_buffer_; v8::internal::EmbeddedVector<char, 128> tmp_buffer_;
unsigned int tmp_buffer_pos_; unsigned int tmp_buffer_pos_;
bool abort_on_unimplemented_; bool abort_on_unimplemented_;
enum { enum {
eax = 0, eax = 0,
ecx = 1, ecx = 1,
...@@ -884,7 +886,7 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer, ...@@ -884,7 +886,7 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector<char> out_buffer,
} }
bool processed = true; // Will be set to false if the current instruction bool processed = true; // Will be set to false if the current instruction
// is not in 'instructions' table. // is not in 'instructions' table.
const InstructionDesc& idesc = instruction_table.Get(*data); const InstructionDesc& idesc = instruction_table_->Get(*data);
switch (idesc.type) { switch (idesc.type) {
case ZERO_OPERANDS_INSTR: case ZERO_OPERANDS_INSTR:
AppendToBuffer(idesc.mnem); AppendToBuffer(idesc.mnem);
......
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