Commit 597a4b4d authored by jochen@chromium.org's avatar jochen@chromium.org

A64: Make the Decoder a template

This will allow for replacing the dispatcher with a concrete decoder
visitor.

BUG=none
R=ulan@chromium.org, rodolph.perfetta@arm.com
LOG=n

Review URL: https://codereview.chromium.org/181253002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19562 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 662bb0cc
...@@ -41,7 +41,7 @@ namespace internal { ...@@ -41,7 +41,7 @@ namespace internal {
class Debugger : public Simulator { class Debugger : public Simulator {
public: public:
Debugger(Decoder* decoder, FILE* stream = stderr) Debugger(Decoder<DispatchingDecoderVisitor>* decoder, FILE* stream = stderr)
: Simulator(decoder, NULL, stream) {} : Simulator(decoder, NULL, stream) {}
// Functions overloading. // Functions overloading.
......
This diff is collapsed.
This diff is collapsed.
...@@ -142,7 +142,8 @@ class DispatchingDecoderVisitor : public DecoderVisitor { ...@@ -142,7 +142,8 @@ class DispatchingDecoderVisitor : public DecoderVisitor {
}; };
class Decoder : public DispatchingDecoderVisitor { template<typename V>
class Decoder : public V {
public: public:
Decoder() {} Decoder() {}
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#if V8_TARGET_ARCH_A64 #if V8_TARGET_ARCH_A64
#include "disasm.h" #include "disasm.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h" #include "a64/disasm-a64.h"
#include "macro-assembler.h" #include "macro-assembler.h"
#include "platform.h" #include "platform.h"
...@@ -1824,7 +1825,7 @@ Disassembler::~Disassembler() {} ...@@ -1824,7 +1825,7 @@ Disassembler::~Disassembler() {}
int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer, int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer,
byte* instr) { byte* instr) {
v8::internal::Decoder decoder; v8::internal::Decoder<v8::internal::DispatchingDecoderVisitor> decoder;
BufferDisassembler disasm(buffer); BufferDisassembler disasm(buffer);
decoder.AppendVisitor(&disasm); decoder.AppendVisitor(&disasm);
...@@ -1840,7 +1841,7 @@ int Disassembler::ConstantPoolSizeAt(byte* instr) { ...@@ -1840,7 +1841,7 @@ int Disassembler::ConstantPoolSizeAt(byte* instr) {
void Disassembler::Disassemble(FILE* file, byte* start, byte* end) { void Disassembler::Disassemble(FILE* file, byte* start, byte* end) {
v8::internal::Decoder decoder; v8::internal::Decoder<v8::internal::DispatchingDecoderVisitor> decoder;
v8::internal::PrintDisassembler disasm(file); v8::internal::PrintDisassembler disasm(file);
decoder.AppendVisitor(&disasm); decoder.AppendVisitor(&disasm);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "disasm.h" #include "disasm.h"
#include "assembler.h" #include "assembler.h"
#include "a64/decoder-a64-inl.h"
#include "a64/simulator-a64.h" #include "a64/simulator-a64.h"
#include "macro-assembler.h" #include "macro-assembler.h"
...@@ -105,7 +106,7 @@ Simulator* Simulator::current(Isolate* isolate) { ...@@ -105,7 +106,7 @@ Simulator* Simulator::current(Isolate* isolate) {
Simulator* sim = isolate_data->simulator(); Simulator* sim = isolate_data->simulator();
if (sim == NULL) { if (sim == NULL) {
// TODO(146): delete the simulator object when a thread/isolate goes away. // TODO(146): delete the simulator object when a thread/isolate goes away.
sim = new Simulator(new Decoder(), isolate); sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(), isolate);
isolate_data->set_simulator(sim); isolate_data->set_simulator(sim);
} }
return sim; return sim;
...@@ -333,8 +334,11 @@ uintptr_t Simulator::StackLimit() const { ...@@ -333,8 +334,11 @@ uintptr_t Simulator::StackLimit() const {
} }
Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream) Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
: decoder_(decoder), last_debugger_input_(NULL), log_parameters_(NO_PARAM), Isolate* isolate, FILE* stream)
: decoder_(decoder),
last_debugger_input_(NULL),
log_parameters_(NO_PARAM),
isolate_(isolate) { isolate_(isolate) {
// Setup the decoder. // Setup the decoder.
decoder_->AppendVisitor(this); decoder_->AppendVisitor(this);
...@@ -359,7 +363,7 @@ Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream) ...@@ -359,7 +363,7 @@ Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream)
// The debugger needs to disassemble code without the simulator executing an // The debugger needs to disassemble code without the simulator executing an
// instruction, so we create a dedicated decoder. // instruction, so we create a dedicated decoder.
disassembler_decoder_ = new Decoder(); disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>();
disassembler_decoder_->AppendVisitor(print_disasm_); disassembler_decoder_->AppendVisitor(print_disasm_);
if (FLAG_log_instruction_stats) { if (FLAG_log_instruction_stats) {
......
...@@ -192,7 +192,7 @@ typedef SimRegisterBase<kDRegSizeInBytes> SimFPRegister; // v0-v31 ...@@ -192,7 +192,7 @@ typedef SimRegisterBase<kDRegSizeInBytes> SimFPRegister; // v0-v31
class Simulator : public DecoderVisitor { class Simulator : public DecoderVisitor {
public: public:
explicit Simulator(Decoder* decoder, explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate = NULL, Isolate* isolate = NULL,
FILE* stream = stderr); FILE* stream = stderr);
~Simulator(); ~Simulator();
...@@ -796,8 +796,8 @@ class Simulator : public DecoderVisitor { ...@@ -796,8 +796,8 @@ class Simulator : public DecoderVisitor {
byte* stack_limit_; byte* stack_limit_;
// TODO(aleram): protect the stack. // TODO(aleram): protect the stack.
Decoder* decoder_; Decoder<DispatchingDecoderVisitor>* decoder_;
Decoder* disassembler_decoder_; Decoder<DispatchingDecoderVisitor>* disassembler_decoder_;
// Indicates if the pc has been modified by the instruction and should not be // Indicates if the pc has been modified by the instruction and should not be
// automatically incremented. // automatically incremented.
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "macro-assembler.h" #include "macro-assembler.h"
#include "a64/simulator-a64.h" #include "a64/simulator-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h" #include "a64/disasm-a64.h"
#include "a64/utils-a64.h" #include "a64/utils-a64.h"
#include "cctest.h" #include "cctest.h"
...@@ -118,7 +119,7 @@ static void InitializeVM() { ...@@ -118,7 +119,7 @@ static void InitializeVM() {
ASSERT(isolate != NULL); \ ASSERT(isolate != NULL); \
byte* buf = new byte[buf_size]; \ byte* buf = new byte[buf_size]; \
MacroAssembler masm(isolate, buf, buf_size); \ MacroAssembler masm(isolate, buf, buf_size); \
Decoder decoder; \ Decoder<DispatchingDecoderVisitor> decoder; \
Simulator simulator(&decoder); \ Simulator simulator(&decoder); \
PrintDisassembler* pdis = NULL; \ PrintDisassembler* pdis = NULL; \
RegisterDump core; RegisterDump core;
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#include "macro-assembler.h" #include "macro-assembler.h"
#include "a64/assembler-a64.h" #include "a64/assembler-a64.h"
#include "a64/macro-assembler-a64.h" #include "a64/macro-assembler-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h" #include "a64/disasm-a64.h"
#include "a64/utils-a64.h" #include "a64/utils-a64.h"
...@@ -50,7 +51,8 @@ using namespace v8::internal; ...@@ -50,7 +51,8 @@ using namespace v8::internal;
byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); \ byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); \
uint32_t encoding = 0; \ uint32_t encoding = 0; \
ASMCLASS* assm = new ASMCLASS(isolate, buf, INSTR_SIZE); \ ASMCLASS* assm = new ASMCLASS(isolate, buf, INSTR_SIZE); \
Decoder* decoder = new Decoder(); \ Decoder<DispatchingDecoderVisitor>* decoder = \
new Decoder<DispatchingDecoderVisitor>(); \
Disassembler* disasm = new Disassembler(); \ Disassembler* disasm = new Disassembler(); \
decoder->AppendVisitor(disasm) decoder->AppendVisitor(disasm)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "cctest.h" #include "cctest.h"
#include "a64/decoder-a64.h" #include "a64/decoder-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h" #include "a64/disasm-a64.h"
using namespace v8::internal; using namespace v8::internal;
...@@ -38,7 +39,7 @@ TEST(FUZZ_decoder) { ...@@ -38,7 +39,7 @@ TEST(FUZZ_decoder) {
uint16_t seed[3] = {1, 2, 3}; uint16_t seed[3] = {1, 2, 3};
seed48(seed); seed48(seed);
Decoder decoder; Decoder<DispatchingDecoderVisitor> decoder;
Instruction buffer[kInstructionSize]; Instruction buffer[kInstructionSize];
for (int i = 0; i < instruction_count; i++) { for (int i = 0; i < instruction_count; i++) {
...@@ -57,7 +58,7 @@ TEST(FUZZ_disasm) { ...@@ -57,7 +58,7 @@ TEST(FUZZ_disasm) {
uint16_t seed[3] = {42, 43, 44}; uint16_t seed[3] = {42, 43, 44};
seed48(seed); seed48(seed);
Decoder decoder; Decoder<DispatchingDecoderVisitor> decoder;
Disassembler disasm; Disassembler disasm;
Instruction buffer[kInstructionSize]; Instruction buffer[kInstructionSize];
......
...@@ -664,6 +664,7 @@ ...@@ -664,6 +664,7 @@
'../../src/a64/debugger-a64.h', '../../src/a64/debugger-a64.h',
'../../src/a64/decoder-a64.cc', '../../src/a64/decoder-a64.cc',
'../../src/a64/decoder-a64.h', '../../src/a64/decoder-a64.h',
'../../src/a64/decoder-a64-inl.h',
'../../src/a64/deoptimizer-a64.cc', '../../src/a64/deoptimizer-a64.cc',
'../../src/a64/disasm-a64.cc', '../../src/a64/disasm-a64.cc',
'../../src/a64/disasm-a64.h', '../../src/a64/disasm-a64.h',
......
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