| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 2301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2915 // [prototype]: implicit prototype object. | 2921 // [prototype]: implicit prototype object. |
| 2916 DECL_ACCESSORS(prototype, Object) | 2922 DECL_ACCESSORS(prototype, Object) |
| 2917 | 2923 |
| 2918 // [constructor]: points back to the function responsible for this map. | 2924 // [constructor]: points back to the function responsible for this map. |
| 2919 DECL_ACCESSORS(constructor, Object) | 2925 DECL_ACCESSORS(constructor, Object) |
| 2920 | 2926 |
| 2921 // [instance descriptors]: describes the object. | 2927 // [instance descriptors]: describes the object. |
| 2922 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 2928 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
| 2923 | 2929 |
| 2924 // [stub cache]: contains stubs compiled for this map. | 2930 // [stub cache]: contains stubs compiled for this map. |
| 2925 DECL_ACCESSORS(code_cache, FixedArray) | 2931 DECL_ACCESSORS(code_cache, Object) |
| 2926 | 2932 |
| 2927 Object* CopyDropDescriptors(); | 2933 Object* CopyDropDescriptors(); |
| 2928 | 2934 |
| 2929 // Returns a copy of the map, with all transitions dropped from the | 2935 // Returns a copy of the map, with all transitions dropped from the |
| 2930 // instance descriptors. | 2936 // instance descriptors. |
| 2931 Object* CopyDropTransitions(); | 2937 Object* CopyDropTransitions(); |
| 2932 | 2938 |
| 2933 // Returns the property index for name (only valid for FAST MODE). | 2939 // Returns the property index for name (only valid for FAST MODE). |
| 2934 int PropertyIndexFor(String* name); | 2940 int PropertyIndexFor(String* name); |
| 2935 | 2941 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3019 static const int kHasNamedInterceptor = 3; | 3025 static const int kHasNamedInterceptor = 3; |
| 3020 static const int kHasIndexedInterceptor = 4; | 3026 static const int kHasIndexedInterceptor = 4; |
| 3021 static const int kIsUndetectable = 5; | 3027 static const int kIsUndetectable = 5; |
| 3022 static const int kHasInstanceCallHandler = 6; | 3028 static const int kHasInstanceCallHandler = 6; |
| 3023 static const int kIsAccessCheckNeeded = 7; | 3029 static const int kIsAccessCheckNeeded = 7; |
| 3024 | 3030 |
| 3025 // Bit positions for bit field 2 | 3031 // Bit positions for bit field 2 |
| 3026 static const int kNeedsLoading = 0; | 3032 static const int kNeedsLoading = 0; |
| 3027 static const int kIsExtensible = 1; | 3033 static const int kIsExtensible = 1; |
| 3028 | 3034 |
| 3035 // Layout of the default cache. It holds alternating name and code objects. |
| 3036 static const int kCodeCacheEntrySize = 2; |
| 3037 static const int kCodeCacheEntryNameOffset = 0; |
| 3038 static const int kCodeCacheEntryCodeOffset = 1; |
| 3039 |
| 3029 private: | 3040 private: |
| 3030 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); | 3041 DISALLOW_IMPLICIT_CONSTRUCTORS(Map); |
| 3031 }; | 3042 }; |
| 3032 | 3043 |
| 3033 | 3044 |
| 3034 // An abstract superclass, a marker class really, for simple structure classes. | 3045 // An abstract superclass, a marker class really, for simple structure classes. |
| 3035 // It doesn't carry much functionality but allows struct classes to me | 3046 // It doesn't carry much functionality but allows struct classes to me |
| 3036 // identified in the type system. | 3047 // identified in the type system. |
| 3037 class Struct: public HeapObject { | 3048 class Struct: public HeapObject { |
| 3038 public: | 3049 public: |
| (...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3704 Object* PutEval(String* src, Context* context, Object* value); | 3715 Object* PutEval(String* src, Context* context, Object* value); |
| 3705 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); | 3716 Object* PutRegExp(String* src, JSRegExp::Flags flags, FixedArray* value); |
| 3706 | 3717 |
| 3707 static inline CompilationCacheTable* cast(Object* obj); | 3718 static inline CompilationCacheTable* cast(Object* obj); |
| 3708 | 3719 |
| 3709 private: | 3720 private: |
| 3710 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); | 3721 DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheTable); |
| 3711 }; | 3722 }; |
| 3712 | 3723 |
| 3713 | 3724 |
| 3725 class CodeCache: public Struct { |
| 3726 public: |
| 3727 DECL_ACCESSORS(default_cache, FixedArray) |
| 3728 DECL_ACCESSORS(normal_type_cache, Object) |
| 3729 |
| 3730 // Add the code object to the cache. |
| 3731 Object* Update(String* name, Code* code); |
| 3732 |
| 3733 // Lookup code object in the cache. Returns code object if found. |
| 3734 Object* Lookup(String* name, Code::Flags flags); |
| 3735 |
| 3736 // Get the internal index of a code object in the cache. Returns -1 if the |
| 3737 // code object is not in that cache. This index can be used to later call |
| 3738 // RemoveByIndex. The cache cannot be modified between a call to GetIndex and |
| 3739 // RemoveByIndex. |
| 3740 int GetIndex(Code* code); |
| 3741 |
| 3742 // Remove an object from the cache with the provided internal index. |
| 3743 void RemoveByIndex(int index); |
| 3744 |
| 3745 static inline CodeCache* cast(Object* obj); |
| 3746 |
| 3747 #ifdef DEBUG |
| 3748 void CodeCachePrint(); |
| 3749 void CodeCacheVerify(); |
| 3750 #endif |
| 3751 |
| 3752 static const int kDefaultCacheOffset = HeapObject::kHeaderSize; |
| 3753 static const int kNormalTypeCacheOffset = |
| 3754 kDefaultCacheOffset + kPointerSize; |
| 3755 static const int kSize = kNormalTypeCacheOffset + kPointerSize; |
| 3756 |
| 3757 private: |
| 3758 Object* UpdateDefaultCache(String* name, Code* code); |
| 3759 Object* UpdateNormalTypeCache(String* name, Code* code); |
| 3760 Object* LookupDefaultCache(String* name, Code::Flags flags); |
| 3761 Object* LookupNormalTypeCache(String* name, Code::Flags flags); |
| 3762 |
| 3763 // Code cache layout of the default cache. Elements are alternating name and |
| 3764 // code objects for non normal load/store/call IC's. |
| 3765 static const int kCodeCacheEntrySize = 2; |
| 3766 static const int kCodeCacheEntryNameOffset = 0; |
| 3767 static const int kCodeCacheEntryCodeOffset = 1; |
| 3768 |
| 3769 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCache); |
| 3770 }; |
| 3771 |
| 3772 |
| 3773 class CodeCacheHashTableShape { |
| 3774 public: |
| 3775 static inline bool IsMatch(HashTableKey* key, Object* value) { |
| 3776 return key->IsMatch(value); |
| 3777 } |
| 3778 |
| 3779 static inline uint32_t Hash(HashTableKey* key) { |
| 3780 return key->Hash(); |
| 3781 } |
| 3782 |
| 3783 static inline uint32_t HashForObject(HashTableKey* key, Object* object) { |
| 3784 return key->HashForObject(object); |
| 3785 } |
| 3786 |
| 3787 static Object* AsObject(HashTableKey* key) { |
| 3788 return key->AsObject(); |
| 3789 } |
| 3790 |
| 3791 static const int kPrefixSize = 0; |
| 3792 static const int kEntrySize = 2; |
| 3793 }; |
| 3794 |
| 3795 |
| 3796 class CodeCacheHashTable: public HashTable<CodeCacheHashTableShape, |
| 3797 HashTableKey*> { |
| 3798 public: |
| 3799 Object* Lookup(String* name, Code::Flags flags); |
| 3800 Object* Put(String* name, Code* code); |
| 3801 |
| 3802 static inline CodeCacheHashTable* cast(Object* obj); |
| 3803 |
| 3804 // Initial size of the fixed array backing the hash table. |
| 3805 static const int kInitialSize = 64; |
| 3806 |
| 3807 private: |
| 3808 DISALLOW_IMPLICIT_CONSTRUCTORS(CodeCacheHashTable); |
| 3809 }; |
| 3810 |
| 3811 |
| 3714 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; | 3812 enum AllowNullsFlag {ALLOW_NULLS, DISALLOW_NULLS}; |
| 3715 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; | 3813 enum RobustnessFlag {ROBUST_STRING_TRAVERSAL, FAST_STRING_TRAVERSAL}; |
| 3716 | 3814 |
| 3717 | 3815 |
| 3718 class StringHasher { | 3816 class StringHasher { |
| 3719 public: | 3817 public: |
| 3720 inline StringHasher(int length); | 3818 inline StringHasher(int length); |
| 3721 | 3819 |
| 3722 // Returns true if the hash of this string can be computed without | 3820 // Returns true if the hash of this string can be computed without |
| 3723 // looking at the contents. | 3821 // looking at the contents. |
| (...skipping 1256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4980 } else { | 5078 } else { |
| 4981 value &= ~(1 << bit_position); | 5079 value &= ~(1 << bit_position); |
| 4982 } | 5080 } |
| 4983 return value; | 5081 return value; |
| 4984 } | 5082 } |
| 4985 }; | 5083 }; |
| 4986 | 5084 |
| 4987 } } // namespace v8::internal | 5085 } } // namespace v8::internal |
| 4988 | 5086 |
| 4989 #endif // V8_OBJECTS_H_ | 5087 #endif // V8_OBJECTS_H_ |
| OLD | NEW |