simplified-operator.cc 82.4 KB
Newer Older
1 2 3 4 5
// Copyright 2012 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "src/compiler/simplified-operator.h"
6

7
#include "include/v8-fast-api-calls.h"
8
#include "src/base/lazy-instance.h"
9
#include "src/compiler/linkage.h"
10 11
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
12
#include "src/compiler/types.h"
13
#include "src/handles/handles-inl.h"
14
#include "src/objects/feedback-cell.h"
15
#include "src/objects/map.h"
16
#include "src/objects/name.h"
17
#include "src/objects/objects-inl.h"
18 19 20 21 22

namespace v8 {
namespace internal {
namespace compiler {

23 24 25 26
size_t hash_value(BaseTaggedness base_taggedness) {
  return static_cast<uint8_t>(base_taggedness);
}

27
std::ostream& operator<<(std::ostream& os, BaseTaggedness base_taggedness) {
28 29 30 31 32 33 34 35 36
  switch (base_taggedness) {
    case kUntaggedBase:
      return os << "untagged base";
    case kTaggedBase:
      return os << "tagged base";
  }
  UNREACHABLE();
}

37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
std::ostream& operator<<(std::ostream& os,
                         ConstFieldInfo const& const_field_info) {
  if (const_field_info.IsConst()) {
    return os << "const (field owner: " << const_field_info.owner_map.address()
              << ")";
  } else {
    return os << "mutable";
  }
  UNREACHABLE();
}

bool operator==(ConstFieldInfo const& lhs, ConstFieldInfo const& rhs) {
  return lhs.owner_map.address() == rhs.owner_map.address();
}

size_t hash_value(ConstFieldInfo const& const_field_info) {
53
  return static_cast<size_t>(const_field_info.owner_map.address());
54 55
}

56
bool operator==(FieldAccess const& lhs, FieldAccess const& rhs) {
57 58 59
  // On purpose we don't include the write barrier kind here, as this method is
  // really only relevant for eliminating loads and they don't care about the
  // write barrier mode.
60
  return lhs.base_is_tagged == rhs.base_is_tagged && lhs.offset == rhs.offset &&
61
         lhs.map.address() == rhs.map.address() &&
62
         lhs.machine_type == rhs.machine_type &&
63 64
         lhs.const_field_info == rhs.const_field_info &&
         lhs.is_store_in_literal == rhs.is_store_in_literal;
65 66
}

67
size_t hash_value(FieldAccess const& access) {
68 69 70
  // On purpose we don't include the write barrier kind here, as this method is
  // really only relevant for eliminating loads and they don't care about the
  // write barrier mode.
71
  return base::hash_combine(access.base_is_tagged, access.offset,
72 73
                            access.machine_type, access.const_field_info,
                            access.is_store_in_literal);
74 75
}

76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
size_t hash_value(LoadSensitivity load_sensitivity) {
  return static_cast<size_t>(load_sensitivity);
}

std::ostream& operator<<(std::ostream& os, LoadSensitivity load_sensitivity) {
  switch (load_sensitivity) {
    case LoadSensitivity::kCritical:
      return os << "Critical";
    case LoadSensitivity::kSafe:
      return os << "Safe";
    case LoadSensitivity::kUnsafe:
      return os << "Unsafe";
  }
  UNREACHABLE();
}
91

92 93 94 95 96
std::ostream& operator<<(std::ostream& os, FieldAccess const& access) {
  os << "[" << access.base_is_tagged << ", " << access.offset << ", ";
#ifdef OBJECT_PRINT
  Handle<Name> name;
  if (access.name.ToHandle(&name)) {
97
    name->NamePrint(os);
98 99
    os << ", ";
  }
100 101 102 103
  Handle<Map> map;
  if (access.map.ToHandle(&map)) {
    os << Brief(*map) << ", ";
  }
104
#endif
105
  os << access.type << ", " << access.machine_type << ", "
106
     << access.write_barrier_kind << ", " << access.const_field_info;
107 108 109
  if (access.is_store_in_literal) {
    os << " (store in literal)";
  }
110
  if (FLAG_untrusted_code_mitigations) {
111 112 113
    os << ", " << access.load_sensitivity;
  }
  os << "]";
114 115 116
  return os;
}

117 118 119 120 121 122 123 124 125
template <>
void Operator1<FieldAccess>::PrintParameter(std::ostream& os,
                                            PrintVerbosity verbose) const {
  if (verbose == PrintVerbosity::kVerbose) {
    os << parameter();
  } else {
    os << "[+" << parameter().offset << "]";
  }
}
126

127
bool operator==(ElementAccess const& lhs, ElementAccess const& rhs) {
128 129 130
  // On purpose we don't include the write barrier kind here, as this method is
  // really only relevant for eliminating loads and they don't care about the
  // write barrier mode.
131
  return lhs.base_is_tagged == rhs.base_is_tagged &&
132
         lhs.header_size == rhs.header_size &&
133 134 135
         lhs.machine_type == rhs.machine_type;
}

136
size_t hash_value(ElementAccess const& access) {
137 138 139
  // On purpose we don't include the write barrier kind here, as this method is
  // really only relevant for eliminating loads and they don't care about the
  // write barrier mode.
140 141 142 143
  return base::hash_combine(access.base_is_tagged, access.header_size,
                            access.machine_type);
}

144
std::ostream& operator<<(std::ostream& os, ElementAccess const& access) {
145 146 147
  os << access.base_is_tagged << ", " << access.header_size << ", "
     << access.type << ", " << access.machine_type << ", "
     << access.write_barrier_kind;
148
  if (FLAG_untrusted_code_mitigations) {
149 150
    os << ", " << access.load_sensitivity;
  }
151 152 153
  return os;
}

154 155 156 157 158 159 160 161 162 163 164 165 166 167
bool operator==(ObjectAccess const& lhs, ObjectAccess const& rhs) {
  return lhs.machine_type == rhs.machine_type &&
         lhs.write_barrier_kind == rhs.write_barrier_kind;
}

size_t hash_value(ObjectAccess const& access) {
  return base::hash_combine(access.machine_type, access.write_barrier_kind);
}

std::ostream& operator<<(std::ostream& os, ObjectAccess const& access) {
  os << access.machine_type << ", " << access.write_barrier_kind;
  return os;
}

168 169 170 171 172 173 174 175 176 177 178 179
const FieldAccess& FieldAccessOf(const Operator* op) {
  DCHECK_NOT_NULL(op);
  DCHECK(op->opcode() == IrOpcode::kLoadField ||
         op->opcode() == IrOpcode::kStoreField);
  return OpParameter<FieldAccess>(op);
}

const ElementAccess& ElementAccessOf(const Operator* op) {
  DCHECK_NOT_NULL(op);
  DCHECK(op->opcode() == IrOpcode::kLoadElement ||
         op->opcode() == IrOpcode::kStoreElement);
  return OpParameter<ElementAccess>(op);
180 181
}

182 183 184 185 186 187 188
const ObjectAccess& ObjectAccessOf(const Operator* op) {
  DCHECK_NOT_NULL(op);
  DCHECK(op->opcode() == IrOpcode::kLoadFromObject ||
         op->opcode() == IrOpcode::kStoreToObject);
  return OpParameter<ObjectAccess>(op);
}

189 190
ExternalArrayType ExternalArrayTypeOf(const Operator* op) {
  DCHECK(op->opcode() == IrOpcode::kLoadTypedElement ||
191
         op->opcode() == IrOpcode::kLoadDataViewElement ||
192 193
         op->opcode() == IrOpcode::kStoreTypedElement ||
         op->opcode() == IrOpcode::kStoreDataViewElement);
194 195 196
  return OpParameter<ExternalArrayType>(op);
}

197 198 199 200 201
ConvertReceiverMode ConvertReceiverModeOf(Operator const* op) {
  DCHECK_EQ(IrOpcode::kConvertReceiver, op->opcode());
  return OpParameter<ConvertReceiverMode>(op);
}

202 203 204 205 206 207 208 209 210 211 212 213 214 215
size_t hash_value(CheckFloat64HoleMode mode) {
  return static_cast<size_t>(mode);
}

std::ostream& operator<<(std::ostream& os, CheckFloat64HoleMode mode) {
  switch (mode) {
    case CheckFloat64HoleMode::kAllowReturnHole:
      return os << "allow-return-hole";
    case CheckFloat64HoleMode::kNeverReturnHole:
      return os << "never-return-hole";
  }
  UNREACHABLE();
}

216 217
CheckFloat64HoleParameters const& CheckFloat64HoleParametersOf(
    Operator const* op) {
218
  DCHECK_EQ(IrOpcode::kCheckFloat64Hole, op->opcode());
219 220 221 222 223
  return OpParameter<CheckFloat64HoleParameters>(op);
}

std::ostream& operator<<(std::ostream& os,
                         CheckFloat64HoleParameters const& params) {
224
  return os << params.mode() << ", " << params.feedback();
225 226 227
}

size_t hash_value(const CheckFloat64HoleParameters& params) {
228 229
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(params.mode(), feedback_hash(params.feedback()));
230 231 232 233 234 235 236 237 238 239
}

bool operator==(CheckFloat64HoleParameters const& lhs,
                CheckFloat64HoleParameters const& rhs) {
  return lhs.mode() == rhs.mode() && lhs.feedback() == rhs.feedback();
}

bool operator!=(CheckFloat64HoleParameters const& lhs,
                CheckFloat64HoleParameters const& rhs) {
  return !(lhs == rhs);
240 241
}

242
CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator* op) {
243
  DCHECK(op->opcode() == IrOpcode::kChangeFloat64ToTagged ||
244
         op->opcode() == IrOpcode::kCheckedInt32Mul);
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261
  return OpParameter<CheckForMinusZeroMode>(op);
}

size_t hash_value(CheckForMinusZeroMode mode) {
  return static_cast<size_t>(mode);
}

std::ostream& operator<<(std::ostream& os, CheckForMinusZeroMode mode) {
  switch (mode) {
    case CheckForMinusZeroMode::kCheckForMinusZero:
      return os << "check-for-minus-zero";
    case CheckForMinusZeroMode::kDontCheckForMinusZero:
      return os << "dont-check-for-minus-zero";
  }
  UNREACHABLE();
}

262 263
std::ostream& operator<<(std::ostream& os, CheckMapsFlags flags) {
  if (flags & CheckMapsFlag::kTryMigrateInstance) {
264 265 266
    return os << "TryMigrateInstance";
  } else {
    return os << "None";
267 268 269
  }
}

270 271
bool operator==(CheckMapsParameters const& lhs,
                CheckMapsParameters const& rhs) {
272 273
  return lhs.flags() == rhs.flags() && lhs.maps() == rhs.maps() &&
         lhs.feedback() == rhs.feedback();
274 275
}

276
size_t hash_value(CheckMapsParameters const& p) {
277 278
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(p.flags(), p.maps(), feedback_hash(p.feedback()));
279
}
280 281

std::ostream& operator<<(std::ostream& os, CheckMapsParameters const& p) {
282
  return os << p.flags() << ", " << p.maps() << ", " << p.feedback();
283 284 285 286 287 288 289
}

CheckMapsParameters const& CheckMapsParametersOf(Operator const* op) {
  DCHECK_EQ(IrOpcode::kCheckMaps, op->opcode());
  return OpParameter<CheckMapsParameters>(op);
}

290 291
bool operator==(DynamicCheckMapsParameters const& lhs,
                DynamicCheckMapsParameters const& rhs) {
292 293 294 295 296
  // FeedbackSource is sufficient as an equality check. FeedbackSource uniquely
  // determines all other properties (handler, flags and the monomorphic map
  DCHECK_IMPLIES(lhs.feedback() == rhs.feedback(),
                 lhs.flags() == rhs.flags() && lhs.state() == rhs.state() &&
                     lhs.handler().address() == rhs.handler().address() &&
297
                     lhs.maps() == rhs.maps());
298
  return lhs.feedback() == rhs.feedback();
299 300 301 302
}

size_t hash_value(DynamicCheckMapsParameters const& p) {
  FeedbackSource::Hash feedback_hash;
303 304 305
  // FeedbackSource is sufficient for hashing. FeedbackSource uniquely
  // determines all other properties (handler, flags and the monomorphic map
  return base::hash_combine(feedback_hash(p.feedback()));
306 307 308 309
}

std::ostream& operator<<(std::ostream& os,
                         DynamicCheckMapsParameters const& p) {
310
  return os << p.handler() << ", " << p.feedback() << "," << p.state() << ","
311
            << p.flags() << "," << p.maps();
312 313 314 315 316 317 318 319
}

DynamicCheckMapsParameters const& DynamicCheckMapsParametersOf(
    Operator const* op) {
  DCHECK_EQ(IrOpcode::kDynamicCheckMaps, op->opcode());
  return OpParameter<DynamicCheckMapsParameters>(op);
}

320
ZoneHandleSet<Map> const& CompareMapsParametersOf(Operator const* op) {
321
  DCHECK_EQ(IrOpcode::kCompareMaps, op->opcode());
322
  return OpParameter<ZoneHandleSet<Map>>(op);
323 324
}

325
ZoneHandleSet<Map> const& MapGuardMapsOf(Operator const* op) {
326
  DCHECK_EQ(IrOpcode::kMapGuard, op->opcode());
327
  return OpParameter<ZoneHandleSet<Map>>(op);
328 329
}

330 331 332 333 334 335 336 337
size_t hash_value(CheckTaggedInputMode mode) {
  return static_cast<size_t>(mode);
}

std::ostream& operator<<(std::ostream& os, CheckTaggedInputMode mode) {
  switch (mode) {
    case CheckTaggedInputMode::kNumber:
      return os << "Number";
338 339
    case CheckTaggedInputMode::kNumberOrBoolean:
      return os << "NumberOrBoolean";
340 341 342 343 344 345
    case CheckTaggedInputMode::kNumberOrOddball:
      return os << "NumberOrOddball";
  }
  UNREACHABLE();
}

346 347 348 349 350 351
std::ostream& operator<<(std::ostream& os, GrowFastElementsMode mode) {
  switch (mode) {
    case GrowFastElementsMode::kDoubleElements:
      return os << "DoubleElements";
    case GrowFastElementsMode::kSmiOrObjectElements:
      return os << "SmiOrObjectElements";
352
  }
353
  UNREACHABLE();
354 355
}

356 357 358 359 360 361
bool operator==(const GrowFastElementsParameters& lhs,
                const GrowFastElementsParameters& rhs) {
  return lhs.mode() == rhs.mode() && lhs.feedback() == rhs.feedback();
}

inline size_t hash_value(const GrowFastElementsParameters& params) {
362 363
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(params.mode(), feedback_hash(params.feedback()));
364 365 366 367
}

std::ostream& operator<<(std::ostream& os,
                         const GrowFastElementsParameters& params) {
368
  return os << params.mode() << ", " << params.feedback();
369 370 371 372
}

const GrowFastElementsParameters& GrowFastElementsParametersOf(
    const Operator* op) {
373
  DCHECK_EQ(IrOpcode::kMaybeGrowFastElements, op->opcode());
374
  return OpParameter<GrowFastElementsParameters>(op);
375 376
}

377 378 379 380 381 382
bool operator==(ElementsTransition const& lhs, ElementsTransition const& rhs) {
  return lhs.mode() == rhs.mode() &&
         lhs.source().address() == rhs.source().address() &&
         lhs.target().address() == rhs.target().address();
}

383
size_t hash_value(ElementsTransition transition) {
384 385 386
  return base::hash_combine(static_cast<uint8_t>(transition.mode()),
                            transition.source().address(),
                            transition.target().address());
387 388 389
}

std::ostream& operator<<(std::ostream& os, ElementsTransition transition) {
390
  switch (transition.mode()) {
391
    case ElementsTransition::kFastTransition:
392 393
      return os << "fast-transition from " << Brief(*transition.source())
                << " to " << Brief(*transition.target());
394
    case ElementsTransition::kSlowTransition:
395 396
      return os << "slow-transition from " << Brief(*transition.source())
                << " to " << Brief(*transition.target());
397 398 399 400
  }
  UNREACHABLE();
}

401
ElementsTransition const& ElementsTransitionOf(const Operator* op) {
402 403 404 405
  DCHECK_EQ(IrOpcode::kTransitionElementsKind, op->opcode());
  return OpParameter<ElementsTransition>(op);
}

406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444
namespace {

// Parameters for the TransitionAndStoreElement opcode.
class TransitionAndStoreElementParameters final {
 public:
  TransitionAndStoreElementParameters(Handle<Map> double_map,
                                      Handle<Map> fast_map);

  Handle<Map> double_map() const { return double_map_; }
  Handle<Map> fast_map() const { return fast_map_; }

 private:
  Handle<Map> const double_map_;
  Handle<Map> const fast_map_;
};

TransitionAndStoreElementParameters::TransitionAndStoreElementParameters(
    Handle<Map> double_map, Handle<Map> fast_map)
    : double_map_(double_map), fast_map_(fast_map) {}

bool operator==(TransitionAndStoreElementParameters const& lhs,
                TransitionAndStoreElementParameters const& rhs) {
  return lhs.fast_map().address() == rhs.fast_map().address() &&
         lhs.double_map().address() == rhs.double_map().address();
}

size_t hash_value(TransitionAndStoreElementParameters parameters) {
  return base::hash_combine(parameters.fast_map().address(),
                            parameters.double_map().address());
}

std::ostream& operator<<(std::ostream& os,
                         TransitionAndStoreElementParameters parameters) {
  return os << "fast-map" << Brief(*parameters.fast_map()) << " double-map"
            << Brief(*parameters.double_map());
}

}  // namespace

445 446 447 448 449 450
namespace {

// Parameters for the TransitionAndStoreNonNumberElement opcode.
class TransitionAndStoreNonNumberElementParameters final {
 public:
  TransitionAndStoreNonNumberElementParameters(Handle<Map> fast_map,
451
                                               Type value_type);
452 453

  Handle<Map> fast_map() const { return fast_map_; }
454
  Type value_type() const { return value_type_; }
455 456 457

 private:
  Handle<Map> const fast_map_;
458
  Type value_type_;
459 460 461 462
};

TransitionAndStoreNonNumberElementParameters::
    TransitionAndStoreNonNumberElementParameters(Handle<Map> fast_map,
463
                                                 Type value_type)
464 465 466 467 468 469 470 471 472 473 474 475 476 477 478
    : fast_map_(fast_map), value_type_(value_type) {}

bool operator==(TransitionAndStoreNonNumberElementParameters const& lhs,
                TransitionAndStoreNonNumberElementParameters const& rhs) {
  return lhs.fast_map().address() == rhs.fast_map().address() &&
         lhs.value_type() == rhs.value_type();
}

size_t hash_value(TransitionAndStoreNonNumberElementParameters parameters) {
  return base::hash_combine(parameters.fast_map().address(),
                            parameters.value_type());
}

std::ostream& operator<<(
    std::ostream& os, TransitionAndStoreNonNumberElementParameters parameters) {
479 480
  return os << parameters.value_type() << ", fast-map"
            << Brief(*parameters.fast_map());
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517
}

}  // namespace

namespace {

// Parameters for the TransitionAndStoreNumberElement opcode.
class TransitionAndStoreNumberElementParameters final {
 public:
  explicit TransitionAndStoreNumberElementParameters(Handle<Map> double_map);

  Handle<Map> double_map() const { return double_map_; }

 private:
  Handle<Map> const double_map_;
};

TransitionAndStoreNumberElementParameters::
    TransitionAndStoreNumberElementParameters(Handle<Map> double_map)
    : double_map_(double_map) {}

bool operator==(TransitionAndStoreNumberElementParameters const& lhs,
                TransitionAndStoreNumberElementParameters const& rhs) {
  return lhs.double_map().address() == rhs.double_map().address();
}

size_t hash_value(TransitionAndStoreNumberElementParameters parameters) {
  return base::hash_combine(parameters.double_map().address());
}

std::ostream& operator<<(std::ostream& os,
                         TransitionAndStoreNumberElementParameters parameters) {
  return os << "double-map" << Brief(*parameters.double_map());
}

}  // namespace

518
Handle<Map> DoubleMapParameterOf(const Operator* op) {
519 520 521 522 523 524 525 526 527 528
  if (op->opcode() == IrOpcode::kTransitionAndStoreElement) {
    return OpParameter<TransitionAndStoreElementParameters>(op).double_map();
  } else if (op->opcode() == IrOpcode::kTransitionAndStoreNumberElement) {
    return OpParameter<TransitionAndStoreNumberElementParameters>(op)
        .double_map();
  }
  UNREACHABLE();
  return Handle<Map>::null();
}

529
Type ValueTypeParameterOf(const Operator* op) {
530 531 532
  DCHECK_EQ(IrOpcode::kTransitionAndStoreNonNumberElement, op->opcode());
  return OpParameter<TransitionAndStoreNonNumberElementParameters>(op)
      .value_type();
533 534 535
}

Handle<Map> FastMapParameterOf(const Operator* op) {
536 537 538 539 540 541 542 543
  if (op->opcode() == IrOpcode::kTransitionAndStoreElement) {
    return OpParameter<TransitionAndStoreElementParameters>(op).fast_map();
  } else if (op->opcode() == IrOpcode::kTransitionAndStoreNonNumberElement) {
    return OpParameter<TransitionAndStoreNonNumberElementParameters>(op)
        .fast_map();
  }
  UNREACHABLE();
  return Handle<Map>::null();
544 545
}

546 547 548 549 550 551 552 553 554 555 556 557
std::ostream& operator<<(std::ostream& os, BigIntOperationHint hint) {
  switch (hint) {
    case BigIntOperationHint::kBigInt:
      return os << "BigInt";
  }
  UNREACHABLE();
}

size_t hash_value(BigIntOperationHint hint) {
  return static_cast<uint8_t>(hint);
}

558 559
std::ostream& operator<<(std::ostream& os, NumberOperationHint hint) {
  switch (hint) {
560 561 562 563
    case NumberOperationHint::kSignedSmall:
      return os << "SignedSmall";
    case NumberOperationHint::kSignedSmallInputs:
      return os << "SignedSmallInputs";
564 565
    case NumberOperationHint::kNumber:
      return os << "Number";
566 567
    case NumberOperationHint::kNumberOrBoolean:
      return os << "NumberOrBoolean";
568 569 570 571 572 573 574 575 576 577 578
    case NumberOperationHint::kNumberOrOddball:
      return os << "NumberOrOddball";
  }
  UNREACHABLE();
}

size_t hash_value(NumberOperationHint hint) {
  return static_cast<uint8_t>(hint);
}

NumberOperationHint NumberOperationHintOf(const Operator* op) {
579
  DCHECK(op->opcode() == IrOpcode::kSpeculativeNumberAdd ||
580 581 582
         op->opcode() == IrOpcode::kSpeculativeNumberSubtract ||
         op->opcode() == IrOpcode::kSpeculativeNumberMultiply ||
         op->opcode() == IrOpcode::kSpeculativeNumberDivide ||
583
         op->opcode() == IrOpcode::kSpeculativeNumberModulus ||
584 585
         op->opcode() == IrOpcode::kSpeculativeNumberShiftLeft ||
         op->opcode() == IrOpcode::kSpeculativeNumberShiftRight ||
586 587 588
         op->opcode() == IrOpcode::kSpeculativeNumberShiftRightLogical ||
         op->opcode() == IrOpcode::kSpeculativeNumberBitwiseAnd ||
         op->opcode() == IrOpcode::kSpeculativeNumberBitwiseOr ||
589 590
         op->opcode() == IrOpcode::kSpeculativeNumberBitwiseXor ||
         op->opcode() == IrOpcode::kSpeculativeNumberEqual ||
591
         op->opcode() == IrOpcode::kSpeculativeNumberLessThan ||
592 593 594
         op->opcode() == IrOpcode::kSpeculativeNumberLessThanOrEqual ||
         op->opcode() == IrOpcode::kSpeculativeSafeIntegerAdd ||
         op->opcode() == IrOpcode::kSpeculativeSafeIntegerSubtract);
595
  return OpParameter<NumberOperationHint>(op);
596 597
}

598 599 600 601 602 603
bool operator==(NumberOperationParameters const& lhs,
                NumberOperationParameters const& rhs) {
  return lhs.hint() == rhs.hint() && lhs.feedback() == rhs.feedback();
}

size_t hash_value(NumberOperationParameters const& p) {
604 605
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(p.hint(), feedback_hash(p.feedback()));
606 607 608
}

std::ostream& operator<<(std::ostream& os, NumberOperationParameters const& p) {
609
  return os << p.hint() << ", " << p.feedback();
610 611 612 613 614 615 616 617
}

NumberOperationParameters const& NumberOperationParametersOf(
    Operator const* op) {
  DCHECK_EQ(IrOpcode::kSpeculativeToNumber, op->opcode());
  return OpParameter<NumberOperationParameters>(op);
}

618
size_t hash_value(AllocateParameters info) {
619 620
  return base::hash_combine(info.type(),
                            static_cast<int>(info.allocation_type()));
621 622 623 624
}

V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream& os,
                                           AllocateParameters info) {
625
  return os << info.type() << ", " << info.allocation_type();
626 627 628
}

bool operator==(AllocateParameters const& lhs, AllocateParameters const& rhs) {
629 630
  return lhs.allocation_type() == rhs.allocation_type() &&
         lhs.type() == rhs.type();
631 632
}

633 634 635 636 637 638
const AllocateParameters& AllocateParametersOf(const Operator* op) {
  DCHECK(op->opcode() == IrOpcode::kAllocate ||
         op->opcode() == IrOpcode::kAllocateRaw);
  return OpParameter<AllocateParameters>(op);
}

639
AllocationType AllocationTypeOf(const Operator* op) {
640 641
  if (op->opcode() == IrOpcode::kNewDoubleElements ||
      op->opcode() == IrOpcode::kNewSmiOrObjectElements) {
642
    return OpParameter<AllocationType>(op);
643
  }
644
  return AllocateParametersOf(op).allocation_type();
645 646
}

647
Type AllocateTypeOf(const Operator* op) {
648
  DCHECK_EQ(IrOpcode::kAllocate, op->opcode());
649
  return AllocateParametersOf(op).type();
650 651
}

652
AbortReason AbortReasonOf(const Operator* op) {
653
  DCHECK_EQ(IrOpcode::kRuntimeAbort, op->opcode());
654
  return static_cast<AbortReason>(OpParameter<int>(op));
655 656
}

657 658
const CheckTaggedInputParameters& CheckTaggedInputParametersOf(
    const Operator* op) {
659 660
  DCHECK(op->opcode() == IrOpcode::kCheckedTruncateTaggedToWord32 ||
         op->opcode() == IrOpcode::kCheckedTaggedToFloat64);
661 662 663 664 665
  return OpParameter<CheckTaggedInputParameters>(op);
}

std::ostream& operator<<(std::ostream& os,
                         const CheckTaggedInputParameters& params) {
666
  return os << params.mode() << ", " << params.feedback();
667 668 669
}

size_t hash_value(const CheckTaggedInputParameters& params) {
670 671
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(params.mode(), feedback_hash(params.feedback()));
672 673 674 675 676 677 678 679
}

bool operator==(CheckTaggedInputParameters const& lhs,
                CheckTaggedInputParameters const& rhs) {
  return lhs.mode() == rhs.mode() && lhs.feedback() == rhs.feedback();
}

const CheckMinusZeroParameters& CheckMinusZeroParametersOf(const Operator* op) {
680 681 682 683
  DCHECK(op->opcode() == IrOpcode::kCheckedTaggedToInt32 ||
         op->opcode() == IrOpcode::kCheckedTaggedToInt64 ||
         op->opcode() == IrOpcode::kCheckedFloat64ToInt32 ||
         op->opcode() == IrOpcode::kCheckedFloat64ToInt64);
684 685 686 687 688
  return OpParameter<CheckMinusZeroParameters>(op);
}

std::ostream& operator<<(std::ostream& os,
                         const CheckMinusZeroParameters& params) {
689
  return os << params.mode() << ", " << params.feedback();
690 691 692
}

size_t hash_value(const CheckMinusZeroParameters& params) {
693 694
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(params.mode(), feedback_hash(params.feedback()));
695 696 697 698 699 700 701
}

bool operator==(CheckMinusZeroParameters const& lhs,
                CheckMinusZeroParameters const& rhs) {
  return lhs.mode() == rhs.mode() && lhs.feedback() == rhs.feedback();
}

702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756
#define PURE_OP_LIST(V)                                            \
  V(BooleanNot, Operator::kNoProperties, 1, 0)                     \
  V(NumberEqual, Operator::kCommutative, 2, 0)                     \
  V(NumberLessThan, Operator::kNoProperties, 2, 0)                 \
  V(NumberLessThanOrEqual, Operator::kNoProperties, 2, 0)          \
  V(NumberAdd, Operator::kCommutative, 2, 0)                       \
  V(NumberSubtract, Operator::kNoProperties, 2, 0)                 \
  V(NumberMultiply, Operator::kCommutative, 2, 0)                  \
  V(NumberDivide, Operator::kNoProperties, 2, 0)                   \
  V(NumberModulus, Operator::kNoProperties, 2, 0)                  \
  V(NumberBitwiseOr, Operator::kCommutative, 2, 0)                 \
  V(NumberBitwiseXor, Operator::kCommutative, 2, 0)                \
  V(NumberBitwiseAnd, Operator::kCommutative, 2, 0)                \
  V(NumberShiftLeft, Operator::kNoProperties, 2, 0)                \
  V(NumberShiftRight, Operator::kNoProperties, 2, 0)               \
  V(NumberShiftRightLogical, Operator::kNoProperties, 2, 0)        \
  V(NumberImul, Operator::kCommutative, 2, 0)                      \
  V(NumberAbs, Operator::kNoProperties, 1, 0)                      \
  V(NumberClz32, Operator::kNoProperties, 1, 0)                    \
  V(NumberCeil, Operator::kNoProperties, 1, 0)                     \
  V(NumberFloor, Operator::kNoProperties, 1, 0)                    \
  V(NumberFround, Operator::kNoProperties, 1, 0)                   \
  V(NumberAcos, Operator::kNoProperties, 1, 0)                     \
  V(NumberAcosh, Operator::kNoProperties, 1, 0)                    \
  V(NumberAsin, Operator::kNoProperties, 1, 0)                     \
  V(NumberAsinh, Operator::kNoProperties, 1, 0)                    \
  V(NumberAtan, Operator::kNoProperties, 1, 0)                     \
  V(NumberAtan2, Operator::kNoProperties, 2, 0)                    \
  V(NumberAtanh, Operator::kNoProperties, 1, 0)                    \
  V(NumberCbrt, Operator::kNoProperties, 1, 0)                     \
  V(NumberCos, Operator::kNoProperties, 1, 0)                      \
  V(NumberCosh, Operator::kNoProperties, 1, 0)                     \
  V(NumberExp, Operator::kNoProperties, 1, 0)                      \
  V(NumberExpm1, Operator::kNoProperties, 1, 0)                    \
  V(NumberLog, Operator::kNoProperties, 1, 0)                      \
  V(NumberLog1p, Operator::kNoProperties, 1, 0)                    \
  V(NumberLog10, Operator::kNoProperties, 1, 0)                    \
  V(NumberLog2, Operator::kNoProperties, 1, 0)                     \
  V(NumberMax, Operator::kNoProperties, 2, 0)                      \
  V(NumberMin, Operator::kNoProperties, 2, 0)                      \
  V(NumberPow, Operator::kNoProperties, 2, 0)                      \
  V(NumberRound, Operator::kNoProperties, 1, 0)                    \
  V(NumberSign, Operator::kNoProperties, 1, 0)                     \
  V(NumberSin, Operator::kNoProperties, 1, 0)                      \
  V(NumberSinh, Operator::kNoProperties, 1, 0)                     \
  V(NumberSqrt, Operator::kNoProperties, 1, 0)                     \
  V(NumberTan, Operator::kNoProperties, 1, 0)                      \
  V(NumberTanh, Operator::kNoProperties, 1, 0)                     \
  V(NumberTrunc, Operator::kNoProperties, 1, 0)                    \
  V(NumberToBoolean, Operator::kNoProperties, 1, 0)                \
  V(NumberToInt32, Operator::kNoProperties, 1, 0)                  \
  V(NumberToString, Operator::kNoProperties, 1, 0)                 \
  V(NumberToUint32, Operator::kNoProperties, 1, 0)                 \
  V(NumberToUint8Clamped, Operator::kNoProperties, 1, 0)           \
  V(NumberSilenceNaN, Operator::kNoProperties, 1, 0)               \
757
  V(BigIntNegate, Operator::kNoProperties, 1, 0)                   \
758 759 760
  V(StringConcat, Operator::kNoProperties, 3, 0)                   \
  V(StringToNumber, Operator::kNoProperties, 1, 0)                 \
  V(StringFromSingleCharCode, Operator::kNoProperties, 1, 0)       \
761
  V(StringFromSingleCodePoint, Operator::kNoProperties, 1, 0)      \
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784
  V(StringIndexOf, Operator::kNoProperties, 3, 0)                  \
  V(StringLength, Operator::kNoProperties, 1, 0)                   \
  V(StringToLowerCaseIntl, Operator::kNoProperties, 1, 0)          \
  V(StringToUpperCaseIntl, Operator::kNoProperties, 1, 0)          \
  V(TypeOf, Operator::kNoProperties, 1, 1)                         \
  V(PlainPrimitiveToNumber, Operator::kNoProperties, 1, 0)         \
  V(PlainPrimitiveToWord32, Operator::kNoProperties, 1, 0)         \
  V(PlainPrimitiveToFloat64, Operator::kNoProperties, 1, 0)        \
  V(ChangeTaggedSignedToInt32, Operator::kNoProperties, 1, 0)      \
  V(ChangeTaggedSignedToInt64, Operator::kNoProperties, 1, 0)      \
  V(ChangeTaggedToInt32, Operator::kNoProperties, 1, 0)            \
  V(ChangeTaggedToInt64, Operator::kNoProperties, 1, 0)            \
  V(ChangeTaggedToUint32, Operator::kNoProperties, 1, 0)           \
  V(ChangeTaggedToFloat64, Operator::kNoProperties, 1, 0)          \
  V(ChangeTaggedToTaggedSigned, Operator::kNoProperties, 1, 0)     \
  V(ChangeFloat64ToTaggedPointer, Operator::kNoProperties, 1, 0)   \
  V(ChangeInt31ToTaggedSigned, Operator::kNoProperties, 1, 0)      \
  V(ChangeInt32ToTagged, Operator::kNoProperties, 1, 0)            \
  V(ChangeInt64ToTagged, Operator::kNoProperties, 1, 0)            \
  V(ChangeUint32ToTagged, Operator::kNoProperties, 1, 0)           \
  V(ChangeUint64ToTagged, Operator::kNoProperties, 1, 0)           \
  V(ChangeTaggedToBit, Operator::kNoProperties, 1, 0)              \
  V(ChangeBitToTagged, Operator::kNoProperties, 1, 0)              \
785 786
  V(TruncateBigIntToUint64, Operator::kNoProperties, 1, 0)         \
  V(ChangeUint64ToBigInt, Operator::kNoProperties, 1, 0)           \
787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815
  V(TruncateTaggedToBit, Operator::kNoProperties, 1, 0)            \
  V(TruncateTaggedPointerToBit, Operator::kNoProperties, 1, 0)     \
  V(TruncateTaggedToWord32, Operator::kNoProperties, 1, 0)         \
  V(TruncateTaggedToFloat64, Operator::kNoProperties, 1, 0)        \
  V(ObjectIsArrayBufferView, Operator::kNoProperties, 1, 0)        \
  V(ObjectIsBigInt, Operator::kNoProperties, 1, 0)                 \
  V(ObjectIsCallable, Operator::kNoProperties, 1, 0)               \
  V(ObjectIsConstructor, Operator::kNoProperties, 1, 0)            \
  V(ObjectIsDetectableCallable, Operator::kNoProperties, 1, 0)     \
  V(ObjectIsMinusZero, Operator::kNoProperties, 1, 0)              \
  V(NumberIsMinusZero, Operator::kNoProperties, 1, 0)              \
  V(ObjectIsNaN, Operator::kNoProperties, 1, 0)                    \
  V(NumberIsNaN, Operator::kNoProperties, 1, 0)                    \
  V(ObjectIsNonCallable, Operator::kNoProperties, 1, 0)            \
  V(ObjectIsNumber, Operator::kNoProperties, 1, 0)                 \
  V(ObjectIsReceiver, Operator::kNoProperties, 1, 0)               \
  V(ObjectIsSmi, Operator::kNoProperties, 1, 0)                    \
  V(ObjectIsString, Operator::kNoProperties, 1, 0)                 \
  V(ObjectIsSymbol, Operator::kNoProperties, 1, 0)                 \
  V(ObjectIsUndetectable, Operator::kNoProperties, 1, 0)           \
  V(NumberIsFloat64Hole, Operator::kNoProperties, 1, 0)            \
  V(NumberIsFinite, Operator::kNoProperties, 1, 0)                 \
  V(ObjectIsFiniteNumber, Operator::kNoProperties, 1, 0)           \
  V(NumberIsInteger, Operator::kNoProperties, 1, 0)                \
  V(ObjectIsSafeInteger, Operator::kNoProperties, 1, 0)            \
  V(NumberIsSafeInteger, Operator::kNoProperties, 1, 0)            \
  V(ObjectIsInteger, Operator::kNoProperties, 1, 0)                \
  V(ConvertTaggedHoleToUndefined, Operator::kNoProperties, 1, 0)   \
  V(SameValue, Operator::kCommutative, 2, 0)                       \
816
  V(SameValueNumbersOnly, Operator::kCommutative, 2, 0)            \
817
  V(NumberSameValue, Operator::kCommutative, 2, 0)                 \
818 819 820 821 822 823
  V(ReferenceEqual, Operator::kCommutative, 2, 0)                  \
  V(StringEqual, Operator::kCommutative, 2, 0)                     \
  V(StringLessThan, Operator::kNoProperties, 2, 0)                 \
  V(StringLessThanOrEqual, Operator::kNoProperties, 2, 0)          \
  V(ToBoolean, Operator::kNoProperties, 1, 0)                      \
  V(NewConsString, Operator::kNoProperties, 3, 0)                  \
824
  V(PoisonIndex, Operator::kNoProperties, 1, 0)
825

826
#define EFFECT_DEPENDENT_OP_LIST(V)                       \
827
  V(BigIntAdd, Operator::kNoProperties, 2, 1)             \
828
  V(BigIntSubtract, Operator::kNoProperties, 2, 1)        \
829 830 831 832
  V(StringCharCodeAt, Operator::kNoProperties, 2, 1)      \
  V(StringCodePointAt, Operator::kNoProperties, 2, 1)     \
  V(StringFromCodePointAt, Operator::kNoProperties, 2, 1) \
  V(StringSubstring, Operator::kNoProperties, 3, 1)       \
833
  V(DateNow, Operator::kNoProperties, 0, 1)
834

835 836 837 838 839
#define SPECULATIVE_NUMBER_BINOP_LIST(V)      \
  SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(V) \
  V(SpeculativeNumberEqual)                   \
  V(SpeculativeNumberLessThan)                \
  V(SpeculativeNumberLessThanOrEqual)
840

841 842 843 844 845 846 847 848 849 850 851 852 853 854
#define CHECKED_OP_LIST(V)                \
  V(CheckEqualsInternalizedString, 2, 0)  \
  V(CheckEqualsSymbol, 2, 0)              \
  V(CheckHeapObject, 1, 1)                \
  V(CheckInternalizedString, 1, 1)        \
  V(CheckNotTaggedHole, 1, 1)             \
  V(CheckReceiver, 1, 1)                  \
  V(CheckReceiverOrNullOrUndefined, 1, 1) \
  V(CheckSymbol, 1, 1)                    \
  V(CheckedInt32Add, 2, 1)                \
  V(CheckedInt32Div, 2, 1)                \
  V(CheckedInt32Mod, 2, 1)                \
  V(CheckedInt32Sub, 2, 1)                \
  V(CheckedUint32Div, 2, 1)               \
855
  V(CheckedUint32Mod, 2, 1)
856

857 858 859 860
#define CHECKED_WITH_FEEDBACK_OP_LIST(V)    \
  V(CheckNumber, 1, 1)                      \
  V(CheckSmi, 1, 1)                         \
  V(CheckString, 1, 1)                      \
861
  V(CheckBigInt, 1, 1)                      \
862 863 864
  V(CheckedInt32ToTaggedSigned, 1, 1)       \
  V(CheckedInt64ToInt32, 1, 1)              \
  V(CheckedInt64ToTaggedSigned, 1, 1)       \
865
  V(CheckedTaggedToArrayIndex, 1, 1)        \
866 867 868 869 870 871
  V(CheckedTaggedSignedToInt32, 1, 1)       \
  V(CheckedTaggedToTaggedPointer, 1, 1)     \
  V(CheckedTaggedToTaggedSigned, 1, 1)      \
  V(CheckedUint32ToInt32, 1, 1)             \
  V(CheckedUint32ToTaggedSigned, 1, 1)      \
  V(CheckedUint64ToInt32, 1, 1)             \
872
  V(CheckedUint64ToTaggedSigned, 1, 1)
873

874
#define CHECKED_BOUNDS_OP_LIST(V) \
875 876
  V(CheckedUint32Bounds)          \
  V(CheckedUint64Bounds)
877

878
struct SimplifiedOperatorGlobalCache final {
879
#define PURE(Name, properties, value_input_count, control_input_count)     \
880
  struct Name##Operator final : public Operator {                          \
881 882
    Name##Operator()                                                       \
        : Operator(IrOpcode::k##Name, Operator::kPure | properties, #Name, \
883
                   value_input_count, 0, control_input_count, 1, 0, 0) {}  \
884
  };                                                                       \
885 886 887
  Name##Operator k##Name;
  PURE_OP_LIST(PURE)
#undef PURE
888

889 890 891 892 893 894 895 896
#define EFFECT_DEPENDENT(Name, properties, value_input_count,               \
                         control_input_count)                               \
  struct Name##Operator final : public Operator {                           \
    Name##Operator()                                                        \
        : Operator(IrOpcode::k##Name, Operator::kEliminatable | properties, \
                   #Name, value_input_count, 1, control_input_count, 1, 1,  \
                   0) {}                                                    \
  };                                                                        \
897 898 899 900
  Name##Operator k##Name;
  EFFECT_DEPENDENT_OP_LIST(EFFECT_DEPENDENT)
#undef EFFECT_DEPENDENT

901 902 903 904 905 906 907
#define CHECKED(Name, value_input_count, value_output_count)             \
  struct Name##Operator final : public Operator {                        \
    Name##Operator()                                                     \
        : Operator(IrOpcode::k##Name,                                    \
                   Operator::kFoldable | Operator::kNoThrow, #Name,      \
                   value_input_count, 1, 1, value_output_count, 1, 0) {} \
  };                                                                     \
908 909 910 911
  Name##Operator k##Name;
  CHECKED_OP_LIST(CHECKED)
#undef CHECKED

912 913 914 915 916 917
#define CHECKED_WITH_FEEDBACK(Name, value_input_count, value_output_count) \
  struct Name##Operator final : public Operator1<CheckParameters> {        \
    Name##Operator()                                                       \
        : Operator1<CheckParameters>(                                      \
              IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow, \
              #Name, value_input_count, 1, 1, value_output_count, 1, 0,    \
918
              CheckParameters(FeedbackSource())) {}                        \
919 920 921 922 923
  };                                                                       \
  Name##Operator k##Name;
  CHECKED_WITH_FEEDBACK_OP_LIST(CHECKED_WITH_FEEDBACK)
#undef CHECKED_WITH_FEEDBACK

924 925 926 927 928 929 930 931 932 933 934
#define CHECKED_BOUNDS(Name)                                               \
  struct Name##Operator final : public Operator1<CheckBoundsParameters> {  \
    Name##Operator(FeedbackSource feedback, CheckBoundsFlags flags)        \
        : Operator1<CheckBoundsParameters>(                                \
              IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow, \
              #Name, 2, 1, 1, 1, 1, 0,                                     \
              CheckBoundsParameters(feedback, flags)) {}                   \
  };                                                                       \
  Name##Operator k##Name = {FeedbackSource(), CheckBoundsFlags()};         \
  Name##Operator k##Name##Aborting = {FeedbackSource(),                    \
                                      CheckBoundsFlag::kAbortOnOutOfBounds};
935
  CHECKED_BOUNDS_OP_LIST(CHECKED_BOUNDS)
936 937 938 939 940 941 942 943
  CHECKED_BOUNDS(CheckBounds)
  // For IrOpcode::kCheckBounds, we allow additional flags:
  CheckBoundsOperator kCheckBoundsConverting = {
      FeedbackSource(), CheckBoundsFlag::kConvertStringAndMinusZero};
  CheckBoundsOperator kCheckBoundsAbortingAndConverting = {
      FeedbackSource(),
      CheckBoundsFlags(CheckBoundsFlag::kAbortOnOutOfBounds) |
          CheckBoundsFlags(CheckBoundsFlag::kConvertStringAndMinusZero)};
944 945
#undef CHECKED_BOUNDS

946
  template <DeoptimizeReason kDeoptimizeReason>
947
  struct CheckIfOperator final : public Operator1<CheckIfParameters> {
948
    CheckIfOperator()
949
        : Operator1<CheckIfParameters>(
950
              IrOpcode::kCheckIf, Operator::kFoldable | Operator::kNoThrow,
951
              "CheckIf", 1, 1, 1, 0, 1, 0,
952
              CheckIfParameters(kDeoptimizeReason, FeedbackSource())) {}
953 954 955 956 957 958
  };
#define CHECK_IF(Name, message) \
  CheckIfOperator<DeoptimizeReason::k##Name> kCheckIf##Name;
  DEOPTIMIZE_REASON_LIST(CHECK_IF)
#undef CHECK_IF

959 960 961 962
  struct FindOrderedHashMapEntryOperator final : public Operator {
    FindOrderedHashMapEntryOperator()
        : Operator(IrOpcode::kFindOrderedHashMapEntry, Operator::kEliminatable,
                   "FindOrderedHashMapEntry", 2, 1, 1, 1, 1, 0) {}
963
  };
964
  FindOrderedHashMapEntryOperator kFindOrderedHashMapEntry;
965

966 967 968
  struct FindOrderedHashMapEntryForInt32KeyOperator final : public Operator {
    FindOrderedHashMapEntryForInt32KeyOperator()
        : Operator(IrOpcode::kFindOrderedHashMapEntryForInt32Key,
969
                   Operator::kEliminatable,
970
                   "FindOrderedHashMapEntryForInt32Key", 2, 1, 1, 1, 1, 0) {}
971
  };
972 973
  FindOrderedHashMapEntryForInt32KeyOperator
      kFindOrderedHashMapEntryForInt32Key;
974

975 976 977 978 979 980 981 982 983 984 985 986 987
  template <CheckForMinusZeroMode kMode>
  struct ChangeFloat64ToTaggedOperator final
      : public Operator1<CheckForMinusZeroMode> {
    ChangeFloat64ToTaggedOperator()
        : Operator1<CheckForMinusZeroMode>(
              IrOpcode::kChangeFloat64ToTagged, Operator::kPure,
              "ChangeFloat64ToTagged", 1, 0, 0, 1, 0, 0, kMode) {}
  };
  ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kCheckForMinusZero>
      kChangeFloat64ToTaggedCheckForMinusZeroOperator;
  ChangeFloat64ToTaggedOperator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kChangeFloat64ToTaggedDontCheckForMinusZeroOperator;

988 989 990 991 992 993 994 995 996 997 998 999 1000 1001
  template <CheckForMinusZeroMode kMode>
  struct CheckedInt32MulOperator final
      : public Operator1<CheckForMinusZeroMode> {
    CheckedInt32MulOperator()
        : Operator1<CheckForMinusZeroMode>(
              IrOpcode::kCheckedInt32Mul,
              Operator::kFoldable | Operator::kNoThrow, "CheckedInt32Mul", 2, 1,
              1, 1, 1, 0, kMode) {}
  };
  CheckedInt32MulOperator<CheckForMinusZeroMode::kCheckForMinusZero>
      kCheckedInt32MulCheckForMinusZeroOperator;
  CheckedInt32MulOperator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kCheckedInt32MulDontCheckForMinusZeroOperator;

1002 1003
  template <CheckForMinusZeroMode kMode>
  struct CheckedFloat64ToInt32Operator final
1004
      : public Operator1<CheckMinusZeroParameters> {
1005
    CheckedFloat64ToInt32Operator()
1006
        : Operator1<CheckMinusZeroParameters>(
1007 1008
              IrOpcode::kCheckedFloat64ToInt32,
              Operator::kFoldable | Operator::kNoThrow, "CheckedFloat64ToInt32",
1009
              1, 1, 1, 1, 1, 0,
1010
              CheckMinusZeroParameters(kMode, FeedbackSource())) {}
1011 1012 1013 1014 1015 1016
  };
  CheckedFloat64ToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero>
      kCheckedFloat64ToInt32CheckForMinusZeroOperator;
  CheckedFloat64ToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kCheckedFloat64ToInt32DontCheckForMinusZeroOperator;

1017 1018 1019 1020 1021 1022 1023 1024
  template <CheckForMinusZeroMode kMode>
  struct CheckedFloat64ToInt64Operator final
      : public Operator1<CheckMinusZeroParameters> {
    CheckedFloat64ToInt64Operator()
        : Operator1<CheckMinusZeroParameters>(
              IrOpcode::kCheckedFloat64ToInt64,
              Operator::kFoldable | Operator::kNoThrow, "CheckedFloat64ToInt64",
              1, 1, 1, 1, 1, 0,
1025
              CheckMinusZeroParameters(kMode, FeedbackSource())) {}
1026 1027 1028 1029 1030 1031
  };
  CheckedFloat64ToInt64Operator<CheckForMinusZeroMode::kCheckForMinusZero>
      kCheckedFloat64ToInt64CheckForMinusZeroOperator;
  CheckedFloat64ToInt64Operator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kCheckedFloat64ToInt64DontCheckForMinusZeroOperator;

1032 1033
  template <CheckForMinusZeroMode kMode>
  struct CheckedTaggedToInt32Operator final
1034
      : public Operator1<CheckMinusZeroParameters> {
1035
    CheckedTaggedToInt32Operator()
1036
        : Operator1<CheckMinusZeroParameters>(
1037 1038
              IrOpcode::kCheckedTaggedToInt32,
              Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToInt32",
1039
              1, 1, 1, 1, 1, 0,
1040
              CheckMinusZeroParameters(kMode, FeedbackSource())) {}
1041 1042 1043 1044 1045 1046
  };
  CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kCheckForMinusZero>
      kCheckedTaggedToInt32CheckForMinusZeroOperator;
  CheckedTaggedToInt32Operator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kCheckedTaggedToInt32DontCheckForMinusZeroOperator;

1047 1048 1049 1050 1051 1052 1053 1054
  template <CheckForMinusZeroMode kMode>
  struct CheckedTaggedToInt64Operator final
      : public Operator1<CheckMinusZeroParameters> {
    CheckedTaggedToInt64Operator()
        : Operator1<CheckMinusZeroParameters>(
              IrOpcode::kCheckedTaggedToInt64,
              Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToInt64",
              1, 1, 1, 1, 1, 0,
1055
              CheckMinusZeroParameters(kMode, FeedbackSource())) {}
1056 1057 1058 1059 1060 1061
  };
  CheckedTaggedToInt64Operator<CheckForMinusZeroMode::kCheckForMinusZero>
      kCheckedTaggedToInt64CheckForMinusZeroOperator;
  CheckedTaggedToInt64Operator<CheckForMinusZeroMode::kDontCheckForMinusZero>
      kCheckedTaggedToInt64DontCheckForMinusZeroOperator;

1062 1063
  template <CheckTaggedInputMode kMode>
  struct CheckedTaggedToFloat64Operator final
1064
      : public Operator1<CheckTaggedInputParameters> {
1065
    CheckedTaggedToFloat64Operator()
1066
        : Operator1<CheckTaggedInputParameters>(
1067 1068
              IrOpcode::kCheckedTaggedToFloat64,
              Operator::kFoldable | Operator::kNoThrow,
1069
              "CheckedTaggedToFloat64", 1, 1, 1, 1, 1, 0,
1070
              CheckTaggedInputParameters(kMode, FeedbackSource())) {}
1071 1072 1073
  };
  CheckedTaggedToFloat64Operator<CheckTaggedInputMode::kNumber>
      kCheckedTaggedToFloat64NumberOperator;
1074 1075
  CheckedTaggedToFloat64Operator<CheckTaggedInputMode::kNumberOrBoolean>
      kCheckedTaggedToFloat64NumberOrBooleanOperator;
1076 1077 1078
  CheckedTaggedToFloat64Operator<CheckTaggedInputMode::kNumberOrOddball>
      kCheckedTaggedToFloat64NumberOrOddballOperator;

1079 1080
  template <CheckTaggedInputMode kMode>
  struct CheckedTruncateTaggedToWord32Operator final
1081
      : public Operator1<CheckTaggedInputParameters> {
1082
    CheckedTruncateTaggedToWord32Operator()
1083
        : Operator1<CheckTaggedInputParameters>(
1084 1085
              IrOpcode::kCheckedTruncateTaggedToWord32,
              Operator::kFoldable | Operator::kNoThrow,
1086
              "CheckedTruncateTaggedToWord32", 1, 1, 1, 1, 1, 0,
1087
              CheckTaggedInputParameters(kMode, FeedbackSource())) {}
1088 1089 1090 1091 1092 1093
  };
  CheckedTruncateTaggedToWord32Operator<CheckTaggedInputMode::kNumber>
      kCheckedTruncateTaggedToWord32NumberOperator;
  CheckedTruncateTaggedToWord32Operator<CheckTaggedInputMode::kNumberOrOddball>
      kCheckedTruncateTaggedToWord32NumberOrOddballOperator;

1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110
  template <ConvertReceiverMode kMode>
  struct ConvertReceiverOperator final : public Operator1<ConvertReceiverMode> {
    ConvertReceiverOperator()
        : Operator1<ConvertReceiverMode>(  // --
              IrOpcode::kConvertReceiver,  // opcode
              Operator::kEliminatable,     // flags
              "ConvertReceiver",           // name
              2, 1, 1, 1, 1, 0,            // counts
              kMode) {}                    // param
  };
  ConvertReceiverOperator<ConvertReceiverMode::kAny>
      kConvertReceiverAnyOperator;
  ConvertReceiverOperator<ConvertReceiverMode::kNullOrUndefined>
      kConvertReceiverNullOrUndefinedOperator;
  ConvertReceiverOperator<ConvertReceiverMode::kNotNullOrUndefined>
      kConvertReceiverNotNullOrUndefinedOperator;

1111
  template <CheckFloat64HoleMode kMode>
1112
  struct CheckFloat64HoleNaNOperator final
1113
      : public Operator1<CheckFloat64HoleParameters> {
1114
    CheckFloat64HoleNaNOperator()
1115
        : Operator1<CheckFloat64HoleParameters>(
1116
              IrOpcode::kCheckFloat64Hole,
1117
              Operator::kFoldable | Operator::kNoThrow, "CheckFloat64Hole", 1,
1118
              1, 1, 1, 1, 0,
1119
              CheckFloat64HoleParameters(kMode, FeedbackSource())) {}
1120
  };
1121
  CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kAllowReturnHole>
1122
      kCheckFloat64HoleAllowReturnHoleOperator;
1123
  CheckFloat64HoleNaNOperator<CheckFloat64HoleMode::kNeverReturnHole>
1124 1125
      kCheckFloat64HoleNeverReturnHoleOperator;

1126 1127 1128 1129 1130 1131 1132 1133 1134 1135
  struct EnsureWritableFastElementsOperator final : public Operator {
    EnsureWritableFastElementsOperator()
        : Operator(                                     // --
              IrOpcode::kEnsureWritableFastElements,    // opcode
              Operator::kNoDeopt | Operator::kNoThrow,  // flags
              "EnsureWritableFastElements",             // name
              2, 1, 1, 1, 1, 0) {}                      // counts
  };
  EnsureWritableFastElementsOperator kEnsureWritableFastElements;

1136 1137 1138 1139 1140 1141
  template <GrowFastElementsMode kMode>
  struct GrowFastElementsOperator final
      : public Operator1<GrowFastElementsParameters> {
    GrowFastElementsOperator()
        : Operator1(IrOpcode::kMaybeGrowFastElements, Operator::kNoThrow,
                    "MaybeGrowFastElements", 4, 1, 1, 1, 1, 0,
1142
                    GrowFastElementsParameters(kMode, FeedbackSource())) {}
1143 1144 1145 1146 1147 1148 1149
  };

  GrowFastElementsOperator<GrowFastElementsMode::kDoubleElements>
      kGrowFastElementsOperatorDoubleElements;
  GrowFastElementsOperator<GrowFastElementsMode::kSmiOrObjectElements>
      kGrowFastElementsOperatorSmiOrObjectElements;

1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
  struct LoadFieldByIndexOperator final : public Operator {
    LoadFieldByIndexOperator()
        : Operator(                         // --
              IrOpcode::kLoadFieldByIndex,  // opcode
              Operator::kEliminatable,      // flags,
              "LoadFieldByIndex",           // name
              2, 1, 1, 1, 1, 0) {}          // counts;
  };
  LoadFieldByIndexOperator kLoadFieldByIndex;

1160 1161 1162 1163
  struct LoadStackArgumentOperator final : public Operator {
    LoadStackArgumentOperator()
        : Operator(                          // --
              IrOpcode::kLoadStackArgument,  // opcode
1164 1165 1166
              Operator::kEliminatable,       // flags
              "LoadStackArgument",           // name
              2, 1, 1, 1, 1, 0) {}           // counts
1167 1168 1169
  };
  LoadStackArgumentOperator kLoadStackArgument;

1170 1171 1172 1173 1174 1175 1176 1177
#define SPECULATIVE_NUMBER_BINOP(Name)                                      \
  template <NumberOperationHint kHint>                                      \
  struct Name##Operator final : public Operator1<NumberOperationHint> {     \
    Name##Operator()                                                        \
        : Operator1<NumberOperationHint>(                                   \
              IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow,  \
              #Name, 2, 1, 1, 1, 1, 0, kHint) {}                            \
  };                                                                        \
1178 1179 1180 1181
  Name##Operator<NumberOperationHint::kSignedSmall>                         \
      k##Name##SignedSmallOperator;                                         \
  Name##Operator<NumberOperationHint::kSignedSmallInputs>                   \
      k##Name##SignedSmallInputsOperator;                                   \
1182
  Name##Operator<NumberOperationHint::kNumber> k##Name##NumberOperator;     \
1183 1184 1185 1186
  Name##Operator<NumberOperationHint::kNumberOrOddball>                     \
      k##Name##NumberOrOddballOperator;
  SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP)
#undef SPECULATIVE_NUMBER_BINOP
1187 1188
  SpeculativeNumberEqualOperator<NumberOperationHint::kNumberOrBoolean>
      kSpeculativeNumberEqualNumberOrBooleanOperator;
1189

1190 1191
  template <NumberOperationHint kHint>
  struct SpeculativeToNumberOperator final
1192
      : public Operator1<NumberOperationParameters> {
1193
    SpeculativeToNumberOperator()
1194 1195 1196 1197
        : Operator1<NumberOperationParameters>(
              IrOpcode::kSpeculativeToNumber,
              Operator::kFoldable | Operator::kNoThrow, "SpeculativeToNumber",
              1, 1, 1, 1, 1, 0,
1198
              NumberOperationParameters(kHint, FeedbackSource())) {}
1199
  };
1200 1201
  SpeculativeToNumberOperator<NumberOperationHint::kSignedSmall>
      kSpeculativeToNumberSignedSmallOperator;
1202 1203 1204 1205
  SpeculativeToNumberOperator<NumberOperationHint::kNumber>
      kSpeculativeToNumberNumberOperator;
  SpeculativeToNumberOperator<NumberOperationHint::kNumberOrOddball>
      kSpeculativeToNumberNumberOrOddballOperator;
1206 1207
};

1208 1209
namespace {
DEFINE_LAZY_LEAKY_OBJECT_GETTER(SimplifiedOperatorGlobalCache,
1210
                                GetSimplifiedOperatorGlobalCache)
1211
}  // namespace
1212 1213

SimplifiedOperatorBuilder::SimplifiedOperatorBuilder(Zone* zone)
1214
    : cache_(*GetSimplifiedOperatorGlobalCache()), zone_(zone) {}
1215

1216
#define GET_FROM_CACHE(Name, ...) \
1217
  const Operator* SimplifiedOperatorBuilder::Name() { return &cache_.k##Name; }
1218
PURE_OP_LIST(GET_FROM_CACHE)
1219
EFFECT_DEPENDENT_OP_LIST(GET_FROM_CACHE)
1220
CHECKED_OP_LIST(GET_FROM_CACHE)
1221
GET_FROM_CACHE(FindOrderedHashMapEntry)
1222
GET_FROM_CACHE(FindOrderedHashMapEntryForInt32Key)
1223
GET_FROM_CACHE(LoadFieldByIndex)
1224
#undef GET_FROM_CACHE
1225

1226 1227 1228
#define GET_FROM_CACHE_WITH_FEEDBACK(Name, value_input_count,               \
                                     value_output_count)                    \
  const Operator* SimplifiedOperatorBuilder::Name(                          \
1229
      const FeedbackSource& feedback) {                                     \
1230 1231 1232
    if (!feedback.IsValid()) {                                              \
      return &cache_.k##Name;                                               \
    }                                                                       \
1233
    return zone()->New<Operator1<CheckParameters>>(                         \
1234 1235 1236 1237 1238 1239 1240
        IrOpcode::k##Name, Operator::kFoldable | Operator::kNoThrow, #Name, \
        value_input_count, 1, 1, value_output_count, 1, 0,                  \
        CheckParameters(feedback));                                         \
  }
CHECKED_WITH_FEEDBACK_OP_LIST(GET_FROM_CACHE_WITH_FEEDBACK)
#undef GET_FROM_CACHE_WITH_FEEDBACK

1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253
#define GET_FROM_CACHE_WITH_FEEDBACK(Name)                             \
  const Operator* SimplifiedOperatorBuilder::Name(                     \
      const FeedbackSource& feedback, CheckBoundsFlags flags) {        \
    DCHECK(!(flags & CheckBoundsFlag::kConvertStringAndMinusZero));    \
    if (!feedback.IsValid()) {                                         \
      if (flags & CheckBoundsFlag::kAbortOnOutOfBounds) {              \
        return &cache_.k##Name##Aborting;                              \
      } else {                                                         \
        return &cache_.k##Name;                                        \
      }                                                                \
    }                                                                  \
    return zone()->New<SimplifiedOperatorGlobalCache::Name##Operator>( \
        feedback, flags);                                              \
1254 1255 1256 1257
  }
CHECKED_BOUNDS_OP_LIST(GET_FROM_CACHE_WITH_FEEDBACK)
#undef GET_FROM_CACHE_WITH_FEEDBACK

1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275
// For IrOpcode::kCheckBounds, we allow additional flags:
const Operator* SimplifiedOperatorBuilder::CheckBounds(
    const FeedbackSource& feedback, CheckBoundsFlags flags) {
  if (!feedback.IsValid()) {
    if (flags & CheckBoundsFlag::kAbortOnOutOfBounds) {
      if (flags & CheckBoundsFlag::kConvertStringAndMinusZero) {
        return &cache_.kCheckBoundsAbortingAndConverting;
      } else {
        return &cache_.kCheckBoundsAborting;
      }
    } else {
      if (flags & CheckBoundsFlag::kConvertStringAndMinusZero) {
        return &cache_.kCheckBoundsConverting;
      } else {
        return &cache_.kCheckBounds;
      }
    }
  }
1276 1277
  return zone()->New<SimplifiedOperatorGlobalCache::CheckBoundsOperator>(
      feedback, flags);
1278 1279
}

1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
bool IsCheckedWithFeedback(const Operator* op) {
#define CASE(Name, ...) case IrOpcode::k##Name:
  switch (op->opcode()) {
    CHECKED_WITH_FEEDBACK_OP_LIST(CASE) return true;
    default:
      return false;
  }
#undef CASE
}

1290
const Operator* SimplifiedOperatorBuilder::RuntimeAbort(AbortReason reason) {
1291
  return zone()->New<Operator1<int>>(           // --
1292 1293 1294 1295 1296
      IrOpcode::kRuntimeAbort,                  // opcode
      Operator::kNoThrow | Operator::kNoDeopt,  // flags
      "RuntimeAbort",                           // name
      0, 1, 1, 0, 1, 0,                         // counts
      static_cast<int>(reason));                // parameter
1297 1298
}

1299 1300 1301
const Operator* SimplifiedOperatorBuilder::BigIntAsUintN(int bits) {
  CHECK(0 <= bits && bits <= 64);

1302
  return zone()->New<Operator1<int>>(IrOpcode::kBigIntAsUintN, Operator::kPure,
1303 1304 1305
                                     "BigIntAsUintN", 1, 0, 0, 1, 0, 0, bits);
}

1306 1307 1308 1309 1310 1311
const Operator* SimplifiedOperatorBuilder::UpdateInterruptBudget(int delta) {
  return zone()->New<Operator1<int>>(
      IrOpcode::kUpdateInterruptBudget, Operator::kNoThrow | Operator::kNoDeopt,
      "UpdateInterruptBudget", 1, 1, 1, 0, 1, 0, delta);
}

1312 1313 1314
const Operator* SimplifiedOperatorBuilder::TierUpCheck() {
  return zone()->New<Operator>(IrOpcode::kTierUpCheck,
                               Operator::kNoThrow | Operator::kNoDeopt,
1315
                               "TierUpCheck", 5, 1, 1, 0, 1, 0);
1316 1317
}

1318 1319
const Operator* SimplifiedOperatorBuilder::AssertType(Type type) {
  DCHECK(type.IsRange());
1320
  return zone()->New<Operator1<Type>>(IrOpcode::kAssertType,
1321 1322 1323 1324
                                      Operator::kNoThrow | Operator::kNoDeopt,
                                      "AssertType", 1, 0, 0, 1, 0, 0, type);
}

1325
const Operator* SimplifiedOperatorBuilder::CheckIf(
1326
    DeoptimizeReason reason, const FeedbackSource& feedback) {
1327 1328
  if (!feedback.IsValid()) {
    switch (reason) {
1329 1330 1331 1332 1333
#define CHECK_IF(Name, message)   \
  case DeoptimizeReason::k##Name: \
    return &cache_.kCheckIf##Name;
    DEOPTIMIZE_REASON_LIST(CHECK_IF)
#undef CHECK_IF
1334
    }
1335
  }
1336
  return zone()->New<Operator1<CheckIfParameters>>(
1337 1338
      IrOpcode::kCheckIf, Operator::kFoldable | Operator::kNoThrow, "CheckIf",
      1, 1, 1, 0, 1, 0, CheckIfParameters(reason, feedback));
1339 1340
}

1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351
const Operator* SimplifiedOperatorBuilder::ChangeFloat64ToTagged(
    CheckForMinusZeroMode mode) {
  switch (mode) {
    case CheckForMinusZeroMode::kCheckForMinusZero:
      return &cache_.kChangeFloat64ToTaggedCheckForMinusZeroOperator;
    case CheckForMinusZeroMode::kDontCheckForMinusZero:
      return &cache_.kChangeFloat64ToTaggedDontCheckForMinusZeroOperator;
  }
  UNREACHABLE();
}

1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362
const Operator* SimplifiedOperatorBuilder::CheckedInt32Mul(
    CheckForMinusZeroMode mode) {
  switch (mode) {
    case CheckForMinusZeroMode::kCheckForMinusZero:
      return &cache_.kCheckedInt32MulCheckForMinusZeroOperator;
    case CheckForMinusZeroMode::kDontCheckForMinusZero:
      return &cache_.kCheckedInt32MulDontCheckForMinusZeroOperator;
  }
  UNREACHABLE();
}

1363
const Operator* SimplifiedOperatorBuilder::CheckedFloat64ToInt32(
1364
    CheckForMinusZeroMode mode, const FeedbackSource& feedback) {
1365 1366 1367 1368 1369 1370 1371
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckForMinusZeroMode::kCheckForMinusZero:
        return &cache_.kCheckedFloat64ToInt32CheckForMinusZeroOperator;
      case CheckForMinusZeroMode::kDontCheckForMinusZero:
        return &cache_.kCheckedFloat64ToInt32DontCheckForMinusZeroOperator;
    }
1372
  }
1373
  return zone()->New<Operator1<CheckMinusZeroParameters>>(
1374 1375 1376
      IrOpcode::kCheckedFloat64ToInt32,
      Operator::kFoldable | Operator::kNoThrow, "CheckedFloat64ToInt32", 1, 1,
      1, 1, 1, 0, CheckMinusZeroParameters(mode, feedback));
1377 1378
}

1379
const Operator* SimplifiedOperatorBuilder::CheckedFloat64ToInt64(
1380
    CheckForMinusZeroMode mode, const FeedbackSource& feedback) {
1381 1382 1383 1384 1385 1386 1387 1388
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckForMinusZeroMode::kCheckForMinusZero:
        return &cache_.kCheckedFloat64ToInt64CheckForMinusZeroOperator;
      case CheckForMinusZeroMode::kDontCheckForMinusZero:
        return &cache_.kCheckedFloat64ToInt64DontCheckForMinusZeroOperator;
    }
  }
1389
  return zone()->New<Operator1<CheckMinusZeroParameters>>(
1390 1391 1392 1393 1394
      IrOpcode::kCheckedFloat64ToInt64,
      Operator::kFoldable | Operator::kNoThrow, "CheckedFloat64ToInt64", 1, 1,
      1, 1, 1, 0, CheckMinusZeroParameters(mode, feedback));
}

1395
const Operator* SimplifiedOperatorBuilder::CheckedTaggedToInt32(
1396
    CheckForMinusZeroMode mode, const FeedbackSource& feedback) {
1397 1398 1399 1400 1401 1402 1403
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckForMinusZeroMode::kCheckForMinusZero:
        return &cache_.kCheckedTaggedToInt32CheckForMinusZeroOperator;
      case CheckForMinusZeroMode::kDontCheckForMinusZero:
        return &cache_.kCheckedTaggedToInt32DontCheckForMinusZeroOperator;
    }
1404
  }
1405
  return zone()->New<Operator1<CheckMinusZeroParameters>>(
1406 1407 1408
      IrOpcode::kCheckedTaggedToInt32, Operator::kFoldable | Operator::kNoThrow,
      "CheckedTaggedToInt32", 1, 1, 1, 1, 1, 0,
      CheckMinusZeroParameters(mode, feedback));
1409 1410
}

1411
const Operator* SimplifiedOperatorBuilder::CheckedTaggedToInt64(
1412
    CheckForMinusZeroMode mode, const FeedbackSource& feedback) {
1413 1414 1415 1416 1417 1418 1419 1420
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckForMinusZeroMode::kCheckForMinusZero:
        return &cache_.kCheckedTaggedToInt64CheckForMinusZeroOperator;
      case CheckForMinusZeroMode::kDontCheckForMinusZero:
        return &cache_.kCheckedTaggedToInt64DontCheckForMinusZeroOperator;
    }
  }
1421
  return zone()->New<Operator1<CheckMinusZeroParameters>>(
1422 1423 1424 1425 1426
      IrOpcode::kCheckedTaggedToInt64, Operator::kFoldable | Operator::kNoThrow,
      "CheckedTaggedToInt64", 1, 1, 1, 1, 1, 0,
      CheckMinusZeroParameters(mode, feedback));
}

1427
const Operator* SimplifiedOperatorBuilder::CheckedTaggedToFloat64(
1428
    CheckTaggedInputMode mode, const FeedbackSource& feedback) {
1429 1430 1431 1432
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckTaggedInputMode::kNumber:
        return &cache_.kCheckedTaggedToFloat64NumberOperator;
1433 1434
      case CheckTaggedInputMode::kNumberOrBoolean:
        return &cache_.kCheckedTaggedToFloat64NumberOrBooleanOperator;
1435 1436 1437
      case CheckTaggedInputMode::kNumberOrOddball:
        return &cache_.kCheckedTaggedToFloat64NumberOrOddballOperator;
    }
1438
  }
1439
  return zone()->New<Operator1<CheckTaggedInputParameters>>(
1440 1441 1442
      IrOpcode::kCheckedTaggedToFloat64,
      Operator::kFoldable | Operator::kNoThrow, "CheckedTaggedToFloat64", 1, 1,
      1, 1, 1, 0, CheckTaggedInputParameters(mode, feedback));
1443 1444
}

1445
const Operator* SimplifiedOperatorBuilder::CheckedTruncateTaggedToWord32(
1446
    CheckTaggedInputMode mode, const FeedbackSource& feedback) {
1447 1448 1449 1450
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckTaggedInputMode::kNumber:
        return &cache_.kCheckedTruncateTaggedToWord32NumberOperator;
1451 1452 1453
      case CheckTaggedInputMode::kNumberOrBoolean:
        // Not used currently.
        UNREACHABLE();
1454 1455 1456
      case CheckTaggedInputMode::kNumberOrOddball:
        return &cache_.kCheckedTruncateTaggedToWord32NumberOrOddballOperator;
    }
1457
  }
1458
  return zone()->New<Operator1<CheckTaggedInputParameters>>(
1459 1460 1461
      IrOpcode::kCheckedTruncateTaggedToWord32,
      Operator::kFoldable | Operator::kNoThrow, "CheckedTruncateTaggedToWord32",
      1, 1, 1, 1, 1, 0, CheckTaggedInputParameters(mode, feedback));
1462 1463
}

1464 1465
const Operator* SimplifiedOperatorBuilder::CheckMaps(
    CheckMapsFlags flags, ZoneHandleSet<Map> maps,
1466
    const FeedbackSource& feedback) {
1467
  CheckMapsParameters const parameters(flags, maps, feedback);
1468
  return zone()->New<Operator1<CheckMapsParameters>>(  // --
1469 1470 1471 1472 1473
      IrOpcode::kCheckMaps,                            // opcode
      Operator::kNoThrow | Operator::kNoWrite,         // flags
      "CheckMaps",                                     // name
      1, 1, 1, 0, 1, 0,                                // counts
      parameters);                                     // parameter
1474 1475
}

1476
const Operator* SimplifiedOperatorBuilder::DynamicCheckMaps(
1477 1478 1479
    CheckMapsFlags flags, Handle<Object> handler,
    ZoneHandleSet<Map> const& maps, const FeedbackSource& feedback) {
  DynamicCheckMapsParameters const parameters(flags, handler, maps, feedback);
1480 1481 1482 1483 1484 1485 1486 1487
  return zone()->New<Operator1<DynamicCheckMapsParameters>>(  // --
      IrOpcode::kDynamicCheckMaps,                            // opcode
      Operator::kNoThrow | Operator::kNoWrite,                // flags
      "DynamicCheckMaps",                                     // name
      1, 1, 1, 0, 1, 0,                                       // counts
      parameters);                                            // parameter
}

1488
const Operator* SimplifiedOperatorBuilder::MapGuard(ZoneHandleSet<Map> maps) {
1489
  DCHECK_LT(0, maps.size());
1490
  return zone()->New<Operator1<ZoneHandleSet<Map>>>(  // --
1491 1492 1493 1494
      IrOpcode::kMapGuard, Operator::kEliminatable,   // opcode
      "MapGuard",                                     // name
      1, 1, 1, 0, 1, 0,                               // counts
      maps);                                          // parameter
1495 1496
}

1497 1498
const Operator* SimplifiedOperatorBuilder::CompareMaps(
    ZoneHandleSet<Map> maps) {
1499
  DCHECK_LT(0, maps.size());
1500
  return zone()->New<Operator1<ZoneHandleSet<Map>>>(  // --
1501
      IrOpcode::kCompareMaps,                         // opcode
1502
      Operator::kNoThrow | Operator::kNoWrite,        // flags
1503 1504 1505
      "CompareMaps",                                  // name
      1, 1, 1, 1, 1, 0,                               // counts
      maps);                                          // parameter
1506 1507
}

1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521
const Operator* SimplifiedOperatorBuilder::ConvertReceiver(
    ConvertReceiverMode mode) {
  switch (mode) {
    case ConvertReceiverMode::kAny:
      return &cache_.kConvertReceiverAnyOperator;
    case ConvertReceiverMode::kNullOrUndefined:
      return &cache_.kConvertReceiverNullOrUndefinedOperator;
    case ConvertReceiverMode::kNotNullOrUndefined:
      return &cache_.kConvertReceiverNotNullOrUndefinedOperator;
  }
  UNREACHABLE();
  return nullptr;
}

1522
const Operator* SimplifiedOperatorBuilder::CheckFloat64Hole(
1523
    CheckFloat64HoleMode mode, FeedbackSource const& feedback) {
1524 1525 1526 1527 1528 1529 1530 1531
  if (!feedback.IsValid()) {
    switch (mode) {
      case CheckFloat64HoleMode::kAllowReturnHole:
        return &cache_.kCheckFloat64HoleAllowReturnHoleOperator;
      case CheckFloat64HoleMode::kNeverReturnHole:
        return &cache_.kCheckFloat64HoleNeverReturnHoleOperator;
    }
    UNREACHABLE();
1532
  }
1533
  return zone()->New<Operator1<CheckFloat64HoleParameters>>(
1534 1535 1536
      IrOpcode::kCheckFloat64Hole, Operator::kFoldable | Operator::kNoThrow,
      "CheckFloat64Hole", 1, 1, 1, 1, 1, 0,
      CheckFloat64HoleParameters(mode, feedback));
1537 1538
}

1539
const Operator* SimplifiedOperatorBuilder::SpeculativeBigIntAdd(
1540
    BigIntOperationHint hint) {
1541
  return zone()->New<Operator1<BigIntOperationHint>>(
1542
      IrOpcode::kSpeculativeBigIntAdd, Operator::kFoldable | Operator::kNoThrow,
1543
      "SpeculativeBigIntAdd", 2, 1, 1, 1, 1, 0, hint);
1544 1545
}

1546 1547
const Operator* SimplifiedOperatorBuilder::SpeculativeBigIntSubtract(
    BigIntOperationHint hint) {
1548
  return zone()->New<Operator1<BigIntOperationHint>>(
1549 1550 1551
      IrOpcode::kSpeculativeBigIntSubtract,
      Operator::kFoldable | Operator::kNoThrow, "SpeculativeBigIntSubtract", 2,
      1, 1, 1, 1, 0, hint);
1552 1553
}

1554 1555
const Operator* SimplifiedOperatorBuilder::SpeculativeBigIntNegate(
    BigIntOperationHint hint) {
1556
  return zone()->New<Operator1<BigIntOperationHint>>(
1557 1558 1559 1560 1561
      IrOpcode::kSpeculativeBigIntNegate,
      Operator::kFoldable | Operator::kNoThrow, "SpeculativeBigIntNegate", 1, 1,
      1, 1, 1, 0, hint);
}

1562 1563
const Operator* SimplifiedOperatorBuilder::CheckClosure(
    const Handle<FeedbackCell>& feedback_cell) {
1564
  return zone()->New<Operator1<Handle<FeedbackCell>>>(  // --
1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576
      IrOpcode::kCheckClosure,                          // opcode
      Operator::kNoThrow | Operator::kNoWrite,          // flags
      "CheckClosure",                                   // name
      1, 1, 1, 1, 1, 0,                                 // counts
      feedback_cell);                                   // parameter
}

Handle<FeedbackCell> FeedbackCellOf(const Operator* op) {
  DCHECK(IrOpcode::kCheckClosure == op->opcode());
  return OpParameter<Handle<FeedbackCell>>(op);
}

1577
const Operator* SimplifiedOperatorBuilder::SpeculativeToNumber(
1578
    NumberOperationHint hint, const FeedbackSource& feedback) {
1579 1580
  if (!feedback.IsValid()) {
    switch (hint) {
1581 1582 1583 1584
      case NumberOperationHint::kSignedSmall:
        return &cache_.kSpeculativeToNumberSignedSmallOperator;
      case NumberOperationHint::kSignedSmallInputs:
        break;
1585 1586
      case NumberOperationHint::kNumber:
        return &cache_.kSpeculativeToNumberNumberOperator;
1587 1588 1589
      case NumberOperationHint::kNumberOrBoolean:
        // Not used currently.
        UNREACHABLE();
1590 1591 1592
      case NumberOperationHint::kNumberOrOddball:
        return &cache_.kSpeculativeToNumberNumberOrOddballOperator;
    }
1593
  }
1594
  return zone()->New<Operator1<NumberOperationParameters>>(
1595 1596 1597
      IrOpcode::kSpeculativeToNumber, Operator::kFoldable | Operator::kNoThrow,
      "SpeculativeToNumber", 1, 1, 1, 1, 1, 0,
      NumberOperationParameters(hint, feedback));
1598 1599
}

1600 1601 1602 1603
const Operator* SimplifiedOperatorBuilder::EnsureWritableFastElements() {
  return &cache_.kEnsureWritableFastElements;
}

1604
const Operator* SimplifiedOperatorBuilder::MaybeGrowFastElements(
1605
    GrowFastElementsMode mode, const FeedbackSource& feedback) {
1606 1607 1608 1609 1610 1611 1612 1613
  if (!feedback.IsValid()) {
    switch (mode) {
      case GrowFastElementsMode::kDoubleElements:
        return &cache_.kGrowFastElementsOperatorDoubleElements;
      case GrowFastElementsMode::kSmiOrObjectElements:
        return &cache_.kGrowFastElementsOperatorSmiOrObjectElements;
    }
  }
1614
  return zone()->New<Operator1<GrowFastElementsParameters>>(  // --
1615 1616 1617 1618 1619
      IrOpcode::kMaybeGrowFastElements,                       // opcode
      Operator::kNoThrow,                                     // flags
      "MaybeGrowFastElements",                                // name
      4, 1, 1, 1, 1, 0,                                       // counts
      GrowFastElementsParameters(mode, feedback));            // parameter
1620 1621
}

1622 1623
const Operator* SimplifiedOperatorBuilder::TransitionElementsKind(
    ElementsTransition transition) {
1624
  return zone()->New<Operator1<ElementsTransition>>(  // --
1625
      IrOpcode::kTransitionElementsKind,              // opcode
1626
      Operator::kNoThrow,                             // flags
1627
      "TransitionElementsKind",                       // name
1628
      1, 1, 1, 0, 1, 0,                               // counts
1629 1630 1631
      transition);                                    // parameter
}

1632 1633 1634 1635 1636 1637
const Operator* SimplifiedOperatorBuilder::ArgumentsLength() {
  return zone()->New<Operator>(    // --
      IrOpcode::kArgumentsLength,  // opcode
      Operator::kPure,             // flags
      "ArgumentsLength",           // name
      0, 0, 0, 1, 0, 0);           // counts
1638 1639
}

1640 1641 1642 1643 1644 1645
const Operator* SimplifiedOperatorBuilder::RestLength(
    int formal_parameter_count) {
  return zone()->New<Operator1<int>>(  // --
      IrOpcode::kRestLength,           // opcode
      Operator::kPure,                 // flags
      "RestLength",                    // name
1646
      0, 0, 0, 1, 0, 0,                // counts
1647
      formal_parameter_count);         // parameter
1648 1649
}

1650 1651 1652 1653
int FormalParameterCountOf(const Operator* op) {
  DCHECK(op->opcode() == IrOpcode::kArgumentsLength ||
         op->opcode() == IrOpcode::kRestLength);
  return OpParameter<int>(op);
1654 1655
}

1656 1657 1658 1659
bool operator==(CheckParameters const& lhs, CheckParameters const& rhs) {
  return lhs.feedback() == rhs.feedback();
}

1660 1661 1662 1663
size_t hash_value(CheckParameters const& p) {
  FeedbackSource::Hash feedback_hash;
  return feedback_hash(p.feedback());
}
1664 1665 1666 1667 1668 1669

std::ostream& operator<<(std::ostream& os, CheckParameters const& p) {
  return os << p.feedback();
}

CheckParameters const& CheckParametersOf(Operator const* op) {
1670
  if (op->opcode() == IrOpcode::kCheckBounds ||
1671 1672
      op->opcode() == IrOpcode::kCheckedUint32Bounds ||
      op->opcode() == IrOpcode::kCheckedUint64Bounds) {
1673 1674
    return OpParameter<CheckBoundsParameters>(op).check_parameters();
  }
1675 1676 1677 1678 1679 1680
#define MAKE_OR(name, arg2, arg3) op->opcode() == IrOpcode::k##name ||
  CHECK((CHECKED_WITH_FEEDBACK_OP_LIST(MAKE_OR) false));
#undef MAKE_OR
  return OpParameter<CheckParameters>(op);
}

1681 1682 1683
bool operator==(CheckBoundsParameters const& lhs,
                CheckBoundsParameters const& rhs) {
  return lhs.check_parameters() == rhs.check_parameters() &&
1684
         lhs.flags() == rhs.flags();
1685 1686 1687
}

size_t hash_value(CheckBoundsParameters const& p) {
1688
  return base::hash_combine(hash_value(p.check_parameters()), p.flags());
1689 1690 1691
}

std::ostream& operator<<(std::ostream& os, CheckBoundsParameters const& p) {
1692
  os << p.check_parameters() << ", " << p.flags();
1693 1694 1695 1696
  return os;
}

CheckBoundsParameters const& CheckBoundsParametersOf(Operator const* op) {
1697 1698 1699
  DCHECK(op->opcode() == IrOpcode::kCheckBounds ||
         op->opcode() == IrOpcode::kCheckedUint32Bounds ||
         op->opcode() == IrOpcode::kCheckedUint64Bounds);
1700 1701 1702
  return OpParameter<CheckBoundsParameters>(op);
}

1703 1704 1705 1706 1707
bool operator==(CheckIfParameters const& lhs, CheckIfParameters const& rhs) {
  return lhs.reason() == rhs.reason() && lhs.feedback() == rhs.feedback();
}

size_t hash_value(CheckIfParameters const& p) {
1708 1709
  FeedbackSource::Hash feedback_hash;
  return base::hash_combine(p.reason(), feedback_hash(p.feedback()));
1710 1711 1712
}

std::ostream& operator<<(std::ostream& os, CheckIfParameters const& p) {
1713
  return os << p.reason() << ", " << p.feedback();
1714 1715 1716 1717 1718 1719 1720
}

CheckIfParameters const& CheckIfParametersOf(Operator const* op) {
  CHECK(op->opcode() == IrOpcode::kCheckIf);
  return OpParameter<CheckIfParameters>(op);
}

1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741
FastApiCallParameters const& FastApiCallParametersOf(const Operator* op) {
  DCHECK_EQ(IrOpcode::kFastApiCall, op->opcode());
  return OpParameter<FastApiCallParameters>(op);
}

std::ostream& operator<<(std::ostream& os, FastApiCallParameters const& p) {
  return os << p.signature() << ", " << p.feedback() << ", " << p.descriptor();
}

size_t hash_value(FastApiCallParameters const& p) {
  return base::hash_combine(p.signature(), FeedbackSource::Hash()(p.feedback()),
                            p.descriptor());
}

bool operator==(FastApiCallParameters const& lhs,
                FastApiCallParameters const& rhs) {
  return lhs.signature() == rhs.signature() &&
         lhs.feedback() == rhs.feedback() &&
         lhs.descriptor() == rhs.descriptor();
}

1742
const Operator* SimplifiedOperatorBuilder::NewDoubleElements(
1743
    AllocationType allocation) {
1744
  return zone()->New<Operator1<AllocationType>>(  // --
1745 1746 1747 1748 1749
      IrOpcode::kNewDoubleElements,               // opcode
      Operator::kEliminatable,                    // flags
      "NewDoubleElements",                        // name
      1, 1, 1, 1, 1, 0,                           // counts
      allocation);                                // parameter
1750 1751
}

1752
const Operator* SimplifiedOperatorBuilder::NewSmiOrObjectElements(
1753
    AllocationType allocation) {
1754
  return zone()->New<Operator1<AllocationType>>(  // --
1755 1756 1757 1758 1759
      IrOpcode::kNewSmiOrObjectElements,          // opcode
      Operator::kEliminatable,                    // flags
      "NewSmiOrObjectElements",                   // name
      1, 1, 1, 1, 1, 0,                           // counts
      allocation);                                // parameter
1760 1761
}

1762
const Operator* SimplifiedOperatorBuilder::NewArgumentsElements(
1763
    CreateArgumentsType type, int formal_parameter_count) {
1764
  return zone()->New<Operator1<NewArgumentsElementsParameters>>(  // --
1765 1766 1767
      IrOpcode::kNewArgumentsElements,                            // opcode
      Operator::kEliminatable,                                    // flags
      "NewArgumentsElements",                                     // name
1768
      1, 1, 0, 1, 1, 0,                                           // counts
1769 1770
      NewArgumentsElementsParameters(type,
                                     formal_parameter_count));  // parameter
1771 1772
}

1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791
bool operator==(const NewArgumentsElementsParameters& lhs,
                const NewArgumentsElementsParameters& rhs) {
  return lhs.arguments_type() == rhs.arguments_type() &&
         lhs.formal_parameter_count() == rhs.formal_parameter_count();
}

inline size_t hash_value(const NewArgumentsElementsParameters& params) {
  return base::hash_combine(params.arguments_type(),
                            params.formal_parameter_count());
}

std::ostream& operator<<(std::ostream& os,
                         const NewArgumentsElementsParameters& params) {
  return os << params.arguments_type()
            << ", parameter_count = " << params.formal_parameter_count();
}

const NewArgumentsElementsParameters& NewArgumentsElementsParametersOf(
    const Operator* op) {
1792
  DCHECK_EQ(IrOpcode::kNewArgumentsElements, op->opcode());
1793
  return OpParameter<NewArgumentsElementsParameters>(op);
1794 1795
}

1796
const Operator* SimplifiedOperatorBuilder::Allocate(Type type,
1797
                                                    AllocationType allocation) {
1798
  return zone()->New<Operator1<AllocateParameters>>(
1799 1800
      IrOpcode::kAllocate, Operator::kEliminatable, "Allocate", 1, 1, 1, 1, 1,
      0, AllocateParameters(type, allocation));
1801 1802
}

1803
const Operator* SimplifiedOperatorBuilder::AllocateRaw(
1804 1805 1806 1807 1808 1809 1810
    Type type, AllocationType allocation,
    AllowLargeObjects allow_large_objects) {
  // We forbid optimized allocations to allocate in a different generation than
  // requested.
  DCHECK(!(allow_large_objects == AllowLargeObjects::kTrue &&
           allocation == AllocationType::kYoung &&
           !FLAG_young_generation_large_objects));
1811
  return zone()->New<Operator1<AllocateParameters>>(
1812 1813
      IrOpcode::kAllocateRaw, Operator::kEliminatable, "AllocateRaw", 1, 1, 1,
      1, 1, 1, AllocateParameters(type, allocation, allow_large_objects));
1814 1815
}

1816 1817 1818
#define SPECULATIVE_NUMBER_BINOP(Name)                                        \
  const Operator* SimplifiedOperatorBuilder::Name(NumberOperationHint hint) { \
    switch (hint) {                                                           \
1819 1820 1821 1822
      case NumberOperationHint::kSignedSmall:                                 \
        return &cache_.k##Name##SignedSmallOperator;                          \
      case NumberOperationHint::kSignedSmallInputs:                           \
        return &cache_.k##Name##SignedSmallInputsOperator;                    \
1823 1824
      case NumberOperationHint::kNumber:                                      \
        return &cache_.k##Name##NumberOperator;                               \
1825 1826 1827
      case NumberOperationHint::kNumberOrBoolean:                             \
        /* Not used currenly. */                                              \
        UNREACHABLE();                                                        \
1828 1829 1830 1831 1832
      case NumberOperationHint::kNumberOrOddball:                             \
        return &cache_.k##Name##NumberOrOddballOperator;                      \
    }                                                                         \
    UNREACHABLE();                                                            \
    return nullptr;                                                           \
1833
  }
1834 1835 1836
SIMPLIFIED_SPECULATIVE_NUMBER_BINOP_LIST(SPECULATIVE_NUMBER_BINOP)
SPECULATIVE_NUMBER_BINOP(SpeculativeNumberLessThan)
SPECULATIVE_NUMBER_BINOP(SpeculativeNumberLessThanOrEqual)
1837
#undef SPECULATIVE_NUMBER_BINOP
1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854
const Operator* SimplifiedOperatorBuilder::SpeculativeNumberEqual(
    NumberOperationHint hint) {
  switch (hint) {
    case NumberOperationHint::kSignedSmall:
      return &cache_.kSpeculativeNumberEqualSignedSmallOperator;
    case NumberOperationHint::kSignedSmallInputs:
      return &cache_.kSpeculativeNumberEqualSignedSmallInputsOperator;
    case NumberOperationHint::kNumber:
      return &cache_.kSpeculativeNumberEqualNumberOperator;
    case NumberOperationHint::kNumberOrBoolean:
      return &cache_.kSpeculativeNumberEqualNumberOrBooleanOperator;
    case NumberOperationHint::kNumberOrOddball:
      return &cache_.kSpeculativeNumberEqualNumberOrOddballOperator;
  }
  UNREACHABLE();
  return nullptr;
}
1855

1856 1857 1858 1859 1860 1861
#define ACCESS_OP_LIST(V)                                                \
  V(LoadField, FieldAccess, Operator::kNoWrite, 1, 1, 1)                 \
  V(StoreField, FieldAccess, Operator::kNoRead, 2, 1, 0)                 \
  V(LoadElement, ElementAccess, Operator::kNoWrite, 2, 1, 1)             \
  V(StoreElement, ElementAccess, Operator::kNoRead, 3, 1, 0)             \
  V(LoadTypedElement, ExternalArrayType, Operator::kNoWrite, 4, 1, 1)    \
1862
  V(LoadFromObject, ObjectAccess, Operator::kNoWrite, 2, 1, 1)           \
1863
  V(StoreTypedElement, ExternalArrayType, Operator::kNoRead, 5, 1, 0)    \
1864
  V(StoreToObject, ObjectAccess, Operator::kNoRead, 3, 1, 0)             \
1865 1866
  V(LoadDataViewElement, ExternalArrayType, Operator::kNoWrite, 4, 1, 1) \
  V(StoreDataViewElement, ExternalArrayType, Operator::kNoRead, 5, 1, 0)
1867 1868 1869 1870

#define ACCESS(Name, Type, properties, value_input_count, control_input_count, \
               output_count)                                                   \
  const Operator* SimplifiedOperatorBuilder::Name(const Type& access) {        \
1871 1872 1873 1874 1875
    return zone()->New<Operator1<Type>>(                                       \
        IrOpcode::k##Name,                                                     \
        Operator::kNoDeopt | Operator::kNoThrow | properties, #Name,           \
        value_input_count, 1, control_input_count, output_count, 1, 0,         \
        access);                                                               \
1876 1877 1878 1879
  }
ACCESS_OP_LIST(ACCESS)
#undef ACCESS

1880
const Operator* SimplifiedOperatorBuilder::LoadMessage() {
1881
  return zone()->New<Operator>(IrOpcode::kLoadMessage, Operator::kEliminatable,
1882
                               "LoadMessage", 1, 1, 1, 1, 1, 0);
1883 1884 1885
}

const Operator* SimplifiedOperatorBuilder::StoreMessage() {
1886 1887 1888 1889
  return zone()->New<Operator>(
      IrOpcode::kStoreMessage,
      Operator::kNoDeopt | Operator::kNoThrow | Operator::kNoRead,
      "StoreMessage", 2, 1, 1, 0, 1, 0);
1890 1891
}

1892 1893 1894 1895
const Operator* SimplifiedOperatorBuilder::LoadStackArgument() {
  return &cache_.kLoadStackArgument;
}

1896 1897 1898
const Operator* SimplifiedOperatorBuilder::TransitionAndStoreElement(
    Handle<Map> double_map, Handle<Map> fast_map) {
  TransitionAndStoreElementParameters parameters(double_map, fast_map);
1899
  return zone()->New<Operator1<TransitionAndStoreElementParameters>>(
1900 1901 1902 1903 1904
      IrOpcode::kTransitionAndStoreElement,
      Operator::kNoDeopt | Operator::kNoThrow, "TransitionAndStoreElement", 3,
      1, 1, 0, 1, 0, parameters);
}

1905
const Operator* SimplifiedOperatorBuilder::StoreSignedSmallElement() {
1906
  return zone()->New<Operator>(IrOpcode::kStoreSignedSmallElement,
1907 1908 1909 1910
                               Operator::kNoDeopt | Operator::kNoThrow,
                               "StoreSignedSmallElement", 3, 1, 1, 0, 1, 0);
}

1911 1912 1913
const Operator* SimplifiedOperatorBuilder::TransitionAndStoreNumberElement(
    Handle<Map> double_map) {
  TransitionAndStoreNumberElementParameters parameters(double_map);
1914
  return zone()->New<Operator1<TransitionAndStoreNumberElementParameters>>(
1915 1916 1917 1918 1919 1920
      IrOpcode::kTransitionAndStoreNumberElement,
      Operator::kNoDeopt | Operator::kNoThrow,
      "TransitionAndStoreNumberElement", 3, 1, 1, 0, 1, 0, parameters);
}

const Operator* SimplifiedOperatorBuilder::TransitionAndStoreNonNumberElement(
1921
    Handle<Map> fast_map, Type value_type) {
1922
  TransitionAndStoreNonNumberElementParameters parameters(fast_map, value_type);
1923
  return zone()->New<Operator1<TransitionAndStoreNonNumberElementParameters>>(
1924 1925 1926 1927 1928
      IrOpcode::kTransitionAndStoreNonNumberElement,
      Operator::kNoDeopt | Operator::kNoThrow,
      "TransitionAndStoreNonNumberElement", 3, 1, 1, 0, 1, 0, parameters);
}

1929 1930 1931 1932 1933 1934 1935 1936
const Operator* SimplifiedOperatorBuilder::FastApiCall(
    const CFunctionInfo* signature, FeedbackSource const& feedback,
    CallDescriptor* descriptor) {
  int value_input_count =
      (signature->ArgumentCount() +
       FastApiCallNode::kFastTargetInputCount) +        // fast call
      static_cast<int>(descriptor->ParameterCount()) +  // slow call
      FastApiCallNode::kEffectAndControlInputCount;
1937
  return zone()->New<Operator1<FastApiCallParameters>>(
1938 1939 1940 1941 1942
      IrOpcode::kFastApiCall, Operator::kNoThrow, "FastApiCall",
      value_input_count, 1, 1, 1, 1, 0,
      FastApiCallParameters(signature, feedback, descriptor));
}

1943 1944 1945 1946 1947
int FastApiCallNode::FastCallExtraInputCount() const {
  return kFastTargetInputCount + kEffectAndControlInputCount +
         (Parameters().signature()->HasOptions() ? 1 : 0);
}

1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962
int FastApiCallNode::FastCallArgumentCount() const {
  FastApiCallParameters p = FastApiCallParametersOf(node()->op());
  const CFunctionInfo* signature = p.signature();
  CHECK_NOT_NULL(signature);
  return signature->ArgumentCount();
}

int FastApiCallNode::SlowCallArgumentCount() const {
  FastApiCallParameters p = FastApiCallParametersOf(node()->op());
  CallDescriptor* descriptor = p.descriptor();
  CHECK_NOT_NULL(descriptor);
  return static_cast<int>(descriptor->ParameterCount()) +
         kContextAndFrameStateInputCount;
}

1963
#undef PURE_OP_LIST
1964
#undef EFFECT_DEPENDENT_OP_LIST
1965
#undef SPECULATIVE_NUMBER_BINOP_LIST
1966
#undef CHECKED_WITH_FEEDBACK_OP_LIST
1967
#undef CHECKED_BOUNDS_OP_LIST
1968 1969 1970
#undef CHECKED_OP_LIST
#undef ACCESS_OP_LIST

1971 1972 1973
}  // namespace compiler
}  // namespace internal
}  // namespace v8