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

Side by Side Diff: src/objects.cc

Issue 9352012: DescriptorArray::IsProperty-related cleanup. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 years, 10 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 | « no previous file | no next file » | 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 3755 matching lines...) Expand 10 before | Expand all | Expand 10 after
3766 3766
3767 MaybeObject* JSObject::GetHiddenPropertiesDictionary(bool create_if_absent) { 3767 MaybeObject* JSObject::GetHiddenPropertiesDictionary(bool create_if_absent) {
3768 ASSERT(!IsJSGlobalProxy()); 3768 ASSERT(!IsJSGlobalProxy());
3769 if (HasFastProperties()) { 3769 if (HasFastProperties()) {
3770 // If the object has fast properties, check whether the first slot 3770 // If the object has fast properties, check whether the first slot
3771 // in the descriptor array matches the hidden symbol. Since the 3771 // in the descriptor array matches the hidden symbol. Since the
3772 // hidden symbols hash code is zero (and no other string has hash 3772 // hidden symbols hash code is zero (and no other string has hash
3773 // code zero) it will always occupy the first entry if present. 3773 // code zero) it will always occupy the first entry if present.
3774 DescriptorArray* descriptors = this->map()->instance_descriptors(); 3774 DescriptorArray* descriptors = this->map()->instance_descriptors();
3775 if ((descriptors->number_of_descriptors() > 0) && 3775 if ((descriptors->number_of_descriptors() > 0) &&
3776 (descriptors->GetKey(0) == GetHeap()->hidden_symbol()) && 3776 (descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
3777 descriptors->IsProperty(0)) { 3777 if (descriptors->GetType(0) == FIELD) {
3778 ASSERT(descriptors->GetType(0) == FIELD); 3778 Object* hidden_store =
3779 Object* hidden_store = 3779 this->FastPropertyAt(descriptors->GetFieldIndex(0));
3780 this->FastPropertyAt(descriptors->GetFieldIndex(0)); 3780 return StringDictionary::cast(hidden_store);
3781 return StringDictionary::cast(hidden_store); 3781 } else {
3782 ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
3783 }
3782 } 3784 }
3783 } else { 3785 } else {
3784 PropertyAttributes attributes; 3786 PropertyAttributes attributes;
3785 // You can't install a getter on a property indexed by the hidden symbol, 3787 // You can't install a getter on a property indexed by the hidden symbol,
3786 // so we can be sure that GetLocalPropertyPostInterceptor returns a real 3788 // so we can be sure that GetLocalPropertyPostInterceptor returns a real
3787 // object. 3789 // object.
3788 Object* lookup = 3790 Object* lookup =
3789 GetLocalPropertyPostInterceptor(this, 3791 GetLocalPropertyPostInterceptor(this,
3790 GetHeap()->hidden_symbol(), 3792 GetHeap()->hidden_symbol(),
3791 &attributes)->ToObjectUnchecked(); 3793 &attributes)->ToObjectUnchecked();
(...skipping 20 matching lines...) Expand all
3812 StringDictionary* dictionary) { 3814 StringDictionary* dictionary) {
3813 ASSERT(!IsJSGlobalProxy()); 3815 ASSERT(!IsJSGlobalProxy());
3814 ASSERT(HasHiddenProperties()); 3816 ASSERT(HasHiddenProperties());
3815 if (HasFastProperties()) { 3817 if (HasFastProperties()) {
3816 // If the object has fast properties, check whether the first slot 3818 // If the object has fast properties, check whether the first slot
3817 // in the descriptor array matches the hidden symbol. Since the 3819 // in the descriptor array matches the hidden symbol. Since the
3818 // hidden symbols hash code is zero (and no other string has hash 3820 // hidden symbols hash code is zero (and no other string has hash
3819 // code zero) it will always occupy the first entry if present. 3821 // code zero) it will always occupy the first entry if present.
3820 DescriptorArray* descriptors = this->map()->instance_descriptors(); 3822 DescriptorArray* descriptors = this->map()->instance_descriptors();
3821 if ((descriptors->number_of_descriptors() > 0) && 3823 if ((descriptors->number_of_descriptors() > 0) &&
3822 (descriptors->GetKey(0) == GetHeap()->hidden_symbol()) && 3824 (descriptors->GetKey(0) == GetHeap()->hidden_symbol())) {
3823 descriptors->IsProperty(0)) { 3825 if (descriptors->GetType(0) == FIELD) {
3824 ASSERT(descriptors->GetType(0) == FIELD); 3826 this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary);
3825 this->FastPropertyAtPut(descriptors->GetFieldIndex(0), dictionary); 3827 return this;
3826 return this; 3828 } else {
3829 ASSERT(descriptors->GetType(0) == MAP_TRANSITION);
3830 }
3827 } 3831 }
3828 } 3832 }
3829 MaybeObject* store_result = 3833 MaybeObject* store_result =
3830 SetPropertyPostInterceptor(GetHeap()->hidden_symbol(), 3834 SetPropertyPostInterceptor(GetHeap()->hidden_symbol(),
3831 dictionary, 3835 dictionary,
3832 DONT_ENUM, 3836 DONT_ENUM,
3833 kNonStrictMode); 3837 kNonStrictMode);
3834 if (store_result->IsFailure()) return store_result; 3838 if (store_result->IsFailure()) return store_result;
3835 return this; 3839 return this;
3836 } 3840 }
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after
5825 return new_descriptors; 5829 return new_descriptors;
5826 } 5830 }
5827 5831
5828 5832
5829 MaybeObject* DescriptorArray::RemoveTransitions() { 5833 MaybeObject* DescriptorArray::RemoveTransitions() {
5830 // Remove all transitions and null descriptors. Return a copy of the array 5834 // Remove all transitions and null descriptors. Return a copy of the array
5831 // with all transitions removed, or a Failure object if the new array could 5835 // with all transitions removed, or a Failure object if the new array could
5832 // not be allocated. 5836 // not be allocated.
5833 5837
5834 // Compute the size of the map transition entries to be removed. 5838 // Compute the size of the map transition entries to be removed.
5835 int num_removed = 0; 5839 int new_number_of_descriptors = 0;
5836 for (int i = 0; i < number_of_descriptors(); i++) { 5840 for (int i = 0; i < number_of_descriptors(); i++) {
5837 if (!IsProperty(i)) num_removed++; 5841 if (IsProperty(i)) new_number_of_descriptors++;
5838 } 5842 }
5839 5843
5840 // Allocate the new descriptor array. 5844 // Allocate the new descriptor array.
5841 DescriptorArray* new_descriptors; 5845 DescriptorArray* new_descriptors;
5842 { MaybeObject* maybe_result = Allocate(number_of_descriptors() - num_removed); 5846 { MaybeObject* maybe_result = Allocate(new_number_of_descriptors);
5843 if (!maybe_result->To<DescriptorArray>(&new_descriptors)) { 5847 if (!maybe_result->To<DescriptorArray>(&new_descriptors)) {
5844 return maybe_result; 5848 return maybe_result;
5845 } 5849 }
5846 } 5850 }
5847 5851
5848 DescriptorArray::WhitenessWitness witness(new_descriptors); 5852 DescriptorArray::WhitenessWitness witness(new_descriptors);
5849 5853
5850 // Copy the content. 5854 // Copy the content.
5851 int next_descriptor = 0; 5855 int next_descriptor = 0;
5852 for (int i = 0; i < number_of_descriptors(); i++) { 5856 for (int i = 0; i < number_of_descriptors(); i++) {
(...skipping 7174 matching lines...) Expand 10 before | Expand all | Expand 10 after
13027 if (break_point_objects()->IsUndefined()) return 0; 13031 if (break_point_objects()->IsUndefined()) return 0;
13028 // Single break point. 13032 // Single break point.
13029 if (!break_point_objects()->IsFixedArray()) return 1; 13033 if (!break_point_objects()->IsFixedArray()) return 1;
13030 // Multiple break points. 13034 // Multiple break points.
13031 return FixedArray::cast(break_point_objects())->length(); 13035 return FixedArray::cast(break_point_objects())->length();
13032 } 13036 }
13033 #endif // ENABLE_DEBUGGER_SUPPORT 13037 #endif // ENABLE_DEBUGGER_SUPPORT
13034 13038
13035 13039
13036 } } // namespace v8::internal 13040 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698