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

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

Issue 1241863002: VM: Refactor allocation stats code and remove duplicate code. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: addressed comments Created 5 years, 5 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_arm.h ('k') | runtime/vm/assembler_arm64.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_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 3327 matching lines...) Expand 10 before | Expand all | Expand 10 after
3338 3338
3339 3339
3340 void Assembler::LeaveStubFrame() { 3340 void Assembler::LeaveStubFrame() {
3341 LeaveFrame((1 << PP) | (1 << FP) | (1 << LR)); 3341 LeaveFrame((1 << PP) | (1 << FP) | (1 << LR));
3342 // Adjust SP for null PC pushed in EnterStubFrame. 3342 // Adjust SP for null PC pushed in EnterStubFrame.
3343 AddImmediate(SP, kWordSize); 3343 AddImmediate(SP, kWordSize);
3344 } 3344 }
3345 3345
3346 3346
3347 void Assembler::LoadAllocationStatsAddress(Register dest, 3347 void Assembler::LoadAllocationStatsAddress(Register dest,
3348 intptr_t cid) { 3348 intptr_t cid,
3349 bool inline_isolate) {
3349 ASSERT(dest != kNoRegister); 3350 ASSERT(dest != kNoRegister);
3350 ASSERT(dest != TMP); 3351 ASSERT(dest != TMP);
3351 ASSERT(cid > 0); 3352 ASSERT(cid > 0);
3352 Isolate* isolate = Isolate::Current(); 3353 const intptr_t class_offset = ClassTable::ClassOffsetFor(cid);
3353 ClassTable* class_table = isolate->class_table(); 3354 if (inline_isolate) {
3354 if (cid < kNumPredefinedCids) { 3355 ClassTable* class_table = Isolate::Current()->class_table();
3355 const uword class_heap_stats_table_address = 3356 ClassHeapStats** table_ptr = class_table->TableAddressFor(cid);
3356 class_table->PredefinedClassHeapStatsTableAddress(); 3357 if (cid < kNumPredefinedCids) {
3357 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 3358 LoadImmediate(dest, reinterpret_cast<uword>(*table_ptr) + class_offset);
3358 LoadImmediate(dest, class_heap_stats_table_address + class_offset); 3359 } else {
3360 LoadImmediate(dest, reinterpret_cast<uword>(table_ptr));
3361 ldr(dest, Address(dest, 0));
3362 AddImmediate(dest, class_offset);
3363 }
3359 } else { 3364 } else {
3360 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 3365 LoadIsolate(dest);
3361 LoadImmediate(dest, class_table->ClassStatsTableAddress()); 3366 intptr_t table_offset =
3362 ldr(dest, Address(dest, 0)); 3367 Isolate::class_table_offset() + ClassTable::TableOffsetFor(cid);
3368 ldr(dest, Address(dest, table_offset));
3363 AddImmediate(dest, class_offset); 3369 AddImmediate(dest, class_offset);
3364 } 3370 }
3365 } 3371 }
3366 3372
3367 3373
3368 void Assembler::MaybeTraceAllocation(intptr_t cid, 3374 void Assembler::MaybeTraceAllocation(intptr_t cid,
3369 Register temp_reg, 3375 Register temp_reg,
3370 Label* trace) { 3376 Label* trace) {
3371 LoadAllocationStatsAddress(temp_reg, cid); 3377 LoadAllocationStatsAddress(temp_reg, cid);
3372 const uword state_offset = ClassHeapStats::state_offset(); 3378 const uword state_offset = ClassHeapStats::state_offset();
3373 const Address& state_address = Address(temp_reg, state_offset); 3379 ldr(temp_reg, Address(temp_reg, state_offset));
3374 ldr(temp_reg, state_address);
3375 tst(temp_reg, Operand(ClassHeapStats::TraceAllocationMask())); 3380 tst(temp_reg, Operand(ClassHeapStats::TraceAllocationMask()));
3376 b(trace, NE); 3381 b(trace, NE);
3377 } 3382 }
3378 3383
3379 3384
3380 void Assembler::IncrementAllocationStats(Register stats_addr_reg, 3385 void Assembler::IncrementAllocationStats(Register stats_addr_reg,
3381 intptr_t cid, 3386 intptr_t cid,
3382 Heap::Space space) { 3387 Heap::Space space) {
3383 ASSERT(stats_addr_reg != kNoRegister); 3388 ASSERT(stats_addr_reg != kNoRegister);
3384 ASSERT(stats_addr_reg != TMP); 3389 ASSERT(stats_addr_reg != TMP);
3385 ASSERT(cid > 0); 3390 ASSERT(cid > 0);
3386 const uword count_field_offset = (space == Heap::kNew) ? 3391 const uword count_field_offset = (space == Heap::kNew) ?
3387 ClassHeapStats::allocated_since_gc_new_space_offset() : 3392 ClassHeapStats::allocated_since_gc_new_space_offset() :
3388 ClassHeapStats::allocated_since_gc_old_space_offset(); 3393 ClassHeapStats::allocated_since_gc_old_space_offset();
3389 const Address& count_address = Address(stats_addr_reg, count_field_offset); 3394 const Address& count_address = Address(stats_addr_reg, count_field_offset);
3390 ldr(TMP, count_address); 3395 ldr(TMP, count_address);
3391 AddImmediate(TMP, 1); 3396 AddImmediate(TMP, 1);
3392 str(TMP, count_address); 3397 str(TMP, count_address);
3393 } 3398 }
3394 3399
3395 3400
3396 void Assembler::IncrementAllocationStatsWithSize(Register stats_addr_reg, 3401 void Assembler::IncrementAllocationStatsWithSize(Register stats_addr_reg,
3397 Register size_reg, 3402 Register size_reg,
3398 intptr_t cid,
3399 Heap::Space space) { 3403 Heap::Space space) {
3400 ASSERT(stats_addr_reg != kNoRegister); 3404 ASSERT(stats_addr_reg != kNoRegister);
3401 ASSERT(stats_addr_reg != TMP); 3405 ASSERT(stats_addr_reg != TMP);
3402 ASSERT(cid > 0);
3403 const uword count_field_offset = (space == Heap::kNew) ? 3406 const uword count_field_offset = (space == Heap::kNew) ?
3404 ClassHeapStats::allocated_since_gc_new_space_offset() : 3407 ClassHeapStats::allocated_since_gc_new_space_offset() :
3405 ClassHeapStats::allocated_since_gc_old_space_offset(); 3408 ClassHeapStats::allocated_since_gc_old_space_offset();
3406 const uword size_field_offset = (space == Heap::kNew) ? 3409 const uword size_field_offset = (space == Heap::kNew) ?
3407 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 3410 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
3408 ClassHeapStats::allocated_size_since_gc_old_space_offset(); 3411 ClassHeapStats::allocated_size_since_gc_old_space_offset();
3409 const Address& count_address = Address(stats_addr_reg, count_field_offset); 3412 const Address& count_address = Address(stats_addr_reg, count_field_offset);
3410 const Address& size_address = Address(stats_addr_reg, size_field_offset); 3413 const Address& size_address = Address(stats_addr_reg, size_field_offset);
3411 ldr(TMP, count_address); 3414 ldr(TMP, count_address);
3412 AddImmediate(TMP, 1); 3415 AddImmediate(TMP, 1);
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 3511
3509 // Initialize the tags. 3512 // Initialize the tags.
3510 // instance: new object start as a tagged pointer. 3513 // instance: new object start as a tagged pointer.
3511 uword tags = 0; 3514 uword tags = 0;
3512 tags = RawObject::ClassIdTag::update(cid, tags); 3515 tags = RawObject::ClassIdTag::update(cid, tags);
3513 tags = RawObject::SizeTag::update(instance_size, tags); 3516 tags = RawObject::SizeTag::update(instance_size, tags);
3514 LoadImmediate(temp1, tags); 3517 LoadImmediate(temp1, tags);
3515 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags. 3518 str(temp1, FieldAddress(instance, Array::tags_offset())); // Store tags.
3516 3519
3517 LoadImmediate(temp1, instance_size); 3520 LoadImmediate(temp1, instance_size);
3518 IncrementAllocationStatsWithSize(temp2, temp1, cid, space); 3521 IncrementAllocationStatsWithSize(temp2, temp1, space);
3519 } else { 3522 } else {
3520 b(failure); 3523 b(failure);
3521 } 3524 }
3522 } 3525 }
3523 3526
3524 3527
3525 void Assembler::Stop(const char* message) { 3528 void Assembler::Stop(const char* message) {
3526 if (FLAG_print_stop_message) { 3529 if (FLAG_print_stop_message) {
3527 StubCode* stub_code = Isolate::Current()->stub_code(); 3530 StubCode* stub_code = Isolate::Current()->stub_code();
3528 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR. 3531 PushList((1 << R0) | (1 << IP) | (1 << LR)); // Preserve R0, IP, LR.
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
3630 3633
3631 3634
3632 const char* Assembler::FpuRegisterName(FpuRegister reg) { 3635 const char* Assembler::FpuRegisterName(FpuRegister reg) {
3633 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); 3636 ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters));
3634 return fpu_reg_names[reg]; 3637 return fpu_reg_names[reg];
3635 } 3638 }
3636 3639
3637 } // namespace dart 3640 } // namespace dart
3638 3641
3639 #endif // defined TARGET_ARCH_ARM 3642 #endif // defined TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « runtime/vm/assembler_arm.h ('k') | runtime/vm/assembler_arm64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698