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

Side by Side Diff: src/objects.h

Issue 2451853002: Uniform and precise source positions for inlining (Closed)
Patch Set: fixed gcmole issue Created 4 years, 1 month 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // - ModuleInfoEntry 161 // - ModuleInfoEntry
162 // - WeakCell 162 // - WeakCell
163 // 163 //
164 // Formats of Object*: 164 // Formats of Object*:
165 // Smi: [31 bit signed int] 0 165 // Smi: [31 bit signed int] 0
166 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01 166 // HeapObject: [32 bit direct pointer] (4 byte aligned) | 01
167 167
168 namespace v8 { 168 namespace v8 {
169 namespace internal { 169 namespace internal {
170 170
171 struct InliningPosition;
172
171 enum KeyedAccessStoreMode { 173 enum KeyedAccessStoreMode {
172 STANDARD_STORE, 174 STANDARD_STORE,
173 STORE_TRANSITION_TO_OBJECT, 175 STORE_TRANSITION_TO_OBJECT,
174 STORE_TRANSITION_TO_DOUBLE, 176 STORE_TRANSITION_TO_DOUBLE,
175 STORE_AND_GROW_NO_TRANSITION, 177 STORE_AND_GROW_NO_TRANSITION,
176 STORE_AND_GROW_TRANSITION_TO_OBJECT, 178 STORE_AND_GROW_TRANSITION_TO_OBJECT,
177 STORE_AND_GROW_TRANSITION_TO_DOUBLE, 179 STORE_AND_GROW_TRANSITION_TO_DOUBLE,
178 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS, 180 STORE_NO_TRANSITION_IGNORE_OUT_OF_BOUNDS,
179 STORE_NO_TRANSITION_HANDLE_COW 181 STORE_NO_TRANSITION_HANDLE_COW
180 }; 182 };
(...skipping 4713 matching lines...) Expand 10 before | Expand all | Expand 10 after
4894 4896
4895 // Maximal memory consumption for a single ByteArray. 4897 // Maximal memory consumption for a single ByteArray.
4896 static const int kMaxSize = 512 * MB; 4898 static const int kMaxSize = 512 * MB;
4897 // Maximal length of a single ByteArray. 4899 // Maximal length of a single ByteArray.
4898 static const int kMaxLength = kMaxSize - kHeaderSize; 4900 static const int kMaxLength = kMaxSize - kHeaderSize;
4899 4901
4900 private: 4902 private:
4901 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray); 4903 DISALLOW_IMPLICIT_CONSTRUCTORS(ByteArray);
4902 }; 4904 };
4903 4905
4906 // Wrapper class for ByteArray which can store arbitrary C++ classes, as long
4907 // as they can be copied with memcpy.
4908 template <class T>
4909 class PodArray : public ByteArray {
4910 public:
4911 static Handle<PodArray<T>> New(Isolate* isolate, int length,
4912 PretenureFlag pretenure = NOT_TENURED);
4913 void copy_out(int index, T* result) {
4914 ByteArray::copy_out(index * sizeof(T), reinterpret_cast<byte*>(result),
4915 sizeof(T));
4916 }
4917 T get(int index) {
4918 T result;
4919 copy_out(index, &result);
4920 return result;
4921 }
4922 void set(int index, const T& value) {
4923 copy_in(index * sizeof(T), reinterpret_cast<const byte*>(&value),
4924 sizeof(T));
4925 }
4926 int length() { return ByteArray::length() / sizeof(T); }
4927 DECLARE_CAST(PodArray<T>)
4928
4929 private:
4930 DISALLOW_IMPLICIT_CONSTRUCTORS(PodArray<T>);
4931 };
4904 4932
4905 // BytecodeArray represents a sequence of interpreter bytecodes. 4933 // BytecodeArray represents a sequence of interpreter bytecodes.
4906 class BytecodeArray : public FixedArrayBase { 4934 class BytecodeArray : public FixedArrayBase {
4907 public: 4935 public:
4908 static int SizeFor(int length) { 4936 static int SizeFor(int length) {
4909 return OBJECT_POINTER_ALIGN(kHeaderSize + length); 4937 return OBJECT_POINTER_ALIGN(kHeaderSize + length);
4910 } 4938 }
4911 4939
4912 // Setter and getter 4940 // Setter and getter
4913 inline byte get(int index); 4941 inline byte get(int index);
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
5126 elementType scalar); \ 5154 elementType scalar); \
5127 static inline elementType defaultValue(); \ 5155 static inline elementType defaultValue(); \
5128 }; \ 5156 }; \
5129 \ 5157 \
5130 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array; 5158 typedef FixedTypedArray<Type##ArrayTraits> Fixed##Type##Array;
5131 5159
5132 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS) 5160 TYPED_ARRAYS(FIXED_TYPED_ARRAY_TRAITS)
5133 5161
5134 #undef FIXED_TYPED_ARRAY_TRAITS 5162 #undef FIXED_TYPED_ARRAY_TRAITS
5135 5163
5136
5137 // DeoptimizationInputData is a fixed array used to hold the deoptimization 5164 // DeoptimizationInputData is a fixed array used to hold the deoptimization
5138 // data for code generated by the Hydrogen/Lithium compiler. It also 5165 // data for code generated by the Hydrogen/Lithium compiler. It also
5139 // contains information about functions that were inlined. If N different 5166 // contains information about functions that were inlined. If N different
5140 // functions were inlined then first N elements of the literal array will 5167 // functions were inlined then first N elements of the literal array will
5141 // contain these functions. 5168 // contain these functions.
5142 // 5169 //
5143 // It can be empty. 5170 // It can be empty.
5144 class DeoptimizationInputData: public FixedArray { 5171 class DeoptimizationInputData: public FixedArray {
5145 public: 5172 public:
5146 // Layout description. Indices in the array. 5173 // Layout description. Indices in the array.
5147 static const int kTranslationByteArrayIndex = 0; 5174 static const int kTranslationByteArrayIndex = 0;
5148 static const int kInlinedFunctionCountIndex = 1; 5175 static const int kInlinedFunctionCountIndex = 1;
5149 static const int kLiteralArrayIndex = 2; 5176 static const int kLiteralArrayIndex = 2;
5150 static const int kOsrAstIdIndex = 3; 5177 static const int kOsrAstIdIndex = 3;
5151 static const int kOsrPcOffsetIndex = 4; 5178 static const int kOsrPcOffsetIndex = 4;
5152 static const int kOptimizationIdIndex = 5; 5179 static const int kOptimizationIdIndex = 5;
5153 static const int kSharedFunctionInfoIndex = 6; 5180 static const int kSharedFunctionInfoIndex = 6;
5154 static const int kWeakCellCacheIndex = 7; 5181 static const int kWeakCellCacheIndex = 7;
5155 static const int kFirstDeoptEntryIndex = 8; 5182 static const int kInliningPositionsIndex = 8;
5183 static const int kFirstDeoptEntryIndex = 9;
5156 5184
5157 // Offsets of deopt entry elements relative to the start of the entry. 5185 // Offsets of deopt entry elements relative to the start of the entry.
5158 static const int kAstIdRawOffset = 0; 5186 static const int kAstIdRawOffset = 0;
5159 static const int kTranslationIndexOffset = 1; 5187 static const int kTranslationIndexOffset = 1;
5160 static const int kArgumentsStackHeightOffset = 2; 5188 static const int kArgumentsStackHeightOffset = 2;
5161 static const int kPcOffset = 3; 5189 static const int kPcOffset = 3;
5162 static const int kDeoptEntrySize = 4; 5190 static const int kDeoptEntrySize = 4;
5163 5191
5164 // Simple element accessors. 5192 // Simple element accessors.
5165 #define DECLARE_ELEMENT_ACCESSORS(name, type) \ 5193 #define DECLARE_ELEMENT_ACCESSORS(name, type) \
5166 inline type* name(); \ 5194 inline type* name(); \
5167 inline void Set##name(type* value); 5195 inline void Set##name(type* value);
5168 5196
5169 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray) 5197 DECLARE_ELEMENT_ACCESSORS(TranslationByteArray, ByteArray)
5170 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi) 5198 DECLARE_ELEMENT_ACCESSORS(InlinedFunctionCount, Smi)
5171 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray) 5199 DECLARE_ELEMENT_ACCESSORS(LiteralArray, FixedArray)
5172 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi) 5200 DECLARE_ELEMENT_ACCESSORS(OsrAstId, Smi)
5173 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi) 5201 DECLARE_ELEMENT_ACCESSORS(OsrPcOffset, Smi)
5174 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi) 5202 DECLARE_ELEMENT_ACCESSORS(OptimizationId, Smi)
5175 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object) 5203 DECLARE_ELEMENT_ACCESSORS(SharedFunctionInfo, Object)
5176 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object) 5204 DECLARE_ELEMENT_ACCESSORS(WeakCellCache, Object)
5205 DECLARE_ELEMENT_ACCESSORS(InliningPositions, PodArray<InliningPosition>)
5177 5206
5178 #undef DECLARE_ELEMENT_ACCESSORS 5207 #undef DECLARE_ELEMENT_ACCESSORS
5179 5208
5180 // Accessors for elements of the ith deoptimization entry. 5209 // Accessors for elements of the ith deoptimization entry.
5181 #define DECLARE_ENTRY_ACCESSORS(name, type) \ 5210 #define DECLARE_ENTRY_ACCESSORS(name, type) \
5182 inline type* name(int i); \ 5211 inline type* name(int i); \
5183 inline void Set##name(int i, type* value); 5212 inline void Set##name(int i, type* value);
5184 5213
5185 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi) 5214 DECLARE_ENTRY_ACCESSORS(AstIdRaw, Smi)
5186 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi) 5215 DECLARE_ENTRY_ACCESSORS(TranslationIndex, Smi)
(...skipping 21 matching lines...) Expand all
5208 5237
5209 private: 5238 private:
5210 static int IndexForEntry(int i) { 5239 static int IndexForEntry(int i) {
5211 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize); 5240 return kFirstDeoptEntryIndex + (i * kDeoptEntrySize);
5212 } 5241 }
5213 5242
5214 5243
5215 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); } 5244 static int LengthFor(int entry_count) { return IndexForEntry(entry_count); }
5216 }; 5245 };
5217 5246
5218
5219 // DeoptimizationOutputData is a fixed array used to hold the deoptimization 5247 // DeoptimizationOutputData is a fixed array used to hold the deoptimization
5220 // data for code generated by the full compiler. 5248 // data for code generated by the full compiler.
5221 // The format of the these objects is 5249 // The format of the these objects is
5222 // [i * 2]: Ast ID for ith deoptimization. 5250 // [i * 2]: Ast ID for ith deoptimization.
5223 // [i * 2 + 1]: PC and state of ith deoptimization 5251 // [i * 2 + 1]: PC and state of ith deoptimization
5224 class DeoptimizationOutputData: public FixedArray { 5252 class DeoptimizationOutputData: public FixedArray {
5225 public: 5253 public:
5226 inline int DeoptPoints(); 5254 inline int DeoptPoints();
5227 5255
5228 inline BailoutId AstId(int index); 5256 inline BailoutId AstId(int index);
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
7094 // Set eval origin for stack trace formatting. 7122 // Set eval origin for stack trace formatting.
7095 static void SetEvalOrigin(Handle<Script> script, 7123 static void SetEvalOrigin(Handle<Script> script,
7096 Handle<SharedFunctionInfo> outer, 7124 Handle<SharedFunctionInfo> outer,
7097 int eval_position); 7125 int eval_position);
7098 // Retrieve source position from where eval was called. 7126 // Retrieve source position from where eval was called.
7099 int GetEvalPosition(); 7127 int GetEvalPosition();
7100 7128
7101 // Init line_ends array with source code positions of line ends. 7129 // Init line_ends array with source code positions of line ends.
7102 static void InitLineEnds(Handle<Script> script); 7130 static void InitLineEnds(Handle<Script> script);
7103 7131
7104 // Convert code offset into column number.
7105 static int GetColumnNumber(Handle<Script> script, int code_offset);
7106
7107 // Convert code offset into (zero-based) line number.
7108 // The non-handlified version does not allocate, but may be much slower.
7109 static int GetLineNumber(Handle<Script> script, int code_offset);
7110 int GetLineNumber(int code_pos);
7111
7112 // Carries information about a source position. 7132 // Carries information about a source position.
7113 struct PositionInfo { 7133 struct PositionInfo {
7114 PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {} 7134 PositionInfo() : line(-1), column(-1), line_start(-1), line_end(-1) {}
7115 7135
7116 int line; // Zero-based line number. 7136 int line; // Zero-based line number.
7117 int column; // Zero-based column number. 7137 int column; // Zero-based column number.
7118 int line_start; // Position of first character in line. 7138 int line_start; // Position of first character in line.
7119 int line_end; // Position of last (non-linebreak) character in line. 7139 int line_end; // Position of final linebreak character in line.
7120 }; 7140 };
7121 7141
7122 // Specifies whether to add offsets to position infos. 7142 // Specifies whether to add offsets to position infos.
7123 enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 }; 7143 enum OffsetFlag { NO_OFFSET = 0, WITH_OFFSET = 1 };
7124 7144
7125 // Retrieves information about the given position, optionally with an offset. 7145 // Retrieves information about the given position, optionally with an offset.
7126 // Returns false on failure, and otherwise writes into the given info object 7146 // Returns false on failure, and otherwise writes into the given info object
7127 // on success. 7147 // on success.
7148 // The static method should is preferable for handlified callsites because it
7149 // initializes the line ends array, avoiding expensive recomputations.
7150 // The non-static version is not allocating and safe for unhandlified
7151 // callsites.
7152 static bool GetPositionInfo(Handle<Script> script, int position,
7153 PositionInfo* info, OffsetFlag offset_flag);
7128 bool GetPositionInfo(int position, PositionInfo* info, 7154 bool GetPositionInfo(int position, PositionInfo* info,
7129 OffsetFlag offset_flag); 7155 OffsetFlag offset_flag) const;
7156
7157 // Wrappers for GetPositionInfo
7158 static int GetColumnNumber(Handle<Script> script, int code_offset);
7159 int GetColumnNumber(int code_pos) const;
7160 static int GetLineNumber(Handle<Script> script, int code_offset);
7161 int GetLineNumber(int code_pos) const;
7130 7162
7131 // Get the JS object wrapping the given script; create it if none exists. 7163 // Get the JS object wrapping the given script; create it if none exists.
7132 static Handle<JSObject> GetWrapper(Handle<Script> script); 7164 static Handle<JSObject> GetWrapper(Handle<Script> script);
7133 7165
7134 // Look through the list of existing shared function infos to find one 7166 // Look through the list of existing shared function infos to find one
7135 // that matches the function literal. Return empty handle if not found. 7167 // that matches the function literal. Return empty handle if not found.
7136 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun); 7168 MaybeHandle<SharedFunctionInfo> FindSharedFunctionInfo(FunctionLiteral* fun);
7137 7169
7138 // Iterate over all script objects on the heap. 7170 // Iterate over all script objects on the heap.
7139 class Iterator { 7171 class Iterator {
(...skipping 23 matching lines...) Expand all
7163 static const int kEvalFromPositionOffset = 7195 static const int kEvalFromPositionOffset =
7164 kEvalFromSharedOffset + kPointerSize; 7196 kEvalFromSharedOffset + kPointerSize;
7165 static const int kSharedFunctionInfosOffset = 7197 static const int kSharedFunctionInfosOffset =
7166 kEvalFromPositionOffset + kPointerSize; 7198 kEvalFromPositionOffset + kPointerSize;
7167 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize; 7199 static const int kFlagsOffset = kSharedFunctionInfosOffset + kPointerSize;
7168 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize; 7200 static const int kSourceUrlOffset = kFlagsOffset + kPointerSize;
7169 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize; 7201 static const int kSourceMappingUrlOffset = kSourceUrlOffset + kPointerSize;
7170 static const int kSize = kSourceMappingUrlOffset + kPointerSize; 7202 static const int kSize = kSourceMappingUrlOffset + kPointerSize;
7171 7203
7172 private: 7204 private:
7173 int GetLineNumberWithArray(int code_pos);
7174
7175 // Bit positions in the flags field. 7205 // Bit positions in the flags field.
7176 static const int kCompilationTypeBit = 0; 7206 static const int kCompilationTypeBit = 0;
7177 static const int kCompilationStateBit = 1; 7207 static const int kCompilationStateBit = 1;
7178 static const int kHideSourceBit = 2; 7208 static const int kHideSourceBit = 2;
7179 static const int kOriginOptionsShift = 3; 7209 static const int kOriginOptionsShift = 3;
7180 static const int kOriginOptionsSize = 3; 7210 static const int kOriginOptionsSize = 3;
7181 static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1) 7211 static const int kOriginOptionsMask = ((1 << kOriginOptionsSize) - 1)
7182 << kOriginOptionsShift; 7212 << kOriginOptionsShift;
7183 7213
7184 DISALLOW_IMPLICIT_CONSTRUCTORS(Script); 7214 DISALLOW_IMPLICIT_CONSTRUCTORS(Script);
(...skipping 4636 matching lines...) Expand 10 before | Expand all | Expand 10 after
11821 } 11851 }
11822 return value; 11852 return value;
11823 } 11853 }
11824 }; 11854 };
11825 11855
11826 11856
11827 } // NOLINT, false-positive due to second-order macros. 11857 } // NOLINT, false-positive due to second-order macros.
11828 } // NOLINT, false-positive due to second-order macros. 11858 } // NOLINT, false-positive due to second-order macros.
11829 11859
11830 #endif // V8_OBJECTS_H_ 11860 #endif // V8_OBJECTS_H_
OLDNEW
« src/crankshaft/hydrogen.cc ('K') | « src/mips64/assembler-mips64.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698