| 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 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 } | 707 } |
| 708 } | 708 } |
| 709 } | 709 } |
| 710 | 710 |
| 711 // Use recursive implementation to also traverse hidden prototypes | 711 // Use recursive implementation to also traverse hidden prototypes |
| 712 GetOwnPropertyImplementation(*obj, *name, &result); | 712 GetOwnPropertyImplementation(*obj, *name, &result); |
| 713 | 713 |
| 714 if (!result.IsProperty()) { | 714 if (!result.IsProperty()) { |
| 715 return Heap::undefined_value(); | 715 return Heap::undefined_value(); |
| 716 } | 716 } |
| 717 if (result.type() == CALLBACKS) { | |
| 718 Object* structure = result.GetCallbackObject(); | |
| 719 if (structure->IsProxy() || structure->IsAccessorInfo()) { | |
| 720 // Property that is internally implemented as a callback or | |
| 721 // an API defined callback. | |
| 722 Object* value = obj->GetPropertyWithCallback( | |
| 723 *obj, structure, *name, result.holder()); | |
| 724 if (value->IsFailure()) return value; | |
| 725 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); | |
| 726 elms->set(VALUE_INDEX, value); | |
| 727 elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly())); | |
| 728 } else if (structure->IsFixedArray()) { | |
| 729 // __defineGetter__/__defineSetter__ callback. | |
| 730 elms->set(IS_ACCESSOR_INDEX, Heap::true_value()); | |
| 731 elms->set(GETTER_INDEX, FixedArray::cast(structure)->get(0)); | |
| 732 elms->set(SETTER_INDEX, FixedArray::cast(structure)->get(1)); | |
| 733 } else { | |
| 734 return Heap::undefined_value(); | |
| 735 } | |
| 736 } else { | |
| 737 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); | |
| 738 elms->set(VALUE_INDEX, result.GetLazyValue()); | |
| 739 elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly())); | |
| 740 } | |
| 741 | 717 |
| 742 elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!result.IsDontEnum())); | 718 elms->set(ENUMERABLE_INDEX, Heap::ToBoolean(!result.IsDontEnum())); |
| 743 elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!result.IsDontDelete())); | 719 elms->set(CONFIGURABLE_INDEX, Heap::ToBoolean(!result.IsDontDelete())); |
| 720 |
| 721 bool is_js_accessor = (result.type() == CALLBACKS) && |
| 722 (result.GetCallbackObject()->IsFixedArray()); |
| 723 |
| 724 if (is_js_accessor) { |
| 725 // __defineGetter__/__defineSetter__ callback. |
| 726 FixedArray* structure = FixedArray::cast(result.GetCallbackObject()); |
| 727 elms->set(IS_ACCESSOR_INDEX, Heap::true_value()); |
| 728 elms->set(GETTER_INDEX, structure->get(0)); |
| 729 elms->set(SETTER_INDEX, structure->get(1)); |
| 730 } else { |
| 731 elms->set(IS_ACCESSOR_INDEX, Heap::false_value()); |
| 732 elms->set(WRITABLE_INDEX, Heap::ToBoolean(!result.IsReadOnly())); |
| 733 |
| 734 PropertyAttributes attrs; |
| 735 Object* value = obj->GetProperty(*obj, &result, *name, &attrs); |
| 736 if (value->IsFailure()) return value; |
| 737 elms->set(VALUE_INDEX, value); |
| 738 } |
| 739 |
| 744 return *desc; | 740 return *desc; |
| 745 } | 741 } |
| 746 | 742 |
| 747 | 743 |
| 748 static Object* Runtime_PreventExtensions(Arguments args) { | 744 static Object* Runtime_PreventExtensions(Arguments args) { |
| 749 ASSERT(args.length() == 1); | 745 ASSERT(args.length() == 1); |
| 750 CONVERT_CHECKED(JSObject, obj, args[0]); | 746 CONVERT_CHECKED(JSObject, obj, args[0]); |
| 751 return obj->PreventExtensions(); | 747 return obj->PreventExtensions(); |
| 752 } | 748 } |
| 753 | 749 |
| (...skipping 9402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10156 } else { | 10152 } else { |
| 10157 // Handle last resort GC and make sure to allow future allocations | 10153 // Handle last resort GC and make sure to allow future allocations |
| 10158 // to grow the heap without causing GCs (if possible). | 10154 // to grow the heap without causing GCs (if possible). |
| 10159 Counters::gc_last_resort_from_js.Increment(); | 10155 Counters::gc_last_resort_from_js.Increment(); |
| 10160 Heap::CollectAllGarbage(false); | 10156 Heap::CollectAllGarbage(false); |
| 10161 } | 10157 } |
| 10162 } | 10158 } |
| 10163 | 10159 |
| 10164 | 10160 |
| 10165 } } // namespace v8::internal | 10161 } } // namespace v8::internal |
| OLD | NEW |