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

Side by Side Diff: src/objects.h

Issue 46030: Implementing __defineSetter__ and __defineGetter__ with an array index as arg... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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') | src/objects.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 String* key, 700 String* key,
701 PropertyAttributes* attributes); 701 PropertyAttributes* attributes);
702 Object* GetProperty(Object* receiver, 702 Object* GetProperty(Object* receiver,
703 LookupResult* result, 703 LookupResult* result,
704 String* key, 704 String* key,
705 PropertyAttributes* attributes); 705 PropertyAttributes* attributes);
706 Object* GetPropertyWithCallback(Object* receiver, 706 Object* GetPropertyWithCallback(Object* receiver,
707 Object* structure, 707 Object* structure,
708 String* name, 708 String* name,
709 Object* holder); 709 Object* holder);
710 Object* GetPropertyWithDefinedGetter(Object* receiver,
711 JSFunction* getter);
710 712
711 inline Object* GetElement(uint32_t index); 713 inline Object* GetElement(uint32_t index);
712 Object* GetElementWithReceiver(Object* receiver, uint32_t index); 714 Object* GetElementWithReceiver(Object* receiver, uint32_t index);
713 715
714 // Return the object's prototype (might be Heap::null_value()). 716 // Return the object's prototype (might be Heap::null_value()).
715 Object* GetPrototype(); 717 Object* GetPrototype();
716 718
717 // Returns true if this is a JSValue containing a string and the index is 719 // Returns true if this is a JSValue containing a string and the index is
718 // < the length of the string. Used to implement [] on strings. 720 // < the length of the string. Used to implement [] on strings.
719 inline bool IsStringObjectWithCharacterAt(uint32_t index); 721 inline bool IsStringObjectWithCharacterAt(uint32_t index);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 String* key, 1163 String* key,
1162 Object* value, 1164 Object* value,
1163 PropertyAttributes attributes); 1165 PropertyAttributes attributes);
1164 Object* SetPropertyWithFailedAccessCheck(LookupResult* result, 1166 Object* SetPropertyWithFailedAccessCheck(LookupResult* result,
1165 String* name, 1167 String* name,
1166 Object* value); 1168 Object* value);
1167 Object* SetPropertyWithCallback(Object* structure, 1169 Object* SetPropertyWithCallback(Object* structure,
1168 String* name, 1170 String* name,
1169 Object* value, 1171 Object* value,
1170 JSObject* holder); 1172 JSObject* holder);
1173 Object* SetPropertyWithDefinedSetter(JSFunction* setter,
1174 Object* value);
1171 Object* SetPropertyWithInterceptor(String* name, 1175 Object* SetPropertyWithInterceptor(String* name,
1172 Object* value, 1176 Object* value,
1173 PropertyAttributes attributes); 1177 PropertyAttributes attributes);
1174 Object* SetPropertyPostInterceptor(String* name, 1178 Object* SetPropertyPostInterceptor(String* name,
1175 Object* value, 1179 Object* value,
1176 PropertyAttributes attributes); 1180 PropertyAttributes attributes);
1177 Object* IgnoreAttributesAndSetLocalProperty(String* key, 1181 Object* IgnoreAttributesAndSetLocalProperty(String* key,
1178 Object* value, 1182 Object* value,
1179 PropertyAttributes attributes); 1183 PropertyAttributes attributes);
1180 1184
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
1288 // Lookup a property. If found, the result is valid and has 1292 // Lookup a property. If found, the result is valid and has
1289 // detailed information. 1293 // detailed information.
1290 void LocalLookup(String* name, LookupResult* result); 1294 void LocalLookup(String* name, LookupResult* result);
1291 void Lookup(String* name, LookupResult* result); 1295 void Lookup(String* name, LookupResult* result);
1292 1296
1293 // The following lookup functions skip interceptors. 1297 // The following lookup functions skip interceptors.
1294 void LocalLookupRealNamedProperty(String* name, LookupResult* result); 1298 void LocalLookupRealNamedProperty(String* name, LookupResult* result);
1295 void LookupRealNamedProperty(String* name, LookupResult* result); 1299 void LookupRealNamedProperty(String* name, LookupResult* result);
1296 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result); 1300 void LookupRealNamedPropertyInPrototypes(String* name, LookupResult* result);
1297 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result); 1301 void LookupCallbackSetterInPrototypes(String* name, LookupResult* result);
1302 Object* LookupCallbackSetterInPrototypes(uint32_t index);
1298 void LookupCallback(String* name, LookupResult* result); 1303 void LookupCallback(String* name, LookupResult* result);
1299 1304
1300 // Returns the number of properties on this object filtering out properties 1305 // Returns the number of properties on this object filtering out properties
1301 // with the specified attributes (ignoring interceptors). 1306 // with the specified attributes (ignoring interceptors).
1302 int NumberOfLocalProperties(PropertyAttributes filter); 1307 int NumberOfLocalProperties(PropertyAttributes filter);
1303 // Returns the number of enumerable properties (ignoring interceptors). 1308 // Returns the number of enumerable properties (ignoring interceptors).
1304 int NumberOfEnumProperties(); 1309 int NumberOfEnumProperties();
1305 // Fill in details for properties into storage starting at the specified 1310 // Fill in details for properties into storage starting at the specified
1306 // index. 1311 // index.
1307 void GetLocalPropertyNames(FixedArray* storage, int index); 1312 void GetLocalPropertyNames(FixedArray* storage, int index);
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1983 // Delete a property from the dictionary. 1988 // Delete a property from the dictionary.
1984 Object* DeleteProperty(int entry); 1989 Object* DeleteProperty(int entry);
1985 1990
1986 // Type specific at put (default NONE attributes is used when adding). 1991 // Type specific at put (default NONE attributes is used when adding).
1987 Object* AtStringPut(String* key, Object* value); 1992 Object* AtStringPut(String* key, Object* value);
1988 Object* AtNumberPut(uint32_t key, Object* value); 1993 Object* AtNumberPut(uint32_t key, Object* value);
1989 1994
1990 Object* AddStringEntry(String* key, Object* value, PropertyDetails details); 1995 Object* AddStringEntry(String* key, Object* value, PropertyDetails details);
1991 Object* AddNumberEntry(uint32_t key, Object* value, PropertyDetails details); 1996 Object* AddNumberEntry(uint32_t key, Object* value, PropertyDetails details);
1992 1997
1993 // Set and existing string entry or add a new one if needed. 1998 // Set and existing entry or add a new one if needed.
Mads Ager (chromium) 2009/03/13 10:27:14 I know this is not your comment, but could you fix
olehougaard 2009/03/13 11:39:46 Fixed.
1994 Object* SetOrAddStringEntry(String* key, 1999 Object* SetOrAddStringEntry(String* key,
1995 Object* value, 2000 Object* value,
1996 PropertyDetails details); 2001 PropertyDetails details);
1997 2002
2003 Object* SetOrAddNumberEntry(uint32_t key,
2004 Object* value,
2005 PropertyDetails details);
2006
1998 // Returns the number of elements in the dictionary filtering out properties 2007 // Returns the number of elements in the dictionary filtering out properties
1999 // with the specified attributes. 2008 // with the specified attributes.
2000 int NumberOfElementsFilterAttributes(PropertyAttributes filter); 2009 int NumberOfElementsFilterAttributes(PropertyAttributes filter);
2001 2010
2002 // Returns the number of enumerable elements in the dictionary. 2011 // Returns the number of enumerable elements in the dictionary.
2003 int NumberOfEnumElements(); 2012 int NumberOfEnumElements();
2004 2013
2005 // Copies keys to preallocated fixed array. 2014 // Copies keys to preallocated fixed array.
2006 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter); 2015 void CopyKeysTo(FixedArray* storage, PropertyAttributes filter);
2007 // Copies enumerable keys to preallocated fixed array. 2016 // Copies enumerable keys to preallocated fixed array.
2008 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array); 2017 void CopyEnumKeysTo(FixedArray* storage, FixedArray* sort_array);
2009 // Fill in details for properties into storage. 2018 // Fill in details for properties into storage.
2010 void CopyKeysTo(FixedArray* storage); 2019 void CopyKeysTo(FixedArray* storage);
2011 2020
2012 // For transforming properties of a JSObject. 2021 // For transforming properties of a JSObject.
2013 Object* TransformPropertiesToFastFor(JSObject* obj, 2022 Object* TransformPropertiesToFastFor(JSObject* obj,
2014 int unused_property_fields); 2023 int unused_property_fields);
2015 2024
2016 // If slow elements are required we will never go back to fast-case 2025 // If slow elements are required we will never go back to fast-case
2017 // for the elements kept in this dictionary. We require slow 2026 // for the elements kept in this dictionary. We require slow
2018 // elements if an element has been added at an index larger than 2027 // elements if an element has been added at an index larger than
2019 // kRequiresSlowElementsLimit. 2028 // kRequiresSlowElementsLimit or set_requires_slow_elements() has been called.
Mads Ager (chromium) 2009/03/13 10:27:14 Maybe state the real reason here: if a getter or s
olehougaard 2009/03/13 11:39:46 Fixed.
2020 inline bool requires_slow_elements(); 2029 inline bool requires_slow_elements();
2030 inline void set_requires_slow_elements();
2021 2031
2022 // Get the value of the max number key that has been added to this 2032 // Get the value of the max number key that has been added to this
2023 // dictionary. max_number_key can only be called if 2033 // dictionary. max_number_key can only be called if
2024 // requires_slow_elements returns false. 2034 // requires_slow_elements returns false.
2025 inline uint32_t max_number_key(); 2035 inline uint32_t max_number_key();
2026 2036
2027 // Accessors for next enumeration index. 2037 // Accessors for next enumeration index.
2028 void SetNextEnumerationIndex(int index) { 2038 void SetNextEnumerationIndex(int index) {
2029 fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index)); 2039 fast_set(this, kNextEnumerationIndexIndex, Smi::FromInt(index));
2030 } 2040 }
(...skipping 12 matching lines...) Expand all
2043 void Print(); 2053 void Print();
2044 #endif 2054 #endif
2045 // Returns the key (slow). 2055 // Returns the key (slow).
2046 Object* SlowReverseLookup(Object* value); 2056 Object* SlowReverseLookup(Object* value);
2047 2057
2048 // Bit masks. 2058 // Bit masks.
2049 static const int kRequiresSlowElementsMask = 1; 2059 static const int kRequiresSlowElementsMask = 1;
2050 static const int kRequiresSlowElementsTagSize = 1; 2060 static const int kRequiresSlowElementsTagSize = 1;
2051 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1; 2061 static const uint32_t kRequiresSlowElementsLimit = (1 << 29) - 1;
2052 2062
2063 void UpdateMaxNumberKey(uint32_t key);
2064
2053 private: 2065 private:
2054 // Generic at put operation. 2066 // Generic at put operation.
2055 Object* AtPut(HashTableKey* key, Object* value); 2067 Object* AtPut(HashTableKey* key, Object* value);
2056 2068
2057 Object* Add(HashTableKey* key, Object* value, PropertyDetails details); 2069 Object* Add(HashTableKey* key, Object* value, PropertyDetails details);
2058 2070
2059 // Add entry to dictionary. 2071 // Add entry to dictionary.
2060 void AddEntry(Object* key, 2072 void AddEntry(Object* key,
2061 Object* value, 2073 Object* value,
2062 PropertyDetails details, 2074 PropertyDetails details,
2063 uint32_t hash); 2075 uint32_t hash);
2064 2076
2065 // Sets the entry to (key, value) pair. 2077 // Sets the entry to (key, value) pair.
2066 inline void SetEntry(int entry, 2078 inline void SetEntry(int entry,
2067 Object* key, 2079 Object* key,
2068 Object* value, 2080 Object* value,
2069 PropertyDetails details); 2081 PropertyDetails details);
2070 2082
2071 void UpdateMaxNumberKey(uint32_t key);
2072
2073 // Generate new enumeration indices to avoid enumeration index overflow. 2083 // Generate new enumeration indices to avoid enumeration index overflow.
2074 Object* GenerateNewEnumerationIndices(); 2084 Object* GenerateNewEnumerationIndices();
2075 2085
2076 static const int kMaxNumberKeyIndex = kPrefixStartIndex; 2086 static const int kMaxNumberKeyIndex = kPrefixStartIndex;
2077 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1; 2087 static const int kNextEnumerationIndexIndex = kMaxNumberKeyIndex + 1;
2078 2088
2079 DISALLOW_IMPLICIT_CONSTRUCTORS(Dictionary); 2089 DISALLOW_IMPLICIT_CONSTRUCTORS(Dictionary);
2080 }; 2090 };
2081 2091
2082 2092
(...skipping 2216 matching lines...) Expand 10 before | Expand all | Expand 10 after
4299 } else { 4309 } else {
4300 value &= ~(1 << bit_position); 4310 value &= ~(1 << bit_position);
4301 } 4311 }
4302 return value; 4312 return value;
4303 } 4313 }
4304 }; 4314 };
4305 4315
4306 } } // namespace v8::internal 4316 } } // namespace v8::internal
4307 4317
4308 #endif // V8_OBJECTS_H_ 4318 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/objects.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698