| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include <math.h> // for isnan. | 5 #include <math.h> // for isnan. |
| 6 #include <setjmp.h> | 6 #include <setjmp.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 | 8 |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #if defined(TARGET_ARCH_ARM) | 10 #if defined(TARGET_ARCH_ARM) |
| (...skipping 938 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 949 } else { | 949 } else { |
| 950 // Same effect on exclusive access state as an LDREX. | 950 // Same effect on exclusive access state as an LDREX. |
| 951 SetExclusiveAccess(reinterpret_cast<uword>(address)); | 951 SetExclusiveAccess(reinterpret_cast<uword>(address)); |
| 952 } | 952 } |
| 953 return value; | 953 return value; |
| 954 } | 954 } |
| 955 | 955 |
| 956 | 956 |
| 957 // Returns the top of the stack area to enable checking for stack pointer | 957 // Returns the top of the stack area to enable checking for stack pointer |
| 958 // validity. | 958 // validity. |
| 959 uintptr_t Simulator::StackTop() const { | 959 uword Simulator::StackTop() const { |
| 960 // To be safe in potential stack underflows we leave some buffer above and | 960 // To be safe in potential stack underflows we leave some buffer above and |
| 961 // set the stack top. | 961 // set the stack top. |
| 962 return reinterpret_cast<uintptr_t>(stack_) + | 962 return reinterpret_cast<uword>(stack_) + |
| 963 (Isolate::GetSpecifiedStackSize() + Isolate::kStackSizeBuffer); | 963 (Isolate::GetSpecifiedStackSize() + Isolate::kStackSizeBuffer); |
| 964 } | 964 } |
| 965 | 965 |
| 966 | 966 |
| 967 // Unsupported instructions use Format to print an error and stop execution. | 967 // Unsupported instructions use Format to print an error and stop execution. |
| 968 void Simulator::Format(Instr* instr, const char* format) { | 968 void Simulator::Format(Instr* instr, const char* format) { |
| 969 OS::Print("Simulator found unsupported instruction:\n 0x%p: %s\n", | 969 OS::Print("Simulator found unsupported instruction:\n 0x%p: %s\n", |
| 970 instr, | 970 instr, |
| 971 format); | 971 format); |
| 972 UNIMPLEMENTED(); | 972 UNIMPLEMENTED(); |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1384 // Handle execution based on instruction types. | 1384 // Handle execution based on instruction types. |
| 1385 | 1385 |
| 1386 // Instruction types 0 and 1 are both rolled into one function because they | 1386 // Instruction types 0 and 1 are both rolled into one function because they |
| 1387 // only differ in the handling of the shifter_operand. | 1387 // only differ in the handling of the shifter_operand. |
| 1388 void Simulator::DecodeType01(Instr* instr) { | 1388 void Simulator::DecodeType01(Instr* instr) { |
| 1389 if (!instr->IsDataProcessing()) { | 1389 if (!instr->IsDataProcessing()) { |
| 1390 // miscellaneous, multiply, sync primitives, extra loads and stores. | 1390 // miscellaneous, multiply, sync primitives, extra loads and stores. |
| 1391 if (instr->IsMiscellaneous()) { | 1391 if (instr->IsMiscellaneous()) { |
| 1392 switch (instr->Bits(4, 3)) { | 1392 switch (instr->Bits(4, 3)) { |
| 1393 case 1: { | 1393 case 1: { |
| 1394 ASSERT(instr->Bits(21, 2) == 0x3); | 1394 if (instr->Bits(21, 2) == 0x3) { |
| 1395 // Format(instr, "clz'cond 'rd, 'rm"); | 1395 // Format(instr, "clz'cond 'rd, 'rm"); |
| 1396 Register rm = instr->RmField(); | 1396 Register rm = instr->RmField(); |
| 1397 Register rd = instr->RdField(); | 1397 Register rd = instr->RdField(); |
| 1398 int32_t rm_val = get_register(rm); | 1398 int32_t rm_val = get_register(rm); |
| 1399 int32_t rd_val = 0; | 1399 int32_t rd_val = 0; |
| 1400 if (rm_val != 0) { | 1400 if (rm_val != 0) { |
| 1401 while (rm_val > 0) { | 1401 while (rm_val > 0) { |
| 1402 rd_val++; | 1402 rd_val++; |
| 1403 rm_val <<= 1; | 1403 rm_val <<= 1; |
| 1404 } |
| 1405 } else { |
| 1406 rd_val = 32; |
| 1404 } | 1407 } |
| 1408 set_register(rd, rd_val); |
| 1405 } else { | 1409 } else { |
| 1406 rd_val = 32; | 1410 ASSERT(instr->Bits(21, 2) == 0x1); |
| 1411 // Format(instr, "bx'cond 'rm"); |
| 1412 Register rm = instr->RmField(); |
| 1413 int32_t rm_val = get_register(rm); |
| 1414 set_pc(rm_val); |
| 1407 } | 1415 } |
| 1408 set_register(rd, rd_val); | |
| 1409 break; | 1416 break; |
| 1410 } | 1417 } |
| 1411 case 3: { | 1418 case 3: { |
| 1412 ASSERT(instr->Bits(21, 2) == 0x1); | 1419 ASSERT(instr->Bits(21, 2) == 0x1); |
| 1413 // Format(instr, "blx'cond 'rm"); | 1420 // Format(instr, "blx'cond 'rm"); |
| 1414 Register rm = instr->RmField(); | 1421 Register rm = instr->RmField(); |
| 1415 int32_t rm_val = get_register(rm); | 1422 int32_t rm_val = get_register(rm); |
| 1416 intptr_t pc = get_pc(); | 1423 intptr_t pc = get_pc(); |
| 1417 set_register(LR, pc + Instr::kInstrSize); | 1424 set_register(LR, pc + Instr::kInstrSize); |
| 1418 set_pc(rm_val); | 1425 set_pc(rm_val); |
| 1419 break; | 1426 break; |
| 1420 } | 1427 } |
| 1421 case 7: { | 1428 case 7: { |
| 1422 if (instr->Bits(21, 2) == 0x1) { | 1429 if (instr->Bits(21, 2) == 0x1) { |
| 1423 // Format(instr, "bkpt #'imm12_4"); | 1430 // Format(instr, "bkpt'cond #'imm12_4"); |
| 1424 SimulatorDebugger dbg(this); | 1431 SimulatorDebugger dbg(this); |
| 1425 set_pc(get_pc() + Instr::kInstrSize); | 1432 set_pc(get_pc() + Instr::kInstrSize); |
| 1426 char buffer[32]; | 1433 char buffer[32]; |
| 1427 snprintf(buffer, sizeof(buffer), "bkpt #0x%x", instr->BkptField()); | 1434 snprintf(buffer, sizeof(buffer), "bkpt #0x%x", instr->BkptField()); |
| 1428 dbg.Stop(instr, buffer); | 1435 dbg.Stop(instr, buffer); |
| 1429 } else { | 1436 } else { |
| 1430 // Format(instr, "smc'cond"); | 1437 // Format(instr, "smc'cond"); |
| 1431 UNIMPLEMENTED(); | 1438 UNIMPLEMENTED(); |
| 1432 } | 1439 } |
| 1433 break; | 1440 break; |
| (...skipping 1232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2666 int32_t r4_val = get_register(R4); | 2673 int32_t r4_val = get_register(R4); |
| 2667 int32_t r5_val = get_register(R5); | 2674 int32_t r5_val = get_register(R5); |
| 2668 int32_t r6_val = get_register(R6); | 2675 int32_t r6_val = get_register(R6); |
| 2669 int32_t r7_val = get_register(R7); | 2676 int32_t r7_val = get_register(R7); |
| 2670 int32_t r8_val = get_register(R8); | 2677 int32_t r8_val = get_register(R8); |
| 2671 int32_t r9_val = get_register(R9); | 2678 int32_t r9_val = get_register(R9); |
| 2672 int32_t r10_val = get_register(R10); | 2679 int32_t r10_val = get_register(R10); |
| 2673 int32_t r11_val = get_register(R11); | 2680 int32_t r11_val = get_register(R11); |
| 2674 | 2681 |
| 2675 // Setup the callee-saved registers with a known value. To be able to check | 2682 // Setup the callee-saved registers with a known value. To be able to check |
| 2676 // that they are preserved properly across JS execution. | 2683 // that they are preserved properly across dart execution. |
| 2677 int32_t callee_saved_value = icount_; | 2684 int32_t callee_saved_value = icount_; |
| 2678 set_register(R4, callee_saved_value); | 2685 set_register(R4, callee_saved_value); |
| 2679 set_register(R5, callee_saved_value); | 2686 set_register(R5, callee_saved_value); |
| 2680 set_register(R6, callee_saved_value); | 2687 set_register(R6, callee_saved_value); |
| 2681 set_register(R7, callee_saved_value); | 2688 set_register(R7, callee_saved_value); |
| 2682 set_register(R8, callee_saved_value); | 2689 set_register(R8, callee_saved_value); |
| 2683 set_register(R9, callee_saved_value); | 2690 set_register(R9, callee_saved_value); |
| 2684 set_register(R10, callee_saved_value); | 2691 set_register(R10, callee_saved_value); |
| 2685 set_register(R11, callee_saved_value); | 2692 set_register(R11, callee_saved_value); |
| 2686 | 2693 |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2733 // isolate->ChangeStateToGeneratedCode(); | 2740 // isolate->ChangeStateToGeneratedCode(); |
| 2734 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); | 2741 set_register(kExceptionObjectReg, bit_cast<int32_t>(object.raw())); |
| 2735 buf->Longjmp(); | 2742 buf->Longjmp(); |
| 2736 } | 2743 } |
| 2737 | 2744 |
| 2738 } // namespace dart | 2745 } // namespace dart |
| 2739 | 2746 |
| 2740 #endif // !defined(HOST_ARCH_ARM) | 2747 #endif // !defined(HOST_ARCH_ARM) |
| 2741 | 2748 |
| 2742 #endif // defined TARGET_ARCH_ARM | 2749 #endif // defined TARGET_ARCH_ARM |
| OLD | NEW |