OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 class TypeField: public BitField<PropertyType, 0, 3> {}; | 159 class TypeField: public BitField<PropertyType, 0, 3> {}; |
160 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; | 160 class AttributesField: public BitField<PropertyAttributes, 3, 3> {}; |
161 class IndexField: public BitField<uint32_t, 6, 32-6> {}; | 161 class IndexField: public BitField<uint32_t, 6, 32-6> {}; |
162 | 162 |
163 static const int kInitialIndex = 1; | 163 static const int kInitialIndex = 1; |
164 | 164 |
165 private: | 165 private: |
166 uint32_t value_; | 166 uint32_t value_; |
167 }; | 167 }; |
168 | 168 |
| 169 |
169 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. | 170 // Setter that skips the write barrier if mode is SKIP_WRITE_BARRIER. |
170 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; | 171 enum WriteBarrierMode { SKIP_WRITE_BARRIER, UPDATE_WRITE_BARRIER }; |
171 | 172 |
| 173 |
| 174 // PropertyNormalizationMode is used to specify wheter or not to |
| 175 // keep inobject properties when normalizing properties of a |
| 176 // JSObject. |
| 177 enum PropertyNormalizationMode { |
| 178 CLEAR_INOBJECT_PROPERTIES, |
| 179 KEEP_INOBJECT_PROPERTIES |
| 180 }; |
| 181 |
| 182 |
172 // All Maps have a field instance_type containing a InstanceType. | 183 // All Maps have a field instance_type containing a InstanceType. |
173 // It describes the type of the instances. | 184 // It describes the type of the instances. |
174 // | 185 // |
175 // As an example, a JavaScript object is a heap object and its map | 186 // As an example, a JavaScript object is a heap object and its map |
176 // instance_type is JS_OBJECT_TYPE. | 187 // instance_type is JS_OBJECT_TYPE. |
177 // | 188 // |
178 // The names of the string instance types are intended to systematically | 189 // The names of the string instance types are intended to systematically |
179 // mirror their encoding in the instance_type field of the map. The length | 190 // mirror their encoding in the instance_type field of the map. The length |
180 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is | 191 // (SHORT, MEDIUM, or LONG) is always mentioned. The default encoding is |
181 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is | 192 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
553 | 564 |
554 NOT_EQUAL = GREATER | 565 NOT_EQUAL = GREATER |
555 }; | 566 }; |
556 | 567 |
557 | 568 |
558 #define DECL_BOOLEAN_ACCESSORS(name) \ | 569 #define DECL_BOOLEAN_ACCESSORS(name) \ |
559 inline bool name(); \ | 570 inline bool name(); \ |
560 inline void set_##name(bool value); \ | 571 inline void set_##name(bool value); \ |
561 | 572 |
562 | 573 |
563 #define DECL_ACCESSORS(name, type) \ | 574 #define DECL_ACCESSORS(name, type) \ |
564 inline type* name(); \ | 575 inline type* name(); \ |
565 inline void set_##name(type* value, \ | 576 inline void set_##name(type* value, \ |
566 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 577 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
567 | 578 |
568 | 579 |
569 class StringStream; | 580 class StringStream; |
570 class ObjectVisitor; | 581 class ObjectVisitor; |
571 | 582 |
572 struct ValueInfo : public Malloced { | 583 struct ValueInfo : public Malloced { |
573 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 584 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
574 InstanceType type; | 585 InstanceType type; |
575 Object* ptr; | 586 Object* ptr; |
(...skipping 774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1350 Object* value, | 1361 Object* value, |
1351 PropertyAttributes attributes); | 1362 PropertyAttributes attributes); |
1352 | 1363 |
1353 // Add a property to an object. | 1364 // Add a property to an object. |
1354 Object* AddProperty(String* name, | 1365 Object* AddProperty(String* name, |
1355 Object* value, | 1366 Object* value, |
1356 PropertyAttributes attributes); | 1367 PropertyAttributes attributes); |
1357 | 1368 |
1358 // Convert the object to use the canonical dictionary | 1369 // Convert the object to use the canonical dictionary |
1359 // representation. | 1370 // representation. |
1360 Object* NormalizeProperties(); | 1371 Object* NormalizeProperties(PropertyNormalizationMode mode); |
1361 Object* NormalizeElements(); | 1372 Object* NormalizeElements(); |
1362 | 1373 |
1363 // Transform slow named properties to fast variants. | 1374 // Transform slow named properties to fast variants. |
1364 // Returns failure if allocation failed. | 1375 // Returns failure if allocation failed. |
1365 Object* TransformToFastProperties(int unused_property_fields); | 1376 Object* TransformToFastProperties(int unused_property_fields); |
1366 | 1377 |
1367 // Access fast-case object properties at index. | 1378 // Access fast-case object properties at index. |
1368 inline Object* FastPropertyAt(int index); | 1379 inline Object* FastPropertyAt(int index); |
1369 inline Object* FastPropertyAtPut(int index, Object* value); | 1380 inline Object* FastPropertyAtPut(int index, Object* value); |
1370 | 1381 |
(...skipping 915 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2286 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 2297 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
2287 }; | 2298 }; |
2288 | 2299 |
2289 | 2300 |
2290 // All heap objects have a Map that describes their structure. | 2301 // All heap objects have a Map that describes their structure. |
2291 // A Map contains information about: | 2302 // A Map contains information about: |
2292 // - Size information about the object | 2303 // - Size information about the object |
2293 // - How to iterate over an object (for garbage collection) | 2304 // - How to iterate over an object (for garbage collection) |
2294 class Map: public HeapObject { | 2305 class Map: public HeapObject { |
2295 public: | 2306 public: |
2296 // instance size. | 2307 // Instance size. |
2297 inline int instance_size(); | 2308 inline int instance_size(); |
2298 inline void set_instance_size(int value); | 2309 inline void set_instance_size(int value); |
2299 | 2310 |
2300 // Count of properties allocated in the object. | 2311 // Count of properties allocated in the object. |
2301 inline int inobject_properties(); | 2312 inline int inobject_properties(); |
2302 inline void set_inobject_properties(int value); | 2313 inline void set_inobject_properties(int value); |
2303 | 2314 |
2304 // instance type. | 2315 // Instance type. |
2305 inline InstanceType instance_type(); | 2316 inline InstanceType instance_type(); |
2306 inline void set_instance_type(InstanceType value); | 2317 inline void set_instance_type(InstanceType value); |
2307 | 2318 |
2308 // tells how many unused property fields are available in the instance. | 2319 // Tells how many unused property fields are available in the |
2309 // (only used for JSObject in fast mode). | 2320 // instance (only used for JSObject in fast mode). |
2310 inline int unused_property_fields(); | 2321 inline int unused_property_fields(); |
2311 inline void set_unused_property_fields(int value); | 2322 inline void set_unused_property_fields(int value); |
2312 | 2323 |
2313 // bit field. | 2324 // Bit field. |
2314 inline byte bit_field(); | 2325 inline byte bit_field(); |
2315 inline void set_bit_field(byte value); | 2326 inline void set_bit_field(byte value); |
2316 | 2327 |
2317 // Tells whether the object in the prototype property will be used | 2328 // Tells whether the object in the prototype property will be used |
2318 // for instances created from this function. If the prototype | 2329 // for instances created from this function. If the prototype |
2319 // property is set to a value that is not a JSObject, the prototype | 2330 // property is set to a value that is not a JSObject, the prototype |
2320 // property will not be used to create instances of the function. | 2331 // property will not be used to create instances of the function. |
2321 // See ECMA-262, 13.2.2. | 2332 // See ECMA-262, 13.2.2. |
2322 inline void set_non_instance_prototype(bool value); | 2333 inline void set_non_instance_prototype(bool value); |
2323 inline bool has_non_instance_prototype(); | 2334 inline bool has_non_instance_prototype(); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2456 static const int kInstanceDescriptorsOffset = | 2467 static const int kInstanceDescriptorsOffset = |
2457 kConstructorOffset + kPointerSize; | 2468 kConstructorOffset + kPointerSize; |
2458 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 2469 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
2459 static const int kSize = kCodeCacheOffset + kIntSize; | 2470 static const int kSize = kCodeCacheOffset + kIntSize; |
2460 | 2471 |
2461 // Byte offsets within kInstanceSizesOffset. | 2472 // Byte offsets within kInstanceSizesOffset. |
2462 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 2473 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
2463 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; | 2474 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; |
2464 // The bytes at positions 2 and 3 are not in use at the moment. | 2475 // The bytes at positions 2 and 3 are not in use at the moment. |
2465 | 2476 |
2466 | |
2467 // Byte offsets within kInstanceAttributesOffset attributes. | 2477 // Byte offsets within kInstanceAttributesOffset attributes. |
2468 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 2478 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
2469 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 2479 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
2470 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 2480 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
2471 // The byte at position 3 is not in use at the moment. | 2481 // The byte at position 3 is not in use at the moment. |
2472 | 2482 |
2473 // Bit positions for bit field. | 2483 // Bit positions for bit field. |
2474 static const int kUnused = 0; // To be used for marking recently used maps. | 2484 static const int kUnused = 0; // To be used for marking recently used maps. |
2475 static const int kHasNonInstancePrototype = 1; | 2485 static const int kHasNonInstancePrototype = 1; |
2476 static const int kIsHiddenPrototype = 2; | 2486 static const int kIsHiddenPrototype = 2; |
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4206 } else { | 4216 } else { |
4207 value &= ~(1 << bit_position); | 4217 value &= ~(1 << bit_position); |
4208 } | 4218 } |
4209 return value; | 4219 return value; |
4210 } | 4220 } |
4211 }; | 4221 }; |
4212 | 4222 |
4213 } } // namespace v8::internal | 4223 } } // namespace v8::internal |
4214 | 4224 |
4215 #endif // V8_OBJECTS_H_ | 4225 #endif // V8_OBJECTS_H_ |
OLD | NEW |