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 #include "vm/stub_code.h" |
| 13 | 13 |
| 14 namespace dart { | 14 namespace dart { |
| 15 | 15 |
| 16 DECLARE_RUNTIME_ENTRY(StoreBuffer); | |
| 17 | |
| 16 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); | 18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); |
| 17 DEFINE_FLAG(bool, code_comments, false, | 19 DEFINE_FLAG(bool, code_comments, false, |
| 18 "Include comments into code and disassembly"); | 20 "Include comments into code and disassembly"); |
| 19 | 21 |
| 20 | 22 |
| 21 class DirectCallRelocation : public AssemblerFixup { | 23 class DirectCallRelocation : public AssemblerFixup { |
| 22 public: | 24 public: |
| 23 void Process(const MemoryRegion& region, int position) { | 25 void Process(const MemoryRegion& region, int position) { |
| 24 // Direct calls are relative to the following instruction on x86. | 26 // Direct calls are relative to the following instruction on x86. |
| 25 int32_t pointer = region.Load<int32_t>(position); | 27 int32_t pointer = region.Load<int32_t>(position); |
| (...skipping 1332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1358 EmitOperand(7, Operand(reg)); | 1360 EmitOperand(7, Operand(reg)); |
| 1359 buffer_.EmitObject(object); | 1361 buffer_.EmitObject(object); |
| 1360 } | 1362 } |
| 1361 } | 1363 } |
| 1362 } | 1364 } |
| 1363 | 1365 |
| 1364 | 1366 |
| 1365 void Assembler::StoreIntoObject(Register object, | 1367 void Assembler::StoreIntoObject(Register object, |
| 1366 const FieldAddress& dest, | 1368 const FieldAddress& dest, |
| 1367 Register value) { | 1369 Register value) { |
| 1368 // TODO(iposva): Add write barrier. | |
| 1369 movl(dest, value); | 1370 movl(dest, value); |
| 1371 Label done; | |
| 1372 // Check that 'value' is a new object. Store buffer updates are not | |
| 1373 // required when storing a smi or an old object. | |
| 1374 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); | |
| 1375 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1376 // Check that 'object' is an old object. A store buffer update is | |
| 1377 // not required when storing into a new object. | |
| 1378 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag)); | |
| 1379 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1380 // A store buffer update is required. | |
| 1381 pushl(object); // Save 'object' register | |
| 1382 pushl(value); // Save 'value' register | |
| 1383 pushl(dest); // Push argument | |
| 1384 CallRuntime(kStoreBufferRuntimeEntry); | |
|
srdjan
2012/06/15 21:12:08
I'd rather have a CallLeafRuntime which would stor
cshapiro
2012/06/15 23:17:32
Per our off-line discussion, I have added a pushal
| |
| 1385 popl(value); // Pop argument | |
| 1386 popl(value); // Restore 'value' register | |
| 1387 popl(object); // Restore 'object' register | |
| 1388 Bind(&done); | |
| 1370 } | 1389 } |
| 1371 | 1390 |
| 1372 | 1391 |
| 1392 void Assembler::StoreIntoObjectNoBarrier(Register object, | |
| 1393 const FieldAddress& dest, | |
| 1394 Register value) { | |
| 1395 movl(dest, value); | |
| 1396 #if defined(DEBUG) | |
| 1397 Label done; | |
| 1398 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); | |
| 1399 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1400 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag)); | |
| 1401 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1402 Stop("Store buffer update is required"); | |
| 1403 Bind(&done); | |
| 1404 #endif | |
| 1405 // No store buffer update. | |
| 1406 } | |
| 1407 | |
| 1408 | |
| 1409 void Assembler::StoreIntoObjectNoBarrier(Register object, | |
| 1410 const FieldAddress& dest, | |
| 1411 const Object& value) { | |
| 1412 if (value.IsSmi()) { | |
| 1413 movl(dest, Immediate(reinterpret_cast<int32_t>(value.raw()))); | |
| 1414 } else { | |
| 1415 ASSERT(value.IsOld()); | |
| 1416 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | |
| 1417 EmitUint8(0xC7); | |
| 1418 EmitOperand(0, dest); | |
| 1419 buffer_.EmitObject(value); | |
| 1420 } | |
| 1421 // No store buffer update. | |
| 1422 } | |
| 1423 | |
| 1424 | |
| 1373 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { | 1425 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { |
| 1374 // TODO(5410843): Need to have a code constants table. | 1426 // TODO(5410843): Need to have a code constants table. |
| 1375 int64_t constant = bit_cast<int64_t, double>(value); | 1427 int64_t constant = bit_cast<int64_t, double>(value); |
| 1376 pushl(Immediate(Utils::High32Bits(constant))); | 1428 pushl(Immediate(Utils::High32Bits(constant))); |
| 1377 pushl(Immediate(Utils::Low32Bits(constant))); | 1429 pushl(Immediate(Utils::Low32Bits(constant))); |
| 1378 movsd(dst, Address(ESP, 0)); | 1430 movsd(dst, Address(ESP, 0)); |
| 1379 addl(ESP, Immediate(2 * kWordSize)); | 1431 addl(ESP, Immediate(2 * kWordSize)); |
| 1380 } | 1432 } |
| 1381 | 1433 |
| 1382 | 1434 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1646 comments.SetCommentAt(i, comments_[i]->comment()); | 1698 comments.SetCommentAt(i, comments_[i]->comment()); |
| 1647 } | 1699 } |
| 1648 | 1700 |
| 1649 return comments; | 1701 return comments; |
| 1650 } | 1702 } |
| 1651 | 1703 |
| 1652 | 1704 |
| 1653 } // namespace dart | 1705 } // namespace dart |
| 1654 | 1706 |
| 1655 #endif // defined TARGET_ARCH_IA32 | 1707 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |