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

Side by Side Diff: src/objects.h

Issue 2270783002: Add new FrameArray type (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comments Created 4 years, 4 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
« no previous file with comments | « src/messages.cc ('k') | src/objects.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 #include <memory> 9 #include <memory>
10 10
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 // - JSGlobalProxy 69 // - JSGlobalProxy
70 // - JSValue 70 // - JSValue
71 // - JSDate 71 // - JSDate
72 // - JSMessageObject 72 // - JSMessageObject
73 // - JSProxy 73 // - JSProxy
74 // - FixedArrayBase 74 // - FixedArrayBase
75 // - ByteArray 75 // - ByteArray
76 // - BytecodeArray 76 // - BytecodeArray
77 // - FixedArray 77 // - FixedArray
78 // - DescriptorArray 78 // - DescriptorArray
79 // - FrameArray
79 // - LiteralsArray 80 // - LiteralsArray
80 // - HashTable 81 // - HashTable
81 // - Dictionary 82 // - Dictionary
82 // - StringTable 83 // - StringTable
83 // - StringSet 84 // - StringSet
84 // - CompilationCacheTable 85 // - CompilationCacheTable
85 // - CodeCacheHashTable 86 // - CodeCacheHashTable
86 // - MapCache 87 // - MapCache
87 // - OrderedHashTable 88 // - OrderedHashTable
88 // - OrderedHashSet 89 // - OrderedHashSet
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 #define DECL_ACCESSORS(name, type) \ 856 #define DECL_ACCESSORS(name, type) \
856 inline type* name() const; \ 857 inline type* name() const; \
857 inline void set_##name(type* value, \ 858 inline void set_##name(type* value, \
858 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ 859 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
859 860
860 861
861 #define DECLARE_CAST(type) \ 862 #define DECLARE_CAST(type) \
862 INLINE(static type* cast(Object* object)); \ 863 INLINE(static type* cast(Object* object)); \
863 INLINE(static const type* cast(const Object* object)); 864 INLINE(static const type* cast(const Object* object));
864 865
865 866 class AbstractCode;
866 class AccessorPair; 867 class AccessorPair;
867 class AllocationSite; 868 class AllocationSite;
868 class AllocationSiteCreationContext; 869 class AllocationSiteCreationContext;
869 class AllocationSiteUsageContext; 870 class AllocationSiteUsageContext;
870 class Cell; 871 class Cell;
871 class ConsString; 872 class ConsString;
872 class ElementsAccessor; 873 class ElementsAccessor;
873 class FixedArrayBase; 874 class FixedArrayBase;
874 class FunctionLiteral; 875 class FunctionLiteral;
875 class JSGlobalObject; 876 class JSGlobalObject;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 V(FixedUint8ClampedArray) \ 955 V(FixedUint8ClampedArray) \
955 V(ByteArray) \ 956 V(ByteArray) \
956 V(BytecodeArray) \ 957 V(BytecodeArray) \
957 V(FreeSpace) \ 958 V(FreeSpace) \
958 V(JSReceiver) \ 959 V(JSReceiver) \
959 V(JSObject) \ 960 V(JSObject) \
960 V(JSContextExtensionObject) \ 961 V(JSContextExtensionObject) \
961 V(JSGeneratorObject) \ 962 V(JSGeneratorObject) \
962 V(Map) \ 963 V(Map) \
963 V(DescriptorArray) \ 964 V(DescriptorArray) \
965 V(FrameArray) \
964 V(TransitionArray) \ 966 V(TransitionArray) \
965 V(LiteralsArray) \ 967 V(LiteralsArray) \
966 V(TypeFeedbackMetadata) \ 968 V(TypeFeedbackMetadata) \
967 V(TypeFeedbackVector) \ 969 V(TypeFeedbackVector) \
968 V(DeoptimizationInputData) \ 970 V(DeoptimizationInputData) \
969 V(DeoptimizationOutputData) \ 971 V(DeoptimizationOutputData) \
970 V(DependentCode) \ 972 V(DependentCode) \
971 V(HandlerTable) \ 973 V(HandlerTable) \
972 V(FixedArray) \ 974 V(FixedArray) \
973 V(FixedDoubleArray) \ 975 V(FixedDoubleArray) \
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 inline int last_used_index() const; 2890 inline int last_used_index() const;
2889 inline void set_last_used_index(int index); 2891 inline void set_last_used_index(int index);
2890 2892
2891 // Disallow inherited setters. 2893 // Disallow inherited setters.
2892 void set(int index, Smi* value); 2894 void set(int index, Smi* value);
2893 void set(int index, Object* value); 2895 void set(int index, Object* value);
2894 void set(int index, Object* value, WriteBarrierMode mode); 2896 void set(int index, Object* value, WriteBarrierMode mode);
2895 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray); 2897 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
2896 }; 2898 };
2897 2899
2898
2899 // Generic array grows dynamically with O(1) amortized insertion. 2900 // Generic array grows dynamically with O(1) amortized insertion.
2900 class ArrayList : public FixedArray { 2901 class ArrayList : public FixedArray {
2901 public: 2902 public:
2902 enum AddMode { 2903 enum AddMode {
2903 kNone, 2904 kNone,
2904 // Use this if GC can delete elements from the array. 2905 // Use this if GC can delete elements from the array.
2905 kReloadLengthAfterAllocation, 2906 kReloadLengthAfterAllocation,
2906 }; 2907 };
2907 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj, 2908 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj,
2908 AddMode mode = kNone); 2909 AddMode mode = kNone);
2909 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj1, 2910 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj1,
2910 Handle<Object> obj2, AddMode = kNone); 2911 Handle<Object> obj2, AddMode = kNone);
2911 inline int Length(); 2912 inline int Length();
2912 inline void SetLength(int length); 2913 inline void SetLength(int length);
2913 inline Object* Get(int index); 2914 inline Object* Get(int index);
2914 inline Object** Slot(int index); 2915 inline Object** Slot(int index);
2915 inline void Set(int index, Object* obj, 2916 inline void Set(int index, Object* obj,
2916 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2917 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2917 inline void Clear(int index, Object* undefined); 2918 inline void Clear(int index, Object* undefined);
2918 bool IsFull(); 2919 bool IsFull();
2919 DECLARE_CAST(ArrayList) 2920 DECLARE_CAST(ArrayList)
2920 2921
2921 private: 2922 private:
2922 static Handle<ArrayList> EnsureSpace(Handle<ArrayList> array, int length); 2923 static Handle<ArrayList> EnsureSpace(Handle<ArrayList> array, int length);
2923 static const int kLengthIndex = 0; 2924 static const int kLengthIndex = 0;
2924 static const int kFirstIndex = 1; 2925 static const int kFirstIndex = 1;
2925 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList); 2926 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList);
2926 }; 2927 };
2927 2928
2929 #define FRAME_ARRAY_FIELD_LIST(V) \
2930 V(WasmObject, Object) \
2931 V(WasmFunctionIndex, Smi) \
2932 V(Receiver, Object) \
2933 V(Function, JSFunction) \
2934 V(Code, AbstractCode) \
2935 V(Offset, Smi)
2936
2937 // Container object for data collected during simple stack trace captures.
2938 class FrameArray : public FixedArray {
2939 public:
2940 #define DECLARE_FRAME_ARRAY_ACCESSORS(name, type) \
2941 inline type* name(int frame_ix) const; \
2942 inline void Set##name(int frame_ix, type* value);
2943 FRAME_ARRAY_FIELD_LIST(DECLARE_FRAME_ARRAY_ACCESSORS)
2944 #undef DECLARE_FRAME_ARRAY_ACCESSORS
2945
2946 inline void SetSloppyFrameCount(int count);
2947 inline int SloppyFrameCount() const;
2948
2949 inline bool IsWasmFrame(int frame_ix) const;
2950 inline int FrameCount() const;
2951
2952 void ShrinkToFit();
2953
2954 static Handle<FrameArray> AppendJSFrame(Handle<FrameArray> in,
2955 Handle<Object> receiver,
2956 Handle<JSFunction> function,
2957 Handle<AbstractCode> code,
2958 int offset);
2959 static Handle<FrameArray> AppendWasmFrame(Handle<FrameArray> in,
2960 Handle<Object> wasm_object,
2961 int wasm_function_index,
2962 Handle<AbstractCode> code,
2963 int offset);
2964
2965 DECLARE_CAST(FrameArray)
2966
2967 private:
2968 // The underlying fixed array embodies a captured stack trace. The number of
2969 // sloppy frames is stored at array[kFirstIndex]. Frame i occupies indices
2970 // kFirstIndex + 1 + [i * kElementsPerFrame, (i + 1) * kElementsPerFrame[,
2971 // with internal offsets as below:
2972
2973 static const int kWasmObjectOffset = 0;
2974 static const int kWasmFunctionIndexOffset = 1;
2975
2976 static const int kReceiverOffset = 0;
2977 static const int kFunctionOffset = 1;
2978
2979 static const int kCodeOffset = 2;
2980 static const int kOffsetOffset = 3;
2981
2982 static const int kElementsPerFrame = 4;
2983
2984 // Array layout indices.
2985
2986 static const int kFrameCountIndex = 0;
2987 static const int kSloppyFramesIndex = 1;
2988 static const int kFirstIndex = 2;
2989
2990 static int LengthFor(int frame_count) {
2991 return kFirstIndex + frame_count * kElementsPerFrame;
2992 }
2993
2994 static Handle<FrameArray> EnsureSpace(Handle<FrameArray> array, int length);
2995
2996 friend class Factory;
2997 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray);
2998 };
2928 2999
2929 // DescriptorArrays are fixed arrays used to hold instance descriptors. 3000 // DescriptorArrays are fixed arrays used to hold instance descriptors.
2930 // The format of the these objects is: 3001 // The format of the these objects is:
2931 // [0]: Number of descriptors 3002 // [0]: Number of descriptors
2932 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array: 3003 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array:
2933 // [0]: pointer to fixed array with enum cache 3004 // [0]: pointer to fixed array with enum cache
2934 // [1]: either Smi(0) or pointer to fixed array with indices 3005 // [1]: either Smi(0) or pointer to fixed array with indices
2935 // [2]: first key 3006 // [2]: first key
2936 // [2 + number of descriptors * kDescriptorSize]: start of slack 3007 // [2 + number of descriptors * kDescriptorSize]: start of slack
2937 class DescriptorArray: public FixedArray { 3008 class DescriptorArray: public FixedArray {
(...skipping 8158 matching lines...) Expand 10 before | Expand all | Expand 10 after
11096 } 11167 }
11097 return value; 11168 return value;
11098 } 11169 }
11099 }; 11170 };
11100 11171
11101 11172
11102 } // NOLINT, false-positive due to second-order macros. 11173 } // NOLINT, false-positive due to second-order macros.
11103 } // NOLINT, false-positive due to second-order macros. 11174 } // NOLINT, false-positive due to second-order macros.
11104 11175
11105 #endif // V8_OBJECTS_H_ 11176 #endif // V8_OBJECTS_H_
OLDNEW
« no previous file with comments | « src/messages.cc ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698