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 18497003: Handlify JSObject::DefineAccessor method. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed comments by Andreas Rossberg. Created 7 years, 5 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 | « no previous file | 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 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
1925 bool continue_search); 1925 bool continue_search);
1926 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver, 1926 PropertyAttributes GetElementAttributeWithReceiver(JSReceiver* receiver,
1927 uint32_t index, 1927 uint32_t index,
1928 bool continue_search); 1928 bool continue_search);
1929 1929
1930 static void DefineAccessor(Handle<JSObject> object, 1930 static void DefineAccessor(Handle<JSObject> object,
1931 Handle<Name> name, 1931 Handle<Name> name,
1932 Handle<Object> getter, 1932 Handle<Object> getter,
1933 Handle<Object> setter, 1933 Handle<Object> setter,
1934 PropertyAttributes attributes); 1934 PropertyAttributes attributes);
1935 // Can cause GC. 1935
1936 MUST_USE_RESULT MaybeObject* DefineAccessor(Name* name,
1937 Object* getter,
1938 Object* setter,
1939 PropertyAttributes attributes);
1940 // Try to define a single accessor paying attention to map transitions.
1941 // Returns a JavaScript null if this was not possible and we have to use the
1942 // slow case. Note that we can fail due to allocations, too.
1943 MUST_USE_RESULT MaybeObject* DefineFastAccessor(
1944 Name* name,
1945 AccessorComponent component,
1946 Object* accessor,
1947 PropertyAttributes attributes);
1948 Object* LookupAccessor(Name* name, AccessorComponent component); 1936 Object* LookupAccessor(Name* name, AccessorComponent component);
1949 1937
1950 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info); 1938 MUST_USE_RESULT MaybeObject* DefineAccessor(AccessorInfo* info);
1951 1939
1952 // Used from Object::GetProperty(). 1940 // Used from Object::GetProperty().
1953 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck( 1941 MUST_USE_RESULT MaybeObject* GetPropertyWithFailedAccessCheck(
1954 Object* receiver, 1942 Object* receiver,
1955 LookupResult* result, 1943 LookupResult* result,
1956 Name* name, 1944 Name* name,
1957 PropertyAttributes* attributes); 1945 PropertyAttributes* attributes);
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 2496
2509 bool CanSetCallback(Name* name); 2497 bool CanSetCallback(Name* name);
2510 MUST_USE_RESULT MaybeObject* SetElementCallback( 2498 MUST_USE_RESULT MaybeObject* SetElementCallback(
2511 uint32_t index, 2499 uint32_t index,
2512 Object* structure, 2500 Object* structure,
2513 PropertyAttributes attributes); 2501 PropertyAttributes attributes);
2514 MUST_USE_RESULT MaybeObject* SetPropertyCallback( 2502 MUST_USE_RESULT MaybeObject* SetPropertyCallback(
2515 Name* name, 2503 Name* name,
2516 Object* structure, 2504 Object* structure,
2517 PropertyAttributes attributes); 2505 PropertyAttributes attributes);
2518 MUST_USE_RESULT MaybeObject* DefineElementAccessor( 2506 static void DefineElementAccessor(Handle<JSObject> object,
2519 uint32_t index, 2507 uint32_t index,
2520 Object* getter, 2508 Handle<Object> getter,
2521 Object* setter, 2509 Handle<Object> setter,
2522 PropertyAttributes attributes); 2510 PropertyAttributes attributes);
2523 MUST_USE_RESULT MaybeObject* CreateAccessorPairFor(Name* name); 2511 static Handle<AccessorPair> CreateAccessorPairFor(Handle<JSObject> object,
2524 MUST_USE_RESULT MaybeObject* DefinePropertyAccessor( 2512 Handle<Name> name);
2525 Name* name, 2513 static void DefinePropertyAccessor(Handle<JSObject> object,
2526 Object* getter, 2514 Handle<Name> name,
2527 Object* setter, 2515 Handle<Object> getter,
2528 PropertyAttributes attributes); 2516 Handle<Object> setter,
2517 PropertyAttributes attributes);
2529 2518
2519 // Try to define a single accessor paying attention to map transitions.
2520 // Returns false if this was not possible and we have to use the slow case.
2521 static bool DefineFastAccessor(Handle<JSObject> object,
2522 Handle<Name> name,
2523 AccessorComponent component,
2524 Handle<Object> accessor,
2525 PropertyAttributes attributes);
2530 2526
2531 enum InitializeHiddenProperties { 2527 enum InitializeHiddenProperties {
2532 CREATE_NEW_IF_ABSENT, 2528 CREATE_NEW_IF_ABSENT,
2533 ONLY_RETURN_INLINE_VALUE 2529 ONLY_RETURN_INLINE_VALUE
2534 }; 2530 };
2535 2531
2536 // If create_if_absent is true, return the hash table backing store 2532 // If create_if_absent is true, return the hash table backing store
2537 // for hidden properties. If there is no backing store, allocate one. 2533 // for hidden properties. If there is no backing store, allocate one.
2538 // If create_if_absent is false, return the hash table backing store 2534 // If create_if_absent is false, return the hash table backing store
2539 // or the inline stored identity hash, whatever is found. 2535 // or the inline stored identity hash, whatever is found.
(...skipping 6711 matching lines...) Expand 10 before | Expand all | Expand 10 after
9251 // * undefined: considered an accessor by the spec, too, strangely enough 9247 // * undefined: considered an accessor by the spec, too, strangely enough
9252 // * the hole: an accessor which has not been set 9248 // * the hole: an accessor which has not been set
9253 // * a pointer to a map: a transition used to ensure map sharing 9249 // * a pointer to a map: a transition used to ensure map sharing
9254 class AccessorPair: public Struct { 9250 class AccessorPair: public Struct {
9255 public: 9251 public:
9256 DECL_ACCESSORS(getter, Object) 9252 DECL_ACCESSORS(getter, Object)
9257 DECL_ACCESSORS(setter, Object) 9253 DECL_ACCESSORS(setter, Object)
9258 9254
9259 static inline AccessorPair* cast(Object* obj); 9255 static inline AccessorPair* cast(Object* obj);
9260 9256
9261 MUST_USE_RESULT MaybeObject* Copy(); 9257 static Handle<AccessorPair> Copy(Handle<AccessorPair> pair);
9262 9258
9263 Object* get(AccessorComponent component) { 9259 Object* get(AccessorComponent component) {
9264 return component == ACCESSOR_GETTER ? getter() : setter(); 9260 return component == ACCESSOR_GETTER ? getter() : setter();
9265 } 9261 }
9266 9262
9267 void set(AccessorComponent component, Object* value) { 9263 void set(AccessorComponent component, Object* value) {
9268 if (component == ACCESSOR_GETTER) { 9264 if (component == ACCESSOR_GETTER) {
9269 set_getter(value); 9265 set_getter(value);
9270 } else { 9266 } else {
9271 set_setter(value); 9267 set_setter(value);
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
9748 } else { 9744 } else {
9749 value &= ~(1 << bit_position); 9745 value &= ~(1 << bit_position);
9750 } 9746 }
9751 return value; 9747 return value;
9752 } 9748 }
9753 }; 9749 };
9754 9750
9755 } } // namespace v8::internal 9751 } } // namespace v8::internal
9756 9752
9757 #endif // V8_OBJECTS_H_ 9753 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698