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(); |
2343 | 2345 |
2344 LOperand* obj; | 2346 LOperand* obj; |
2345 if (needs_write_barrier) { | 2347 if (needs_write_barrier) { |
2346 obj = is_in_object | 2348 obj = is_in_object |
2347 ? UseRegister(instr->object()) | 2349 ? UseRegister(instr->object()) |
2348 : UseTempRegister(instr->object()); | 2350 : UseTempRegister(instr->object()); |
2349 } else if (is_external_location) { | 2351 } else if (is_external_location) { |
2350 ASSERT(!is_in_object); | 2352 ASSERT(!is_in_object); |
2351 ASSERT(!needs_write_barrier); | 2353 ASSERT(!needs_write_barrier); |
| 2354 ASSERT(!needs_write_barrier_for_map); |
2352 obj = UseRegisterOrConstant(instr->object()); | 2355 obj = UseRegisterOrConstant(instr->object()); |
2353 } else { | 2356 } else { |
2354 obj = UseRegisterAtStart(instr->object()); | 2357 obj = needs_write_barrier_for_map |
| 2358 ? UseRegister(instr->object()) |
| 2359 : UseRegisterAtStart(instr->object()); |
2355 } | 2360 } |
2356 | 2361 |
2357 bool can_be_constant = instr->value()->IsConstant() && | 2362 bool can_be_constant = instr->value()->IsConstant() && |
2358 HConstant::cast(instr->value())->NotInNewSpace() && | 2363 HConstant::cast(instr->value())->NotInNewSpace() && |
2359 !instr->field_representation().IsDouble(); | 2364 !instr->field_representation().IsDouble(); |
2360 | 2365 |
2361 LOperand* val; | 2366 LOperand* val; |
2362 if (instr->field_representation().IsInteger8() || | 2367 if (instr->field_representation().IsInteger8() || |
2363 instr->field_representation().IsUInteger8()) { | 2368 instr->field_representation().IsUInteger8()) { |
2364 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). | 2369 // mov_b requires a byte register (i.e. any of eax, ebx, ecx, edx). |
2365 // Just force the value to be in eax and we're safe here. | 2370 // Just force the value to be in eax and we're safe here. |
2366 val = UseFixed(instr->value(), eax); | 2371 val = UseFixed(instr->value(), eax); |
2367 } else if (needs_write_barrier) { | 2372 } else if (needs_write_barrier) { |
2368 val = UseTempRegister(instr->value()); | 2373 val = UseTempRegister(instr->value()); |
2369 } else if (can_be_constant) { | 2374 } else if (can_be_constant) { |
2370 val = UseRegisterOrConstant(instr->value()); | 2375 val = UseRegisterOrConstant(instr->value()); |
2371 } else if (instr->field_representation().IsSmi()) { | 2376 } else if (instr->field_representation().IsSmi()) { |
2372 val = UseTempRegister(instr->value()); | 2377 val = UseTempRegister(instr->value()); |
2373 } else if (instr->field_representation().IsDouble()) { | 2378 } else if (instr->field_representation().IsDouble()) { |
2374 val = UseRegisterAtStart(instr->value()); | 2379 val = UseRegisterAtStart(instr->value()); |
2375 } else { | 2380 } else { |
2376 val = UseRegister(instr->value()); | 2381 val = UseRegister(instr->value()); |
2377 } | 2382 } |
2378 | 2383 |
2379 // We only need a scratch register if we have a write barrier or we | 2384 // We only need a scratch register if we have a write barrier or we |
2380 // have a store into the properties array (not in-object-property). | 2385 // have a store into the properties array (not in-object-property). |
2381 LOperand* temp = (!is_in_object || needs_write_barrier) | 2386 LOperand* temp = (!is_in_object || needs_write_barrier || |
2382 ? TempRegister() : NULL; | 2387 needs_write_barrier_for_map) ? 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; |
2383 | 2391 |
2384 LInstruction* result = | 2392 LInstruction* result = |
2385 new(zone()) LStoreNamedField(obj, val, temp); | 2393 new(zone()) LStoreNamedField(obj, val, temp, temp_map); |
2386 if (!instr->access().IsExternalMemory() && | 2394 if (!instr->access().IsExternalMemory() && |
2387 instr->field_representation().IsHeapObject() && | 2395 instr->field_representation().IsHeapObject() && |
2388 (val->IsConstantOperand() | 2396 (val->IsConstantOperand() |
2389 ? HConstant::cast(instr->value())->HasSmiValue() | 2397 ? HConstant::cast(instr->value())->HasSmiValue() |
2390 : !instr->value()->type().IsHeapObject())) { | 2398 : !instr->value()->type().IsHeapObject())) { |
2391 result = AssignEnvironment(result); | 2399 result = AssignEnvironment(result); |
2392 } | 2400 } |
2393 return result; | 2401 return result; |
2394 } | 2402 } |
2395 | 2403 |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2659 LOperand* index = UseTempRegister(instr->index()); | 2667 LOperand* index = UseTempRegister(instr->index()); |
2660 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | 2668 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); |
2661 LInstruction* result = DefineSameAsFirst(load); | 2669 LInstruction* result = DefineSameAsFirst(load); |
2662 return AssignPointerMap(result); | 2670 return AssignPointerMap(result); |
2663 } | 2671 } |
2664 | 2672 |
2665 | 2673 |
2666 } } // namespace v8::internal | 2674 } } // namespace v8::internal |
2667 | 2675 |
2668 #endif // V8_TARGET_ARCH_IA32 | 2676 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |