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

Side by Side Diff: src/objects.h

Issue 11347037: Object.observe: generate change records for named properties. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressing comments. Created 8 years, 1 month 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/object-observe.js ('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 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
762 return reinterpret_cast<Object*>(this); 762 return reinterpret_cast<Object*>(this);
763 } 763 }
764 764
765 template<typename T> 765 template<typename T>
766 inline bool To(T** obj) { 766 inline bool To(T** obj) {
767 if (IsFailure()) return false; 767 if (IsFailure()) return false;
768 *obj = T::cast(reinterpret_cast<Object*>(this)); 768 *obj = T::cast(reinterpret_cast<Object*>(this));
769 return true; 769 return true;
770 } 770 }
771 771
772 template<typename T>
773 inline bool ToHandle(Handle<T>* obj) {
774 if (IsFailure()) return false;
775 *obj = handle(T::cast(reinterpret_cast<Object*>(this)));
776 return true;
777 }
778
772 #ifdef OBJECT_PRINT 779 #ifdef OBJECT_PRINT
773 // Prints this object with details. 780 // Prints this object with details.
774 inline void Print() { 781 inline void Print() {
775 Print(stdout); 782 Print(stdout);
776 } 783 }
777 inline void PrintLn() { 784 inline void PrintLn() {
778 PrintLn(stdout); 785 PrintLn(stdout);
779 } 786 }
780 void Print(FILE* out); 787 void Print(FILE* out);
781 void PrintLn(FILE* out); 788 void PrintLn(FILE* out);
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after
1679 Object* receiver, 1686 Object* receiver,
1680 LookupResult* result, 1687 LookupResult* result,
1681 String* name, 1688 String* name,
1682 bool continue_search); 1689 bool continue_search);
1683 1690
1684 static void DefineAccessor(Handle<JSObject> object, 1691 static void DefineAccessor(Handle<JSObject> object,
1685 Handle<String> name, 1692 Handle<String> name,
1686 Handle<Object> getter, 1693 Handle<Object> getter,
1687 Handle<Object> setter, 1694 Handle<Object> setter,
1688 PropertyAttributes attributes); 1695 PropertyAttributes attributes);
1696 // Can cause GC.
1689 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name, 1697 MUST_USE_RESULT MaybeObject* DefineAccessor(String* name,
1690 Object* getter, 1698 Object* getter,
1691 Object* setter, 1699 Object* setter,
1692 PropertyAttributes attributes); 1700 PropertyAttributes attributes);
1693 // Try to define a single accessor paying attention to map transitions. 1701 // Try to define a single accessor paying attention to map transitions.
1694 // Returns a JavaScript null if this was not possible and we have to use the 1702 // Returns a JavaScript null if this was not possible and we have to use the
1695 // slow case. Note that we can fail due to allocations, too. 1703 // slow case. Note that we can fail due to allocations, too.
1696 MUST_USE_RESULT MaybeObject* DefineFastAccessor( 1704 MUST_USE_RESULT MaybeObject* DefineFastAccessor(
1697 String* name, 1705 String* name,
1698 AccessorComponent component, 1706 AccessorComponent component,
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1754 void DeleteHiddenProperty(String* key); 1762 void DeleteHiddenProperty(String* key);
1755 // Returns true if the object has a property with the hidden symbol as name. 1763 // Returns true if the object has a property with the hidden symbol as name.
1756 bool HasHiddenProperties(); 1764 bool HasHiddenProperties();
1757 1765
1758 static int GetIdentityHash(Handle<JSObject> obj); 1766 static int GetIdentityHash(Handle<JSObject> obj);
1759 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag); 1767 MUST_USE_RESULT MaybeObject* GetIdentityHash(CreationFlag flag);
1760 MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag); 1768 MUST_USE_RESULT MaybeObject* SetIdentityHash(Smi* hash, CreationFlag flag);
1761 1769
1762 static Handle<Object> DeleteProperty(Handle<JSObject> obj, 1770 static Handle<Object> DeleteProperty(Handle<JSObject> obj,
1763 Handle<String> name); 1771 Handle<String> name);
1772 // Can cause GC.
1764 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode); 1773 MUST_USE_RESULT MaybeObject* DeleteProperty(String* name, DeleteMode mode);
1765 1774
1766 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index); 1775 static Handle<Object> DeleteElement(Handle<JSObject> obj, uint32_t index);
1767 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode); 1776 MUST_USE_RESULT MaybeObject* DeleteElement(uint32_t index, DeleteMode mode);
1768 1777
1769 inline void ValidateElements(); 1778 inline void ValidateElements();
1770 1779
1771 // Makes sure that this object can contain HeapObject as elements. 1780 // Makes sure that this object can contain HeapObject as elements.
1772 MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements(); 1781 MUST_USE_RESULT inline MaybeObject* EnsureCanContainHeapObjectElements();
1773 1782
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 String* name, 2010 String* name,
2002 Object* value, 2011 Object* value,
2003 PropertyAttributes attributes, 2012 PropertyAttributes attributes,
2004 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED); 2013 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED);
2005 2014
2006 // Add a property to a slow-case object. 2015 // Add a property to a slow-case object.
2007 MUST_USE_RESULT MaybeObject* AddSlowProperty(String* name, 2016 MUST_USE_RESULT MaybeObject* AddSlowProperty(String* name,
2008 Object* value, 2017 Object* value,
2009 PropertyAttributes attributes); 2018 PropertyAttributes attributes);
2010 2019
2011 // Add a property to an object. 2020 // Add a property to an object. May cause GC.
2012 MUST_USE_RESULT MaybeObject* AddProperty( 2021 MUST_USE_RESULT MaybeObject* AddProperty(
2013 String* name, 2022 String* name,
2014 Object* value, 2023 Object* value,
2015 PropertyAttributes attributes, 2024 PropertyAttributes attributes,
2016 StrictModeFlag strict_mode, 2025 StrictModeFlag strict_mode,
2017 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED, 2026 StoreFromKeyed store_mode = MAY_BE_STORE_FROM_KEYED,
2018 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK); 2027 ExtensibilityCheck extensibility_check = PERFORM_EXTENSIBILITY_CHECK);
2019 2028
2020 // Convert the object to use the canonical dictionary 2029 // Convert the object to use the canonical dictionary
2021 // representation. If the object is expected to have additional properties 2030 // representation. If the object is expected to have additional properties
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
2269 // for hidden properties. If there is no backing store, allocate one. 2278 // for hidden properties. If there is no backing store, allocate one.
2270 // If create_if_absent is false, return the hash table backing store 2279 // If create_if_absent is false, return the hash table backing store
2271 // or the inline stored identity hash, whatever is found. 2280 // or the inline stored identity hash, whatever is found.
2272 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesHashTable( 2281 MUST_USE_RESULT MaybeObject* GetHiddenPropertiesHashTable(
2273 InitializeHiddenProperties init_option); 2282 InitializeHiddenProperties init_option);
2274 // Set the hidden property backing store to either a hash table or 2283 // Set the hidden property backing store to either a hash table or
2275 // the inline-stored identity hash. 2284 // the inline-stored identity hash.
2276 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesHashTable( 2285 MUST_USE_RESULT MaybeObject* SetHiddenPropertiesHashTable(
2277 Object* value); 2286 Object* value);
2278 2287
2288 // Enqueue change record for Object.observe. May cause GC.
2289 void EnqueueChangeRecord(const char* type,
2290 Handle<String> name,
2291 Handle<Object> old_value);
2292
2279 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject); 2293 DISALLOW_IMPLICIT_CONSTRUCTORS(JSObject);
2280 }; 2294 };
2281 2295
2282 2296
2283 // Common superclass for FixedArrays that allow implementations to share 2297 // Common superclass for FixedArrays that allow implementations to share
2284 // common accessors and some code paths. 2298 // common accessors and some code paths.
2285 class FixedArrayBase: public HeapObject { 2299 class FixedArrayBase: public HeapObject {
2286 public: 2300 public:
2287 // [length]: length of the array. 2301 // [length]: length of the array.
2288 inline int length(); 2302 inline int length();
(...skipping 2405 matching lines...) Expand 10 before | Expand all | Expand 10 after
4694 // Bit field 3. 4708 // Bit field 3.
4695 inline int bit_field3(); 4709 inline int bit_field3();
4696 inline void set_bit_field3(int value); 4710 inline void set_bit_field3(int value);
4697 4711
4698 class EnumLengthBits: public BitField<int, 0, 11> {}; 4712 class EnumLengthBits: public BitField<int, 0, 11> {};
4699 class NumberOfOwnDescriptorsBits: public BitField<int, 11, 11> {}; 4713 class NumberOfOwnDescriptorsBits: public BitField<int, 11, 11> {};
4700 class IsShared: public BitField<bool, 22, 1> {}; 4714 class IsShared: public BitField<bool, 22, 1> {};
4701 class FunctionWithPrototype: public BitField<bool, 23, 1> {}; 4715 class FunctionWithPrototype: public BitField<bool, 23, 1> {};
4702 class DictionaryMap: public BitField<bool, 24, 1> {}; 4716 class DictionaryMap: public BitField<bool, 24, 1> {};
4703 class OwnsDescriptors: public BitField<bool, 25, 1> {}; 4717 class OwnsDescriptors: public BitField<bool, 25, 1> {};
4718 class IsObserved: public BitField<bool, 26, 1> {};
4704 4719
4705 // Tells whether the object in the prototype property will be used 4720 // Tells whether the object in the prototype property will be used
4706 // for instances created from this function. If the prototype 4721 // for instances created from this function. If the prototype
4707 // property is set to a value that is not a JSObject, the prototype 4722 // property is set to a value that is not a JSObject, the prototype
4708 // property will not be used to create instances of the function. 4723 // property will not be used to create instances of the function.
4709 // See ECMA-262, 13.2.2. 4724 // See ECMA-262, 13.2.2.
4710 inline void set_non_instance_prototype(bool value); 4725 inline void set_non_instance_prototype(bool value);
4711 inline bool has_non_instance_prototype(); 4726 inline bool has_non_instance_prototype();
4712 4727
4713 // Tells whether function has special prototype property. If not, prototype 4728 // Tells whether function has special prototype property. If not, prototype
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
4961 ASSERT(length >= 0); 4976 ASSERT(length >= 0);
4962 ASSERT(length == 0 || instance_descriptors()->HasEnumCache()); 4977 ASSERT(length == 0 || instance_descriptors()->HasEnumCache());
4963 ASSERT(length <= NumberOfOwnDescriptors()); 4978 ASSERT(length <= NumberOfOwnDescriptors());
4964 } 4979 }
4965 set_bit_field3(EnumLengthBits::update(bit_field3(), length)); 4980 set_bit_field3(EnumLengthBits::update(bit_field3(), length));
4966 } 4981 }
4967 4982
4968 4983
4969 inline bool owns_descriptors(); 4984 inline bool owns_descriptors();
4970 inline void set_owns_descriptors(bool is_shared); 4985 inline void set_owns_descriptors(bool is_shared);
4986 inline bool is_observed();
4987 inline void set_is_observed(bool is_observed);
4971 4988
4972 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size); 4989 MUST_USE_RESULT MaybeObject* RawCopy(int instance_size);
4973 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors(); 4990 MUST_USE_RESULT MaybeObject* CopyWithPreallocatedFieldDescriptors();
4974 MUST_USE_RESULT MaybeObject* CopyDropDescriptors(); 4991 MUST_USE_RESULT MaybeObject* CopyDropDescriptors();
4975 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors( 4992 MUST_USE_RESULT MaybeObject* CopyReplaceDescriptors(
4976 DescriptorArray* descriptors, 4993 DescriptorArray* descriptors,
4977 String* name, 4994 String* name,
4978 TransitionFlag flag, 4995 TransitionFlag flag,
4979 int descriptor_index); 4996 int descriptor_index);
4980 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors, 4997 MUST_USE_RESULT MaybeObject* ShareDescriptor(DescriptorArray* descriptors,
(...skipping 3974 matching lines...) Expand 10 before | Expand all | Expand 10 after
8955 } else { 8972 } else {
8956 value &= ~(1 << bit_position); 8973 value &= ~(1 << bit_position);
8957 } 8974 }
8958 return value; 8975 return value;
8959 } 8976 }
8960 }; 8977 };
8961 8978
8962 } } // namespace v8::internal 8979 } } // namespace v8::internal
8963 8980
8964 #endif // V8_OBJECTS_H_ 8981 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/object-observe.js ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698