OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_X64) | 6 #if defined(TARGET_ARCH_X64) |
7 | 7 |
8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 1015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1026 __ pushq(RAX); | 1026 __ pushq(RAX); |
1027 __ pushq(RCX); | 1027 __ pushq(RCX); |
1028 | 1028 |
1029 Label add_to_buffer; | 1029 Label add_to_buffer; |
1030 // Check whether this object has already been remembered. Skip adding to the | 1030 // Check whether this object has already been remembered. Skip adding to the |
1031 // store buffer if the object is in the store buffer already. | 1031 // store buffer if the object is in the store buffer already. |
1032 // Spilled: RAX, RCX | 1032 // Spilled: RAX, RCX |
1033 // RDX: Address being stored | 1033 // RDX: Address being stored |
1034 Label reload; | 1034 Label reload; |
1035 __ Bind(&reload); | 1035 __ Bind(&reload); |
1036 __ movq(RAX, FieldAddress(RDX, Object::tags_offset())); | 1036 __ movl(RAX, FieldAddress(RDX, Object::tags_offset())); |
1037 __ testq(RAX, Immediate(1 << RawObject::kRememberedBit)); | 1037 __ testl(RAX, Immediate(1 << RawObject::kRememberedBit)); |
1038 __ j(EQUAL, &add_to_buffer, Assembler::kNearJump); | 1038 __ j(EQUAL, &add_to_buffer, Assembler::kNearJump); |
1039 __ popq(RCX); | 1039 __ popq(RCX); |
1040 __ popq(RAX); | 1040 __ popq(RAX); |
1041 __ ret(); | 1041 __ ret(); |
1042 | 1042 |
1043 // Update the tags that this object has been remembered. | 1043 // Update the tags that this object has been remembered. |
| 1044 // Note that we use 32 bit operations here to match the size of the |
| 1045 // background sweeper which is also manipulating this 32 bit word. |
1044 // RDX: Address being stored | 1046 // RDX: Address being stored |
1045 // RAX: Current tag value | 1047 // RAX: Current tag value |
1046 __ Bind(&add_to_buffer); | 1048 __ Bind(&add_to_buffer); |
1047 __ movq(RCX, RAX); | 1049 __ movl(RCX, RAX); |
1048 __ orq(RCX, Immediate(1 << RawObject::kRememberedBit)); | 1050 __ orl(RCX, Immediate(1 << RawObject::kRememberedBit)); |
1049 // Compare the tag word with RAX, update to RCX if unchanged. | 1051 // Compare the tag word with RAX, update to RCX if unchanged. |
1050 __ LockCmpxchgq(FieldAddress(RDX, Object::tags_offset()), RCX); | 1052 __ LockCmpxchgl(FieldAddress(RDX, Object::tags_offset()), RCX); |
1051 __ j(NOT_EQUAL, &reload); | 1053 __ j(NOT_EQUAL, &reload); |
1052 | 1054 |
1053 // Load the StoreBuffer block out of the thread. Then load top_ out of the | 1055 // Load the StoreBuffer block out of the thread. Then load top_ out of the |
1054 // StoreBufferBlock and add the address to the pointers_. | 1056 // StoreBufferBlock and add the address to the pointers_. |
1055 // RDX: Address being stored | 1057 // RDX: Address being stored |
1056 __ movq(RAX, Address(THR, Thread::store_buffer_block_offset())); | 1058 __ movq(RAX, Address(THR, Thread::store_buffer_block_offset())); |
1057 __ movl(RCX, Address(RAX, StoreBufferBlock::top_offset())); | 1059 __ movl(RCX, Address(RAX, StoreBufferBlock::top_offset())); |
1058 __ movq(Address(RAX, RCX, TIMES_8, StoreBufferBlock::pointers_offset()), RDX); | 1060 __ movq(Address(RAX, RCX, TIMES_8, StoreBufferBlock::pointers_offset()), RDX); |
1059 | 1061 |
1060 // Increment top_ and check for overflow. | 1062 // Increment top_ and check for overflow. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 } else { | 1126 } else { |
1125 __ j(ABOVE_EQUAL, &slow_case); | 1127 __ j(ABOVE_EQUAL, &slow_case); |
1126 } | 1128 } |
1127 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); | 1129 __ movq(Address(RCX, Heap::TopOffset(space)), RBX); |
1128 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), space)); | 1130 NOT_IN_PRODUCT(__ UpdateAllocationStats(cls.id(), space)); |
1129 | 1131 |
1130 // RAX: new object start (untagged). | 1132 // RAX: new object start (untagged). |
1131 // RBX: next object start. | 1133 // RBX: next object start. |
1132 // RDX: new object type arguments (if is_cls_parameterized). | 1134 // RDX: new object type arguments (if is_cls_parameterized). |
1133 // Set the tags. | 1135 // Set the tags. |
1134 uword tags = 0; | 1136 uint32_t tags = 0; |
1135 tags = RawObject::SizeTag::update(instance_size, tags); | 1137 tags = RawObject::SizeTag::update(instance_size, tags); |
1136 ASSERT(cls.id() != kIllegalCid); | 1138 ASSERT(cls.id() != kIllegalCid); |
1137 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 1139 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 1140 // 64 bit store also zeros the identity hash field. |
1138 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); | 1141 __ movq(Address(RAX, Instance::tags_offset()), Immediate(tags)); |
1139 __ addq(RAX, Immediate(kHeapObjectTag)); | 1142 __ addq(RAX, Immediate(kHeapObjectTag)); |
1140 | 1143 |
1141 // Initialize the remaining words of the object. | 1144 // Initialize the remaining words of the object. |
1142 // RAX: new object (tagged). | 1145 // RAX: new object (tagged). |
1143 // RBX: next object start. | 1146 // RBX: next object start. |
1144 // RDX: new object type arguments (if is_cls_parameterized). | 1147 // RDX: new object type arguments (if is_cls_parameterized). |
1145 // R9: raw null. | 1148 // R9: raw null. |
1146 // First try inlining the initialization without a loop. | 1149 // First try inlining the initialization without a loop. |
1147 if (instance_size < (kInlineInstanceSize * kWordSize)) { | 1150 if (instance_size < (kInlineInstanceSize * kWordSize)) { |
(...skipping 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 } | 2322 } |
2320 | 2323 |
2321 | 2324 |
2322 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { | 2325 void StubCode::GenerateAsynchronousGapMarkerStub(Assembler* assembler) { |
2323 __ int3(); | 2326 __ int3(); |
2324 } | 2327 } |
2325 | 2328 |
2326 } // namespace dart | 2329 } // namespace dart |
2327 | 2330 |
2328 #endif // defined TARGET_ARCH_X64 | 2331 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |