| 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 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 { | 520 { |
| 521 // Leaving JavaScript. | 521 // Leaving JavaScript. |
| 522 VMState state(EXTERNAL); | 522 VMState state(EXTERNAL); |
| 523 result = enum_fun(info); | 523 result = enum_fun(info); |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 return result; | 526 return result; |
| 527 } | 527 } |
| 528 | 528 |
| 529 | 529 |
| 530 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object) { | 530 Handle<FixedArray> GetKeysInFixedArrayFor(Handle<JSObject> object, |
| 531 KeyCollectionType type) { |
| 531 Handle<FixedArray> content = Factory::empty_fixed_array(); | 532 Handle<FixedArray> content = Factory::empty_fixed_array(); |
| 532 | 533 |
| 533 JSObject* arguments_boilerplate = | 534 JSObject* arguments_boilerplate = |
| 534 Top::context()->global_context()->arguments_boilerplate(); | 535 Top::context()->global_context()->arguments_boilerplate(); |
| 535 JSFunction* arguments_function = | 536 JSFunction* arguments_function = |
| 536 JSFunction::cast(arguments_boilerplate->map()->constructor()); | 537 JSFunction::cast(arguments_boilerplate->map()->constructor()); |
| 537 bool allow_enumeration = (object->map()->constructor() != arguments_function); | 538 bool allow_enumeration = (object->map()->constructor() != arguments_function); |
| 538 | 539 |
| 539 // Only collect keys if access is permitted. | 540 // Only collect keys if access is permitted. |
| 540 if (allow_enumeration) { | 541 if (allow_enumeration) { |
| (...skipping 27 matching lines...) Expand all Loading... |
| 568 // Compute the property keys. | 569 // Compute the property keys. |
| 569 content = UnionOfKeys(content, GetEnumPropertyKeys(current)); | 570 content = UnionOfKeys(content, GetEnumPropertyKeys(current)); |
| 570 | 571 |
| 571 // Add the property keys from the interceptor. | 572 // Add the property keys from the interceptor. |
| 572 if (current->HasNamedInterceptor()) { | 573 if (current->HasNamedInterceptor()) { |
| 573 v8::Handle<v8::Array> result = | 574 v8::Handle<v8::Array> result = |
| 574 GetKeysForNamedInterceptor(object, current); | 575 GetKeysForNamedInterceptor(object, current); |
| 575 if (!result.IsEmpty()) | 576 if (!result.IsEmpty()) |
| 576 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result)); | 577 content = AddKeysFromJSArray(content, v8::Utils::OpenHandle(*result)); |
| 577 } | 578 } |
| 579 |
| 580 // If we only want local properties we bail out after the first |
| 581 // iteration. |
| 582 if (type == LOCAL_ONLY) |
| 583 break; |
| 578 } | 584 } |
| 579 } | 585 } |
| 580 return content; | 586 return content; |
| 581 } | 587 } |
| 582 | 588 |
| 583 | 589 |
| 584 Handle<JSArray> GetKeysFor(Handle<JSObject> object) { | 590 Handle<JSArray> GetKeysFor(Handle<JSObject> object) { |
| 585 Counters::for_in.Increment(); | 591 Counters::for_in.Increment(); |
| 586 Handle<FixedArray> elements = GetKeysInFixedArrayFor(object); | 592 Handle<FixedArray> elements = GetKeysInFixedArrayFor(object, |
| 593 INCLUDE_PROTOS); |
| 587 return Factory::NewJSArrayWithElements(elements); | 594 return Factory::NewJSArrayWithElements(elements); |
| 588 } | 595 } |
| 589 | 596 |
| 590 | 597 |
| 591 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object) { | 598 Handle<FixedArray> GetEnumPropertyKeys(Handle<JSObject> object) { |
| 592 int index = 0; | 599 int index = 0; |
| 593 if (object->HasFastProperties()) { | 600 if (object->HasFastProperties()) { |
| 594 if (object->map()->instance_descriptors()->HasEnumCache()) { | 601 if (object->map()->instance_descriptors()->HasEnumCache()) { |
| 595 Counters::enum_cache_hits.Increment(); | 602 Counters::enum_cache_hits.Increment(); |
| 596 DescriptorArray* desc = object->map()->instance_descriptors(); | 603 DescriptorArray* desc = object->map()->instance_descriptors(); |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); | 765 Handle<Map> new_map = Factory::CopyMapDropTransitions(old_map); |
| 759 obj->set_map(*new_map); | 766 obj->set_map(*new_map); |
| 760 new_map->set_needs_loading(true); | 767 new_map->set_needs_loading(true); |
| 761 // Store the lazy loading info in the constructor field. We'll | 768 // Store the lazy loading info in the constructor field. We'll |
| 762 // reestablish the constructor from the fixed array after loading. | 769 // reestablish the constructor from the fixed array after loading. |
| 763 new_map->set_constructor(*arr); | 770 new_map->set_constructor(*arr); |
| 764 ASSERT(!obj->IsLoaded()); | 771 ASSERT(!obj->IsLoaded()); |
| 765 } | 772 } |
| 766 | 773 |
| 767 } } // namespace v8::internal | 774 } } // namespace v8::internal |
| OLD | NEW |