Revision: 19564
Author: [email protected]
Date: Wed Feb 26 14:50:58 2014 UTC
Log: A64: Hardwire the decoder and the simulator
If one of --trace-sim --debug-sim or --log-instruction-stats flags is
given, we use the decoder dispatcher instead.
BUG=none
[email protected], [email protected]
LOG=n
Review URL: https://codereview.chromium.org/177533023
http://code.google.com/p/v8/source/detail?r=19564
Modified:
/branches/bleeding_edge/src/a64/decoder-a64.h
/branches/bleeding_edge/src/a64/simulator-a64.cc
/branches/bleeding_edge/src/a64/simulator-a64.h
/branches/bleeding_edge/src/flag-definitions.h
=======================================
--- /branches/bleeding_edge/src/a64/decoder-a64.h Wed Feb 26 12:01:05 2014
UTC
+++ /branches/bleeding_edge/src/a64/decoder-a64.h Wed Feb 26 14:50:58 2014
UTC
@@ -146,10 +146,11 @@
class Decoder : public V {
public:
Decoder() {}
+ virtual ~Decoder() {}
// Top-level instruction decoder function. Decodes an instruction and
calls
// the visitor functions registered with the Decoder class.
- void Decode(Instruction *instr);
+ virtual void Decode(Instruction *instr);
private:
// Decode the PC relative addressing instruction, and call the
corresponding
=======================================
--- /branches/bleeding_edge/src/a64/simulator-a64.cc Wed Feb 26 12:01:05
2014 UTC
+++ /branches/bleeding_edge/src/a64/simulator-a64.cc Wed Feb 26 14:50:58
2014 UTC
@@ -105,8 +105,12 @@
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<DispatchingDecoderVisitor>(), isolate);
+ if (FLAG_trace_sim || FLAG_log_instruction_stats || FLAG_debug_sim) {
+ sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(),
isolate);
+ } else {
+ sim = new Decoder<Simulator>();
+ sim->isolate_ = isolate;
+ }
isolate_data->set_simulator(sim);
}
return sim;
@@ -343,6 +347,32 @@
// Setup the decoder.
decoder_->AppendVisitor(this);
+ Init(stream);
+
+ if (FLAG_trace_sim) {
+ decoder_->InsertVisitorBefore(print_disasm_, this);
+ log_parameters_ = LOG_ALL;
+ }
+
+ if (FLAG_log_instruction_stats) {
+ instrument_ = new Instrument(FLAG_log_instruction_file,
+ FLAG_log_instruction_period);
+ decoder_->AppendVisitor(instrument_);
+ }
+}
+
+
+Simulator::Simulator()
+ : decoder_(NULL),
+ last_debugger_input_(NULL),
+ log_parameters_(NO_PARAM),
+ isolate_(NULL) {
+ Init(NULL);
+ CHECK(!FLAG_trace_sim && !FLAG_log_instruction_stats);
+}
+
+
+void Simulator::Init(FILE* stream) {
ResetState();
// Allocate and setup the simulator stack.
@@ -356,21 +386,10 @@
stream_ = stream;
print_disasm_ = new PrintDisassembler(stream_);
- if (FLAG_trace_sim) {
- decoder_->InsertVisitorBefore(print_disasm_, this);
- log_parameters_ = LOG_ALL;
- }
-
// The debugger needs to disassemble code without the simulator
executing an
// instruction, so we create a dedicated decoder.
disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>();
disassembler_decoder_->AppendVisitor(print_disasm_);
-
- if (FLAG_log_instruction_stats) {
- instrument_ = new Instrument(FLAG_log_instruction_file,
- FLAG_log_instruction_period);
- decoder_->AppendVisitor(instrument_);
- }
}
@@ -405,6 +424,7 @@
delete disassembler_decoder_;
delete print_disasm_;
DeleteArray(last_debugger_input_);
+ delete decoder_;
}
=======================================
--- /branches/bleeding_edge/src/a64/simulator-a64.h Wed Feb 26 12:01:05
2014 UTC
+++ /branches/bleeding_edge/src/a64/simulator-a64.h Wed Feb 26 14:50:58
2014 UTC
@@ -195,6 +195,7 @@
explicit Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
Isolate* isolate = NULL,
FILE* stream = stderr);
+ Simulator();
~Simulator();
// System functions.
@@ -333,11 +334,15 @@
pc_modified_ = false;
}
+
+ virtual void Decode(Instruction* instr) {
+ decoder_->Decode(instr);
+ }
void ExecuteInstruction() {
ASSERT(IsAligned(reinterpret_cast<uintptr_t>(pc_), kInstructionSize));
CheckBreakNext();
- decoder_->Decode(pc_);
+ Decode(pc_);
LogProcessorState();
increment_pc();
CheckBreakpoints();
@@ -582,12 +587,18 @@
int log_parameters() { return log_parameters_; }
void set_log_parameters(int new_parameters) {
+ log_parameters_ = new_parameters;
+ if (!decoder_) {
+ if (new_parameters & LOG_DISASM) {
+ PrintF("Run --debug-sim to dynamically turn on disassembler\n");
+ }
+ return;
+ }
if (new_parameters & LOG_DISASM) {
decoder_->InsertVisitorBefore(print_disasm_, this);
} else {
decoder_->RemoveVisitor(print_disasm_);
}
- log_parameters_ = new_parameters;
}
static inline const char* WRegNameForCode(unsigned code,
@@ -819,6 +830,8 @@
char* last_debugger_input_;
private:
+ void Init(FILE* stream);
+
int log_parameters_;
Isolate* isolate_;
};
=======================================
--- /branches/bleeding_edge/src/flag-definitions.h Tue Feb 25 13:53:06 2014
UTC
+++ /branches/bleeding_edge/src/flag-definitions.h Wed Feb 26 14:50:58 2014
UTC
@@ -585,6 +585,7 @@
// simulator-arm.cc, simulator-a64.cc and simulator-mips.cc
DEFINE_bool(trace_sim, false, "Trace simulator execution")
+DEFINE_bool(debug_sim, false, "Enable debugging the simulator")
DEFINE_bool(check_icache, false,
"Check icache flushes in ARM and MIPS simulator")
DEFINE_int(stop_sim_at, 0, "Simulator stop after x number of instructions")
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.