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" |
11 #include "vm/heap_class_stats.h" | |
11 #include "vm/memory_region.h" | 12 #include "vm/memory_region.h" |
12 #include "vm/runtime_entry.h" | 13 #include "vm/runtime_entry.h" |
13 #include "vm/stack_frame.h" | 14 #include "vm/stack_frame.h" |
14 #include "vm/stub_code.h" | 15 #include "vm/stub_code.h" |
15 | 16 |
16 namespace dart { | 17 namespace dart { |
17 | 18 |
18 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); | 19 DEFINE_FLAG(bool, print_stop_message, true, "Print stop message."); |
19 DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available"); | 20 DEFINE_FLAG(bool, use_sse41, true, "Use SSE 4.1 if available"); |
20 DECLARE_FLAG(bool, inline_alloc); | 21 DECLARE_FLAG(bool, inline_alloc); |
(...skipping 2235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2256 while (label->HasNear()) { | 2257 while (label->HasNear()) { |
2257 intptr_t position = label->NearPosition(); | 2258 intptr_t position = label->NearPosition(); |
2258 intptr_t offset = bound - (position + 1); | 2259 intptr_t offset = bound - (position + 1); |
2259 ASSERT(Utils::IsInt(8, offset)); | 2260 ASSERT(Utils::IsInt(8, offset)); |
2260 buffer_.Store<int8_t>(position, offset); | 2261 buffer_.Store<int8_t>(position, offset); |
2261 } | 2262 } |
2262 label->BindTo(bound); | 2263 label->BindTo(bound); |
2263 } | 2264 } |
2264 | 2265 |
2265 | 2266 |
2267 // Updates the allocation count for cid. | |
2268 void Assembler::BumpAllocationCount(intptr_t cid, | |
2269 Register temp_reg) { | |
2270 ASSERT(temp_reg != kNoRegister); | |
2271 HeapClassStatistics* heap_class_stats = | |
2272 Isolate::Current()->heap_class_stats(); | |
2273 // temp_reg gets address of class table pointer. | |
2274 movl(temp_reg, Address::Absolute(heap_class_stats->ClassStatsTableAddress())); | |
2275 // Offset into class table. | |
2276 const intptr_t offset = cid * sizeof(HeapClassData); // NOLINT | |
2277 // temp_reg points at HeapClassData for cid + offset to allocation count. | |
2278 leal(temp_reg, Address(temp_reg, offset)); | |
2279 // Increment allocation count. | |
2280 addl(Address(temp_reg, HeapClassData::allocated_since_gc_offset()), | |
2281 Immediate(1)); | |
2282 } | |
2283 | |
2266 void Assembler::TryAllocate(const Class& cls, | 2284 void Assembler::TryAllocate(const Class& cls, |
2267 Label* failure, | 2285 Label* failure, |
2268 bool near_jump, | 2286 bool near_jump, |
2269 Register instance_reg) { | 2287 Register instance_reg) { |
2270 ASSERT(failure != NULL); | 2288 ASSERT(failure != NULL); |
2271 if (FLAG_inline_alloc) { | 2289 if (FLAG_inline_alloc) { |
2272 Heap* heap = Isolate::Current()->heap(); | 2290 Heap* heap = Isolate::Current()->heap(); |
2273 const intptr_t instance_size = cls.instance_size(); | 2291 const intptr_t instance_size = cls.instance_size(); |
2274 movl(instance_reg, Address::Absolute(heap->TopAddress())); | 2292 movl(instance_reg, Address::Absolute(heap->TopAddress())); |
2275 addl(instance_reg, Immediate(instance_size)); | 2293 addl(instance_reg, Immediate(instance_size)); |
2276 // instance_reg: potential next object start. | 2294 // instance_reg: potential next object start. |
2277 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); | 2295 cmpl(instance_reg, Address::Absolute(heap->EndAddress())); |
2278 j(ABOVE_EQUAL, failure, near_jump); | 2296 j(ABOVE_EQUAL, failure, near_jump); |
2279 // Successfully allocated the object, now update top to point to | 2297 // Successfully allocated the object, now update top to point to |
2280 // next object start and store the class in the class field of object. | 2298 // next object start and store the class in the class field of object. |
2281 movl(Address::Absolute(heap->TopAddress()), instance_reg); | 2299 movl(Address::Absolute(heap->TopAddress()), instance_reg); |
2300 pushl(instance_reg); | |
Florian Schneider
2013/10/31 09:56:01
I suspect that this will make bump allocation a _l
Cutch
2013/10/31 11:20:02
I will run some tests tomorrow against patch set 2
| |
2301 BumpAllocationCount(cls.id(), instance_reg); | |
2302 popl(instance_reg); | |
2282 ASSERT(instance_size >= kHeapObjectTag); | 2303 ASSERT(instance_size >= kHeapObjectTag); |
2283 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 2304 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
2284 uword tags = 0; | 2305 uword tags = 0; |
2285 tags = RawObject::SizeTag::update(instance_size, tags); | 2306 tags = RawObject::SizeTag::update(instance_size, tags); |
2286 ASSERT(cls.id() != kIllegalCid); | 2307 ASSERT(cls.id() != kIllegalCid); |
2287 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2308 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
2288 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 2309 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
2289 } else { | 2310 } else { |
2290 jmp(failure); | 2311 jmp(failure); |
2291 } | 2312 } |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2507 | 2528 |
2508 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2529 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
2509 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2530 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
2510 return xmm_reg_names[reg]; | 2531 return xmm_reg_names[reg]; |
2511 } | 2532 } |
2512 | 2533 |
2513 | 2534 |
2514 } // namespace dart | 2535 } // namespace dart |
2515 | 2536 |
2516 #endif // defined TARGET_ARCH_IA32 | 2537 #endif // defined TARGET_ARCH_IA32 |
OLD | NEW |