Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: runtime/vm/assembler_x64.cc

Issue 1263513002: VM: Load allocation-top and -end via Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: fixed cc tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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" // NOLINT 5 #include "vm/globals.h" // NOLINT
6 #if defined(TARGET_ARCH_X64) 6 #if defined(TARGET_ARCH_X64)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h" 9 #include "vm/cpu.h"
10 #include "vm/heap.h" 10 #include "vm/heap.h"
(...skipping 3519 matching lines...) Expand 10 before | Expand all | Expand 10 after
3530 UpdateAllocationStats(cid, space, inline_isolate); 3530 UpdateAllocationStats(cid, space, inline_isolate);
3531 Register temp_reg = TMP; 3531 Register temp_reg = TMP;
3532 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew); 3532 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew);
3533 addq(Address(temp_reg, size_offset), Immediate(size_in_bytes)); 3533 addq(Address(temp_reg, size_offset), Immediate(size_in_bytes));
3534 } 3534 }
3535 3535
3536 3536
3537 void Assembler::TryAllocate(const Class& cls, 3537 void Assembler::TryAllocate(const Class& cls,
3538 Label* failure, 3538 Label* failure,
3539 bool near_jump, 3539 bool near_jump,
3540 Register instance_reg) { 3540 Register instance_reg,
3541 Register temp) {
3541 ASSERT(failure != NULL); 3542 ASSERT(failure != NULL);
3542 if (FLAG_inline_alloc) { 3543 if (FLAG_inline_alloc) {
3543 // If this allocation is traced, program will jump to failure path 3544 // If this allocation is traced, program will jump to failure path
3544 // (i.e. the allocation stub) which will allocate the object and trace the 3545 // (i.e. the allocation stub) which will allocate the object and trace the
3545 // allocation call site. 3546 // allocation call site.
3546 MaybeTraceAllocation(cls.id(), failure, near_jump); 3547 MaybeTraceAllocation(cls.id(), failure, near_jump,
3547 Heap* heap = Isolate::Current()->heap(); 3548 /* inline_isolate = */ false);
3548 const intptr_t instance_size = cls.instance_size(); 3549 const intptr_t instance_size = cls.instance_size();
3549 Heap::Space space = heap->SpaceForAllocation(cls.id()); 3550 Heap::Space space = Heap::SpaceForAllocation(cls.id());
3550 LoadImmediate(TMP, Immediate(heap->TopAddress(space))); 3551 movq(temp, Address(THR, Thread::heap_offset()));
3551 movq(instance_reg, Address(TMP, 0)); 3552 movq(instance_reg, Address(temp, Heap::TopOffset(space)));
3552 AddImmediate(instance_reg, Immediate(instance_size)); 3553 addq(instance_reg, Immediate(instance_size));
3553 // instance_reg: potential next object start. 3554 // instance_reg: potential next object start.
3554 LoadImmediate(TMP, Immediate(heap->EndAddress(space))); 3555 cmpq(instance_reg, Address(temp, Heap::EndOffset(space)));
3555 cmpq(instance_reg, Address(TMP, 0));
3556 j(ABOVE_EQUAL, failure, near_jump); 3556 j(ABOVE_EQUAL, failure, near_jump);
3557 // Successfully allocated the object, now update top to point to 3557 // Successfully allocated the object, now update top to point to
3558 // next object start and store the class in the class field of object. 3558 // next object start and store the class in the class field of object.
3559 LoadImmediate(TMP, Immediate(heap->TopAddress(space))); 3559 movq(Address(temp, Heap::TopOffset(space)), instance_reg);
3560 movq(Address(TMP, 0), instance_reg); 3560 UpdateAllocationStats(cls.id(), space, /* inline_isolate = */ false);
3561 UpdateAllocationStats(cls.id(), space);
3562 ASSERT(instance_size >= kHeapObjectTag); 3561 ASSERT(instance_size >= kHeapObjectTag);
3563 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); 3562 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size));
3564 uword tags = 0; 3563 uword tags = 0;
3565 tags = RawObject::SizeTag::update(instance_size, tags); 3564 tags = RawObject::SizeTag::update(instance_size, tags);
3566 ASSERT(cls.id() != kIllegalCid); 3565 ASSERT(cls.id() != kIllegalCid);
3567 tags = RawObject::ClassIdTag::update(cls.id(), tags); 3566 tags = RawObject::ClassIdTag::update(cls.id(), tags);
3568 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), 3567 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()),
3569 Immediate(tags)); 3568 Immediate(tags));
3570 } else { 3569 } else {
3571 jmp(failure); 3570 jmp(failure);
3572 } 3571 }
3573 } 3572 }
3574 3573
3575 3574
3576 void Assembler::TryAllocateArray(intptr_t cid, 3575 void Assembler::TryAllocateArray(intptr_t cid,
3577 intptr_t instance_size, 3576 intptr_t instance_size,
3578 Label* failure, 3577 Label* failure,
3579 bool near_jump, 3578 bool near_jump,
3580 Register instance, 3579 Register instance,
3581 Register end_address) { 3580 Register end_address,
3581 Register temp) {
3582 ASSERT(failure != NULL); 3582 ASSERT(failure != NULL);
3583 if (FLAG_inline_alloc) { 3583 if (FLAG_inline_alloc) {
3584 // If this allocation is traced, program will jump to failure path 3584 // If this allocation is traced, program will jump to failure path
3585 // (i.e. the allocation stub) which will allocate the object and trace the 3585 // (i.e. the allocation stub) which will allocate the object and trace the
3586 // allocation call site. 3586 // allocation call site.
3587 MaybeTraceAllocation(cid, failure, near_jump); 3587 MaybeTraceAllocation(cid, failure, near_jump, /* inline_isolate = */ false);
3588 Isolate* isolate = Isolate::Current(); 3588 Heap::Space space = Heap::SpaceForAllocation(cid);
3589 Heap* heap = isolate->heap(); 3589 movq(temp, Address(THR, Thread::heap_offset()));
3590 Heap::Space space = heap->SpaceForAllocation(cid); 3590 movq(instance, Address(temp, Heap::TopOffset(space)));
3591 movq(instance, Immediate(heap->TopAddress(space))); 3591 movq(end_address, instance);
3592 movq(instance, Address(instance, 0));
3593 movq(end_address, RAX);
3594 3592
3595 addq(end_address, Immediate(instance_size)); 3593 addq(end_address, Immediate(instance_size));
3596 j(CARRY, failure); 3594 j(CARRY, failure);
3597 3595
3598 // Check if the allocation fits into the remaining space. 3596 // Check if the allocation fits into the remaining space.
3599 // instance: potential new object start. 3597 // instance: potential new object start.
3600 // end_address: potential next object start. 3598 // end_address: potential next object start.
3601 movq(TMP, Immediate(heap->EndAddress(space))); 3599 cmpq(end_address, Address(temp, Heap::EndOffset(space)));
3602 cmpq(end_address, Address(TMP, 0));
3603 j(ABOVE_EQUAL, failure); 3600 j(ABOVE_EQUAL, failure);
3604 3601
3605 // Successfully allocated the object(s), now update top to point to 3602 // Successfully allocated the object(s), now update top to point to
3606 // next object start and initialize the object. 3603 // next object start and initialize the object.
3607 movq(TMP, Immediate(heap->TopAddress(space))); 3604 movq(Address(temp, Heap::TopOffset(space)), end_address);
3608 movq(Address(TMP, 0), end_address);
3609 addq(instance, Immediate(kHeapObjectTag)); 3605 addq(instance, Immediate(kHeapObjectTag));
3610 UpdateAllocationStatsWithSize(cid, instance_size, space); 3606 UpdateAllocationStatsWithSize(cid, instance_size, space,
3607 /* inline_isolate = */ false);
3611 3608
3612 // Initialize the tags. 3609 // Initialize the tags.
3613 // instance: new object start as a tagged pointer. 3610 // instance: new object start as a tagged pointer.
3614 uword tags = 0; 3611 uword tags = 0;
3615 tags = RawObject::ClassIdTag::update(cid, tags); 3612 tags = RawObject::ClassIdTag::update(cid, tags);
3616 tags = RawObject::SizeTag::update(instance_size, tags); 3613 tags = RawObject::SizeTag::update(instance_size, tags);
3617 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); 3614 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags));
3618 } else { 3615 } else {
3619 jmp(failure); 3616 jmp(failure);
3620 } 3617 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3946 3943
3947 3944
3948 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3945 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3949 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3946 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3950 return xmm_reg_names[reg]; 3947 return xmm_reg_names[reg];
3951 } 3948 }
3952 3949
3953 } // namespace dart 3950 } // namespace dart
3954 3951
3955 #endif // defined TARGET_ARCH_X64 3952 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/dart.cc » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698