Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/globals.h" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/heap.h" | 9 #include "vm/heap.h" |
| 10 #include "vm/memory_region.h" | 10 #include "vm/memory_region.h" |
| 11 #include "vm/runtime_entry.h" | 11 #include "vm/runtime_entry.h" |
| 12 #include "vm/stub_code.h" | |
| 12 | 13 |
| 13 namespace dart { | 14 namespace dart { |
| 14 | 15 |
| 16 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); | |
| 17 | |
| 18 | |
| 15 class DirectCallRelocation : public AssemblerFixup { | 19 class DirectCallRelocation : public AssemblerFixup { |
| 16 public: | 20 public: |
| 17 void Process(const MemoryRegion& region, int position) { | 21 void Process(const MemoryRegion& region, int position) { |
| 18 // Direct calls are relative to the following instruction on x86. | 22 // Direct calls are relative to the following instruction on x86. |
| 19 int32_t pointer = region.Load<int32_t>(position); | 23 int32_t pointer = region.Load<int32_t>(position); |
| 20 int32_t delta = region.start() + position + sizeof(int32_t); | 24 int32_t delta = region.start() + position + sizeof(int32_t); |
| 21 region.Store<int32_t>(position, pointer - delta); | 25 region.Store<int32_t>(position, pointer - delta); |
| 22 } | 26 } |
| 23 }; | 27 }; |
| 24 | 28 |
| (...skipping 1406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1431 int position = label->NearPosition(); | 1435 int position = label->NearPosition(); |
| 1432 int offset = bound - (position + 1); | 1436 int offset = bound - (position + 1); |
| 1433 ASSERT(Utils::IsInt(8, offset)); | 1437 ASSERT(Utils::IsInt(8, offset)); |
| 1434 buffer_.Store<int8_t>(position, offset); | 1438 buffer_.Store<int8_t>(position, offset); |
| 1435 } | 1439 } |
| 1436 label->BindTo(bound); | 1440 label->BindTo(bound); |
| 1437 } | 1441 } |
| 1438 | 1442 |
| 1439 | 1443 |
| 1440 void Assembler::Stop(const char* message) { | 1444 void Assembler::Stop(const char* message) { |
| 1445 if (FLAG_print_stop_message) { | |
| 1446 pushl(Immediate(reinterpret_cast<int32_t>(message))); | |
| 1447 call(&StubCode::PrintStopMessageLabel()); | |
| 1448 popl(EAX); | |
|
Ivan Posva
2012/01/09 17:26:42
This destroys whatever was in EAX.
regis
2012/01/10 00:09:16
Done.
| |
| 1449 } | |
| 1441 // Emit the message address as immediate operand in the test rax instruction, | 1450 // Emit the message address as immediate operand in the test rax instruction, |
| 1442 // followed by the int3 instruction. | 1451 // followed by the int3 instruction. |
| 1443 // Execution can be resumed with the 'cont' command in gdb. | 1452 // Execution can be resumed with the 'cont' command in gdb. |
| 1444 testl(EAX, Immediate(reinterpret_cast<int32_t>(message))); | 1453 testl(EAX, Immediate(reinterpret_cast<int32_t>(message))); |
| 1445 int3(); | 1454 int3(); |
| 1446 } | 1455 } |
| 1447 | 1456 |
| 1448 | 1457 |
| 1449 void Assembler::EmitOperand(int rm, const Operand& operand) { | 1458 void Assembler::EmitOperand(int rm, const Operand& operand) { |
| 1450 ASSERT(rm >= 0 && rm < 8); | 1459 ASSERT(rm >= 0 && rm < 8); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1534 Register shifter) { | 1543 Register shifter) { |
| 1535 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 1544 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 1536 ASSERT(shifter == ECX); | 1545 ASSERT(shifter == ECX); |
| 1537 EmitUint8(0xD3); | 1546 EmitUint8(0xD3); |
| 1538 EmitOperand(rm, Operand(operand)); | 1547 EmitOperand(rm, Operand(operand)); |
| 1539 } | 1548 } |
| 1540 | 1549 |
| 1541 } // namespace dart | 1550 } // namespace dart |
| 1542 | 1551 |
| 1543 #endif // defined TARGET_ARCH_IA32 | 1552 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |