| 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" | 5 #include "vm/globals.h" |
| 6 #if defined(TARGET_ARCH_IA32) | 6 #if defined(TARGET_ARCH_IA32) |
| 7 | 7 |
| 8 #include "vm/assembler.h" | 8 #include "vm/assembler.h" |
| 9 #include "vm/code_generator.h" | 9 #include "vm/code_generator.h" |
| 10 #include "vm/cpu.h" | 10 #include "vm/cpu.h" |
| (...skipping 2484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2495 | 2495 |
| 2496 void Assembler::TryAllocate(const Class& cls, | 2496 void Assembler::TryAllocate(const Class& cls, |
| 2497 Label* failure, | 2497 Label* failure, |
| 2498 bool near_jump, | 2498 bool near_jump, |
| 2499 Register instance_reg, | 2499 Register instance_reg, |
| 2500 Register temp_reg) { | 2500 Register temp_reg) { |
| 2501 ASSERT(failure != NULL); | 2501 ASSERT(failure != NULL); |
| 2502 if (FLAG_inline_alloc) { | 2502 if (FLAG_inline_alloc) { |
| 2503 Heap* heap = Isolate::Current()->heap(); | 2503 Heap* heap = Isolate::Current()->heap(); |
| 2504 const intptr_t instance_size = cls.instance_size(); | 2504 const intptr_t instance_size = cls.instance_size(); |
| 2505 movl(instance_reg, Address::Absolute(heap->TopAddress())); | 2505 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
| 2506 movl(instance_reg, Address::Absolute(heap->TopAddress(space))); |
| 2506 addl(instance_reg, Immediate(instance_size)); | 2507 addl(instance_reg, Immediate(instance_size)); |
| 2507 // instance_reg: potential next object start. | 2508 // instance_reg: potential next object start. |
| 2508 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); | 2509 cmpl(instance_reg, Address::Absolute(heap->EndAddress(space))); |
| 2509 j(ABOVE_EQUAL, failure, near_jump); | 2510 j(ABOVE_EQUAL, failure, near_jump); |
| 2510 // Successfully allocated the object, now update top to point to | 2511 // Successfully allocated the object, now update top to point to |
| 2511 // next object start and store the class in the class field of object. | 2512 // next object start and store the class in the class field of object. |
| 2512 movl(Address::Absolute(heap->TopAddress()), instance_reg); | 2513 movl(Address::Absolute(heap->TopAddress(space)), instance_reg); |
| 2513 UpdateAllocationStats(cls.id(), temp_reg); | 2514 UpdateAllocationStats(cls.id(), temp_reg, space); |
| 2514 ASSERT(instance_size >= kHeapObjectTag); | 2515 ASSERT(instance_size >= kHeapObjectTag); |
| 2515 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 2516 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
| 2516 uword tags = 0; | 2517 uword tags = 0; |
| 2517 tags = RawObject::SizeTag::update(instance_size, tags); | 2518 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2518 ASSERT(cls.id() != kIllegalCid); | 2519 ASSERT(cls.id() != kIllegalCid); |
| 2519 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2520 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 2520 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 2521 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
| 2521 } else { | 2522 } else { |
| 2522 jmp(failure); | 2523 jmp(failure); |
| 2523 } | 2524 } |
| 2524 } | 2525 } |
| 2525 | 2526 |
| 2526 | 2527 |
| 2527 void Assembler::TryAllocateArray(intptr_t cid, | 2528 void Assembler::TryAllocateArray(intptr_t cid, |
| 2528 intptr_t instance_size, | 2529 intptr_t instance_size, |
| 2529 Label* failure, | 2530 Label* failure, |
| 2530 bool near_jump, | 2531 bool near_jump, |
| 2531 Register instance, | 2532 Register instance, |
| 2532 Register end_address) { | 2533 Register end_address) { |
| 2533 ASSERT(failure != NULL); | 2534 ASSERT(failure != NULL); |
| 2534 if (FLAG_inline_alloc) { | 2535 if (FLAG_inline_alloc) { |
| 2535 Isolate* isolate = Isolate::Current(); | 2536 Isolate* isolate = Isolate::Current(); |
| 2536 Heap* heap = isolate->heap(); | 2537 Heap* heap = isolate->heap(); |
| 2537 movl(instance, Address::Absolute(heap->TopAddress())); | 2538 Heap::Space space = heap->SpaceForAllocation(cid); |
| 2539 movl(instance, Address::Absolute(heap->TopAddress(space))); |
| 2538 movl(end_address, instance); | 2540 movl(end_address, instance); |
| 2539 | 2541 |
| 2540 addl(end_address, Immediate(instance_size)); | 2542 addl(end_address, Immediate(instance_size)); |
| 2541 j(CARRY, failure); | 2543 j(CARRY, failure); |
| 2542 | 2544 |
| 2543 // Check if the allocation fits into the remaining space. | 2545 // Check if the allocation fits into the remaining space. |
| 2544 // EAX: potential new object start. | 2546 // EAX: potential new object start. |
| 2545 // EBX: potential next object start. | 2547 // EBX: potential next object start. |
| 2546 cmpl(end_address, Address::Absolute(heap->EndAddress())); | 2548 cmpl(end_address, Address::Absolute(heap->EndAddress(space))); |
| 2547 j(ABOVE_EQUAL, failure); | 2549 j(ABOVE_EQUAL, failure); |
| 2548 | 2550 |
| 2549 // Successfully allocated the object(s), now update top to point to | 2551 // Successfully allocated the object(s), now update top to point to |
| 2550 // next object start and initialize the object. | 2552 // next object start and initialize the object. |
| 2551 movl(Address::Absolute(heap->TopAddress()), end_address); | 2553 movl(Address::Absolute(heap->TopAddress(space)), end_address); |
| 2552 addl(instance, Immediate(kHeapObjectTag)); | 2554 addl(instance, Immediate(kHeapObjectTag)); |
| 2553 UpdateAllocationStatsWithSize(cid, instance_size, kNoRegister); | 2555 UpdateAllocationStatsWithSize(cid, instance_size, kNoRegister, space); |
| 2554 | 2556 |
| 2555 // Initialize the tags. | 2557 // Initialize the tags. |
| 2556 uword tags = 0; | 2558 uword tags = 0; |
| 2557 tags = RawObject::ClassIdTag::update(cid, tags); | 2559 tags = RawObject::ClassIdTag::update(cid, tags); |
| 2558 tags = RawObject::SizeTag::update(instance_size, tags); | 2560 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2559 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); | 2561 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); |
| 2560 } else { | 2562 } else { |
| 2561 jmp(failure); | 2563 jmp(failure); |
| 2562 } | 2564 } |
| 2563 } | 2565 } |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2869 | 2871 |
| 2870 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2872 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 2871 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2873 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 2872 return xmm_reg_names[reg]; | 2874 return xmm_reg_names[reg]; |
| 2873 } | 2875 } |
| 2874 | 2876 |
| 2875 | 2877 |
| 2876 } // namespace dart | 2878 } // namespace dart |
| 2877 | 2879 |
| 2878 #endif // defined TARGET_ARCH_IA32 | 2880 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |