| 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 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 // mark an object as live and/or overflowed: | 1145 // mark an object as live and/or overflowed: |
| 1146 // last bit = 0, marked as alive | 1146 // last bit = 0, marked as alive |
| 1147 // second bit = 1, overflowed | 1147 // second bit = 1, overflowed |
| 1148 // An object is only marked as overflowed when it is marked as live while | 1148 // An object is only marked as overflowed when it is marked as live while |
| 1149 // the marking stack is overflowed. | 1149 // the marking stack is overflowed. |
| 1150 static const int kMarkingBit = 0; // marking bit | 1150 static const int kMarkingBit = 0; // marking bit |
| 1151 static const int kMarkingMask = (1 << kMarkingBit); // marking mask | 1151 static const int kMarkingMask = (1 << kMarkingBit); // marking mask |
| 1152 static const int kOverflowBit = 1; // overflow bit | 1152 static const int kOverflowBit = 1; // overflow bit |
| 1153 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask | 1153 static const int kOverflowMask = (1 << kOverflowBit); // overflow mask |
| 1154 | 1154 |
| 1155 // Forwarding pointers and map pointer encoding | 1155 // Forwarding pointers and map pointer encoding. On 32 bit all the bits are |
| 1156 // 31 21 20 10 9 0 | 1156 // used. |
| 1157 // +-----------------+------------------+-----------------+ | 1157 // +-----------------+------------------+-----------------+ |
| 1158 // |forwarding offset|page offset of map|page index of map| | 1158 // |forwarding offset|page offset of map|page index of map| |
| 1159 // +-----------------+------------------+-----------------+ | 1159 // +-----------------+------------------+-----------------+ |
| 1160 // 11 bits 11 bits 10 bits | 1160 // ^ ^ ^ |
| 1161 static const int kMapPageIndexBits = 10; | 1161 // | | | |
| 1162 static const int kMapPageOffsetBits = 11; | 1162 // | | kMapPageIndexBits |
| 1163 static const int kForwardingOffsetBits = 11; | 1163 // | kMapPageOffsetBits |
| 1164 // kForwardingOffsetBits |
| 1165 static const int kMapPageOffsetBits = kPageSizeBits - kMapAlignmentBits; |
| 1166 static const int kForwardingOffsetBits = kPageSizeBits - kObjectAlignmentBits; |
| 1167 #ifdef V8_HOST_ARCH_64_BIT |
| 1168 static const int kMapPageIndexBits = 16; |
| 1169 #else |
| 1170 // Use all the 32-bits to encode on a 32-bit platform. |
| 1171 static const int kMapPageIndexBits = |
| 1172 32 - (kMapPageOffsetBits + kForwardingOffsetBits); |
| 1173 #endif |
| 1164 | 1174 |
| 1165 static const int kMapPageIndexShift = 0; | 1175 static const int kMapPageIndexShift = 0; |
| 1166 static const int kMapPageOffsetShift = | 1176 static const int kMapPageOffsetShift = |
| 1167 kMapPageIndexShift + kMapPageIndexBits; | 1177 kMapPageIndexShift + kMapPageIndexBits; |
| 1168 static const int kForwardingOffsetShift = | 1178 static const int kForwardingOffsetShift = |
| 1169 kMapPageOffsetShift + kMapPageOffsetBits; | 1179 kMapPageOffsetShift + kMapPageOffsetBits; |
| 1170 | 1180 |
| 1171 // 0x000003FF | 1181 // Bit masks covering the different parts the encoding. |
| 1172 static const uint32_t kMapPageIndexMask = | 1182 static const uintptr_t kMapPageIndexMask = |
| 1173 (1 << kMapPageOffsetShift) - 1; | 1183 (1 << kMapPageOffsetShift) - 1; |
| 1174 | 1184 static const uintptr_t kMapPageOffsetMask = |
| 1175 // 0x001FFC00 | |
| 1176 static const uint32_t kMapPageOffsetMask = | |
| 1177 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; | 1185 ((1 << kForwardingOffsetShift) - 1) & ~kMapPageIndexMask; |
| 1178 | 1186 static const uintptr_t kForwardingOffsetMask = |
| 1179 // 0xFFE00000 | |
| 1180 static const uint32_t kForwardingOffsetMask = | |
| 1181 ~(kMapPageIndexMask | kMapPageOffsetMask); | 1187 ~(kMapPageIndexMask | kMapPageOffsetMask); |
| 1182 | 1188 |
| 1183 private: | 1189 private: |
| 1184 // HeapObject calls the private constructor and directly reads the value. | 1190 // HeapObject calls the private constructor and directly reads the value. |
| 1185 friend class HeapObject; | 1191 friend class HeapObject; |
| 1186 | 1192 |
| 1187 explicit MapWord(uintptr_t value) : value_(value) {} | 1193 explicit MapWord(uintptr_t value) : value_(value) {} |
| 1188 | 1194 |
| 1189 uintptr_t value_; | 1195 uintptr_t value_; |
| 1190 }; | 1196 }; |
| (...skipping 1898 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3089 | 3095 |
| 3090 // [constructor]: points back to the function responsible for this map. | 3096 // [constructor]: points back to the function responsible for this map. |
| 3091 DECL_ACCESSORS(constructor, Object) | 3097 DECL_ACCESSORS(constructor, Object) |
| 3092 | 3098 |
| 3093 // [instance descriptors]: describes the object. | 3099 // [instance descriptors]: describes the object. |
| 3094 DECL_ACCESSORS(instance_descriptors, DescriptorArray) | 3100 DECL_ACCESSORS(instance_descriptors, DescriptorArray) |
| 3095 | 3101 |
| 3096 // [stub cache]: contains stubs compiled for this map. | 3102 // [stub cache]: contains stubs compiled for this map. |
| 3097 DECL_ACCESSORS(code_cache, FixedArray) | 3103 DECL_ACCESSORS(code_cache, FixedArray) |
| 3098 | 3104 |
| 3099 // Returns a copy of the map. | |
| 3100 Object* CopyDropDescriptors(); | 3105 Object* CopyDropDescriptors(); |
| 3101 | 3106 |
| 3102 // Returns a copy of the map, with all transitions dropped from the | 3107 // Returns a copy of the map, with all transitions dropped from the |
| 3103 // instance descriptors. | 3108 // instance descriptors. |
| 3104 Object* CopyDropTransitions(); | 3109 Object* CopyDropTransitions(); |
| 3105 | 3110 |
| 3106 // Returns the property index for name (only valid for FAST MODE). | 3111 // Returns the property index for name (only valid for FAST MODE). |
| 3107 int PropertyIndexFor(String* name); | 3112 int PropertyIndexFor(String* name); |
| 3108 | 3113 |
| 3109 // Returns the next free property index (only valid for FAST MODE). | 3114 // Returns the next free property index (only valid for FAST MODE). |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3157 static const int kMaxPreAllocatedPropertyFields = 255; | 3162 static const int kMaxPreAllocatedPropertyFields = 255; |
| 3158 | 3163 |
| 3159 // Layout description. | 3164 // Layout description. |
| 3160 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; | 3165 static const int kInstanceSizesOffset = HeapObject::kHeaderSize; |
| 3161 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; | 3166 static const int kInstanceAttributesOffset = kInstanceSizesOffset + kIntSize; |
| 3162 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; | 3167 static const int kPrototypeOffset = kInstanceAttributesOffset + kIntSize; |
| 3163 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; | 3168 static const int kConstructorOffset = kPrototypeOffset + kPointerSize; |
| 3164 static const int kInstanceDescriptorsOffset = | 3169 static const int kInstanceDescriptorsOffset = |
| 3165 kConstructorOffset + kPointerSize; | 3170 kConstructorOffset + kPointerSize; |
| 3166 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 3171 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
| 3167 static const int kSize = kCodeCacheOffset + kPointerSize; | 3172 static const int kPadStart = kCodeCacheOffset + kPointerSize; |
| 3173 static const int kSize = MAP_SIZE_ALIGN(kPadStart); |
| 3168 | 3174 |
| 3169 // Byte offsets within kInstanceSizesOffset. | 3175 // Byte offsets within kInstanceSizesOffset. |
| 3170 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 3176 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 3171 static const int kInObjectPropertiesByte = 1; | 3177 static const int kInObjectPropertiesByte = 1; |
| 3172 static const int kInObjectPropertiesOffset = | 3178 static const int kInObjectPropertiesOffset = |
| 3173 kInstanceSizesOffset + kInObjectPropertiesByte; | 3179 kInstanceSizesOffset + kInObjectPropertiesByte; |
| 3174 static const int kPreAllocatedPropertyFieldsByte = 2; | 3180 static const int kPreAllocatedPropertyFieldsByte = 2; |
| 3175 static const int kPreAllocatedPropertyFieldsOffset = | 3181 static const int kPreAllocatedPropertyFieldsOffset = |
| 3176 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; | 3182 kInstanceSizesOffset + kPreAllocatedPropertyFieldsByte; |
| 3177 // The byte at position 3 is not in use at the moment. | 3183 // The byte at position 3 is not in use at the moment. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3256 | 3262 |
| 3257 // [type]: the script type. | 3263 // [type]: the script type. |
| 3258 DECL_ACCESSORS(type, Smi) | 3264 DECL_ACCESSORS(type, Smi) |
| 3259 | 3265 |
| 3260 // [compilation]: how the the script was compiled. | 3266 // [compilation]: how the the script was compiled. |
| 3261 DECL_ACCESSORS(compilation_type, Smi) | 3267 DECL_ACCESSORS(compilation_type, Smi) |
| 3262 | 3268 |
| 3263 // [line_ends]: FixedArray of line ends positions. | 3269 // [line_ends]: FixedArray of line ends positions. |
| 3264 DECL_ACCESSORS(line_ends, Object) | 3270 DECL_ACCESSORS(line_ends, Object) |
| 3265 | 3271 |
| 3266 // [eval_from_function]: for eval scripts the funcion from which eval was | 3272 // [eval_from_shared]: for eval scripts the shared funcion info for the |
| 3267 // called. | 3273 // function from which eval was called. |
| 3268 DECL_ACCESSORS(eval_from_function, Object) | 3274 DECL_ACCESSORS(eval_from_shared, Object) |
| 3269 | 3275 |
| 3270 // [eval_from_instructions_offset]: the instruction offset in the code for the | 3276 // [eval_from_instructions_offset]: the instruction offset in the code for the |
| 3271 // function from which eval was called where eval was called. | 3277 // function from which eval was called where eval was called. |
| 3272 DECL_ACCESSORS(eval_from_instructions_offset, Smi) | 3278 DECL_ACCESSORS(eval_from_instructions_offset, Smi) |
| 3273 | 3279 |
| 3274 static inline Script* cast(Object* obj); | 3280 static inline Script* cast(Object* obj); |
| 3275 | 3281 |
| 3276 // If script source is an external string, check that the underlying | 3282 // If script source is an external string, check that the underlying |
| 3277 // resource is accessible. Otherwise, always return true. | 3283 // resource is accessible. Otherwise, always return true. |
| 3278 inline bool HasValidSource(); | 3284 inline bool HasValidSource(); |
| 3279 | 3285 |
| 3280 #ifdef DEBUG | 3286 #ifdef DEBUG |
| 3281 void ScriptPrint(); | 3287 void ScriptPrint(); |
| 3282 void ScriptVerify(); | 3288 void ScriptVerify(); |
| 3283 #endif | 3289 #endif |
| 3284 | 3290 |
| 3285 static const int kSourceOffset = HeapObject::kHeaderSize; | 3291 static const int kSourceOffset = HeapObject::kHeaderSize; |
| 3286 static const int kNameOffset = kSourceOffset + kPointerSize; | 3292 static const int kNameOffset = kSourceOffset + kPointerSize; |
| 3287 static const int kLineOffsetOffset = kNameOffset + kPointerSize; | 3293 static const int kLineOffsetOffset = kNameOffset + kPointerSize; |
| 3288 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; | 3294 static const int kColumnOffsetOffset = kLineOffsetOffset + kPointerSize; |
| 3289 static const int kDataOffset = kColumnOffsetOffset + kPointerSize; | 3295 static const int kDataOffset = kColumnOffsetOffset + kPointerSize; |
| 3290 static const int kContextOffset = kDataOffset + kPointerSize; | 3296 static const int kContextOffset = kDataOffset + kPointerSize; |
| 3291 static const int kWrapperOffset = kContextOffset + kPointerSize; | 3297 static const int kWrapperOffset = kContextOffset + kPointerSize; |
| 3292 static const int kTypeOffset = kWrapperOffset + kPointerSize; | 3298 static const int kTypeOffset = kWrapperOffset + kPointerSize; |
| 3293 static const int kCompilationTypeOffset = kTypeOffset + kPointerSize; | 3299 static const int kCompilationTypeOffset = kTypeOffset + kPointerSize; |
| 3294 static const int kLineEndsOffset = kCompilationTypeOffset + kPointerSize; | 3300 static const int kLineEndsOffset = kCompilationTypeOffset + kPointerSize; |
| 3295 static const int kIdOffset = kLineEndsOffset + kPointerSize; | 3301 static const int kIdOffset = kLineEndsOffset + kPointerSize; |
| 3296 static const int kEvalFromFunctionOffset = kIdOffset + kPointerSize; | 3302 static const int kEvalFromSharedOffset = kIdOffset + kPointerSize; |
| 3297 static const int kEvalFrominstructionsOffsetOffset = | 3303 static const int kEvalFrominstructionsOffsetOffset = |
| 3298 kEvalFromFunctionOffset + kPointerSize; | 3304 kEvalFromSharedOffset + kPointerSize; |
| 3299 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize; | 3305 static const int kSize = kEvalFrominstructionsOffsetOffset + kPointerSize; |
| 3300 | 3306 |
| 3301 private: | 3307 private: |
| 3302 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); | 3308 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); |
| 3303 }; | 3309 }; |
| 3304 | 3310 |
| 3305 | 3311 |
| 3306 // SharedFunctionInfo describes the JSFunction information that can be | 3312 // SharedFunctionInfo describes the JSFunction information that can be |
| 3307 // shared by multiple instances of the function. | 3313 // shared by multiple instances of the function. |
| 3308 class SharedFunctionInfo: public HeapObject { | 3314 class SharedFunctionInfo: public HeapObject { |
| (...skipping 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5160 } else { | 5166 } else { |
| 5161 value &= ~(1 << bit_position); | 5167 value &= ~(1 << bit_position); |
| 5162 } | 5168 } |
| 5163 return value; | 5169 return value; |
| 5164 } | 5170 } |
| 5165 }; | 5171 }; |
| 5166 | 5172 |
| 5167 } } // namespace v8::internal | 5173 } } // namespace v8::internal |
| 5168 | 5174 |
| 5169 #endif // V8_OBJECTS_H_ | 5175 #endif // V8_OBJECTS_H_ |
| OLD | NEW |