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

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

Issue 181253002: A64: Make the Decoder a template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 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') | test/cctest/test-assembler-a64.cc » ('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 16 matching lines...) Expand all
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <cmath> 29 #include <cmath>
30 #include <cstdarg> 30 #include <cstdarg>
31 #include "v8.h" 31 #include "v8.h"
32 32
33 #if V8_TARGET_ARCH_A64 33 #if V8_TARGET_ARCH_A64
34 34
35 #include "disasm.h" 35 #include "disasm.h"
36 #include "assembler.h" 36 #include "assembler.h"
37 #include "a64/decoder-a64-inl.h"
37 #include "a64/simulator-a64.h" 38 #include "a64/simulator-a64.h"
38 #include "macro-assembler.h" 39 #include "macro-assembler.h"
39 40
40 namespace v8 { 41 namespace v8 {
41 namespace internal { 42 namespace internal {
42 43
43 #if defined(USE_SIMULATOR) 44 #if defined(USE_SIMULATOR)
44 45
45 46
46 // This macro provides a platform independent use of sscanf. The reason for 47 // This macro provides a platform independent use of sscanf. The reason for
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 99
99 // Get the active Simulator for the current thread. 100 // Get the active Simulator for the current thread.
100 Simulator* Simulator::current(Isolate* isolate) { 101 Simulator* Simulator::current(Isolate* isolate) {
101 Isolate::PerIsolateThreadData* isolate_data = 102 Isolate::PerIsolateThreadData* isolate_data =
102 isolate->FindOrAllocatePerThreadDataForThisThread(); 103 isolate->FindOrAllocatePerThreadDataForThisThread();
103 ASSERT(isolate_data != NULL); 104 ASSERT(isolate_data != NULL);
104 105
105 Simulator* sim = isolate_data->simulator(); 106 Simulator* sim = isolate_data->simulator();
106 if (sim == NULL) { 107 if (sim == NULL) {
107 // TODO(146): delete the simulator object when a thread/isolate goes away. 108 // TODO(146): delete the simulator object when a thread/isolate goes away.
108 sim = new Simulator(new Decoder(), isolate); 109 sim = new Simulator(new Decoder<DispatchingDecoderVisitor>(), isolate);
109 isolate_data->set_simulator(sim); 110 isolate_data->set_simulator(sim);
110 } 111 }
111 return sim; 112 return sim;
112 } 113 }
113 114
114 115
115 void Simulator::CallVoid(byte* entry, CallArgument* args) { 116 void Simulator::CallVoid(byte* entry, CallArgument* args) {
116 int index_x = 0; 117 int index_x = 0;
117 int index_d = 0; 118 int index_d = 0;
118 119
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 // pushing values. 327 // pushing values.
327 // TODO(all): Increase the stack limit protection. 328 // TODO(all): Increase the stack limit protection.
328 329
329 // The margin was decreased to 256 bytes, because we are intensively using 330 // The margin was decreased to 256 bytes, because we are intensively using
330 // the stack. The stack usage should decrease when our code improves. Then 331 // the stack. The stack usage should decrease when our code improves. Then
331 // we can set it to 1024 again. 332 // we can set it to 1024 again.
332 return reinterpret_cast<uintptr_t>(stack_limit_) + 256; 333 return reinterpret_cast<uintptr_t>(stack_limit_) + 256;
333 } 334 }
334 335
335 336
336 Simulator::Simulator(Decoder* decoder, Isolate* isolate, FILE* stream) 337 Simulator::Simulator(Decoder<DispatchingDecoderVisitor>* decoder,
337 : decoder_(decoder), last_debugger_input_(NULL), log_parameters_(NO_PARAM), 338 Isolate* isolate, FILE* stream)
339 : decoder_(decoder),
340 last_debugger_input_(NULL),
341 log_parameters_(NO_PARAM),
338 isolate_(isolate) { 342 isolate_(isolate) {
339 // Setup the decoder. 343 // Setup the decoder.
340 decoder_->AppendVisitor(this); 344 decoder_->AppendVisitor(this);
341 345
342 ResetState(); 346 ResetState();
343 347
344 // Allocate and setup the simulator stack. 348 // Allocate and setup the simulator stack.
345 stack_size_ = (FLAG_sim_stack_size * KB) + (2 * stack_protection_size_); 349 stack_size_ = (FLAG_sim_stack_size * KB) + (2 * stack_protection_size_);
346 stack_ = new byte[stack_size_]; 350 stack_ = new byte[stack_size_];
347 stack_limit_ = stack_ + stack_protection_size_; 351 stack_limit_ = stack_ + stack_protection_size_;
348 byte* tos = stack_ + stack_size_ - stack_protection_size_; 352 byte* tos = stack_ + stack_size_ - stack_protection_size_;
349 // The stack pointer must be 16 bytes aligned. 353 // The stack pointer must be 16 bytes aligned.
350 set_sp(reinterpret_cast<int64_t>(tos) & ~0xfUL); 354 set_sp(reinterpret_cast<int64_t>(tos) & ~0xfUL);
351 355
352 stream_ = stream; 356 stream_ = stream;
353 print_disasm_ = new PrintDisassembler(stream_); 357 print_disasm_ = new PrintDisassembler(stream_);
354 358
355 if (FLAG_trace_sim) { 359 if (FLAG_trace_sim) {
356 decoder_->InsertVisitorBefore(print_disasm_, this); 360 decoder_->InsertVisitorBefore(print_disasm_, this);
357 log_parameters_ = LOG_ALL; 361 log_parameters_ = LOG_ALL;
358 } 362 }
359 363
360 // The debugger needs to disassemble code without the simulator executing an 364 // The debugger needs to disassemble code without the simulator executing an
361 // instruction, so we create a dedicated decoder. 365 // instruction, so we create a dedicated decoder.
362 disassembler_decoder_ = new Decoder(); 366 disassembler_decoder_ = new Decoder<DispatchingDecoderVisitor>();
363 disassembler_decoder_->AppendVisitor(print_disasm_); 367 disassembler_decoder_->AppendVisitor(print_disasm_);
364 368
365 if (FLAG_log_instruction_stats) { 369 if (FLAG_log_instruction_stats) {
366 instrument_ = new Instrument(FLAG_log_instruction_file, 370 instrument_ = new Instrument(FLAG_log_instruction_file,
367 FLAG_log_instruction_period); 371 FLAG_log_instruction_period);
368 decoder_->AppendVisitor(instrument_); 372 decoder_->AppendVisitor(instrument_);
369 } 373 }
370 } 374 }
371 375
372 376
(...skipping 3032 matching lines...) Expand 10 before | Expand all | Expand 10 after
3405 default: 3409 default:
3406 UNIMPLEMENTED(); 3410 UNIMPLEMENTED();
3407 } 3411 }
3408 } 3412 }
3409 3413
3410 #endif // USE_SIMULATOR 3414 #endif // USE_SIMULATOR
3411 3415
3412 } } // namespace v8::internal 3416 } } // namespace v8::internal
3413 3417
3414 #endif // V8_TARGET_ARCH_A64 3418 #endif // V8_TARGET_ARCH_A64
OLDNEW
« no previous file with comments | « src/a64/simulator-a64.h ('k') | test/cctest/test-assembler-a64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698