Chromium Code Reviews| 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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 if (scale_factor == TIMES_16) { \ | 230 if (scale_factor == TIMES_16) { \ |
| 231 /* double length of array. */ \ | 231 /* double length of array. */ \ |
| 232 __ addq(RDI, RDI); \ | 232 __ addq(RDI, RDI); \ |
| 233 /* only scale by 8. */ \ | 233 /* only scale by 8. */ \ |
| 234 scale_factor = TIMES_8; \ | 234 scale_factor = TIMES_8; \ |
| 235 } \ | 235 } \ |
| 236 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ | 236 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ |
| 237 __ leaq(RDI, Address(RDI, scale_factor, fixed_size)); \ | 237 __ leaq(RDI, Address(RDI, scale_factor, fixed_size)); \ |
| 238 __ andq(RDI, Immediate(-kObjectAlignment)); \ | 238 __ andq(RDI, Immediate(-kObjectAlignment)); \ |
| 239 Heap* heap = Isolate::Current()->heap(); \ | 239 Heap* heap = Isolate::Current()->heap(); \ |
| 240 \ | 240 Heap::Space space = heap->SpaceForAllocation(cid); \ |
| 241 __ movq(RAX, Immediate(heap->TopAddress())); \ | 241 __ movq(RAX, Immediate(heap->TopAddress(space))); \ |
| 242 __ movq(RAX, Address(RAX, 0)); \ | 242 __ movq(RAX, Address(RAX, 0)); \ |
| 243 __ movq(RCX, RAX); \ | 243 __ movq(RCX, RAX); \ |
| 244 \ | 244 \ |
| 245 /* RDI: allocation size. */ \ | 245 /* RDI: allocation size. */ \ |
| 246 __ addq(RCX, RDI); \ | 246 __ addq(RCX, RDI); \ |
| 247 __ j(CARRY, &fall_through); \ | 247 __ j(CARRY, &fall_through); \ |
| 248 \ | 248 \ |
| 249 /* Check if the allocation fits into the remaining space. */ \ | 249 /* Check if the allocation fits into the remaining space. */ \ |
| 250 /* RAX: potential new object start. */ \ | 250 /* RAX: potential new object start. */ \ |
| 251 /* RCX: potential next object start. */ \ | 251 /* RCX: potential next object start. */ \ |
| 252 /* RDI: allocation size. */ \ | 252 /* RDI: allocation size. */ \ |
| 253 /* R13: scratch register. */ \ | 253 /* R13: scratch register. */ \ |
| 254 __ movq(R13, Immediate(heap->EndAddress())); \ | 254 __ movq(R13, Immediate(heap->EndAddress(space))); \ |
| 255 __ cmpq(RCX, Address(R13, 0)); \ | 255 __ cmpq(RCX, Address(R13, 0)); \ |
| 256 __ j(ABOVE_EQUAL, &fall_through); \ | 256 __ j(ABOVE_EQUAL, &fall_through); \ |
| 257 \ | 257 \ |
| 258 /* Successfully allocated the object(s), now update top to point to */ \ | 258 /* Successfully allocated the object(s), now update top to point to */ \ |
| 259 /* next object start and initialize the object. */ \ | 259 /* next object start and initialize the object. */ \ |
| 260 __ movq(R13, Immediate(heap->TopAddress())); \ | 260 __ movq(R13, Immediate(heap->TopAddress(space))); \ |
| 261 __ movq(Address(R13, 0), RCX); \ | 261 __ movq(Address(R13, 0), RCX); \ |
| 262 __ addq(RAX, Immediate(kHeapObjectTag)); \ | 262 __ addq(RAX, Immediate(kHeapObjectTag)); \ |
| 263 __ UpdateAllocationStatsWithSize(cid, RDI); \ | 263 __ UpdateAllocationStatsWithSize(cid, RDI, space); \ |
| 264 /* Initialize the tags. */ \ | 264 /* Initialize the tags. */ \ |
| 265 /* RAX: new object start as a tagged pointer. */ \ | 265 /* RAX: new object start as a tagged pointer. */ \ |
| 266 /* RCX: new object end address. */ \ | 266 /* RCX: new object end address. */ \ |
| 267 /* RDI: allocation size. */ \ | 267 /* RDI: allocation size. */ \ |
| 268 /* R13: scratch register. */ \ | 268 /* R13: scratch register. */ \ |
| 269 { \ | 269 { \ |
| 270 Label size_tag_overflow, done; \ | 270 Label size_tag_overflow, done; \ |
| 271 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ | 271 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ |
| 272 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ | 272 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ |
| 273 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ | 273 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ |
| (...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1299 } | 1299 } |
| 1300 Label pop_and_fail; | 1300 Label pop_and_fail; |
| 1301 __ pushq(RDI); // Preserve length. | 1301 __ pushq(RDI); // Preserve length. |
| 1302 __ SmiUntag(RDI); | 1302 __ SmiUntag(RDI); |
| 1303 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1303 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
| 1304 __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi. | 1304 __ leaq(RDI, Address(RDI, TIMES_1, fixed_size)); // RDI is a Smi. |
| 1305 __ andq(RDI, Immediate(-kObjectAlignment)); | 1305 __ andq(RDI, Immediate(-kObjectAlignment)); |
| 1306 | 1306 |
| 1307 Isolate* isolate = Isolate::Current(); | 1307 Isolate* isolate = Isolate::Current(); |
| 1308 Heap* heap = isolate->heap(); | 1308 Heap* heap = isolate->heap(); |
| 1309 | 1309 Heap::Space space = heap->SpaceForAllocation(kOneByteStringCid); |
| 1310 __ movq(RAX, Immediate(heap->TopAddress())); | 1310 __ movq(RAX, Immediate(heap->TopAddress(space))); |
| 1311 __ movq(RAX, Address(RAX, 0)); | 1311 __ movq(RAX, Address(RAX, 0)); |
| 1312 | 1312 |
| 1313 // RDI: allocation size. | 1313 // RDI: allocation size. |
| 1314 __ movq(RCX, RAX); | 1314 __ movq(RCX, RAX); |
| 1315 __ addq(RCX, RDI); | 1315 __ addq(RCX, RDI); |
| 1316 __ j(CARRY, &pop_and_fail); | 1316 __ j(CARRY, &pop_and_fail); |
| 1317 | 1317 |
| 1318 // Check if the allocation fits into the remaining space. | 1318 // Check if the allocation fits into the remaining space. |
| 1319 // RAX: potential new object start. | 1319 // RAX: potential new object start. |
| 1320 // RCX: potential next object start. | 1320 // RCX: potential next object start. |
| 1321 // RDI: allocation size. | 1321 // RDI: allocation size. |
| 1322 __ movq(R13, Immediate(heap->EndAddress())); | 1322 __ movq(R13, Immediate(heap->EndAddress(space))); |
| 1323 __ cmpq(RCX, Address(R13, 0)); | 1323 __ cmpq(RCX, Address(R13, 0)); |
| 1324 __ j(ABOVE_EQUAL, &pop_and_fail); | 1324 __ j(ABOVE_EQUAL, &pop_and_fail); |
| 1325 | 1325 |
| 1326 // Successfully allocated the object(s), now update top to point to | 1326 // Successfully allocated the object(s), now update top to point to |
| 1327 // next object start and initialize the object. | 1327 // next object start and initialize the object. |
| 1328 __ movq(R13, Immediate(heap->TopAddress())); | 1328 __ movq(R13, Immediate(heap->TopAddress(space))); |
| 1329 __ movq(Address(R13, 0), RCX); | 1329 __ movq(Address(R13, 0), RCX); |
| 1330 __ addq(RAX, Immediate(kHeapObjectTag)); | 1330 __ addq(RAX, Immediate(kHeapObjectTag)); |
| 1331 __ UpdateAllocationStatsWithSize(kOneByteStringCid, RDI); | 1331 __ UpdateAllocationStatsWithSize(kOneByteStringCid, RDI, space); |
| 1332 | 1332 |
| 1333 // Initialize the tags. | 1333 // Initialize the tags. |
| 1334 // RAX: new object start as a tagged pointer. | 1334 // RAX: new object start as a tagged pointer. |
| 1335 // RDI: allocation size. | 1335 // RDI: allocation size. |
| 1336 { | 1336 { |
| 1337 Label size_tag_overflow, done; | 1337 Label size_tag_overflow, done; |
| 1338 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 1338 __ cmpq(RDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
| 1339 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 1339 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
| 1340 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 1340 __ shlq(RDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
| 1341 __ jmp(&done, Assembler::kNearJump); | 1341 __ jmp(&done, Assembler::kNearJump); |
| 1342 | 1342 |
| 1343 __ Bind(&size_tag_overflow); | 1343 __ Bind(&size_tag_overflow); |
| 1344 __ xorq(RDI, RDI); | 1344 __ xorq(RDI, RDI); |
| 1345 __ Bind(&done); | 1345 __ Bind(&done); |
| 1346 | 1346 |
| 1347 // Get the class index and insert it into the tags. | 1347 // Get the class index and insert it into the tags. |
| 1348 const Class& cls = | 1348 const Class& cls = |
| 1349 Class::Handle(isolate->object_store()->one_byte_string_class()); | 1349 Class::Handle(isolate->object_store()->one_byte_string_class()); |
|
Ivan Posva
2014/09/19 18:45:55
Maybe just define a cid local variable above and a
koda
2014/09/19 20:48:29
Done.
| |
| 1350 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id()))); | 1350 __ orq(RDI, Immediate(RawObject::ClassIdTag::encode(cls.id()))); |
| 1351 __ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags. | 1351 __ movq(FieldAddress(RAX, String::tags_offset()), RDI); // Tags. |
| 1352 } | 1352 } |
| 1353 | 1353 |
| 1354 // Set the length field. | 1354 // Set the length field. |
| 1355 __ popq(RDI); | 1355 __ popq(RDI); |
| 1356 __ StoreIntoObjectNoBarrier(RAX, | 1356 __ StoreIntoObjectNoBarrier(RAX, |
| 1357 FieldAddress(RAX, String::length_offset()), | 1357 FieldAddress(RAX, String::length_offset()), |
| 1358 RDI); | 1358 RDI); |
| 1359 // Clear hash. | 1359 // Clear hash. |
| (...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1549 // Set return value to Isolate::current_tag_. | 1549 // Set return value to Isolate::current_tag_. |
| 1550 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); | 1550 __ movq(RAX, Address(RBX, Isolate::current_tag_offset())); |
| 1551 __ ret(); | 1551 __ ret(); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 #undef __ | 1554 #undef __ |
| 1555 | 1555 |
| 1556 } // namespace dart | 1556 } // namespace dart |
| 1557 | 1557 |
| 1558 #endif // defined TARGET_ARCH_X64 | 1558 #endif // defined TARGET_ARCH_X64 |
| OLD | NEW |