| OLD | NEW |
| 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 1127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1138 set_properties(FixedArray::cast(values)); | 1138 set_properties(FixedArray::cast(values)); |
| 1139 } | 1139 } |
| 1140 set_map(new_map); | 1140 set_map(new_map); |
| 1141 return FastPropertyAtPut(index, value); | 1141 return FastPropertyAtPut(index, value); |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 | 1144 |
| 1145 Object* JSObject::AddFastProperty(String* name, | 1145 Object* JSObject::AddFastProperty(String* name, |
| 1146 Object* value, | 1146 Object* value, |
| 1147 PropertyAttributes attributes) { | 1147 PropertyAttributes attributes) { |
| 1148 // Normalize the object if the name is not a real identifier. | 1148 // Normalize the object if the name is an actual string (not the |
| 1149 // hidden symbols) and is not a real identifier. |
| 1149 StringInputBuffer buffer(name); | 1150 StringInputBuffer buffer(name); |
| 1150 if (!Scanner::IsIdentifier(&buffer)) { | 1151 if (!Scanner::IsIdentifier(&buffer) && name != Heap::hidden_symbol()) { |
| 1151 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES); | 1152 Object* obj = NormalizeProperties(CLEAR_INOBJECT_PROPERTIES); |
| 1152 if (obj->IsFailure()) return obj; | 1153 if (obj->IsFailure()) return obj; |
| 1153 return AddSlowProperty(name, value, attributes); | 1154 return AddSlowProperty(name, value, attributes); |
| 1154 } | 1155 } |
| 1155 | 1156 |
| 1156 DescriptorArray* old_descriptors = map()->instance_descriptors(); | 1157 DescriptorArray* old_descriptors = map()->instance_descriptors(); |
| 1157 // Compute the new index for new field. | 1158 // Compute the new index for new field. |
| 1158 int index = map()->NextFreePropertyIndex(); | 1159 int index = map()->NextFreePropertyIndex(); |
| 1159 | 1160 |
| 1160 // Allocate new instance descriptors with (name, index) added | 1161 // Allocate new instance descriptors with (name, index) added |
| (...skipping 4007 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5168 !FixedArray::cast(elements())->get(index)->IsTheHole(); | 5169 !FixedArray::cast(elements())->get(index)->IsTheHole(); |
| 5169 } else { | 5170 } else { |
| 5170 return element_dictionary()->FindNumberEntry(index) != -1; | 5171 return element_dictionary()->FindNumberEntry(index) != -1; |
| 5171 } | 5172 } |
| 5172 } | 5173 } |
| 5173 | 5174 |
| 5174 | 5175 |
| 5175 Object* JSObject::GetHiddenProperties(bool create_if_needed) { | 5176 Object* JSObject::GetHiddenProperties(bool create_if_needed) { |
| 5176 String* key = Heap::hidden_symbol(); | 5177 String* key = Heap::hidden_symbol(); |
| 5177 if (this->HasFastProperties()) { | 5178 if (this->HasFastProperties()) { |
| 5178 // If the object has fast properties, check whether the first slot in the | 5179 // If the object has fast properties, check whether the first slot |
| 5179 // descriptor array matches the hidden symbol. Since the hidden symbols | 5180 // in the descriptor array matches the hidden symbol. Since the |
| 5180 // hash code is zero it will always occupy the first entry if present. | 5181 // hidden symbols hash code is zero (and no other string has hash |
| 5182 // code zero) it will always occupy the first entry if present. |
| 5181 DescriptorArray* descriptors = this->map()->instance_descriptors(); | 5183 DescriptorArray* descriptors = this->map()->instance_descriptors(); |
| 5182 if (descriptors->number_of_descriptors() > 0) { | 5184 DescriptorReader r(descriptors); |
| 5183 if (descriptors->GetKey(0) == key) { | 5185 if (!r.eos() && (r.GetKey() == key) && r.IsProperty()) { |
| 5184 #ifdef DEBUG | 5186 ASSERT(r.type() == FIELD); |
| 5185 PropertyDetails details(descriptors->GetDetails(0)); | 5187 return FastPropertyAt(r.GetFieldIndex()); |
| 5186 ASSERT(details.type() == FIELD); | |
| 5187 #endif // DEBUG | |
| 5188 Object* value = descriptors->GetValue(0); | |
| 5189 return FastPropertyAt(Descriptor::IndexFromValue(value)); | |
| 5190 } | |
| 5191 } | 5188 } |
| 5192 } | 5189 } |
| 5193 | 5190 |
| 5194 // Only attempt to find the hidden properties in the local object and not | 5191 // Only attempt to find the hidden properties in the local object and not |
| 5195 // in the prototype chain. | 5192 // in the prototype chain. |
| 5196 if (!this->HasLocalProperty(key)) { | 5193 if (!this->HasLocalProperty(key)) { |
| 5197 // Hidden properties object not found. Allocate a new hidden properties | 5194 // Hidden properties object not found. Allocate a new hidden properties |
| 5198 // object if requested. Otherwise return the undefined value. | 5195 // object if requested. Otherwise return the undefined value. |
| 5199 if (create_if_needed) { | 5196 if (create_if_needed) { |
| 5200 Object* obj = Heap::AllocateJSObject( | 5197 Object* obj = Heap::AllocateJSObject( |
| (...skipping 2217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7418 // No break point. | 7415 // No break point. |
| 7419 if (break_point_objects()->IsUndefined()) return 0; | 7416 if (break_point_objects()->IsUndefined()) return 0; |
| 7420 // Single beak point. | 7417 // Single beak point. |
| 7421 if (!break_point_objects()->IsFixedArray()) return 1; | 7418 if (!break_point_objects()->IsFixedArray()) return 1; |
| 7422 // Multiple break points. | 7419 // Multiple break points. |
| 7423 return FixedArray::cast(break_point_objects())->length(); | 7420 return FixedArray::cast(break_point_objects())->length(); |
| 7424 } | 7421 } |
| 7425 | 7422 |
| 7426 | 7423 |
| 7427 } } // namespace v8::internal | 7424 } } // namespace v8::internal |
| OLD | NEW |