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

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: 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
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 844 matching lines...) Expand 10 before | Expand all | Expand 10 after
855 #define DECL_ACCESSORS(name, type) \ 855 #define DECL_ACCESSORS(name, type) \
856 inline type* name() const; \ 856 inline type* name() const; \
857 inline void set_##name(type* value, \ 857 inline void set_##name(type* value, \
858 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \ 858 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); \
859 859
860 860
861 #define DECLARE_CAST(type) \ 861 #define DECLARE_CAST(type) \
862 INLINE(static type* cast(Object* object)); \ 862 INLINE(static type* cast(Object* object)); \
863 INLINE(static const type* cast(const Object* object)); 863 INLINE(static const type* cast(const Object* object));
864 864
865 865 class AbstractCode;
866 class AccessorPair; 866 class AccessorPair;
867 class AllocationSite; 867 class AllocationSite;
868 class AllocationSiteCreationContext; 868 class AllocationSiteCreationContext;
869 class AllocationSiteUsageContext; 869 class AllocationSiteUsageContext;
870 class Cell; 870 class Cell;
871 class ConsString; 871 class ConsString;
872 class ElementsAccessor; 872 class ElementsAccessor;
873 class FixedArrayBase; 873 class FixedArrayBase;
874 class FunctionLiteral; 874 class FunctionLiteral;
875 class JSGlobalObject; 875 class JSGlobalObject;
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
954 V(FixedUint8ClampedArray) \ 954 V(FixedUint8ClampedArray) \
955 V(ByteArray) \ 955 V(ByteArray) \
956 V(BytecodeArray) \ 956 V(BytecodeArray) \
957 V(FreeSpace) \ 957 V(FreeSpace) \
958 V(JSReceiver) \ 958 V(JSReceiver) \
959 V(JSObject) \ 959 V(JSObject) \
960 V(JSContextExtensionObject) \ 960 V(JSContextExtensionObject) \
961 V(JSGeneratorObject) \ 961 V(JSGeneratorObject) \
962 V(Map) \ 962 V(Map) \
963 V(DescriptorArray) \ 963 V(DescriptorArray) \
964 V(FrameArray) \
964 V(TransitionArray) \ 965 V(TransitionArray) \
965 V(LiteralsArray) \ 966 V(LiteralsArray) \
966 V(TypeFeedbackMetadata) \ 967 V(TypeFeedbackMetadata) \
967 V(TypeFeedbackVector) \ 968 V(TypeFeedbackVector) \
968 V(DeoptimizationInputData) \ 969 V(DeoptimizationInputData) \
969 V(DeoptimizationOutputData) \ 970 V(DeoptimizationOutputData) \
970 V(DependentCode) \ 971 V(DependentCode) \
971 V(HandlerTable) \ 972 V(HandlerTable) \
972 V(FixedArray) \ 973 V(FixedArray) \
973 V(FixedDoubleArray) \ 974 V(FixedDoubleArray) \
(...skipping 1914 matching lines...) Expand 10 before | Expand all | Expand 10 after
2888 inline int last_used_index() const; 2889 inline int last_used_index() const;
2889 inline void set_last_used_index(int index); 2890 inline void set_last_used_index(int index);
2890 2891
2891 // Disallow inherited setters. 2892 // Disallow inherited setters.
2892 void set(int index, Smi* value); 2893 void set(int index, Smi* value);
2893 void set(int index, Object* value); 2894 void set(int index, Object* value);
2894 void set(int index, Object* value, WriteBarrierMode mode); 2895 void set(int index, Object* value, WriteBarrierMode mode);
2895 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray); 2896 DISALLOW_IMPLICIT_CONSTRUCTORS(WeakFixedArray);
2896 }; 2897 };
2897 2898
2898
2899 // Generic array grows dynamically with O(1) amortized insertion. 2899 // Generic array grows dynamically with O(1) amortized insertion.
2900 class ArrayList : public FixedArray { 2900 class ArrayList : public FixedArray {
2901 public: 2901 public:
2902 enum AddMode { 2902 enum AddMode {
2903 kNone, 2903 kNone,
2904 // Use this if GC can delete elements from the array. 2904 // Use this if GC can delete elements from the array.
2905 kReloadLengthAfterAllocation, 2905 kReloadLengthAfterAllocation,
2906 }; 2906 };
2907 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj, 2907 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj,
2908 AddMode mode = kNone); 2908 AddMode mode = kNone);
2909 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj1, 2909 static Handle<ArrayList> Add(Handle<ArrayList> array, Handle<Object> obj1,
2910 Handle<Object> obj2, AddMode = kNone); 2910 Handle<Object> obj2, AddMode = kNone);
2911 inline int Length(); 2911 inline int Length();
2912 inline void SetLength(int length); 2912 inline void SetLength(int length);
2913 inline Object* Get(int index); 2913 inline Object* Get(int index);
2914 inline Object** Slot(int index); 2914 inline Object** Slot(int index);
2915 inline void Set(int index, Object* obj, 2915 inline void Set(int index, Object* obj,
2916 WriteBarrierMode mode = UPDATE_WRITE_BARRIER); 2916 WriteBarrierMode mode = UPDATE_WRITE_BARRIER);
2917 inline void Clear(int index, Object* undefined); 2917 inline void Clear(int index, Object* undefined);
2918 bool IsFull(); 2918 bool IsFull();
2919 DECLARE_CAST(ArrayList) 2919 DECLARE_CAST(ArrayList)
2920 2920
2921 private: 2921 private:
2922 static Handle<ArrayList> EnsureSpace(Handle<ArrayList> array, int length); 2922 static Handle<ArrayList> EnsureSpace(Handle<ArrayList> array, int length);
2923 static const int kLengthIndex = 0; 2923 static const int kLengthIndex = 0;
2924 static const int kFirstIndex = 1; 2924 static const int kFirstIndex = 1;
2925 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList); 2925 DISALLOW_IMPLICIT_CONSTRUCTORS(ArrayList);
2926 }; 2926 };
2927 2927
2928 #define FRAME_ARRAY_FIELD_LIST(V) \
2929 V(WasmObject, Object) \
2930 V(WasmFunctionIndex, Smi) \
2931 V(Receiver, Object) \
2932 V(Function, JSFunction) \
2933 V(Code, AbstractCode) \
2934 V(Offset, Smi)
2935
2936 // Container object for data collected during simple stack trace captures.
2937 class FrameArray : public FixedArray {
2938 public:
2939 #define DECLARE_FRAME_ARRAY_ACCESSORS(name, type) \
2940 inline type* name(int frame_ix) const; \
2941 inline void Set##name(int frame_ix, type* value);
2942 FRAME_ARRAY_FIELD_LIST(DECLARE_FRAME_ARRAY_ACCESSORS)
2943 #undef DECLARE_FRAME_ARRAY_ACCESSORS
2944
2945 inline bool IsWasmFrame(int frame_ix) const;
2946 inline int FrameCount() const;
2947
2948 static Handle<FrameArray> Allocate(Isolate* isolate, int number_of_frames);
2949
2950 static Handle<FrameArray> AppendJSFrame(Handle<FrameArray> in, int frame_ix,
2951 Handle<Object> receiver,
2952 Handle<JSFunction> function,
2953 Handle<AbstractCode> code,
2954 int offset);
2955 static Handle<FrameArray> AppendWasmFrame(Handle<FrameArray> in, int frame_ix,
2956 Handle<Object> wasm_object,
2957 int wasm_function_index,
2958 Handle<AbstractCode> code,
2959 int offset);
2960
2961 static int LengthFor(int frame_count) {
2962 return 1 + frame_count * kElementsPerFrame;
2963 }
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[0]. Frame i occupies indices
2970 // 1 + [i * kElementsPerFrame, (i + 1) * kElementsPerFrame[, with internal
2971 // 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 static Handle<FrameArray> EnsureSpace(Handle<FrameArray> array, int length);
2985
2986 DISALLOW_IMPLICIT_CONSTRUCTORS(FrameArray);
2987 };
2928 2988
2929 // DescriptorArrays are fixed arrays used to hold instance descriptors. 2989 // DescriptorArrays are fixed arrays used to hold instance descriptors.
2930 // The format of the these objects is: 2990 // The format of the these objects is:
2931 // [0]: Number of descriptors 2991 // [0]: Number of descriptors
2932 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array: 2992 // [1]: Either Smi(0) if uninitialized, or a pointer to small fixed array:
2933 // [0]: pointer to fixed array with enum cache 2993 // [0]: pointer to fixed array with enum cache
2934 // [1]: either Smi(0) or pointer to fixed array with indices 2994 // [1]: either Smi(0) or pointer to fixed array with indices
2935 // [2]: first key 2995 // [2]: first key
2936 // [2 + number of descriptors * kDescriptorSize]: start of slack 2996 // [2 + number of descriptors * kDescriptorSize]: start of slack
2937 class DescriptorArray: public FixedArray { 2997 class DescriptorArray: public FixedArray {
(...skipping 8158 matching lines...) Expand 10 before | Expand all | Expand 10 after
11096 } 11156 }
11097 return value; 11157 return value;
11098 } 11158 }
11099 }; 11159 };
11100 11160
11101 11161
11102 } // NOLINT, false-positive due to second-order macros. 11162 } // NOLINT, false-positive due to second-order macros.
11103 } // NOLINT, false-positive due to second-order macros. 11163 } // NOLINT, false-positive due to second-order macros.
11104 11164
11105 #endif // V8_OBJECTS_H_ 11165 #endif // V8_OBJECTS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698