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