OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2245 Name* name, | 2245 Name* name, |
2246 bool continue_search); | 2246 bool continue_search); |
2247 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, | 2247 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, |
2248 uint32_t index, | 2248 uint32_t index, |
2249 bool continue_search); | 2249 bool continue_search); |
2250 | 2250 |
2251 static void DefineAccessor(Handle<JSObject> object, | 2251 static void DefineAccessor(Handle<JSObject> object, |
2252 Handle<Name> name, | 2252 Handle<Name> name, |
2253 Handle<Object> getter, | 2253 Handle<Object> getter, |
2254 Handle<Object> setter, | 2254 Handle<Object> setter, |
2255 PropertyAttributes attributes); | 2255 PropertyAttributes attributes, |
| 2256 v8::AccessControl access_control = v8::DEFAULT); |
2256 | 2257 |
2257 MaybeObject* LookupAccessor(Name* name, AccessorComponent component); | 2258 MaybeObject* LookupAccessor(Name* name, AccessorComponent component); |
2258 | 2259 |
2259 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); | 2260 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); |
2260 | 2261 |
2261 // Used from Object::GetProperty(). | 2262 // Used from Object::GetProperty(). |
2262 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( | 2263 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( |
2263 Object* receiver, | 2264 Object* receiver, |
2264 LookupResult* result, | 2265 LookupResult* result, |
2265 Name* name, | 2266 Name* name, |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2835 Object* structure, | 2836 Object* structure, |
2836 PropertyAttributes attributes); | 2837 PropertyAttributes attributes); |
2837 MUST_USE_RESULT MaybeObject* SetPropertyCallback( | 2838 MUST_USE_RESULT MaybeObject* SetPropertyCallback( |
2838 Name* name, | 2839 Name* name, |
2839 Object* structure, | 2840 Object* structure, |
2840 PropertyAttributes attributes); | 2841 PropertyAttributes attributes); |
2841 static void DefineElementAccessor(Handle<JSObject> object, | 2842 static void DefineElementAccessor(Handle<JSObject> object, |
2842 uint32_t index, | 2843 uint32_t index, |
2843 Handle<Object> getter, | 2844 Handle<Object> getter, |
2844 Handle<Object> setter, | 2845 Handle<Object> setter, |
2845 PropertyAttributes attributes); | 2846 PropertyAttributes attributes, |
| 2847 v8::AccessControl access_control); |
2846 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object, | 2848 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object, |
2847 Handle<Name> name); | 2849 Handle<Name> name); |
2848 static void DefinePropertyAccessor(Handle<JSObject> object, | 2850 static void DefinePropertyAccessor(Handle<JSObject> object, |
2849 Handle<Name> name, | 2851 Handle<Name> name, |
2850 Handle<Object> getter, | 2852 Handle<Object> getter, |
2851 Handle<Object> setter, | 2853 Handle<Object> setter, |
2852 PropertyAttributes attributes); | 2854 PropertyAttributes attributes, |
| 2855 v8::AccessControl access_control); |
2853 | 2856 |
2854 // Try to define a single accessor paying attention to map transitions. | 2857 // Try to define a single accessor paying attention to map transitions. |
2855 // Returns false if this was not possible and we have to use the slow case. | 2858 // Returns false if this was not possible and we have to use the slow case. |
2856 static bool DefineFastAccessor(Handle<JSObject> object, | 2859 static bool DefineFastAccessor(Handle<JSObject> object, |
2857 Handle<Name> name, | 2860 Handle<Name> name, |
2858 AccessorComponent component, | 2861 AccessorComponent component, |
2859 Handle<Object> accessor, | 2862 Handle<Object> accessor, |
2860 PropertyAttributes attributes); | 2863 PropertyAttributes attributes); |
2861 | 2864 |
2862 enum InitializeHiddenProperties { | 2865 enum InitializeHiddenProperties { |
(...skipping 6816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9679 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo); | 9682 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo); |
9680 }; | 9683 }; |
9681 | 9684 |
9682 | 9685 |
9683 // Support for JavaScript accessors: A pair of a getter and a setter. Each | 9686 // Support for JavaScript accessors: A pair of a getter and a setter. Each |
9684 // accessor can either be | 9687 // accessor can either be |
9685 // * a pointer to a JavaScript function or proxy: a real accessor | 9688 // * a pointer to a JavaScript function or proxy: a real accessor |
9686 // * undefined: considered an accessor by the spec, too, strangely enough | 9689 // * undefined: considered an accessor by the spec, too, strangely enough |
9687 // * the hole: an accessor which has not been set | 9690 // * the hole: an accessor which has not been set |
9688 // * a pointer to a map: a transition used to ensure map sharing | 9691 // * a pointer to a map: a transition used to ensure map sharing |
| 9692 // access_flags provides the ability to override access checks on access check |
| 9693 // failure. |
9689 class AccessorPair: public Struct { | 9694 class AccessorPair: public Struct { |
9690 public: | 9695 public: |
9691 DECL_ACCESSORS(getter, Object) | 9696 DECL_ACCESSORS(getter, Object) |
9692 DECL_ACCESSORS(setter, Object) | 9697 DECL_ACCESSORS(setter, Object) |
| 9698 DECL_ACCESSORS(access_flags, Smi) |
| 9699 |
| 9700 inline void set_access_flags(v8::AccessControl access_control); |
| 9701 inline bool all_can_read(); |
| 9702 inline bool all_can_write(); |
| 9703 inline bool prohibits_overwriting(); |
9693 | 9704 |
9694 static inline AccessorPair* cast(Object* obj); | 9705 static inline AccessorPair* cast(Object* obj); |
9695 | 9706 |
9696 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); | 9707 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); |
9697 | 9708 |
9698 Object* get(AccessorComponent component) { | 9709 Object* get(AccessorComponent component) { |
9699 return component == ACCESSOR_GETTER ? getter() : setter(); | 9710 return component == ACCESSOR_GETTER ? getter() : setter(); |
9700 } | 9711 } |
9701 | 9712 |
9702 void set(AccessorComponent component, Object* value) { | 9713 void set(AccessorComponent component, Object* value) { |
(...skipping 16 matching lines...) Expand all Loading... |
9719 bool ContainsAccessor() { | 9730 bool ContainsAccessor() { |
9720 return IsJSAccessor(getter()) || IsJSAccessor(setter()); | 9731 return IsJSAccessor(getter()) || IsJSAccessor(setter()); |
9721 } | 9732 } |
9722 | 9733 |
9723 // Dispatched behavior. | 9734 // Dispatched behavior. |
9724 DECLARE_PRINTER(AccessorPair) | 9735 DECLARE_PRINTER(AccessorPair) |
9725 DECLARE_VERIFIER(AccessorPair) | 9736 DECLARE_VERIFIER(AccessorPair) |
9726 | 9737 |
9727 static const int kGetterOffset = HeapObject::kHeaderSize; | 9738 static const int kGetterOffset = HeapObject::kHeaderSize; |
9728 static const int kSetterOffset = kGetterOffset + kPointerSize; | 9739 static const int kSetterOffset = kGetterOffset + kPointerSize; |
9729 static const int kSize = kSetterOffset + kPointerSize; | 9740 static const int kAccessFlagsOffset = kSetterOffset + kPointerSize; |
| 9741 static const int kSize = kAccessFlagsOffset + kPointerSize; |
9730 | 9742 |
9731 private: | 9743 private: |
| 9744 static const int kAllCanReadBit = 0; |
| 9745 static const int kAllCanWriteBit = 1; |
| 9746 static const int kProhibitsOverwritingBit = 2; |
| 9747 |
9732 // Strangely enough, in addition to functions and harmony proxies, the spec | 9748 // Strangely enough, in addition to functions and harmony proxies, the spec |
9733 // requires us to consider undefined as a kind of accessor, too: | 9749 // requires us to consider undefined as a kind of accessor, too: |
9734 // var obj = {}; | 9750 // var obj = {}; |
9735 // Object.defineProperty(obj, "foo", {get: undefined}); | 9751 // Object.defineProperty(obj, "foo", {get: undefined}); |
9736 // assertTrue("foo" in obj); | 9752 // assertTrue("foo" in obj); |
9737 bool IsJSAccessor(Object* obj) { | 9753 bool IsJSAccessor(Object* obj) { |
9738 return obj->IsSpecFunction() || obj->IsUndefined(); | 9754 return obj->IsSpecFunction() || obj->IsUndefined(); |
9739 } | 9755 } |
9740 | 9756 |
9741 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); | 9757 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10184 } else { | 10200 } else { |
10185 value &= ~(1 << bit_position); | 10201 value &= ~(1 << bit_position); |
10186 } | 10202 } |
10187 return value; | 10203 return value; |
10188 } | 10204 } |
10189 }; | 10205 }; |
10190 | 10206 |
10191 } } // namespace v8::internal | 10207 } } // namespace v8::internal |
10192 | 10208 |
10193 #endif // V8_OBJECTS_H_ | 10209 #endif // V8_OBJECTS_H_ |
OLD | NEW |