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

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

Issue 1911253002: Never include_isolate or allow_embedded_addresses. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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 | « runtime/vm/assembler_x64.h ('k') | runtime/vm/flag_list.h » ('j') | no next file with comments »
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_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 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
2796 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 2796 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
2797 if (Thread::CanLoadFromThread(object)) { 2797 if (Thread::CanLoadFromThread(object)) {
2798 movq(dst, Address(THR, Thread::OffsetFromThread(object))); 2798 movq(dst, Address(THR, Thread::OffsetFromThread(object)));
2799 } else if (CanLoadFromObjectPool(object)) { 2799 } else if (CanLoadFromObjectPool(object)) {
2800 const intptr_t idx = 2800 const intptr_t idx =
2801 is_unique ? object_pool_wrapper_.AddObject(object) 2801 is_unique ? object_pool_wrapper_.AddObject(object)
2802 : object_pool_wrapper_.FindObject(object); 2802 : object_pool_wrapper_.FindObject(object);
2803 const int32_t offset = ObjectPool::element_offset(idx); 2803 const int32_t offset = ObjectPool::element_offset(idx);
2804 LoadWordFromPoolOffset(dst, offset - kHeapObjectTag); 2804 LoadWordFromPoolOffset(dst, offset - kHeapObjectTag);
2805 } else { 2805 } else {
2806 ASSERT(object.IsSmi() || object.InVMHeap()); 2806 ASSERT(object.IsSmi());
2807 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses);
2808 LoadImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw()))); 2807 LoadImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw())));
2809 } 2808 }
2810 } 2809 }
2811 2810
2812 2811
2813 void Assembler::LoadFunctionFromCalleePool(Register dst, 2812 void Assembler::LoadFunctionFromCalleePool(Register dst,
2814 const Function& function, 2813 const Function& function,
2815 Register new_pp) { 2814 Register new_pp) {
2816 ASSERT(!constant_pool_allowed()); 2815 ASSERT(!constant_pool_allowed());
2817 ASSERT(new_pp != PP); 2816 ASSERT(new_pp != PP);
(...skipping 16 matching lines...) Expand all
2834 void Assembler::StoreObject(const Address& dst, const Object& object) { 2833 void Assembler::StoreObject(const Address& dst, const Object& object) {
2835 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); 2834 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal());
2836 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 2835 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
2837 if (Thread::CanLoadFromThread(object)) { 2836 if (Thread::CanLoadFromThread(object)) {
2838 movq(TMP, Address(THR, Thread::OffsetFromThread(object))); 2837 movq(TMP, Address(THR, Thread::OffsetFromThread(object)));
2839 movq(dst, TMP); 2838 movq(dst, TMP);
2840 } else if (CanLoadFromObjectPool(object)) { 2839 } else if (CanLoadFromObjectPool(object)) {
2841 LoadObject(TMP, object); 2840 LoadObject(TMP, object);
2842 movq(dst, TMP); 2841 movq(dst, TMP);
2843 } else { 2842 } else {
2844 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); 2843 ASSERT(object.IsSmi());
2845 MoveImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw()))); 2844 MoveImmediate(dst, Immediate(reinterpret_cast<int64_t>(object.raw())));
2846 } 2845 }
2847 } 2846 }
2848 2847
2849 2848
2850 void Assembler::PushObject(const Object& object) { 2849 void Assembler::PushObject(const Object& object) {
2851 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); 2850 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal());
2852 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 2851 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
2853 if (Thread::CanLoadFromThread(object)) { 2852 if (Thread::CanLoadFromThread(object)) {
2854 pushq(Address(THR, Thread::OffsetFromThread(object))); 2853 pushq(Address(THR, Thread::OffsetFromThread(object)));
2855 } else if (CanLoadFromObjectPool(object)) { 2854 } else if (CanLoadFromObjectPool(object)) {
2856 LoadObject(TMP, object); 2855 LoadObject(TMP, object);
2857 pushq(TMP); 2856 pushq(TMP);
2858 } else { 2857 } else {
2859 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); 2858 ASSERT(object.IsSmi());
2860 PushImmediate(Immediate(reinterpret_cast<int64_t>(object.raw()))); 2859 PushImmediate(Immediate(reinterpret_cast<int64_t>(object.raw())));
2861 } 2860 }
2862 } 2861 }
2863 2862
2864 2863
2865 void Assembler::CompareObject(Register reg, const Object& object) { 2864 void Assembler::CompareObject(Register reg, const Object& object) {
2866 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal()); 2865 ASSERT(!object.IsICData() || ICData::Cast(object).IsOriginal());
2867 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal()); 2866 ASSERT(!object.IsField() || Field::Cast(object).IsOriginal());
2868 if (Thread::CanLoadFromThread(object)) { 2867 if (Thread::CanLoadFromThread(object)) {
2869 cmpq(reg, Address(THR, Thread::OffsetFromThread(object))); 2868 cmpq(reg, Address(THR, Thread::OffsetFromThread(object)));
2870 } else if (CanLoadFromObjectPool(object)) { 2869 } else if (CanLoadFromObjectPool(object)) {
2871 const intptr_t idx = object_pool_wrapper_.FindObject(object, kNotPatchable); 2870 const intptr_t idx = object_pool_wrapper_.FindObject(object, kNotPatchable);
2872 const int32_t offset = ObjectPool::element_offset(idx); 2871 const int32_t offset = ObjectPool::element_offset(idx);
2873 cmpq(reg, Address(PP, offset-kHeapObjectTag)); 2872 cmpq(reg, Address(PP, offset-kHeapObjectTag));
2874 } else { 2873 } else {
2875 ASSERT(object.IsSmi() || FLAG_allow_absolute_addresses); 2874 ASSERT(object.IsSmi());
2876 CompareImmediate( 2875 CompareImmediate(
2877 reg, Immediate(reinterpret_cast<int64_t>(object.raw()))); 2876 reg, Immediate(reinterpret_cast<int64_t>(object.raw())));
2878 } 2877 }
2879 } 2878 }
2880 2879
2881 2880
2882 intptr_t Assembler::FindImmediate(int64_t imm) { 2881 intptr_t Assembler::FindImmediate(int64_t imm) {
2883 return object_pool_wrapper_.FindImmediate(imm); 2882 return object_pool_wrapper_.FindImmediate(imm);
2884 } 2883 }
2885 2884
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
3451 } 3450 }
3452 3451
3453 3452
3454 void Assembler::LeaveStubFrame() { 3453 void Assembler::LeaveStubFrame() {
3455 LeaveDartFrame(); 3454 LeaveDartFrame();
3456 } 3455 }
3457 3456
3458 3457
3459 void Assembler::MaybeTraceAllocation(intptr_t cid, 3458 void Assembler::MaybeTraceAllocation(intptr_t cid,
3460 Label* trace, 3459 Label* trace,
3461 bool near_jump, 3460 bool near_jump) {
3462 bool inline_isolate) {
3463 ASSERT(cid > 0); 3461 ASSERT(cid > 0);
3464 intptr_t state_offset = ClassTable::StateOffsetFor(cid); 3462 intptr_t state_offset = ClassTable::StateOffsetFor(cid);
3465 Register temp_reg = TMP; 3463 Register temp_reg = TMP;
3466 if (inline_isolate) { 3464 LoadIsolate(temp_reg);
3467 ASSERT(FLAG_allow_absolute_addresses); 3465 intptr_t table_offset =
3468 ClassTable* class_table = Isolate::Current()->class_table(); 3466 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
3469 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid); 3467 movq(temp_reg, Address(temp_reg, table_offset));
3470 if (cid < kNumPredefinedCids) {
3471 movq(temp_reg, Immediate(reinterpret_cast<uword>(*table_ptr)));
3472 } else {
3473 movq(temp_reg, Immediate(reinterpret_cast<uword>(table_ptr)));
3474 movq(temp_reg, Address(temp_reg, 0));
3475 }
3476 } else {
3477 LoadIsolate(temp_reg);
3478 intptr_t table_offset =
3479 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
3480 movq(temp_reg, Address(temp_reg, table_offset));
3481 }
3482 testb(Address(temp_reg, state_offset), 3468 testb(Address(temp_reg, state_offset),
3483 Immediate(ClassHeapStats::TraceAllocationMask())); 3469 Immediate(ClassHeapStats::TraceAllocationMask()));
3484 // We are tracing for this class, jump to the trace label which will use 3470 // We are tracing for this class, jump to the trace label which will use
3485 // the allocation stub. 3471 // the allocation stub.
3486 j(NOT_ZERO, trace, near_jump); 3472 j(NOT_ZERO, trace, near_jump);
3487 } 3473 }
3488 3474
3489 3475
3490 void Assembler::UpdateAllocationStats(intptr_t cid, 3476 void Assembler::UpdateAllocationStats(intptr_t cid,
3491 Heap::Space space, 3477 Heap::Space space) {
3492 bool inline_isolate) {
3493 ASSERT(cid > 0); 3478 ASSERT(cid > 0);
3494 intptr_t counter_offset = 3479 intptr_t counter_offset =
3495 ClassTable::CounterOffsetFor(cid, space == Heap::kNew); 3480 ClassTable::CounterOffsetFor(cid, space == Heap::kNew);
3496 Register temp_reg = TMP; 3481 Register temp_reg = TMP;
3497 if (inline_isolate) { 3482 LoadIsolate(temp_reg);
3498 ASSERT(FLAG_allow_absolute_addresses); 3483 intptr_t table_offset =
3499 ClassTable* class_table = Isolate::Current()->class_table(); 3484 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
3500 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid); 3485 movq(temp_reg, Address(temp_reg, table_offset));
3501 if (cid < kNumPredefinedCids) {
3502 movq(temp_reg, Immediate(reinterpret_cast<uword>(*table_ptr)));
3503 } else {
3504 movq(temp_reg, Immediate(reinterpret_cast<uword>(table_ptr)));
3505 movq(temp_reg, Address(temp_reg, 0));
3506 }
3507 } else {
3508 LoadIsolate(temp_reg);
3509 intptr_t table_offset =
3510 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
3511 movq(temp_reg, Address(temp_reg, table_offset));
3512 }
3513 incq(Address(temp_reg, counter_offset)); 3486 incq(Address(temp_reg, counter_offset));
3514 } 3487 }
3515 3488
3516 3489
3517 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 3490 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
3518 Register size_reg, 3491 Register size_reg,
3519 Heap::Space space, 3492 Heap::Space space) {
3520 bool inline_isolate) {
3521 ASSERT(cid > 0); 3493 ASSERT(cid > 0);
3522 ASSERT(cid < kNumPredefinedCids); 3494 ASSERT(cid < kNumPredefinedCids);
3523 UpdateAllocationStats(cid, space, inline_isolate); 3495 UpdateAllocationStats(cid, space);
3524 Register temp_reg = TMP; 3496 Register temp_reg = TMP;
3525 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew); 3497 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew);
3526 addq(Address(temp_reg, size_offset), size_reg); 3498 addq(Address(temp_reg, size_offset), size_reg);
3527 } 3499 }
3528 3500
3529 3501
3530 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 3502 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
3531 intptr_t size_in_bytes, 3503 intptr_t size_in_bytes,
3532 Heap::Space space, 3504 Heap::Space space) {
3533 bool inline_isolate) {
3534 ASSERT(cid > 0); 3505 ASSERT(cid > 0);
3535 ASSERT(cid < kNumPredefinedCids); 3506 ASSERT(cid < kNumPredefinedCids);
3536 UpdateAllocationStats(cid, space, inline_isolate); 3507 UpdateAllocationStats(cid, space);
3537 Register temp_reg = TMP; 3508 Register temp_reg = TMP;
3538 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew); 3509 intptr_t size_offset = ClassTable::SizeOffsetFor(cid, space == Heap::kNew);
3539 addq(Address(temp_reg, size_offset), Immediate(size_in_bytes)); 3510 addq(Address(temp_reg, size_offset), Immediate(size_in_bytes));
3540 } 3511 }
3541 3512
3542 3513
3543 void Assembler::TryAllocate(const Class& cls, 3514 void Assembler::TryAllocate(const Class& cls,
3544 Label* failure, 3515 Label* failure,
3545 bool near_jump, 3516 bool near_jump,
3546 Register instance_reg, 3517 Register instance_reg,
3547 Register temp) { 3518 Register temp) {
3548 ASSERT(failure != NULL); 3519 ASSERT(failure != NULL);
3549 if (FLAG_inline_alloc) { 3520 if (FLAG_inline_alloc) {
3550 // If this allocation is traced, program will jump to failure path 3521 // If this allocation is traced, program will jump to failure path
3551 // (i.e. the allocation stub) which will allocate the object and trace the 3522 // (i.e. the allocation stub) which will allocate the object and trace the
3552 // allocation call site. 3523 // allocation call site.
3553 MaybeTraceAllocation(cls.id(), failure, near_jump, 3524 MaybeTraceAllocation(cls.id(), failure, near_jump);
3554 /* inline_isolate = */ false);
3555 const intptr_t instance_size = cls.instance_size(); 3525 const intptr_t instance_size = cls.instance_size();
3556 Heap::Space space = Heap::SpaceForAllocation(cls.id()); 3526 Heap::Space space = Heap::SpaceForAllocation(cls.id());
3557 movq(temp, Address(THR, Thread::heap_offset())); 3527 movq(temp, Address(THR, Thread::heap_offset()));
3558 movq(instance_reg, Address(temp, Heap::TopOffset(space))); 3528 movq(instance_reg, Address(temp, Heap::TopOffset(space)));
3559 addq(instance_reg, Immediate(instance_size)); 3529 addq(instance_reg, Immediate(instance_size));
3560 // instance_reg: potential next object start. 3530 // instance_reg: potential next object start.
3561 cmpq(instance_reg, Address(temp, Heap::EndOffset(space))); 3531 cmpq(instance_reg, Address(temp, Heap::EndOffset(space)));
3562 j(ABOVE_EQUAL, failure, near_jump); 3532 j(ABOVE_EQUAL, failure, near_jump);
3563 // Successfully allocated the object, now update top to point to 3533 // Successfully allocated the object, now update top to point to
3564 // next object start and store the class in the class field of object. 3534 // next object start and store the class in the class field of object.
3565 movq(Address(temp, Heap::TopOffset(space)), instance_reg); 3535 movq(Address(temp, Heap::TopOffset(space)), instance_reg);
3566 UpdateAllocationStats(cls.id(), space, /* inline_isolate = */ false); 3536 UpdateAllocationStats(cls.id(), space);
3567 ASSERT(instance_size >= kHeapObjectTag); 3537 ASSERT(instance_size >= kHeapObjectTag);
3568 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size)); 3538 AddImmediate(instance_reg, Immediate(kHeapObjectTag - instance_size));
3569 uword tags = 0; 3539 uword tags = 0;
3570 tags = RawObject::SizeTag::update(instance_size, tags); 3540 tags = RawObject::SizeTag::update(instance_size, tags);
3571 ASSERT(cls.id() != kIllegalCid); 3541 ASSERT(cls.id() != kIllegalCid);
3572 tags = RawObject::ClassIdTag::update(cls.id(), tags); 3542 tags = RawObject::ClassIdTag::update(cls.id(), tags);
3573 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()), 3543 MoveImmediate(FieldAddress(instance_reg, Object::tags_offset()),
3574 Immediate(tags)); 3544 Immediate(tags));
3575 } else { 3545 } else {
3576 jmp(failure); 3546 jmp(failure);
3577 } 3547 }
3578 } 3548 }
3579 3549
3580 3550
3581 void Assembler::TryAllocateArray(intptr_t cid, 3551 void Assembler::TryAllocateArray(intptr_t cid,
3582 intptr_t instance_size, 3552 intptr_t instance_size,
3583 Label* failure, 3553 Label* failure,
3584 bool near_jump, 3554 bool near_jump,
3585 Register instance, 3555 Register instance,
3586 Register end_address, 3556 Register end_address,
3587 Register temp) { 3557 Register temp) {
3588 ASSERT(failure != NULL); 3558 ASSERT(failure != NULL);
3589 if (FLAG_inline_alloc) { 3559 if (FLAG_inline_alloc) {
3590 // If this allocation is traced, program will jump to failure path 3560 // If this allocation is traced, program will jump to failure path
3591 // (i.e. the allocation stub) which will allocate the object and trace the 3561 // (i.e. the allocation stub) which will allocate the object and trace the
3592 // allocation call site. 3562 // allocation call site.
3593 MaybeTraceAllocation(cid, failure, near_jump, /* inline_isolate = */ false); 3563 MaybeTraceAllocation(cid, failure, near_jump);
3594 Heap::Space space = Heap::SpaceForAllocation(cid); 3564 Heap::Space space = Heap::SpaceForAllocation(cid);
3595 movq(temp, Address(THR, Thread::heap_offset())); 3565 movq(temp, Address(THR, Thread::heap_offset()));
3596 movq(instance, Address(temp, Heap::TopOffset(space))); 3566 movq(instance, Address(temp, Heap::TopOffset(space)));
3597 movq(end_address, instance); 3567 movq(end_address, instance);
3598 3568
3599 addq(end_address, Immediate(instance_size)); 3569 addq(end_address, Immediate(instance_size));
3600 j(CARRY, failure); 3570 j(CARRY, failure);
3601 3571
3602 // Check if the allocation fits into the remaining space. 3572 // Check if the allocation fits into the remaining space.
3603 // instance: potential new object start. 3573 // instance: potential new object start.
3604 // end_address: potential next object start. 3574 // end_address: potential next object start.
3605 cmpq(end_address, Address(temp, Heap::EndOffset(space))); 3575 cmpq(end_address, Address(temp, Heap::EndOffset(space)));
3606 j(ABOVE_EQUAL, failure); 3576 j(ABOVE_EQUAL, failure);
3607 3577
3608 // Successfully allocated the object(s), now update top to point to 3578 // Successfully allocated the object(s), now update top to point to
3609 // next object start and initialize the object. 3579 // next object start and initialize the object.
3610 movq(Address(temp, Heap::TopOffset(space)), end_address); 3580 movq(Address(temp, Heap::TopOffset(space)), end_address);
3611 addq(instance, Immediate(kHeapObjectTag)); 3581 addq(instance, Immediate(kHeapObjectTag));
3612 UpdateAllocationStatsWithSize(cid, instance_size, space, 3582 UpdateAllocationStatsWithSize(cid, instance_size, space);
3613 /* inline_isolate = */ false);
3614 3583
3615 // Initialize the tags. 3584 // Initialize the tags.
3616 // instance: new object start as a tagged pointer. 3585 // instance: new object start as a tagged pointer.
3617 uword tags = 0; 3586 uword tags = 0;
3618 tags = RawObject::ClassIdTag::update(cid, tags); 3587 tags = RawObject::ClassIdTag::update(cid, tags);
3619 tags = RawObject::SizeTag::update(instance_size, tags); 3588 tags = RawObject::SizeTag::update(instance_size, tags);
3620 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags)); 3589 movq(FieldAddress(instance, Array::tags_offset()), Immediate(tags));
3621 } else { 3590 } else {
3622 jmp(failure); 3591 jmp(failure);
3623 } 3592 }
(...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after
3949 3918
3950 3919
3951 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3920 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3952 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 3921 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
3953 return xmm_reg_names[reg]; 3922 return xmm_reg_names[reg];
3954 } 3923 }
3955 3924
3956 } // namespace dart 3925 } // namespace dart
3957 3926
3958 #endif // defined TARGET_ARCH_X64 3927 #endif // defined TARGET_ARCH_X64
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/flag_list.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698