1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "src/compiler/js-operator.h"
6
7 #include <limits>
8
9 #include "src/base/lazy-instance.h"
10 #include "src/compiler/js-graph.h"
11 #include "src/compiler/js-heap-broker.h"
12 #include "src/compiler/node-matchers.h"
13 #include "src/compiler/operator.h"
14 #include "src/handles/handles-inl.h"
15 #include "src/objects/objects-inl.h"
16 #include "src/objects/template-objects.h"
17
18 namespace v8 {
19 namespace internal {
20 namespace compiler {
21
22 namespace {
23
24 // Returns properties for the given binary op.
BinopProperties(Operator::Opcode opcode)25 constexpr Operator::Properties BinopProperties(Operator::Opcode opcode) {
26 DCHECK(JSOperator::IsBinaryWithFeedback(opcode));
27 return opcode == IrOpcode::kJSStrictEqual ? Operator::kPure
28 : Operator::kNoProperties;
29 }
30
31 template <class T>
AddressOrNull(base::Optional<T> ref)32 Address AddressOrNull(base::Optional<T> ref) {
33 if (!ref.has_value()) return kNullAddress;
34 return ref->object().address();
35 }
36
37 } // namespace
38
39 namespace js_node_wrapper_utils {
40
UndefinedConstant(JSGraph * jsgraph)41 TNode<Oddball> UndefinedConstant(JSGraph* jsgraph) {
42 return TNode<Oddball>::UncheckedCast(jsgraph->UndefinedConstant());
43 }
44
45 } // namespace js_node_wrapper_utils
46
GetFeedbackCellRefChecked(JSHeapBroker * broker) const47 FeedbackCellRef JSCreateClosureNode::GetFeedbackCellRefChecked(
48 JSHeapBroker* broker) const {
49 HeapObjectMatcher m(feedback_cell());
50 CHECK(m.HasResolvedValue());
51 return MakeRef(broker, Handle<FeedbackCell>::cast(m.ResolvedValue()));
52 }
53
operator <<(std::ostream & os,CallFrequency const & f)54 std::ostream& operator<<(std::ostream& os, CallFrequency const& f) {
55 if (f.IsUnknown()) return os << "unknown";
56 return os << f.value();
57 }
58
operator <<(std::ostream & os,ConstructForwardVarargsParameters const & p)59 std::ostream& operator<<(std::ostream& os,
60 ConstructForwardVarargsParameters const& p) {
61 return os << p.arity() << ", " << p.start_index();
62 }
63
ConstructForwardVarargsParametersOf(Operator const * op)64 ConstructForwardVarargsParameters const& ConstructForwardVarargsParametersOf(
65 Operator const* op) {
66 DCHECK_EQ(IrOpcode::kJSConstructForwardVarargs, op->opcode());
67 return OpParameter<ConstructForwardVarargsParameters>(op);
68 }
69
operator ==(ConstructParameters const & lhs,ConstructParameters const & rhs)70 bool operator==(ConstructParameters const& lhs,
71 ConstructParameters const& rhs) {
72 return lhs.arity() == rhs.arity() && lhs.frequency() == rhs.frequency() &&
73 lhs.feedback() == rhs.feedback();
74 }
75
operator !=(ConstructParameters const & lhs,ConstructParameters const & rhs)76 bool operator!=(ConstructParameters const& lhs,
77 ConstructParameters const& rhs) {
78 return !(lhs == rhs);
79 }
80
hash_value(ConstructParameters const & p)81 size_t hash_value(ConstructParameters const& p) {
82 return base::hash_combine(p.arity(), p.frequency(),
83 FeedbackSource::Hash()(p.feedback()));
84 }
85
operator <<(std::ostream & os,ConstructParameters const & p)86 std::ostream& operator<<(std::ostream& os, ConstructParameters const& p) {
87 return os << p.arity() << ", " << p.frequency();
88 }
89
ConstructParametersOf(Operator const * op)90 ConstructParameters const& ConstructParametersOf(Operator const* op) {
91 DCHECK(op->opcode() == IrOpcode::kJSConstruct ||
92 op->opcode() == IrOpcode::kJSConstructWithArrayLike ||
93 op->opcode() == IrOpcode::kJSConstructWithSpread);
94 return OpParameter<ConstructParameters>(op);
95 }
96
operator <<(std::ostream & os,CallParameters const & p)97 std::ostream& operator<<(std::ostream& os, CallParameters const& p) {
98 return os << p.arity() << ", " << p.frequency() << ", " << p.convert_mode()
99 << ", " << p.speculation_mode() << ", " << p.feedback_relation();
100 }
101
CallParametersOf(const Operator * op)102 const CallParameters& CallParametersOf(const Operator* op) {
103 DCHECK(op->opcode() == IrOpcode::kJSCall ||
104 op->opcode() == IrOpcode::kJSCallWithArrayLike ||
105 op->opcode() == IrOpcode::kJSCallWithSpread);
106 return OpParameter<CallParameters>(op);
107 }
108
operator <<(std::ostream & os,CallForwardVarargsParameters const & p)109 std::ostream& operator<<(std::ostream& os,
110 CallForwardVarargsParameters const& p) {
111 return os << p.arity() << ", " << p.start_index();
112 }
113
CallForwardVarargsParametersOf(Operator const * op)114 CallForwardVarargsParameters const& CallForwardVarargsParametersOf(
115 Operator const* op) {
116 DCHECK_EQ(IrOpcode::kJSCallForwardVarargs, op->opcode());
117 return OpParameter<CallForwardVarargsParameters>(op);
118 }
119
120
operator ==(CallRuntimeParameters const & lhs,CallRuntimeParameters const & rhs)121 bool operator==(CallRuntimeParameters const& lhs,
122 CallRuntimeParameters const& rhs) {
123 return lhs.id() == rhs.id() && lhs.arity() == rhs.arity();
124 }
125
126
operator !=(CallRuntimeParameters const & lhs,CallRuntimeParameters const & rhs)127 bool operator!=(CallRuntimeParameters const& lhs,
128 CallRuntimeParameters const& rhs) {
129 return !(lhs == rhs);
130 }
131
132
hash_value(CallRuntimeParameters const & p)133 size_t hash_value(CallRuntimeParameters const& p) {
134 return base::hash_combine(p.id(), p.arity());
135 }
136
137
operator <<(std::ostream & os,CallRuntimeParameters const & p)138 std::ostream& operator<<(std::ostream& os, CallRuntimeParameters const& p) {
139 return os << p.id() << ", " << p.arity();
140 }
141
142
CallRuntimeParametersOf(const Operator * op)143 const CallRuntimeParameters& CallRuntimeParametersOf(const Operator* op) {
144 DCHECK_EQ(IrOpcode::kJSCallRuntime, op->opcode());
145 return OpParameter<CallRuntimeParameters>(op);
146 }
147
148
ContextAccess(size_t depth,size_t index,bool immutable)149 ContextAccess::ContextAccess(size_t depth, size_t index, bool immutable)
150 : immutable_(immutable),
151 depth_(static_cast<uint16_t>(depth)),
152 index_(static_cast<uint32_t>(index)) {
153 DCHECK(depth <= std::numeric_limits<uint16_t>::max());
154 DCHECK(index <= std::numeric_limits<uint32_t>::max());
155 }
156
157
operator ==(ContextAccess const & lhs,ContextAccess const & rhs)158 bool operator==(ContextAccess const& lhs, ContextAccess const& rhs) {
159 return lhs.depth() == rhs.depth() && lhs.index() == rhs.index() &&
160 lhs.immutable() == rhs.immutable();
161 }
162
163
operator !=(ContextAccess const & lhs,ContextAccess const & rhs)164 bool operator!=(ContextAccess const& lhs, ContextAccess const& rhs) {
165 return !(lhs == rhs);
166 }
167
168
hash_value(ContextAccess const & access)169 size_t hash_value(ContextAccess const& access) {
170 return base::hash_combine(access.depth(), access.index(), access.immutable());
171 }
172
173
operator <<(std::ostream & os,ContextAccess const & access)174 std::ostream& operator<<(std::ostream& os, ContextAccess const& access) {
175 return os << access.depth() << ", " << access.index() << ", "
176 << access.immutable();
177 }
178
179
ContextAccessOf(Operator const * op)180 ContextAccess const& ContextAccessOf(Operator const* op) {
181 DCHECK(op->opcode() == IrOpcode::kJSLoadContext ||
182 op->opcode() == IrOpcode::kJSStoreContext);
183 return OpParameter<ContextAccess>(op);
184 }
185
operator ==(CreateFunctionContextParameters const & lhs,CreateFunctionContextParameters const & rhs)186 bool operator==(CreateFunctionContextParameters const& lhs,
187 CreateFunctionContextParameters const& rhs) {
188 return lhs.scope_info_.object().location() ==
189 rhs.scope_info_.object().location() &&
190 lhs.slot_count() == rhs.slot_count() &&
191 lhs.scope_type() == rhs.scope_type();
192 }
193
operator !=(CreateFunctionContextParameters const & lhs,CreateFunctionContextParameters const & rhs)194 bool operator!=(CreateFunctionContextParameters const& lhs,
195 CreateFunctionContextParameters const& rhs) {
196 return !(lhs == rhs);
197 }
198
hash_value(CreateFunctionContextParameters const & parameters)199 size_t hash_value(CreateFunctionContextParameters const& parameters) {
200 return base::hash_combine(parameters.scope_info_.object().location(),
201 parameters.slot_count(),
202 static_cast<int>(parameters.scope_type()));
203 }
204
operator <<(std::ostream & os,CreateFunctionContextParameters const & parameters)205 std::ostream& operator<<(std::ostream& os,
206 CreateFunctionContextParameters const& parameters) {
207 return os << parameters.slot_count() << ", " << parameters.scope_type();
208 }
209
CreateFunctionContextParametersOf(Operator const * op)210 CreateFunctionContextParameters const& CreateFunctionContextParametersOf(
211 Operator const* op) {
212 DCHECK_EQ(IrOpcode::kJSCreateFunctionContext, op->opcode());
213 return OpParameter<CreateFunctionContextParameters>(op);
214 }
215
operator ==(StoreNamedOwnParameters const & lhs,StoreNamedOwnParameters const & rhs)216 bool operator==(StoreNamedOwnParameters const& lhs,
217 StoreNamedOwnParameters const& rhs) {
218 return lhs.name_.object().location() == rhs.name_.object().location() &&
219 lhs.feedback() == rhs.feedback();
220 }
221
operator !=(StoreNamedOwnParameters const & lhs,StoreNamedOwnParameters const & rhs)222 bool operator!=(StoreNamedOwnParameters const& lhs,
223 StoreNamedOwnParameters const& rhs) {
224 return !(lhs == rhs);
225 }
226
hash_value(StoreNamedOwnParameters const & p)227 size_t hash_value(StoreNamedOwnParameters const& p) {
228 return base::hash_combine(p.name_.object().location(),
229 FeedbackSource::Hash()(p.feedback()));
230 }
231
operator <<(std::ostream & os,StoreNamedOwnParameters const & p)232 std::ostream& operator<<(std::ostream& os, StoreNamedOwnParameters const& p) {
233 return os << Brief(*p.name_.object());
234 }
235
StoreNamedOwnParametersOf(const Operator * op)236 StoreNamedOwnParameters const& StoreNamedOwnParametersOf(const Operator* op) {
237 DCHECK_EQ(IrOpcode::kJSStoreNamedOwn, op->opcode());
238 return OpParameter<StoreNamedOwnParameters>(op);
239 }
240
operator ==(FeedbackParameter const & lhs,FeedbackParameter const & rhs)241 bool operator==(FeedbackParameter const& lhs, FeedbackParameter const& rhs) {
242 return lhs.feedback() == rhs.feedback();
243 }
244
operator !=(FeedbackParameter const & lhs,FeedbackParameter const & rhs)245 bool operator!=(FeedbackParameter const& lhs, FeedbackParameter const& rhs) {
246 return !(lhs == rhs);
247 }
248
hash_value(FeedbackParameter const & p)249 size_t hash_value(FeedbackParameter const& p) {
250 return FeedbackSource::Hash()(p.feedback());
251 }
252
operator <<(std::ostream & os,FeedbackParameter const & p)253 std::ostream& operator<<(std::ostream& os, FeedbackParameter const& p) {
254 return os << p.feedback();
255 }
256
FeedbackParameterOf(const Operator * op)257 FeedbackParameter const& FeedbackParameterOf(const Operator* op) {
258 DCHECK(JSOperator::IsUnaryWithFeedback(op->opcode()) ||
259 JSOperator::IsBinaryWithFeedback(op->opcode()) ||
260 op->opcode() == IrOpcode::kJSCreateEmptyLiteralArray ||
261 op->opcode() == IrOpcode::kJSInstanceOf ||
262 op->opcode() == IrOpcode::kJSStoreDataPropertyInLiteral ||
263 op->opcode() == IrOpcode::kJSStoreInArrayLiteral);
264 return OpParameter<FeedbackParameter>(op);
265 }
266
operator ==(NamedAccess const & lhs,NamedAccess const & rhs)267 bool operator==(NamedAccess const& lhs, NamedAccess const& rhs) {
268 return lhs.name_.object().location() == rhs.name_.object().location() &&
269 lhs.language_mode() == rhs.language_mode() &&
270 lhs.feedback() == rhs.feedback();
271 }
272
273
operator !=(NamedAccess const & lhs,NamedAccess const & rhs)274 bool operator!=(NamedAccess const& lhs, NamedAccess const& rhs) {
275 return !(lhs == rhs);
276 }
277
278
hash_value(NamedAccess const & p)279 size_t hash_value(NamedAccess const& p) {
280 return base::hash_combine(p.name_.object().location(), p.language_mode(),
281 FeedbackSource::Hash()(p.feedback()));
282 }
283
284
operator <<(std::ostream & os,NamedAccess const & p)285 std::ostream& operator<<(std::ostream& os, NamedAccess const& p) {
286 return os << Brief(*p.name_.object()) << ", " << p.language_mode();
287 }
288
289
NamedAccessOf(const Operator * op)290 NamedAccess const& NamedAccessOf(const Operator* op) {
291 DCHECK(op->opcode() == IrOpcode::kJSLoadNamed ||
292 op->opcode() == IrOpcode::kJSLoadNamedFromSuper ||
293 op->opcode() == IrOpcode::kJSStoreNamed);
294 return OpParameter<NamedAccess>(op);
295 }
296
297
operator <<(std::ostream & os,PropertyAccess const & p)298 std::ostream& operator<<(std::ostream& os, PropertyAccess const& p) {
299 return os << p.language_mode() << ", " << p.feedback();
300 }
301
302
operator ==(PropertyAccess const & lhs,PropertyAccess const & rhs)303 bool operator==(PropertyAccess const& lhs, PropertyAccess const& rhs) {
304 return lhs.language_mode() == rhs.language_mode() &&
305 lhs.feedback() == rhs.feedback();
306 }
307
308
operator !=(PropertyAccess const & lhs,PropertyAccess const & rhs)309 bool operator!=(PropertyAccess const& lhs, PropertyAccess const& rhs) {
310 return !(lhs == rhs);
311 }
312
313
PropertyAccessOf(const Operator * op)314 PropertyAccess const& PropertyAccessOf(const Operator* op) {
315 DCHECK(op->opcode() == IrOpcode::kJSHasProperty ||
316 op->opcode() == IrOpcode::kJSLoadProperty ||
317 op->opcode() == IrOpcode::kJSStoreProperty);
318 return OpParameter<PropertyAccess>(op);
319 }
320
321
hash_value(PropertyAccess const & p)322 size_t hash_value(PropertyAccess const& p) {
323 return base::hash_combine(p.language_mode(),
324 FeedbackSource::Hash()(p.feedback()));
325 }
326
327
operator ==(LoadGlobalParameters const & lhs,LoadGlobalParameters const & rhs)328 bool operator==(LoadGlobalParameters const& lhs,
329 LoadGlobalParameters const& rhs) {
330 return lhs.name_.object().location() == rhs.name_.object().location() &&
331 lhs.feedback() == rhs.feedback() &&
332 lhs.typeof_mode() == rhs.typeof_mode();
333 }
334
335
operator !=(LoadGlobalParameters const & lhs,LoadGlobalParameters const & rhs)336 bool operator!=(LoadGlobalParameters const& lhs,
337 LoadGlobalParameters const& rhs) {
338 return !(lhs == rhs);
339 }
340
341
hash_value(LoadGlobalParameters const & p)342 size_t hash_value(LoadGlobalParameters const& p) {
343 return base::hash_combine(p.name_.object().location(),
344 static_cast<int>(p.typeof_mode()));
345 }
346
347
operator <<(std::ostream & os,LoadGlobalParameters const & p)348 std::ostream& operator<<(std::ostream& os, LoadGlobalParameters const& p) {
349 return os << Brief(*p.name_.object()) << ", "
350 << static_cast<int>(p.typeof_mode());
351 }
352
353
LoadGlobalParametersOf(const Operator * op)354 const LoadGlobalParameters& LoadGlobalParametersOf(const Operator* op) {
355 DCHECK_EQ(IrOpcode::kJSLoadGlobal, op->opcode());
356 return OpParameter<LoadGlobalParameters>(op);
357 }
358
359
operator ==(StoreGlobalParameters const & lhs,StoreGlobalParameters const & rhs)360 bool operator==(StoreGlobalParameters const& lhs,
361 StoreGlobalParameters const& rhs) {
362 return lhs.language_mode() == rhs.language_mode() &&
363 lhs.name_.object().location() == rhs.name_.object().location() &&
364 lhs.feedback() == rhs.feedback();
365 }
366
367
operator !=(StoreGlobalParameters const & lhs,StoreGlobalParameters const & rhs)368 bool operator!=(StoreGlobalParameters const& lhs,
369 StoreGlobalParameters const& rhs) {
370 return !(lhs == rhs);
371 }
372
373
hash_value(StoreGlobalParameters const & p)374 size_t hash_value(StoreGlobalParameters const& p) {
375 return base::hash_combine(p.language_mode(), p.name_.object().location(),
376 FeedbackSource::Hash()(p.feedback()));
377 }
378
379
operator <<(std::ostream & os,StoreGlobalParameters const & p)380 std::ostream& operator<<(std::ostream& os, StoreGlobalParameters const& p) {
381 return os << p.language_mode() << ", " << Brief(*p.name_.object());
382 }
383
384
StoreGlobalParametersOf(const Operator * op)385 const StoreGlobalParameters& StoreGlobalParametersOf(const Operator* op) {
386 DCHECK_EQ(IrOpcode::kJSStoreGlobal, op->opcode());
387 return OpParameter<StoreGlobalParameters>(op);
388 }
389
390
CreateArgumentsTypeOf(const Operator * op)391 CreateArgumentsType const& CreateArgumentsTypeOf(const Operator* op) {
392 DCHECK_EQ(IrOpcode::kJSCreateArguments, op->opcode());
393 return OpParameter<CreateArgumentsType>(op);
394 }
395
operator ==(CreateArrayParameters const & lhs,CreateArrayParameters const & rhs)396 bool operator==(CreateArrayParameters const& lhs,
397 CreateArrayParameters const& rhs) {
398 return lhs.arity() == rhs.arity() &&
399 AddressOrNull(lhs.site_) == AddressOrNull(rhs.site_);
400 }
401
402
operator !=(CreateArrayParameters const & lhs,CreateArrayParameters const & rhs)403 bool operator!=(CreateArrayParameters const& lhs,
404 CreateArrayParameters const& rhs) {
405 return !(lhs == rhs);
406 }
407
408
hash_value(CreateArrayParameters const & p)409 size_t hash_value(CreateArrayParameters const& p) {
410 return base::hash_combine(p.arity(), AddressOrNull(p.site_));
411 }
412
413
operator <<(std::ostream & os,CreateArrayParameters const & p)414 std::ostream& operator<<(std::ostream& os, CreateArrayParameters const& p) {
415 os << p.arity();
416 if (p.site_.has_value()) {
417 os << ", " << Brief(*p.site_->object());
418 }
419 return os;
420 }
421
CreateArrayParametersOf(const Operator * op)422 const CreateArrayParameters& CreateArrayParametersOf(const Operator* op) {
423 DCHECK_EQ(IrOpcode::kJSCreateArray, op->opcode());
424 return OpParameter<CreateArrayParameters>(op);
425 }
426
operator ==(CreateArrayIteratorParameters const & lhs,CreateArrayIteratorParameters const & rhs)427 bool operator==(CreateArrayIteratorParameters const& lhs,
428 CreateArrayIteratorParameters const& rhs) {
429 return lhs.kind() == rhs.kind();
430 }
431
operator !=(CreateArrayIteratorParameters const & lhs,CreateArrayIteratorParameters const & rhs)432 bool operator!=(CreateArrayIteratorParameters const& lhs,
433 CreateArrayIteratorParameters const& rhs) {
434 return !(lhs == rhs);
435 }
436
hash_value(CreateArrayIteratorParameters const & p)437 size_t hash_value(CreateArrayIteratorParameters const& p) {
438 return static_cast<size_t>(p.kind());
439 }
440
operator <<(std::ostream & os,CreateArrayIteratorParameters const & p)441 std::ostream& operator<<(std::ostream& os,
442 CreateArrayIteratorParameters const& p) {
443 return os << p.kind();
444 }
445
CreateArrayIteratorParametersOf(const Operator * op)446 const CreateArrayIteratorParameters& CreateArrayIteratorParametersOf(
447 const Operator* op) {
448 DCHECK_EQ(IrOpcode::kJSCreateArrayIterator, op->opcode());
449 return OpParameter<CreateArrayIteratorParameters>(op);
450 }
451
operator ==(CreateCollectionIteratorParameters const & lhs,CreateCollectionIteratorParameters const & rhs)452 bool operator==(CreateCollectionIteratorParameters const& lhs,
453 CreateCollectionIteratorParameters const& rhs) {
454 return lhs.collection_kind() == rhs.collection_kind() &&
455 lhs.iteration_kind() == rhs.iteration_kind();
456 }
457
operator !=(CreateCollectionIteratorParameters const & lhs,CreateCollectionIteratorParameters const & rhs)458 bool operator!=(CreateCollectionIteratorParameters const& lhs,
459 CreateCollectionIteratorParameters const& rhs) {
460 return !(lhs == rhs);
461 }
462
hash_value(CreateCollectionIteratorParameters const & p)463 size_t hash_value(CreateCollectionIteratorParameters const& p) {
464 return base::hash_combine(static_cast<size_t>(p.collection_kind()),
465 static_cast<size_t>(p.iteration_kind()));
466 }
467
operator <<(std::ostream & os,CreateCollectionIteratorParameters const & p)468 std::ostream& operator<<(std::ostream& os,
469 CreateCollectionIteratorParameters const& p) {
470 return os << p.collection_kind() << ", " << p.iteration_kind();
471 }
472
CreateCollectionIteratorParametersOf(const Operator * op)473 const CreateCollectionIteratorParameters& CreateCollectionIteratorParametersOf(
474 const Operator* op) {
475 DCHECK_EQ(IrOpcode::kJSCreateCollectionIterator, op->opcode());
476 return OpParameter<CreateCollectionIteratorParameters>(op);
477 }
478
operator ==(CreateBoundFunctionParameters const & lhs,CreateBoundFunctionParameters const & rhs)479 bool operator==(CreateBoundFunctionParameters const& lhs,
480 CreateBoundFunctionParameters const& rhs) {
481 return lhs.arity() == rhs.arity() &&
482 lhs.map_.object().location() == rhs.map_.object().location();
483 }
484
operator !=(CreateBoundFunctionParameters const & lhs,CreateBoundFunctionParameters const & rhs)485 bool operator!=(CreateBoundFunctionParameters const& lhs,
486 CreateBoundFunctionParameters const& rhs) {
487 return !(lhs == rhs);
488 }
489
hash_value(CreateBoundFunctionParameters const & p)490 size_t hash_value(CreateBoundFunctionParameters const& p) {
491 return base::hash_combine(p.arity(), p.map_.object().location());
492 }
493
operator <<(std::ostream & os,CreateBoundFunctionParameters const & p)494 std::ostream& operator<<(std::ostream& os,
495 CreateBoundFunctionParameters const& p) {
496 os << p.arity();
497 if (!p.map_.object().is_null()) os << ", " << Brief(*p.map_.object());
498 return os;
499 }
500
CreateBoundFunctionParametersOf(const Operator * op)501 const CreateBoundFunctionParameters& CreateBoundFunctionParametersOf(
502 const Operator* op) {
503 DCHECK_EQ(IrOpcode::kJSCreateBoundFunction, op->opcode());
504 return OpParameter<CreateBoundFunctionParameters>(op);
505 }
506
operator ==(GetTemplateObjectParameters const & lhs,GetTemplateObjectParameters const & rhs)507 bool operator==(GetTemplateObjectParameters const& lhs,
508 GetTemplateObjectParameters const& rhs) {
509 return lhs.description_.object().location() ==
510 rhs.description_.object().location() &&
511 lhs.shared_.object().location() == rhs.shared_.object().location() &&
512 lhs.feedback() == rhs.feedback();
513 }
514
operator !=(GetTemplateObjectParameters const & lhs,GetTemplateObjectParameters const & rhs)515 bool operator!=(GetTemplateObjectParameters const& lhs,
516 GetTemplateObjectParameters const& rhs) {
517 return !(lhs == rhs);
518 }
519
hash_value(GetTemplateObjectParameters const & p)520 size_t hash_value(GetTemplateObjectParameters const& p) {
521 return base::hash_combine(p.description_.object().location(),
522 p.shared_.object().location(),
523 FeedbackSource::Hash()(p.feedback()));
524 }
525
operator <<(std::ostream & os,GetTemplateObjectParameters const & p)526 std::ostream& operator<<(std::ostream& os,
527 GetTemplateObjectParameters const& p) {
528 return os << Brief(*p.description_.object()) << ", "
529 << Brief(*p.shared_.object());
530 }
531
GetTemplateObjectParametersOf(const Operator * op)532 const GetTemplateObjectParameters& GetTemplateObjectParametersOf(
533 const Operator* op) {
534 DCHECK(op->opcode() == IrOpcode::kJSGetTemplateObject);
535 return OpParameter<GetTemplateObjectParameters>(op);
536 }
537
operator ==(CreateClosureParameters const & lhs,CreateClosureParameters const & rhs)538 bool operator==(CreateClosureParameters const& lhs,
539 CreateClosureParameters const& rhs) {
540 return lhs.allocation() == rhs.allocation() &&
541 lhs.code_.object().location() == rhs.code_.object().location() &&
542 lhs.shared_info_.object().location() ==
543 rhs.shared_info_.object().location();
544 }
545
546
operator !=(CreateClosureParameters const & lhs,CreateClosureParameters const & rhs)547 bool operator!=(CreateClosureParameters const& lhs,
548 CreateClosureParameters const& rhs) {
549 return !(lhs == rhs);
550 }
551
552
hash_value(CreateClosureParameters const & p)553 size_t hash_value(CreateClosureParameters const& p) {
554 return base::hash_combine(p.allocation(), p.code_.object().location(),
555 p.shared_info_.object().location());
556 }
557
558
operator <<(std::ostream & os,CreateClosureParameters const & p)559 std::ostream& operator<<(std::ostream& os, CreateClosureParameters const& p) {
560 return os << p.allocation() << ", " << Brief(*p.shared_info_.object()) << ", "
561 << Brief(*p.code_.object());
562 }
563
564
CreateClosureParametersOf(const Operator * op)565 const CreateClosureParameters& CreateClosureParametersOf(const Operator* op) {
566 DCHECK_EQ(IrOpcode::kJSCreateClosure, op->opcode());
567 return OpParameter<CreateClosureParameters>(op);
568 }
569
570
operator ==(CreateLiteralParameters const & lhs,CreateLiteralParameters const & rhs)571 bool operator==(CreateLiteralParameters const& lhs,
572 CreateLiteralParameters const& rhs) {
573 return lhs.constant_.object().location() ==
574 rhs.constant_.object().location() &&
575 lhs.feedback() == rhs.feedback() && lhs.length() == rhs.length() &&
576 lhs.flags() == rhs.flags();
577 }
578
579
operator !=(CreateLiteralParameters const & lhs,CreateLiteralParameters const & rhs)580 bool operator!=(CreateLiteralParameters const& lhs,
581 CreateLiteralParameters const& rhs) {
582 return !(lhs == rhs);
583 }
584
585
hash_value(CreateLiteralParameters const & p)586 size_t hash_value(CreateLiteralParameters const& p) {
587 return base::hash_combine(p.constant_.object().location(),
588 FeedbackSource::Hash()(p.feedback()), p.length(),
589 p.flags());
590 }
591
592
operator <<(std::ostream & os,CreateLiteralParameters const & p)593 std::ostream& operator<<(std::ostream& os, CreateLiteralParameters const& p) {
594 return os << Brief(*p.constant_.object()) << ", " << p.length() << ", "
595 << p.flags();
596 }
597
598
CreateLiteralParametersOf(const Operator * op)599 const CreateLiteralParameters& CreateLiteralParametersOf(const Operator* op) {
600 DCHECK(op->opcode() == IrOpcode::kJSCreateLiteralArray ||
601 op->opcode() == IrOpcode::kJSCreateLiteralObject ||
602 op->opcode() == IrOpcode::kJSCreateLiteralRegExp);
603 return OpParameter<CreateLiteralParameters>(op);
604 }
605
operator ==(CloneObjectParameters const & lhs,CloneObjectParameters const & rhs)606 bool operator==(CloneObjectParameters const& lhs,
607 CloneObjectParameters const& rhs) {
608 return lhs.feedback() == rhs.feedback() && lhs.flags() == rhs.flags();
609 }
610
operator !=(CloneObjectParameters const & lhs,CloneObjectParameters const & rhs)611 bool operator!=(CloneObjectParameters const& lhs,
612 CloneObjectParameters const& rhs) {
613 return !(lhs == rhs);
614 }
615
hash_value(CloneObjectParameters const & p)616 size_t hash_value(CloneObjectParameters const& p) {
617 return base::hash_combine(FeedbackSource::Hash()(p.feedback()), p.flags());
618 }
619
operator <<(std::ostream & os,CloneObjectParameters const & p)620 std::ostream& operator<<(std::ostream& os, CloneObjectParameters const& p) {
621 return os << p.flags();
622 }
623
CloneObjectParametersOf(const Operator * op)624 const CloneObjectParameters& CloneObjectParametersOf(const Operator* op) {
625 DCHECK(op->opcode() == IrOpcode::kJSCloneObject);
626 return OpParameter<CloneObjectParameters>(op);
627 }
628
operator <<(std::ostream & os,GetIteratorParameters const & p)629 std::ostream& operator<<(std::ostream& os, GetIteratorParameters const& p) {
630 return os << p.loadFeedback() << ", " << p.callFeedback();
631 }
632
operator ==(GetIteratorParameters const & lhs,GetIteratorParameters const & rhs)633 bool operator==(GetIteratorParameters const& lhs,
634 GetIteratorParameters const& rhs) {
635 return lhs.loadFeedback() == rhs.loadFeedback() &&
636 lhs.callFeedback() == rhs.callFeedback();
637 }
638
operator !=(GetIteratorParameters const & lhs,GetIteratorParameters const & rhs)639 bool operator!=(GetIteratorParameters const& lhs,
640 GetIteratorParameters const& rhs) {
641 return !(lhs == rhs);
642 }
643
GetIteratorParametersOf(const Operator * op)644 GetIteratorParameters const& GetIteratorParametersOf(const Operator* op) {
645 DCHECK(op->opcode() == IrOpcode::kJSGetIterator);
646 return OpParameter<GetIteratorParameters>(op);
647 }
648
hash_value(GetIteratorParameters const & p)649 size_t hash_value(GetIteratorParameters const& p) {
650 return base::hash_combine(FeedbackSource::Hash()(p.loadFeedback()),
651 FeedbackSource::Hash()(p.callFeedback()));
652 }
653
hash_value(ForInMode const & mode)654 size_t hash_value(ForInMode const& mode) { return static_cast<uint8_t>(mode); }
655
operator <<(std::ostream & os,ForInMode const & mode)656 std::ostream& operator<<(std::ostream& os, ForInMode const& mode) {
657 switch (mode) {
658 case ForInMode::kUseEnumCacheKeysAndIndices:
659 return os << "UseEnumCacheKeysAndIndices";
660 case ForInMode::kUseEnumCacheKeys:
661 return os << "UseEnumCacheKeys";
662 case ForInMode::kGeneric:
663 return os << "Generic";
664 }
665 UNREACHABLE();
666 }
667
operator ==(ForInParameters const & lhs,ForInParameters const & rhs)668 bool operator==(ForInParameters const& lhs, ForInParameters const& rhs) {
669 return lhs.feedback() == rhs.feedback() && lhs.mode() == rhs.mode();
670 }
671
operator !=(ForInParameters const & lhs,ForInParameters const & rhs)672 bool operator!=(ForInParameters const& lhs, ForInParameters const& rhs) {
673 return !(lhs == rhs);
674 }
675
hash_value(ForInParameters const & p)676 size_t hash_value(ForInParameters const& p) {
677 return base::hash_combine(FeedbackSource::Hash()(p.feedback()), p.mode());
678 }
679
operator <<(std::ostream & os,ForInParameters const & p)680 std::ostream& operator<<(std::ostream& os, ForInParameters const& p) {
681 return os << p.feedback() << ", " << p.mode();
682 }
683
ForInParametersOf(const Operator * op)684 ForInParameters const& ForInParametersOf(const Operator* op) {
685 DCHECK(op->opcode() == IrOpcode::kJSForInNext ||
686 op->opcode() == IrOpcode::kJSForInPrepare);
687 return OpParameter<ForInParameters>(op);
688 }
689
690 #if V8_ENABLE_WEBASSEMBLY
JSWasmCallParametersOf(const Operator * op)691 JSWasmCallParameters const& JSWasmCallParametersOf(const Operator* op) {
692 DCHECK_EQ(IrOpcode::kJSWasmCall, op->opcode());
693 return OpParameter<JSWasmCallParameters>(op);
694 }
695
operator <<(std::ostream & os,JSWasmCallParameters const & p)696 std::ostream& operator<<(std::ostream& os, JSWasmCallParameters const& p) {
697 return os << p.module() << ", " << p.signature() << ", " << p.feedback();
698 }
699
hash_value(JSWasmCallParameters const & p)700 size_t hash_value(JSWasmCallParameters const& p) {
701 return base::hash_combine(p.module(), p.signature(),
702 FeedbackSource::Hash()(p.feedback()));
703 }
704
operator ==(JSWasmCallParameters const & lhs,JSWasmCallParameters const & rhs)705 bool operator==(JSWasmCallParameters const& lhs,
706 JSWasmCallParameters const& rhs) {
707 return lhs.module() == rhs.module() && lhs.signature() == rhs.signature() &&
708 lhs.feedback() == rhs.feedback();
709 }
710
arity_without_implicit_args() const711 int JSWasmCallParameters::arity_without_implicit_args() const {
712 return static_cast<int>(signature_->parameter_count());
713 }
714
input_count() const715 int JSWasmCallParameters::input_count() const {
716 return static_cast<int>(signature_->parameter_count()) +
717 JSWasmCallNode::kExtraInputCount;
718 }
719
720 // static
TypeForWasmReturnType(const wasm::ValueType & type)721 Type JSWasmCallNode::TypeForWasmReturnType(const wasm::ValueType& type) {
722 switch (type.kind()) {
723 case wasm::kI32:
724 return Type::Signed32();
725 case wasm::kI64:
726 return Type::BigInt();
727 case wasm::kF32:
728 case wasm::kF64:
729 return Type::Number();
730 default:
731 UNREACHABLE();
732 }
733 }
734 #endif // V8_ENABLE_WEBASSEMBLY
735
736 #define CACHED_OP_LIST(V) \
737 V(ToLength, Operator::kNoProperties, 1, 1) \
738 V(ToName, Operator::kNoProperties, 1, 1) \
739 V(ToNumber, Operator::kNoProperties, 1, 1) \
740 V(ToNumberConvertBigInt, Operator::kNoProperties, 1, 1) \
741 V(ToNumeric, Operator::kNoProperties, 1, 1) \
742 V(ToObject, Operator::kFoldable, 1, 1) \
743 V(ToString, Operator::kNoProperties, 1, 1) \
744 V(Create, Operator::kNoProperties, 2, 1) \
745 V(CreateIterResultObject, Operator::kEliminatable, 2, 1) \
746 V(CreateStringIterator, Operator::kEliminatable, 1, 1) \
747 V(CreateKeyValueArray, Operator::kEliminatable, 2, 1) \
748 V(CreatePromise, Operator::kEliminatable, 0, 1) \
749 V(CreateTypedArray, Operator::kNoProperties, 5, 1) \
750 V(CreateObject, Operator::kNoProperties, 1, 1) \
751 V(ObjectIsArray, Operator::kNoProperties, 1, 1) \
752 V(HasInPrototypeChain, Operator::kNoProperties, 2, 1) \
753 V(OrdinaryHasInstance, Operator::kNoProperties, 2, 1) \
754 V(ForInEnumerate, Operator::kNoProperties, 1, 1) \
755 V(AsyncFunctionEnter, Operator::kNoProperties, 2, 1) \
756 V(AsyncFunctionReject, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
757 V(AsyncFunctionResolve, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
758 V(LoadMessage, Operator::kNoThrow | Operator::kNoWrite, 0, 1) \
759 V(StoreMessage, Operator::kNoRead | Operator::kNoThrow, 1, 0) \
760 V(GeneratorRestoreContinuation, Operator::kNoThrow, 1, 1) \
761 V(GeneratorRestoreContext, Operator::kNoThrow, 1, 1) \
762 V(GeneratorRestoreInputOrDebugPos, Operator::kNoThrow, 1, 1) \
763 V(Debugger, Operator::kNoProperties, 0, 0) \
764 V(FulfillPromise, Operator::kNoDeopt | Operator::kNoThrow, 2, 1) \
765 V(PerformPromiseThen, Operator::kNoDeopt | Operator::kNoThrow, 4, 1) \
766 V(PromiseResolve, Operator::kNoProperties, 2, 1) \
767 V(RejectPromise, Operator::kNoDeopt | Operator::kNoThrow, 3, 1) \
768 V(ResolvePromise, Operator::kNoDeopt | Operator::kNoThrow, 2, 1) \
769 V(GetSuperConstructor, Operator::kNoWrite | Operator::kNoThrow, 1, 1) \
770 V(ParseInt, Operator::kNoProperties, 2, 1) \
771 V(RegExpTest, Operator::kNoProperties, 2, 1)
772
773 struct JSOperatorGlobalCache final {
774 #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
775 struct Name##Operator final : public Operator { \
776 Name##Operator() \
777 : Operator(IrOpcode::kJS##Name, properties, "JS" #Name, \
778 value_input_count, Operator::ZeroIfPure(properties), \
779 Operator::ZeroIfEliminatable(properties), \
780 value_output_count, Operator::ZeroIfPure(properties), \
781 Operator::ZeroIfNoThrow(properties)) {} \
782 }; \
783 Name##Operator k##Name##Operator;
784 CACHED_OP_LIST(CACHED_OP)
785 #undef CACHED_OP
786 };
787
788 namespace {
789 DEFINE_LAZY_LEAKY_OBJECT_GETTER(JSOperatorGlobalCache, GetJSOperatorGlobalCache)
790 } // namespace
791
JSOperatorBuilder(Zone * zone)792 JSOperatorBuilder::JSOperatorBuilder(Zone* zone)
793 : cache_(*GetJSOperatorGlobalCache()), zone_(zone) {}
794
795 #define CACHED_OP(Name, properties, value_input_count, value_output_count) \
796 const Operator* JSOperatorBuilder::Name() { \
797 return &cache_.k##Name##Operator; \
798 }
799 CACHED_OP_LIST(CACHED_OP)
800 #undef CACHED_OP
801
802 #define UNARY_OP(JSName, Name) \
803 const Operator* JSOperatorBuilder::Name(FeedbackSource const& feedback) { \
804 FeedbackParameter parameters(feedback); \
805 return zone()->New<Operator1<FeedbackParameter>>( \
806 IrOpcode::k##JSName, Operator::kNoProperties, #JSName, 2, 1, 1, 1, 1, \
807 2, parameters); \
808 }
JS_UNOP_WITH_FEEDBACK(UNARY_OP)809 JS_UNOP_WITH_FEEDBACK(UNARY_OP)
810 #undef UNARY_OP
811
812 #define BINARY_OP(JSName, Name) \
813 const Operator* JSOperatorBuilder::Name(FeedbackSource const& feedback) { \
814 static constexpr auto kProperties = BinopProperties(IrOpcode::k##JSName); \
815 FeedbackParameter parameters(feedback); \
816 return zone()->New<Operator1<FeedbackParameter>>( \
817 IrOpcode::k##JSName, kProperties, #JSName, 3, 1, 1, 1, 1, \
818 Operator::ZeroIfNoThrow(kProperties), parameters); \
819 }
820 JS_BINOP_WITH_FEEDBACK(BINARY_OP)
821 #undef BINARY_OP
822
823 const Operator* JSOperatorBuilder::StoreDataPropertyInLiteral(
824 const FeedbackSource& feedback) {
825 static constexpr int kObject = 1;
826 static constexpr int kName = 1;
827 static constexpr int kValue = 1;
828 static constexpr int kFlags = 1;
829 static constexpr int kFeedbackVector = 1;
830 static constexpr int kArity =
831 kObject + kName + kValue + kFlags + kFeedbackVector;
832 FeedbackParameter parameters(feedback);
833 return zone()->New<Operator1<FeedbackParameter>>( // --
834 IrOpcode::kJSStoreDataPropertyInLiteral,
835 Operator::kNoThrow, // opcode
836 "JSStoreDataPropertyInLiteral", // name
837 kArity, 1, 1, 0, 1, 1, // counts
838 parameters); // parameter
839 }
840
StoreInArrayLiteral(const FeedbackSource & feedback)841 const Operator* JSOperatorBuilder::StoreInArrayLiteral(
842 const FeedbackSource& feedback) {
843 static constexpr int kArray = 1;
844 static constexpr int kIndex = 1;
845 static constexpr int kValue = 1;
846 static constexpr int kFeedbackVector = 1;
847 static constexpr int kArity = kArray + kIndex + kValue + kFeedbackVector;
848 FeedbackParameter parameters(feedback);
849 return zone()->New<Operator1<FeedbackParameter>>( // --
850 IrOpcode::kJSStoreInArrayLiteral,
851 Operator::kNoThrow, // opcode
852 "JSStoreInArrayLiteral", // name
853 kArity, 1, 1, 0, 1, 1, // counts
854 parameters); // parameter
855 }
856
CallForwardVarargs(size_t arity,uint32_t start_index)857 const Operator* JSOperatorBuilder::CallForwardVarargs(size_t arity,
858 uint32_t start_index) {
859 CallForwardVarargsParameters parameters(arity, start_index);
860 return zone()->New<Operator1<CallForwardVarargsParameters>>( // --
861 IrOpcode::kJSCallForwardVarargs, Operator::kNoProperties, // opcode
862 "JSCallForwardVarargs", // name
863 parameters.arity(), 1, 1, 1, 1, 2, // counts
864 parameters); // parameter
865 }
866
Call(size_t arity,CallFrequency const & frequency,FeedbackSource const & feedback,ConvertReceiverMode convert_mode,SpeculationMode speculation_mode,CallFeedbackRelation feedback_relation)867 const Operator* JSOperatorBuilder::Call(
868 size_t arity, CallFrequency const& frequency,
869 FeedbackSource const& feedback, ConvertReceiverMode convert_mode,
870 SpeculationMode speculation_mode, CallFeedbackRelation feedback_relation) {
871 CallParameters parameters(arity, frequency, feedback, convert_mode,
872 speculation_mode, feedback_relation);
873 return zone()->New<Operator1<CallParameters>>( // --
874 IrOpcode::kJSCall, Operator::kNoProperties, // opcode
875 "JSCall", // name
876 parameters.arity(), 1, 1, 1, 1, 2, // inputs/outputs
877 parameters); // parameter
878 }
879
CallWithArrayLike(const CallFrequency & frequency,const FeedbackSource & feedback,SpeculationMode speculation_mode,CallFeedbackRelation feedback_relation)880 const Operator* JSOperatorBuilder::CallWithArrayLike(
881 const CallFrequency& frequency, const FeedbackSource& feedback,
882 SpeculationMode speculation_mode, CallFeedbackRelation feedback_relation) {
883 static constexpr int kTheArrayLikeObject = 1;
884 CallParameters parameters(
885 JSCallWithArrayLikeNode::ArityForArgc(kTheArrayLikeObject), frequency,
886 feedback, ConvertReceiverMode::kAny, speculation_mode, feedback_relation);
887 return zone()->New<Operator1<CallParameters>>( // --
888 IrOpcode::kJSCallWithArrayLike, Operator::kNoProperties, // opcode
889 "JSCallWithArrayLike", // name
890 parameters.arity(), 1, 1, 1, 1, 2, // counts
891 parameters); // parameter
892 }
893
CallWithSpread(uint32_t arity,CallFrequency const & frequency,FeedbackSource const & feedback,SpeculationMode speculation_mode,CallFeedbackRelation feedback_relation)894 const Operator* JSOperatorBuilder::CallWithSpread(
895 uint32_t arity, CallFrequency const& frequency,
896 FeedbackSource const& feedback, SpeculationMode speculation_mode,
897 CallFeedbackRelation feedback_relation) {
898 DCHECK_IMPLIES(speculation_mode == SpeculationMode::kAllowSpeculation,
899 feedback.IsValid());
900 CallParameters parameters(arity, frequency, feedback,
901 ConvertReceiverMode::kAny, speculation_mode,
902 feedback_relation);
903 return zone()->New<Operator1<CallParameters>>( // --
904 IrOpcode::kJSCallWithSpread, Operator::kNoProperties, // opcode
905 "JSCallWithSpread", // name
906 parameters.arity(), 1, 1, 1, 1, 2, // counts
907 parameters); // parameter
908 }
909
CallRuntime(Runtime::FunctionId id)910 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id) {
911 const Runtime::Function* f = Runtime::FunctionForId(id);
912 return CallRuntime(f, f->nargs);
913 }
914
915
CallRuntime(Runtime::FunctionId id,size_t arity)916 const Operator* JSOperatorBuilder::CallRuntime(Runtime::FunctionId id,
917 size_t arity) {
918 const Runtime::Function* f = Runtime::FunctionForId(id);
919 return CallRuntime(f, arity);
920 }
921
922
CallRuntime(const Runtime::Function * f,size_t arity)923 const Operator* JSOperatorBuilder::CallRuntime(const Runtime::Function* f,
924 size_t arity) {
925 CallRuntimeParameters parameters(f->function_id, arity);
926 DCHECK(f->nargs == -1 || f->nargs == static_cast<int>(parameters.arity()));
927 return zone()->New<Operator1<CallRuntimeParameters>>( // --
928 IrOpcode::kJSCallRuntime, Operator::kNoProperties, // opcode
929 "JSCallRuntime", // name
930 parameters.arity(), 1, 1, f->result_size, 1, 2, // inputs/outputs
931 parameters); // parameter
932 }
933
934 #if V8_ENABLE_WEBASSEMBLY
CallWasm(const wasm::WasmModule * wasm_module,const wasm::FunctionSig * wasm_signature,FeedbackSource const & feedback)935 const Operator* JSOperatorBuilder::CallWasm(
936 const wasm::WasmModule* wasm_module,
937 const wasm::FunctionSig* wasm_signature, FeedbackSource const& feedback) {
938 JSWasmCallParameters parameters(wasm_module, wasm_signature, feedback);
939 return zone()->New<Operator1<JSWasmCallParameters>>(
940 IrOpcode::kJSWasmCall, Operator::kNoProperties, // opcode
941 "JSWasmCall", // name
942 parameters.input_count(), 1, 1, 1, 1, 2, // inputs/outputs
943 parameters); // parameter
944 }
945 #endif // V8_ENABLE_WEBASSEMBLY
946
ConstructForwardVarargs(size_t arity,uint32_t start_index)947 const Operator* JSOperatorBuilder::ConstructForwardVarargs(
948 size_t arity, uint32_t start_index) {
949 ConstructForwardVarargsParameters parameters(arity, start_index);
950 return zone()->New<Operator1<ConstructForwardVarargsParameters>>( // --
951 IrOpcode::kJSConstructForwardVarargs, Operator::kNoProperties, // opcode
952 "JSConstructForwardVarargs", // name
953 parameters.arity(), 1, 1, 1, 1, 2, // counts
954 parameters); // parameter
955 }
956
957 // Note: frequency is taken by reference to work around a GCC bug
958 // on AIX (v8:8193).
Construct(uint32_t arity,CallFrequency const & frequency,FeedbackSource const & feedback)959 const Operator* JSOperatorBuilder::Construct(uint32_t arity,
960 CallFrequency const& frequency,
961 FeedbackSource const& feedback) {
962 ConstructParameters parameters(arity, frequency, feedback);
963 return zone()->New<Operator1<ConstructParameters>>( // --
964 IrOpcode::kJSConstruct, Operator::kNoProperties, // opcode
965 "JSConstruct", // name
966 parameters.arity(), 1, 1, 1, 1, 2, // counts
967 parameters); // parameter
968 }
969
ConstructWithArrayLike(CallFrequency const & frequency,FeedbackSource const & feedback)970 const Operator* JSOperatorBuilder::ConstructWithArrayLike(
971 CallFrequency const& frequency, FeedbackSource const& feedback) {
972 static constexpr int kTheArrayLikeObject = 1;
973 ConstructParameters parameters(
974 JSConstructWithArrayLikeNode::ArityForArgc(kTheArrayLikeObject),
975 frequency, feedback);
976 return zone()->New<Operator1<ConstructParameters>>( // --
977 IrOpcode::kJSConstructWithArrayLike, // opcode
978 Operator::kNoProperties, // properties
979 "JSConstructWithArrayLike", // name
980 parameters.arity(), 1, 1, 1, 1, 2, // counts
981 parameters); // parameter
982 }
983
ConstructWithSpread(uint32_t arity,CallFrequency const & frequency,FeedbackSource const & feedback)984 const Operator* JSOperatorBuilder::ConstructWithSpread(
985 uint32_t arity, CallFrequency const& frequency,
986 FeedbackSource const& feedback) {
987 ConstructParameters parameters(arity, frequency, feedback);
988 return zone()->New<Operator1<ConstructParameters>>( // --
989 IrOpcode::kJSConstructWithSpread, Operator::kNoProperties, // opcode
990 "JSConstructWithSpread", // name
991 parameters.arity(), 1, 1, 1, 1, 2, // counts
992 parameters); // parameter
993 }
994
LoadNamed(const NameRef & name,const FeedbackSource & feedback)995 const Operator* JSOperatorBuilder::LoadNamed(const NameRef& name,
996 const FeedbackSource& feedback) {
997 static constexpr int kObject = 1;
998 static constexpr int kFeedbackVector = 1;
999 static constexpr int kArity = kObject + kFeedbackVector;
1000 NamedAccess access(LanguageMode::kSloppy, name, feedback);
1001 return zone()->New<Operator1<NamedAccess>>( // --
1002 IrOpcode::kJSLoadNamed, Operator::kNoProperties, // opcode
1003 "JSLoadNamed", // name
1004 kArity, 1, 1, 1, 1, 2, // counts
1005 access); // parameter
1006 }
1007
LoadNamedFromSuper(const NameRef & name,const FeedbackSource & feedback)1008 const Operator* JSOperatorBuilder::LoadNamedFromSuper(
1009 const NameRef& name, const FeedbackSource& feedback) {
1010 static constexpr int kReceiver = 1;
1011 static constexpr int kHomeObject = 1;
1012 static constexpr int kFeedbackVector = 1;
1013 static constexpr int kArity = kReceiver + kHomeObject + kFeedbackVector;
1014 NamedAccess access(LanguageMode::kSloppy, name, feedback);
1015 return zone()->New<Operator1<NamedAccess>>( // --
1016 IrOpcode::kJSLoadNamedFromSuper, Operator::kNoProperties, // opcode
1017 "JSLoadNamedFromSuper", // name
1018 kArity, 1, 1, 1, 1, 2, // counts
1019 access); // parameter
1020 }
1021
LoadProperty(FeedbackSource const & feedback)1022 const Operator* JSOperatorBuilder::LoadProperty(
1023 FeedbackSource const& feedback) {
1024 PropertyAccess access(LanguageMode::kSloppy, feedback);
1025 return zone()->New<Operator1<PropertyAccess>>( // --
1026 IrOpcode::kJSLoadProperty, Operator::kNoProperties, // opcode
1027 "JSLoadProperty", // name
1028 3, 1, 1, 1, 1, 2, // counts
1029 access); // parameter
1030 }
1031
GetIterator(FeedbackSource const & load_feedback,FeedbackSource const & call_feedback)1032 const Operator* JSOperatorBuilder::GetIterator(
1033 FeedbackSource const& load_feedback, FeedbackSource const& call_feedback) {
1034 GetIteratorParameters access(load_feedback, call_feedback);
1035 return zone()->New<Operator1<GetIteratorParameters>>( // --
1036 IrOpcode::kJSGetIterator, Operator::kNoProperties, // opcode
1037 "JSGetIterator", // name
1038 2, 1, 1, 1, 1, 2, // counts
1039 access); // parameter
1040 }
1041
HasProperty(FeedbackSource const & feedback)1042 const Operator* JSOperatorBuilder::HasProperty(FeedbackSource const& feedback) {
1043 PropertyAccess access(LanguageMode::kSloppy, feedback);
1044 return zone()->New<Operator1<PropertyAccess>>( // --
1045 IrOpcode::kJSHasProperty, Operator::kNoProperties, // opcode
1046 "JSHasProperty", // name
1047 3, 1, 1, 1, 1, 2, // counts
1048 access); // parameter
1049 }
1050
ForInNext(ForInMode mode,const FeedbackSource & feedback)1051 const Operator* JSOperatorBuilder::ForInNext(ForInMode mode,
1052 const FeedbackSource& feedback) {
1053 return zone()->New<Operator1<ForInParameters>>( // --
1054 IrOpcode::kJSForInNext, Operator::kNoProperties, // opcode
1055 "JSForInNext", // name
1056 5, 1, 1, 1, 1, 2, // counts
1057 ForInParameters{feedback, mode}); // parameter
1058 }
1059
ForInPrepare(ForInMode mode,const FeedbackSource & feedback)1060 const Operator* JSOperatorBuilder::ForInPrepare(
1061 ForInMode mode, const FeedbackSource& feedback) {
1062 return zone()->New<Operator1<ForInParameters>>( // --
1063 IrOpcode::kJSForInPrepare, // opcode
1064 Operator::kNoWrite | Operator::kNoThrow, // flags
1065 "JSForInPrepare", // name
1066 2, 1, 1, 3, 1, 1, // counts
1067 ForInParameters{feedback, mode}); // parameter
1068 }
1069
GeneratorStore(int register_count)1070 const Operator* JSOperatorBuilder::GeneratorStore(int register_count) {
1071 return zone()->New<Operator1<int>>( // --
1072 IrOpcode::kJSGeneratorStore, Operator::kNoThrow, // opcode
1073 "JSGeneratorStore", // name
1074 3 + register_count, 1, 1, 0, 1, 0, // counts
1075 register_count); // parameter
1076 }
1077
RegisterCountOf(Operator const * op)1078 int RegisterCountOf(Operator const* op) {
1079 DCHECK_EQ(IrOpcode::kJSCreateAsyncFunctionObject, op->opcode());
1080 return OpParameter<int>(op);
1081 }
1082
GeneratorStoreValueCountOf(const Operator * op)1083 int GeneratorStoreValueCountOf(const Operator* op) {
1084 DCHECK_EQ(IrOpcode::kJSGeneratorStore, op->opcode());
1085 return OpParameter<int>(op);
1086 }
1087
GeneratorRestoreRegister(int index)1088 const Operator* JSOperatorBuilder::GeneratorRestoreRegister(int index) {
1089 return zone()->New<Operator1<int>>( // --
1090 IrOpcode::kJSGeneratorRestoreRegister, Operator::kNoThrow, // opcode
1091 "JSGeneratorRestoreRegister", // name
1092 1, 1, 1, 1, 1, 0, // counts
1093 index); // parameter
1094 }
1095
RestoreRegisterIndexOf(const Operator * op)1096 int RestoreRegisterIndexOf(const Operator* op) {
1097 DCHECK_EQ(IrOpcode::kJSGeneratorRestoreRegister, op->opcode());
1098 return OpParameter<int>(op);
1099 }
1100
StoreNamed(LanguageMode language_mode,const NameRef & name,FeedbackSource const & feedback)1101 const Operator* JSOperatorBuilder::StoreNamed(LanguageMode language_mode,
1102 const NameRef& name,
1103 FeedbackSource const& feedback) {
1104 static constexpr int kObject = 1;
1105 static constexpr int kValue = 1;
1106 static constexpr int kFeedbackVector = 1;
1107 static constexpr int kArity = kObject + kValue + kFeedbackVector;
1108 NamedAccess access(language_mode, name, feedback);
1109 return zone()->New<Operator1<NamedAccess>>( // --
1110 IrOpcode::kJSStoreNamed, Operator::kNoProperties, // opcode
1111 "JSStoreNamed", // name
1112 kArity, 1, 1, 0, 1, 2, // counts
1113 access); // parameter
1114 }
1115
StoreProperty(LanguageMode language_mode,FeedbackSource const & feedback)1116 const Operator* JSOperatorBuilder::StoreProperty(
1117 LanguageMode language_mode, FeedbackSource const& feedback) {
1118 PropertyAccess access(language_mode, feedback);
1119 return zone()->New<Operator1<PropertyAccess>>( // --
1120 IrOpcode::kJSStoreProperty, Operator::kNoProperties, // opcode
1121 "JSStoreProperty", // name
1122 4, 1, 1, 0, 1, 2, // counts
1123 access); // parameter
1124 }
1125
StoreNamedOwn(const NameRef & name,FeedbackSource const & feedback)1126 const Operator* JSOperatorBuilder::StoreNamedOwn(
1127 const NameRef& name, FeedbackSource const& feedback) {
1128 static constexpr int kObject = 1;
1129 static constexpr int kValue = 1;
1130 static constexpr int kFeedbackVector = 1;
1131 static constexpr int kArity = kObject + kValue + kFeedbackVector;
1132 StoreNamedOwnParameters parameters(name, feedback);
1133 return zone()->New<Operator1<StoreNamedOwnParameters>>( // --
1134 IrOpcode::kJSStoreNamedOwn, Operator::kNoProperties, // opcode
1135 "JSStoreNamedOwn", // name
1136 kArity, 1, 1, 0, 1, 2, // counts
1137 parameters); // parameter
1138 }
1139
DeleteProperty()1140 const Operator* JSOperatorBuilder::DeleteProperty() {
1141 return zone()->New<Operator>( // --
1142 IrOpcode::kJSDeleteProperty, Operator::kNoProperties, // opcode
1143 "JSDeleteProperty", // name
1144 3, 1, 1, 1, 1, 2); // counts
1145 }
1146
CreateGeneratorObject()1147 const Operator* JSOperatorBuilder::CreateGeneratorObject() {
1148 return zone()->New<Operator>( // --
1149 IrOpcode::kJSCreateGeneratorObject, Operator::kEliminatable, // opcode
1150 "JSCreateGeneratorObject", // name
1151 2, 1, 1, 1, 1, 0); // counts
1152 }
1153
LoadGlobal(const NameRef & name,const FeedbackSource & feedback,TypeofMode typeof_mode)1154 const Operator* JSOperatorBuilder::LoadGlobal(const NameRef& name,
1155 const FeedbackSource& feedback,
1156 TypeofMode typeof_mode) {
1157 static constexpr int kFeedbackVector = 1;
1158 static constexpr int kArity = kFeedbackVector;
1159 LoadGlobalParameters parameters(name, feedback, typeof_mode);
1160 return zone()->New<Operator1<LoadGlobalParameters>>( // --
1161 IrOpcode::kJSLoadGlobal, Operator::kNoProperties, // opcode
1162 "JSLoadGlobal", // name
1163 kArity, 1, 1, 1, 1, 2, // counts
1164 parameters); // parameter
1165 }
1166
StoreGlobal(LanguageMode language_mode,const NameRef & name,const FeedbackSource & feedback)1167 const Operator* JSOperatorBuilder::StoreGlobal(LanguageMode language_mode,
1168 const NameRef& name,
1169 const FeedbackSource& feedback) {
1170 static constexpr int kValue = 1;
1171 static constexpr int kFeedbackVector = 1;
1172 static constexpr int kArity = kValue + kFeedbackVector;
1173 StoreGlobalParameters parameters(language_mode, feedback, name);
1174 return zone()->New<Operator1<StoreGlobalParameters>>( // --
1175 IrOpcode::kJSStoreGlobal, Operator::kNoProperties, // opcode
1176 "JSStoreGlobal", // name
1177 kArity, 1, 1, 0, 1, 2, // counts
1178 parameters); // parameter
1179 }
1180
HasContextExtension(size_t depth)1181 const Operator* JSOperatorBuilder::HasContextExtension(size_t depth) {
1182 return zone()->New<Operator1<size_t>>( // --
1183 IrOpcode::kJSHasContextExtension, // opcode
1184 Operator::kNoWrite | Operator::kNoThrow, // flags
1185 "JSHasContextExtension", // name
1186 0, 1, 0, 1, 1, 0, // counts
1187 depth); // parameter
1188 }
1189
LoadContext(size_t depth,size_t index,bool immutable)1190 const Operator* JSOperatorBuilder::LoadContext(size_t depth, size_t index,
1191 bool immutable) {
1192 ContextAccess access(depth, index, immutable);
1193 return zone()->New<Operator1<ContextAccess>>( // --
1194 IrOpcode::kJSLoadContext, // opcode
1195 Operator::kNoWrite | Operator::kNoThrow, // flags
1196 "JSLoadContext", // name
1197 0, 1, 0, 1, 1, 0, // counts
1198 access); // parameter
1199 }
1200
1201
StoreContext(size_t depth,size_t index)1202 const Operator* JSOperatorBuilder::StoreContext(size_t depth, size_t index) {
1203 ContextAccess access(depth, index, false);
1204 return zone()->New<Operator1<ContextAccess>>( // --
1205 IrOpcode::kJSStoreContext, // opcode
1206 Operator::kNoRead | Operator::kNoThrow, // flags
1207 "JSStoreContext", // name
1208 1, 1, 1, 0, 1, 0, // counts
1209 access); // parameter
1210 }
1211
LoadModule(int32_t cell_index)1212 const Operator* JSOperatorBuilder::LoadModule(int32_t cell_index) {
1213 return zone()->New<Operator1<int32_t>>( // --
1214 IrOpcode::kJSLoadModule, // opcode
1215 Operator::kNoWrite | Operator::kNoThrow, // flags
1216 "JSLoadModule", // name
1217 1, 1, 1, 1, 1, 0, // counts
1218 cell_index); // parameter
1219 }
1220
GetImportMeta()1221 const Operator* JSOperatorBuilder::GetImportMeta() {
1222 return zone()->New<Operator>( // --
1223 IrOpcode::kJSGetImportMeta, // opcode
1224 Operator::kNoProperties, // flags
1225 "JSGetImportMeta", // name
1226 0, 1, 1, 1, 1, 2); // counts
1227 }
1228
StoreModule(int32_t cell_index)1229 const Operator* JSOperatorBuilder::StoreModule(int32_t cell_index) {
1230 return zone()->New<Operator1<int32_t>>( // --
1231 IrOpcode::kJSStoreModule, // opcode
1232 Operator::kNoRead | Operator::kNoThrow, // flags
1233 "JSStoreModule", // name
1234 2, 1, 1, 0, 1, 0, // counts
1235 cell_index); // parameter
1236 }
1237
CreateArguments(CreateArgumentsType type)1238 const Operator* JSOperatorBuilder::CreateArguments(CreateArgumentsType type) {
1239 return zone()->New<Operator1<CreateArgumentsType>>( // --
1240 IrOpcode::kJSCreateArguments, Operator::kEliminatable, // opcode
1241 "JSCreateArguments", // name
1242 1, 1, 0, 1, 1, 0, // counts
1243 type); // parameter
1244 }
1245
CreateArray(size_t arity,base::Optional<AllocationSiteRef> site)1246 const Operator* JSOperatorBuilder::CreateArray(
1247 size_t arity, base::Optional<AllocationSiteRef> site) {
1248 // constructor, new_target, arg1, ..., argN
1249 int const value_input_count = static_cast<int>(arity) + 2;
1250 CreateArrayParameters parameters(arity, site);
1251 return zone()->New<Operator1<CreateArrayParameters>>( // --
1252 IrOpcode::kJSCreateArray, Operator::kNoProperties, // opcode
1253 "JSCreateArray", // name
1254 value_input_count, 1, 1, 1, 1, 2, // counts
1255 parameters); // parameter
1256 }
1257
CreateArrayIterator(IterationKind kind)1258 const Operator* JSOperatorBuilder::CreateArrayIterator(IterationKind kind) {
1259 CreateArrayIteratorParameters parameters(kind);
1260 return zone()->New<Operator1<CreateArrayIteratorParameters>>( // --
1261 IrOpcode::kJSCreateArrayIterator, Operator::kEliminatable, // opcode
1262 "JSCreateArrayIterator", // name
1263 1, 1, 1, 1, 1, 0, // counts
1264 parameters); // parameter
1265 }
1266
CreateAsyncFunctionObject(int register_count)1267 const Operator* JSOperatorBuilder::CreateAsyncFunctionObject(
1268 int register_count) {
1269 return zone()->New<Operator1<int>>( // --
1270 IrOpcode::kJSCreateAsyncFunctionObject, // opcode
1271 Operator::kEliminatable, // flags
1272 "JSCreateAsyncFunctionObject", // name
1273 3, 1, 1, 1, 1, 0, // counts
1274 register_count); // parameter
1275 }
1276
CreateCollectionIterator(CollectionKind collection_kind,IterationKind iteration_kind)1277 const Operator* JSOperatorBuilder::CreateCollectionIterator(
1278 CollectionKind collection_kind, IterationKind iteration_kind) {
1279 CreateCollectionIteratorParameters parameters(collection_kind,
1280 iteration_kind);
1281 return zone()->New<Operator1<CreateCollectionIteratorParameters>>(
1282 IrOpcode::kJSCreateCollectionIterator, Operator::kEliminatable,
1283 "JSCreateCollectionIterator", 1, 1, 1, 1, 1, 0, parameters);
1284 }
1285
CreateBoundFunction(size_t arity,const MapRef & map)1286 const Operator* JSOperatorBuilder::CreateBoundFunction(size_t arity,
1287 const MapRef& map) {
1288 // bound_target_function, bound_this, arg1, ..., argN
1289 int const value_input_count = static_cast<int>(arity) + 2;
1290 CreateBoundFunctionParameters parameters(arity, map);
1291 return zone()->New<Operator1<CreateBoundFunctionParameters>>( // --
1292 IrOpcode::kJSCreateBoundFunction, Operator::kEliminatable, // opcode
1293 "JSCreateBoundFunction", // name
1294 value_input_count, 1, 1, 1, 1, 0, // counts
1295 parameters); // parameter
1296 }
1297
CreateClosure(const SharedFunctionInfoRef & shared_info,const CodeTRef & code,AllocationType allocation)1298 const Operator* JSOperatorBuilder::CreateClosure(
1299 const SharedFunctionInfoRef& shared_info, const CodeTRef& code,
1300 AllocationType allocation) {
1301 static constexpr int kFeedbackCell = 1;
1302 static constexpr int kArity = kFeedbackCell;
1303 CreateClosureParameters parameters(shared_info, code, allocation);
1304 return zone()->New<Operator1<CreateClosureParameters>>( // --
1305 IrOpcode::kJSCreateClosure, Operator::kEliminatable, // opcode
1306 "JSCreateClosure", // name
1307 kArity, 1, 1, 1, 1, 0, // counts
1308 parameters); // parameter
1309 }
1310
CreateLiteralArray(const ArrayBoilerplateDescriptionRef & description,FeedbackSource const & feedback,int literal_flags,int number_of_elements)1311 const Operator* JSOperatorBuilder::CreateLiteralArray(
1312 const ArrayBoilerplateDescriptionRef& description,
1313 FeedbackSource const& feedback, int literal_flags, int number_of_elements) {
1314 CreateLiteralParameters parameters(description, feedback, number_of_elements,
1315 literal_flags);
1316 return zone()->New<Operator1<CreateLiteralParameters>>( // --
1317 IrOpcode::kJSCreateLiteralArray, // opcode
1318 Operator::kNoProperties, // properties
1319 "JSCreateLiteralArray", // name
1320 1, 1, 1, 1, 1, 2, // counts
1321 parameters); // parameter
1322 }
1323
CreateEmptyLiteralArray(FeedbackSource const & feedback)1324 const Operator* JSOperatorBuilder::CreateEmptyLiteralArray(
1325 FeedbackSource const& feedback) {
1326 static constexpr int kFeedbackVector = 1;
1327 static constexpr int kArity = kFeedbackVector;
1328 FeedbackParameter parameters(feedback);
1329 return zone()->New<Operator1<FeedbackParameter>>( // --
1330 IrOpcode::kJSCreateEmptyLiteralArray, // opcode
1331 Operator::kEliminatable, // properties
1332 "JSCreateEmptyLiteralArray", // name
1333 kArity, 1, 1, 1, 1, 0, // counts
1334 parameters); // parameter
1335 }
1336
CreateArrayFromIterable()1337 const Operator* JSOperatorBuilder::CreateArrayFromIterable() {
1338 return zone()->New<Operator>( // --
1339 IrOpcode::kJSCreateArrayFromIterable, // opcode
1340 Operator::kNoProperties, // properties
1341 "JSCreateArrayFromIterable", // name
1342 1, 1, 1, 1, 1, 2); // counts
1343 }
1344
CreateLiteralObject(const ObjectBoilerplateDescriptionRef & constant_properties,FeedbackSource const & feedback,int literal_flags,int number_of_properties)1345 const Operator* JSOperatorBuilder::CreateLiteralObject(
1346 const ObjectBoilerplateDescriptionRef& constant_properties,
1347 FeedbackSource const& feedback, int literal_flags,
1348 int number_of_properties) {
1349 CreateLiteralParameters parameters(constant_properties, feedback,
1350 number_of_properties, literal_flags);
1351 return zone()->New<Operator1<CreateLiteralParameters>>( // --
1352 IrOpcode::kJSCreateLiteralObject, // opcode
1353 Operator::kNoProperties, // properties
1354 "JSCreateLiteralObject", // name
1355 1, 1, 1, 1, 1, 2, // counts
1356 parameters); // parameter
1357 }
1358
GetTemplateObject(const TemplateObjectDescriptionRef & description,const SharedFunctionInfoRef & shared,FeedbackSource const & feedback)1359 const Operator* JSOperatorBuilder::GetTemplateObject(
1360 const TemplateObjectDescriptionRef& description,
1361 const SharedFunctionInfoRef& shared, FeedbackSource const& feedback) {
1362 GetTemplateObjectParameters parameters(description, shared, feedback);
1363 return zone()->New<Operator1<GetTemplateObjectParameters>>( // --
1364 IrOpcode::kJSGetTemplateObject, // opcode
1365 Operator::kEliminatable, // properties
1366 "JSGetTemplateObject", // name
1367 1, 1, 1, 1, 1, 0, // counts
1368 parameters); // parameter
1369 }
1370
CloneObject(FeedbackSource const & feedback,int literal_flags)1371 const Operator* JSOperatorBuilder::CloneObject(FeedbackSource const& feedback,
1372 int literal_flags) {
1373 CloneObjectParameters parameters(feedback, literal_flags);
1374 return zone()->New<Operator1<CloneObjectParameters>>( // --
1375 IrOpcode::kJSCloneObject, // opcode
1376 Operator::kNoProperties, // properties
1377 "JSCloneObject", // name
1378 2, 1, 1, 1, 1, 2, // counts
1379 parameters); // parameter
1380 }
1381
StackCheck(StackCheckKind kind)1382 const Operator* JSOperatorBuilder::StackCheck(StackCheckKind kind) {
1383 return zone()->New<Operator1<StackCheckKind>>( // --
1384 IrOpcode::kJSStackCheck, // opcode
1385 Operator::kNoWrite, // properties
1386 "JSStackCheck", // name
1387 0, 1, 1, 0, 1, 2, // counts
1388 kind); // parameter
1389 }
1390
CreateEmptyLiteralObject()1391 const Operator* JSOperatorBuilder::CreateEmptyLiteralObject() {
1392 return zone()->New<Operator>( // --
1393 IrOpcode::kJSCreateEmptyLiteralObject, // opcode
1394 Operator::kNoProperties, // properties
1395 "JSCreateEmptyLiteralObject", // name
1396 0, 1, 1, 1, 1, 2); // counts
1397 }
1398
CreateLiteralRegExp(const StringRef & constant_pattern,FeedbackSource const & feedback,int literal_flags)1399 const Operator* JSOperatorBuilder::CreateLiteralRegExp(
1400 const StringRef& constant_pattern, FeedbackSource const& feedback,
1401 int literal_flags) {
1402 CreateLiteralParameters parameters(constant_pattern, feedback, -1,
1403 literal_flags);
1404 return zone()->New<Operator1<CreateLiteralParameters>>( // --
1405 IrOpcode::kJSCreateLiteralRegExp, // opcode
1406 Operator::kNoProperties, // properties
1407 "JSCreateLiteralRegExp", // name
1408 1, 1, 1, 1, 1, 2, // counts
1409 parameters); // parameter
1410 }
1411
CreateFunctionContext(const ScopeInfoRef & scope_info,int slot_count,ScopeType scope_type)1412 const Operator* JSOperatorBuilder::CreateFunctionContext(
1413 const ScopeInfoRef& scope_info, int slot_count, ScopeType scope_type) {
1414 CreateFunctionContextParameters parameters(scope_info, slot_count,
1415 scope_type);
1416 return zone()->New<Operator1<CreateFunctionContextParameters>>( // --
1417 IrOpcode::kJSCreateFunctionContext, Operator::kNoProperties, // opcode
1418 "JSCreateFunctionContext", // name
1419 0, 1, 1, 1, 1, 2, // counts
1420 parameters); // parameter
1421 }
1422
CreateCatchContext(const ScopeInfoRef & scope_info)1423 const Operator* JSOperatorBuilder::CreateCatchContext(
1424 const ScopeInfoRef& scope_info) {
1425 return zone()->New<Operator1<ScopeInfoTinyRef>>(
1426 IrOpcode::kJSCreateCatchContext, Operator::kNoProperties, // opcode
1427 "JSCreateCatchContext", // name
1428 1, 1, 1, 1, 1, 2, // counts
1429 ScopeInfoTinyRef{scope_info}); // parameter
1430 }
1431
CreateWithContext(const ScopeInfoRef & scope_info)1432 const Operator* JSOperatorBuilder::CreateWithContext(
1433 const ScopeInfoRef& scope_info) {
1434 return zone()->New<Operator1<ScopeInfoTinyRef>>(
1435 IrOpcode::kJSCreateWithContext, Operator::kNoProperties, // opcode
1436 "JSCreateWithContext", // name
1437 1, 1, 1, 1, 1, 2, // counts
1438 ScopeInfoTinyRef{scope_info}); // parameter
1439 }
1440
CreateBlockContext(const ScopeInfoRef & scope_info)1441 const Operator* JSOperatorBuilder::CreateBlockContext(
1442 const ScopeInfoRef& scope_info) {
1443 return zone()->New<Operator1<ScopeInfoTinyRef>>( // --
1444 IrOpcode::kJSCreateBlockContext, Operator::kNoProperties, // opcode
1445 "JSCreateBlockContext", // name
1446 0, 1, 1, 1, 1, 2, // counts
1447 ScopeInfoTinyRef{scope_info}); // parameter
1448 }
1449
ScopeInfoOf(JSHeapBroker * broker,const Operator * op)1450 ScopeInfoRef ScopeInfoOf(JSHeapBroker* broker, const Operator* op) {
1451 DCHECK(IrOpcode::kJSCreateBlockContext == op->opcode() ||
1452 IrOpcode::kJSCreateWithContext == op->opcode() ||
1453 IrOpcode::kJSCreateCatchContext == op->opcode());
1454 return OpParameter<ScopeInfoTinyRef>(op).AsRef(broker);
1455 }
1456
operator ==(ScopeInfoTinyRef const & lhs,ScopeInfoTinyRef const & rhs)1457 bool operator==(ScopeInfoTinyRef const& lhs, ScopeInfoTinyRef const& rhs) {
1458 return lhs.object().location() == rhs.object().location();
1459 }
1460
operator !=(ScopeInfoTinyRef const & lhs,ScopeInfoTinyRef const & rhs)1461 bool operator!=(ScopeInfoTinyRef const& lhs, ScopeInfoTinyRef const& rhs) {
1462 return !(lhs == rhs);
1463 }
1464
hash_value(ScopeInfoTinyRef const & ref)1465 size_t hash_value(ScopeInfoTinyRef const& ref) {
1466 return reinterpret_cast<size_t>(ref.object().location());
1467 }
1468
operator <<(std::ostream & os,ScopeInfoTinyRef const & ref)1469 std::ostream& operator<<(std::ostream& os, ScopeInfoTinyRef const& ref) {
1470 return os << Brief(*ref.object());
1471 }
1472
1473 #undef CACHED_OP_LIST
1474
1475 } // namespace compiler
1476 } // namespace internal
1477 } // namespace v8
1478