OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 8766 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8777 | 8777 |
8778 // [byte_length]: length in bytes | 8778 // [byte_length]: length in bytes |
8779 DECL_ACCESSORS(byte_length, Object) | 8779 DECL_ACCESSORS(byte_length, Object) |
8780 | 8780 |
8781 // [flags] | 8781 // [flags] |
8782 DECL_ACCESSORS(flag, Smi) | 8782 DECL_ACCESSORS(flag, Smi) |
8783 | 8783 |
8784 inline bool is_external(); | 8784 inline bool is_external(); |
8785 inline void set_is_external(bool value); | 8785 inline void set_is_external(bool value); |
8786 | 8786 |
| 8787 // [weak_next]: linked list of array buffers. |
| 8788 DECL_ACCESSORS(weak_next, Object) |
| 8789 |
| 8790 // [weak_first_array]: weak linked list of typed arrays. |
| 8791 DECL_ACCESSORS(weak_first_array, Object) |
| 8792 |
8787 // Casting. | 8793 // Casting. |
8788 static inline JSArrayBuffer* cast(Object* obj); | 8794 static inline JSArrayBuffer* cast(Object* obj); |
8789 | 8795 |
8790 // Dispatched behavior. | 8796 // Dispatched behavior. |
8791 DECLARE_PRINTER(JSArrayBuffer) | 8797 DECLARE_PRINTER(JSArrayBuffer) |
8792 DECLARE_VERIFIER(JSArrayBuffer) | 8798 DECLARE_VERIFIER(JSArrayBuffer) |
8793 | 8799 |
8794 static const int kBackingStoreOffset = JSObject::kHeaderSize; | 8800 static const int kBackingStoreOffset = JSObject::kHeaderSize; |
8795 static const int kByteLengthOffset = kBackingStoreOffset + kPointerSize; | 8801 static const int kByteLengthOffset = kBackingStoreOffset + kPointerSize; |
8796 static const int kFlagOffset = kByteLengthOffset + kPointerSize; | 8802 static const int kFlagOffset = kByteLengthOffset + kPointerSize; |
8797 static const int kSize = kFlagOffset + kPointerSize; | 8803 // It is important for GC visitor that weak_next and weak_first_array |
| 8804 // layed out consequtively in memory |
| 8805 static const int kWeakNextOffset = kFlagOffset + kPointerSize; |
| 8806 static const int kWeakFirstArrayOffset = kWeakNextOffset + kPointerSize; |
| 8807 static const int kSize = kWeakFirstArrayOffset + kPointerSize; |
8798 | 8808 |
8799 private: | 8809 private: |
8800 // Bit position in a flag | 8810 // Bit position in a flag |
8801 static const int kIsExternalBit = 0; | 8811 static const int kIsExternalBit = 0; |
8802 | 8812 |
8803 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); | 8813 DISALLOW_IMPLICIT_CONSTRUCTORS(JSArrayBuffer); |
8804 }; | 8814 }; |
8805 | 8815 |
8806 | 8816 |
8807 class JSTypedArray: public JSObject { | 8817 class JSTypedArray: public JSObject { |
8808 public: | 8818 public: |
8809 // [buffer]: ArrayBuffer that this typed array views. | 8819 // [buffer]: ArrayBuffer that this typed array views. |
8810 DECL_ACCESSORS(buffer, Object) | 8820 DECL_ACCESSORS(buffer, Object) |
8811 | 8821 |
8812 // [byte_length]: offset of typed array in bytes. | 8822 // [byte_length]: offset of typed array in bytes. |
8813 DECL_ACCESSORS(byte_offset, Object) | 8823 DECL_ACCESSORS(byte_offset, Object) |
8814 | 8824 |
8815 // [byte_length]: length of typed array in bytes. | 8825 // [byte_length]: length of typed array in bytes. |
8816 DECL_ACCESSORS(byte_length, Object) | 8826 DECL_ACCESSORS(byte_length, Object) |
8817 | 8827 |
8818 // [length]: length of typed array in elements. | 8828 // [length]: length of typed array in elements. |
8819 DECL_ACCESSORS(length, Object) | 8829 DECL_ACCESSORS(length, Object) |
8820 | 8830 |
| 8831 // [next]: linked list of typed arrays over the same array buffer. |
| 8832 DECL_ACCESSORS(weak_next, Object) |
| 8833 |
8821 // Casting. | 8834 // Casting. |
8822 static inline JSTypedArray* cast(Object* obj); | 8835 static inline JSTypedArray* cast(Object* obj); |
8823 | 8836 |
8824 ExternalArrayType type(); | 8837 ExternalArrayType type(); |
8825 size_t element_size(); | 8838 size_t element_size(); |
8826 | 8839 |
8827 // Dispatched behavior. | 8840 // Dispatched behavior. |
8828 DECLARE_PRINTER(JSTypedArray) | 8841 DECLARE_PRINTER(JSTypedArray) |
8829 DECLARE_VERIFIER(JSTypedArray) | 8842 DECLARE_VERIFIER(JSTypedArray) |
8830 | 8843 |
8831 static const int kBufferOffset = JSObject::kHeaderSize; | 8844 static const int kBufferOffset = JSObject::kHeaderSize; |
8832 static const int kByteOffsetOffset = kBufferOffset + kPointerSize; | 8845 static const int kByteOffsetOffset = kBufferOffset + kPointerSize; |
8833 static const int kByteLengthOffset = kByteOffsetOffset + kPointerSize; | 8846 static const int kByteLengthOffset = kByteOffsetOffset + kPointerSize; |
8834 static const int kLengthOffset = kByteLengthOffset + kPointerSize; | 8847 static const int kLengthOffset = kByteLengthOffset + kPointerSize; |
8835 static const int kSize = kLengthOffset + kPointerSize; | 8848 static const int kWeakNextOffset = kLengthOffset + kPointerSize; |
| 8849 static const int kSize = kWeakNextOffset + kPointerSize; |
8836 | 8850 |
8837 private: | 8851 private: |
8838 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); | 8852 DISALLOW_IMPLICIT_CONSTRUCTORS(JSTypedArray); |
8839 }; | 8853 }; |
8840 | 8854 |
8841 | 8855 |
8842 // Foreign describes objects pointing from JavaScript to C structures. | 8856 // Foreign describes objects pointing from JavaScript to C structures. |
8843 // Since they cannot contain references to JS HeapObjects they can be | 8857 // Since they cannot contain references to JS HeapObjects they can be |
8844 // placed in old_data_space. | 8858 // placed in old_data_space. |
8845 class Foreign: public HeapObject { | 8859 class Foreign: public HeapObject { |
(...skipping 794 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9640 } else { | 9654 } else { |
9641 value &= ~(1 << bit_position); | 9655 value &= ~(1 << bit_position); |
9642 } | 9656 } |
9643 return value; | 9657 return value; |
9644 } | 9658 } |
9645 }; | 9659 }; |
9646 | 9660 |
9647 } } // namespace v8::internal | 9661 } } // namespace v8::internal |
9648 | 9662 |
9649 #endif // V8_OBJECTS_H_ | 9663 #endif // V8_OBJECTS_H_ |
OLD | NEW |