OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 // - JSArray | 50 // - JSArray |
51 // - JSRegExp | 51 // - JSRegExp |
52 // - JSFunction | 52 // - JSFunction |
53 // - GlobalObject | 53 // - GlobalObject |
54 // - JSGlobalObject | 54 // - JSGlobalObject |
55 // - JSBuiltinsObject | 55 // - JSBuiltinsObject |
56 // - JSGlobalProxy | 56 // - JSGlobalProxy |
57 // - JSValue | 57 // - JSValue |
58 // - JSMessageObject | 58 // - JSMessageObject |
59 // - ByteArray | 59 // - ByteArray |
| 60 // - FreeSpace |
60 // - ExternalArray | 61 // - ExternalArray |
61 // - ExternalPixelArray | 62 // - ExternalPixelArray |
62 // - ExternalByteArray | 63 // - ExternalByteArray |
63 // - ExternalUnsignedByteArray | 64 // - ExternalUnsignedByteArray |
64 // - ExternalShortArray | 65 // - ExternalShortArray |
65 // - ExternalUnsignedShortArray | 66 // - ExternalUnsignedShortArray |
66 // - ExternalIntArray | 67 // - ExternalIntArray |
67 // - ExternalUnsignedIntArray | 68 // - ExternalUnsignedIntArray |
68 // - ExternalFloatArray | 69 // - ExternalFloatArray |
69 // - FixedArray | 70 // - FixedArray |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ | 256 V(PRIVATE_EXTERNAL_ASCII_STRING_TYPE) \ |
256 \ | 257 \ |
257 V(MAP_TYPE) \ | 258 V(MAP_TYPE) \ |
258 V(CODE_TYPE) \ | 259 V(CODE_TYPE) \ |
259 V(ODDBALL_TYPE) \ | 260 V(ODDBALL_TYPE) \ |
260 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ | 261 V(JS_GLOBAL_PROPERTY_CELL_TYPE) \ |
261 \ | 262 \ |
262 V(HEAP_NUMBER_TYPE) \ | 263 V(HEAP_NUMBER_TYPE) \ |
263 V(PROXY_TYPE) \ | 264 V(PROXY_TYPE) \ |
264 V(BYTE_ARRAY_TYPE) \ | 265 V(BYTE_ARRAY_TYPE) \ |
| 266 V(FREE_SPACE_TYPE) \ |
265 /* Note: the order of these external array */ \ | 267 /* Note: the order of these external array */ \ |
266 /* types is relied upon in */ \ | 268 /* types is relied upon in */ \ |
267 /* Object::IsExternalArray(). */ \ | 269 /* Object::IsExternalArray(). */ \ |
268 V(EXTERNAL_BYTE_ARRAY_TYPE) \ | 270 V(EXTERNAL_BYTE_ARRAY_TYPE) \ |
269 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ | 271 V(EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE) \ |
270 V(EXTERNAL_SHORT_ARRAY_TYPE) \ | 272 V(EXTERNAL_SHORT_ARRAY_TYPE) \ |
271 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ | 273 V(EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE) \ |
272 V(EXTERNAL_INT_ARRAY_TYPE) \ | 274 V(EXTERNAL_INT_ARRAY_TYPE) \ |
273 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ | 275 V(EXTERNAL_UNSIGNED_INT_ARRAY_TYPE) \ |
274 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ | 276 V(EXTERNAL_FLOAT_ARRAY_TYPE) \ |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE | 485 MAP_TYPE = kNotStringTag, // FIRST_NONSTRING_TYPE |
484 CODE_TYPE, | 486 CODE_TYPE, |
485 ODDBALL_TYPE, | 487 ODDBALL_TYPE, |
486 JS_GLOBAL_PROPERTY_CELL_TYPE, | 488 JS_GLOBAL_PROPERTY_CELL_TYPE, |
487 | 489 |
488 // "Data", objects that cannot contain non-map-word pointers to heap | 490 // "Data", objects that cannot contain non-map-word pointers to heap |
489 // objects. | 491 // objects. |
490 HEAP_NUMBER_TYPE, | 492 HEAP_NUMBER_TYPE, |
491 PROXY_TYPE, | 493 PROXY_TYPE, |
492 BYTE_ARRAY_TYPE, | 494 BYTE_ARRAY_TYPE, |
| 495 FREE_SPACE_TYPE, |
493 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 496 EXTERNAL_BYTE_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
494 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, | 497 EXTERNAL_UNSIGNED_BYTE_ARRAY_TYPE, |
495 EXTERNAL_SHORT_ARRAY_TYPE, | 498 EXTERNAL_SHORT_ARRAY_TYPE, |
496 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, | 499 EXTERNAL_UNSIGNED_SHORT_ARRAY_TYPE, |
497 EXTERNAL_INT_ARRAY_TYPE, | 500 EXTERNAL_INT_ARRAY_TYPE, |
498 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, | 501 EXTERNAL_UNSIGNED_INT_ARRAY_TYPE, |
499 EXTERNAL_FLOAT_ARRAY_TYPE, | 502 EXTERNAL_FLOAT_ARRAY_TYPE, |
500 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 503 EXTERNAL_PIXEL_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
501 FILLER_TYPE, // LAST_DATA_TYPE | 504 FILLER_TYPE, // LAST_DATA_TYPE |
502 | 505 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
658 V(ExternalArray) \ | 661 V(ExternalArray) \ |
659 V(ExternalByteArray) \ | 662 V(ExternalByteArray) \ |
660 V(ExternalUnsignedByteArray) \ | 663 V(ExternalUnsignedByteArray) \ |
661 V(ExternalShortArray) \ | 664 V(ExternalShortArray) \ |
662 V(ExternalUnsignedShortArray) \ | 665 V(ExternalUnsignedShortArray) \ |
663 V(ExternalIntArray) \ | 666 V(ExternalIntArray) \ |
664 V(ExternalUnsignedIntArray) \ | 667 V(ExternalUnsignedIntArray) \ |
665 V(ExternalFloatArray) \ | 668 V(ExternalFloatArray) \ |
666 V(ExternalPixelArray) \ | 669 V(ExternalPixelArray) \ |
667 V(ByteArray) \ | 670 V(ByteArray) \ |
| 671 V(FreeSpace) \ |
668 V(JSObject) \ | 672 V(JSObject) \ |
669 V(JSContextExtensionObject) \ | 673 V(JSContextExtensionObject) \ |
670 V(Map) \ | 674 V(Map) \ |
671 V(DescriptorArray) \ | 675 V(DescriptorArray) \ |
672 V(DeoptimizationInputData) \ | 676 V(DeoptimizationInputData) \ |
673 V(DeoptimizationOutputData) \ | 677 V(DeoptimizationOutputData) \ |
674 V(FixedArray) \ | 678 V(FixedArray) \ |
675 V(Context) \ | 679 V(Context) \ |
676 V(CatchContext) \ | 680 V(CatchContext) \ |
677 V(GlobalContext) \ | 681 V(GlobalContext) \ |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) | 730 STRUCT_LIST(DECLARE_STRUCT_PREDICATE) |
727 #undef DECLARE_STRUCT_PREDICATE | 731 #undef DECLARE_STRUCT_PREDICATE |
728 | 732 |
729 // Oddball testing. | 733 // Oddball testing. |
730 INLINE(bool IsUndefined()); | 734 INLINE(bool IsUndefined()); |
731 INLINE(bool IsNull()); | 735 INLINE(bool IsNull()); |
732 INLINE(bool IsTrue()); | 736 INLINE(bool IsTrue()); |
733 INLINE(bool IsFalse()); | 737 INLINE(bool IsFalse()); |
734 inline bool IsArgumentsMarker(); | 738 inline bool IsArgumentsMarker(); |
735 | 739 |
| 740 // Filler objects (fillers and free space objects). |
| 741 inline bool IsFiller(); |
| 742 |
736 // Extract the number. | 743 // Extract the number. |
737 inline double Number(); | 744 inline double Number(); |
738 | 745 |
739 inline bool HasSpecificClassOf(String* name); | 746 inline bool HasSpecificClassOf(String* name); |
740 | 747 |
741 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. | 748 MUST_USE_RESULT MaybeObject* ToObject(); // ECMA-262 9.9. |
742 Object* ToBoolean(); // ECMA-262 9.2. | 749 Object* ToBoolean(); // ECMA-262 9.2. |
743 | 750 |
744 // Convert to a JSObject if needed. | 751 // Convert to a JSObject if needed. |
745 // global_context is used when creating wrapper object. | 752 // global_context is used when creating wrapper object. |
(...skipping 1853 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2599 void NormalizedMapCacheVerify(); | 2606 void NormalizedMapCacheVerify(); |
2600 #endif | 2607 #endif |
2601 | 2608 |
2602 private: | 2609 private: |
2603 static int Hash(Map* fast); | 2610 static int Hash(Map* fast); |
2604 | 2611 |
2605 static bool CheckHit(Map* slow, Map* fast, PropertyNormalizationMode mode); | 2612 static bool CheckHit(Map* slow, Map* fast, PropertyNormalizationMode mode); |
2606 }; | 2613 }; |
2607 | 2614 |
2608 | 2615 |
2609 // ByteArray represents fixed sized byte arrays. Used by the outside world, | 2616 // ByteArray represents fixed sized byte arrays. Used for the relocation info |
2610 // such as PCRE, and also by the memory allocator and garbage collector to | 2617 // that is attached to code objects. |
2611 // fill in free blocks in the heap. | |
2612 class ByteArray: public HeapObject { | 2618 class ByteArray: public HeapObject { |
2613 public: | 2619 public: |
2614 // [length]: length of the array. | 2620 // [length]: length of the array. |
2615 inline int length(); | 2621 inline int length(); |
2616 inline void set_length(int value); | 2622 inline void set_length(int value); |
2617 | 2623 |
| 2624 inline int Size() { return RoundUp(length() + kHeaderSize, kPointerSize); } |
| 2625 |
2618 // Setter and getter. | 2626 // Setter and getter. |
2619 inline byte get(int index); | 2627 inline byte get(int index); |
2620 inline void set(int index, byte value); | 2628 inline void set(int index, byte value); |
2621 | 2629 |
2622 // Treat contents as an int array. | 2630 // Treat contents as an int array. |
2623 inline int get_int(int index); | 2631 inline int get_int(int index); |
2624 | 2632 |
2625 static int SizeFor(int length) { | 2633 static int SizeFor(int length) { |
2626 return OBJECT_POINTER_ALIGN(kHeaderSize + length); | 2634 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
2627 } | 2635 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2668 // Maximal memory consumption for a single ByteArray. | 2676 // Maximal memory consumption for a single ByteArray. |
2669 static const int kMaxSize = 512 * MB; | 2677 static const int kMaxSize = 512 * MB; |
2670 // Maximal length of a single ByteArray. | 2678 // Maximal length of a single ByteArray. |
2671 static const int kMaxLength = kMaxSize - kHeaderSize; | 2679 static const int kMaxLength = kMaxSize - kHeaderSize; |
2672 | 2680 |
2673 private: | 2681 private: |
2674 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 2682 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
2675 }; | 2683 }; |
2676 | 2684 |
2677 | 2685 |
| 2686 // FreeSpace represents fixed sized areas of the heap that are not currently in |
| 2687 // use. Used by the heap and GC. |
| 2688 class FreeSpace: public HeapObject { |
| 2689 public: |
| 2690 // [size]: size of the free space including the header. |
| 2691 inline int size(); |
| 2692 inline void set_size(int value); |
| 2693 |
| 2694 inline int Size() { return size(); } |
| 2695 |
| 2696 // Casting. |
| 2697 static inline FreeSpace* cast(Object* obj); |
| 2698 |
| 2699 #ifdef OBJECT_PRINT |
| 2700 inline void FreeSpacePrint() { |
| 2701 FreeSpacePrint(stdout); |
| 2702 } |
| 2703 void FreeSpacePrint(FILE* out); |
| 2704 #endif |
| 2705 #ifdef DEBUG |
| 2706 void FreeSpaceVerify(); |
| 2707 #endif |
| 2708 |
| 2709 // Layout description. |
| 2710 // Size is smi tagged when it is stored. |
| 2711 static const int kSizeOffset = HeapObject::kHeaderSize; |
| 2712 static const int kHeaderSize = kSizeOffset + kPointerSize; |
| 2713 |
| 2714 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
| 2715 |
| 2716 // Maximal size of a single FreeSpace. |
| 2717 static const int kMaxSize = 512 * MB; |
| 2718 |
| 2719 private: |
| 2720 DISALLOW_IMPLICIT_CONSTRUCTORS(FreeSpace); |
| 2721 }; |
| 2722 |
| 2723 |
2678 // An ExternalArray represents a fixed-size array of primitive values | 2724 // An ExternalArray represents a fixed-size array of primitive values |
2679 // which live outside the JavaScript heap. Its subclasses are used to | 2725 // which live outside the JavaScript heap. Its subclasses are used to |
2680 // implement the CanvasArray types being defined in the WebGL | 2726 // implement the CanvasArray types being defined in the WebGL |
2681 // specification. As of this writing the first public draft is not yet | 2727 // specification. As of this writing the first public draft is not yet |
2682 // available, but Khronos members can access the draft at: | 2728 // available, but Khronos members can access the draft at: |
2683 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html | 2729 // https://cvs.khronos.org/svn/repos/3dweb/trunk/doc/spec/WebGL-spec.html |
2684 // | 2730 // |
2685 // The semantics of these arrays differ from CanvasPixelArray. | 2731 // The semantics of these arrays differ from CanvasPixelArray. |
2686 // Out-of-range values passed to the setter are converted via a C | 2732 // Out-of-range values passed to the setter are converted via a C |
2687 // cast, not clamping. Out-of-range indices cause exceptions to be | 2733 // cast, not clamping. Out-of-range indices cause exceptions to be |
(...skipping 3797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6485 } else { | 6531 } else { |
6486 value &= ~(1 << bit_position); | 6532 value &= ~(1 << bit_position); |
6487 } | 6533 } |
6488 return value; | 6534 return value; |
6489 } | 6535 } |
6490 }; | 6536 }; |
6491 | 6537 |
6492 } } // namespace v8::internal | 6538 } } // namespace v8::internal |
6493 | 6539 |
6494 #endif // V8_OBJECTS_H_ | 6540 #endif // V8_OBJECTS_H_ |
OLD | NEW |