| 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/ic-inl.h" | 9 #include "src/ic-inl.h" |
| 10 #include "src/codegen.h" | 10 #include "src/codegen.h" |
| (...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 653 Register receiver_reg, | 653 Register receiver_reg, |
| 654 Register name_reg, | 654 Register name_reg, |
| 655 Register value_reg, | 655 Register value_reg, |
| 656 Register scratch1, | 656 Register scratch1, |
| 657 Register scratch2, | 657 Register scratch2, |
| 658 Label* miss_label) { | 658 Label* miss_label) { |
| 659 // Stub never generated for non-global objects that require access | 659 // Stub never generated for non-global objects that require access |
| 660 // checks. | 660 // checks. |
| 661 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); | 661 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); |
| 662 | 662 |
| 663 FieldIndex index = lookup->GetFieldIndex(); | 663 int index = lookup->GetFieldIndex().field_index(); |
| 664 |
| 665 // Adjust for the number of properties stored in the object. Even in the |
| 666 // face of a transition we can use the old map here because the size of the |
| 667 // object and the number of in-object properties is not going to change. |
| 668 index -= object->map()->inobject_properties(); |
| 664 | 669 |
| 665 Representation representation = lookup->representation(); | 670 Representation representation = lookup->representation(); |
| 666 ASSERT(!representation.IsNone()); | 671 ASSERT(!representation.IsNone()); |
| 667 if (representation.IsSmi()) { | 672 if (representation.IsSmi()) { |
| 668 __ JumpIfNotSmi(value_reg, miss_label); | 673 __ JumpIfNotSmi(value_reg, miss_label); |
| 669 } else if (representation.IsHeapObject()) { | 674 } else if (representation.IsHeapObject()) { |
| 670 __ JumpIfSmi(value_reg, miss_label); | 675 __ JumpIfSmi(value_reg, miss_label); |
| 671 HeapType* field_type = lookup->GetFieldType(); | 676 HeapType* field_type = lookup->GetFieldType(); |
| 672 HeapType::Iterator<Map> it = field_type->Classes(); | 677 HeapType::Iterator<Map> it = field_type->Classes(); |
| 673 if (!it.Done()) { | 678 if (!it.Done()) { |
| 674 Label do_store; | 679 Label do_store; |
| 675 while (true) { | 680 while (true) { |
| 676 __ CompareMap(value_reg, it.Current()); | 681 __ CompareMap(value_reg, it.Current()); |
| 677 it.Advance(); | 682 it.Advance(); |
| 678 if (it.Done()) { | 683 if (it.Done()) { |
| 679 __ j(not_equal, miss_label); | 684 __ j(not_equal, miss_label); |
| 680 break; | 685 break; |
| 681 } | 686 } |
| 682 __ j(equal, &do_store, Label::kNear); | 687 __ j(equal, &do_store, Label::kNear); |
| 683 } | 688 } |
| 684 __ bind(&do_store); | 689 __ bind(&do_store); |
| 685 } | 690 } |
| 686 } else if (representation.IsDouble()) { | 691 } else if (representation.IsDouble()) { |
| 687 // Load the double storage. | 692 // Load the double storage. |
| 688 if (index.is_inobject()) { | 693 if (index < 0) { |
| 689 __ mov(scratch1, FieldOperand(receiver_reg, index.offset())); | 694 int offset = object->map()->instance_size() + (index * kPointerSize); |
| 695 __ mov(scratch1, FieldOperand(receiver_reg, offset)); |
| 690 } else { | 696 } else { |
| 691 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | 697 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 692 __ mov(scratch1, FieldOperand(scratch1, index.offset())); | 698 int offset = index * kPointerSize + FixedArray::kHeaderSize; |
| 699 __ mov(scratch1, FieldOperand(scratch1, offset)); |
| 693 } | 700 } |
| 694 | 701 |
| 695 // Store the value into the storage. | 702 // Store the value into the storage. |
| 696 Label do_store, heap_number; | 703 Label do_store, heap_number; |
| 697 __ JumpIfNotSmi(value_reg, &heap_number); | 704 __ JumpIfNotSmi(value_reg, &heap_number); |
| 698 __ SmiUntag(value_reg); | 705 __ SmiUntag(value_reg); |
| 699 __ push(value_reg); | 706 __ push(value_reg); |
| 700 __ fild_s(Operand(esp, 0)); | 707 __ fild_s(Operand(esp, 0)); |
| 701 __ pop(value_reg); | 708 __ pop(value_reg); |
| 702 __ SmiTag(value_reg); | 709 __ SmiTag(value_reg); |
| 703 __ jmp(&do_store); | 710 __ jmp(&do_store); |
| 704 __ bind(&heap_number); | 711 __ bind(&heap_number); |
| 705 __ CheckMap(value_reg, masm->isolate()->factory()->heap_number_map(), | 712 __ CheckMap(value_reg, masm->isolate()->factory()->heap_number_map(), |
| 706 miss_label, DONT_DO_SMI_CHECK); | 713 miss_label, DONT_DO_SMI_CHECK); |
| 707 __ fld_d(FieldOperand(value_reg, HeapNumber::kValueOffset)); | 714 __ fld_d(FieldOperand(value_reg, HeapNumber::kValueOffset)); |
| 708 __ bind(&do_store); | 715 __ bind(&do_store); |
| 709 __ fstp_d(FieldOperand(scratch1, HeapNumber::kValueOffset)); | 716 __ fstp_d(FieldOperand(scratch1, HeapNumber::kValueOffset)); |
| 710 // Return the value (register eax). | 717 // Return the value (register eax). |
| 711 ASSERT(value_reg.is(eax)); | 718 ASSERT(value_reg.is(eax)); |
| 712 __ ret(0); | 719 __ ret(0); |
| 713 return; | 720 return; |
| 714 } | 721 } |
| 715 | 722 |
| 716 ASSERT(!representation.IsDouble()); | 723 ASSERT(!representation.IsDouble()); |
| 717 // TODO(verwaest): Share this code as a code stub. | 724 // TODO(verwaest): Share this code as a code stub. |
| 718 SmiCheck smi_check = representation.IsTagged() | 725 SmiCheck smi_check = representation.IsTagged() |
| 719 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; | 726 ? INLINE_SMI_CHECK : OMIT_SMI_CHECK; |
| 720 if (index.is_inobject()) { | 727 if (index < 0) { |
| 721 // Set the property straight into the object. | 728 // Set the property straight into the object. |
| 722 __ mov(FieldOperand(receiver_reg, index.offset()), value_reg); | 729 int offset = object->map()->instance_size() + (index * kPointerSize); |
| 730 __ mov(FieldOperand(receiver_reg, offset), value_reg); |
| 723 | 731 |
| 724 if (!representation.IsSmi()) { | 732 if (!representation.IsSmi()) { |
| 725 // Update the write barrier for the array address. | 733 // Update the write barrier for the array address. |
| 726 // Pass the value being stored in the now unused name_reg. | 734 // Pass the value being stored in the now unused name_reg. |
| 727 __ mov(name_reg, value_reg); | 735 __ mov(name_reg, value_reg); |
| 728 __ RecordWriteField(receiver_reg, | 736 __ RecordWriteField(receiver_reg, |
| 729 index.offset(), | 737 offset, |
| 730 name_reg, | 738 name_reg, |
| 731 scratch1, | 739 scratch1, |
| 732 EMIT_REMEMBERED_SET, | 740 EMIT_REMEMBERED_SET, |
| 733 smi_check); | 741 smi_check); |
| 734 } | 742 } |
| 735 } else { | 743 } else { |
| 736 // Write to the properties array. | 744 // Write to the properties array. |
| 745 int offset = index * kPointerSize + FixedArray::kHeaderSize; |
| 737 // Get the properties array (optimistically). | 746 // Get the properties array (optimistically). |
| 738 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | 747 __ mov(scratch1, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 739 __ mov(FieldOperand(scratch1, index.offset()), value_reg); | 748 __ mov(FieldOperand(scratch1, offset), value_reg); |
| 740 | 749 |
| 741 if (!representation.IsSmi()) { | 750 if (!representation.IsSmi()) { |
| 742 // Update the write barrier for the array address. | 751 // Update the write barrier for the array address. |
| 743 // Pass the value being stored in the now unused name_reg. | 752 // Pass the value being stored in the now unused name_reg. |
| 744 __ mov(name_reg, value_reg); | 753 __ mov(name_reg, value_reg); |
| 745 __ RecordWriteField(scratch1, | 754 __ RecordWriteField(scratch1, |
| 746 index.offset(), | 755 offset, |
| 747 name_reg, | 756 name_reg, |
| 748 receiver_reg, | 757 receiver_reg, |
| 749 EMIT_REMEMBERED_SET, | 758 EMIT_REMEMBERED_SET, |
| 750 smi_check); | 759 smi_check); |
| 751 } | 760 } |
| 752 } | 761 } |
| 753 | 762 |
| 754 // Return the value (register eax). | 763 // Return the value (register eax). |
| 755 ASSERT(value_reg.is(eax)); | 764 ASSERT(value_reg.is(eax)); |
| 756 __ ret(0); | 765 __ ret(0); |
| (...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 955 __ j(not_equal, &miss); | 964 __ j(not_equal, &miss); |
| 956 } | 965 } |
| 957 | 966 |
| 958 HandlerFrontendFooter(name, &miss); | 967 HandlerFrontendFooter(name, &miss); |
| 959 return reg; | 968 return reg; |
| 960 } | 969 } |
| 961 | 970 |
| 962 | 971 |
| 963 void LoadStubCompiler::GenerateLoadField(Register reg, | 972 void LoadStubCompiler::GenerateLoadField(Register reg, |
| 964 Handle<JSObject> holder, | 973 Handle<JSObject> holder, |
| 965 FieldIndex field, | 974 PropertyIndex field, |
| 966 Representation representation) { | 975 Representation representation) { |
| 967 if (!reg.is(receiver())) __ mov(receiver(), reg); | 976 if (!reg.is(receiver())) __ mov(receiver(), reg); |
| 968 if (kind() == Code::LOAD_IC) { | 977 if (kind() == Code::LOAD_IC) { |
| 969 LoadFieldStub stub(isolate(), field); | 978 LoadFieldStub stub(isolate(), |
| 979 field.is_inobject(holder), |
| 980 field.translate(holder), |
| 981 representation); |
| 970 GenerateTailCall(masm(), stub.GetCode()); | 982 GenerateTailCall(masm(), stub.GetCode()); |
| 971 } else { | 983 } else { |
| 972 KeyedLoadFieldStub stub(isolate(), field); | 984 KeyedLoadFieldStub stub(isolate(), |
| 985 field.is_inobject(holder), |
| 986 field.translate(holder), |
| 987 representation); |
| 973 GenerateTailCall(masm(), stub.GetCode()); | 988 GenerateTailCall(masm(), stub.GetCode()); |
| 974 } | 989 } |
| 975 } | 990 } |
| 976 | 991 |
| 977 | 992 |
| 978 void LoadStubCompiler::GenerateLoadCallback( | 993 void LoadStubCompiler::GenerateLoadCallback( |
| 979 Register reg, | 994 Register reg, |
| 980 Handle<ExecutableAccessorInfo> callback) { | 995 Handle<ExecutableAccessorInfo> callback) { |
| 981 // Insert additional parameters into the stack frame above return address. | 996 // Insert additional parameters into the stack frame above return address. |
| 982 ASSERT(!scratch3().is(reg)); | 997 ASSERT(!scratch3().is(reg)); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1484 // ----------------------------------- | 1499 // ----------------------------------- |
| 1485 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); | 1500 TailCallBuiltin(masm, Builtins::kKeyedLoadIC_Miss); |
| 1486 } | 1501 } |
| 1487 | 1502 |
| 1488 | 1503 |
| 1489 #undef __ | 1504 #undef __ |
| 1490 | 1505 |
| 1491 } } // namespace v8::internal | 1506 } } // namespace v8::internal |
| 1492 | 1507 |
| 1493 #endif // V8_TARGET_ARCH_X87 | 1508 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |