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

Side by Side Diff: runtime/vm/assembler_arm.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
« no previous file with comments | « no previous file | runtime/vm/assembler_arm64.cc » ('j') | runtime/vm/isolate.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_ARM) 6 #if defined(TARGET_ARCH_ARM)
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/longjump.h" 10 #include "vm/longjump.h"
(...skipping 3435 matching lines...) Expand 10 before | Expand all | Expand 10 after
3446 Register temp_reg) { 3446 Register temp_reg) {
3447 ASSERT(failure != NULL); 3447 ASSERT(failure != NULL);
3448 if (FLAG_inline_alloc) { 3448 if (FLAG_inline_alloc) {
3449 ASSERT(instance_reg != temp_reg); 3449 ASSERT(instance_reg != temp_reg);
3450 ASSERT(temp_reg != IP); 3450 ASSERT(temp_reg != IP);
3451 const intptr_t instance_size = cls.instance_size(); 3451 const intptr_t instance_size = cls.instance_size();
3452 ASSERT(instance_size != 0); 3452 ASSERT(instance_size != 0);
3453 // If this allocation is traced, program will jump to failure path 3453 // If this allocation is traced, program will jump to failure path
3454 // (i.e. the allocation stub) which will allocate the object and trace the 3454 // (i.e. the allocation stub) which will allocate the object and trace the
3455 // allocation call site. 3455 // allocation call site.
3456 MaybeTraceAllocation(cls.id(), temp_reg, failure); 3456 MaybeTraceAllocation(cls.id(), temp_reg, failure,
3457 Heap* heap = Isolate::Current()->heap(); 3457 /* inline_isolate = */ false);
3458 Heap::Space space = heap->SpaceForAllocation(cls.id()); 3458 Heap::Space space = Heap::SpaceForAllocation(cls.id());
3459 const uword top_address = heap->TopAddress(space); 3459 ldr(temp_reg, Address(THR, Thread::heap_offset()));
3460 LoadImmediate(temp_reg, top_address); 3460 ldr(instance_reg, Address(temp_reg, Heap::TopOffset(space)));
3461 ldr(instance_reg, Address(temp_reg));
3462 // TODO(koda): Protect against unsigned overflow here. 3461 // TODO(koda): Protect against unsigned overflow here.
3463 AddImmediateSetFlags(instance_reg, instance_reg, instance_size); 3462 AddImmediateSetFlags(instance_reg, instance_reg, instance_size);
3464 3463
3465 // instance_reg: potential next object start. 3464 // instance_reg: potential next object start.
3466 const uword end_address = heap->EndAddress(space); 3465 ldr(IP, Address(temp_reg, Heap::EndOffset(space)));
3467 ASSERT(top_address < end_address);
3468 // Could use ldm to load (top, end), but no benefit seen experimentally.
3469 ldr(IP, Address(temp_reg, end_address - top_address));
3470 cmp(IP, Operand(instance_reg)); 3466 cmp(IP, Operand(instance_reg));
3471 // fail if heap end unsigned less than or equal to instance_reg. 3467 // fail if heap end unsigned less than or equal to instance_reg.
3472 b(failure, LS); 3468 b(failure, LS);
3473 3469
3474 // Successfully allocated the object, now update top to point to 3470 // Successfully allocated the object, now update top to point to
3475 // next object start and store the class in the class field of object. 3471 // next object start and store the class in the class field of object.
3476 str(instance_reg, Address(temp_reg)); 3472 str(instance_reg, Address(temp_reg, Heap::TopOffset(space)));
3477 3473
3478 LoadAllocationStatsAddress(temp_reg, cls.id()); 3474 LoadAllocationStatsAddress(temp_reg, cls.id(),
3475 /* inline_isolate = */ false);
3479 3476
3480 ASSERT(instance_size >= kHeapObjectTag); 3477 ASSERT(instance_size >= kHeapObjectTag);
3481 AddImmediate(instance_reg, -instance_size + kHeapObjectTag); 3478 AddImmediate(instance_reg, -instance_size + kHeapObjectTag);
3482 3479
3483 uword tags = 0; 3480 uword tags = 0;
3484 tags = RawObject::SizeTag::update(instance_size, tags); 3481 tags = RawObject::SizeTag::update(instance_size, tags);
3485 ASSERT(cls.id() != kIllegalCid); 3482 ASSERT(cls.id() != kIllegalCid);
3486 tags = RawObject::ClassIdTag::update(cls.id(), tags); 3483 tags = RawObject::ClassIdTag::update(cls.id(), tags);
3487 LoadImmediate(IP, tags); 3484 LoadImmediate(IP, tags);
3488 str(IP, FieldAddress(instance_reg, Object::tags_offset())); 3485 str(IP, FieldAddress(instance_reg, Object::tags_offset()));
3489 3486
3490 IncrementAllocationStats(temp_reg, cls.id(), space); 3487 IncrementAllocationStats(temp_reg, cls.id(), space);
3491 } else { 3488 } else {
3492 b(failure); 3489 b(failure);
3493 } 3490 }
3494 } 3491 }
3495 3492
3496 3493
3497 void Assembler::TryAllocateArray(intptr_t cid, 3494 void Assembler::TryAllocateArray(intptr_t cid,
3498 intptr_t instance_size, 3495 intptr_t instance_size,
3499 Label* failure, 3496 Label* failure,
3500 Register instance, 3497 Register instance,
3501 Register end_address, 3498 Register end_address,
3502 Register temp1, 3499 Register temp1,
3503 Register temp2) { 3500 Register temp2) {
3504 if (FLAG_inline_alloc) { 3501 if (FLAG_inline_alloc) {
3505 // If this allocation is traced, program will jump to failure path 3502 // If this allocation is traced, program will jump to failure path
3506 // (i.e. the allocation stub) which will allocate the object and trace the 3503 // (i.e. the allocation stub) which will allocate the object and trace the
3507 // allocation call site. 3504 // allocation call site.
3508 MaybeTraceAllocation(cid, temp1, failure); 3505 MaybeTraceAllocation(cid, temp1, failure, /* inline_isolate = */ false);
3509 Isolate* isolate = Isolate::Current(); 3506 Heap::Space space = Heap::SpaceForAllocation(cid);
3510 Heap* heap = isolate->heap(); 3507 ldr(temp1, Address(THR, Thread::heap_offset()));
3511 Heap::Space space = heap->SpaceForAllocation(cid); 3508 // Potential new object start.
3512 LoadImmediate(temp1, heap->TopAddress(space)); 3509 ldr(instance, Address(temp1, Heap::TopOffset(space)));
3513 ldr(instance, Address(temp1, 0)); // Potential new object start.
3514 AddImmediateSetFlags(end_address, instance, instance_size); 3510 AddImmediateSetFlags(end_address, instance, instance_size);
3515 b(failure, CS); // Branch if unsigned overflow. 3511 b(failure, CS); // Branch if unsigned overflow.
3516 3512
3517 // Check if the allocation fits into the remaining space. 3513 // Check if the allocation fits into the remaining space.
3518 // instance: potential new object start. 3514 // instance: potential new object start.
3519 // end_address: potential next object start. 3515 // end_address: potential next object start.
3520 LoadImmediate(temp2, heap->EndAddress(space)); 3516 ldr(temp2, Address(temp1, Heap::EndOffset(space)));
3521 ldr(temp2, Address(temp2, 0));
3522 cmp(end_address, Operand(temp2)); 3517 cmp(end_address, Operand(temp2));
3523 b(failure, CS); 3518 b(failure, CS);
3524 3519
3525 LoadAllocationStatsAddress(temp2, cid); 3520 LoadAllocationStatsAddress(temp2, cid, /* inline_isolate = */ false);
3526 3521
3527 // Successfully allocated the object(s), now update top to point to 3522 // Successfully allocated the object(s), now update top to point to
3528 // next object start and initialize the object. 3523 // next object start and initialize the object.
3529 str(end_address, Address(temp1, 0)); 3524 str(end_address, Address(temp1, Heap::TopOffset(space)));
3530 add(instance, instance, Operand(kHeapObjectTag)); 3525 add(instance, instance, Operand(kHeapObjectTag));
3531 3526
3532 // Initialize the tags. 3527 // Initialize the tags.
3533 // instance: new object start as a tagged pointer. 3528 // instance: new object start as a tagged pointer.
3534 uword tags = 0; 3529 uword tags = 0;
3535 tags = RawObject::ClassIdTag::update(cid, tags); 3530 tags = RawObject::ClassIdTag::update(cid, tags);
3536 tags = RawObject::SizeTag::update(instance_size, tags); 3531 tags = RawObject::SizeTag::update(instance_size, tags);
3537 LoadImmediate(temp1, tags); 3532 LoadImmediate(temp1, tags);
3538 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. 3533 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags.
3539 3534
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
3652 3647
3653 3648
3654 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3649 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3655 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); 3650 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters));
3656 return fpu_reg_names[reg]; 3651 return fpu_reg_names[reg];
3657 } 3652 }
3658 3653
3659 } // namespace dart 3654 } // namespace dart
3660 3655
3661 #endif // defined TARGET_ARCH_ARM 3656 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/assembler_arm64.cc » ('j') | runtime/vm/isolate.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698