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 "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
8 | 8 |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/ic-inl.h" | 10 #include "src/ic-inl.h" |
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 // but may be destroyed if store is successful. | 571 // but may be destroyed if store is successful. |
572 void NamedStoreHandlerCompiler::GenerateStoreField( | 572 void NamedStoreHandlerCompiler::GenerateStoreField( |
573 Handle<JSObject> object, LookupResult* lookup, Register receiver_reg, | 573 Handle<JSObject> object, LookupResult* lookup, Register receiver_reg, |
574 Register name_reg, Register value_reg, Register scratch1, Register scratch2, | 574 Register name_reg, Register value_reg, Register scratch1, Register scratch2, |
575 Label* miss_label) { | 575 Label* miss_label) { |
576 // Stub never generated for objects that require access checks. | 576 // Stub never generated for objects that require access checks. |
577 DCHECK(!object->IsAccessCheckNeeded()); | 577 DCHECK(!object->IsAccessCheckNeeded()); |
578 DCHECK(!object->IsJSGlobalProxy()); | 578 DCHECK(!object->IsJSGlobalProxy()); |
579 | 579 |
580 FieldIndex index = lookup->GetFieldIndex(); | 580 FieldIndex index = lookup->GetFieldIndex(); |
581 | 581 DCHECK(lookup->representation().IsHeapObject()); |
582 Representation representation = lookup->representation(); | 582 __ JumpIfSmi(value_reg, miss_label); |
583 DCHECK(!representation.IsNone()); | 583 HeapType* field_type = lookup->GetFieldType(); |
584 if (representation.IsSmi()) { | 584 HeapType::Iterator<Map> it = field_type->Classes(); |
585 __ JumpIfNotSmi(value_reg, miss_label); | 585 if (!it.Done()) { |
586 } else if (representation.IsHeapObject()) { | 586 Label do_store; |
587 __ JumpIfSmi(value_reg, miss_label); | 587 while (true) { |
588 HeapType* field_type = lookup->GetFieldType(); | 588 __ CompareMap(value_reg, it.Current()); |
589 HeapType::Iterator<Map> it = field_type->Classes(); | 589 it.Advance(); |
590 if (!it.Done()) { | 590 if (it.Done()) { |
591 Label do_store; | 591 __ j(not_equal, miss_label); |
592 while (true) { | 592 break; |
593 __ CompareMap(value_reg, it.Current()); | |
594 it.Advance(); | |
595 if (it.Done()) { | |
596 __ j(not_equal, miss_label); | |
597 break; | |
598 } | |
599 __ j(equal, &do_store, Label::kNear); | |
600 } | 593 } |
601 __ bind(&do_store); | 594 __ j(equal, &do_store, Label::kNear); |
602 } | 595 } |
603 } else if (representation.IsDouble()) { | |
604 // Load the double storage. | |
605 if (index.is_inobject()) { | |
606 __ mov(scratch1, FieldOperand(receiver_reg, index.offset())); | |
607 } else { | |
608 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | |
609 __ mov(scratch1, FieldOperand(scratch1, index.offset())); | |
610 } | |
611 | |
612 // Store the value into the storage. | |
613 Label do_store, heap_number; | |
614 __ JumpIfNotSmi(value_reg, &heap_number); | |
615 __ SmiUntag(value_reg); | |
616 __ push(value_reg); | |
617 __ fild_s(Operand(esp, 0)); | |
618 __ pop(value_reg); | |
619 __ SmiTag(value_reg); | |
620 __ jmp(&do_store); | |
621 __ bind(&heap_number); | |
622 __ CheckMap(value_reg, isolate()->factory()->heap_number_map(), miss_label, | |
623 DONT_DO_SMI_CHECK); | |
624 __ fld_d(FieldOperand(value_reg, HeapNumber::kValueOffset)); | |
625 __ bind(&do_store); | 596 __ bind(&do_store); |
626 __ fstp_d(FieldOperand(scratch1, HeapNumber::kValueOffset)); | |
627 // Return the value (register eax). | |
628 DCHECK(value_reg.is(eax)); | |
629 __ ret(0); | |
630 return; | |
631 } | 597 } |
632 | 598 |
633 DCHECK(!representation.IsDouble()); | |
634 // TODO(verwaest): Share this code as a code stub. | |
635 SmiCheck smi_check = representation.IsTagged() | |
636 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; | |
637 if (index.is_inobject()) { | 599 if (index.is_inobject()) { |
638 // Set the property straight into the object. | 600 // Set the property straight into the object. |
639 __ mov(FieldOperand(receiver_reg, index.offset()), value_reg); | 601 __ mov(FieldOperand(receiver_reg, index.offset()), value_reg); |
640 | 602 |
641 if (!representation.IsSmi()) { | 603 // Update the write barrier for the array address. |
642 // Update the write barrier for the array address. | 604 // Pass the value being stored in the now unused name_reg. |
643 // Pass the value being stored in the now unused name_reg. | 605 __ mov(name_reg, value_reg); |
644 __ mov(name_reg, value_reg); | 606 __ RecordWriteField(receiver_reg, index.offset(), name_reg, scratch1, |
645 __ RecordWriteField(receiver_reg, | 607 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
646 index.offset(), | |
647 name_reg, | |
648 scratch1, | |
649 EMIT_REMEMBERED_SET, | |
650 smi_check); | |
651 } | |
652 } else { | 608 } else { |
653 // Write to the properties array. | 609 // Write to the properties array. |
654 // Get the properties array (optimistically). | 610 // Get the properties array (optimistically). |
655 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | 611 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); |
656 __ mov(FieldOperand(scratch1, index.offset()), value_reg); | 612 __ mov(FieldOperand(scratch1, index.offset()), value_reg); |
657 | 613 |
658 if (!representation.IsSmi()) { | 614 // Update the write barrier for the array address. |
659 // Update the write barrier for the array address. | 615 // Pass the value being stored in the now unused name_reg. |
660 // Pass the value being stored in the now unused name_reg. | 616 __ mov(name_reg, value_reg); |
661 __ mov(name_reg, value_reg); | 617 __ RecordWriteField(scratch1, index.offset(), name_reg, receiver_reg, |
662 __ RecordWriteField(scratch1, | 618 EMIT_REMEMBERED_SET, OMIT_SMI_CHECK); |
663 index.offset(), | |
664 name_reg, | |
665 receiver_reg, | |
666 EMIT_REMEMBERED_SET, | |
667 smi_check); | |
668 } | |
669 } | 619 } |
670 | 620 |
671 // Return the value (register eax). | 621 // Return the value (register eax). |
672 DCHECK(value_reg.is(eax)); | 622 DCHECK(value_reg.is(eax)); |
673 __ ret(0); | 623 __ ret(0); |
674 } | 624 } |
675 | 625 |
676 | 626 |
677 Register PropertyHandlerCompiler::CheckPrototypes( | 627 Register PropertyHandlerCompiler::CheckPrototypes( |
678 Register object_reg, Register holder_reg, Register scratch1, | 628 Register object_reg, Register holder_reg, Register scratch1, |
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 // ----------------------------------- | 1225 // ----------------------------------- |
1276 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1226 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
1277 } | 1227 } |
1278 | 1228 |
1279 | 1229 |
1280 #undef __ | 1230 #undef __ |
1281 | 1231 |
1282 } } // namespace v8::internal | 1232 } } // namespace v8::internal |
1283 | 1233 |
1284 #endif // V8_TARGET_ARCH_X87 | 1234 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |