| 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" // 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 /* double length of array. */ \ | 168 /* double length of array. */ \ |
| 169 __ addq(RDI, RDI); \ | 169 __ addq(RDI, RDI); \ |
| 170 /* only scale by 8. */ \ | 170 /* only scale by 8. */ \ |
| 171 scale_factor = TIMES_8; \ | 171 scale_factor = TIMES_8; \ |
| 172 } \ | 172 } \ |
| 173 const intptr_t fixed_size_plus_alignment_padding = \ | 173 const intptr_t fixed_size_plus_alignment_padding = \ |
| 174 sizeof(Raw##type_name) + kObjectAlignment - 1; \ | 174 sizeof(Raw##type_name) + kObjectAlignment - 1; \ |
| 175 __ leaq(RDI, Address(RDI, scale_factor, fixed_size_plus_alignment_padding)); \ | 175 __ leaq(RDI, Address(RDI, scale_factor, fixed_size_plus_alignment_padding)); \ |
| 176 __ andq(RDI, Immediate(-kObjectAlignment)); \ | 176 __ andq(RDI, Immediate(-kObjectAlignment)); \ |
| 177 Heap::Space space = Heap::kNew; \ | 177 Heap::Space space = Heap::kNew; \ |
| 178 __ movq(R13, Address(THR, Thread::heap_offset())); \ | 178 __ movq(RAX, Address(THR, Thread::top_offset())); \ |
| 179 __ movq(RAX, Address(R13, Heap::TopOffset(space))); \ | |
| 180 __ movq(RCX, RAX); \ | 179 __ movq(RCX, RAX); \ |
| 181 \ | 180 \ |
| 182 /* RDI: allocation size. */ \ | 181 /* RDI: allocation size. */ \ |
| 183 __ addq(RCX, RDI); \ | 182 __ addq(RCX, RDI); \ |
| 184 __ j(CARRY, &fall_through); \ | 183 __ j(CARRY, &fall_through); \ |
| 185 \ | 184 \ |
| 186 /* Check if the allocation fits into the remaining space. */ \ | 185 /* Check if the allocation fits into the remaining space. */ \ |
| 187 /* RAX: potential new object start. */ \ | 186 /* RAX: potential new object start. */ \ |
| 188 /* RCX: potential next object start. */ \ | 187 /* RCX: potential next object start. */ \ |
| 189 /* RDI: allocation size. */ \ | 188 /* RDI: allocation size. */ \ |
| 190 /* R13: heap. */ \ | 189 /* R13: heap. */ \ |
| 191 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); \ | 190 __ cmpq(RCX, Address(THR, Thread::end_offset())); \ |
| 192 __ j(ABOVE_EQUAL, &fall_through); \ | 191 __ j(ABOVE_EQUAL, &fall_through); \ |
| 193 \ | 192 \ |
| 194 /* Successfully allocated the object(s), now update top to point to */ \ | 193 /* Successfully allocated the object(s), now update top to point to */ \ |
| 195 /* next object start and initialize the object. */ \ | 194 /* next object start and initialize the object. */ \ |
| 196 __ movq(Address(R13, Heap::TopOffset(space)), RCX); \ | 195 __ movq(Address(THR, Thread::top_offset()), RCX); \ |
| 197 __ addq(RAX, Immediate(kHeapObjectTag)); \ | 196 __ addq(RAX, Immediate(kHeapObjectTag)); \ |
| 198 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); \ | 197 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); \ |
| 199 /* Initialize the tags. */ \ | 198 /* Initialize the tags. */ \ |
| 200 /* RAX: new object start as a tagged pointer. */ \ | 199 /* RAX: new object start as a tagged pointer. */ \ |
| 201 /* RCX: new object end address. */ \ | 200 /* RCX: new object end address. */ \ |
| 202 /* RDI: allocation size. */ \ | 201 /* RDI: allocation size. */ \ |
| 203 /* R13: scratch register. */ \ | 202 /* R13: scratch register. */ \ |
| 204 { \ | 203 { \ |
| 205 Label size_tag_overflow, done; \ | 204 Label size_tag_overflow, done; \ |
| 206 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ | 205 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ |
| (...skipping 1812 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2019 __ j(NOT_ZERO, ¬_zero_length); | 2018 __ j(NOT_ZERO, ¬_zero_length); |
| 2020 __ addq(RDI, Immediate(1)); | 2019 __ addq(RDI, Immediate(1)); |
| 2021 __ Bind(¬_zero_length); | 2020 __ Bind(¬_zero_length); |
| 2022 const intptr_t fixed_size_plus_alignment_padding = | 2021 const intptr_t fixed_size_plus_alignment_padding = |
| 2023 sizeof(RawString) + kObjectAlignment - 1; | 2022 sizeof(RawString) + kObjectAlignment - 1; |
| 2024 __ addq(RDI, Immediate(fixed_size_plus_alignment_padding)); | 2023 __ addq(RDI, Immediate(fixed_size_plus_alignment_padding)); |
| 2025 __ andq(RDI, Immediate(-kObjectAlignment)); | 2024 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 2026 | 2025 |
| 2027 const intptr_t cid = kOneByteStringCid; | 2026 const intptr_t cid = kOneByteStringCid; |
| 2028 Heap::Space space = Heap::kNew; | 2027 Heap::Space space = Heap::kNew; |
| 2029 __ movq(R13, Address(THR, Thread::heap_offset())); | 2028 __ movq(RAX, Address(THR, Thread::top_offset())); |
| 2030 __ movq(RAX, Address(R13, Heap::TopOffset(space))); | |
| 2031 | 2029 |
| 2032 // RDI: allocation size. | 2030 // RDI: allocation size. |
| 2033 __ movq(RCX, RAX); | 2031 __ movq(RCX, RAX); |
| 2034 __ addq(RCX, RDI); | 2032 __ addq(RCX, RDI); |
| 2035 __ j(CARRY, &pop_and_fail); | 2033 __ j(CARRY, &pop_and_fail); |
| 2036 | 2034 |
| 2037 // Check if the allocation fits into the remaining space. | 2035 // Check if the allocation fits into the remaining space. |
| 2038 // RAX: potential new object start. | 2036 // RAX: potential new object start. |
| 2039 // RCX: potential next object start. | 2037 // RCX: potential next object start. |
| 2040 // RDI: allocation size. | 2038 // RDI: allocation size. |
| 2041 // R13: heap. | 2039 __ cmpq(RCX, Address(THR, Thread::end_offset())); |
| 2042 __ cmpq(RCX, Address(R13, Heap::EndOffset(space))); | |
| 2043 __ j(ABOVE_EQUAL, &pop_and_fail); | 2040 __ j(ABOVE_EQUAL, &pop_and_fail); |
| 2044 | 2041 |
| 2045 // Successfully allocated the object(s), now update top to point to | 2042 // Successfully allocated the object(s), now update top to point to |
| 2046 // next object start and initialize the object. | 2043 // next object start and initialize the object. |
| 2047 __ movq(Address(R13, Heap::TopOffset(space)), RCX); | 2044 __ movq(Address(THR, Thread::top_offset()), RCX); |
| 2048 __ addq(RAX, Immediate(kHeapObjectTag)); | 2045 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 2049 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); | 2046 NOT_IN_PRODUCT(__ UpdateAllocationStatsWithSize(cid, RDI, space)); |
| 2050 | 2047 |
| 2051 // Initialize the tags. | 2048 // Initialize the tags. |
| 2052 // RAX: new object start as a tagged pointer. | 2049 // RAX: new object start as a tagged pointer. |
| 2053 // RDI: allocation size. | 2050 // RDI: allocation size. |
| 2054 { | 2051 { |
| 2055 Label size_tag_overflow, done; | 2052 Label size_tag_overflow, done; |
| 2056 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 2053 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 2057 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 2054 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2319 __ movq(Address(THR, Thread::async_stack_trace_offset()), RAX); | 2316 __ movq(Address(THR, Thread::async_stack_trace_offset()), RAX); |
| 2320 __ LoadObject(RAX, Object::null_object()); | 2317 __ LoadObject(RAX, Object::null_object()); |
| 2321 __ ret(); | 2318 __ ret(); |
| 2322 } | 2319 } |
| 2323 | 2320 |
| 2324 #undef __ | 2321 #undef __ |
| 2325 | 2322 |
| 2326 } // namespace dart | 2323 } // namespace dart |
| 2327 | 2324 |
| 2328 #endif // defined TARGET_ARCH_X64 | 2325 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |