| 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" // NOLINT | 5 #include "vm/globals.h" // NOLINT |
| 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/cpu.h" | 9 #include "vm/cpu.h" |
| 10 #include "vm/heap.h" | 10 #include "vm/heap.h" |
| (...skipping 2324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2335 Register temp_reg) { | 2335 Register temp_reg) { |
| 2336 ASSERT(failure != NULL); | 2336 ASSERT(failure != NULL); |
| 2337 ASSERT(temp_reg != kNoRegister); | 2337 ASSERT(temp_reg != kNoRegister); |
| 2338 if (FLAG_inline_alloc) { | 2338 if (FLAG_inline_alloc) { |
| 2339 // If this allocation is traced, program will jump to failure path | 2339 // If this allocation is traced, program will jump to failure path |
| 2340 // (i.e. the allocation stub) which will allocate the object and trace the | 2340 // (i.e. the allocation stub) which will allocate the object and trace the |
| 2341 // allocation call site. | 2341 // allocation call site. |
| 2342 NOT_IN_PRODUCT( | 2342 NOT_IN_PRODUCT( |
| 2343 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump)); | 2343 MaybeTraceAllocation(cls.id(), temp_reg, failure, near_jump)); |
| 2344 const intptr_t instance_size = cls.instance_size(); | 2344 const intptr_t instance_size = cls.instance_size(); |
| 2345 Heap::Space space = Heap::kNew; | 2345 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 2346 movl(temp_reg, Address(THR, Thread::heap_offset())); | 2346 movl(instance_reg, Address(THR, Thread::top_offset())); |
| 2347 movl(instance_reg, Address(temp_reg, Heap::TopOffset(space))); | |
| 2348 addl(instance_reg, Immediate(instance_size)); | 2347 addl(instance_reg, Immediate(instance_size)); |
| 2349 // instance_reg: potential next object start. | 2348 // instance_reg: potential next object start. |
| 2350 cmpl(instance_reg, Address(temp_reg, Heap::EndOffset(space))); | 2349 cmpl(instance_reg, Address(THR, Thread::end_offset())); |
| 2351 j(ABOVE_EQUAL, failure, near_jump); | 2350 j(ABOVE_EQUAL, failure, near_jump); |
| 2352 // Successfully allocated the object, now update top to point to | 2351 // Successfully allocated the object, now update top to point to |
| 2353 // next object start and store the class in the class field of object. | 2352 // next object start and store the class in the class field of object. |
| 2354 movl(Address(temp_reg, Heap::TopOffset(space)), instance_reg); | 2353 movl(Address(THR, Thread::top_offset()), instance_reg); |
| 2355 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), temp_reg, space)); | 2354 NOT_IN_PRODUCT(UpdateAllocationStats(cls.id(), temp_reg, space)); |
| 2356 ASSERT(instance_size >= kHeapObjectTag); | 2355 ASSERT(instance_size >= kHeapObjectTag); |
| 2357 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); | 2356 subl(instance_reg, Immediate(instance_size - kHeapObjectTag)); |
| 2358 uint32_t tags = 0; | 2357 uint32_t tags = 0; |
| 2359 tags = RawObject::SizeTag::update(instance_size, tags); | 2358 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2360 ASSERT(cls.id() != kIllegalCid); | 2359 ASSERT(cls.id() != kIllegalCid); |
| 2361 tags = RawObject::ClassIdTag::update(cls.id(), tags); | 2360 tags = RawObject::ClassIdTag::update(cls.id(), tags); |
| 2362 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); | 2361 movl(FieldAddress(instance_reg, Object::tags_offset()), Immediate(tags)); |
| 2363 } else { | 2362 } else { |
| 2364 jmp(failure); | 2363 jmp(failure); |
| 2365 } | 2364 } |
| 2366 } | 2365 } |
| 2367 | 2366 |
| 2368 void Assembler::TryAllocateArray(intptr_t cid, | 2367 void Assembler::TryAllocateArray(intptr_t cid, |
| 2369 intptr_t instance_size, | 2368 intptr_t instance_size, |
| 2370 Label* failure, | 2369 Label* failure, |
| 2371 bool near_jump, | 2370 bool near_jump, |
| 2372 Register instance, | 2371 Register instance, |
| 2373 Register end_address, | 2372 Register end_address, |
| 2374 Register temp_reg) { | 2373 Register temp_reg) { |
| 2375 ASSERT(failure != NULL); | 2374 ASSERT(failure != NULL); |
| 2376 ASSERT(temp_reg != kNoRegister); | 2375 ASSERT(temp_reg != kNoRegister); |
| 2377 if (FLAG_inline_alloc) { | 2376 if (FLAG_inline_alloc) { |
| 2378 // If this allocation is traced, program will jump to failure path | 2377 // If this allocation is traced, program will jump to failure path |
| 2379 // (i.e. the allocation stub) which will allocate the object and trace the | 2378 // (i.e. the allocation stub) which will allocate the object and trace the |
| 2380 // allocation call site. | 2379 // allocation call site. |
| 2381 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp_reg, failure, near_jump)); | 2380 NOT_IN_PRODUCT(MaybeTraceAllocation(cid, temp_reg, failure, near_jump)); |
| 2382 Heap::Space space = Heap::kNew; | 2381 NOT_IN_PRODUCT(Heap::Space space = Heap::kNew); |
| 2383 movl(temp_reg, Address(THR, Thread::heap_offset())); | 2382 movl(instance, Address(THR, Thread::top_offset())); |
| 2384 movl(instance, Address(temp_reg, Heap::TopOffset(space))); | |
| 2385 movl(end_address, instance); | 2383 movl(end_address, instance); |
| 2386 | 2384 |
| 2387 addl(end_address, Immediate(instance_size)); | 2385 addl(end_address, Immediate(instance_size)); |
| 2388 j(CARRY, failure); | 2386 j(CARRY, failure); |
| 2389 | 2387 |
| 2390 // Check if the allocation fits into the remaining space. | 2388 // Check if the allocation fits into the remaining space. |
| 2391 // EAX: potential new object start. | 2389 // EAX: potential new object start. |
| 2392 // EBX: potential next object start. | 2390 // EBX: potential next object start. |
| 2393 cmpl(end_address, Address(temp_reg, Heap::EndOffset(space))); | 2391 cmpl(end_address, Address(THR, Thread::end_offset())); |
| 2394 j(ABOVE_EQUAL, failure); | 2392 j(ABOVE_EQUAL, failure); |
| 2395 | 2393 |
| 2396 // Successfully allocated the object(s), now update top to point to | 2394 // Successfully allocated the object(s), now update top to point to |
| 2397 // next object start and initialize the object. | 2395 // next object start and initialize the object. |
| 2398 movl(Address(temp_reg, Heap::TopOffset(space)), end_address); | 2396 movl(Address(THR, Thread::top_offset()), end_address); |
| 2399 addl(instance, Immediate(kHeapObjectTag)); | 2397 addl(instance, Immediate(kHeapObjectTag)); |
| 2400 NOT_IN_PRODUCT( | 2398 NOT_IN_PRODUCT( |
| 2401 UpdateAllocationStatsWithSize(cid, instance_size, temp_reg, space)); | 2399 UpdateAllocationStatsWithSize(cid, instance_size, temp_reg, space)); |
| 2402 | 2400 |
| 2403 // Initialize the tags. | 2401 // Initialize the tags. |
| 2404 uint32_t tags = 0; | 2402 uint32_t tags = 0; |
| 2405 tags = RawObject::ClassIdTag::update(cid, tags); | 2403 tags = RawObject::ClassIdTag::update(cid, tags); |
| 2406 tags = RawObject::SizeTag::update(instance_size, tags); | 2404 tags = RawObject::SizeTag::update(instance_size, tags); |
| 2407 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); | 2405 movl(FieldAddress(instance, Object::tags_offset()), Immediate(tags)); |
| 2408 } else { | 2406 } else { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2705 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"}; | 2703 "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7"}; |
| 2706 | 2704 |
| 2707 const char* Assembler::FpuRegisterName(FpuRegister reg) { | 2705 const char* Assembler::FpuRegisterName(FpuRegister reg) { |
| 2708 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); | 2706 ASSERT((0 <= reg) && (reg < kNumberOfXmmRegisters)); |
| 2709 return xmm_reg_names[reg]; | 2707 return xmm_reg_names[reg]; |
| 2710 } | 2708 } |
| 2711 | 2709 |
| 2712 } // namespace dart | 2710 } // namespace dart |
| 2713 | 2711 |
| 2714 #endif // defined TARGET_ARCH_IA32 | 2712 #endif // defined TARGET_ARCH_IA32 |
| OLD | NEW |