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" | 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/heap.h" | 10 #include "vm/heap.h" |
(...skipping 2261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2272 while (label->HasNear()) { | 2272 while (label->HasNear()) { |
2273 intptr_t position = label->NearPosition(); | 2273 intptr_t position = label->NearPosition(); |
2274 intptr_t offset = bound - (position + 1); | 2274 intptr_t offset = bound - (position + 1); |
2275 ASSERT(Utils::IsInt(8, offset)); | 2275 ASSERT(Utils::IsInt(8, offset)); |
2276 buffer_.Store<int8_t>(position, offset); | 2276 buffer_.Store<int8_t>(position, offset); |
2277 } | 2277 } |
2278 label->BindTo(bound); | 2278 label->BindTo(bound); |
2279 } | 2279 } |
2280 | 2280 |
2281 | 2281 |
| 2282 void Assembler::UpdateAllocationStats(intptr_t cid, |
| 2283 Register temp_reg, |
| 2284 Heap::Space space) { |
| 2285 ASSERT(cid > 0); |
| 2286 Isolate* isolate = Isolate::Current(); |
| 2287 ClassTable* class_table = isolate->class_table(); |
| 2288 if (cid < kNumPredefinedCids) { |
| 2289 const uword class_heap_stats_table_address = |
| 2290 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2291 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2292 const uword count_field_offset = (space == Heap::kNew) ? |
| 2293 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2294 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2295 const Address& count_address = Address::Absolute( |
| 2296 class_heap_stats_table_address + class_offset + count_field_offset); |
| 2297 incl(count_address); |
| 2298 } else { |
| 2299 ASSERT(temp_reg != kNoRegister); |
| 2300 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2301 const uword count_field_offset = (space == Heap::kNew) ? |
| 2302 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2303 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2304 // temp_reg gets address of class table pointer. |
| 2305 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress())); |
| 2306 // Increment allocation count. |
| 2307 incl(Address(temp_reg, class_offset + count_field_offset)); |
| 2308 } |
| 2309 } |
| 2310 |
| 2311 |
| 2312 void Assembler::UpdateAllocationStatsWithSize(intptr_t cid, |
| 2313 Register size_reg, |
| 2314 Register temp_reg, |
| 2315 Heap::Space space) { |
| 2316 ASSERT(cid > 0); |
| 2317 Isolate* isolate = Isolate::Current(); |
| 2318 ClassTable* class_table = isolate->class_table(); |
| 2319 if (cid < kNumPredefinedCids) { |
| 2320 const uword class_heap_stats_table_address = |
| 2321 class_table->PredefinedClassHeapStatsTableAddress(); |
| 2322 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2323 const uword count_field_offset = (space == Heap::kNew) ? |
| 2324 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2325 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2326 const uword size_field_offset = (space == Heap::kNew) ? |
| 2327 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2328 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2329 const Address& count_address = Address::Absolute( |
| 2330 class_heap_stats_table_address + class_offset + count_field_offset); |
| 2331 const Address& size_address = Address::Absolute( |
| 2332 class_heap_stats_table_address + class_offset + size_field_offset); |
| 2333 incl(count_address); |
| 2334 addl(size_address, size_reg); |
| 2335 } else { |
| 2336 ASSERT(temp_reg != kNoRegister); |
| 2337 const uword class_offset = cid * sizeof(ClassHeapStats); // NOLINT |
| 2338 const uword count_field_offset = (space == Heap::kNew) ? |
| 2339 ClassHeapStats::allocated_since_gc_new_space_offset() : |
| 2340 ClassHeapStats::allocated_since_gc_old_space_offset(); |
| 2341 const uword size_field_offset = (space == Heap::kNew) ? |
| 2342 ClassHeapStats::allocated_size_since_gc_new_space_offset() : |
| 2343 ClassHeapStats::allocated_size_since_gc_old_space_offset(); |
| 2344 // temp_reg gets address of class table pointer. |
| 2345 movl(temp_reg, Address::Absolute(class_table->ClassStatsTableAddress())); |
| 2346 // Increment allocation count. |
| 2347 incl(Address(temp_reg, class_offset + count_field_offset)); |
| 2348 addl(Address(temp_reg, class_offset + size_field_offset), size_reg); |
| 2349 } |
| 2350 } |
| 2351 |
| 2352 |
2282 void Assembler::TryAllocate(const Class& cls, | 2353 void Assembler::TryAllocate(const Class& cls, |
2283 Label* failure, | 2354 Label* failure, |
2284 bool near_jump, | 2355 bool near_jump, |
2285 Register instance_reg) { | 2356 Register instance_reg, |
| 2357 Register temp_reg) { |
2286 ASSERT(failure != NULL); | 2358 ASSERT(failure != NULL); |
2287 if (FLAG_inline_alloc) { | 2359 if (FLAG_inline_alloc) { |
2288 Heap* heap = Isolate::Current()->heap(); | 2360 Heap* heap = Isolate::Current()->heap(); |
2289 const intptr_t instance_size = cls.instance_size(); | 2361 const intptr_t instance_size = cls.instance_size(); |
2290 movl(instance_reg, Address::Absolute(heap->TopAddress())); | 2362 movl(instance_reg, Address::Absolute(heap->TopAddress())); |
2291 addl(instance_reg, Immediate(instance_size)); | 2363 addl(instance_reg, Immediate(instance_size)); |
2292 // instance_reg: potential next object start. | 2364 // instance_reg: potential next object start. |
2293 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); | 2365 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); |
2294 j(ABOVE_EQUAL, failure, near_jump); | 2366 j(ABOVE_EQUAL, failure, near_jump); |
2295 // Successfully allocated the object, now update top to point to | 2367 // Successfully allocated the object, now update top to point to |
2296 // next object start and store the class in the class field of object. | 2368 // next object start and store the class in the class field of object. |
2297 movl(Address::Absolute(heap->TopAddress()), instance_reg); | 2369 movl(Address::Absolute(heap->TopAddress()), instance_reg); |
| 2370 UpdateAllocationStats(cls.id(), temp_reg); |
2298 ASSERT(instance_size >= kHeapObjectTag); | 2371 ASSERT(instance_size >= kHeapObjectTag); |
2299 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 2372 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
2300 uword tags = 0; | 2373 uword tags = 0; |
2301 tags = RawObject::SizeTag::update(instance_size, tags); | 2374 tags = RawObject::SizeTag::update(instance_size, tags); |
2302 ASSERT(cls.id() != kIllegalCid); | 2375 ASSERT(cls.id() != kIllegalCid); |
2303 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2376 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
2304 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 2377 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
2305 } else { | 2378 } else { |
2306 jmp(failure); | 2379 jmp(failure); |
2307 } | 2380 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2523 | 2596 |
2524 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2597 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2525 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2598 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2526 return xmm_reg_names[reg]; | 2599 return xmm_reg_names[reg]; |
2527 } | 2600 } |
2528 | 2601 |
2529 | 2602 |
2530 } // namespace dart | 2603 } // namespace dart |
2531 | 2604 |
2532 #endif // defined TARGET_ARCH_IA32 | 2605 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |