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

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: Check callbacks in the prototype chain before looking for transitions. Fix !IsReadOnly 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') | src/ic.cc » ('J')
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 if (lookup->IsFound()) {
768 holder = lookup.holder(); 758 holder = lookup->holder();
769 } else { 759 } else {
770 // Find the top object. 760 // Find the top object.
771 holder = *object; 761 holder = *object;
772 do { 762 do {
773 holder = JSObject::cast(holder->GetPrototype()); 763 holder = JSObject::cast(holder->GetPrototype());
774 } while (holder->GetPrototype()->IsJSObject()); 764 } while (holder->GetPrototype()->IsJSObject());
775 } 765 }
776 // We need an extra register, push 766 // We need an extra register, push
777 CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg, 767 CheckPrototypes(object, receiver_reg, Handle<JSObject>(holder), name_reg,
778 scratch1, scratch2, name, miss_restore_name); 768 scratch1, scratch2, name, miss_restore_name);
(...skipping 13 matching lines...) Expand all
792 __ push(eax); 782 __ push(eax);
793 __ push(scratch1); 783 __ push(scratch1);
794 __ TailCallExternalReference( 784 __ TailCallExternalReference(
795 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage), 785 ExternalReference(IC_Utility(IC::kSharedStoreIC_ExtendStorage),
796 masm->isolate()), 786 masm->isolate()),
797 3, 787 3,
798 1); 788 1);
799 return; 789 return;
800 } 790 }
801 791
792 int index;
802 if (!transition.is_null()) { 793 if (!transition.is_null()) {
803 // Update the map of the object. 794 // Update the map of the object.
804 __ mov(scratch1, Immediate(transition)); 795 __ mov(scratch1, Immediate(transition));
805 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1); 796 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), scratch1);
806 797
807 // Update the write barrier for the map field and pass the now unused 798 // Update the write barrier for the map field and pass the now unused
808 // name_reg as scratch register. 799 // name_reg as scratch register.
809 __ RecordWriteField(receiver_reg, 800 __ RecordWriteField(receiver_reg,
810 HeapObject::kMapOffset, 801 HeapObject::kMapOffset,
811 scratch1, 802 scratch1,
812 name_reg, 803 name_reg,
813 kDontSaveFPRegs, 804 kDontSaveFPRegs,
814 OMIT_REMEMBERED_SET, 805 OMIT_REMEMBERED_SET,
815 OMIT_SMI_CHECK); 806 OMIT_SMI_CHECK);
807 index = transition->instance_descriptors()->GetFieldIndex(
808 transition->LastAdded());
809 } else {
810 index = lookup->GetFieldIndex().field_index();
816 } 811 }
817 812
813
818 // Adjust for the number of properties stored in the object. Even in the 814 // 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 815 // 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. 816 // object and the number of in-object properties is not going to change.
821 index -= object->map()->inobject_properties(); 817 index -= object->map()->inobject_properties();
822 818
823 if (index < 0) { 819 if (index < 0) {
824 // Set the property straight into the object. 820 // Set the property straight into the object.
825 int offset = object->map()->instance_size() + (index * kPointerSize); 821 int offset = object->map()->instance_size() + (index * kPointerSize);
826 __ mov(FieldOperand(receiver_reg, offset), value_reg); 822 __ mov(FieldOperand(receiver_reg, offset), value_reg);
827 823
(...skipping 2785 matching lines...) Expand 10 before | Expand all | Expand 10 after
3613 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow); 3609 TailCallBuiltin(masm, Builtins::kKeyedStoreIC_Slow);
3614 } 3610 }
3615 } 3611 }
3616 3612
3617 3613
3618 #undef __ 3614 #undef __
3619 3615
3620 } } // namespace v8::internal 3616 } } // namespace v8::internal
3621 3617
3622 #endif // V8_TARGET_ARCH_IA32 3618 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/arm/stub-cache-arm.cc ('k') | src/ic.cc » ('j') | src/ic.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698