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 {
class Debugger : public Simulator {
public:
Debugger(Decoder* decoder, FILE* stream = stderr)
Debugger(Decoder<DispatchingDecoderVisitor>* decoder, FILE* stream = stderr)
: Simulator(decoder, NULL, stream) {}
// Functions overloading.
......
This diff is collapsed.
This diff is collapsed.
......@@ -142,7 +142,8 @@ class DispatchingDecoderVisitor : public DecoderVisitor {
};
class Decoder : public DispatchingDecoderVisitor {
template<typename V>
class Decoder : public V {
public:
Decoder() {}
......
......@@ -35,6 +35,7 @@
#if V8_TARGET_ARCH_A64
#include "disasm.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h"
#include "macro-assembler.h"
#include "platform.h"
......@@ -1824,7 +1825,7 @@ Disassembler::~Disassembler() {}
int Disassembler::InstructionDecode(v8::internal::Vector<char> buffer,
byte* instr) {
v8::internal::Decoder decoder;
v8::internal::Decoder<v8::internal::DispatchingDecoderVisitor> decoder;
BufferDisassembler disasm(buffer);
decoder.AppendVisitor(&disasm);
......@@ -1840,7 +1841,7 @@ int Disassembler::ConstantPoolSizeAt(byte* instr) {
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);
decoder.AppendVisitor(&disasm);
......
......@@ -34,6 +34,7 @@
#include "disasm.h"
#include "assembler.h"
#include "a64/decoder-a64-inl.h"
#include "a64/simulator-a64.h"
#include "macro-assembler.h"
......@@ -105,7 +106,7 @@ Simulator* Simulator::current(Isolate* isolate) {
Simulator* sim = isolate_data->simulator();
if (sim == NULL) {
// 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);
}
return sim;
......@@ -333,8 +334,11 @@ uintptr_t Simulator::StackLimit() const {
}
Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream)
: decoder_(decoder), last_debugger_input_(NULL), log_parameters_(NO_PARAM),
Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate, FILE* stream)
: decoder_(decoder),
last_debugger_input_(NULL),
log_parameters_(NO_PARAM),
isolate_(isolate) {
// Setup the decoder.
decoder_->AppendVisitor(this);
......@@ -359,7 +363,7 @@ Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream)
// The debugger needs to disassemble code without the simulator executing an
// instruction, so we create a dedicated decoder.
disassembler_decoder_ = new Decoder();
disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>();
disassembler_decoder_->AppendVisitor(print_disasm_);
if (FLAG_log_instruction_stats) {
......
......@@ -192,7 +192,7 @@ typedef SimRegisterBase<kDRegSizeInBytes> SimFPRegister; // v0-v31
class Simulator : public DecoderVisitor {
public:
explicit Simulator(Decoder* decoder,
explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate = NULL,
FILE* stream = stderr);
~Simulator();
......@@ -796,8 +796,8 @@ class Simulator : public DecoderVisitor {
byte* stack_limit_;
// TODO(aleram): protect the stack.
Decoder* decoder_;
Decoder* disassembler_decoder_;
Decoder<DispatchingDecoderVisitor>* decoder_;
Decoder<DispatchingDecoderVisitor>* disassembler_decoder_;
// Indicates if the pc has been modified by the instruction and should not be
// automatically incremented.
......
......@@ -35,6 +35,7 @@
#include "macro-assembler.h"
#include "a64/simulator-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h"
#include "a64/utils-a64.h"
#include "cctest.h"
......@@ -112,15 +113,15 @@ static void InitializeVM() {
#ifdef USE_SIMULATOR
// Run tests with the simulator.
#define SETUP_SIZE(buf_size) \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
ASSERT(isolate != NULL); \
byte* buf = new byte[buf_size]; \
MacroAssembler masm(isolate, buf, buf_size); \
Decoder decoder; \
Simulator simulator(&decoder); \
PrintDisassembler* pdis = NULL; \
#define SETUP_SIZE(buf_size) \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
ASSERT(isolate != NULL); \
byte* buf = new byte[buf_size]; \
MacroAssembler masm(isolate, buf, buf_size); \
Decoder<DispatchingDecoderVisitor> decoder; \
Simulator simulator(&decoder); \
PrintDisassembler* pdis = NULL; \
RegisterDump core;
/* if (Cctest::trace_sim()) { \
......
......@@ -34,6 +34,7 @@
#include "macro-assembler.h"
#include "a64/assembler-a64.h"
#include "a64/macro-assembler-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h"
#include "a64/utils-a64.h"
......@@ -43,15 +44,16 @@ using namespace v8::internal;
#define EXP_SIZE (256)
#define INSTR_SIZE (1024)
#define SET_UP_CLASS(ASMCLASS) \
InitializeVM(); \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); \
uint32_t encoding = 0; \
ASMCLASS* assm = new ASMCLASS(isolate, buf, INSTR_SIZE); \
Decoder* decoder = new Decoder(); \
Disassembler* disasm = new Disassembler(); \
#define SET_UP_CLASS(ASMCLASS) \
InitializeVM(); \
Isolate* isolate = Isolate::Current(); \
HandleScope scope(isolate); \
byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); \
uint32_t encoding = 0; \
ASMCLASS* assm = new ASMCLASS(isolate, buf, INSTR_SIZE); \
Decoder<DispatchingDecoderVisitor>* decoder = \
new Decoder<DispatchingDecoderVisitor>(); \
Disassembler* disasm = new Disassembler(); \
decoder->AppendVisitor(disasm)
#define SET_UP() SET_UP_CLASS(Assembler)
......
......@@ -26,6 +26,7 @@
#include "cctest.h"
#include "a64/decoder-a64.h"
#include "a64/decoder-a64-inl.h"
#include "a64/disasm-a64.h"
using namespace v8::internal;
......@@ -38,7 +39,7 @@ TEST(FUZZ_decoder) {
uint16_t seed[3] = {1, 2, 3};
seed48(seed);
Decoder decoder;
Decoder<DispatchingDecoderVisitor> decoder;
Instruction buffer[kInstructionSize];
for (int i = 0; i < instruction_count; i++) {
......@@ -57,7 +58,7 @@ TEST(FUZZ_disasm) {
uint16_t seed[3] = {42, 43, 44};
seed48(seed);
Decoder decoder;
Decoder<DispatchingDecoderVisitor> decoder;
Disassembler disasm;
Instruction buffer[kInstructionSize];
......
......@@ -664,6 +664,7 @@
'../../src/a64/debugger-a64.h',
'../../src/a64/decoder-a64.cc',
'../../src/a64/decoder-a64.h',
'../../src/a64/decoder-a64-inl.h',
'../../src/a64/deoptimizer-a64.cc',
'../../src/a64/disasm-a64.cc',
'../../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