Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: src/objects.h

Issue 22903012: js accessor creation on Template (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: grokdump Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 563 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 Object* structure, 2830 Object* structure,
2830 PropertyAttributes attributes); 2831 PropertyAttributes attributes);
2831 MUST_USE_RESULT MaybeObject* SetPropertyCallback( 2832 MUST_USE_RESULT MaybeObject* SetPropertyCallback(
2832 Name* name, 2833 Name* name,
2833 Object* structure, 2834 Object* structure,
2834 PropertyAttributes attributes); 2835 PropertyAttributes attributes);
2835 static void DefineElementAccessor(Handle<JSObject> object, 2836 static void DefineElementAccessor(Handle<JSObject> object,
2836 uint32_t index, 2837 uint32_t index,
2837 Handle<Object> getter, 2838 Handle<Object> getter,
2838 Handle<Object> setter, 2839 Handle<Object> setter,
2839 PropertyAttributes attributes); 2840 PropertyAttributes attributes,
2841 v8::AccessControl access_control);
2840 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object, 2842 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object,
2841 Handle<Name> name); 2843 Handle<Name> name);
2842 static void DefinePropertyAccessor(Handle<JSObject> object, 2844 static void DefinePropertyAccessor(Handle<JSObject> object,
2843 Handle<Name> name, 2845 Handle<Name> name,
2844 Handle<Object> getter, 2846 Handle<Object> getter,
2845 Handle<Object> setter, 2847 Handle<Object> setter,
2846 PropertyAttributes attributes); 2848 PropertyAttributes attributes,
2849 v8::AccessControl access_control);
2847 2850
2848 // Try to define a single accessor paying attention to map transitions. 2851 // Try to define a single accessor paying attention to map transitions.
2849 // Returns false if this was not possible and we have to use the slow case. 2852 // Returns false if this was not possible and we have to use the slow case.
2850 static bool DefineFastAccessor(Handle<JSObject> object, 2853 static bool DefineFastAccessor(Handle<JSObject> object,
2851 Handle<Name> name, 2854 Handle<Name> name,
2852 AccessorComponent component, 2855 AccessorComponent component,
2853 Handle<Object> accessor, 2856 Handle<Object> accessor,
2854 PropertyAttributes attributes); 2857 PropertyAttributes attributes);
2855 2858
2856 enum InitializeHiddenProperties { 2859 enum InitializeHiddenProperties {
(...skipping 6825 matching lines...) Expand 10 before | Expand all | Expand 10 after
9682 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo); 9685 DISALLOW_IMPLICIT_CONSTRUCTORS(ExecutableAccessorInfo);
9683 }; 9686 };
9684 9687
9685 9688
9686 // Support for JavaScript accessors: A pair of a getter and a setter. Each 9689 // Support for JavaScript accessors: A pair of a getter and a setter. Each
9687 // accessor can either be 9690 // accessor can either be
9688 // * a pointer to a JavaScript function or proxy: a real accessor 9691 // * a pointer to a JavaScript function or proxy: a real accessor
9689 // * undefined: considered an accessor by the spec, too, strangely enough 9692 // * undefined: considered an accessor by the spec, too, strangely enough
9690 // * the hole: an accessor which has not been set 9693 // * the hole: an accessor which has not been set
9691 // * a pointer to a map: a transition used to ensure map sharing 9694 // * a pointer to a map: a transition used to ensure map sharing
9695 // access_flags provides the ability to override access checks on access check
9696 // failure.
9692 class AccessorPair: public Struct { 9697 class AccessorPair: public Struct {
9693 public: 9698 public:
9694 DECL_ACCESSORS(getter, Object) 9699 DECL_ACCESSORS(getter, Object)
9695 DECL_ACCESSORS(setter, Object) 9700 DECL_ACCESSORS(setter, Object)
9701 DECL_ACCESSORS(access_flags, Smi)
9702
9703 inline void set_access_flags(v8::AccessControl access_control);
9704 inline bool all_can_read();
9705 inline bool all_can_write();
9706 inline bool prohibits_overwriting();
9696 9707
9697 static inline AccessorPair* cast(Object* obj); 9708 static inline AccessorPair* cast(Object* obj);
9698 9709
9699 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair); 9710 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair);
9700 9711
9701 Object* get(AccessorComponent component) { 9712 Object* get(AccessorComponent component) {
9702 return component == ACCESSOR_GETTER ? getter() : setter(); 9713 return component == ACCESSOR_GETTER ? getter() : setter();
9703 } 9714 }
9704 9715
9705 void set(AccessorComponent component, Object* value) { 9716 void set(AccessorComponent component, Object* value) {
(...skipping 16 matching lines...) Expand all
9722 bool ContainsAccessor() { 9733 bool ContainsAccessor() {
9723 return IsJSAccessor(getter()) || IsJSAccessor(setter()); 9734 return IsJSAccessor(getter()) || IsJSAccessor(setter());
9724 } 9735 }
9725 9736
9726 // Dispatched behavior. 9737 // Dispatched behavior.
9727 DECLARE_PRINTER(AccessorPair) 9738 DECLARE_PRINTER(AccessorPair)
9728 DECLARE_VERIFIER(AccessorPair) 9739 DECLARE_VERIFIER(AccessorPair)
9729 9740
9730 static const int kGetterOffset = HeapObject::kHeaderSize; 9741 static const int kGetterOffset = HeapObject::kHeaderSize;
9731 static const int kSetterOffset = kGetterOffset + kPointerSize; 9742 static const int kSetterOffset = kGetterOffset + kPointerSize;
9732 static const int kSize = kSetterOffset + kPointerSize; 9743 static const int kAccessFlagsOffset = kSetterOffset + kPointerSize;
9744 static const int kSize = kAccessFlagsOffset + kPointerSize;
9733 9745
9734 private: 9746 private:
9747 static const int kAllCanReadBit = 0;
9748 static const int kAllCanWriteBit = 1;
9749 static const int kProhibitsOverwritingBit = 2;
9750
9735 // Strangely enough, in addition to functions and harmony proxies, the spec 9751 // Strangely enough, in addition to functions and harmony proxies, the spec
9736 // requires us to consider undefined as a kind of accessor, too: 9752 // requires us to consider undefined as a kind of accessor, too:
9737 // var obj = {}; 9753 // var obj = {};
9738 // Object.defineProperty(obj, "foo", {get: undefined}); 9754 // Object.defineProperty(obj, "foo", {get: undefined});
9739 // assertTrue("foo" in obj); 9755 // assertTrue("foo" in obj);
9740 bool IsJSAccessor(Object* obj) { 9756 bool IsJSAccessor(Object* obj) {
9741 return obj->IsSpecFunction() || obj->IsUndefined(); 9757 return obj->IsSpecFunction() || obj->IsUndefined();
9742 } 9758 }
9743 9759
9744 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair); 9760 DISALLOW_IMPLICIT_CONSTRUCTORS(AccessorPair);
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
10187 } else { 10203 } else {
10188 value &= ~(1 << bit_position); 10204 value &= ~(1 << bit_position);
10189 } 10205 }
10190 return value; 10206 return value;
10191 } 10207 }
10192 }; 10208 };
10193 10209
10194 } } // namespace v8::internal 10210 } } // namespace v8::internal
10195 10211
10196 #endif // V8_OBJECTS_H_ 10212 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/heap.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698