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

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

Issue 182303005: Inline context allocation in optimized code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/code_generator.h" 9 #include "vm/code_generator.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 2313 matching lines...) Expand 10 before | Expand all | Expand 10 after
2324 while (label->HasNear()) { 2324 while (label->HasNear()) {
2325 intptr_t position = label->NearPosition(); 2325 intptr_t position = label->NearPosition();
2326 intptr_t offset = bound - (position + 1); 2326 intptr_t offset = bound - (position + 1);
2327 ASSERT(Utils::IsInt(8, offset)); 2327 ASSERT(Utils::IsInt(8, offset));
2328 buffer_.Store<int8_t>(position, offset); 2328 buffer_.Store<int8_t>(position, offset);
2329 } 2329 }
2330 label->BindTo(bound); 2330 label->BindTo(bound);
2331 } 2331 }
2332 2332
2333 2333
2334 static void ComputeCounterAddressesForCid(intptr_t cid,
2335 Heap::Space space,
2336 Address* count_address,
2337 Address* size_address) {
2338 ASSERT(cid < kNumPredefinedCids);
2339 Isolate* isolate = Isolate::Current();
2340 ClassTable* class_table = isolate->class_table();
2341 const uword class_heap_stats_table_address =
2342 class_table->PredefinedClassHeapStatsTableAddress();
2343 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
2344 const uword count_field_offset = (space == Heap::kNew) ?
2345 ClassHeapStats::allocated_since_gc_new_space_offset() :
2346 ClassHeapStats::allocated_since_gc_old_space_offset();
2347 const uword size_field_offset = (space == Heap::kNew) ?
2348 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
2349 ClassHeapStats::allocated_size_since_gc_old_space_offset();
2350 *count_address = Address::Absolute(
2351 class_heap_stats_table_address + class_offset + count_field_offset);
2352 *size_address = Address::Absolute(
2353 class_heap_stats_table_address + class_offset + size_field_offset);
2354 }
2355
srdjan 2014/03/03 18:30:08 Two lines between functions.
2334 void Assembler::UpdateAllocationStats(intptr_t cid, 2356 void Assembler::UpdateAllocationStats(intptr_t cid,
2335 Register temp_reg, 2357 Register temp_reg,
2336 Heap::Space space) { 2358 Heap::Space space) {
2337 ASSERT(cid > 0); 2359 ASSERT(cid > 0);
2338 Isolate* isolate = Isolate::Current();
2339 ClassTable* class_table = isolate->class_table();
2340 if (cid < kNumPredefinedCids) { 2360 if (cid < kNumPredefinedCids) {
2341 const uword class_heap_stats_table_address = 2361 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
2342 class_table->PredefinedClassHeapStatsTableAddress(); 2362 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
2343 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
2344 const uword count_field_offset = (space == Heap::kNew) ?
2345 ClassHeapStats::allocated_since_gc_new_space_offset() :
2346 ClassHeapStats::allocated_since_gc_old_space_offset();
2347 const Address& count_address = Address::Absolute(
2348 class_heap_stats_table_address + class_offset + count_field_offset);
2349 incl(count_address); 2363 incl(count_address);
2350 } else { 2364 } else {
2351 ASSERT(temp_reg != kNoRegister); 2365 ASSERT(temp_reg != kNoRegister);
2352 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 2366 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
2353 const uword count_field_offset = (space == Heap::kNew) ? 2367 const uword count_field_offset = (space == Heap::kNew) ?
2354 ClassHeapStats::allocated_since_gc_new_space_offset() : 2368 ClassHeapStats::allocated_since_gc_new_space_offset() :
2355 ClassHeapStats::allocated_since_gc_old_space_offset(); 2369 ClassHeapStats::allocated_since_gc_old_space_offset();
2356 // temp_reg gets address of class table pointer. 2370 // temp_reg gets address of class table pointer.
2371 ClassTable* class_table = Isolate::Current()->class_table();
2357 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress())); 2372 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress()));
2358 // Increment allocation count. 2373 // Increment allocation count.
2359 incl(Address(temp_reg, class_offset + count_field_offset)); 2374 incl(Address(temp_reg, class_offset + count_field_offset));
2360 } 2375 }
2361 } 2376 }
2362 2377
2363 2378
2364 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, 2379 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
2365 Register size_reg, 2380 Register size_reg,
2366 Register temp_reg, 2381 Register temp_reg,
2367 Heap::Space space) { 2382 Heap::Space space) {
2368 ASSERT(cid > 0); 2383 ASSERT(cid > 0);
2369 Isolate* isolate = Isolate::Current(); 2384 ASSERT(cid < kNumPredefinedCids);
2370 ClassTable* class_table = isolate->class_table(); 2385 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
2371 if (cid < kNumPredefinedCids) { 2386 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
2372 const uword class_heap_stats_table_address = 2387 incl(count_address);
2373 class_table->PredefinedClassHeapStatsTableAddress(); 2388 addl(size_address, size_reg);
2374 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT 2389 }
2375 const uword count_field_offset = (space == Heap::kNew) ? 2390
2376 ClassHeapStats::allocated_since_gc_new_space_offset() : 2391
2377 ClassHeapStats::allocated_since_gc_old_space_offset(); 2392 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid,
2378 const uword size_field_offset = (space == Heap::kNew) ? 2393 intptr_t size_in_bytes,
2379 ClassHeapStats::allocated_size_since_gc_new_space_offset() : 2394 Register temp_reg,
2380 ClassHeapStats::allocated_size_since_gc_old_space_offset(); 2395 Heap::Space space) {
2381 const Address& count_address = Address::Absolute( 2396 ASSERT(cid > 0);
2382 class_heap_stats_table_address + class_offset + count_field_offset); 2397 ASSERT(cid < kNumPredefinedCids);
2383 const Address& size_address = Address::Absolute( 2398 Address count_address(kNoRegister, 0), size_address(kNoRegister, 0);
2384 class_heap_stats_table_address + class_offset + size_field_offset); 2399 ComputeCounterAddressesForCid(cid, space, &count_address, &size_address);
2385 incl(count_address); 2400 incl(count_address);
2386 addl(size_address, size_reg); 2401 addl(size_address, Immediate(size_in_bytes));
2387 } else {
2388 ASSERT(temp_reg != kNoRegister);
2389 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT
2390 const uword count_field_offset = (space == Heap::kNew) ?
2391 ClassHeapStats::allocated_since_gc_new_space_offset() :
2392 ClassHeapStats::allocated_since_gc_old_space_offset();
2393 const uword size_field_offset = (space == Heap::kNew) ?
2394 ClassHeapStats::allocated_size_since_gc_new_space_offset() :
2395 ClassHeapStats::allocated_size_since_gc_old_space_offset();
2396 // temp_reg gets address of class table pointer.
2397 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress()));
2398 // Increment allocation count.
2399 incl(Address(temp_reg, class_offset + count_field_offset));
2400 addl(Address(temp_reg, class_offset + size_field_offset), size_reg);
2401 }
2402 } 2402 }
2403 2403
2404 2404
2405 void Assembler::TryAllocate(const Class& cls, 2405 void Assembler::TryAllocate(const Class& cls,
2406 Label* failure, 2406 Label* failure,
2407 bool near_jump, 2407 bool near_jump,
2408 Register instance_reg, 2408 Register instance_reg,
2409 Register temp_reg) { 2409 Register temp_reg) {
2410 ASSERT(failure != NULL); 2410 ASSERT(failure != NULL);
2411 if (FLAG_inline_alloc) { 2411 if (FLAG_inline_alloc) {
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2648 2648
2649 const char* Assembler::FpuRegisterName(FpuRegister reg) { 2649 const char* Assembler::FpuRegisterName(FpuRegister reg) {
2650 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); 2650 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters));
2651 return xmm_reg_names[reg]; 2651 return xmm_reg_names[reg];
2652 } 2652 }
2653 2653
2654 2654
2655 } // namespace dart 2655 } // namespace dart
2656 2656
2657 #endif // defined TARGET_ARCH_IA32 2657 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698