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 2686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2697 class Map: public HeapObject { | 2697 class Map: public HeapObject { |
2698 public: | 2698 public: |
2699 // Instance size. | 2699 // Instance size. |
2700 inline int instance_size(); | 2700 inline int instance_size(); |
2701 inline void set_instance_size(int value); | 2701 inline void set_instance_size(int value); |
2702 | 2702 |
2703 // Count of properties allocated in the object. | 2703 // Count of properties allocated in the object. |
2704 inline int inobject_properties(); | 2704 inline int inobject_properties(); |
2705 inline void set_inobject_properties(int value); | 2705 inline void set_inobject_properties(int value); |
2706 | 2706 |
| 2707 // Count of property fields pre-allocated in the object when first allocated. |
| 2708 inline int pre_allocated_property_fields(); |
| 2709 inline void set_pre_allocated_property_fields(int value); |
| 2710 |
2707 // Instance type. | 2711 // Instance type. |
2708 inline InstanceType instance_type(); | 2712 inline InstanceType instance_type(); |
2709 inline void set_instance_type(InstanceType value); | 2713 inline void set_instance_type(InstanceType value); |
2710 | 2714 |
2711 // Tells how many unused property fields are available in the | 2715 // Tells how many unused property fields are available in the |
2712 // instance (only used for JSObject in fast mode). | 2716 // instance (only used for JSObject in fast mode). |
2713 inline int unused_property_fields(); | 2717 inline int unused_property_fields(); |
2714 inline void set_unused_property_fields(int value); | 2718 inline void set_unused_property_fields(int value); |
2715 | 2719 |
2716 // Bit field. | 2720 // Bit field. |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2862 // following back pointers. | 2866 // following back pointers. |
2863 void ClearNonLiveTransitions(Object* real_prototype); | 2867 void ClearNonLiveTransitions(Object* real_prototype); |
2864 | 2868 |
2865 // Dispatched behavior. | 2869 // Dispatched behavior. |
2866 void MapIterateBody(ObjectVisitor* v); | 2870 void MapIterateBody(ObjectVisitor* v); |
2867 #ifdef DEBUG | 2871 #ifdef DEBUG |
2868 void MapPrint(); | 2872 void MapPrint(); |
2869 void MapVerify(); | 2873 void MapVerify(); |
2870 #endif | 2874 #endif |
2871 | 2875 |
| 2876 static const int kMaxPreAllocatedPropertyFields = 255; |
| 2877 |
2872 // Layout description. | 2878 // Layout description. |
2873 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 2879 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
2874 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 2880 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
2875 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 2881 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
2876 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 2882 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
2877 static const int kInstanceDescriptorsOffset = | 2883 static const int kInstanceDescriptorsOffset = |
2878 kConstructorOffset + kPointerSize; | 2884 kConstructorOffset + kPointerSize; |
2879 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 2885 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
2880 static const int kSize = kCodeCacheOffset + kPointerSize; | 2886 static const int kSize = kCodeCacheOffset + kPointerSize; |
2881 | 2887 |
2882 // Byte offsets within kInstanceSizesOffset. | 2888 // Byte offsets within kInstanceSizesOffset. |
2883 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 2889 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
2884 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; | 2890 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; |
2885 // The bytes at positions 2 and 3 are not in use at the moment. | 2891 static const int kPreAllocatedPropertyFieldsOffset = kInstanceSizesOffset + 2; |
| 2892 // The byte at position 3 is not in use at the moment. |
2886 | 2893 |
2887 // Byte offsets within kInstanceAttributesOffset attributes. | 2894 // Byte offsets within kInstanceAttributesOffset attributes. |
2888 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 2895 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
2889 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 2896 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
2890 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 2897 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
2891 static const int kBitField2Offset = kInstanceAttributesOffset + 3; | 2898 static const int kBitField2Offset = kInstanceAttributesOffset + 3; |
2892 | 2899 |
2893 // Bit positions for bit field. | 2900 // Bit positions for bit field. |
2894 static const int kUnused = 0; // To be used for marking recently used maps. | 2901 static const int kUnused = 0; // To be used for marking recently used maps. |
2895 static const int kHasNonInstancePrototype = 1; | 2902 static const int kHasNonInstancePrototype = 1; |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3083 // Is this function a function expression in the source code. | 3090 // Is this function a function expression in the source code. |
3084 inline bool is_expression(); | 3091 inline bool is_expression(); |
3085 inline void set_is_expression(bool value); | 3092 inline void set_is_expression(bool value); |
3086 | 3093 |
3087 // Is this function a top-level function. Used for accessing the | 3094 // Is this function a top-level function. Used for accessing the |
3088 // caller of functions. Top-level functions (scripts, evals) are | 3095 // caller of functions. Top-level functions (scripts, evals) are |
3089 // returned as null; see JSFunction::GetCallerAccessor(...). | 3096 // returned as null; see JSFunction::GetCallerAccessor(...). |
3090 inline bool is_toplevel(); | 3097 inline bool is_toplevel(); |
3091 inline void set_is_toplevel(bool value); | 3098 inline void set_is_toplevel(bool value); |
3092 | 3099 |
| 3100 // Bit field containing various information collected by the compiler to |
| 3101 // drive optimization. |
| 3102 inline int compiler_hints(); |
| 3103 inline void set_compiler_hints(int value); |
| 3104 |
| 3105 // Add information on assignments of the form this.x = ...; |
| 3106 void SetThisPropertyAssignmentsInfo( |
| 3107 bool has_only_this_property_assignments, |
| 3108 bool has_only_simple_this_property_assignments, |
| 3109 FixedArray* this_property_assignments); |
| 3110 |
| 3111 // Indicate that this function only consists of assignments of the form |
| 3112 // this.x = ...;. |
| 3113 inline bool has_only_this_property_assignments(); |
| 3114 |
| 3115 // Indicate that this function only consists of assignments of the form |
| 3116 // this.x = y; where y is either a constant or refers to an argument. |
| 3117 inline bool has_only_simple_this_property_assignments(); |
| 3118 |
| 3119 // For functions which only contains this property assignments this provides |
| 3120 // access to the names for the properties assigned. |
| 3121 DECL_ACCESSORS(this_property_assignments, Object) |
| 3122 inline int this_property_assignments_count(); |
| 3123 inline void set_this_property_assignments_count(int value); |
| 3124 String* GetThisPropertyAssignmentName(int index); |
| 3125 |
3093 // [source code]: Source code for the function. | 3126 // [source code]: Source code for the function. |
3094 bool HasSourceCode(); | 3127 bool HasSourceCode(); |
3095 Object* GetSourceCode(); | 3128 Object* GetSourceCode(); |
3096 | 3129 |
| 3130 // Calculate the instance size. |
| 3131 int CalculateInstanceSize(); |
| 3132 |
| 3133 // Calculate the number of in-object properties. |
| 3134 int CalculateInObjectProperties(); |
| 3135 |
3097 // Dispatched behavior. | 3136 // Dispatched behavior. |
3098 void SharedFunctionInfoIterateBody(ObjectVisitor* v); | 3137 void SharedFunctionInfoIterateBody(ObjectVisitor* v); |
3099 // Set max_length to -1 for unlimited length. | 3138 // Set max_length to -1 for unlimited length. |
3100 void SourceCodePrint(StringStream* accumulator, int max_length); | 3139 void SourceCodePrint(StringStream* accumulator, int max_length); |
3101 #ifdef DEBUG | 3140 #ifdef DEBUG |
3102 void SharedFunctionInfoPrint(); | 3141 void SharedFunctionInfoPrint(); |
3103 void SharedFunctionInfoVerify(); | 3142 void SharedFunctionInfoVerify(); |
3104 #endif | 3143 #endif |
3105 | 3144 |
3106 // Casting. | 3145 // Casting. |
(...skipping 15 matching lines...) Expand all Loading... |
3122 kExpectedNofPropertiesOffset + kIntSize; | 3161 kExpectedNofPropertiesOffset + kIntSize; |
3123 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; | 3162 static const int kEndPositionOffset = kStartPositionAndTypeOffset + kIntSize; |
3124 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; | 3163 static const int kFunctionTokenPositionOffset = kEndPositionOffset + kIntSize; |
3125 static const int kInstanceClassNameOffset = | 3164 static const int kInstanceClassNameOffset = |
3126 kFunctionTokenPositionOffset + kIntSize; | 3165 kFunctionTokenPositionOffset + kIntSize; |
3127 static const int kExternalReferenceDataOffset = | 3166 static const int kExternalReferenceDataOffset = |
3128 kInstanceClassNameOffset + kPointerSize; | 3167 kInstanceClassNameOffset + kPointerSize; |
3129 static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize; | 3168 static const int kScriptOffset = kExternalReferenceDataOffset + kPointerSize; |
3130 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; | 3169 static const int kDebugInfoOffset = kScriptOffset + kPointerSize; |
3131 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; | 3170 static const int kInferredNameOffset = kDebugInfoOffset + kPointerSize; |
3132 static const int kSize = kInferredNameOffset + kPointerSize; | 3171 static const int kCompilerHintsOffset = kInferredNameOffset + kPointerSize; |
| 3172 static const int kThisPropertyAssignmentsOffset = |
| 3173 kCompilerHintsOffset + kPointerSize; |
| 3174 static const int kThisPropertyAssignmentsCountOffset = |
| 3175 kThisPropertyAssignmentsOffset + kPointerSize; |
| 3176 static const int kSize = kThisPropertyAssignmentsCountOffset + kPointerSize; |
3133 | 3177 |
3134 private: | 3178 private: |
3135 // Bit positions in length_and_flg. | 3179 // Bit positions in length_and_flg. |
3136 // The least significant bit is used as the flag. | 3180 // The least significant bit is used as the flag. |
3137 static const int kFlagBit = 0; | 3181 static const int kFlagBit = 0; |
3138 static const int kLengthShift = 1; | 3182 static const int kLengthShift = 1; |
3139 static const int kLengthMask = ~((1 << kLengthShift) - 1); | 3183 static const int kLengthMask = ~((1 << kLengthShift) - 1); |
3140 | 3184 |
3141 // Bit positions in start_position_and_type. | 3185 // Bit positions in start_position_and_type. |
3142 // The source code start position is in the 30 most significant bits of | 3186 // The source code start position is in the 30 most significant bits of |
3143 // the start_position_and_type field. | 3187 // the start_position_and_type field. |
3144 static const int kIsExpressionBit = 0; | 3188 static const int kIsExpressionBit = 0; |
3145 static const int kIsTopLevelBit = 1; | 3189 static const int kIsTopLevelBit = 1; |
3146 static const int kStartPositionShift = 2; | 3190 static const int kStartPositionShift = 2; |
3147 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); | 3191 static const int kStartPositionMask = ~((1 << kStartPositionShift) - 1); |
3148 | 3192 |
| 3193 // Bit positions in compiler_hints. |
| 3194 static const int kHasOnlyThisPropertyAssignments = 0; |
| 3195 static const int kHasOnlySimpleThisPropertyAssignments = 1; |
| 3196 |
3149 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); | 3197 DISALLOW_IMPLICIT_CONSTRUCTORS(SharedFunctionInfo); |
3150 }; | 3198 }; |
3151 | 3199 |
3152 | 3200 |
3153 // JSFunction describes JavaScript functions. | 3201 // JSFunction describes JavaScript functions. |
3154 class JSFunction: public JSObject { | 3202 class JSFunction: public JSObject { |
3155 public: | 3203 public: |
3156 // [prototype_or_initial_map]: | 3204 // [prototype_or_initial_map]: |
3157 DECL_ACCESSORS(prototype_or_initial_map, Object) | 3205 DECL_ACCESSORS(prototype_or_initial_map, Object) |
3158 | 3206 |
(...skipping 1630 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4789 } else { | 4837 } else { |
4790 value &= ~(1 << bit_position); | 4838 value &= ~(1 << bit_position); |
4791 } | 4839 } |
4792 return value; | 4840 return value; |
4793 } | 4841 } |
4794 }; | 4842 }; |
4795 | 4843 |
4796 } } // namespace v8::internal | 4844 } } // namespace v8::internal |
4797 | 4845 |
4798 #endif // V8_OBJECTS_H_ | 4846 #endif // V8_OBJECTS_H_ |
OLD | NEW |