OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "v8.h" | 5 #include "v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "lithium-allocator-inl.h" | 9 #include "lithium-allocator-inl.h" |
10 #include "ia32/lithium-ia32.h" | 10 #include "ia32/lithium-ia32.h" |
(...skipping 2322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 new(zone()) LTrapAllocationMemento(object, temp); | 2333 new(zone()) LTrapAllocationMemento(object, temp); |
2334 return AssignEnvironment(result); | 2334 return AssignEnvironment(result); |
2335 } | 2335 } |
2336 | 2336 |
2337 | 2337 |
2338 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | 2338 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { |
2339 bool is_in_object = instr->access().IsInobject(); | 2339 bool is_in_object = instr->access().IsInobject(); |
2340 bool is_external_location = instr->access().IsExternalMemory() && | 2340 bool is_external_location = instr->access().IsExternalMemory() && |
2341 instr->access().offset() == 0; | 2341 instr->access().offset() == 0; |
2342 bool needs_write_barrier = instr->NeedsWriteBarrier(); | 2342 bool needs_write_barrier = instr->NeedsWriteBarrier(); |
2343 bool needs_write_barrier_for_map = instr->has_transition() && | |
2344 instr->NeedsWriteBarrierForMap(); | |
2345 | 2343 |
2346 LOperand* obj; | 2344 LOperand* obj; |
2347 if (needs_write_barrier) { | 2345 if (needs_write_barrier) { |
2348 obj = is_in_object | 2346 obj = is_in_object |
2349 ? UseRegister(instr->object()) | 2347 ? UseRegister(instr->object()) |
2350 : UseTempRegister(instr->object()); | 2348 : UseTempRegister(instr->object()); |
2351 } else if (is_external_location) { | 2349 } else if (is_external_location) { |
2352 ASSERT(!is_in_object); | 2350 ASSERT(!is_in_object); |
2353 ASSERT(!needs_write_barrier); | 2351 ASSERT(!needs_write_barrier); |
2354 ASSERT(!needs_write_barrier_for_map); | |
2355 obj = UseRegisterOrConstant(instr->object()); | 2352 obj = UseRegisterOrConstant(instr->object()); |
2356 } else { | 2353 } else { |
2357 obj = needs_write_barrier_for_map | 2354 obj = UseRegisterAtStart(instr->object()); |
2358 ? UseRegister(instr->object()) | |
2359 : UseRegisterAtStart(instr->object()); | |
2360 } | 2355 } |
2361 | 2356 |
2362 bool can_be_constant = instr->value()->IsConstant() && | 2357 bool can_be_constant = instr->value()->IsConstant() && |
2363 HConstant::cast(instr->value())->NotInNewSpace() && | 2358 HConstant::cast(instr->value())->NotInNewSpace() && |
2364 !instr->field_representation().IsDouble(); | 2359 !instr->field_representation().IsDouble(); |
2365 | 2360 |
2366 LOperand* val; | 2361 LOperand* val; |
2367 if (instr->field_representation().IsInteger8() || | 2362 if (instr->field_representation().IsInteger8() || |
2368 instr->field_representation().IsUInteger8()) { | 2363 instr->field_representation().IsUInteger8()) { |
2369 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). | 2364 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). |
2370 // Just force the value to be in eax and we're safe here. | 2365 // Just force the value to be in eax and we're safe here. |
2371 val = UseFixed(instr->value(), eax); | 2366 val = UseFixed(instr->value(), eax); |
2372 } else if (needs_write_barrier) { | 2367 } else if (needs_write_barrier) { |
2373 val = UseTempRegister(instr->value()); | 2368 val = UseTempRegister(instr->value()); |
2374 } else if (can_be_constant) { | 2369 } else if (can_be_constant) { |
2375 val = UseRegisterOrConstant(instr->value()); | 2370 val = UseRegisterOrConstant(instr->value()); |
2376 } else if (instr->field_representation().IsSmi()) { | 2371 } else if (instr->field_representation().IsSmi()) { |
2377 val = UseTempRegister(instr->value()); | 2372 val = UseTempRegister(instr->value()); |
2378 } else if (instr->field_representation().IsDouble()) { | 2373 } else if (instr->field_representation().IsDouble()) { |
2379 val = UseRegisterAtStart(instr->value()); | 2374 val = UseRegisterAtStart(instr->value()); |
2380 } else { | 2375 } else { |
2381 val = UseRegister(instr->value()); | 2376 val = UseRegister(instr->value()); |
2382 } | 2377 } |
2383 | 2378 |
2384 // We only need a scratch register if we have a write barrier or we | 2379 // We only need a scratch register if we have a write barrier or we |
2385 // have a store into the properties array (not in-object-property). | 2380 // have a store into the properties array (not in-object-property). |
2386 LOperand* temp = (!is_in_object || needs_write_barrier || | 2381 LOperand* temp = (!is_in_object || needs_write_barrier) |
2387 needs_write_barrier_for_map) ? TempRegister() : NULL; | 2382 ? TempRegister() : NULL; |
2388 | |
2389 // We need a temporary register for write barrier of the map field. | |
2390 LOperand* temp_map = needs_write_barrier_for_map ? TempRegister() : NULL; | |
2391 | 2383 |
2392 LInstruction* result = | 2384 LInstruction* result = |
2393 new(zone()) LStoreNamedField(obj, val, temp, temp_map); | 2385 new(zone()) LStoreNamedField(obj, val, temp); |
2394 if (!instr->access().IsExternalMemory() && | 2386 if (!instr->access().IsExternalMemory() && |
2395 instr->field_representation().IsHeapObject() && | 2387 instr->field_representation().IsHeapObject() && |
2396 (val->IsConstantOperand() | 2388 (val->IsConstantOperand() |
2397 ? HConstant::cast(instr->value())->HasSmiValue() | 2389 ? HConstant::cast(instr->value())->HasSmiValue() |
2398 : !instr->value()->type().IsHeapObject())) { | 2390 : !instr->value()->type().IsHeapObject())) { |
2399 result = AssignEnvironment(result); | 2391 result = AssignEnvironment(result); |
2400 } | 2392 } |
2401 return result; | 2393 return result; |
2402 } | 2394 } |
2403 | 2395 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2667 LOperand* index = UseTempRegister(instr->index()); | 2659 LOperand* index = UseTempRegister(instr->index()); |
2668 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | 2660 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); |
2669 LInstruction* result = DefineSameAsFirst(load); | 2661 LInstruction* result = DefineSameAsFirst(load); |
2670 return AssignPointerMap(result); | 2662 return AssignPointerMap(result); |
2671 } | 2663 } |
2672 | 2664 |
2673 | 2665 |
2674 } } // namespace v8::internal | 2666 } } // namespace v8::internal |
2675 | 2667 |
2676 #endif // V8_TARGET_ARCH_IA32 | 2668 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |