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 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 92 } | 94 } |
| 93 | 95 |
| 94 | 96 |
| 95 void Assembler::popl(const Address& address) { | 97 void Assembler::popl(const Address& address) { |
| 96 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 98 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 97 EmitUint8(0x8F); | 99 EmitUint8(0x8F); |
| 98 EmitOperand(0, address); | 100 EmitOperand(0, address); |
| 99 } | 101 } |
| 100 | 102 |
| 101 | 103 |
| 104 void Assembler::pushal() { | |
| 105 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | |
| 106 EmitUint8(0x60); | |
| 107 } | |
| 108 | |
| 109 | |
| 110 void Assembler::popal() { | |
| 111 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | |
| 112 EmitUint8(0x61); | |
| 113 } | |
| 114 | |
| 115 | |
| 102 void Assembler::movl(Register dst, const Immediate& imm) { | 116 void Assembler::movl(Register dst, const Immediate& imm) { |
| 103 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 117 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 104 EmitUint8(0xB8 + dst); | 118 EmitUint8(0xB8 + dst); |
| 105 EmitImmediate(imm); | 119 EmitImmediate(imm); |
| 106 } | 120 } |
| 107 | 121 |
| 108 | 122 |
| 109 void Assembler::movl(Register dst, Register src) { | 123 void Assembler::movl(Register dst, Register src) { |
| 110 AssemblerBuffer::EnsureCapacity ensured(&buffer_); | 124 AssemblerBuffer::EnsureCapacity ensured(&buffer_); |
| 111 EmitUint8(0x89); | 125 EmitUint8(0x89); |
| (...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1357 EmitOperand(7, Operand(reg)); | 1371 EmitOperand(7, Operand(reg)); |
| 1358 buffer_.EmitObject(object); | 1372 buffer_.EmitObject(object); |
| 1359 } | 1373 } |
| 1360 } | 1374 } |
| 1361 } | 1375 } |
| 1362 | 1376 |
| 1363 | 1377 |
| 1364 void Assembler::StoreIntoObject(Register object, | 1378 void Assembler::StoreIntoObject(Register object, |
| 1365 const FieldAddress& dest, | 1379 const FieldAddress& dest, |
| 1366 Register value) { | 1380 Register value) { |
| 1367 // TODO(iposva): Add write barrier. | |
| 1368 movl(dest, value); | 1381 movl(dest, value); |
| 1382 Label done; | |
| 1383 // Check that value is a new object. Store buffer updates are not | |
|
siva
2012/06/08 17:26:01
Check that 'value'
cshapiro
2012/06/08 23:48:04
Fixed.
| |
| 1384 // required when storing a smi or an old object. | |
| 1385 testl(value, Immediate(kNewObjectAlignmentOffset | kHeapObjectTag)); | |
| 1386 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1387 // Check that object is an old object. A store buffer update is | |
|
siva
2012/06/08 17:26:01
Check that 'object'
cshapiro
2012/06/08 23:48:04
Fixed.
| |
| 1388 // not required when storing into a new object. | |
| 1389 testl(object, Immediate(kOldObjectAlignmentOffset | kHeapObjectTag)); | |
| 1390 j(NOT_EQUAL, &done, Assembler::kNearJump); | |
| 1391 // A store buffer update is required. | |
|
Ivan Posva
2012/06/08 14:39:55
I was hoping that you could do the regular store i
cshapiro
2012/06/08 23:48:04
Passing arguments is not a problem. The runtime c
| |
| 1392 pushal(); | |
|
srdjan
2012/06/08 05:46:59
This is bad idea: stack may contain only objects,
cshapiro
2012/06/08 23:48:04
It seems that, thanks to the filter, we can get aw
| |
| 1393 pushl(dest); | |
| 1394 CallRuntime(kStoreBufferRuntimeEntry); | |
| 1395 Drop(1); | |
| 1396 popal(); | |
| 1397 Bind(&done); | |
| 1369 } | 1398 } |
|
siva
2012/06/08 17:26:01
Maybe we need two versions of this one for calls f
| |
| 1370 | 1399 |
| 1371 | 1400 |
| 1401 void Assembler::StoreNullIntoObject(Register object, | |
| 1402 const FieldAddress& dest) { | |
|
srdjan
2012/06/08 05:46:59
Why do you need 'object' ?
cshapiro
2012/06/08 23:48:04
Yes, this code does not make use of object. Howev
| |
| 1403 const Immediate raw_null = | |
| 1404 Immediate(reinterpret_cast<intptr_t>(Object::null())); | |
| 1405 movl(dest, raw_null); | |
| 1406 // No store buffer update. | |
| 1407 } | |
| 1408 | |
| 1409 | |
| 1372 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { | 1410 void Assembler::LoadDoubleConstant(XmmRegister dst, double value) { |
| 1373 // TODO(5410843): Need to have a code constants table. | 1411 // TODO(5410843): Need to have a code constants table. |
| 1374 int64_t constant = bit_cast<int64_t, double>(value); | 1412 int64_t constant = bit_cast<int64_t, double>(value); |
| 1375 pushl(Immediate(Utils::High32Bits(constant))); | 1413 pushl(Immediate(Utils::High32Bits(constant))); |
| 1376 pushl(Immediate(Utils::Low32Bits(constant))); | 1414 pushl(Immediate(Utils::Low32Bits(constant))); |
| 1377 movsd(dst, Address(ESP, 0)); | 1415 movsd(dst, Address(ESP, 0)); |
| 1378 addl(ESP, Immediate(2 * kWordSize)); | 1416 addl(ESP, Immediate(2 * kWordSize)); |
| 1379 } | 1417 } |
| 1380 | 1418 |
| 1381 | 1419 |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1645 comments.SetCommentAt(i, comments_[i]->comment()); | 1683 comments.SetCommentAt(i, comments_[i]->comment()); |
| 1646 } | 1684 } |
| 1647 | 1685 |
| 1648 return comments; | 1686 return comments; |
| 1649 } | 1687 } |
| 1650 | 1688 |
| 1651 | 1689 |
| 1652 } // namespace dart | 1690 } // namespace dart |
| 1653 | 1691 |
| 1654 #endif // defined TARGET_ARCH_IA32 | 1692 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |