Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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" // Needed here to get TARGET_ARCH_X64. | 5 #include "vm/globals.h" // Needed here to get TARGET_ARCH_X64. |
| 6 #if defined(TARGET_ARCH_X64) | 6 #if defined(TARGET_ARCH_X64) |
| 7 | 7 |
| 8 #include "vm/intrinsifier.h" | 8 #include "vm/intrinsifier.h" |
| 9 | 9 |
| 10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 | 54 |
| 55 // RDI: allocation size. | 55 // RDI: allocation size. |
| 56 __ movq(RAX, Immediate(heap->TopAddress())); | 56 __ movq(RAX, Immediate(heap->TopAddress())); |
| 57 __ movq(RAX, Address(RAX, 0)); | 57 __ movq(RAX, Address(RAX, 0)); |
| 58 __ leaq(RCX, Address(RAX, RDI, TIMES_1, 0)); | 58 __ leaq(RCX, Address(RAX, RDI, TIMES_1, 0)); |
| 59 | 59 |
| 60 // Check if the allocation fits into the remaining space. | 60 // Check if the allocation fits into the remaining space. |
| 61 // RAX: potential new object start. | 61 // RAX: potential new object start. |
| 62 // RCX: potential next object start. | 62 // RCX: potential next object start. |
| 63 // RDI: allocation size. | 63 // RDI: allocation size. |
| 64 __ movq(R13, Immediate(heap->TopAddress())); | 64 __ movq(R13, Immediate(heap->EndAddress())); |
| 65 __ cmpq(RCX, Address(R13, 0)); | 65 __ cmpq(RCX, Address(R13, 0)); |
| 66 __ j(ABOVE_EQUAL, &fall_through); | 66 __ j(ABOVE_EQUAL, &fall_through); |
| 67 | 67 |
| 68 // Successfully allocated the object(s), now update top to point to | 68 // Successfully allocated the object(s), now update top to point to |
| 69 // next object start and initialize the object. | 69 // next object start and initialize the object. |
| 70 __ movq(R13, Immediate(heap->TopAddress())); | |
| 70 __ movq(Address(R13, 0), RCX); | 71 __ movq(Address(R13, 0), RCX); |
| 71 __ addq(RAX, Immediate(kHeapObjectTag)); | 72 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 72 | 73 |
| 73 // Initialize the tags. | 74 // Initialize the tags. |
| 74 // RAX: new object start as a tagged pointer. | 75 // RAX: new object start as a tagged pointer. |
| 75 // RCX: new object end address. | 76 // RCX: new object end address. |
|
siva
2012/08/06 22:47:17
RCX is not used in the block below, why does it ha
srdjan
2012/08/06 23:01:02
Removed from comment.
| |
| 76 // RDI: allocation size. | 77 // RDI: allocation size. |
| 77 { | 78 { |
| 78 Label size_tag_overflow, done; | 79 Label size_tag_overflow, done; |
| 79 __ cmpl(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 80 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 80 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 81 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 81 __ shlq(RDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); | 82 __ shlq(RDI, Immediate(RawObject::kSizeTagBit - kObjectAlignmentLog2)); |
| 82 __ jmp(&done, Assembler::kNearJump); | 83 __ jmp(&done, Assembler::kNearJump); |
| 83 | 84 |
| 84 __ Bind(&size_tag_overflow); | 85 __ Bind(&size_tag_overflow); |
| 85 __ movq(RDI, Immediate(0)); | 86 __ movq(RDI, Immediate(0)); |
| 86 __ Bind(&done); | 87 __ Bind(&done); |
| 87 | 88 |
| 88 // Get the class index and insert it into the tags. | 89 // Get the class index and insert it into the tags. |
| 89 const Class& cls = Class::Handle(isolate->object_store()->array_class()); | 90 const Class& cls = Class::Handle(isolate->object_store()->array_class()); |
| 90 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id()))); | 91 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id()))); |
| 91 __ movq(FieldAddress(RAX, Array::tags_offset()), RDI); // Tags. | 92 __ movq(FieldAddress(RAX, Array::tags_offset()), RDI); // Tags. |
| 92 } | 93 } |
| 93 | 94 |
| 94 // RAX: new object start as a tagged pointer. | 95 // RAX: new object start as a tagged pointer. |
| 95 // RCX: new object end address. | 96 // RCX: new object end address. |
|
siva
2012/08/06 22:47:17
Ditto comment regarding RCX.
srdjan
2012/08/06 23:01:02
Removed from comment.
| |
| 96 // Store the type argument field. | 97 // Store the type argument field. |
| 97 __ movl(RDI, Address(RSP, kTypeArgumentsOffset)); // type argument. | 98 __ movq(RDI, Address(RSP, kTypeArgumentsOffset)); // type argument. |
| 98 __ StoreIntoObjectNoBarrier(RAX, | 99 __ StoreIntoObjectNoBarrier(RAX, |
| 99 FieldAddress(RAX, Array::type_arguments_offset()), | 100 FieldAddress(RAX, Array::type_arguments_offset()), |
| 100 RDI); | 101 RDI); |
| 101 | 102 |
| 102 // Set the length field. | 103 // Set the length field. |
| 103 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length. | 104 __ movq(RDI, Address(RSP, kArrayLengthOffset)); // Array Length. |
| 104 __ StoreIntoObjectNoBarrier(RAX, | 105 __ StoreIntoObjectNoBarrier(RAX, |
| 105 FieldAddress(RAX, Array::length_offset()), | 106 FieldAddress(RAX, Array::length_offset()), |
| 106 RDI); | 107 RDI); |
| 107 | 108 |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1321 __ LoadObject(RAX, bool_true); | 1322 __ LoadObject(RAX, bool_true); |
| 1322 __ ret(); | 1323 __ ret(); |
| 1323 return true; | 1324 return true; |
| 1324 } | 1325 } |
| 1325 | 1326 |
| 1326 #undef __ | 1327 #undef __ |
| 1327 | 1328 |
| 1328 } // namespace dart | 1329 } // namespace dart |
| 1329 | 1330 |
| 1330 #endif // defined TARGET_ARCH_X64 | 1331 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |