Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(799)

Side by Side Diff: src/objects.h

Issue 1230753004: [Interpreter] Add BytecodeArray class and add to SharedFunctionInfo. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Don't use extra memory for BytecodeArray in SharedFunctionInfo and add a BytecodeArray test. Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 V(CODE_TYPE) \ 392 V(CODE_TYPE) \
392 V(ODDBALL_TYPE) \ 393 V(ODDBALL_TYPE) \
393 V(CELL_TYPE) \ 394 V(CELL_TYPE) \
394 V(PROPERTY_CELL_TYPE) \ 395 V(PROPERTY_CELL_TYPE) \
395 \ 396 \
396 V(HEAP_NUMBER_TYPE) \ 397 V(HEAP_NUMBER_TYPE) \
397 V(MUTABLE_HEAP_NUMBER_TYPE) \ 398 V(MUTABLE_HEAP_NUMBER_TYPE) \
398 V(FLOAT32X4_TYPE) \ 399 V(FLOAT32X4_TYPE) \
399 V(FOREIGN_TYPE) \ 400 V(FOREIGN_TYPE) \
400 V(BYTE_ARRAY_TYPE) \ 401 V(BYTE_ARRAY_TYPE) \
402 V(BYTECODE_ARRAY_TYPE) \
401 V(FREE_SPACE_TYPE) \ 403 V(FREE_SPACE_TYPE) \
402 /* Note: the order of these external array */ \ 404 /* Note: the order of these external array */ \
403 /* types is relied upon in */ \ 405 /* types is relied upon in */ \
404 /* Object::IsExternalArray(). */ \ 406 /* Object::IsExternalArray(). */ \
405 V(EXTERNAL_INT8_ARRAY_TYPE) \ 407 V(EXTERNAL_INT8_ARRAY_TYPE) \
406 V(EXTERNAL_UINT8_ARRAY_TYPE) \ 408 V(EXTERNAL_UINT8_ARRAY_TYPE) \
407 V(EXTERNAL_INT16_ARRAY_TYPE) \ 409 V(EXTERNAL_INT16_ARRAY_TYPE) \
408 V(EXTERNAL_UINT16_ARRAY_TYPE) \ 410 V(EXTERNAL_UINT16_ARRAY_TYPE) \
409 V(EXTERNAL_INT32_ARRAY_TYPE) \ 411 V(EXTERNAL_INT32_ARRAY_TYPE) \
410 V(EXTERNAL_UINT32_ARRAY_TYPE) \ 412 V(EXTERNAL_UINT32_ARRAY_TYPE) \
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 CODE_TYPE, 689 CODE_TYPE,
688 ODDBALL_TYPE, 690 ODDBALL_TYPE,
689 691
690 // "Data", objects that cannot contain non-map-word pointers to heap 692 // "Data", objects that cannot contain non-map-word pointers to heap
691 // objects. 693 // objects.
692 HEAP_NUMBER_TYPE, 694 HEAP_NUMBER_TYPE,
693 MUTABLE_HEAP_NUMBER_TYPE, 695 MUTABLE_HEAP_NUMBER_TYPE,
694 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE 696 FLOAT32X4_TYPE, // FIRST_SIMD_TYPE, LAST_SIMD_TYPE
695 FOREIGN_TYPE, 697 FOREIGN_TYPE,
696 BYTE_ARRAY_TYPE, 698 BYTE_ARRAY_TYPE,
699 BYTECODE_ARRAY_TYPE,
697 FREE_SPACE_TYPE, 700 FREE_SPACE_TYPE,
698 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE 701 EXTERNAL_INT8_ARRAY_TYPE, // FIRST_EXTERNAL_ARRAY_TYPE
699 EXTERNAL_UINT8_ARRAY_TYPE, 702 EXTERNAL_UINT8_ARRAY_TYPE,
700 EXTERNAL_INT16_ARRAY_TYPE, 703 EXTERNAL_INT16_ARRAY_TYPE,
701 EXTERNAL_UINT16_ARRAY_TYPE, 704 EXTERNAL_UINT16_ARRAY_TYPE,
702 EXTERNAL_INT32_ARRAY_TYPE, 705 EXTERNAL_INT32_ARRAY_TYPE,
703 EXTERNAL_UINT32_ARRAY_TYPE, 706 EXTERNAL_UINT32_ARRAY_TYPE,
704 EXTERNAL_FLOAT32_ARRAY_TYPE, 707 EXTERNAL_FLOAT32_ARRAY_TYPE,
705 EXTERNAL_FLOAT64_ARRAY_TYPE, 708 EXTERNAL_FLOAT64_ARRAY_TYPE,
706 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE 709 EXTERNAL_UINT8_CLAMPED_ARRAY_TYPE, // LAST_EXTERNAL_ARRAY_TYPE
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
953 V(FixedInt8Array) \ 956 V(FixedInt8Array) \
954 V(FixedUint16Array) \ 957 V(FixedUint16Array) \
955 V(FixedInt16Array) \ 958 V(FixedInt16Array) \
956 V(FixedUint32Array) \ 959 V(FixedUint32Array) \
957 V(FixedInt32Array) \ 960 V(FixedInt32Array) \
958 V(FixedFloat32Array) \ 961 V(FixedFloat32Array) \
959 V(FixedFloat64Array) \ 962 V(FixedFloat64Array) \
960 V(FixedUint8ClampedArray) \ 963 V(FixedUint8ClampedArray) \
961 V(Float32x4) \ 964 V(Float32x4) \
962 V(ByteArray) \ 965 V(ByteArray) \
966 V(BytecodeArray) \
963 V(FreeSpace) \ 967 V(FreeSpace) \
964 V(JSReceiver) \ 968 V(JSReceiver) \
965 V(JSObject) \ 969 V(JSObject) \
966 V(JSContextExtensionObject) \ 970 V(JSContextExtensionObject) \
967 V(JSGeneratorObject) \ 971 V(JSGeneratorObject) \
968 V(JSModule) \ 972 V(JSModule) \
969 V(LayoutDescriptor) \ 973 V(LayoutDescriptor) \
970 V(Map) \ 974 V(Map) \
971 V(DescriptorArray) \ 975 V(DescriptorArray) \
972 V(TransitionArray) \ 976 V(TransitionArray) \
(...skipping 3280 matching lines...) Expand 10 before | Expand all | Expand 10 after
4253 // Maximal memory consumption for a single ByteArray. 4257 // Maximal memory consumption for a single ByteArray.
4254 static const int kMaxSize = 512 * MB; 4258 static const int kMaxSize = 512 * MB;
4255 // Maximal length of a single ByteArray. 4259 // Maximal length of a single ByteArray.
4256 static const int kMaxLength = kMaxSize - kHeaderSize; 4260 static const int kMaxLength = kMaxSize - kHeaderSize;
4257 4261
4258 private: 4262 private:
4259 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 4263 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
4260 }; 4264 };
4261 4265
4262 4266
4267 // BytecodeArray represents a sequence of interpreter bytecodes.
4268 class BytecodeArray : public FixedArrayBase {
4269 public:
4270 static int SizeFor(int length) {
4271 return OBJECT_POINTER_ALIGN(kHeaderSize + length);
4272 }
4273
4274 // Setter and getter
4275 inline byte get(int index);
4276 inline void set(int index, byte value);
4277
4278 // Returns data start address.
4279 inline Address GetFirstBytecodeAddress();
4280
4281 // Accessors for frame size and the number of locals
4282 inline int frame_size() const;
4283 inline void set_frame_size(int value);
4284 inline int number_of_locals() const;
4285 inline void set_number_of_locals(int value);
4286
4287 DECLARE_CAST(BytecodeArray)
4288
4289 // Dispatched behavior.
4290 inline int BytecodeArraySize() { return SizeFor(this->length()); }
4291
4292 DECLARE_PRINTER(BytecodeArray)
4293 DECLARE_VERIFIER(BytecodeArray)
4294
4295 void Disassemble(std::ostream& os);
4296
4297 // Layout description.
4298 static const int kFrameSizeOffset = ByteArray::kHeaderSize;
4299 static const int kNumberOfLocalsOffset = kFrameSizeOffset + kIntSize;
4300 static const int kHeaderSize = kNumberOfLocalsOffset + kIntSize;
4301
4302 static const int kAlignedSize = OBJECT_POINTER_ALIGN(kHeaderSize);
4303
4304 // Maximal memory consumption for a single BytecodeArray.
4305 static const int kMaxSize = ByteArray::kMaxSize;
4306 // Maximal length of a single BytecodeArray.
4307 static const int kMaxLength = kMaxSize - kHeaderSize;
4308
4309 private:
4310 DISALLOW_IMPLICIT_CONSTRUCTORS(BytecodeArray);
4311 };
4312
4313
4263 // FreeSpace are fixed-size free memory blocks used by the heap and GC. 4314 // FreeSpace are fixed-size free memory blocks used by the heap and GC.
4264 // They look like heap objects (are heap object tagged and have a map) so that 4315 // They look like heap objects (are heap object tagged and have a map) so that
4265 // the heap remains iterable. They have a size and a next pointer. 4316 // the heap remains iterable. They have a size and a next pointer.
4266 // The next pointer is the raw address of the next FreeSpace object (or NULL) 4317 // The next pointer is the raw address of the next FreeSpace object (or NULL)
4267 // in the free list. 4318 // in the free list.
4268 class FreeSpace: public HeapObject { 4319 class FreeSpace: public HeapObject {
4269 public: 4320 public:
4270 // [size]: size of the free space including the header. 4321 // [size]: size of the free space including the header.
4271 inline int size() const; 4322 inline int size() const;
4272 inline void set_size(int value); 4323 inline void set_size(int value);
(...skipping 2379 matching lines...) Expand 10 before | Expand all | Expand 10 after
6652 // (increasingly) from crankshafted code where sufficient feedback isn't 6703 // (increasingly) from crankshafted code where sufficient feedback isn't
6653 // available. 6704 // available.
6654 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector) 6705 DECL_ACCESSORS(feedback_vector, TypeFeedbackVector)
6655 6706
6656 // Unconditionally clear the type feedback vector (including vector ICs). 6707 // Unconditionally clear the type feedback vector (including vector ICs).
6657 void ClearTypeFeedbackInfo(); 6708 void ClearTypeFeedbackInfo();
6658 6709
6659 // Clear the type feedback vector with a more subtle policy at GC time. 6710 // Clear the type feedback vector with a more subtle policy at GC time.
6660 void ClearTypeFeedbackInfoAtGCTime(); 6711 void ClearTypeFeedbackInfoAtGCTime();
6661 6712
6713 // [bytecode_array]: Interpreter bytecodes.
6714 DECL_ACCESSORS(bytecode_array, BytecodeArray)
Michael Starzinger 2015/07/22 07:20:54 nit: These declarations have become obsolete, let'
oth 2015/07/22 08:50:00 Done.
6715
6662 #if TRACE_MAPS 6716 #if TRACE_MAPS
6663 // [unique_id] - For --trace-maps purposes, an identifier that's persistent 6717 // [unique_id] - For --trace-maps purposes, an identifier that's persistent
6664 // even if the GC moves this SharedFunctionInfo. 6718 // even if the GC moves this SharedFunctionInfo.
6665 inline int unique_id() const; 6719 inline int unique_id() const;
6666 inline void set_unique_id(int value); 6720 inline void set_unique_id(int value);
6667 #endif 6721 #endif
6668 6722
6669 // [instance class name]: class name for instances. 6723 // [instance class name]: class name for instances.
6670 DECL_ACCESSORS(instance_class_name, Object) 6724 DECL_ACCESSORS(instance_class_name, Object)
6671 6725
6672 // [function data]: This field holds some additional data for function. 6726 // [function data]: This field holds some additional data for function.
6673 // Currently it either has FunctionTemplateInfo to make benefit the API 6727 // Currently it has one of:
6674 // or Smi identifying a builtin function. 6728 // - a FunctionTemplateInfo to make benefit the API [IsApiFunction()].
6729 // - a Smi identifying a builtin function [HasBuiltinFunctionId()].
6730 // - a bytecode array for the interpreter [HasBytecodeArray()].
rmcilroy 2015/07/22 07:44:00 nit /s/bytecode array/BytecodeArray
oth 2015/07/22 08:50:00 Done.
6675 // In the long run we don't want all functions to have this field but 6731 // In the long run we don't want all functions to have this field but
6676 // we can fix that when we have a better model for storing hidden data 6732 // we can fix that when we have a better model for storing hidden data
6677 // on objects. 6733 // on objects.
6678 DECL_ACCESSORS(function_data, Object) 6734 DECL_ACCESSORS(function_data, Object)
6679 6735
6680 inline bool IsApiFunction(); 6736 inline bool IsApiFunction();
6681 inline FunctionTemplateInfo* get_api_func_data(); 6737 inline FunctionTemplateInfo* get_api_func_data();
6682 inline bool HasBuiltinFunctionId(); 6738 inline bool HasBuiltinFunctionId();
6683 inline BuiltinFunctionId builtin_function_id(); 6739 inline BuiltinFunctionId builtin_function_id();
6740 inline bool HasBytecodeArray();
6741 inline BytecodeArray* bytecode_array();
6684 6742
6685 // [script info]: Script from which the function originates. 6743 // [script info]: Script from which the function originates.
6686 DECL_ACCESSORS(script, Object) 6744 DECL_ACCESSORS(script, Object)
6687 6745
6688 // [num_literals]: Number of literals used by this function. 6746 // [num_literals]: Number of literals used by this function.
6689 inline int num_literals() const; 6747 inline int num_literals() const;
6690 inline void set_num_literals(int value); 6748 inline void set_num_literals(int value);
6691 6749
6692 // [start_position_and_type]: Field used to store both the source code 6750 // [start_position_and_type]: Field used to store both the source code
6693 // position, whether or not the function is a function expression, 6751 // position, whether or not the function is a function expression,
(...skipping 4130 matching lines...) Expand 10 before | Expand all | Expand 10 after
10824 } else { 10882 } else {
10825 value &= ~(1 << bit_position); 10883 value &= ~(1 << bit_position);
10826 } 10884 }
10827 return value; 10885 return value;
10828 } 10886 }
10829 }; 10887 };
10830 10888
10831 } } // namespace v8::internal 10889 } } // namespace v8::internal
10832 10890
10833 #endif // V8_OBJECTS_H_ 10891 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/interpreter/bytecodes.cc ('k') | src/objects.cc » ('j') | src/objects-debug.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698