| OLD | NEW |
| 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 1433 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1444 | 1444 |
| 1445 uint8_t* Simulator::LoadStoreAddress(unsigned addr_reg, | 1445 uint8_t* Simulator::LoadStoreAddress(unsigned addr_reg, |
| 1446 int64_t offset, | 1446 int64_t offset, |
| 1447 AddrMode addrmode) { | 1447 AddrMode addrmode) { |
| 1448 const unsigned kSPRegCode = kSPRegInternalCode & kRegCodeMask; | 1448 const unsigned kSPRegCode = kSPRegInternalCode & kRegCodeMask; |
| 1449 int64_t address = xreg(addr_reg, Reg31IsStackPointer); | 1449 int64_t address = xreg(addr_reg, Reg31IsStackPointer); |
| 1450 if ((addr_reg == kSPRegCode) && ((address % 16) != 0)) { | 1450 if ((addr_reg == kSPRegCode) && ((address % 16) != 0)) { |
| 1451 // When the base register is SP the stack pointer is required to be | 1451 // When the base register is SP the stack pointer is required to be |
| 1452 // quadword aligned prior to the address calculation and write-backs. | 1452 // quadword aligned prior to the address calculation and write-backs. |
| 1453 // Misalignment will cause a stack alignment fault. | 1453 // Misalignment will cause a stack alignment fault. |
| 1454 ALIGNMENT_EXCEPTION(); | 1454 FATAL("ALIGNMENT EXCEPTION"); |
| 1455 } | 1455 } |
| 1456 | 1456 |
| 1457 if ((addrmode == Offset) || (addrmode == PreIndex)) { | 1457 if ((addrmode == Offset) || (addrmode == PreIndex)) { |
| 1458 address += offset; | 1458 address += offset; |
| 1459 } | 1459 } |
| 1460 | 1460 |
| 1461 return reinterpret_cast<uint8_t*>(address); | 1461 return reinterpret_cast<uint8_t*>(address); |
| 1462 } | 1462 } |
| 1463 | 1463 |
| 1464 | 1464 |
| 1465 void Simulator::LoadStoreWriteBack(unsigned addr_reg, | 1465 void Simulator::LoadStoreWriteBack(unsigned addr_reg, |
| 1466 int64_t offset, | 1466 int64_t offset, |
| 1467 AddrMode addrmode) { | 1467 AddrMode addrmode) { |
| 1468 if ((addrmode == PreIndex) || (addrmode == PostIndex)) { | 1468 if ((addrmode == PreIndex) || (addrmode == PostIndex)) { |
| 1469 ASSERT(offset != 0); | 1469 ASSERT(offset != 0); |
| 1470 uint64_t address = xreg(addr_reg, Reg31IsStackPointer); | 1470 uint64_t address = xreg(addr_reg, Reg31IsStackPointer); |
| 1471 set_reg(addr_reg, address + offset, Reg31IsStackPointer); | 1471 set_reg(addr_reg, address + offset, Reg31IsStackPointer); |
| 1472 } | 1472 } |
| 1473 } | 1473 } |
| 1474 | 1474 |
| 1475 | 1475 |
| 1476 void Simulator::CheckMemoryAccess(uint8_t* address, uint8_t* stack) { | 1476 void Simulator::CheckMemoryAccess(uint8_t* address, uint8_t* stack) { |
| 1477 if ((address >= stack_limit_) && (address < stack)) { | 1477 if ((address >= stack_limit_) && (address < stack)) { |
| 1478 fprintf(stream_, "ACCESS BELOW STACK POINTER:\n"); | 1478 fprintf(stream_, "ACCESS BELOW STACK POINTER:\n"); |
| 1479 fprintf(stream_, " sp is here: 0x%16p\n", stack); | 1479 fprintf(stream_, " sp is here: 0x%16p\n", stack); |
| 1480 fprintf(stream_, " access was here: 0x%16p\n", address); | 1480 fprintf(stream_, " access was here: 0x%16p\n", address); |
| 1481 fprintf(stream_, " stack limit is here: 0x%16p\n", stack_limit_); | 1481 fprintf(stream_, " stack limit is here: 0x%16p\n", stack_limit_); |
| 1482 fprintf(stream_, "\n"); | 1482 fprintf(stream_, "\n"); |
| 1483 ABORT(); | 1483 FATAL("ACCESS BELOW STACK POINTER"); |
| 1484 } | 1484 } |
| 1485 } | 1485 } |
| 1486 | 1486 |
| 1487 | 1487 |
| 1488 uint64_t Simulator::MemoryRead(uint8_t* address, unsigned num_bytes) { | 1488 uint64_t Simulator::MemoryRead(uint8_t* address, unsigned num_bytes) { |
| 1489 ASSERT(address != NULL); | 1489 ASSERT(address != NULL); |
| 1490 ASSERT((num_bytes > 0) && (num_bytes <= sizeof(uint64_t))); | 1490 ASSERT((num_bytes > 0) && (num_bytes <= sizeof(uint64_t))); |
| 1491 uint64_t read = 0; | 1491 uint64_t read = 0; |
| 1492 memcpy(&read, address, num_bytes); | 1492 memcpy(&read, address, num_bytes); |
| 1493 return read; | 1493 return read; |
| (...skipping 1708 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3202 int64_t external = | 3202 int64_t external = |
| 3203 reinterpret_cast<int64_t>(redirection->external_function()); | 3203 reinterpret_cast<int64_t>(redirection->external_function()); |
| 3204 | 3204 |
| 3205 TraceSim("Call to host function at %p\n", | 3205 TraceSim("Call to host function at %p\n", |
| 3206 reinterpret_cast<void*>(redirection->external_function())); | 3206 reinterpret_cast<void*>(redirection->external_function())); |
| 3207 | 3207 |
| 3208 // SP must be 16 bytes aligned at the call interface. | 3208 // SP must be 16 bytes aligned at the call interface. |
| 3209 bool stack_alignment_exception = ((sp() & 0xf) != 0); | 3209 bool stack_alignment_exception = ((sp() & 0xf) != 0); |
| 3210 if (stack_alignment_exception) { | 3210 if (stack_alignment_exception) { |
| 3211 TraceSim(" with unaligned stack 0x%016" PRIx64 ".\n", sp()); | 3211 TraceSim(" with unaligned stack 0x%016" PRIx64 ".\n", sp()); |
| 3212 ALIGNMENT_EXCEPTION(); | 3212 FATAL("ALIGNMENT EXCEPTION"); |
| 3213 } | 3213 } |
| 3214 | 3214 |
| 3215 switch (redirection->type()) { | 3215 switch (redirection->type()) { |
| 3216 default: | 3216 default: |
| 3217 TraceSim("Type: Unknown.\n"); | 3217 TraceSim("Type: Unknown.\n"); |
| 3218 UNREACHABLE(); | 3218 UNREACHABLE(); |
| 3219 break; | 3219 break; |
| 3220 | 3220 |
| 3221 case ExternalReference::BUILTIN_CALL: { | 3221 case ExternalReference::BUILTIN_CALL: { |
| 3222 // MaybeObject* f(v8::internal::Arguments). | 3222 // MaybeObject* f(v8::internal::Arguments). |
| (...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3420 default: | 3420 default: |
| 3421 UNIMPLEMENTED(); | 3421 UNIMPLEMENTED(); |
| 3422 } | 3422 } |
| 3423 } | 3423 } |
| 3424 | 3424 |
| 3425 #endif // USE_SIMULATOR | 3425 #endif // USE_SIMULATOR |
| 3426 | 3426 |
| 3427 } } // namespace v8::internal | 3427 } } // namespace v8::internal |
| 3428 | 3428 |
| 3429 #endif // V8_TARGET_ARCH_A64 | 3429 #endif // V8_TARGET_ARCH_A64 |
| OLD | NEW |