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" // 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 3452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3463 : ClassHeapStats::allocated_since_gc_old_space_offset(); | 3463 : ClassHeapStats::allocated_since_gc_old_space_offset(); |
3464 const uword size_field_offset = (space == Heap::kNew) | 3464 const uword size_field_offset = (space == Heap::kNew) |
3465 ? ClassHeapStats::allocated_size_since_gc_new_space_offset() | 3465 ? ClassHeapStats::allocated_size_since_gc_new_space_offset() |
3466 : ClassHeapStats::allocated_size_since_gc_old_space_offset(); | 3466 : ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
3467 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); | 3467 movq(temp_reg, Immediate(class_heap_stats_table_address + class_offset)); |
3468 *count_address = Address(temp_reg, count_field_offset); | 3468 *count_address = Address(temp_reg, count_field_offset); |
3469 *size_address = Address(temp_reg, size_field_offset); | 3469 *size_address = Address(temp_reg, size_field_offset); |
3470 } | 3470 } |
3471 | 3471 |
3472 | 3472 |
| 3473 void Assembler::ComputeHeapStatsStateAddressForCid(intptr_t cid, |
| 3474 Address* state_address) { |
| 3475 ASSERT(cid < kNumPredefinedCids); |
| 3476 Register temp_reg = TMP; |
| 3477 Isolate* isolate = Isolate::Current(); |
| 3478 ClassTable* class_table = isolate->class_table(); |
| 3479 const uword class_heap_stats_table_address = |
| 3480 class_table->PredefinedClassHeapStatsTableAddress(); |
| 3481 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 3482 const uword state_offset = ClassHeapStats::state_offset(); |
| 3483 movq(temp_reg, Immediate(class_heap_stats_table_address + |
| 3484 class_offset + |
| 3485 state_offset)); |
| 3486 *state_address = Address(temp_reg, 0); |
| 3487 } |
| 3488 |
| 3489 |
| 3490 void Assembler::MaybeTraceAllocation(intptr_t cid, |
| 3491 Label* trace, |
| 3492 bool near_jump) { |
| 3493 ASSERT(cid > 0); |
| 3494 Address state_address(kNoRegister, 0); |
| 3495 if (cid < kNumPredefinedCids) { |
| 3496 ComputeHeapStatsStateAddressForCid(cid, &state_address); |
| 3497 } else { |
| 3498 Register temp_reg = TMP; |
| 3499 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 3500 const uword state_offset = ClassHeapStats::state_offset(); |
| 3501 // temp_reg gets address of class table pointer. |
| 3502 ClassTable* class_table = Isolate::Current()->class_table(); |
| 3503 movq(temp_reg, Immediate(class_table->ClassStatsTableAddress())); |
| 3504 state_address = Address(temp_reg, class_offset + state_offset); |
| 3505 } |
| 3506 testb(state_address, Immediate(ClassHeapStats::TraceAllocationMask())); |
| 3507 // We are tracing for this class, jump to the trace label which will use |
| 3508 // the allocation stub. |
| 3509 j(NOT_ZERO, trace, near_jump); |
| 3510 } |
| 3511 |
| 3512 |
3473 void Assembler::UpdateAllocationStats(intptr_t cid, | 3513 void Assembler::UpdateAllocationStats(intptr_t cid, |
3474 Heap::Space space) { | 3514 Heap::Space space) { |
3475 ASSERT(cid > 0); | 3515 ASSERT(cid > 0); |
3476 if (cid < kNumPredefinedCids) { | 3516 if (cid < kNumPredefinedCids) { |
3477 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0); | 3517 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0); |
3478 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address); | 3518 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address); |
3479 incq(count_address); | 3519 incq(count_address); |
3480 } else { | 3520 } else { |
3481 Register temp_reg = TMP; | 3521 Register temp_reg = TMP; |
3482 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT | 3522 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3515 } | 3555 } |
3516 | 3556 |
3517 | 3557 |
3518 void Assembler::TryAllocate(const Class& cls, | 3558 void Assembler::TryAllocate(const Class& cls, |
3519 Label* failure, | 3559 Label* failure, |
3520 bool near_jump, | 3560 bool near_jump, |
3521 Register instance_reg, | 3561 Register instance_reg, |
3522 Register pp) { | 3562 Register pp) { |
3523 ASSERT(failure != NULL); | 3563 ASSERT(failure != NULL); |
3524 if (FLAG_inline_alloc) { | 3564 if (FLAG_inline_alloc) { |
| 3565 // If this allocation is traced, program will jump to failure path |
| 3566 // (i.e. the allocation stub) which will allocate the object and trace the |
| 3567 // allocation call site. |
| 3568 MaybeTraceAllocation(cls.id(), failure, near_jump); |
3525 Heap* heap = Isolate::Current()->heap(); | 3569 Heap* heap = Isolate::Current()->heap(); |
3526 const intptr_t instance_size = cls.instance_size(); | 3570 const intptr_t instance_size = cls.instance_size(); |
3527 Heap::Space space = heap->SpaceForAllocation(cls.id()); | 3571 Heap::Space space = heap->SpaceForAllocation(cls.id()); |
3528 LoadImmediate(TMP, Immediate(heap->TopAddress(space)), pp); | 3572 LoadImmediate(TMP, Immediate(heap->TopAddress(space)), pp); |
3529 movq(instance_reg, Address(TMP, 0)); | 3573 movq(instance_reg, Address(TMP, 0)); |
3530 AddImmediate(instance_reg, Immediate(instance_size), pp); | 3574 AddImmediate(instance_reg, Immediate(instance_size), pp); |
3531 // instance_reg: potential next object start. | 3575 // instance_reg: potential next object start. |
3532 LoadImmediate(TMP, Immediate(heap->EndAddress(space)), pp); | 3576 LoadImmediate(TMP, Immediate(heap->EndAddress(space)), pp); |
3533 cmpq(instance_reg, Address(TMP, 0)); | 3577 cmpq(instance_reg, Address(TMP, 0)); |
3534 j(ABOVE_EQUAL, failure, near_jump); | 3578 j(ABOVE_EQUAL, failure, near_jump); |
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3919 | 3963 |
3920 | 3964 |
3921 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 3965 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
3922 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 3966 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
3923 return xmm_reg_names[reg]; | 3967 return xmm_reg_names[reg]; |
3924 } | 3968 } |
3925 | 3969 |
3926 } // namespace dart | 3970 } // namespace dart |
3927 | 3971 |
3928 #endif // defined TARGET_ARCH_X64 | 3972 #endif // defined TARGET_ARCH_X64 |
OLD | NEW |