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

Side by Side Diff: src/compiler/js-operator.h

Issue 1198983002: [turbofan] Revive the VectorSlotPair and also put feedback on JSCallFunction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Try to address compilation error. Created 5 years, 6 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/compiler/ast-graph-builder.cc ('k') | src/compiler/js-operator.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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_COMPILER_JS_OPERATOR_H_ 5 #ifndef V8_COMPILER_JS_OPERATOR_H_
6 #define V8_COMPILER_JS_OPERATOR_H_ 6 #define V8_COMPILER_JS_OPERATOR_H_
7 7
8 #include "src/runtime/runtime.h" 8 #include "src/runtime/runtime.h"
9 #include "src/unique.h" 9 #include "src/unique.h"
10 10
11 namespace v8 { 11 namespace v8 {
12 namespace internal { 12 namespace internal {
13 namespace compiler { 13 namespace compiler {
14 14
15 // Forward declarations. 15 // Forward declarations.
16 class Operator; 16 class Operator;
17 struct JSOperatorGlobalCache; 17 struct JSOperatorGlobalCache;
18 18
19 19
20 // Defines a pair of {TypeFeedbackVector} and {TypeFeedbackVectorICSlot}, which
21 // is used to access the type feedback for a certain {Node}.
22 class VectorSlotPair {
23 public:
24 VectorSlotPair() : slot_(FeedbackVectorICSlot::Invalid()) {}
25 VectorSlotPair(Handle<TypeFeedbackVector> vector, FeedbackVectorICSlot slot)
26 : vector_(vector), slot_(slot) {}
27
28 bool IsValid() const { return !vector_.is_null(); }
29
30 MaybeHandle<TypeFeedbackVector> vector() const { return vector_; }
31 FeedbackVectorICSlot slot() const { return slot_; }
32
33 int index() const {
34 Handle<TypeFeedbackVector> vector;
35 return vector_.ToHandle(&vector) ? vector->GetIndex(slot_) : -1;
36 }
37
38 private:
39 const MaybeHandle<TypeFeedbackVector> vector_;
40 const FeedbackVectorICSlot slot_;
41 };
42
43 bool operator==(VectorSlotPair const&, VectorSlotPair const&);
44 bool operator!=(VectorSlotPair const&, VectorSlotPair const&);
45
46 size_t hash_value(VectorSlotPair const&);
47
48
20 // Defines the arity and the call flags for a JavaScript function call. This is 49 // Defines the arity and the call flags for a JavaScript function call. This is
21 // used as a parameter by JSCallFunction operators. 50 // used as a parameter by JSCallFunction operators.
22 class CallFunctionParameters final { 51 class CallFunctionParameters final {
23 public: 52 public:
24 CallFunctionParameters(size_t arity, CallFunctionFlags flags, 53 CallFunctionParameters(size_t arity, CallFunctionFlags flags,
25 LanguageMode language_mode) 54 LanguageMode language_mode,
55 VectorSlotPair const& feedback)
26 : bit_field_(ArityField::encode(arity) | FlagsField::encode(flags) | 56 : bit_field_(ArityField::encode(arity) | FlagsField::encode(flags) |
27 LanguageModeField::encode(language_mode)) {} 57 LanguageModeField::encode(language_mode)),
58 feedback_(feedback) {}
28 59
29 size_t arity() const { return ArityField::decode(bit_field_); } 60 size_t arity() const { return ArityField::decode(bit_field_); }
30 CallFunctionFlags flags() const { return FlagsField::decode(bit_field_); } 61 CallFunctionFlags flags() const { return FlagsField::decode(bit_field_); }
31 LanguageMode language_mode() const { 62 LanguageMode language_mode() const {
32 return LanguageModeField::decode(bit_field_); 63 return LanguageModeField::decode(bit_field_);
33 } 64 }
65 VectorSlotPair const& feedback() const { return feedback_; }
34 66
35 bool operator==(CallFunctionParameters const& that) const { 67 bool operator==(CallFunctionParameters const& that) const {
36 return this->bit_field_ == that.bit_field_; 68 return this->bit_field_ == that.bit_field_ &&
69 this->feedback_ == that.feedback_;
37 } 70 }
38 bool operator!=(CallFunctionParameters const& that) const { 71 bool operator!=(CallFunctionParameters const& that) const {
39 return !(*this == that); 72 return !(*this == that);
40 } 73 }
41 74
42 private: 75 private:
43 friend size_t hash_value(CallFunctionParameters const& p) { 76 friend size_t hash_value(CallFunctionParameters const& p) {
44 return p.bit_field_; 77 return base::hash_combine(p.bit_field_, p.feedback_);
45 } 78 }
46 79
47 typedef BitField<size_t, 0, 28> ArityField; 80 typedef BitField<size_t, 0, 28> ArityField;
48 typedef BitField<CallFunctionFlags, 28, 2> FlagsField; 81 typedef BitField<CallFunctionFlags, 28, 2> FlagsField;
49 typedef BitField<LanguageMode, 30, 2> LanguageModeField; 82 typedef BitField<LanguageMode, 30, 2> LanguageModeField;
50 83
51 const uint32_t bit_field_; 84 const uint32_t bit_field_;
85 const VectorSlotPair feedback_;
52 }; 86 };
53 87
54 size_t hash_value(CallFunctionParameters const&); 88 size_t hash_value(CallFunctionParameters const&);
55 89
56 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&); 90 std::ostream& operator<<(std::ostream&, CallFunctionParameters const&);
57 91
58 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op); 92 const CallFunctionParameters& CallFunctionParametersOf(const Operator* op);
59 93
60 94
61 // Defines the arity and the ID for a runtime function call. This is used as a 95 // Defines the arity and the ID for a runtime function call. This is used as a
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 bool operator==(ContextAccess const&, ContextAccess const&); 139 bool operator==(ContextAccess const&, ContextAccess const&);
106 bool operator!=(ContextAccess const&, ContextAccess const&); 140 bool operator!=(ContextAccess const&, ContextAccess const&);
107 141
108 size_t hash_value(ContextAccess const&); 142 size_t hash_value(ContextAccess const&);
109 143
110 std::ostream& operator<<(std::ostream&, ContextAccess const&); 144 std::ostream& operator<<(std::ostream&, ContextAccess const&);
111 145
112 ContextAccess const& ContextAccessOf(Operator const*); 146 ContextAccess const& ContextAccessOf(Operator const*);
113 147
114 148
115 // A ResolvedFeedbackSlot needs to query the type feedback vector to get it's
116 // index in the vector.
117 class ResolvedFeedbackSlot {
118 public:
119 ResolvedFeedbackSlot(Handle<TypeFeedbackVector> vector,
120 FeedbackVectorICSlot slot)
121 : slot_(slot),
122 index_(slot == FeedbackVectorICSlot::Invalid() ? -1 : vector->GetIndex(
123 slot)) {}
124 ResolvedFeedbackSlot() : slot_(FeedbackVectorICSlot::Invalid()), index_(-1) {}
125
126 FeedbackVectorICSlot slot() const { return slot_; }
127 int index() const { return index_; }
128
129 private:
130 const FeedbackVectorICSlot slot_;
131 const int index_;
132 };
133
134
135 bool operator==(ResolvedFeedbackSlot const& lhs,
136 ResolvedFeedbackSlot const& rhs);
137
138
139 // Defines the name for a dynamic variable lookup. The {check_bitset} allows to 149 // Defines the name for a dynamic variable lookup. The {check_bitset} allows to
140 // inline checks whether the lookup yields in a global variable. This is used as 150 // inline checks whether the lookup yields in a global variable. This is used as
141 // a parameter by JSLoadDynamicGlobal and JSStoreDynamicGlobal operators. 151 // a parameter by JSLoadDynamicGlobal and JSStoreDynamicGlobal operators.
142 class DynamicGlobalAccess final { 152 class DynamicGlobalAccess final {
143 public: 153 public:
144 DynamicGlobalAccess(const Handle<String>& name, uint32_t check_bitset, 154 DynamicGlobalAccess(const Handle<String>& name, uint32_t check_bitset,
145 const ResolvedFeedbackSlot& feedback, 155 const VectorSlotPair& feedback, ContextualMode mode);
146 ContextualMode mode);
147 156
148 const Handle<String>& name() const { return name_; } 157 const Handle<String>& name() const { return name_; }
149 uint32_t check_bitset() const { return check_bitset_; } 158 uint32_t check_bitset() const { return check_bitset_; }
150 const ResolvedFeedbackSlot& feedback() const { return feedback_; } 159 const VectorSlotPair& feedback() const { return feedback_; }
151 ContextualMode mode() const { return mode_; } 160 ContextualMode mode() const { return mode_; }
152 161
153 // Indicates that an inline check is disabled. 162 // Indicates that an inline check is disabled.
154 bool RequiresFullCheck() const { 163 bool RequiresFullCheck() const {
155 return check_bitset() == kFullCheckRequired; 164 return check_bitset() == kFullCheckRequired;
156 } 165 }
157 166
158 // Limit of context chain length to which inline check is possible. 167 // Limit of context chain length to which inline check is possible.
159 static const int kMaxCheckDepth = 30; 168 static const int kMaxCheckDepth = 30;
160 169
161 // Sentinel for {check_bitset} disabling inline checks. 170 // Sentinel for {check_bitset} disabling inline checks.
162 static const uint32_t kFullCheckRequired = -1; 171 static const uint32_t kFullCheckRequired = -1;
163 172
164 private: 173 private:
165 const Handle<String> name_; 174 const Handle<String> name_;
166 const uint32_t check_bitset_; 175 const uint32_t check_bitset_;
167 const ResolvedFeedbackSlot feedback_; 176 const VectorSlotPair feedback_;
168 const ContextualMode mode_; 177 const ContextualMode mode_;
169 }; 178 };
170 179
171 size_t hash_value(DynamicGlobalAccess const&); 180 size_t hash_value(DynamicGlobalAccess const&);
172 181
173 bool operator==(DynamicGlobalAccess const&, DynamicGlobalAccess const&); 182 bool operator==(DynamicGlobalAccess const&, DynamicGlobalAccess const&);
174 bool operator!=(DynamicGlobalAccess const&, DynamicGlobalAccess const&); 183 bool operator!=(DynamicGlobalAccess const&, DynamicGlobalAccess const&);
175 184
176 std::ostream& operator<<(std::ostream&, DynamicGlobalAccess const&); 185 std::ostream& operator<<(std::ostream&, DynamicGlobalAccess const&);
177 186
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 223
215 std::ostream& operator<<(std::ostream&, DynamicContextAccess const&); 224 std::ostream& operator<<(std::ostream&, DynamicContextAccess const&);
216 225
217 DynamicContextAccess const& DynamicContextAccessOf(Operator const*); 226 DynamicContextAccess const& DynamicContextAccessOf(Operator const*);
218 227
219 228
220 // Defines the property being loaded from an object by a named load. This is 229 // Defines the property being loaded from an object by a named load. This is
221 // used as a parameter by JSLoadNamed operators. 230 // used as a parameter by JSLoadNamed operators.
222 class LoadNamedParameters final { 231 class LoadNamedParameters final {
223 public: 232 public:
224 LoadNamedParameters(const Unique<Name>& name, 233 LoadNamedParameters(const Unique<Name>& name, const VectorSlotPair& feedback,
225 const ResolvedFeedbackSlot& feedback,
226 ContextualMode contextual_mode) 234 ContextualMode contextual_mode)
227 : name_(name), feedback_(feedback), contextual_mode_(contextual_mode) {} 235 : name_(name), feedback_(feedback), contextual_mode_(contextual_mode) {}
228 236
229 const Unique<Name>& name() const { return name_; } 237 const Unique<Name>& name() const { return name_; }
230 ContextualMode contextual_mode() const { return contextual_mode_; } 238 ContextualMode contextual_mode() const { return contextual_mode_; }
231 239
232 const ResolvedFeedbackSlot& feedback() const { return feedback_; } 240 const VectorSlotPair& feedback() const { return feedback_; }
233 241
234 private: 242 private:
235 const Unique<Name> name_; 243 const Unique<Name> name_;
236 const ResolvedFeedbackSlot feedback_; 244 const VectorSlotPair feedback_;
237 const ContextualMode contextual_mode_; 245 const ContextualMode contextual_mode_;
238 }; 246 };
239 247
240 bool operator==(LoadNamedParameters const&, LoadNamedParameters const&); 248 bool operator==(LoadNamedParameters const&, LoadNamedParameters const&);
241 bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&); 249 bool operator!=(LoadNamedParameters const&, LoadNamedParameters const&);
242 250
243 size_t hash_value(LoadNamedParameters const&); 251 size_t hash_value(LoadNamedParameters const&);
244 252
245 std::ostream& operator<<(std::ostream&, LoadNamedParameters const&); 253 std::ostream& operator<<(std::ostream&, LoadNamedParameters const&);
246 254
247 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op); 255 const LoadNamedParameters& LoadNamedParametersOf(const Operator* op);
248 256
249 257
250 // Defines the property being loaded from an object. This is 258 // Defines the property being loaded from an object. This is
251 // used as a parameter by JSLoadProperty operators. 259 // used as a parameter by JSLoadProperty operators.
252 class LoadPropertyParameters final { 260 class LoadPropertyParameters final {
253 public: 261 public:
254 explicit LoadPropertyParameters(const ResolvedFeedbackSlot& feedback) 262 explicit LoadPropertyParameters(const VectorSlotPair& feedback)
255 : feedback_(feedback) {} 263 : feedback_(feedback) {}
256 264
257 const ResolvedFeedbackSlot& feedback() const { return feedback_; } 265 const VectorSlotPair& feedback() const { return feedback_; }
258 266
259 private: 267 private:
260 const ResolvedFeedbackSlot feedback_; 268 const VectorSlotPair feedback_;
261 }; 269 };
262 270
263 bool operator==(LoadPropertyParameters const&, LoadPropertyParameters const&); 271 bool operator==(LoadPropertyParameters const&, LoadPropertyParameters const&);
264 bool operator!=(LoadPropertyParameters const&, LoadPropertyParameters const&); 272 bool operator!=(LoadPropertyParameters const&, LoadPropertyParameters const&);
265 273
266 size_t hash_value(LoadPropertyParameters const&); 274 size_t hash_value(LoadPropertyParameters const&);
267 275
268 std::ostream& operator<<(std::ostream&, LoadPropertyParameters const&); 276 std::ostream& operator<<(std::ostream&, LoadPropertyParameters const&);
269 277
270 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op); 278 const LoadPropertyParameters& LoadPropertyParametersOf(const Operator* op);
271 279
272 280
273 // Defines the property being stored to an object by a named store. This is 281 // Defines the property being stored to an object by a named store. This is
274 // used as a parameter by JSStoreNamed operators. 282 // used as a parameter by JSStoreNamed operators.
275 class StoreNamedParameters final { 283 class StoreNamedParameters final {
276 public: 284 public:
277 StoreNamedParameters(LanguageMode language_mode, 285 StoreNamedParameters(LanguageMode language_mode,
278 const ResolvedFeedbackSlot& feedback, 286 const VectorSlotPair& feedback, const Unique<Name>& name)
279 const Unique<Name>& name)
280 : language_mode_(language_mode), name_(name), feedback_(feedback) {} 287 : language_mode_(language_mode), name_(name), feedback_(feedback) {}
281 288
282 LanguageMode language_mode() const { return language_mode_; } 289 LanguageMode language_mode() const { return language_mode_; }
283 const ResolvedFeedbackSlot& feedback() const { return feedback_; } 290 const VectorSlotPair& feedback() const { return feedback_; }
284 const Unique<Name>& name() const { return name_; } 291 const Unique<Name>& name() const { return name_; }
285 292
286 private: 293 private:
287 const LanguageMode language_mode_; 294 const LanguageMode language_mode_;
288 const Unique<Name> name_; 295 const Unique<Name> name_;
289 const ResolvedFeedbackSlot feedback_; 296 const VectorSlotPair feedback_;
290 }; 297 };
291 298
292 bool operator==(StoreNamedParameters const&, StoreNamedParameters const&); 299 bool operator==(StoreNamedParameters const&, StoreNamedParameters const&);
293 bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&); 300 bool operator!=(StoreNamedParameters const&, StoreNamedParameters const&);
294 301
295 size_t hash_value(StoreNamedParameters const&); 302 size_t hash_value(StoreNamedParameters const&);
296 303
297 std::ostream& operator<<(std::ostream&, StoreNamedParameters const&); 304 std::ostream& operator<<(std::ostream&, StoreNamedParameters const&);
298 305
299 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op); 306 const StoreNamedParameters& StoreNamedParametersOf(const Operator* op);
300 307
301 308
302 // Defines the property being stored to an object. This is used as a parameter 309 // Defines the property being stored to an object. This is used as a parameter
303 // by JSStoreProperty operators. 310 // by JSStoreProperty operators.
304 class StorePropertyParameters final { 311 class StorePropertyParameters final {
305 public: 312 public:
306 StorePropertyParameters(LanguageMode language_mode, 313 StorePropertyParameters(LanguageMode language_mode,
307 const ResolvedFeedbackSlot& feedback) 314 const VectorSlotPair& feedback)
308 : language_mode_(language_mode), feedback_(feedback) {} 315 : language_mode_(language_mode), feedback_(feedback) {}
309 316
310 LanguageMode language_mode() const { return language_mode_; } 317 LanguageMode language_mode() const { return language_mode_; }
311 const ResolvedFeedbackSlot& feedback() const { return feedback_; } 318 const VectorSlotPair& feedback() const { return feedback_; }
312 319
313 private: 320 private:
314 const LanguageMode language_mode_; 321 const LanguageMode language_mode_;
315 const ResolvedFeedbackSlot feedback_; 322 const VectorSlotPair feedback_;
316 }; 323 };
317 324
318 bool operator==(StorePropertyParameters const&, StorePropertyParameters const&); 325 bool operator==(StorePropertyParameters const&, StorePropertyParameters const&);
319 bool operator!=(StorePropertyParameters const&, StorePropertyParameters const&); 326 bool operator!=(StorePropertyParameters const&, StorePropertyParameters const&);
320 327
321 size_t hash_value(StorePropertyParameters const&); 328 size_t hash_value(StorePropertyParameters const&);
322 329
323 std::ostream& operator<<(std::ostream&, StorePropertyParameters const&); 330 std::ostream& operator<<(std::ostream&, StorePropertyParameters const&);
324 331
325 const StorePropertyParameters& StorePropertyParametersOf(const Operator* op); 332 const StorePropertyParameters& StorePropertyParametersOf(const Operator* op);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 const Operator* ToName(); 392 const Operator* ToName();
386 const Operator* ToObject(); 393 const Operator* ToObject();
387 const Operator* Yield(); 394 const Operator* Yield();
388 395
389 const Operator* Create(); 396 const Operator* Create();
390 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info, 397 const Operator* CreateClosure(Handle<SharedFunctionInfo> shared_info,
391 PretenureFlag pretenure); 398 PretenureFlag pretenure);
392 const Operator* CreateLiteralArray(int literal_flags); 399 const Operator* CreateLiteralArray(int literal_flags);
393 const Operator* CreateLiteralObject(int literal_flags); 400 const Operator* CreateLiteralObject(int literal_flags);
394 401
395 const Operator* CallFunction(size_t arity, CallFunctionFlags flags, 402 const Operator* CallFunction(
396 LanguageMode language_mode); 403 size_t arity, CallFunctionFlags flags, LanguageMode language_mode,
404 VectorSlotPair const& feedback = VectorSlotPair());
397 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity); 405 const Operator* CallRuntime(Runtime::FunctionId id, size_t arity);
398 406
399 const Operator* CallConstruct(int arguments); 407 const Operator* CallConstruct(int arguments);
400 408
401 const Operator* LoadProperty(const ResolvedFeedbackSlot& feedback); 409 const Operator* LoadProperty(const VectorSlotPair& feedback);
402 const Operator* LoadNamed(const Unique<Name>& name, 410 const Operator* LoadNamed(const Unique<Name>& name,
403 const ResolvedFeedbackSlot& feedback, 411 const VectorSlotPair& feedback,
404 ContextualMode contextual_mode = NOT_CONTEXTUAL); 412 ContextualMode contextual_mode = NOT_CONTEXTUAL);
405 413
406 const Operator* StoreProperty(LanguageMode language_mode, 414 const Operator* StoreProperty(LanguageMode language_mode,
407 const ResolvedFeedbackSlot& feedback); 415 const VectorSlotPair& feedback);
408 const Operator* StoreNamed(LanguageMode language_mode, 416 const Operator* StoreNamed(LanguageMode language_mode,
409 const Unique<Name>& name, 417 const Unique<Name>& name,
410 const ResolvedFeedbackSlot& feedback); 418 const VectorSlotPair& feedback);
411 419
412 const Operator* DeleteProperty(LanguageMode language_mode); 420 const Operator* DeleteProperty(LanguageMode language_mode);
413 421
414 const Operator* HasProperty(); 422 const Operator* HasProperty();
415 423
416 const Operator* LoadContext(size_t depth, size_t index, bool immutable); 424 const Operator* LoadContext(size_t depth, size_t index, bool immutable);
417 const Operator* StoreContext(size_t depth, size_t index); 425 const Operator* StoreContext(size_t depth, size_t index);
418 426
419 const Operator* LoadDynamicGlobal(const Handle<String>& name, 427 const Operator* LoadDynamicGlobal(const Handle<String>& name,
420 uint32_t check_bitset, 428 uint32_t check_bitset,
421 const ResolvedFeedbackSlot& feedback, 429 const VectorSlotPair& feedback,
422 ContextualMode mode); 430 ContextualMode mode);
423 const Operator* LoadDynamicContext(const Handle<String>& name, 431 const Operator* LoadDynamicContext(const Handle<String>& name,
424 uint32_t check_bitset, size_t depth, 432 uint32_t check_bitset, size_t depth,
425 size_t index); 433 size_t index);
426 434
427 const Operator* TypeOf(); 435 const Operator* TypeOf();
428 const Operator* InstanceOf(); 436 const Operator* InstanceOf();
429 437
430 const Operator* ForInDone(); 438 const Operator* ForInDone();
431 const Operator* ForInNext(); 439 const Operator* ForInNext();
(...skipping 17 matching lines...) Expand all
449 Zone* const zone_; 457 Zone* const zone_;
450 458
451 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder); 459 DISALLOW_COPY_AND_ASSIGN(JSOperatorBuilder);
452 }; 460 };
453 461
454 } // namespace compiler 462 } // namespace compiler
455 } // namespace internal 463 } // namespace internal
456 } // namespace v8 464 } // namespace v8
457 465
458 #endif // V8_COMPILER_JS_OPERATOR_H_ 466 #endif // V8_COMPILER_JS_OPERATOR_H_
OLDNEW
« no previous file with comments | « src/compiler/ast-graph-builder.cc ('k') | src/compiler/js-operator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698