Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Side by Side Diff: src/ia32/stub-cache-ia32.cc

Issue 12810006: Change LookupForWrite to always do a full lookup and check the result. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 712 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 __ bind(label); 723 __ bind(label);
724 __ mov(this->name(), Immediate(name)); 724 __ mov(this->name(), Immediate(name));
725 } 725 }
726 } 726 }
727 727
728 728
729 // Both name_reg and receiver_reg are preserved on jumps to miss_label, 729 // Both name_reg and receiver_reg are preserved on jumps to miss_label,
730 // but may be destroyed if store is successful. 730 // but may be destroyed if store is successful.
731 void StubCompiler::GenerateStoreField(MacroAssembler* masm, 731 void StubCompiler::GenerateStoreField(MacroAssembler* masm,
732 Handle<JSObject> object, 732 Handle<JSObject> object,
733 int index, 733 LookupResult* lookup,
734 Handle<Map> transition, 734 Handle<Map> transition,
735 Handle<Name> name, 735 Handle<Name> name,
736 Register receiver_reg, 736 Register receiver_reg,
737 Register name_reg, 737 Register name_reg,
738 Register value_reg, 738 Register value_reg,
739 Register scratch1, 739 Register scratch1,
740 Register scratch2, 740 Register scratch2,
741 Label* miss_label, 741 Label* miss_label,
742 Label* miss_restore_name) { 742 Label* miss_restore_name) {
743 LookupResult lookup(masm->isolate());
744 object->Lookup(*name, &lookup);
745 if (lookup.IsFound() && (lookup.IsReadOnly() || !lookup.IsCacheable())) {
746 // In sloppy mode, we could just return the value and be done. However, we
747 // might be in strict mode, where we have to throw. Since we cannot tell,
748 // go into slow case unconditionally.
749 __ jmp(miss_label);
750 return;
751 }
752
753 // Check that the map of the object hasn't changed. 743 // Check that the map of the object hasn't changed.
754 CompareMapMode mode = transition.is_null() ? ALLOW_ELEMENT_TRANSITION_MAPS 744 CompareMapMode mode = transition.is_null() ? ALLOW_ELEMENT_TRANSITION_MAPS
755 : REQUIRE_EXACT_MAP; 745 : REQUIRE_EXACT_MAP;
756 __ CheckMap(receiver_reg, Handle<Map>(object->map()), 746 __ CheckMap(receiver_reg, Handle<Map>(object->map()),
757 miss_label, DO_SMI_CHECK, mode); 747 miss_label, DO_SMI_CHECK, mode);
758 748
759 // Perform global security token check if needed. 749 // Perform global security token check if needed.
760 if (object->IsJSGlobalProxy()) { 750 if (object->IsJSGlobalProxy()) {
761 __ CheckAccessGlobalProxy(receiver_reg, scratch1, miss_label); 751 __ CheckAccessGlobalProxy(receiver_reg, scratch1, miss_label);
762 } 752 }
763 753
764 // Check that we are allowed to write this. 754 // Check that we are allowed to write this.
765 if (!transition.is_null() && object->GetPrototype()->IsJSObject()) { 755 if (!transition.is_null() && object->GetPrototype()->IsJSObject()) {
766 JSObject* holder; 756 JSObject* holder;
767 if (lookup.IsFound()) { 757 // holder == object indicates that no property was found.
768 holder = lookup.holder(); 758 if (lookup->holder() != *object) {
759 holder = lookup->holder();
769 } else { 760 } else {
770 // Find the top object. 761 // Find the top object.
771 holder = *object; 762 holder = *object;
772 do { 763 do {
773 holder = JSObject::cast(holder->GetPrototype()); 764 holder = JSObject::cast(holder->GetPrototype());
774 } while (holder->GetPrototype()->IsJSObject()); 765 } while (holder->GetPrototype()->IsJSObject());
775 } 766 }
776 // We need an extra register, push 767 // We need an extra register, push
777 CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg, 768 Register holder_reg = CheckPrototypes(
778 scratch1, scratch2, name, miss_restore_name); 769 object, receiver_reg, Handle<JSObject>(holder), name_reg,
770 scratch1, scratch2, name, miss_restore_name);
771 // If no property was found, and the holder (the last object in the
772 // prototype chain) is in slow mode, we need to do a negative lookup on the
773 // holder.
774 if (lookup->holder() == *object &&
775 !holder->HasFastProperties() &&
776 !holder->IsJSGlobalProxy() &&
777 !holder->IsJSGlobalObject()) {
778 GenerateDictionaryNegativeLookup(
779 masm, miss_restore_name, holder_reg, name, scratch1, scratch2);
780 }
779 } 781 }
780 782
781 // Stub never generated for non-global objects that require access 783 // Stub never generated for non-global objects that require access
782 // checks. 784 // checks.
783 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded()); 785 ASSERT(object->IsJSGlobalProxy() || !object->IsAccessCheckNeeded());
784 786
785 // Perform map transition for the receiver if necessary. 787 // Perform map transition for the receiver if necessary.
786 if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) { 788 if (!transition.is_null() && (object->map()->unused_property_fields() == 0)) {
787 // The properties must be extended before we can store the value. 789 // The properties must be extended before we can store the value.
788 // We jump to a runtime call that extends the properties array. 790 // We jump to a runtime call that extends the properties array.
789 __ pop(scratch1); // Return address. 791 __ pop(scratch1); // Return address.
790 __ push(receiver_reg); 792 __ push(receiver_reg);
791 __ push(Immediate(transition)); 793 __ push(Immediate(transition));
792 __ push(eax); 794 __ push(eax);
793 __ push(scratch1); 795 __ push(scratch1);
794 __ TailCallExternalReference( 796 __ TailCallExternalReference(
795 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), 797 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
796 masm->isolate()), 798 masm->isolate()),
797 3, 799 3,
798 1); 800 1);
799 return; 801 return;
800 } 802 }
801 803
804 int index;
802 if (!transition.is_null()) { 805 if (!transition.is_null()) {
803 // Update the map of the object. 806 // Update the map of the object.
804 __ mov(scratch1, Immediate(transition)); 807 __ mov(scratch1, Immediate(transition));
805 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1); 808 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1);
806 809
807 // Update the write barrier for the map field and pass the now unused 810 // Update the write barrier for the map field and pass the now unused
808 // name_reg as scratch register. 811 // name_reg as scratch register.
809 __ RecordWriteField(receiver_reg, 812 __ RecordWriteField(receiver_reg,
810 HeapObject::kMapOffset, 813 HeapObject::kMapOffset,
811 scratch1, 814 scratch1,
812 name_reg, 815 name_reg,
813 kDontSaveFPRegs, 816 kDontSaveFPRegs,
814 OMIT_REMEMBERED_SET, 817 OMIT_REMEMBERED_SET,
815 OMIT_SMI_CHECK); 818 OMIT_SMI_CHECK);
819 index = transition->instance_descriptors()->GetFieldIndex(
820 transition->LastAdded());
821 } else {
822 index = lookup->GetFieldIndex().field_index();
816 } 823 }
817 824
825
818 // Adjust for the number of properties stored in the object. Even in the 826 // Adjust for the number of properties stored in the object. Even in the
819 // face of a transition we can use the old map here because the size of the 827 // face of a transition we can use the old map here because the size of the
820 // object and the number of in-object properties is not going to change. 828 // object and the number of in-object properties is not going to change.
821 index -= object->map()->inobject_properties(); 829 index -= object->map()->inobject_properties();
822 830
823 if (index < 0) { 831 if (index < 0) {
824 // Set the property straight into the object. 832 // Set the property straight into the object.
825 int offset = object->map()->instance_size() + (index * kPointerSize); 833 int offset = object->map()->instance_size() + (index * kPointerSize);
826 __ mov(FieldOperand(receiver_reg, offset), value_reg); 834 __ mov(FieldOperand(receiver_reg, offset), value_reg);
827 835
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3621 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3614 } 3622 }
3615 } 3623 }
3616 3624
3617 3625
3618 #undef __ 3626 #undef __
3619 3627
3620 } } // namespace v8::internal 3628 } } // namespace v8::internal
3621 3629
3622 #endif // V8_TARGET_ARCH_IA32 3630 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698