OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_H_ | 5 #ifndef V8_OBJECTS_H_ |
6 #define V8_OBJECTS_H_ | 6 #define V8_OBJECTS_H_ |
7 | 7 |
8 #include <iosfwd> | 8 #include <iosfwd> |
9 | 9 |
10 #include "src/allocation.h" | 10 #include "src/allocation.h" |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // - JSGlobalObject | 66 // - JSGlobalObject |
67 // - JSBuiltinsObject | 67 // - JSBuiltinsObject |
68 // - JSGlobalProxy | 68 // - JSGlobalProxy |
69 // - JSValue | 69 // - JSValue |
70 // - JSDate | 70 // - JSDate |
71 // - JSMessageObject | 71 // - JSMessageObject |
72 // - JSProxy | 72 // - JSProxy |
73 // - JSFunctionProxy | 73 // - JSFunctionProxy |
74 // - FixedArrayBase | 74 // - FixedArrayBase |
75 // - ByteArray | 75 // - ByteArray |
| 76 // - BytecodeArray |
76 // - FixedArray | 77 // - FixedArray |
77 // - DescriptorArray | 78 // - DescriptorArray |
78 // - HashTable | 79 // - HashTable |
79 // - Dictionary | 80 // - Dictionary |
80 // - StringTable | 81 // - StringTable |
81 // - CompilationCacheTable | 82 // - CompilationCacheTable |
82 // - CodeCacheHashTable | 83 // - CodeCacheHashTable |
83 // - MapCache | 84 // - MapCache |
84 // - OrderedHashTable | 85 // - OrderedHashTable |
85 // - OrderedHashSet | 86 // - OrderedHashSet |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 V(MAP_TYPE) \ | 383 V(MAP_TYPE) \ |
383 V(CODE_TYPE) \ | 384 V(CODE_TYPE) \ |
384 V(ODDBALL_TYPE) \ | 385 V(ODDBALL_TYPE) \ |
385 V(CELL_TYPE) \ | 386 V(CELL_TYPE) \ |
386 V(PROPERTY_CELL_TYPE) \ | 387 V(PROPERTY_CELL_TYPE) \ |
387 \ | 388 \ |
388 V(HEAP_NUMBER_TYPE) \ | 389 V(HEAP_NUMBER_TYPE) \ |
389 V(MUTABLE_HEAP_NUMBER_TYPE) \ | 390 V(MUTABLE_HEAP_NUMBER_TYPE) \ |
390 V(FOREIGN_TYPE) \ | 391 V(FOREIGN_TYPE) \ |
391 V(BYTE_ARRAY_TYPE) \ | 392 V(BYTE_ARRAY_TYPE) \ |
| 393 V(BYTECODE_ARRAY_TYPE) \ |
392 V(FREE_SPACE_TYPE) \ | 394 V(FREE_SPACE_TYPE) \ |
393 /* Note: the order of these external array */ \ | 395 /* Note: the order of these external array */ \ |
394 /* types is relied upon in */ \ | 396 /* types is relied upon in */ \ |
395 /* Object::IsExternalArray(). */ \ | 397 /* Object::IsExternalArray(). */ \ |
396 V(EXTERNAL_INT8_ARRAY_TYPE) \ | 398 V(EXTERNAL_INT8_ARRAY_TYPE) \ |
397 V(EXTERNAL_UINT8_ARRAY_TYPE) \ | 399 V(EXTERNAL_UINT8_ARRAY_TYPE) \ |
398 V(EXTERNAL_INT16_ARRAY_TYPE) \ | 400 V(EXTERNAL_INT16_ARRAY_TYPE) \ |
399 V(EXTERNAL_UINT16_ARRAY_TYPE) \ | 401 V(EXTERNAL_UINT16_ARRAY_TYPE) \ |
400 V(EXTERNAL_INT32_ARRAY_TYPE) \ | 402 V(EXTERNAL_INT32_ARRAY_TYPE) \ |
401 V(EXTERNAL_UINT32_ARRAY_TYPE) \ | 403 V(EXTERNAL_UINT32_ARRAY_TYPE) \ |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 CODE_TYPE, | 680 CODE_TYPE, |
679 ODDBALL_TYPE, | 681 ODDBALL_TYPE, |
680 | 682 |
681 // "Data", objects that cannot contain non-map-word pointers to heap | 683 // "Data", objects that cannot contain non-map-word pointers to heap |
682 // objects. | 684 // objects. |
683 HEAP_NUMBER_TYPE, | 685 HEAP_NUMBER_TYPE, |
684 MUTABLE_HEAP_NUMBER_TYPE, | 686 MUTABLE_HEAP_NUMBER_TYPE, |
685 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE | 687 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE |
686 FOREIGN_TYPE, | 688 FOREIGN_TYPE, |
687 BYTE_ARRAY_TYPE, | 689 BYTE_ARRAY_TYPE, |
| 690 BYTECODE_ARRAY_TYPE, |
688 FREE_SPACE_TYPE, | 691 FREE_SPACE_TYPE, |
689 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE | 692 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE |
690 EXTERNAL_UINT8_ARRAY_TYPE, | 693 EXTERNAL_UINT8_ARRAY_TYPE, |
691 EXTERNAL_INT16_ARRAY_TYPE, | 694 EXTERNAL_INT16_ARRAY_TYPE, |
692 EXTERNAL_UINT16_ARRAY_TYPE, | 695 EXTERNAL_UINT16_ARRAY_TYPE, |
693 EXTERNAL_INT32_ARRAY_TYPE, | 696 EXTERNAL_INT32_ARRAY_TYPE, |
694 EXTERNAL_UINT32_ARRAY_TYPE, | 697 EXTERNAL_UINT32_ARRAY_TYPE, |
695 EXTERNAL_FLOAT32_ARRAY_TYPE, | 698 EXTERNAL_FLOAT32_ARRAY_TYPE, |
696 EXTERNAL_FLOAT64_ARRAY_TYPE, | 699 EXTERNAL_FLOAT64_ARRAY_TYPE, |
697 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE | 700 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
944 V(FixedUint8Array) \ | 947 V(FixedUint8Array) \ |
945 V(FixedInt8Array) \ | 948 V(FixedInt8Array) \ |
946 V(FixedUint16Array) \ | 949 V(FixedUint16Array) \ |
947 V(FixedInt16Array) \ | 950 V(FixedInt16Array) \ |
948 V(FixedUint32Array) \ | 951 V(FixedUint32Array) \ |
949 V(FixedInt32Array) \ | 952 V(FixedInt32Array) \ |
950 V(FixedFloat32Array) \ | 953 V(FixedFloat32Array) \ |
951 V(FixedFloat64Array) \ | 954 V(FixedFloat64Array) \ |
952 V(FixedUint8ClampedArray) \ | 955 V(FixedUint8ClampedArray) \ |
953 V(ByteArray) \ | 956 V(ByteArray) \ |
| 957 V(BytecodeArray) \ |
954 V(FreeSpace) \ | 958 V(FreeSpace) \ |
955 V(JSReceiver) \ | 959 V(JSReceiver) \ |
956 V(JSObject) \ | 960 V(JSObject) \ |
957 V(JSContextExtensionObject) \ | 961 V(JSContextExtensionObject) \ |
958 V(JSGeneratorObject) \ | 962 V(JSGeneratorObject) \ |
959 V(JSModule) \ | 963 V(JSModule) \ |
960 V(LayoutDescriptor) \ | 964 V(LayoutDescriptor) \ |
961 V(Map) \ | 965 V(Map) \ |
962 V(DescriptorArray) \ | 966 V(DescriptorArray) \ |
963 V(TransitionArray) \ | 967 V(TransitionArray) \ |
(...skipping 3262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4226 // Maximal memory consumption for a single ByteArray. | 4230 // Maximal memory consumption for a single ByteArray. |
4227 static const int kMaxSize = 512 * MB; | 4231 static const int kMaxSize = 512 * MB; |
4228 // Maximal length of a single ByteArray. | 4232 // Maximal length of a single ByteArray. |
4229 static const int kMaxLength = kMaxSize - kHeaderSize; | 4233 static const int kMaxLength = kMaxSize - kHeaderSize; |
4230 | 4234 |
4231 private: | 4235 private: |
4232 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); | 4236 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); |
4233 }; | 4237 }; |
4234 | 4238 |
4235 | 4239 |
| 4240 // BytecodeArray represents a sequence of interpreter bytecodes. |
| 4241 class BytecodeArray : public FixedArrayBase { |
| 4242 public: |
| 4243 static int SizeFor(int length) { |
| 4244 return OBJECT_POINTER_ALIGN(kHeaderSize + length); |
| 4245 } |
| 4246 |
| 4247 // Setter and getter |
| 4248 inline byte get(int index); |
| 4249 inline void set(int index, byte value); |
| 4250 |
| 4251 // Returns data start address. |
| 4252 inline Address GetFirstBytecodeAddress(); |
| 4253 |
| 4254 // Accessors for frame size and the number of locals |
| 4255 inline int frame_size() const; |
| 4256 inline void set_frame_size(int value); |
| 4257 inline int number_of_locals() const; |
| 4258 inline void set_number_of_locals(int value); |
| 4259 |
| 4260 DECLARE_CAST(BytecodeArray) |
| 4261 |
| 4262 // Dispatched behavior. |
| 4263 inline int BytecodeArraySize() { return SizeFor(this->length()); } |
| 4264 |
| 4265 DECLARE_PRINTER(BytecodeArray) |
| 4266 DECLARE_VERIFIER(BytecodeArray) |
| 4267 |
| 4268 void Disassemble(std::ostream& os); |
| 4269 |
| 4270 // Layout description. |
| 4271 static const int kFrameSizeOffset = FixedArrayBase::kHeaderSize; |
| 4272 static const int kNumberOfLocalsOffset = kFrameSizeOffset + kIntSize; |
| 4273 static const int kHeaderSize = kNumberOfLocalsOffset + kIntSize; |
| 4274 |
| 4275 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize); |
| 4276 |
| 4277 // Maximal memory consumption for a single BytecodeArray. |
| 4278 static const int kMaxSize = 512 * MB; |
| 4279 // Maximal length of a single BytecodeArray. |
| 4280 static const int kMaxLength = kMaxSize - kHeaderSize; |
| 4281 |
| 4282 private: |
| 4283 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray); |
| 4284 }; |
| 4285 |
| 4286 |
4236 // FreeSpace are fixed-size free memory blocks used by the heap and GC. | 4287 // FreeSpace are fixed-size free memory blocks used by the heap and GC. |
4237 // They look like heap objects (are heap object tagged and have a map) so that | 4288 // They look like heap objects (are heap object tagged and have a map) so that |
4238 // the heap remains iterable. They have a size and a next pointer. | 4289 // the heap remains iterable. They have a size and a next pointer. |
4239 // The next pointer is the raw address of the next FreeSpace object (or NULL) | 4290 // The next pointer is the raw address of the next FreeSpace object (or NULL) |
4240 // in the free list. | 4291 // in the free list. |
4241 class FreeSpace: public HeapObject { | 4292 class FreeSpace: public HeapObject { |
4242 public: | 4293 public: |
4243 // [size]: size of the free space including the header. | 4294 // [size]: size of the free space including the header. |
4244 inline int size() const; | 4295 inline int size() const; |
4245 inline void set_size(int value); | 4296 inline void set_size(int value); |
(...skipping 2393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6639 // [unique_id] - For --trace-maps purposes, an identifier that's persistent | 6690 // [unique_id] - For --trace-maps purposes, an identifier that's persistent |
6640 // even if the GC moves this SharedFunctionInfo. | 6691 // even if the GC moves this SharedFunctionInfo. |
6641 inline int unique_id() const; | 6692 inline int unique_id() const; |
6642 inline void set_unique_id(int value); | 6693 inline void set_unique_id(int value); |
6643 #endif | 6694 #endif |
6644 | 6695 |
6645 // [instance class name]: class name for instances. | 6696 // [instance class name]: class name for instances. |
6646 DECL_ACCESSORS(instance_class_name, Object) | 6697 DECL_ACCESSORS(instance_class_name, Object) |
6647 | 6698 |
6648 // [function data]: This field holds some additional data for function. | 6699 // [function data]: This field holds some additional data for function. |
6649 // Currently it either has FunctionTemplateInfo to make benefit the API | 6700 // Currently it has one of: |
6650 // or Smi identifying a builtin function. | 6701 // - a FunctionTemplateInfo to make benefit the API [IsApiFunction()]. |
| 6702 // - a Smi identifying a builtin function [HasBuiltinFunctionId()]. |
| 6703 // - a BytecodeArray for the interpreter [HasBytecodeArray()]. |
6651 // In the long run we don't want all functions to have this field but | 6704 // In the long run we don't want all functions to have this field but |
6652 // we can fix that when we have a better model for storing hidden data | 6705 // we can fix that when we have a better model for storing hidden data |
6653 // on objects. | 6706 // on objects. |
6654 DECL_ACCESSORS(function_data, Object) | 6707 DECL_ACCESSORS(function_data, Object) |
6655 | 6708 |
6656 inline bool IsApiFunction(); | 6709 inline bool IsApiFunction(); |
6657 inline FunctionTemplateInfo* get_api_func_data(); | 6710 inline FunctionTemplateInfo* get_api_func_data(); |
6658 inline bool HasBuiltinFunctionId(); | 6711 inline bool HasBuiltinFunctionId(); |
6659 inline BuiltinFunctionId builtin_function_id(); | 6712 inline BuiltinFunctionId builtin_function_id(); |
| 6713 inline bool HasBytecodeArray(); |
| 6714 inline BytecodeArray* bytecode_array(); |
6660 | 6715 |
6661 // [script info]: Script from which the function originates. | 6716 // [script info]: Script from which the function originates. |
6662 DECL_ACCESSORS(script, Object) | 6717 DECL_ACCESSORS(script, Object) |
6663 | 6718 |
6664 // [num_literals]: Number of literals used by this function. | 6719 // [num_literals]: Number of literals used by this function. |
6665 inline int num_literals() const; | 6720 inline int num_literals() const; |
6666 inline void set_num_literals(int value); | 6721 inline void set_num_literals(int value); |
6667 | 6722 |
6668 // [start_position_and_type]: Field used to store both the source code | 6723 // [start_position_and_type]: Field used to store both the source code |
6669 // position, whether or not the function is a function expression, | 6724 // position, whether or not the function is a function expression, |
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10800 } else { | 10855 } else { |
10801 value &= ~(1 << bit_position); | 10856 value &= ~(1 << bit_position); |
10802 } | 10857 } |
10803 return value; | 10858 return value; |
10804 } | 10859 } |
10805 }; | 10860 }; |
10806 | 10861 |
10807 } } // namespace v8::internal | 10862 } } // namespace v8::internal |
10808 | 10863 |
10809 #endif // V8_OBJECTS_H_ | 10864 #endif // V8_OBJECTS_H_ |
OLD | NEW |