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

Side by Side Diff: src/objects.cc

Issue 93004: Adding hidden values always turned the object slow case because the... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 11 years, 8 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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1111 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 set_properties(FixedArray::cast(values)); 1122 set_properties(FixedArray::cast(values));
1123 } 1123 }
1124 set_map(new_map); 1124 set_map(new_map);
1125 return FastPropertyAtPut(index, value); 1125 return FastPropertyAtPut(index, value);
1126 } 1126 }
1127 1127
1128 1128
1129 Object* JSObject::AddFastProperty(String* name, 1129 Object* JSObject::AddFastProperty(String* name,
1130 Object* value, 1130 Object* value,
1131 PropertyAttributes attributes) { 1131 PropertyAttributes attributes) {
1132 // Normalize the object if the name is not a real identifier. 1132 // Normalize the object if the name is an actual string (not the
1133 // hidden symbols) and is not a real identifier.
1133 StringInputBuffer buffer(name); 1134 StringInputBuffer buffer(name);
1134 if (!Scanner::IsIdentifier(&buffer)) { 1135 if (!Scanner::IsIdentifier(&buffer) && name != Heap::hidden_symbol()) {
1135 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES); 1136 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES);
1136 if (obj->IsFailure()) return obj; 1137 if (obj->IsFailure()) return obj;
1137 return AddSlowProperty(name, value, attributes); 1138 return AddSlowProperty(name, value, attributes);
1138 } 1139 }
1139 1140
1140 DescriptorArray* old_descriptors = map()->instance_descriptors(); 1141 DescriptorArray* old_descriptors = map()->instance_descriptors();
1141 // Compute the new index for new field. 1142 // Compute the new index for new field.
1142 int index = map()->NextFreePropertyIndex(); 1143 int index = map()->NextFreePropertyIndex();
1143 1144
1144 // Allocate new instance descriptors with (name, index) added 1145 // Allocate new instance descriptors with (name, index) added
(...skipping 4020 matching lines...) Expand 10 before | Expand all | Expand 10 after
5165 !FixedArray::cast(elements())->get(index)->IsTheHole(); 5166 !FixedArray::cast(elements())->get(index)->IsTheHole();
5166 } else { 5167 } else {
5167 return element_dictionary()->FindNumberEntry(index) != -1; 5168 return element_dictionary()->FindNumberEntry(index) != -1;
5168 } 5169 }
5169 } 5170 }
5170 5171
5171 5172
5172 Object* JSObject::GetHiddenProperties(bool create_if_needed) { 5173 Object* JSObject::GetHiddenProperties(bool create_if_needed) {
5173 String* key = Heap::hidden_symbol(); 5174 String* key = Heap::hidden_symbol();
5174 if (this->HasFastProperties()) { 5175 if (this->HasFastProperties()) {
5175 // If the object has fast properties, check whether the first slot in the 5176 // If the object has fast properties, check whether the first slot
5176 // descriptor array matches the hidden symbol. Since the hidden symbols 5177 // in the descriptor array matches the hidden symbol. Since the
5177 // hash code is zero it will always occupy the first entry if present. 5178 // hidden symbols hash code is zero (and no other string has hash
5179 // code zero) it will always occupy the first entry if present.
5178 DescriptorArray* descriptors = this->map()->instance_descriptors(); 5180 DescriptorArray* descriptors = this->map()->instance_descriptors();
5179 if (descriptors->number_of_descriptors() > 0) { 5181 DescriptorReader r(descriptors);
5180 if (descriptors->GetKey(0) == key) { 5182 if (!r.eos() && (r.GetKey() == key) && r.IsProperty()) {
5181 #ifdef DEBUG 5183 ASSERT(r.type() == FIELD);
5182 PropertyDetails details(descriptors->GetDetails(0)); 5184 return FastPropertyAt(r.GetFieldIndex());
5183 ASSERT(details.type() == FIELD);
5184 #endif // DEBUG
5185 Object* value = descriptors->GetValue(0);
5186 return FastPropertyAt(Descriptor::IndexFromValue(value));
5187 }
5188 } 5185 }
5189 } 5186 }
5190 5187
5191 // Only attempt to find the hidden properties in the local object and not 5188 // Only attempt to find the hidden properties in the local object and not
5192 // in the prototype chain. 5189 // in the prototype chain.
5193 if (!this->HasLocalProperty(key)) { 5190 if (!this->HasLocalProperty(key)) {
5194 // Hidden properties object not found. Allocate a new hidden properties 5191 // Hidden properties object not found. Allocate a new hidden properties
5195 // object if requested. Otherwise return the undefined value. 5192 // object if requested. Otherwise return the undefined value.
5196 if (create_if_needed) { 5193 if (create_if_needed) {
5197 Object* obj = Heap::AllocateJSObject( 5194 Object* obj = Heap::AllocateJSObject(
(...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after
7415 // No break point. 7412 // No break point.
7416 if (break_point_objects()->IsUndefined()) return 0; 7413 if (break_point_objects()->IsUndefined()) return 0;
7417 // Single beak point. 7414 // Single beak point.
7418 if (!break_point_objects()->IsFixedArray()) return 1; 7415 if (!break_point_objects()->IsFixedArray()) return 1;
7419 // Multiple break points. 7416 // Multiple break points.
7420 return FixedArray::cast(break_point_objects())->length(); 7417 return FixedArray::cast(break_point_objects())->length();
7421 } 7418 }
7422 #endif 7419 #endif
7423 7420
7424 } } // namespace v8::internal 7421 } } // 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