Chromium Code Reviews| 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 574 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2840 uint32_t index, | 2841 uint32_t index, |
| 2841 Handle<Object> getter, | 2842 Handle<Object> getter, |
| 2842 Handle<Object> setter, | 2843 Handle<Object> setter, |
| 2843 PropertyAttributes attributes); | 2844 PropertyAttributes attributes); |
| 2844 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object, | 2845 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object, |
| 2845 Handle<Name> name); | 2846 Handle<Name> name); |
| 2846 static void DefinePropertyAccessor(Handle<JSObject> object, | 2847 static void DefinePropertyAccessor(Handle<JSObject> object, |
| 2847 Handle<Name> name, | 2848 Handle<Name> name, |
| 2848 Handle<Object> getter, | 2849 Handle<Object> getter, |
| 2849 Handle<Object> setter, | 2850 Handle<Object> setter, |
| 2850 PropertyAttributes attributes); | 2851 PropertyAttributes attributes, |
| 2852 v8::AccessControl access_control); | |
| 2851 | 2853 |
| 2852 // Try to define a single accessor paying attention to map transitions. | 2854 // Try to define a single accessor paying attention to map transitions. |
| 2853 // Returns false if this was not possible and we have to use the slow case. | 2855 // Returns false if this was not possible and we have to use the slow case. |
| 2854 static bool DefineFastAccessor(Handle<JSObject> object, | 2856 static bool DefineFastAccessor(Handle<JSObject> object, |
| 2855 Handle<Name> name, | 2857 Handle<Name> name, |
| 2856 AccessorComponent component, | 2858 AccessorComponent component, |
| 2857 Handle<Object> accessor, | 2859 Handle<Object> accessor, |
| 2858 PropertyAttributes attributes); | 2860 PropertyAttributes attributes); |
| 2859 | 2861 |
| 2860 enum InitializeHiddenProperties { | 2862 enum InitializeHiddenProperties { |
| (...skipping 6804 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 9665 private: | 9667 private: |
| 9666 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo); | 9668 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo); |
| 9667 }; | 9669 }; |
| 9668 | 9670 |
| 9669 | 9671 |
| 9670 // Support for JavaScript accessors: A pair of a getter and a setter. Each | 9672 // Support for JavaScript accessors: A pair of a getter and a setter. Each |
| 9671 // accessor can either be | 9673 // accessor can either be |
| 9672 // * a pointer to a JavaScript function or proxy: a real accessor | 9674 // * a pointer to a JavaScript function or proxy: a real accessor |
| 9673 // * undefined: considered an accessor by the spec, too, strangely enough | 9675 // * undefined: considered an accessor by the spec, too, strangely enough |
| 9674 // * the hole: an accessor which has not been set | 9676 // * the hole: an accessor which has not been set |
| 9675 // * a pointer to a map: a transition used to ensure map sharing | 9677 // * a pointer to a map: a transition used to ensure map sharing |
|
Sven Panne
2013/08/21 10:46:25
Extend the comment, covering the access flag part.
dcarney
2013/08/21 10:59:33
okay
| |
| 9676 class AccessorPair: public Struct { | 9678 class AccessorPair: public Struct { |
| 9677 public: | 9679 public: |
| 9678 DECL_ACCESSORS(getter, Object) | 9680 DECL_ACCESSORS(getter, Object) |
| 9679 DECL_ACCESSORS(setter, Object) | 9681 DECL_ACCESSORS(setter, Object) |
| 9682 DECL_ACCESSORS(flag, Smi) | |
| 9683 | |
| 9684 inline void set_access_flags(v8::AccessControl access_control); | |
| 9685 inline bool all_can_read(); | |
| 9686 inline bool all_can_write(); | |
| 9687 inline bool prohibits_overwriting(); | |
| 9680 | 9688 |
| 9681 static inline AccessorPair* cast(Object* obj); | 9689 static inline AccessorPair* cast(Object* obj); |
| 9682 | 9690 |
| 9683 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); | 9691 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); |
| 9684 | 9692 |
| 9685 Object* get(AccessorComponent component) { | 9693 Object* get(AccessorComponent component) { |
| 9686 return component == ACCESSOR_GETTER ? getter() : setter(); | 9694 return component == ACCESSOR_GETTER ? getter() : setter(); |
| 9687 } | 9695 } |
| 9688 | 9696 |
| 9689 void set(AccessorComponent component, Object* value) { | 9697 void set(AccessorComponent component, Object* value) { |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 9706 bool ContainsAccessor() { | 9714 bool ContainsAccessor() { |
| 9707 return IsJSAccessor(getter()) || IsJSAccessor(setter()); | 9715 return IsJSAccessor(getter()) || IsJSAccessor(setter()); |
| 9708 } | 9716 } |
| 9709 | 9717 |
| 9710 // Dispatched behavior. | 9718 // Dispatched behavior. |
| 9711 DECLARE_PRINTER(AccessorPair) | 9719 DECLARE_PRINTER(AccessorPair) |
| 9712 DECLARE_VERIFIER(AccessorPair) | 9720 DECLARE_VERIFIER(AccessorPair) |
| 9713 | 9721 |
| 9714 static const int kGetterOffset = HeapObject::kHeaderSize; | 9722 static const int kGetterOffset = HeapObject::kHeaderSize; |
| 9715 static const int kSetterOffset = kGetterOffset + kPointerSize; | 9723 static const int kSetterOffset = kGetterOffset + kPointerSize; |
| 9716 static const int kSize = kSetterOffset + kPointerSize; | 9724 static const int kFlagOffset = kSetterOffset + kPointerSize; |
| 9725 static const int kSize = kFlagOffset + kPointerSize; | |
| 9717 | 9726 |
| 9718 private: | 9727 private: |
| 9728 static const int kAllCanReadBit = 0; | |
| 9729 static const int kAllCanWriteBit = 1; | |
| 9730 static const int kProhibitsOverwritingBit = 2; | |
| 9731 | |
| 9719 // Strangely enough, in addition to functions and harmony proxies, the spec | 9732 // Strangely enough, in addition to functions and harmony proxies, the spec |
| 9720 // requires us to consider undefined as a kind of accessor, too: | 9733 // requires us to consider undefined as a kind of accessor, too: |
| 9721 // var obj = {}; | 9734 // var obj = {}; |
| 9722 // Object.defineProperty(obj, "foo", {get: undefined}); | 9735 // Object.defineProperty(obj, "foo", {get: undefined}); |
| 9723 // assertTrue("foo" in obj); | 9736 // assertTrue("foo" in obj); |
| 9724 bool IsJSAccessor(Object* obj) { | 9737 bool IsJSAccessor(Object* obj) { |
| 9725 return obj->IsSpecFunction() || obj->IsUndefined(); | 9738 return obj->IsSpecFunction() || obj->IsUndefined(); |
| 9726 } | 9739 } |
| 9727 | 9740 |
| 9728 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); | 9741 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); |
| (...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10171 } else { | 10184 } else { |
| 10172 value &= ~(1 << bit_position); | 10185 value &= ~(1 << bit_position); |
| 10173 } | 10186 } |
| 10174 return value; | 10187 return value; |
| 10175 } | 10188 } |
| 10176 }; | 10189 }; |
| 10177 | 10190 |
| 10178 } } // namespace v8::internal | 10191 } } // namespace v8::internal |
| 10179 | 10192 |
| 10180 #endif // V8_OBJECTS_H_ | 10193 #endif // V8_OBJECTS_H_ |
| OLD | NEW |