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 3501007: Merge r5518 into 2.3 branch. (Closed) Base URL: http://v8.googlecode.com/svn/branches/2.3/
Patch Set: '' Created 10 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 | « no previous file | src/objects.cc » ('j') | src/objects-inl.h » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 194
195 195
196 // PropertyNormalizationMode is used to specify whether to keep 196 // PropertyNormalizationMode is used to specify whether to keep
197 // inobject properties when normalizing properties of a JSObject. 197 // inobject properties when normalizing properties of a JSObject.
198 enum PropertyNormalizationMode { 198 enum PropertyNormalizationMode {
199 CLEAR_INOBJECT_PROPERTIES, 199 CLEAR_INOBJECT_PROPERTIES,
200 KEEP_INOBJECT_PROPERTIES 200 KEEP_INOBJECT_PROPERTIES
201 }; 201 };
202 202
203 203
204 // NormalizedMapSharingMode is used to specify whether a map may be shared
205 // by different objects with normalized properties.
206 enum NormalizedMapSharingMode {
207 UNIQUE_NORMALIZED_MAP,
208 SHARED_NORMALIZED_MAP
209 };
210
211
204 // Instance size sentinel for objects of variable size. 212 // Instance size sentinel for objects of variable size.
205 static const int kVariableSizeSentinel = 0; 213 static const int kVariableSizeSentinel = 0;
206 214
207 215
208 // All Maps have a field instance_type containing a InstanceType. 216 // All Maps have a field instance_type containing a InstanceType.
209 // It describes the type of the instances. 217 // It describes the type of the instances.
210 // 218 //
211 // As an example, a JavaScript object is a heap object and its map 219 // As an example, a JavaScript object is a heap object and its map
212 // instance_type is JS_OBJECT_TYPE. 220 // instance_type is JS_OBJECT_TYPE.
213 // 221 //
(...skipping 2259 matching lines...) Expand 10 before | Expand all | Expand 10 after
2473 }; 2481 };
2474 2482
2475 2483
2476 // The cache for maps used by normalized (dictionary mode) objects. 2484 // The cache for maps used by normalized (dictionary mode) objects.
2477 // Such maps do not have property descriptors, so a typical program 2485 // Such maps do not have property descriptors, so a typical program
2478 // needs very limited number of distinct normalized maps. 2486 // needs very limited number of distinct normalized maps.
2479 class NormalizedMapCache: public FixedArray { 2487 class NormalizedMapCache: public FixedArray {
2480 public: 2488 public:
2481 static const int kEntries = 64; 2489 static const int kEntries = 64;
2482 2490
2483 static bool IsCacheable(JSObject* object);
2484
2485 Object* Get(JSObject* object, PropertyNormalizationMode mode); 2491 Object* Get(JSObject* object, PropertyNormalizationMode mode);
2486 2492
2487 bool Contains(Map* map);
2488
2489 void Clear(); 2493 void Clear();
2490 2494
2491 // Casting 2495 // Casting
2492 static inline NormalizedMapCache* cast(Object* obj); 2496 static inline NormalizedMapCache* cast(Object* obj);
2493 2497
2494 #ifdef DEBUG 2498 #ifdef DEBUG
2495 void NormalizedMapCacheVerify(); 2499 void NormalizedMapCacheVerify();
2496 #endif 2500 #endif
2497 2501
2498 private: 2502 private:
(...skipping 635 matching lines...) Expand 10 before | Expand all | Expand 10 after
3134 set_bit_field2(bit_field2() | (1 << kHasFastElements)); 3138 set_bit_field2(bit_field2() | (1 << kHasFastElements));
3135 } else { 3139 } else {
3136 set_bit_field2(bit_field2() & ~(1 << kHasFastElements)); 3140 set_bit_field2(bit_field2() & ~(1 << kHasFastElements));
3137 } 3141 }
3138 } 3142 }
3139 3143
3140 inline bool has_fast_elements() { 3144 inline bool has_fast_elements() {
3141 return ((1 << kHasFastElements) & bit_field2()) != 0; 3145 return ((1 << kHasFastElements) & bit_field2()) != 0;
3142 } 3146 }
3143 3147
3148 // Tells whether the map is shared between objects that may have different
3149 // behavior. If true, the map should never be modified, instead a clone
3150 // should be created and modified.
3151 inline void set_is_shared(bool value);
3152
3153 inline bool is_shared();
3154
3144 // Tells whether the instance needs security checks when accessing its 3155 // Tells whether the instance needs security checks when accessing its
3145 // properties. 3156 // properties.
3146 inline void set_is_access_check_needed(bool access_check_needed); 3157 inline void set_is_access_check_needed(bool access_check_needed);
3147 inline bool is_access_check_needed(); 3158 inline bool is_access_check_needed();
3148 3159
3149 // [prototype]: implicit prototype object. 3160 // [prototype]: implicit prototype object.
3150 DECL_ACCESSORS(prototype, Object) 3161 DECL_ACCESSORS(prototype, Object)
3151 3162
3152 // [constructor]: points back to the function responsible for this map. 3163 // [constructor]: points back to the function responsible for this map.
3153 DECL_ACCESSORS(constructor, Object) 3164 DECL_ACCESSORS(constructor, Object)
3154 3165
3155 // [instance descriptors]: describes the object. 3166 // [instance descriptors]: describes the object.
3156 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 3167 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
3157 3168
3158 // [stub cache]: contains stubs compiled for this map. 3169 // [stub cache]: contains stubs compiled for this map.
3159 DECL_ACCESSORS(code_cache, Object) 3170 DECL_ACCESSORS(code_cache, Object)
3160 3171
3161 Object* CopyDropDescriptors(); 3172 Object* CopyDropDescriptors();
3162 3173
3163 Object* CopyNormalized(PropertyNormalizationMode mode); 3174 Object* CopyNormalized(PropertyNormalizationMode mode,
3175 NormalizedMapSharingMode sharing);
3164 3176
3165 // Returns a copy of the map, with all transitions dropped from the 3177 // Returns a copy of the map, with all transitions dropped from the
3166 // instance descriptors. 3178 // instance descriptors.
3167 Object* CopyDropTransitions(); 3179 Object* CopyDropTransitions();
3168 3180
3169 // Returns this map if it has the fast elements bit set, otherwise 3181 // Returns this map if it has the fast elements bit set, otherwise
3170 // returns a copy of the map, with all transitions dropped from the 3182 // returns a copy of the map, with all transitions dropped from the
3171 // descriptors and the fast elements bit set. 3183 // descriptors and the fast elements bit set.
3172 inline Object* GetFastElementsMap(); 3184 inline Object* GetFastElementsMap();
3173 3185
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
3217 // Set all map transitions from this map to dead maps to null. 3229 // Set all map transitions from this map to dead maps to null.
3218 // Also, restore the original prototype on the targets of these 3230 // Also, restore the original prototype on the targets of these
3219 // transitions, so that we do not process this map again while 3231 // transitions, so that we do not process this map again while
3220 // following back pointers. 3232 // following back pointers.
3221 void ClearNonLiveTransitions(Object* real_prototype); 3233 void ClearNonLiveTransitions(Object* real_prototype);
3222 3234
3223 // Dispatched behavior. 3235 // Dispatched behavior.
3224 #ifdef DEBUG 3236 #ifdef DEBUG
3225 void MapPrint(); 3237 void MapPrint();
3226 void MapVerify(); 3238 void MapVerify();
3227 void NormalizedMapVerify(); 3239 void SharedMapVerify();
3228 #endif 3240 #endif
3229 3241
3230 inline int visitor_id(); 3242 inline int visitor_id();
3231 inline void set_visitor_id(int visitor_id); 3243 inline void set_visitor_id(int visitor_id);
3232 3244
3233 static const int kMaxPreAllocatedPropertyFields = 255; 3245 static const int kMaxPreAllocatedPropertyFields = 255;
3234 3246
3235 // Layout description. 3247 // Layout description.
3236 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; 3248 static const int kInstanceSizesOffset = HeapObject::kHeaderSize;
3237 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; 3249 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize;
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3278 static const int kHasIndexedInterceptor = 4; 3290 static const int kHasIndexedInterceptor = 4;
3279 static const int kIsUndetectable = 5; 3291 static const int kIsUndetectable = 5;
3280 static const int kHasInstanceCallHandler = 6; 3292 static const int kHasInstanceCallHandler = 6;
3281 static const int kIsAccessCheckNeeded = 7; 3293 static const int kIsAccessCheckNeeded = 7;
3282 3294
3283 // Bit positions for bit field 2 3295 // Bit positions for bit field 2
3284 static const int kIsExtensible = 0; 3296 static const int kIsExtensible = 0;
3285 static const int kFunctionWithPrototype = 1; 3297 static const int kFunctionWithPrototype = 1;
3286 static const int kHasFastElements = 2; 3298 static const int kHasFastElements = 2;
3287 static const int kStringWrapperSafeForDefaultValueOf = 3; 3299 static const int kStringWrapperSafeForDefaultValueOf = 3;
3300 static const int kIsShared = 5;
3288 3301
3289 // Layout of the default cache. It holds alternating name and code objects. 3302 // Layout of the default cache. It holds alternating name and code objects.
3290 static const int kCodeCacheEntrySize = 2; 3303 static const int kCodeCacheEntrySize = 2;
3291 static const int kCodeCacheEntryNameOffset = 0; 3304 static const int kCodeCacheEntryNameOffset = 0;
3292 static const int kCodeCacheEntryCodeOffset = 1; 3305 static const int kCodeCacheEntryCodeOffset = 1;
3293 3306
3294 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset, 3307 typedef FixedBodyDescriptor<kPointerFieldsBeginOffset,
3295 kPointerFieldsEndOffset, 3308 kPointerFieldsEndOffset,
3296 kSize> BodyDescriptor; 3309 kSize> BodyDescriptor;
3297 3310
(...skipping 2258 matching lines...) Expand 10 before | Expand all | Expand 10 after
5556 } else { 5569 } else {
5557 value &= ~(1 << bit_position); 5570 value &= ~(1 << bit_position);
5558 } 5571 }
5559 return value; 5572 return value;
5560 } 5573 }
5561 }; 5574 };
5562 5575
5563 } } // namespace v8::internal 5576 } } // namespace v8::internal
5564 5577
5565 #endif // V8_OBJECTS_H_ 5578 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « no previous file | src/objects.cc » ('j') | src/objects-inl.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698