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 // The intrinsic code below is executed before a method has built its frame. | 5 // The intrinsic code below is executed before a method has built its frame. |
6 // The return address is on the stack and the arguments below it. | 6 // The return address is on the stack and the arguments below it. |
7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. | 7 // Registers EDX (arguments descriptor) and ECX (function) must be preserved. |
8 // Each intrinsification method returns true if the corresponding | 8 // Each intrinsification method returns true if the corresponding |
9 // Dart method was intrinsified. | 9 // Dart method was intrinsified. |
10 | 10 |
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 if (scale_factor == TIMES_16) { \ | 279 if (scale_factor == TIMES_16) { \ |
280 /* double length of array. */ \ | 280 /* double length of array. */ \ |
281 __ addl(EDI, EDI); \ | 281 __ addl(EDI, EDI); \ |
282 /* only scale by 8. */ \ | 282 /* only scale by 8. */ \ |
283 scale_factor = TIMES_8; \ | 283 scale_factor = TIMES_8; \ |
284 } \ | 284 } \ |
285 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ | 285 const intptr_t fixed_size = sizeof(Raw##type_name) + kObjectAlignment - 1; \ |
286 __ leal(EDI, Address(EDI, scale_factor, fixed_size)); \ | 286 __ leal(EDI, Address(EDI, scale_factor, fixed_size)); \ |
287 __ andl(EDI, Immediate(-kObjectAlignment)); \ | 287 __ andl(EDI, Immediate(-kObjectAlignment)); \ |
288 Heap* heap = Isolate::Current()->heap(); \ | 288 Heap* heap = Isolate::Current()->heap(); \ |
289 \ | 289 Heap::Space space = heap->SpaceForAllocation(cid); \ |
290 __ movl(EAX, Address::Absolute(heap->TopAddress())); \ | 290 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); \ |
291 __ movl(EBX, EAX); \ | 291 __ movl(EBX, EAX); \ |
292 \ | 292 \ |
293 /* EDI: allocation size. */ \ | 293 /* EDI: allocation size. */ \ |
294 __ addl(EBX, EDI); \ | 294 __ addl(EBX, EDI); \ |
295 __ j(CARRY, &fall_through); \ | 295 __ j(CARRY, &fall_through); \ |
296 \ | 296 \ |
297 /* Check if the allocation fits into the remaining space. */ \ | 297 /* Check if the allocation fits into the remaining space. */ \ |
298 /* EAX: potential new object start. */ \ | 298 /* EAX: potential new object start. */ \ |
299 /* EBX: potential next object start. */ \ | 299 /* EBX: potential next object start. */ \ |
300 /* EDI: allocation size. */ \ | 300 /* EDI: allocation size. */ \ |
301 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); \ | 301 __ cmpl(EBX, Address::Absolute(heap->EndAddress(space))); \ |
302 __ j(ABOVE_EQUAL, &fall_through); \ | 302 __ j(ABOVE_EQUAL, &fall_through); \ |
303 \ | 303 \ |
304 /* Successfully allocated the object(s), now update top to point to */ \ | 304 /* Successfully allocated the object(s), now update top to point to */ \ |
305 /* next object start and initialize the object. */ \ | 305 /* next object start and initialize the object. */ \ |
306 __ movl(Address::Absolute(heap->TopAddress()), EBX); \ | 306 __ movl(Address::Absolute(heap->TopAddress(space)), EBX); \ |
307 __ addl(EAX, Immediate(kHeapObjectTag)); \ | 307 __ addl(EAX, Immediate(kHeapObjectTag)); \ |
308 __ UpdateAllocationStatsWithSize(cid, EDI, kNoRegister); \ | 308 __ UpdateAllocationStatsWithSize(cid, EDI, kNoRegister, space); \ |
309 \ | 309 \ |
310 /* Initialize the tags. */ \ | 310 /* Initialize the tags. */ \ |
311 /* EAX: new object start as a tagged pointer. */ \ | 311 /* EAX: new object start as a tagged pointer. */ \ |
312 /* EBX: new object end address. */ \ | 312 /* EBX: new object end address. */ \ |
313 /* EDI: allocation size. */ \ | 313 /* EDI: allocation size. */ \ |
314 { \ | 314 { \ |
315 Label size_tag_overflow, done; \ | 315 Label size_tag_overflow, done; \ |
316 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ | 316 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); \ |
317 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ | 317 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); \ |
318 __ shll(EDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ | 318 __ shll(EDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); \ |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 } | 1495 } |
1496 Label pop_and_fail; | 1496 Label pop_and_fail; |
1497 __ pushl(EDI); // Preserve length. | 1497 __ pushl(EDI); // Preserve length. |
1498 __ SmiUntag(EDI); | 1498 __ SmiUntag(EDI); |
1499 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; | 1499 const intptr_t fixed_size = sizeof(RawString) + kObjectAlignment - 1; |
1500 __ leal(EDI, Address(EDI, TIMES_1, fixed_size)); // EDI is untagged. | 1500 __ leal(EDI, Address(EDI, TIMES_1, fixed_size)); // EDI is untagged. |
1501 __ andl(EDI, Immediate(-kObjectAlignment)); | 1501 __ andl(EDI, Immediate(-kObjectAlignment)); |
1502 | 1502 |
1503 Isolate* isolate = Isolate::Current(); | 1503 Isolate* isolate = Isolate::Current(); |
1504 Heap* heap = isolate->heap(); | 1504 Heap* heap = isolate->heap(); |
1505 | 1505 const intptr_t cid = kOneByteStringCid; |
1506 __ movl(EAX, Address::Absolute(heap->TopAddress())); | 1506 Heap::Space space = heap->SpaceForAllocation(cid); |
| 1507 __ movl(EAX, Address::Absolute(heap->TopAddress(space))); |
1507 __ movl(EBX, EAX); | 1508 __ movl(EBX, EAX); |
1508 | 1509 |
1509 // EDI: allocation size. | 1510 // EDI: allocation size. |
1510 __ addl(EBX, EDI); | 1511 __ addl(EBX, EDI); |
1511 __ j(CARRY, &pop_and_fail, Assembler::kNearJump); | 1512 __ j(CARRY, &pop_and_fail, Assembler::kNearJump); |
1512 | 1513 |
1513 // Check if the allocation fits into the remaining space. | 1514 // Check if the allocation fits into the remaining space. |
1514 // EAX: potential new object start. | 1515 // EAX: potential new object start. |
1515 // EBX: potential next object start. | 1516 // EBX: potential next object start. |
1516 // EDI: allocation size. | 1517 // EDI: allocation size. |
1517 __ cmpl(EBX, Address::Absolute(heap->EndAddress())); | 1518 __ cmpl(EBX, Address::Absolute(heap->EndAddress(space))); |
1518 __ j(ABOVE_EQUAL, &pop_and_fail, Assembler::kNearJump); | 1519 __ j(ABOVE_EQUAL, &pop_and_fail, Assembler::kNearJump); |
1519 | 1520 |
1520 // Successfully allocated the object(s), now update top to point to | 1521 // Successfully allocated the object(s), now update top to point to |
1521 // next object start and initialize the object. | 1522 // next object start and initialize the object. |
1522 __ movl(Address::Absolute(heap->TopAddress()), EBX); | 1523 __ movl(Address::Absolute(heap->TopAddress(space)), EBX); |
1523 __ addl(EAX, Immediate(kHeapObjectTag)); | 1524 __ addl(EAX, Immediate(kHeapObjectTag)); |
1524 | 1525 |
1525 __ UpdateAllocationStatsWithSize(kOneByteStringCid, EDI, kNoRegister); | 1526 __ UpdateAllocationStatsWithSize(cid, EDI, kNoRegister, space); |
1526 | 1527 |
1527 // Initialize the tags. | 1528 // Initialize the tags. |
1528 // EAX: new object start as a tagged pointer. | 1529 // EAX: new object start as a tagged pointer. |
1529 // EBX: new object end address. | 1530 // EBX: new object end address. |
1530 // EDI: allocation size. | 1531 // EDI: allocation size. |
1531 { | 1532 { |
1532 Label size_tag_overflow, done; | 1533 Label size_tag_overflow, done; |
1533 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); | 1534 __ cmpl(EDI, Immediate(RawObject::SizeTag::kMaxSizeTag)); |
1534 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); | 1535 __ j(ABOVE, &size_tag_overflow, Assembler::kNearJump); |
1535 __ shll(EDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); | 1536 __ shll(EDI, Immediate(RawObject::kSizeTagPos - kObjectAlignmentLog2)); |
1536 __ jmp(&done, Assembler::kNearJump); | 1537 __ jmp(&done, Assembler::kNearJump); |
1537 | 1538 |
1538 __ Bind(&size_tag_overflow); | 1539 __ Bind(&size_tag_overflow); |
1539 __ xorl(EDI, EDI); | 1540 __ xorl(EDI, EDI); |
1540 __ Bind(&done); | 1541 __ Bind(&done); |
1541 | 1542 |
1542 // Get the class index and insert it into the tags. | 1543 // Get the class index and insert it into the tags. |
1543 const Class& cls = | 1544 __ orl(EDI, Immediate(RawObject::ClassIdTag::encode(cid))); |
1544 Class::Handle(isolate->object_store()->one_byte_string_class()); | |
1545 __ orl(EDI, Immediate(RawObject::ClassIdTag::encode(cls.id()))); | |
1546 __ movl(FieldAddress(EAX, String::tags_offset()), EDI); // Tags. | 1545 __ movl(FieldAddress(EAX, String::tags_offset()), EDI); // Tags. |
1547 } | 1546 } |
1548 | 1547 |
1549 // Set the length field. | 1548 // Set the length field. |
1550 __ popl(EDI); | 1549 __ popl(EDI); |
1551 __ StoreIntoObjectNoBarrier(EAX, | 1550 __ StoreIntoObjectNoBarrier(EAX, |
1552 FieldAddress(EAX, String::length_offset()), | 1551 FieldAddress(EAX, String::length_offset()), |
1553 EDI); | 1552 EDI); |
1554 // Clear hash. | 1553 // Clear hash. |
1555 __ movl(FieldAddress(EAX, String::hash_offset()), Immediate(0)); | 1554 __ movl(FieldAddress(EAX, String::hash_offset()), Immediate(0)); |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1742 Isolate::current_tag_offset()); | 1741 Isolate::current_tag_offset()); |
1743 // Set return value to Isolate::current_tag_. | 1742 // Set return value to Isolate::current_tag_. |
1744 __ movl(EAX, current_tag_addr); | 1743 __ movl(EAX, current_tag_addr); |
1745 __ ret(); | 1744 __ ret(); |
1746 } | 1745 } |
1747 | 1746 |
1748 #undef __ | 1747 #undef __ |
1749 } // namespace dart | 1748 } // namespace dart |
1750 | 1749 |
1751 #endif // defined TARGET_ARCH_IA32 | 1750 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |