| OLD | NEW |
| 1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 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 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 | 294 |
| 295 | 295 |
| 296 Handle<Object> GetPrototype(Handle<Object> obj) { | 296 Handle<Object> GetPrototype(Handle<Object> obj) { |
| 297 Handle<Object> result(obj->GetPrototype()); | 297 Handle<Object> result(obj->GetPrototype()); |
| 298 return result; | 298 return result; |
| 299 } | 299 } |
| 300 | 300 |
| 301 | 301 |
| 302 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, | 302 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, |
| 303 bool create_if_needed) { | 303 bool create_if_needed) { |
| 304 Handle<String> key = Factory::hidden_symbol(); | 304 Object* holder = obj->BypassGlobalProxy(); |
| 305 if (holder->IsUndefined()) return Factory::undefined_value(); |
| 306 obj = Handle<JSObject>(JSObject::cast(holder)); |
| 305 | 307 |
| 306 if (obj->HasFastProperties()) { | 308 if (obj->HasFastProperties()) { |
| 307 // If the object has fast properties, check whether the first slot | 309 // If the object has fast properties, check whether the first slot |
| 308 // in the descriptor array matches the hidden symbol. Since the | 310 // in the descriptor array matches the hidden symbol. Since the |
| 309 // hidden symbols hash code is zero (and no other string has hash | 311 // hidden symbols hash code is zero (and no other string has hash |
| 310 // code zero) it will always occupy the first entry if present. | 312 // code zero) it will always occupy the first entry if present. |
| 311 DescriptorArray* descriptors = obj->map()->instance_descriptors(); | 313 DescriptorArray* descriptors = obj->map()->instance_descriptors(); |
| 312 if ((descriptors->number_of_descriptors() > 0) && | 314 if ((descriptors->number_of_descriptors() > 0) && |
| 313 (descriptors->GetKey(0) == *key) && | 315 (descriptors->GetKey(0) == Heap::hidden_symbol()) && |
| 314 descriptors->IsProperty(0)) { | 316 descriptors->IsProperty(0)) { |
| 315 ASSERT(descriptors->GetType(0) == FIELD); | 317 ASSERT(descriptors->GetType(0) == FIELD); |
| 316 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0))); | 318 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0))); |
| 317 } | 319 } |
| 318 } | 320 } |
| 319 | 321 |
| 320 // Only attempt to find the hidden properties in the local object and not | 322 // Only attempt to find the hidden properties in the local object and not |
| 321 // in the prototype chain. Note that HasLocalProperty() can cause a GC in | 323 // in the prototype chain. Note that HasLocalProperty() can cause a GC in |
| 322 // the general case in the presence of interceptors. | 324 // the general case in the presence of interceptors. |
| 323 if (!obj->HasLocalProperty(*key)) { | 325 if (!obj->HasHiddenPropertiesObject()) { |
| 324 // Hidden properties object not found. Allocate a new hidden properties | 326 // Hidden properties object not found. Allocate a new hidden properties |
| 325 // object if requested. Otherwise return the undefined value. | 327 // object if requested. Otherwise return the undefined value. |
| 326 if (create_if_needed) { | 328 if (create_if_needed) { |
| 327 Handle<Object> hidden_obj = Factory::NewJSObject(Top::object_function()); | 329 Handle<Object> hidden_obj = Factory::NewJSObject(Top::object_function()); |
| 328 return SetProperty(obj, key, hidden_obj, DONT_ENUM); | 330 return Handle<Object>(obj->SetHiddenPropertiesObject(*hidden_obj)); |
| 329 } else { | 331 } else { |
| 330 return Factory::undefined_value(); | 332 return Factory::undefined_value(); |
| 331 } | 333 } |
| 332 } | 334 } |
| 333 return GetProperty(obj, key); | 335 return Handle<Object>(obj->GetHiddenPropertiesObject()); |
| 334 } | 336 } |
| 335 | 337 |
| 336 | 338 |
| 337 Handle<Object> DeleteElement(Handle<JSObject> obj, | 339 Handle<Object> DeleteElement(Handle<JSObject> obj, |
| 338 uint32_t index) { | 340 uint32_t index) { |
| 339 CALL_HEAP_FUNCTION(obj->DeleteElement(index, JSObject::NORMAL_DELETION), | 341 CALL_HEAP_FUNCTION(obj->DeleteElement(index, JSObject::NORMAL_DELETION), |
| 340 Object); | 342 Object); |
| 341 } | 343 } |
| 342 | 344 |
| 343 | 345 |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 780 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
| 779 obj->set_map(*new_map); | 781 obj->set_map(*new_map); |
| 780 new_map->set_needs_loading(true); | 782 new_map->set_needs_loading(true); |
| 781 // Store the lazy loading info in the constructor field. We'll | 783 // Store the lazy loading info in the constructor field. We'll |
| 782 // reestablish the constructor from the fixed array after loading. | 784 // reestablish the constructor from the fixed array after loading. |
| 783 new_map->set_constructor(*arr); | 785 new_map->set_constructor(*arr); |
| 784 ASSERT(!obj->IsLoaded()); | 786 ASSERT(!obj->IsLoaded()); |
| 785 } | 787 } |
| 786 | 788 |
| 787 } } // namespace v8::internal | 789 } } // namespace v8::internal |
| OLD | NEW |