| 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 whether to keep |
| 175 // inobject properties when normalizing properties of a JSObject. |
| 176 enum PropertyNormalizationMode { |
| 177 CLEAR_INOBJECT_PROPERTIES, |
| 178 KEEP_INOBJECT_PROPERTIES |
| 179 }; |
| 180 |
| 181 |
| 172 // All Maps have a field instance_type containing a InstanceType. | 182 // All Maps have a field instance_type containing a InstanceType. |
| 173 // It describes the type of the instances. | 183 // It describes the type of the instances. |
| 174 // | 184 // |
| 175 // As an example, a JavaScript object is a heap object and its map | 185 // As an example, a JavaScript object is a heap object and its map |
| 176 // instance_type is JS_OBJECT_TYPE. | 186 // instance_type is JS_OBJECT_TYPE. |
| 177 // | 187 // |
| 178 // The names of the string instance types are intended to systematically | 188 // 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 | 189 // 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 | 190 // (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 | 191 // considered TWO_BYTE. It is not mentioned in the name. ASCII encoding is |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 V(FUNCTION_TEMPLATE_INFO_TYPE) \ | 271 V(FUNCTION_TEMPLATE_INFO_TYPE) \ |
| 262 V(OBJECT_TEMPLATE_INFO_TYPE) \ | 272 V(OBJECT_TEMPLATE_INFO_TYPE) \ |
| 263 V(SIGNATURE_INFO_TYPE) \ | 273 V(SIGNATURE_INFO_TYPE) \ |
| 264 V(TYPE_SWITCH_INFO_TYPE) \ | 274 V(TYPE_SWITCH_INFO_TYPE) \ |
| 265 V(DEBUG_INFO_TYPE) \ | 275 V(DEBUG_INFO_TYPE) \ |
| 266 V(BREAK_POINT_INFO_TYPE) \ | 276 V(BREAK_POINT_INFO_TYPE) \ |
| 267 V(SCRIPT_TYPE) \ | 277 V(SCRIPT_TYPE) \ |
| 268 \ | 278 \ |
| 269 V(JS_VALUE_TYPE) \ | 279 V(JS_VALUE_TYPE) \ |
| 270 V(JS_OBJECT_TYPE) \ | 280 V(JS_OBJECT_TYPE) \ |
| 281 V(JS_CONTEXT_EXTENSION_OBJECT_TYPE) \ |
| 271 V(JS_GLOBAL_OBJECT_TYPE) \ | 282 V(JS_GLOBAL_OBJECT_TYPE) \ |
| 272 V(JS_BUILTINS_OBJECT_TYPE) \ | 283 V(JS_BUILTINS_OBJECT_TYPE) \ |
| 273 V(JS_GLOBAL_PROXY_TYPE) \ | 284 V(JS_GLOBAL_PROXY_TYPE) \ |
| 274 V(JS_ARRAY_TYPE) \ | 285 V(JS_ARRAY_TYPE) \ |
| 275 V(JS_REGEXP_TYPE) \ | 286 V(JS_REGEXP_TYPE) \ |
| 276 \ | 287 \ |
| 277 V(JS_FUNCTION_TYPE) \ | 288 V(JS_FUNCTION_TYPE) \ |
| 278 | 289 |
| 279 | 290 |
| 280 // Since string types are not consecutive, this macro is used to | 291 // Since string types are not consecutive, this macro is used to |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 FUNCTION_TEMPLATE_INFO_TYPE, | 529 FUNCTION_TEMPLATE_INFO_TYPE, |
| 519 OBJECT_TEMPLATE_INFO_TYPE, | 530 OBJECT_TEMPLATE_INFO_TYPE, |
| 520 SIGNATURE_INFO_TYPE, | 531 SIGNATURE_INFO_TYPE, |
| 521 TYPE_SWITCH_INFO_TYPE, | 532 TYPE_SWITCH_INFO_TYPE, |
| 522 DEBUG_INFO_TYPE, | 533 DEBUG_INFO_TYPE, |
| 523 BREAK_POINT_INFO_TYPE, | 534 BREAK_POINT_INFO_TYPE, |
| 524 SCRIPT_TYPE, | 535 SCRIPT_TYPE, |
| 525 | 536 |
| 526 JS_VALUE_TYPE, | 537 JS_VALUE_TYPE, |
| 527 JS_OBJECT_TYPE, | 538 JS_OBJECT_TYPE, |
| 539 JS_CONTEXT_EXTENSION_OBJECT_TYPE, |
| 528 JS_GLOBAL_OBJECT_TYPE, | 540 JS_GLOBAL_OBJECT_TYPE, |
| 529 JS_BUILTINS_OBJECT_TYPE, | 541 JS_BUILTINS_OBJECT_TYPE, |
| 530 JS_GLOBAL_PROXY_TYPE, | 542 JS_GLOBAL_PROXY_TYPE, |
| 531 JS_ARRAY_TYPE, | 543 JS_ARRAY_TYPE, |
| 532 JS_REGEXP_TYPE, | 544 JS_REGEXP_TYPE, |
| 533 | 545 |
| 534 JS_FUNCTION_TYPE, | 546 JS_FUNCTION_TYPE, |
| 535 | 547 |
| 536 // Pseudo-types | 548 // Pseudo-types |
| 537 FIRST_NONSTRING_TYPE = MAP_TYPE, | 549 FIRST_NONSTRING_TYPE = MAP_TYPE, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 553 | 565 |
| 554 NOT_EQUAL = GREATER | 566 NOT_EQUAL = GREATER |
| 555 }; | 567 }; |
| 556 | 568 |
| 557 | 569 |
| 558 #define DECL_BOOLEAN_ACCESSORS(name) \ | 570 #define DECL_BOOLEAN_ACCESSORS(name) \ |
| 559 inline bool name(); \ | 571 inline bool name(); \ |
| 560 inline void set_##name(bool value); \ | 572 inline void set_##name(bool value); \ |
| 561 | 573 |
| 562 | 574 |
| 563 #define DECL_ACCESSORS(name, type) \ | 575 #define DECL_ACCESSORS(name, type) \ |
| 564 inline type* name(); \ | 576 inline type* name(); \ |
| 565 inline void set_##name(type* value, \ | 577 inline void set_##name(type* value, \ |
| 566 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ | 578 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ |
| 567 | 579 |
| 568 | 580 |
| 569 class StringStream; | 581 class StringStream; |
| 570 class ObjectVisitor; | 582 class ObjectVisitor; |
| 571 | 583 |
| 572 struct ValueInfo : public Malloced { | 584 struct ValueInfo : public Malloced { |
| 573 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } | 585 ValueInfo() : type(FIRST_TYPE), ptr(NULL), str(NULL), number(0) { } |
| 574 InstanceType type; | 586 InstanceType type; |
| 575 Object* ptr; | 587 Object* ptr; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 605 inline bool IsSeqTwoByteString(); | 617 inline bool IsSeqTwoByteString(); |
| 606 inline bool IsSeqAsciiString(); | 618 inline bool IsSeqAsciiString(); |
| 607 | 619 |
| 608 inline bool IsNumber(); | 620 inline bool IsNumber(); |
| 609 inline bool IsByteArray(); | 621 inline bool IsByteArray(); |
| 610 inline bool IsFailure(); | 622 inline bool IsFailure(); |
| 611 inline bool IsRetryAfterGC(); | 623 inline bool IsRetryAfterGC(); |
| 612 inline bool IsOutOfMemoryFailure(); | 624 inline bool IsOutOfMemoryFailure(); |
| 613 inline bool IsException(); | 625 inline bool IsException(); |
| 614 inline bool IsJSObject(); | 626 inline bool IsJSObject(); |
| 627 inline bool IsJSContextExtensionObject(); |
| 615 inline bool IsMap(); | 628 inline bool IsMap(); |
| 616 inline bool IsFixedArray(); | 629 inline bool IsFixedArray(); |
| 617 inline bool IsDescriptorArray(); | 630 inline bool IsDescriptorArray(); |
| 618 inline bool IsContext(); | 631 inline bool IsContext(); |
| 619 inline bool IsCatchContext(); | 632 inline bool IsCatchContext(); |
| 620 inline bool IsGlobalContext(); | 633 inline bool IsGlobalContext(); |
| 621 inline bool IsJSFunction(); | 634 inline bool IsJSFunction(); |
| 622 inline bool IsCode(); | 635 inline bool IsCode(); |
| 623 inline bool IsOddball(); | 636 inline bool IsOddball(); |
| 624 inline bool IsSharedFunctionInfo(); | 637 inline bool IsSharedFunctionInfo(); |
| (...skipping 725 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1350 Object* value, | 1363 Object* value, |
| 1351 PropertyAttributes attributes); | 1364 PropertyAttributes attributes); |
| 1352 | 1365 |
| 1353 // Add a property to an object. | 1366 // Add a property to an object. |
| 1354 Object* AddProperty(String* name, | 1367 Object* AddProperty(String* name, |
| 1355 Object* value, | 1368 Object* value, |
| 1356 PropertyAttributes attributes); | 1369 PropertyAttributes attributes); |
| 1357 | 1370 |
| 1358 // Convert the object to use the canonical dictionary | 1371 // Convert the object to use the canonical dictionary |
| 1359 // representation. | 1372 // representation. |
| 1360 Object* NormalizeProperties(); | 1373 Object* NormalizeProperties(PropertyNormalizationMode mode); |
| 1361 Object* NormalizeElements(); | 1374 Object* NormalizeElements(); |
| 1362 | 1375 |
| 1363 // Transform slow named properties to fast variants. | 1376 // Transform slow named properties to fast variants. |
| 1364 // Returns failure if allocation failed. | 1377 // Returns failure if allocation failed. |
| 1365 Object* TransformToFastProperties(int unused_property_fields); | 1378 Object* TransformToFastProperties(int unused_property_fields); |
| 1366 | 1379 |
| 1367 // Access fast-case object properties at index. | 1380 // Access fast-case object properties at index. |
| 1368 inline Object* FastPropertyAt(int index); | 1381 inline Object* FastPropertyAt(int index); |
| 1369 inline Object* FastPropertyAtPut(int index, Object* value); | 1382 inline Object* FastPropertyAtPut(int index, Object* value); |
| 1370 | 1383 |
| (...skipping 913 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2284 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); | 2297 DISALLOW_IMPLICIT_CONSTRUCTORS(Code); |
| 2285 }; | 2298 }; |
| 2286 | 2299 |
| 2287 | 2300 |
| 2288 // All heap objects have a Map that describes their structure. | 2301 // All heap objects have a Map that describes their structure. |
| 2289 // A Map contains information about: | 2302 // A Map contains information about: |
| 2290 // - Size information about the object | 2303 // - Size information about the object |
| 2291 // - How to iterate over an object (for garbage collection) | 2304 // - How to iterate over an object (for garbage collection) |
| 2292 class Map: public HeapObject { | 2305 class Map: public HeapObject { |
| 2293 public: | 2306 public: |
| 2294 // instance size. | 2307 // Instance size. |
| 2295 inline int instance_size(); | 2308 inline int instance_size(); |
| 2296 inline void set_instance_size(int value); | 2309 inline void set_instance_size(int value); |
| 2297 | 2310 |
| 2298 // Count of properties allocated in the object. | 2311 // Count of properties allocated in the object. |
| 2299 inline int inobject_properties(); | 2312 inline int inobject_properties(); |
| 2300 inline void set_inobject_properties(int value); | 2313 inline void set_inobject_properties(int value); |
| 2301 | 2314 |
| 2302 // instance type. | 2315 // Instance type. |
| 2303 inline InstanceType instance_type(); | 2316 inline InstanceType instance_type(); |
| 2304 inline void set_instance_type(InstanceType value); | 2317 inline void set_instance_type(InstanceType value); |
| 2305 | 2318 |
| 2306 // tells how many unused property fields are available in the instance. | 2319 // Tells how many unused property fields are available in the |
| 2307 // (only used for JSObject in fast mode). | 2320 // instance (only used for JSObject in fast mode). |
| 2308 inline int unused_property_fields(); | 2321 inline int unused_property_fields(); |
| 2309 inline void set_unused_property_fields(int value); | 2322 inline void set_unused_property_fields(int value); |
| 2310 | 2323 |
| 2311 // bit field. | 2324 // Bit field. |
| 2312 inline byte bit_field(); | 2325 inline byte bit_field(); |
| 2313 inline void set_bit_field(byte value); | 2326 inline void set_bit_field(byte value); |
| 2314 | 2327 |
| 2315 // Tells whether the object in the prototype property will be used | 2328 // Tells whether the object in the prototype property will be used |
| 2316 // for instances created from this function. If the prototype | 2329 // for instances created from this function. If the prototype |
| 2317 // 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 |
| 2318 // property will not be used to create instances of the function. | 2331 // property will not be used to create instances of the function. |
| 2319 // See ECMA-262, 13.2.2. | 2332 // See ECMA-262, 13.2.2. |
| 2320 inline void set_non_instance_prototype(bool value); | 2333 inline void set_non_instance_prototype(bool value); |
| 2321 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... |
| 2454 static const int kInstanceDescriptorsOffset = | 2467 static const int kInstanceDescriptorsOffset = |
| 2455 kConstructorOffset + kPointerSize; | 2468 kConstructorOffset + kPointerSize; |
| 2456 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; | 2469 static const int kCodeCacheOffset = kInstanceDescriptorsOffset + kPointerSize; |
| 2457 static const int kSize = kCodeCacheOffset + kIntSize; | 2470 static const int kSize = kCodeCacheOffset + kIntSize; |
| 2458 | 2471 |
| 2459 // Byte offsets within kInstanceSizesOffset. | 2472 // Byte offsets within kInstanceSizesOffset. |
| 2460 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; | 2473 static const int kInstanceSizeOffset = kInstanceSizesOffset + 0; |
| 2461 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; | 2474 static const int kInObjectPropertiesOffset = kInstanceSizesOffset + 1; |
| 2462 // 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. |
| 2463 | 2476 |
| 2464 | |
| 2465 // Byte offsets within kInstanceAttributesOffset attributes. | 2477 // Byte offsets within kInstanceAttributesOffset attributes. |
| 2466 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; | 2478 static const int kInstanceTypeOffset = kInstanceAttributesOffset + 0; |
| 2467 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; | 2479 static const int kUnusedPropertyFieldsOffset = kInstanceAttributesOffset + 1; |
| 2468 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; | 2480 static const int kBitFieldOffset = kInstanceAttributesOffset + 2; |
| 2469 // 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. |
| 2470 | 2482 |
| 2471 // Bit positions for bit field. | 2483 // Bit positions for bit field. |
| 2472 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. |
| 2473 static const int kHasNonInstancePrototype = 1; | 2485 static const int kHasNonInstancePrototype = 1; |
| 2474 static const int kIsHiddenPrototype = 2; | 2486 static const int kIsHiddenPrototype = 2; |
| (...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4204 } else { | 4216 } else { |
| 4205 value &= ~(1 << bit_position); | 4217 value &= ~(1 << bit_position); |
| 4206 } | 4218 } |
| 4207 return value; | 4219 return value; |
| 4208 } | 4220 } |
| 4209 }; | 4221 }; |
| 4210 | 4222 |
| 4211 } } // namespace v8::internal | 4223 } } // namespace v8::internal |
| 4212 | 4224 |
| 4213 #endif // V8_OBJECTS_H_ | 4225 #endif // V8_OBJECTS_H_ |
| OLD | NEW |