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