From 6898ff2780ad74e508043fa0a97b2f5422b67e08 Mon Sep 17 00:00:00 2001 From: "lrn@chromium.org" Date: Mon, 24 Oct 2011 12:07:35 +0000 Subject: [PATCH] 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 --- src/ia32/disasm-ia32.cc | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/ia32/disasm-ia32.cc b/src/ia32/disasm-ia32.cc index 04edc5f42..8ece804c6 100644 --- a/src/ia32/disasm-ia32.cc +++ b/src/ia32/disasm-ia32.cc @@ -179,6 +179,10 @@ class InstructionTable { public: InstructionTable(); const InstructionDesc& Get(byte x) const { return instructions_[x]; } + static InstructionTable* get_instance() { + static InstructionTable table; + return &table; + } private: InstructionDesc instructions_[256]; @@ -259,15 +263,13 @@ void InstructionTable::AddJumpConditionalShort() { } -static InstructionTable instruction_table; - - // The IA32 disassembler implementation. class DisassemblerIA32 { public: DisassemblerIA32(const NameConverter& converter, bool abort_on_unimplemented = true) - : converter_(converter), + : instruction_table_(InstructionTabel::get_instance()), + converter_(converter), tmp_buffer_pos_(0), abort_on_unimplemented_(abort_on_unimplemented) { tmp_buffer_[0] = '\0'; @@ -281,11 +283,11 @@ class DisassemblerIA32 { private: const NameConverter& converter_; + InstructionTable* instruction_table_; v8::internal::EmbeddedVector tmp_buffer_; unsigned int tmp_buffer_pos_; bool abort_on_unimplemented_; - enum { eax = 0, ecx = 1, @@ -884,7 +886,7 @@ int DisassemblerIA32::InstructionDecode(v8::internal::Vector out_buffer, } bool processed = true; // Will be set to false if the current instruction // is not in 'instructions' table. - const InstructionDesc& idesc = instruction_table.Get(*data); + const InstructionDesc& idesc = instruction_table_->Get(*data); switch (idesc.type) { case ZERO_OPERANDS_INSTR: AppendToBuffer(idesc.mnem); -- 2.34.1