| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <stdarg.h> | 5 #include <stdarg.h> |
| 6 #include <stdlib.h> | 6 #include <stdlib.h> |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #if V8_TARGET_ARCH_ARM | 9 #if V8_TARGET_ARCH_ARM |
| 10 | 10 |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 if (argc == next_arg) { | 380 if (argc == next_arg) { |
| 381 words = 10; | 381 words = 10; |
| 382 } else { | 382 } else { |
| 383 if (!GetValue(argv[next_arg], &words)) { | 383 if (!GetValue(argv[next_arg], &words)) { |
| 384 words = 10; | 384 words = 10; |
| 385 } | 385 } |
| 386 } | 386 } |
| 387 end = cur + words; | 387 end = cur + words; |
| 388 | 388 |
| 389 while (cur < end) { | 389 while (cur < end) { |
| 390 PrintF(" 0x%08x: 0x%08x %10d", | 390 PrintF(" 0x%08" V8PRIxPTR ": 0x%08x %10d", |
| 391 reinterpret_cast<intptr_t>(cur), *cur, *cur); | 391 reinterpret_cast<intptr_t>(cur), *cur, *cur); |
| 392 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); | 392 HeapObject* obj = reinterpret_cast<HeapObject*>(*cur); |
| 393 int value = *cur; | 393 int value = *cur; |
| 394 Heap* current_heap = sim_->isolate_->heap(); | 394 Heap* current_heap = sim_->isolate_->heap(); |
| 395 if (((value & 1) == 0) || | 395 if (((value & 1) == 0) || |
| 396 current_heap->ContainsSlow(obj->address())) { | 396 current_heap->ContainsSlow(obj->address())) { |
| 397 PrintF(" ("); | 397 PrintF(" ("); |
| 398 if ((value & 1) == 0) { | 398 if ((value & 1) == 0) { |
| 399 PrintF("smi %d", value / 2); | 399 PrintF("smi %d", value / 2); |
| 400 } else { | 400 } else { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 442 int32_t value2; | 442 int32_t value2; |
| 443 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { | 443 if (GetValue(arg1, &value1) && GetValue(arg2, &value2)) { |
| 444 cur = reinterpret_cast<byte*>(value1); | 444 cur = reinterpret_cast<byte*>(value1); |
| 445 end = cur + (value2 * Instruction::kInstrSize); | 445 end = cur + (value2 * Instruction::kInstrSize); |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 | 448 |
| 449 while (cur < end) { | 449 while (cur < end) { |
| 450 prev = cur; | 450 prev = cur; |
| 451 cur += dasm.InstructionDecode(buffer, cur); | 451 cur += dasm.InstructionDecode(buffer, cur); |
| 452 PrintF(" 0x%08x %s\n", | 452 PrintF(" 0x%08" V8PRIxPTR " %s\n", reinterpret_cast<intptr_t>(prev), |
| 453 reinterpret_cast<intptr_t>(prev), buffer.start()); | 453 buffer.start()); |
| 454 } | 454 } |
| 455 } else if (strcmp(cmd, "gdb") == 0) { | 455 } else if (strcmp(cmd, "gdb") == 0) { |
| 456 PrintF("relinquishing control to gdb\n"); | 456 PrintF("relinquishing control to gdb\n"); |
| 457 v8::base::OS::DebugBreak(); | 457 v8::base::OS::DebugBreak(); |
| 458 PrintF("regaining control from gdb\n"); | 458 PrintF("regaining control from gdb\n"); |
| 459 } else if (strcmp(cmd, "break") == 0) { | 459 } else if (strcmp(cmd, "break") == 0) { |
| 460 if (argc == 2) { | 460 if (argc == 2) { |
| 461 int32_t value; | 461 int32_t value; |
| 462 if (GetValue(arg1, &value)) { | 462 if (GetValue(arg1, &value)) { |
| 463 if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) { | 463 if (!SetBreakpoint(reinterpret_cast<Instruction*>(value))) { |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 } | 1264 } |
| 1265 | 1265 |
| 1266 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes | 1266 // Otherwise the limit is the JS stack. Leave a safety margin of 1024 bytes |
| 1267 // to prevent overrunning the stack when pushing values. | 1267 // to prevent overrunning the stack when pushing values. |
| 1268 return reinterpret_cast<uintptr_t>(stack_) + 1024; | 1268 return reinterpret_cast<uintptr_t>(stack_) + 1024; |
| 1269 } | 1269 } |
| 1270 | 1270 |
| 1271 | 1271 |
| 1272 // Unsupported instructions use Format to print an error and stop execution. | 1272 // Unsupported instructions use Format to print an error and stop execution. |
| 1273 void Simulator::Format(Instruction* instr, const char* format) { | 1273 void Simulator::Format(Instruction* instr, const char* format) { |
| 1274 PrintF("Simulator found unsupported instruction:\n 0x%08x: %s\n", | 1274 PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", |
| 1275 reinterpret_cast<intptr_t>(instr), format); | 1275 reinterpret_cast<intptr_t>(instr), format); |
| 1276 UNIMPLEMENTED(); | 1276 UNIMPLEMENTED(); |
| 1277 } | 1277 } |
| 1278 | 1278 |
| 1279 | 1279 |
| 1280 // Checks if the current instruction should be executed based on its | 1280 // Checks if the current instruction should be executed based on its |
| 1281 // condition bits. | 1281 // condition bits. |
| 1282 bool Simulator::ConditionallyExecute(Instruction* instr) { | 1282 bool Simulator::ConditionallyExecute(Instruction* instr) { |
| 1283 switch (instr->ConditionField()) { | 1283 switch (instr->ConditionField()) { |
| 1284 case eq: return z_flag_; | 1284 case eq: return z_flag_; |
| (...skipping 2795 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4080 CheckICache(isolate_->simulator_i_cache(), instr); | 4080 CheckICache(isolate_->simulator_i_cache(), instr); |
| 4081 } | 4081 } |
| 4082 pc_modified_ = false; | 4082 pc_modified_ = false; |
| 4083 if (::v8::internal::FLAG_trace_sim) { | 4083 if (::v8::internal::FLAG_trace_sim) { |
| 4084 disasm::NameConverter converter; | 4084 disasm::NameConverter converter; |
| 4085 disasm::Disassembler dasm(converter); | 4085 disasm::Disassembler dasm(converter); |
| 4086 // use a reasonably large buffer | 4086 // use a reasonably large buffer |
| 4087 v8::internal::EmbeddedVector<char, 256> buffer; | 4087 v8::internal::EmbeddedVector<char, 256> buffer; |
| 4088 dasm.InstructionDecode(buffer, | 4088 dasm.InstructionDecode(buffer, |
| 4089 reinterpret_cast<byte*>(instr)); | 4089 reinterpret_cast<byte*>(instr)); |
| 4090 PrintF(" 0x%08x %s\n", reinterpret_cast<intptr_t>(instr), buffer.start()); | 4090 PrintF(" 0x%08" V8PRIxPTR " %s\n", reinterpret_cast<intptr_t>(instr), |
| 4091 buffer.start()); |
| 4091 } | 4092 } |
| 4092 if (instr->ConditionField() == kSpecialCondition) { | 4093 if (instr->ConditionField() == kSpecialCondition) { |
| 4093 DecodeSpecialCondition(instr); | 4094 DecodeSpecialCondition(instr); |
| 4094 } else if (ConditionallyExecute(instr)) { | 4095 } else if (ConditionallyExecute(instr)) { |
| 4095 switch (instr->TypeValue()) { | 4096 switch (instr->TypeValue()) { |
| 4096 case 0: | 4097 case 0: |
| 4097 case 1: { | 4098 case 1: { |
| 4098 DecodeType01(instr); | 4099 DecodeType01(instr); |
| 4099 break; | 4100 break; |
| 4100 } | 4101 } |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4314 set_register(sp, current_sp + sizeof(uintptr_t)); | 4315 set_register(sp, current_sp + sizeof(uintptr_t)); |
| 4315 return address; | 4316 return address; |
| 4316 } | 4317 } |
| 4317 | 4318 |
| 4318 } // namespace internal | 4319 } // namespace internal |
| 4319 } // namespace v8 | 4320 } // namespace v8 |
| 4320 | 4321 |
| 4321 #endif // USE_SIMULATOR | 4322 #endif // USE_SIMULATOR |
| 4322 | 4323 |
| 4323 #endif // V8_TARGET_ARCH_ARM | 4324 #endif // V8_TARGET_ARCH_ARM |
| OLD | NEW |