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

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

Issue 500095: As a first step towards implementing thumb2, add code for... Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years 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
« src/arm/assembler-thumb2.cc ('K') | « src/arm/simulator-arm.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 414
415 415
416 Simulator::Simulator() { 416 Simulator::Simulator() {
417 Initialize(); 417 Initialize();
418 // Setup simulator support first. Some of this information is needed to 418 // Setup simulator support first. Some of this information is needed to
419 // setup the architecture state. 419 // setup the architecture state.
420 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack 420 size_t stack_size = 1 * 1024*1024; // allocate 1MB for stack
421 stack_ = reinterpret_cast<char*>(malloc(stack_size)); 421 stack_ = reinterpret_cast<char*>(malloc(stack_size));
422 pc_modified_ = false; 422 pc_modified_ = false;
423 icount_ = 0; 423 icount_ = 0;
424 thumb_mode_ = false;
424 break_pc_ = NULL; 425 break_pc_ = NULL;
425 break_instr_ = 0; 426 break_instr_ = 0;
426 427
427 // Setup architecture state. 428 // Setup architecture state.
428 // All registers are initialized to zero to start with. 429 // All registers are initialized to zero to start with.
429 for (int i = 0; i < num_registers; i++) { 430 for (int i = 0; i < num_registers; i++) {
430 registers_[i] = 0; 431 registers_[i] = 0;
431 } 432 }
432 n_flag_ = false; 433 n_flag_ = false;
433 z_flag_ = false; 434 z_flag_ = false;
(...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after
2067 pc_modified_ = false; 2068 pc_modified_ = false;
2068 if (::v8::internal::FLAG_trace_sim) { 2069 if (::v8::internal::FLAG_trace_sim) {
2069 disasm::NameConverter converter; 2070 disasm::NameConverter converter;
2070 disasm::Disassembler dasm(converter); 2071 disasm::Disassembler dasm(converter);
2071 // use a reasonably large buffer 2072 // use a reasonably large buffer
2072 v8::internal::EmbeddedVector<char, 256> buffer; 2073 v8::internal::EmbeddedVector<char, 256> buffer;
2073 dasm.InstructionDecode(buffer, 2074 dasm.InstructionDecode(buffer,
2074 reinterpret_cast<byte*>(instr)); 2075 reinterpret_cast<byte*>(instr));
2075 PrintF(" 0x%08x %s\n", instr, buffer.start()); 2076 PrintF(" 0x%08x %s\n", instr, buffer.start());
2076 } 2077 }
2078 // Temporary special-casing of our particular ARM/THUMB switch
Erik Corry 2009/12/17 14:05:50 I think this can be moved to where it fits (in the
2079 if ((unsigned)instr->InstructionBits() == 0xe24ff003) {
2080 thumb_mode_ = true;
2081 set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize);
2082 return;
2083 }
2077 if (instr->ConditionField() == special_condition) { 2084 if (instr->ConditionField() == special_condition) {
2078 DecodeUnconditional(instr); 2085 DecodeUnconditional(instr);
2079 } else if (ConditionallyExecute(instr)) { 2086 } else if (ConditionallyExecute(instr)) {
2080 switch (instr->TypeField()) { 2087 switch (instr->TypeField()) {
2081 case 0: 2088 case 0:
2082 case 1: { 2089 case 1: {
2083 DecodeType01(instr); 2090 DecodeType01(instr);
2084 break; 2091 break;
2085 } 2092 }
2086 case 2: { 2093 case 2: {
(...skipping 24 matching lines...) Expand all
2111 UNIMPLEMENTED(); 2118 UNIMPLEMENTED();
2112 break; 2119 break;
2113 } 2120 }
2114 } 2121 }
2115 } 2122 }
2116 if (!pc_modified_) { 2123 if (!pc_modified_) {
2117 set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize); 2124 set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize);
2118 } 2125 }
2119 } 2126 }
2120 2127
2128 void Simulator::InstructionDecode(ThumbInstr* instr) {
2129 // For now, assume all thumb instructions are an aligned switch back to ARM
Erik Corry 2009/12/17 14:05:50 Please assert this is true.
2130 set_register(pc, reinterpret_cast<int32_t>(instr) + Instr::kInstrSize);
2131 thumb_mode_ = false;
2132 }
2121 2133
2122 void Simulator::Execute() { 2134 void Simulator::Execute() {
2123 // Get the PC to simulate. Cannot use the accessor here as we need the 2135 // Get the PC to simulate. Cannot use the accessor here as we need the
2124 // raw PC value and not the one used as input to arithmetic instructions. 2136 // raw PC value and not the one used as input to arithmetic instructions.
2125 int program_counter = get_pc(); 2137 int program_counter = get_pc();
2126 2138
2127 if (::v8::internal::FLAG_stop_sim_at == 0) { 2139 if (::v8::internal::FLAG_stop_sim_at == 0) {
2128 // Fast version of the dispatch loop without checking whether the simulator 2140 // Fast version of the dispatch loop without checking whether the simulator
2129 // should be stopping at a particular executed instruction. 2141 // should be stopping at a particular executed instruction.
2130 while (program_counter != end_sim_pc) { 2142 while (program_counter != end_sim_pc) {
2131 Instr* instr = reinterpret_cast<Instr*>(program_counter); 2143 if (thumb_mode_) {
2144 ThumbInstr* instr = reinterpret_cast<ThumbInstr*>(program_counter);
2145 InstructionDecode(instr);
2146 } else {
2147 Instr* instr = reinterpret_cast<Instr*>(program_counter);
2148 InstructionDecode(instr);
2149 }
2132 icount_++; 2150 icount_++;
2133 InstructionDecode(instr);
2134 program_counter = get_pc(); 2151 program_counter = get_pc();
2135 } 2152 }
2136 } else { 2153 } else {
2137 // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when 2154 // FLAG_stop_sim_at is at the non-default value. Stop in the debugger when
2138 // we reach the particular instuction count. 2155 // we reach the particular instuction count.
2139 while (program_counter != end_sim_pc) { 2156 while (program_counter != end_sim_pc) {
2140 Instr* instr = reinterpret_cast<Instr*>(program_counter); 2157 Instr* instr = reinterpret_cast<Instr*>(program_counter);
2141 icount_++; 2158 icount_++;
2142 if (icount_ == ::v8::internal::FLAG_stop_sim_at) { 2159 if (icount_ == ::v8::internal::FLAG_stop_sim_at) {
2143 Debugger dbg(this); 2160 Debugger dbg(this);
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
2255 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp); 2272 uintptr_t* stack_slot = reinterpret_cast<uintptr_t*>(current_sp);
2256 uintptr_t address = *stack_slot; 2273 uintptr_t address = *stack_slot;
2257 set_register(sp, current_sp + sizeof(uintptr_t)); 2274 set_register(sp, current_sp + sizeof(uintptr_t));
2258 return address; 2275 return address;
2259 } 2276 }
2260 2277
2261 2278
2262 } } // namespace assembler::arm 2279 } } // namespace assembler::arm
2263 2280
2264 #endif // !defined(__arm__) 2281 #endif // !defined(__arm__)
OLDNEW
« src/arm/assembler-thumb2.cc ('K') | « src/arm/simulator-arm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698