Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(426)

Side by Side Diff: src/a64/simulator-a64.cc

Issue 177533023: A64: Hardwire the decoder and the simulator (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/a64/simulator-a64.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 98
99 99
100 // Get the active Simulator for the current thread. 100 // Get the active Simulator for the current thread.
101 Simulator* Simulator::current(Isolate* isolate) { 101 Simulator* Simulator::current(Isolate* isolate) {
102 Isolate::PerIsolateThreadData* isolate_data = 102 Isolate::PerIsolateThreadData* isolate_data =
103 isolate->FindOrAllocatePerThreadDataForThisThread(); 103 isolate->FindOrAllocatePerThreadDataForThisThread();
104 ASSERT(isolate_data != NULL); 104 ASSERT(isolate_data != NULL);
105 105
106 Simulator* sim = isolate_data->simulator(); 106 Simulator* sim = isolate_data->simulator();
107 if (sim == NULL) { 107 if (sim == NULL) {
108 // TODO(146): delete the simulator object when a thread/isolate goes away. 108 if (FLAG_trace_sim || FLAG_log_instruction_stats || FLAG_debug_sim) {
109 sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(), isolate); 109 sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(), isolate);
110 } else {
111 sim = new Decoder<Simulator>();
112 sim->isolate_ = isolate;
113 }
110 isolate_data->set_simulator(sim); 114 isolate_data->set_simulator(sim);
111 } 115 }
112 return sim; 116 return sim;
113 } 117 }
114 118
115 119
116 void Simulator::CallVoid(byte* entry, CallArgument* args) { 120 void Simulator::CallVoid(byte* entry, CallArgument* args) {
117 int index_x = 0; 121 int index_x = 0;
118 int index_d = 0; 122 int index_d = 0;
119 123
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 340
337 Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder, 341 Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
338 Isolate* isolate, FILE* stream) 342 Isolate* isolate, FILE* stream)
339 : decoder_(decoder), 343 : decoder_(decoder),
340 last_debugger_input_(NULL), 344 last_debugger_input_(NULL),
341 log_parameters_(NO_PARAM), 345 log_parameters_(NO_PARAM),
342 isolate_(isolate) { 346 isolate_(isolate) {
343 // Setup the decoder. 347 // Setup the decoder.
344 decoder_->AppendVisitor(this); 348 decoder_->AppendVisitor(this);
345 349
350 Init(stream);
351
352 if (FLAG_trace_sim) {
353 decoder_->InsertVisitorBefore(print_disasm_, this);
354 log_parameters_ = LOG_ALL;
355 }
356
357 if (FLAG_log_instruction_stats) {
358 instrument_ = new Instrument(FLAG_log_instruction_file,
359 FLAG_log_instruction_period);
360 decoder_->AppendVisitor(instrument_);
361 }
362 }
363
364
365 Simulator::Simulator()
366 : decoder_(NULL),
367 last_debugger_input_(NULL),
368 log_parameters_(NO_PARAM),
369 isolate_(NULL) {
370 Init(NULL);
371 CHECK(!FLAG_trace_sim && !FLAG_log_instruction_stats);
372 }
373
374
375 void Simulator::Init(FILE* stream) {
346 ResetState(); 376 ResetState();
347 377
348 // Allocate and setup the simulator stack. 378 // Allocate and setup the simulator stack.
349 stack_size_ = (FLAG_sim_stack_size * KB) + (2 * stack_protection_size_); 379 stack_size_ = (FLAG_sim_stack_size * KB) + (2 * stack_protection_size_);
350 stack_ = new byte[stack_size_]; 380 stack_ = new byte[stack_size_];
351 stack_limit_ = stack_ + stack_protection_size_; 381 stack_limit_ = stack_ + stack_protection_size_;
352 byte* tos = stack_ + stack_size_ - stack_protection_size_; 382 byte* tos = stack_ + stack_size_ - stack_protection_size_;
353 // The stack pointer must be 16 bytes aligned. 383 // The stack pointer must be 16 bytes aligned.
354 set_sp(reinterpret_cast<int64_t>(tos) & ~0xfUL); 384 set_sp(reinterpret_cast<int64_t>(tos) & ~0xfUL);
355 385
356 stream_ = stream; 386 stream_ = stream;
357 print_disasm_ = new PrintDisassembler(stream_); 387 print_disasm_ = new PrintDisassembler(stream_);
358 388
359 if (FLAG_trace_sim) {
360 decoder_->InsertVisitorBefore(print_disasm_, this);
361 log_parameters_ = LOG_ALL;
362 }
363
364 // The debugger needs to disassemble code without the simulator executing an 389 // The debugger needs to disassemble code without the simulator executing an
365 // instruction, so we create a dedicated decoder. 390 // instruction, so we create a dedicated decoder.
366 disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>(); 391 disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>();
367 disassembler_decoder_->AppendVisitor(print_disasm_); 392 disassembler_decoder_->AppendVisitor(print_disasm_);
368
369 if (FLAG_log_instruction_stats) {
370 instrument_ = new Instrument(FLAG_log_instruction_file,
371 FLAG_log_instruction_period);
372 decoder_->AppendVisitor(instrument_);
373 }
374 } 393 }
375 394
376 395
377 void Simulator::ResetState() { 396 void Simulator::ResetState() {
378 // Reset the system registers. 397 // Reset the system registers.
379 nzcv_ = SimSystemRegister::DefaultValueFor(NZCV); 398 nzcv_ = SimSystemRegister::DefaultValueFor(NZCV);
380 fpcr_ = SimSystemRegister::DefaultValueFor(FPCR); 399 fpcr_ = SimSystemRegister::DefaultValueFor(FPCR);
381 400
382 // Reset registers to 0. 401 // Reset registers to 0.
383 pc_ = NULL; 402 pc_ = NULL;
(...skipping 14 matching lines...) Expand all
398 417
399 418
400 Simulator::~Simulator() { 419 Simulator::~Simulator() {
401 delete[] stack_; 420 delete[] stack_;
402 if (FLAG_log_instruction_stats) { 421 if (FLAG_log_instruction_stats) {
403 delete instrument_; 422 delete instrument_;
404 } 423 }
405 delete disassembler_decoder_; 424 delete disassembler_decoder_;
406 delete print_disasm_; 425 delete print_disasm_;
407 DeleteArray(last_debugger_input_); 426 DeleteArray(last_debugger_input_);
427 delete decoder_;
408 } 428 }
409 429
410 430
411 void Simulator::Run() { 431 void Simulator::Run() {
412 pc_modified_ = false; 432 pc_modified_ = false;
413 while (pc_ != kEndOfSimAddress) { 433 while (pc_ != kEndOfSimAddress) {
414 ExecuteInstruction(); 434 ExecuteInstruction();
415 } 435 }
416 } 436 }
417 437
(...skipping 2991 matching lines...) Expand 10 before | Expand all | Expand 10 after
3409 default: 3429 default:
3410 UNIMPLEMENTED(); 3430 UNIMPLEMENTED();
3411 } 3431 }
3412 } 3432 }
3413 3433
3414 #endif // USE_SIMULATOR 3434 #endif // USE_SIMULATOR
3415 3435
3416 } } // namespace v8::internal 3436 } } // namespace v8::internal
3417 3437
3418 #endif // V8_TARGET_ARCH_A64 3438 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « src/a64/simulator-a64.h ('k') | src/flag-definitions.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698