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

Side by Side Diff: src/objects.h

Issue 717001: Refactor the code cache to handle large number of properties on the global ob... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 10 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 | « src/ic.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 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 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
65 // - ExternalUnsignedShortArray 65 // - ExternalUnsignedShortArray
66 // - ExternalIntArray 66 // - ExternalIntArray
67 // - ExternalUnsignedIntArray 67 // - ExternalUnsignedIntArray
68 // - ExternalFloatArray 68 // - ExternalFloatArray
69 // - FixedArray 69 // - FixedArray
70 // - DescriptorArray 70 // - DescriptorArray
71 // - HashTable 71 // - HashTable
72 // - Dictionary 72 // - Dictionary
73 // - SymbolTable 73 // - SymbolTable
74 // - CompilationCacheTable 74 // - CompilationCacheTable
75 // - CodeCacheHashTable
75 // - MapCache 76 // - MapCache
76 // - Context 77 // - Context
77 // - GlobalContext 78 // - GlobalContext
78 // - String 79 // - String
79 // - SeqString 80 // - SeqString
80 // - SeqAsciiString 81 // - SeqAsciiString
81 // - SeqTwoByteString 82 // - SeqTwoByteString
82 // - ConsString 83 // - ConsString
83 // - ExternalString 84 // - ExternalString
84 // - ExternalAsciiString 85 // - ExternalAsciiString
(...skipping 10 matching lines...) Expand all
95 // - InterceptorInfo 96 // - InterceptorInfo
96 // - CallHandlerInfo 97 // - CallHandlerInfo
97 // - TemplateInfo 98 // - TemplateInfo
98 // - FunctionTemplateInfo 99 // - FunctionTemplateInfo
99 // - ObjectTemplateInfo 100 // - ObjectTemplateInfo
100 // - Script 101 // - Script
101 // - SignatureInfo 102 // - SignatureInfo
102 // - TypeSwitchInfo 103 // - TypeSwitchInfo
103 // - DebugInfo 104 // - DebugInfo
104 // - BreakPointInfo 105 // - BreakPointInfo
106 // - CodeCache
105 // 107 //
106 // Formats of Object*: 108 // Formats of Object*:
107 // Smi: [31 bit signed int] 0 109 // Smi: [31 bit signed int] 0
108 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 110 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
109 // Failure: [30 bit signed int] 11 111 // Failure: [30 bit signed int] 11
110 112
111 // Ecma-262 3rd 8.6.1 113 // Ecma-262 3rd 8.6.1
112 enum PropertyAttributes { 114 enum PropertyAttributes {
113 NONE = v8::None, 115 NONE = v8::None,
114 READ_ONLY = v8::ReadOnly, 116 READ_ONLY = v8::ReadOnly,
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 V(ACCESSOR_INFO_TYPE) \ 264 V(ACCESSOR_INFO_TYPE) \
263 V(ACCESS_CHECK_INFO_TYPE) \ 265 V(ACCESS_CHECK_INFO_TYPE) \
264 V(INTERCEPTOR_INFO_TYPE) \ 266 V(INTERCEPTOR_INFO_TYPE) \
265 V(SHARED_FUNCTION_INFO_TYPE) \ 267 V(SHARED_FUNCTION_INFO_TYPE) \
266 V(CALL_HANDLER_INFO_TYPE) \ 268 V(CALL_HANDLER_INFO_TYPE) \
267 V(FUNCTION_TEMPLATE_INFO_TYPE) \ 269 V(FUNCTION_TEMPLATE_INFO_TYPE) \
268 V(OBJECT_TEMPLATE_INFO_TYPE) \ 270 V(OBJECT_TEMPLATE_INFO_TYPE) \
269 V(SIGNATURE_INFO_TYPE) \ 271 V(SIGNATURE_INFO_TYPE) \
270 V(TYPE_SWITCH_INFO_TYPE) \ 272 V(TYPE_SWITCH_INFO_TYPE) \
271 V(SCRIPT_TYPE) \ 273 V(SCRIPT_TYPE) \
274 V(CODE_CACHE_TYPE) \
272 \ 275 \
273 V(JS_VALUE_TYPE) \ 276 V(JS_VALUE_TYPE) \
274 V(JS_OBJECT_TYPE) \ 277 V(JS_OBJECT_TYPE) \
275 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ 278 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \
276 V(JS_GLOBAL_OBJECT_TYPE) \ 279 V(JS_GLOBAL_OBJECT_TYPE) \
277 V(JS_BUILTINS_OBJECT_TYPE) \ 280 V(JS_BUILTINS_OBJECT_TYPE) \
278 V(JS_GLOBAL_PROXY_TYPE) \ 281 V(JS_GLOBAL_PROXY_TYPE) \
279 V(JS_ARRAY_TYPE) \ 282 V(JS_ARRAY_TYPE) \
280 V(JS_REGEXP_TYPE) \ 283 V(JS_REGEXP_TYPE) \
281 \ 284 \
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 // manually. 360 // manually.
358 #define STRUCT_LIST_ALL(V) \ 361 #define STRUCT_LIST_ALL(V) \
359 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \ 362 V(ACCESSOR_INFO, AccessorInfo, accessor_info) \
360 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \ 363 V(ACCESS_CHECK_INFO, AccessCheckInfo, access_check_info) \
361 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \ 364 V(INTERCEPTOR_INFO, InterceptorInfo, interceptor_info) \
362 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \ 365 V(CALL_HANDLER_INFO, CallHandlerInfo, call_handler_info) \
363 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \ 366 V(FUNCTION_TEMPLATE_INFO, FunctionTemplateInfo, function_template_info) \
364 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \ 367 V(OBJECT_TEMPLATE_INFO, ObjectTemplateInfo, object_template_info) \
365 V(SIGNATURE_INFO, SignatureInfo, signature_info) \ 368 V(SIGNATURE_INFO, SignatureInfo, signature_info) \
366 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \ 369 V(TYPE_SWITCH_INFO, TypeSwitchInfo, type_switch_info) \
367 V(SCRIPT, Script, script) 370 V(SCRIPT, Script, script) \
371 V(CODE_CACHE, CodeCache, code_cache)
368 372
369 #ifdef ENABLE_DEBUGGER_SUPPORT 373 #ifdef ENABLE_DEBUGGER_SUPPORT
370 #define STRUCT_LIST_DEBUGGER(V) \ 374 #define STRUCT_LIST_DEBUGGER(V) \
371 V(DEBUG_INFO, DebugInfo, debug_info) \ 375 V(DEBUG_INFO, DebugInfo, debug_info) \
372 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info) 376 V(BREAK_POINT_INFO, BreakPointInfo, break_point_info)
373 #else 377 #else
374 #define STRUCT_LIST_DEBUGGER(V) 378 #define STRUCT_LIST_DEBUGGER(V)
375 #endif 379 #endif
376 380
377 #define STRUCT_LIST(V) \ 381 #define STRUCT_LIST(V) \
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 // Structs. 465 // Structs.
462 ACCESSOR_INFO_TYPE, 466 ACCESSOR_INFO_TYPE,
463 ACCESS_CHECK_INFO_TYPE, 467 ACCESS_CHECK_INFO_TYPE,
464 INTERCEPTOR_INFO_TYPE, 468 INTERCEPTOR_INFO_TYPE,
465 CALL_HANDLER_INFO_TYPE, 469 CALL_HANDLER_INFO_TYPE,
466 FUNCTION_TEMPLATE_INFO_TYPE, 470 FUNCTION_TEMPLATE_INFO_TYPE,
467 OBJECT_TEMPLATE_INFO_TYPE, 471 OBJECT_TEMPLATE_INFO_TYPE,
468 SIGNATURE_INFO_TYPE, 472 SIGNATURE_INFO_TYPE,
469 TYPE_SWITCH_INFO_TYPE, 473 TYPE_SWITCH_INFO_TYPE,
470 SCRIPT_TYPE, 474 SCRIPT_TYPE,
475 CODE_CACHE_TYPE,
471 #ifdef ENABLE_DEBUGGER_SUPPORT 476 #ifdef ENABLE_DEBUGGER_SUPPORT
472 DEBUG_INFO_TYPE, 477 DEBUG_INFO_TYPE,
473 BREAK_POINT_INFO_TYPE, 478 BREAK_POINT_INFO_TYPE,
474 #endif 479 #endif
475 480
476 FIXED_ARRAY_TYPE, 481 FIXED_ARRAY_TYPE,
477 SHARED_FUNCTION_INFO_TYPE, 482 SHARED_FUNCTION_INFO_TYPE,
478 483
479 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE 484 JS_VALUE_TYPE, // FIRST_JS_OBJECT_TYPE
480 JS_OBJECT_TYPE, 485 JS_OBJECT_TYPE,
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 inline bool IsJSValue(); 599 inline bool IsJSValue();
595 inline bool IsStringWrapper(); 600 inline bool IsStringWrapper();
596 inline bool IsProxy(); 601 inline bool IsProxy();
597 inline bool IsBoolean(); 602 inline bool IsBoolean();
598 inline bool IsJSArray(); 603 inline bool IsJSArray();
599 inline bool IsJSRegExp(); 604 inline bool IsJSRegExp();
600 inline bool IsHashTable(); 605 inline bool IsHashTable();
601 inline bool IsDictionary(); 606 inline bool IsDictionary();
602 inline bool IsSymbolTable(); 607 inline bool IsSymbolTable();
603 inline bool IsCompilationCacheTable(); 608 inline bool IsCompilationCacheTable();
609 inline bool IsCodeCacheHashTable();
604 inline bool IsMapCache(); 610 inline bool IsMapCache();
605 inline bool IsPrimitive(); 611 inline bool IsPrimitive();
606 inline bool IsGlobalObject(); 612 inline bool IsGlobalObject();
607 inline bool IsJSGlobalObject(); 613 inline bool IsJSGlobalObject();
608 inline bool IsJSBuiltinsObject(); 614 inline bool IsJSBuiltinsObject();
609 inline bool IsJSGlobalProxy(); 615 inline bool IsJSGlobalProxy();
610 inline bool IsUndetectableObject(); 616 inline bool IsUndetectableObject();
611 inline bool IsAccessCheckNeeded(); 617 inline bool IsAccessCheckNeeded();
612 inline bool IsJSGlobalPropertyCell(); 618 inline bool IsJSGlobalPropertyCell();
613 619
(...skipping 2308 matching lines...) Expand 10 before | Expand all | Expand 10 after
2922 // [prototype]: implicit prototype object. 2928 // [prototype]: implicit prototype object.
2923 DECL_ACCESSORS(prototype, Object) 2929 DECL_ACCESSORS(prototype, Object)
2924 2930
2925 // [constructor]: points back to the function responsible for this map. 2931 // [constructor]: points back to the function responsible for this map.
2926 DECL_ACCESSORS(constructor, Object) 2932 DECL_ACCESSORS(constructor, Object)
2927 2933
2928 // [instance descriptors]: describes the object. 2934 // [instance descriptors]: describes the object.
2929 DECL_ACCESSORS(instance_descriptors, DescriptorArray) 2935 DECL_ACCESSORS(instance_descriptors, DescriptorArray)
2930 2936
2931 // [stub cache]: contains stubs compiled for this map. 2937 // [stub cache]: contains stubs compiled for this map.
2932 DECL_ACCESSORS(code_cache, FixedArray) 2938 DECL_ACCESSORS(code_cache, Object)
2933 2939
2934 Object* CopyDropDescriptors(); 2940 Object* CopyDropDescriptors();
2935 2941
2936 // Returns a copy of the map, with all transitions dropped from the 2942 // Returns a copy of the map, with all transitions dropped from the
2937 // instance descriptors. 2943 // instance descriptors.
2938 Object* CopyDropTransitions(); 2944 Object* CopyDropTransitions();
2939 2945
2940 // Returns the property index for name (only valid for FAST MODE). 2946 // Returns the property index for name (only valid for FAST MODE).
2941 int PropertyIndexFor(String* name); 2947 int PropertyIndexFor(String* name);
2942 2948
(...skipping 15 matching lines...) Expand all
2958 inline void ClearCodeCache(); 2964 inline void ClearCodeCache();
2959 2965
2960 // Update code cache. 2966 // Update code cache.
2961 Object* UpdateCodeCache(String* name, Code* code); 2967 Object* UpdateCodeCache(String* name, Code* code);
2962 2968
2963 // Returns the found code or undefined if absent. 2969 // Returns the found code or undefined if absent.
2964 Object* FindInCodeCache(String* name, Code::Flags flags); 2970 Object* FindInCodeCache(String* name, Code::Flags flags);
2965 2971
2966 // Returns the non-negative index of the code object if it is in the 2972 // Returns the non-negative index of the code object if it is in the
2967 // cache and -1 otherwise. 2973 // cache and -1 otherwise.
2968 int IndexInCodeCache(Code* code); 2974 int IndexInCodeCache(String* name, Code* code);
2969 2975
2970 // Removes a code object from the code cache at the given index. 2976 // Removes a code object from the code cache at the given index.
2971 void RemoveFromCodeCache(int index); 2977 void RemoveFromCodeCache(String* name, Code* code, int index);
2972 2978
2973 // For every transition in this map, makes the transition's 2979 // For every transition in this map, makes the transition's
2974 // target's prototype pointer point back to this map. 2980 // target's prototype pointer point back to this map.
2975 // This is undone in MarkCompactCollector::ClearNonLiveTransitions(). 2981 // This is undone in MarkCompactCollector::ClearNonLiveTransitions().
2976 void CreateBackPointers(); 2982 void CreateBackPointers();
2977 2983
2978 // Set all map transitions from this map to dead maps to null. 2984 // Set all map transitions from this map to dead maps to null.
2979 // Also, restore the original prototype on the targets of these 2985 // Also, restore the original prototype on the targets of these
2980 // transitions, so that we do not process this map again while 2986 // transitions, so that we do not process this map again while
2981 // following back pointers. 2987 // following back pointers.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
3026 static const int kHasNamedInterceptor = 3; 3032 static const int kHasNamedInterceptor = 3;
3027 static const int kHasIndexedInterceptor = 4; 3033 static const int kHasIndexedInterceptor = 4;
3028 static const int kIsUndetectable = 5; 3034 static const int kIsUndetectable = 5;
3029 static const int kHasInstanceCallHandler = 6; 3035 static const int kHasInstanceCallHandler = 6;
3030 static const int kIsAccessCheckNeeded = 7; 3036 static const int kIsAccessCheckNeeded = 7;
3031 3037
3032 // Bit positions for bit field 2 3038 // Bit positions for bit field 2
3033 static const int kNeedsLoading = 0; 3039 static const int kNeedsLoading = 0;
3034 static const int kIsExtensible = 1; 3040 static const int kIsExtensible = 1;
3035 3041
3042 // Layout of the default cache. It holds alternating name and code objects.
3043 static const int kCodeCacheEntrySize = 2;
3044 static const int kCodeCacheEntryNameOffset = 0;
3045 static const int kCodeCacheEntryCodeOffset = 1;
3046
3036 private: 3047 private:
3037 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); 3048 DISALLOW_IMPLICIT_CONSTRUCTORS(Map);
3038 }; 3049 };
3039 3050
3040 3051
3041 // An abstract superclass, a marker class really, for simple structure classes. 3052 // An abstract superclass, a marker class really, for simple structure classes.
3042 // It doesn't carry much functionality but allows struct classes to me 3053 // It doesn't carry much functionality but allows struct classes to me
3043 // identified in the type system. 3054 // identified in the type system.
3044 class Struct: public HeapObject { 3055 class Struct: public HeapObject {
3045 public: 3056 public:
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3709 Object* PutEval(String* src, Context* context, Object* value); 3720 Object* PutEval(String* src, Context* context, Object* value);
3710 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); 3721 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value);
3711 3722
3712 static inline CompilationCacheTable* cast(Object* obj); 3723 static inline CompilationCacheTable* cast(Object* obj);
3713 3724
3714 private: 3725 private:
3715 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); 3726 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable);
3716 }; 3727 };
3717 3728
3718 3729
3730 class CodeCache: public Struct {
3731 public:
3732 DECL_ACCESSORS(default_cache, FixedArray)
3733 DECL_ACCESSORS(normal_type_cache, Object)
3734
3735 // Add the code object to the cache.
3736 Object* Update(String* name, Code* code);
3737
3738 // Lookup code object in the cache. Returns code object if found and undefined
3739 // if not.
3740 Object* Lookup(String* name, Code::Flags flags);
3741
3742 // Get the internal index of a code object in the cache. Returns -1 if the
3743 // code object is not in that cache. This index can be used to later call
3744 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and
3745 // RemoveByIndex.
3746 int GetIndex(String* name, Code* code);
3747
3748 // Remove an object from the cache with the provided internal index.
3749 void RemoveByIndex(String* name, Code* code, int index);
3750
3751 static inline CodeCache* cast(Object* obj);
3752
3753 #ifdef DEBUG
3754 void CodeCachePrint();
3755 void CodeCacheVerify();
3756 #endif
3757
3758 static const int kDefaultCacheOffset = HeapObject::kHeaderSize;
3759 static const int kNormalTypeCacheOffset =
3760 kDefaultCacheOffset + kPointerSize;
3761 static const int kSize = kNormalTypeCacheOffset + kPointerSize;
3762
3763 private:
3764 Object* UpdateDefaultCache(String* name, Code* code);
3765 Object* UpdateNormalTypeCache(String* name, Code* code);
3766 Object* LookupDefaultCache(String* name, Code::Flags flags);
3767 Object* LookupNormalTypeCache(String* name, Code::Flags flags);
3768
3769 // Code cache layout of the default cache. Elements are alternating name and
3770 // code objects for non normal load/store/call IC's.
3771 static const int kCodeCacheEntrySize = 2;
3772 static const int kCodeCacheEntryNameOffset = 0;
3773 static const int kCodeCacheEntryCodeOffset = 1;
3774
3775 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache);
3776 };
3777
3778
3779 class CodeCacheHashTableShape {
3780 public:
3781 static inline bool IsMatch(HashTableKey* key, Object* value) {
3782 return key->IsMatch(value);
3783 }
3784
3785 static inline uint32_t Hash(HashTableKey* key) {
3786 return key->Hash();
3787 }
3788
3789 static inline uint32_t HashForObject(HashTableKey* key, Object* object) {
3790 return key->HashForObject(object);
3791 }
3792
3793 static Object* AsObject(HashTableKey* key) {
3794 return key->AsObject();
3795 }
3796
3797 static const int kPrefixSize = 0;
3798 static const int kEntrySize = 2;
3799 };
3800
3801
3802 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape,
3803 HashTableKey*> {
3804 public:
3805 Object* Lookup(String* name, Code::Flags flags);
3806 Object* Put(String* name, Code* code);
3807
3808 int GetIndex(String* name, Code::Flags flags);
3809 void RemoveByIndex(int index);
3810
3811 static inline CodeCacheHashTable* cast(Object* obj);
3812
3813 // Initial size of the fixed array backing the hash table.
3814 static const int kInitialSize = 64;
3815
3816 private:
3817 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable);
3818 };
3819
3820
3719 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; 3821 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS};
3720 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; 3822 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL};
3721 3823
3722 3824
3723 class StringHasher { 3825 class StringHasher {
3724 public: 3826 public:
3725 inline StringHasher(int length); 3827 inline StringHasher(int length);
3726 3828
3727 // Returns true if the hash of this string can be computed without 3829 // Returns true if the hash of this string can be computed without
3728 // looking at the contents. 3830 // looking at the contents.
(...skipping 1252 matching lines...) Expand 10 before | Expand all | Expand 10 after
4981 } else { 5083 } else {
4982 value &= ~(1 << bit_position); 5084 value &= ~(1 << bit_position);
4983 } 5085 }
4984 return value; 5086 return value;
4985 } 5087 }
4986 }; 5088 };
4987 5089
4988 } } // namespace v8::internal 5090 } } // namespace v8::internal
4989 5091
4990 #endif // V8_OBJECTS_H_ 5092 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/ic.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698