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 1331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 EmitOperand(7, Operand(reg)); | 1359 EmitOperand(7, Operand(reg)); |
| 1358 buffer_.EmitObject(object); | 1360 buffer_.EmitObject(object); |
| 1359 } | 1361 } |
| 1360 } | 1362 } |
| 1361 } | 1363 } |
| 1362 | 1364 |
| 1363 | 1365 |
| 1364 void Assembler::StoreIntoObject(Register object, | 1366 void Assembler::StoreIntoObject(Register object, |
| 1365 const FieldAddress& dest, | 1367 const FieldAddress& dest, |
| 1366 Register value) { | 1368 Register value) { |
| 1367 // TODO(iposva): Add write barrier. | |
| 1368 movl(dest, value); | 1369 movl(dest, value); |
| 1370 Label done; | |
| 1371 // Check that 'value' is a new object. Store buffer updates are not | |
| 1372 // required when storing a smi or an old object. | |
| 1373 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); | |
| 1374 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1375 // Check that 'object' is an old object. A store buffer update is | |
| 1376 // not required when storing into a new object. | |
| 1377 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag)); | |
| 1378 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1379 // A store buffer update is required. | |
| 1380 pushl(object); // Save 'object' register | |
| 1381 pushl(value); // Save 'value' register | |
| 1382 pushl(dest); // Push argument | |
|
cshapiro
2012/06/12 21:41:01
Apparently, this store is not legal since it is an
| |
| 1383 CallRuntime(kStoreBufferRuntimeEntry); | |
| 1384 popl(value); // Pop argument | |
| 1385 popl(value); // Restore 'value' register | |
| 1386 popl(object); // Restore 'object' register | |
| 1387 Bind(&done); | |
| 1369 } | 1388 } |
| 1370 | 1389 |
| 1371 | 1390 |
| 1391 void Assembler::StoreIntoObjectNoBarrier(Register object, | |
| 1392 const FieldAddress& dest, | |
| 1393 Register value) { | |
| 1394 movl(dest, value); | |
| 1395 // No store buffer update. | |
| 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 } | |
| 1406 | |
| 1407 | |
| 1408 void Assembler::StoreIntoObjectNoBarrier(Register object, | |
| 1409 const FieldAddress& dest, | |
| 1410 const Immediate& value) { | |
| 1411 movl(dest, value); | |
|
srdjan
2012/06/12 06:57:08
I do not think this works as the inlined value is
cshapiro
2012/06/12 21:41:01
Thanks. I have changed the code to use EmitObject
| |
| 1412 // No store buffer update. | |
| 1413 int addr = value.value(); | |
| 1414 bool is_smi = ((addr & kHeapObjectTag) == 0); | |
| 1415 bool is_old = ((addr & (kOldObjectAlignmentOffset | kHeapObjectTag)) == 1); | |
| 1416 ASSERT(is_smi || is_old); | |
| 1417 } | |
| 1418 | |
| 1419 | |
| 1372 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { | 1420 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { |
| 1373 // TODO(5410843): Need to have a code constants table. | 1421 // TODO(5410843): Need to have a code constants table. |
| 1374 int64_t constant = bit_cast<int64_t, double>(value); | 1422 int64_t constant = bit_cast<int64_t, double>(value); |
| 1375 pushl(Immediate(Utils::High32Bits(constant))); | 1423 pushl(Immediate(Utils::High32Bits(constant))); |
| 1376 pushl(Immediate(Utils::Low32Bits(constant))); | 1424 pushl(Immediate(Utils::Low32Bits(constant))); |
| 1377 movsd(dst, Address(ESP, 0)); | 1425 movsd(dst, Address(ESP, 0)); |
| 1378 addl(ESP, Immediate(2 * kWordSize)); | 1426 addl(ESP, Immediate(2 * kWordSize)); |
| 1379 } | 1427 } |
| 1380 | 1428 |
| 1381 | 1429 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 comments.SetCommentAt(i, comments_[i]->comment()); | 1693 comments.SetCommentAt(i, comments_[i]->comment()); |
| 1646 } | 1694 } |
| 1647 | 1695 |
| 1648 return comments; | 1696 return comments; |
| 1649 } | 1697 } |
| 1650 | 1698 |
| 1651 | 1699 |
| 1652 } // namespace dart | 1700 } // namespace dart |
| 1653 | 1701 |
| 1654 #endif // defined TARGET_ARCH_IA32 | 1702 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |