| 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 | 278 |
| 279 | 279 |
| 280 Handle<Object> GetPrototype(Handle<Object> obj) { | 280 Handle<Object> GetPrototype(Handle<Object> obj) { |
| 281 Handle<Object> result(obj->GetPrototype()); | 281 Handle<Object> result(obj->GetPrototype()); |
| 282 return result; | 282 return result; |
| 283 } | 283 } |
| 284 | 284 |
| 285 | 285 |
| 286 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, | 286 Handle<Object> GetHiddenProperties(Handle<JSObject> obj, |
| 287 bool create_if_needed) { | 287 bool create_if_needed) { |
| 288 Handle<String> key = Factory::hidden_symbol(); | 288 Object* holder = obj->BypassGlobalProxy(); |
| 289 if (holder->IsUndefined()) return Factory::undefined_value(); |
| 290 obj = Handle<JSObject>(JSObject::cast(holder)); |
| 289 | 291 |
| 290 if (obj->HasFastProperties()) { | 292 if (obj->HasFastProperties()) { |
| 291 // If the object has fast properties, check whether the first slot | 293 // If the object has fast properties, check whether the first slot |
| 292 // in the descriptor array matches the hidden symbol. Since the | 294 // in the descriptor array matches the hidden symbol. Since the |
| 293 // hidden symbols hash code is zero (and no other string has hash | 295 // hidden symbols hash code is zero (and no other string has hash |
| 294 // code zero) it will always occupy the first entry if present. | 296 // code zero) it will always occupy the first entry if present. |
| 295 DescriptorArray* descriptors = obj->map()->instance_descriptors(); | 297 DescriptorArray* descriptors = obj->map()->instance_descriptors(); |
| 296 if ((descriptors->number_of_descriptors() > 0) && | 298 if ((descriptors->number_of_descriptors() > 0) && |
| 297 (descriptors->GetKey(0) == *key) && | 299 (descriptors->GetKey(0) == Heap::hidden_symbol()) && |
| 298 descriptors->IsProperty(0)) { | 300 descriptors->IsProperty(0)) { |
| 299 ASSERT(descriptors->GetType(0) == FIELD); | 301 ASSERT(descriptors->GetType(0) == FIELD); |
| 300 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0))); | 302 return Handle<Object>(obj->FastPropertyAt(descriptors->GetFieldIndex(0))); |
| 301 } | 303 } |
| 302 } | 304 } |
| 303 | 305 |
| 304 // Only attempt to find the hidden properties in the local object and not | 306 // Only attempt to find the hidden properties in the local object and not |
| 305 // in the prototype chain. Note that HasLocalProperty() can cause a GC in | 307 // in the prototype chain. Note that HasLocalProperty() can cause a GC in |
| 306 // the general case in the presence of interceptors. | 308 // the general case in the presence of interceptors. |
| 307 if (!obj->HasLocalProperty(*key)) { | 309 if (!obj->HasHiddenPropertiesObject()) { |
| 308 // Hidden properties object not found. Allocate a new hidden properties | 310 // Hidden properties object not found. Allocate a new hidden properties |
| 309 // object if requested. Otherwise return the undefined value. | 311 // object if requested. Otherwise return the undefined value. |
| 310 if (create_if_needed) { | 312 if (create_if_needed) { |
| 311 Handle<Object> hidden_obj = Factory::NewJSObject(Top::object_function()); | 313 Handle<Object> hidden_obj = Factory::NewJSObject(Top::object_function()); |
| 312 return SetProperty(obj, key, hidden_obj, DONT_ENUM); | 314 return Handle<Object>(obj->SetHiddenPropertiesObject(*hidden_obj)); |
| 313 } else { | 315 } else { |
| 314 return Factory::undefined_value(); | 316 return Factory::undefined_value(); |
| 315 } | 317 } |
| 316 } | 318 } |
| 317 return GetProperty(obj, key); | 319 return Handle<Object>(obj->GetHiddenPropertiesObject()); |
| 318 } | 320 } |
| 319 | 321 |
| 320 | 322 |
| 321 Handle<Object> DeleteElement(Handle<JSObject> obj, | 323 Handle<Object> DeleteElement(Handle<JSObject> obj, |
| 322 uint32_t index) { | 324 uint32_t index) { |
| 323 CALL_HEAP_FUNCTION(obj->DeleteElement(index, JSObject::NORMAL_DELETION), | 325 CALL_HEAP_FUNCTION(obj->DeleteElement(index, JSObject::NORMAL_DELETION), |
| 324 Object); | 326 Object); |
| 325 } | 327 } |
| 326 | 328 |
| 327 | 329 |
| (...skipping 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 759 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
| 758 obj->set_map(*new_map); | 760 obj->set_map(*new_map); |
| 759 new_map->set_needs_loading(true); | 761 new_map->set_needs_loading(true); |
| 760 // Store the lazy loading info in the constructor field. We'll | 762 // Store the lazy loading info in the constructor field. We'll |
| 761 // reestablish the constructor from the fixed array after loading. | 763 // reestablish the constructor from the fixed array after loading. |
| 762 new_map->set_constructor(*arr); | 764 new_map->set_constructor(*arr); |
| 763 ASSERT(!obj->IsLoaded()); | 765 ASSERT(!obj->IsLoaded()); |
| 764 } | 766 } |
| 765 | 767 |
| 766 } } // namespace v8::internal | 768 } } // namespace v8::internal |
| OLD | NEW |