simplified-operator.h 33.5 KB
Newer Older
1 2 3 4 5 6 7
// Copyright 2014 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.

#ifndef V8_COMPILER_SIMPLIFIED_OPERATOR_H_
#define V8_COMPILER_SIMPLIFIED_OPERATOR_H_

8 9
#include <iosfwd>

10
#include "src/base/compiler-specific.h"
11
#include "src/codegen/machine-type.h"
12
#include "src/common/globals.h"
13
#include "src/compiler/feedback-source.h"
14
#include "src/compiler/operator.h"
15
#include "src/compiler/types.h"
16
#include "src/compiler/write-barrier-kind.h"
17
#include "src/deoptimizer/deoptimize-reason.h"
18 19
#include "src/handles/handles.h"
#include "src/handles/maybe-handles.h"
20
#include "src/objects/objects.h"
21
#include "src/objects/type-hints.h"
22
#include "src/zone/zone-handle-set.h"
23 24 25

namespace v8 {
namespace internal {
26 27

// Forward declarations.
28
enum class AbortReason : uint8_t;
29
class Zone;
30

31 32
namespace compiler {

33 34
// Forward declarations.
class Operator;
35
struct SimplifiedOperatorGlobalCache;
36

37
enum BaseTaggedness : uint8_t { kUntaggedBase, kTaggedBase };
38

39
size_t hash_value(BaseTaggedness);
40

41
std::ostream& operator<<(std::ostream&, BaseTaggedness);
42

43 44 45 46
size_t hash_value(LoadSensitivity);

std::ostream& operator<<(std::ostream&, LoadSensitivity);

47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
struct ConstFieldInfo {
  // the map that introduced the const field, if any. An access is considered
  // mutable iff the handle is null.
  MaybeHandle<Map> owner_map;

  ConstFieldInfo() : owner_map(MaybeHandle<Map>()) {}
  explicit ConstFieldInfo(Handle<Map> owner_map) : owner_map(owner_map) {}

  bool IsConst() const { return !owner_map.is_null(); }

  // No const field owner, i.e., a mutable field
  static ConstFieldInfo None() { return ConstFieldInfo(); }
};

V8_EXPORT_PRIVATE bool operator==(ConstFieldInfo const&, ConstFieldInfo const&);

size_t hash_value(ConstFieldInfo const&);

V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
                                           ConstFieldInfo const&);

68 69 70
// An access descriptor for loads/stores of fixed structures like field
// accesses of heap objects. Accesses from either tagged or untagged base
// pointers are supported; untagging is done automatically during lowering.
71
struct FieldAccess {
72 73
  BaseTaggedness base_is_tagged;  // specifies if the base pointer is tagged.
  int offset;                     // offset of the field, without tag.
74
  MaybeHandle<Name> name;         // debugging only.
75
  MaybeHandle<Map> map;           // map of the field value (if known).
76
  Type type;                      // type of the field.
77
  MachineType machine_type;       // machine type of the field.
78
  WriteBarrierKind write_barrier_kind;  // write barrier hint.
79
  LoadSensitivity load_sensitivity;     // load safety for poisoning.
80 81
  ConstFieldInfo const_field_info;      // the constness of this access, and the
                                    // field owner map, if the access is const
82
  bool is_store_in_literal;  // originates from a kStoreInLiteral access
83

84 85 86 87 88
  FieldAccess()
      : base_is_tagged(kTaggedBase),
        offset(0),
        type(Type::None()),
        machine_type(MachineType::None()),
89
        write_barrier_kind(kFullWriteBarrier),
90
        load_sensitivity(LoadSensitivity::kUnsafe),
91 92
        const_field_info(ConstFieldInfo::None()),
        is_store_in_literal(false) {}
93 94

  FieldAccess(BaseTaggedness base_is_tagged, int offset, MaybeHandle<Name> name,
95
              MaybeHandle<Map> map, Type type, MachineType machine_type,
96
              WriteBarrierKind write_barrier_kind,
97
              LoadSensitivity load_sensitivity = LoadSensitivity::kUnsafe,
98 99
              ConstFieldInfo const_field_info = ConstFieldInfo::None(),
              bool is_store_in_literal = false)
100 101 102 103 104 105
      : base_is_tagged(base_is_tagged),
        offset(offset),
        name(name),
        map(map),
        type(type),
        machine_type(machine_type),
106
        write_barrier_kind(write_barrier_kind),
107
        load_sensitivity(load_sensitivity),
108 109
        const_field_info(const_field_info),
        is_store_in_literal(is_store_in_literal) {}
110

111
  int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
112 113
};

114
V8_EXPORT_PRIVATE bool operator==(FieldAccess const&, FieldAccess const&);
115 116

size_t hash_value(FieldAccess const&);
117

118
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, FieldAccess const&);
119

120
V8_EXPORT_PRIVATE FieldAccess const& FieldAccessOf(const Operator* op)
121
    V8_WARN_UNUSED_RESULT;
122

123 124 125
template <>
void Operator1<FieldAccess>::PrintParameter(std::ostream& os,
                                            PrintVerbosity verbose) const;
126

127 128 129 130
// An access descriptor for loads/stores of indexed structures like characters
// in strings or off-heap backing stores. Accesses from either tagged or
// untagged base pointers are supported; untagging is done automatically during
// lowering.
131
struct ElementAccess {
132 133
  BaseTaggedness base_is_tagged;  // specifies if the base pointer is tagged.
  int header_size;                // size of the header, without tag.
134
  Type type;                      // type of the element.
135
  MachineType machine_type;       // machine type of the element.
136
  WriteBarrierKind write_barrier_kind;  // write barrier hint.
137
  LoadSensitivity load_sensitivity;     // load safety for poisoning.
138

139 140 141 142 143
  ElementAccess()
      : base_is_tagged(kTaggedBase),
        header_size(0),
        type(Type::None()),
        machine_type(MachineType::None()),
144 145
        write_barrier_kind(kFullWriteBarrier),
        load_sensitivity(LoadSensitivity::kUnsafe) {}
146

147
  ElementAccess(BaseTaggedness base_is_tagged, int header_size, Type type,
148 149
                MachineType machine_type, WriteBarrierKind write_barrier_kind,
                LoadSensitivity load_sensitivity = LoadSensitivity::kUnsafe)
150 151 152 153
      : base_is_tagged(base_is_tagged),
        header_size(header_size),
        type(type),
        machine_type(machine_type),
154 155
        write_barrier_kind(write_barrier_kind),
        load_sensitivity(load_sensitivity) {}
156

157
  int tag() const { return base_is_tagged == kTaggedBase ? kHeapObjectTag : 0; }
158 159
};

160
V8_EXPORT_PRIVATE bool operator==(ElementAccess const&, ElementAccess const&);
161 162

size_t hash_value(ElementAccess const&);
163

164
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ElementAccess const&);
165

166
V8_EXPORT_PRIVATE ElementAccess const& ElementAccessOf(const Operator* op)
167
    V8_WARN_UNUSED_RESULT;
168

169
ExternalArrayType ExternalArrayTypeOf(const Operator* op) V8_WARN_UNUSED_RESULT;
170

171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
// An access descriptor for loads/stores of CSA-accessible structures.
struct ObjectAccess {
  MachineType machine_type;             // machine type of the field.
  WriteBarrierKind write_barrier_kind;  // write barrier hint.

  ObjectAccess()
      : machine_type(MachineType::None()),
        write_barrier_kind(kFullWriteBarrier) {}

  ObjectAccess(MachineType machine_type, WriteBarrierKind write_barrier_kind)
      : machine_type(machine_type), write_barrier_kind(write_barrier_kind) {}

  int tag() const { return kHeapObjectTag; }
};

V8_EXPORT_PRIVATE bool operator==(ObjectAccess const&, ObjectAccess const&);

size_t hash_value(ObjectAccess const&);

V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, ObjectAccess const&);

V8_EXPORT_PRIVATE ObjectAccess const& ObjectAccessOf(const Operator* op)
    V8_WARN_UNUSED_RESULT;

195
// The ConvertReceiverMode is used as parameter by ConvertReceiver operators.
196
ConvertReceiverMode ConvertReceiverModeOf(Operator const* op)
197
    V8_WARN_UNUSED_RESULT;
198

199 200 201 202 203
// A the parameters for several Check nodes. The {feedback} parameter is
// optional. If {feedback} references a valid CallIC slot and this MapCheck
// fails, then speculation on that CallIC slot will be disabled.
class CheckParameters final {
 public:
204
  explicit CheckParameters(const FeedbackSource& feedback)
205 206
      : feedback_(feedback) {}

207
  FeedbackSource const& feedback() const { return feedback_; }
208 209

 private:
210
  FeedbackSource feedback_;
211 212 213 214 215 216 217 218
};

bool operator==(CheckParameters const&, CheckParameters const&);

size_t hash_value(CheckParameters const&);

std::ostream& operator<<(std::ostream&, CheckParameters const&);

219
CheckParameters const& CheckParametersOf(Operator const*) V8_WARN_UNUSED_RESULT;
220

221 222 223 224
class CheckBoundsParameters final {
 public:
  enum Mode { kAbortOnOutOfBounds, kDeoptOnOutOfBounds };

225
  CheckBoundsParameters(const FeedbackSource& feedback, Mode mode)
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244
      : check_parameters_(feedback), mode_(mode) {}

  Mode mode() const { return mode_; }
  const CheckParameters& check_parameters() const { return check_parameters_; }

 private:
  CheckParameters check_parameters_;
  Mode mode_;
};

bool operator==(CheckBoundsParameters const&, CheckBoundsParameters const&);

size_t hash_value(CheckBoundsParameters const&);

std::ostream& operator<<(std::ostream&, CheckBoundsParameters const&);

CheckBoundsParameters const& CheckBoundsParametersOf(Operator const*)
    V8_WARN_UNUSED_RESULT;

245 246 247
class CheckIfParameters final {
 public:
  explicit CheckIfParameters(DeoptimizeReason reason,
248
                             const FeedbackSource& feedback)
249 250
      : reason_(reason), feedback_(feedback) {}

251
  FeedbackSource const& feedback() const { return feedback_; }
252 253 254 255
  DeoptimizeReason reason() const { return reason_; }

 private:
  DeoptimizeReason reason_;
256
  FeedbackSource feedback_;
257 258 259 260 261 262 263 264 265 266 267
};

bool operator==(CheckIfParameters const&, CheckIfParameters const&);

size_t hash_value(CheckIfParameters const&);

std::ostream& operator<<(std::ostream&, CheckIfParameters const&);

CheckIfParameters const& CheckIfParametersOf(Operator const*)
    V8_WARN_UNUSED_RESULT;

268 269 270 271 272 273 274 275 276
enum class CheckFloat64HoleMode : uint8_t {
  kNeverReturnHole,  // Never return the hole (deoptimize instead).
  kAllowReturnHole   // Allow to return the hole (signaling NaN).
};

size_t hash_value(CheckFloat64HoleMode);

std::ostream& operator<<(std::ostream&, CheckFloat64HoleMode);

277 278 279
class CheckFloat64HoleParameters {
 public:
  CheckFloat64HoleParameters(CheckFloat64HoleMode mode,
280
                             FeedbackSource const& feedback)
281 282 283
      : mode_(mode), feedback_(feedback) {}

  CheckFloat64HoleMode mode() const { return mode_; }
284
  FeedbackSource const& feedback() const { return feedback_; }
285 286 287

 private:
  CheckFloat64HoleMode mode_;
288
  FeedbackSource feedback_;
289 290 291
};

CheckFloat64HoleParameters const& CheckFloat64HoleParametersOf(Operator const*)
292
    V8_WARN_UNUSED_RESULT;
293

294 295 296 297 298 299 300 301 302
std::ostream& operator<<(std::ostream&, CheckFloat64HoleParameters const&);

size_t hash_value(CheckFloat64HoleParameters const&);

bool operator==(CheckFloat64HoleParameters const&,
                CheckFloat64HoleParameters const&);
bool operator!=(CheckFloat64HoleParameters const&,
                CheckFloat64HoleParameters const&);

303 304 305 306 307 308 309
enum class CheckTaggedInputMode : uint8_t {
  kNumber,
  kNumberOrOddball,
};

size_t hash_value(CheckTaggedInputMode);

310
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, CheckTaggedInputMode);
311

312 313 314
class CheckTaggedInputParameters {
 public:
  CheckTaggedInputParameters(CheckTaggedInputMode mode,
315
                             const FeedbackSource& feedback)
316 317 318
      : mode_(mode), feedback_(feedback) {}

  CheckTaggedInputMode mode() const { return mode_; }
319
  const FeedbackSource& feedback() const { return feedback_; }
320 321 322

 private:
  CheckTaggedInputMode mode_;
323
  FeedbackSource feedback_;
324 325 326
};

const CheckTaggedInputParameters& CheckTaggedInputParametersOf(const Operator*)
327
    V8_WARN_UNUSED_RESULT;
328 329 330 331 332 333 334 335

std::ostream& operator<<(std::ostream&,
                         const CheckTaggedInputParameters& params);

size_t hash_value(const CheckTaggedInputParameters& params);

bool operator==(CheckTaggedInputParameters const&,
                CheckTaggedInputParameters const&);
336

337 338 339 340 341 342 343
enum class CheckForMinusZeroMode : uint8_t {
  kCheckForMinusZero,
  kDontCheckForMinusZero,
};

size_t hash_value(CheckForMinusZeroMode);

344 345
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
                                           CheckForMinusZeroMode);
346

347 348
CheckForMinusZeroMode CheckMinusZeroModeOf(const Operator*)
    V8_WARN_UNUSED_RESULT;
349

350 351 352
class CheckMinusZeroParameters {
 public:
  CheckMinusZeroParameters(CheckForMinusZeroMode mode,
353
                           const FeedbackSource& feedback)
354 355 356
      : mode_(mode), feedback_(feedback) {}

  CheckForMinusZeroMode mode() const { return mode_; }
357
  const FeedbackSource& feedback() const { return feedback_; }
358 359 360

 private:
  CheckForMinusZeroMode mode_;
361
  FeedbackSource feedback_;
362 363
};

364 365
V8_EXPORT_PRIVATE const CheckMinusZeroParameters& CheckMinusZeroParametersOf(
    const Operator* op) V8_WARN_UNUSED_RESULT;
366

367 368
V8_EXPORT_PRIVATE std::ostream& operator<<(
    std::ostream&, const CheckMinusZeroParameters& params);
369 370 371 372 373 374

size_t hash_value(const CheckMinusZeroParameters& params);

bool operator==(CheckMinusZeroParameters const&,
                CheckMinusZeroParameters const&);

375 376 377 378 379
// Flags for map checks.
enum class CheckMapsFlag : uint8_t {
  kNone = 0u,
  kTryMigrateInstance = 1u << 0,  // Try instance migration.
};
380
using CheckMapsFlags = base::Flags<CheckMapsFlag>;
381 382 383 384 385

DEFINE_OPERATORS_FOR_FLAGS(CheckMapsFlags)

std::ostream& operator<<(std::ostream&, CheckMapsFlags);

386 387 388
// A descriptor for map checks. The {feedback} parameter is optional.
// If {feedback} references a valid CallIC slot and this MapCheck fails,
// then speculation on that CallIC slot will be disabled.
389 390
class CheckMapsParameters final {
 public:
391
  CheckMapsParameters(CheckMapsFlags flags, ZoneHandleSet<Map> const& maps,
392
                      const FeedbackSource& feedback)
393
      : flags_(flags), maps_(maps), feedback_(feedback) {}
394

395
  CheckMapsFlags flags() const { return flags_; }
396
  ZoneHandleSet<Map> const& maps() const { return maps_; }
397
  FeedbackSource const& feedback() const { return feedback_; }
398 399

 private:
400
  CheckMapsFlags const flags_;
401
  ZoneHandleSet<Map> const maps_;
402
  FeedbackSource const feedback_;
403 404 405 406 407 408 409 410 411
};

bool operator==(CheckMapsParameters const&, CheckMapsParameters const&);

size_t hash_value(CheckMapsParameters const&);

std::ostream& operator<<(std::ostream&, CheckMapsParameters const&);

CheckMapsParameters const& CheckMapsParametersOf(Operator const*)
412
    V8_WARN_UNUSED_RESULT;
413

414
ZoneHandleSet<Map> const& MapGuardMapsOf(Operator const*) V8_WARN_UNUSED_RESULT;
415

416
// Parameters for CompareMaps operator.
417
ZoneHandleSet<Map> const& CompareMapsParametersOf(Operator const*)
418
    V8_WARN_UNUSED_RESULT;
419

420
// A descriptor for growing elements backing stores.
421 422 423
enum class GrowFastElementsMode : uint8_t {
  kDoubleElements,
  kSmiOrObjectElements
424 425
};

426 427 428
inline size_t hash_value(GrowFastElementsMode mode) {
  return static_cast<uint8_t>(mode);
}
429

430
std::ostream& operator<<(std::ostream&, GrowFastElementsMode);
431

432 433 434
class GrowFastElementsParameters {
 public:
  GrowFastElementsParameters(GrowFastElementsMode mode,
435
                             const FeedbackSource& feedback)
436 437 438
      : mode_(mode), feedback_(feedback) {}

  GrowFastElementsMode mode() const { return mode_; }
439
  const FeedbackSource& feedback() const { return feedback_; }
440 441 442

 private:
  GrowFastElementsMode mode_;
443
  FeedbackSource feedback_;
444 445 446 447 448 449 450 451 452 453
};

bool operator==(const GrowFastElementsParameters&,
                const GrowFastElementsParameters&);

inline size_t hash_value(const GrowFastElementsParameters&);

std::ostream& operator<<(std::ostream&, const GrowFastElementsParameters&);

const GrowFastElementsParameters& GrowFastElementsParametersOf(const Operator*)
454
    V8_WARN_UNUSED_RESULT;
455

456
// A descriptor for elements kind transitions.
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474
class ElementsTransition final {
 public:
  enum Mode : uint8_t {
    kFastTransition,  // simple transition, just updating the map.
    kSlowTransition   // full transition, round-trip to the runtime.
  };

  ElementsTransition(Mode mode, Handle<Map> source, Handle<Map> target)
      : mode_(mode), source_(source), target_(target) {}

  Mode mode() const { return mode_; }
  Handle<Map> source() const { return source_; }
  Handle<Map> target() const { return target_; }

 private:
  Mode const mode_;
  Handle<Map> const source_;
  Handle<Map> const target_;
475 476
};

477 478
bool operator==(ElementsTransition const&, ElementsTransition const&);

479 480
size_t hash_value(ElementsTransition);

481 482
std::ostream& operator<<(std::ostream&, ElementsTransition);

483
ElementsTransition const& ElementsTransitionOf(const Operator* op)
484
    V8_WARN_UNUSED_RESULT;
485

486 487 488
// Parameters for TransitionAndStoreElement, or
// TransitionAndStoreNonNumberElement, or
// TransitionAndStoreNumberElement.
489 490
Handle<Map> DoubleMapParameterOf(const Operator* op) V8_WARN_UNUSED_RESULT;
Handle<Map> FastMapParameterOf(const Operator* op) V8_WARN_UNUSED_RESULT;
491

492
// Parameters for TransitionAndStoreNonNumberElement.
493
Type ValueTypeParameterOf(const Operator* op) V8_WARN_UNUSED_RESULT;
494

495 496
// A hint for speculative number operations.
enum class NumberOperationHint : uint8_t {
497 498 499 500 501
  kSignedSmall,        // Inputs were Smi, output was in Smi.
  kSignedSmallInputs,  // Inputs were Smi, output was Number.
  kSigned32,           // Inputs were Signed32, output was Number.
  kNumber,             // Inputs were Number, output was Number.
  kNumberOrOddball,    // Inputs were Number or Oddball, output was Number.
502 503
};

504 505 506 507
enum class BigIntOperationHint : uint8_t {
  kBigInt,
};

508
size_t hash_value(NumberOperationHint);
509
size_t hash_value(BigIntOperationHint);
510

511
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, NumberOperationHint);
512
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, BigIntOperationHint);
513
V8_EXPORT_PRIVATE NumberOperationHint NumberOperationHintOf(const Operator* op)
514 515
    V8_WARN_UNUSED_RESULT;

516 517 518
class NumberOperationParameters {
 public:
  NumberOperationParameters(NumberOperationHint hint,
519
                            const FeedbackSource& feedback)
520 521 522
      : hint_(hint), feedback_(feedback) {}

  NumberOperationHint hint() const { return hint_; }
523
  const FeedbackSource& feedback() const { return feedback_; }
524 525 526

 private:
  NumberOperationHint hint_;
527
  FeedbackSource feedback_;
528 529 530 531 532 533 534 535
};

size_t hash_value(NumberOperationParameters const&);
V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&,
                                           const NumberOperationParameters&);
bool operator==(NumberOperationParameters const&,
                NumberOperationParameters const&);
const NumberOperationParameters& NumberOperationParametersOf(const Operator* op)
536
    V8_WARN_UNUSED_RESULT;
537

538 539
int FormalParameterCountOf(const Operator* op) V8_WARN_UNUSED_RESULT;
bool IsRestLengthOf(const Operator* op) V8_WARN_UNUSED_RESULT;
540

541 542
class AllocateParameters {
 public:
543 544 545 546 547 548
  AllocateParameters(
      Type type, AllocationType allocation_type,
      AllowLargeObjects allow_large_objects = AllowLargeObjects::kFalse)
      : type_(type),
        allocation_type_(allocation_type),
        allow_large_objects_(allow_large_objects) {}
549

550
  Type type() const { return type_; }
551
  AllocationType allocation_type() const { return allocation_type_; }
552
  AllowLargeObjects allow_large_objects() const { return allow_large_objects_; }
553 554

 private:
555
  Type type_;
556
  AllocationType allocation_type_;
557
  AllowLargeObjects allow_large_objects_;
558 559
};

560 561
bool IsCheckedWithFeedback(const Operator* op);

562 563 564 565 566 567
size_t hash_value(AllocateParameters);

V8_EXPORT_PRIVATE std::ostream& operator<<(std::ostream&, AllocateParameters);

bool operator==(AllocateParameters const&, AllocateParameters const&);

568 569 570
const AllocateParameters& AllocateParametersOf(const Operator* op)
    V8_WARN_UNUSED_RESULT;

571
AllocationType AllocationTypeOf(const Operator* op) V8_WARN_UNUSED_RESULT;
572

573
Type AllocateTypeOf(const Operator* op) V8_WARN_UNUSED_RESULT;
574

575
UnicodeEncoding UnicodeEncodingOf(const Operator*) V8_WARN_UNUSED_RESULT;
576

577
AbortReason AbortReasonOf(const Operator* op) V8_WARN_UNUSED_RESULT;
578

579
DeoptimizeReason DeoptimizeReasonOf(const Operator* op) V8_WARN_UNUSED_RESULT;
580

581
int NewArgumentsElementsMappedCountOf(const Operator* op) V8_WARN_UNUSED_RESULT;
582

583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604
// Interface for building simplified operators, which represent the
// medium-level operations of V8, including adding numbers, allocating objects,
// indexing into objects and arrays, etc.
// All operators are typed but many are representation independent.

// Number values from JS can be in one of these representations:
//   - Tagged: word-sized integer that is either
//     - a signed small integer (31 or 32 bits plus a tag)
//     - a tagged pointer to a HeapNumber object that has a float64 field
//   - Int32: an untagged signed 32-bit integer
//   - Uint32: an untagged unsigned 32-bit integer
//   - Float64: an untagged float64

// Additional representations for intermediate code or non-JS code:
//   - Int64: an untagged signed 64-bit integer
//   - Uint64: an untagged unsigned 64-bit integer
//   - Float32: an untagged float32

// Boolean values can be:
//   - Bool: a tagged pointer to either the canonical JS #false or
//           the canonical JS #true object
//   - Bit: an untagged integer 0 or 1, but word-sized
605 606
class V8_EXPORT_PRIVATE SimplifiedOperatorBuilder final
    : public NON_EXPORTED_BASE(ZoneObject) {
607
 public:
608 609
  explicit SimplifiedOperatorBuilder(Zone* zone);

610 611 612
  const Operator* BooleanNot();

  const Operator* NumberEqual();
613
  const Operator* NumberSameValue();
614 615 616 617 618 619 620
  const Operator* NumberLessThan();
  const Operator* NumberLessThanOrEqual();
  const Operator* NumberAdd();
  const Operator* NumberSubtract();
  const Operator* NumberMultiply();
  const Operator* NumberDivide();
  const Operator* NumberModulus();
621 622 623
  const Operator* NumberBitwiseOr();
  const Operator* NumberBitwiseXor();
  const Operator* NumberBitwiseAnd();
624 625 626
  const Operator* NumberShiftLeft();
  const Operator* NumberShiftRight();
  const Operator* NumberShiftRightLogical();
627
  const Operator* NumberImul();
628
  const Operator* NumberAbs();
629
  const Operator* NumberClz32();
630
  const Operator* NumberCeil();
631
  const Operator* NumberFloor();
632
  const Operator* NumberFround();
633 634 635 636
  const Operator* NumberAcos();
  const Operator* NumberAcosh();
  const Operator* NumberAsin();
  const Operator* NumberAsinh();
637 638
  const Operator* NumberAtan();
  const Operator* NumberAtan2();
639
  const Operator* NumberAtanh();
640 641
  const Operator* NumberCbrt();
  const Operator* NumberCos();
642
  const Operator* NumberCosh();
643
  const Operator* NumberExp();
644
  const Operator* NumberExpm1();
645
  const Operator* NumberLog();
646
  const Operator* NumberLog1p();
647
  const Operator* NumberLog10();
648
  const Operator* NumberLog2();
649 650
  const Operator* NumberMax();
  const Operator* NumberMin();
651
  const Operator* NumberPow();
652
  const Operator* NumberRound();
653
  const Operator* NumberSign();
654
  const Operator* NumberSin();
655
  const Operator* NumberSinh();
656
  const Operator* NumberSqrt();
657
  const Operator* NumberTan();
658
  const Operator* NumberTanh();
659
  const Operator* NumberTrunc();
660
  const Operator* NumberToBoolean();
661
  const Operator* NumberToInt32();
662
  const Operator* NumberToString();
663
  const Operator* NumberToUint32();
664
  const Operator* NumberToUint8Clamped();
665

666 667
  const Operator* NumberSilenceNaN();

668
  const Operator* BigIntAdd();
669
  const Operator* BigIntSubtract();
670 671
  const Operator* BigIntNegate();

672 673 674
  const Operator* SpeculativeSafeIntegerAdd(NumberOperationHint hint);
  const Operator* SpeculativeSafeIntegerSubtract(NumberOperationHint hint);

675 676 677 678 679 680 681 682 683 684 685 686 687 688 689
  const Operator* SpeculativeNumberAdd(NumberOperationHint hint);
  const Operator* SpeculativeNumberSubtract(NumberOperationHint hint);
  const Operator* SpeculativeNumberMultiply(NumberOperationHint hint);
  const Operator* SpeculativeNumberDivide(NumberOperationHint hint);
  const Operator* SpeculativeNumberModulus(NumberOperationHint hint);
  const Operator* SpeculativeNumberShiftLeft(NumberOperationHint hint);
  const Operator* SpeculativeNumberShiftRight(NumberOperationHint hint);
  const Operator* SpeculativeNumberShiftRightLogical(NumberOperationHint hint);
  const Operator* SpeculativeNumberBitwiseAnd(NumberOperationHint hint);
  const Operator* SpeculativeNumberBitwiseOr(NumberOperationHint hint);
  const Operator* SpeculativeNumberBitwiseXor(NumberOperationHint hint);

  const Operator* SpeculativeNumberLessThan(NumberOperationHint hint);
  const Operator* SpeculativeNumberLessThanOrEqual(NumberOperationHint hint);
  const Operator* SpeculativeNumberEqual(NumberOperationHint hint);
690

691
  const Operator* SpeculativeBigIntAdd(BigIntOperationHint hint);
692
  const Operator* SpeculativeBigIntSubtract(BigIntOperationHint hint);
693
  const Operator* SpeculativeBigIntNegate(BigIntOperationHint hint);
694
  const Operator* BigIntAsUintN(int bits);
695

696
  const Operator* ReferenceEqual();
697
  const Operator* SameValue();
698
  const Operator* SameValueNumbersOnly();
699

700 701
  const Operator* TypeOf();

702
  const Operator* ToBoolean();
703

704
  const Operator* StringConcat();
705 706 707
  const Operator* StringEqual();
  const Operator* StringLessThan();
  const Operator* StringLessThanOrEqual();
708
  const Operator* StringCharCodeAt();
709
  const Operator* StringCodePointAt();
710
  const Operator* StringFromSingleCharCode();
711 712
  const Operator* StringFromSingleCodePoint();
  const Operator* StringFromCodePointAt();
713
  const Operator* StringIndexOf();
714
  const Operator* StringLength();
715 716
  const Operator* StringToLowerCaseIntl();
  const Operator* StringToUpperCaseIntl();
717
  const Operator* StringSubstring();
718

719
  const Operator* FindOrderedHashMapEntry();
720
  const Operator* FindOrderedHashMapEntryForInt32Key();
721

722
  const Operator* SpeculativeToNumber(NumberOperationHint hint,
723
                                      const FeedbackSource& feedback);
724

725
  const Operator* StringToNumber();
726 727 728 729
  const Operator* PlainPrimitiveToNumber();
  const Operator* PlainPrimitiveToWord32();
  const Operator* PlainPrimitiveToFloat64();

730
  const Operator* ChangeTaggedSignedToInt32();
731
  const Operator* ChangeTaggedSignedToInt64();
732
  const Operator* ChangeTaggedToInt32();
733
  const Operator* ChangeTaggedToInt64();
734 735
  const Operator* ChangeTaggedToUint32();
  const Operator* ChangeTaggedToFloat64();
736
  const Operator* ChangeTaggedToTaggedSigned();
737
  const Operator* ChangeInt31ToTaggedSigned();
738
  const Operator* ChangeInt32ToTagged();
739
  const Operator* ChangeInt64ToTagged();
740
  const Operator* ChangeUint32ToTagged();
741
  const Operator* ChangeUint64ToTagged();
742
  const Operator* ChangeFloat64ToTagged(CheckForMinusZeroMode);
743
  const Operator* ChangeFloat64ToTaggedPointer();
744 745
  const Operator* ChangeTaggedToBit();
  const Operator* ChangeBitToTagged();
746 747
  const Operator* TruncateBigIntToUint64();
  const Operator* ChangeUint64ToBigInt();
748
  const Operator* TruncateTaggedToWord32();
749
  const Operator* TruncateTaggedToFloat64();
750
  const Operator* TruncateTaggedToBit();
751
  const Operator* TruncateTaggedPointerToBit();
752

753
  const Operator* PoisonIndex();
754
  const Operator* CompareMaps(ZoneHandleSet<Map>);
755
  const Operator* MapGuard(ZoneHandleSet<Map> maps);
756

757
  const Operator* CheckBounds(const FeedbackSource& feedback);
758 759
  const Operator* CheckEqualsInternalizedString();
  const Operator* CheckEqualsSymbol();
760
  const Operator* CheckFloat64Hole(CheckFloat64HoleMode, FeedbackSource const&);
761
  const Operator* CheckHeapObject();
762
  const Operator* CheckIf(DeoptimizeReason deoptimize_reason,
763
                          const FeedbackSource& feedback = FeedbackSource());
764
  const Operator* CheckInternalizedString();
765
  const Operator* CheckMaps(CheckMapsFlags, ZoneHandleSet<Map>,
766
                            const FeedbackSource& = FeedbackSource());
767
  const Operator* CheckNotTaggedHole();
768
  const Operator* CheckNumber(const FeedbackSource& feedback);
769
  const Operator* CheckReceiver();
770
  const Operator* CheckReceiverOrNullOrUndefined();
771 772
  const Operator* CheckSmi(const FeedbackSource& feedback);
  const Operator* CheckString(const FeedbackSource& feedback);
773
  const Operator* CheckSymbol();
774

775
  const Operator* CheckedFloat64ToInt32(CheckForMinusZeroMode,
776
                                        const FeedbackSource& feedback);
777
  const Operator* CheckedFloat64ToInt64(CheckForMinusZeroMode,
778
                                        const FeedbackSource& feedback);
779
  const Operator* CheckedInt32Add();
780 781
  const Operator* CheckedInt32Div();
  const Operator* CheckedInt32Mod();
782
  const Operator* CheckedInt32Mul(CheckForMinusZeroMode);
783
  const Operator* CheckedInt32Sub();
784 785 786 787
  const Operator* CheckedInt32ToTaggedSigned(const FeedbackSource& feedback);
  const Operator* CheckedInt64ToInt32(const FeedbackSource& feedback);
  const Operator* CheckedInt64ToTaggedSigned(const FeedbackSource& feedback);
  const Operator* CheckedTaggedSignedToInt32(const FeedbackSource& feedback);
788
  const Operator* CheckedTaggedToFloat64(CheckTaggedInputMode,
789
                                         const FeedbackSource& feedback);
790
  const Operator* CheckedTaggedToInt32(CheckForMinusZeroMode,
791
                                       const FeedbackSource& feedback);
792
  const Operator* CheckedTaggedToArrayIndex(const FeedbackSource& feedback);
793
  const Operator* CheckedTaggedToInt64(CheckForMinusZeroMode,
794 795 796 797
                                       const FeedbackSource& feedback);
  const Operator* CheckedTaggedToTaggedPointer(const FeedbackSource& feedback);
  const Operator* CheckedTaggedToTaggedSigned(const FeedbackSource& feedback);
  const Operator* CheckBigInt(const FeedbackSource& feedback);
798
  const Operator* CheckedTruncateTaggedToWord32(CheckTaggedInputMode,
799
                                                const FeedbackSource& feedback);
800 801
  const Operator* CheckedUint32Div();
  const Operator* CheckedUint32Mod();
802
  const Operator* CheckedUint32Bounds(const FeedbackSource& feedback,
803
                                      CheckBoundsParameters::Mode mode);
804 805 806 807 808
  const Operator* CheckedUint32ToInt32(const FeedbackSource& feedback);
  const Operator* CheckedUint32ToTaggedSigned(const FeedbackSource& feedback);
  const Operator* CheckedUint64Bounds(const FeedbackSource& feedback);
  const Operator* CheckedUint64ToInt32(const FeedbackSource& feedback);
  const Operator* CheckedUint64ToTaggedSigned(const FeedbackSource& feedback);
809

810 811
  const Operator* ConvertReceiver(ConvertReceiverMode);

812
  const Operator* ConvertTaggedHoleToUndefined();
813

814
  const Operator* ObjectIsArrayBufferView();
815
  const Operator* ObjectIsBigInt();
816
  const Operator* ObjectIsCallable();
817
  const Operator* ObjectIsConstructor();
818
  const Operator* ObjectIsDetectableCallable();
819
  const Operator* ObjectIsMinusZero();
820
  const Operator* NumberIsMinusZero();
821
  const Operator* ObjectIsNaN();
822
  const Operator* NumberIsNaN();
823
  const Operator* ObjectIsNonCallable();
824
  const Operator* ObjectIsNumber();
825
  const Operator* ObjectIsReceiver();
826
  const Operator* ObjectIsSmi();
827
  const Operator* ObjectIsString();
828
  const Operator* ObjectIsSymbol();
829
  const Operator* ObjectIsUndetectable();
830

831
  const Operator* NumberIsFloat64Hole();
832 833
  const Operator* NumberIsFinite();
  const Operator* ObjectIsFiniteNumber();
834
  const Operator* NumberIsInteger();
835 836
  const Operator* ObjectIsSafeInteger();
  const Operator* NumberIsSafeInteger();
837
  const Operator* ObjectIsInteger();
838

839 840 841
  const Operator* ArgumentsFrame();
  const Operator* ArgumentsLength(int formal_parameter_count,
                                  bool is_rest_length);
842

843 844
  const Operator* NewDoubleElements(AllocationType);
  const Operator* NewSmiOrObjectElements(AllocationType);
845

846 847
  // new-arguments-elements arguments-frame, arguments-length
  const Operator* NewArgumentsElements(int mapped_count);
848

849 850 851
  // new-cons-string length, first, second
  const Operator* NewConsString();

852 853 854
  // ensure-writable-fast-elements object, elements
  const Operator* EnsureWritableFastElements();

855
  // maybe-grow-fast-elements object, elements, index, length
856
  const Operator* MaybeGrowFastElements(GrowFastElementsMode mode,
857
                                        const FeedbackSource& feedback);
858

859 860 861
  // transition-elements-kind object, from-map, to-map
  const Operator* TransitionElementsKind(ElementsTransition transition);

862 863 864
  const Operator* Allocate(Type type,
                           AllocationType allocation = AllocationType::kYoung);
  const Operator* AllocateRaw(
865 866
      Type type, AllocationType allocation = AllocationType::kYoung,
      AllowLargeObjects allow_large_objects = AllowLargeObjects::kFalse);
867

868 869 870
  const Operator* LoadMessage();
  const Operator* StoreMessage();

871
  const Operator* LoadFieldByIndex();
872 873 874
  const Operator* LoadField(FieldAccess const&);
  const Operator* StoreField(FieldAccess const&);

875
  // load-element [base + index]
876 877
  const Operator* LoadElement(ElementAccess const&);

878 879 880
  // load-stack-argument [base + index]
  const Operator* LoadStackArgument();

881
  // store-element [base + index], value
882
  const Operator* StoreElement(ElementAccess const&);
883

884 885 886
  // store-element [base + index], value, only with fast arrays.
  const Operator* TransitionAndStoreElement(Handle<Map> double_map,
                                            Handle<Map> fast_map);
887 888
  // store-element [base + index], smi value, only with fast arrays.
  const Operator* StoreSignedSmallElement();
889

890 891 892 893 894
  // store-element [base + index], double value, only with fast arrays.
  const Operator* TransitionAndStoreNumberElement(Handle<Map> double_map);

  // store-element [base + index], object value, only with fast arrays.
  const Operator* TransitionAndStoreNonNumberElement(Handle<Map> fast_map,
895
                                                     Type value_type);
896

897 898 899 900 901 902
  // load-from-object [base + offset]
  const Operator* LoadFromObject(ObjectAccess const&);

  // store-to-object [base + offset], value
  const Operator* StoreToObject(ObjectAccess const&);

903 904 905
  // load-typed-element buffer, [base + external + index]
  const Operator* LoadTypedElement(ExternalArrayType const&);

906
  // load-data-view-element object, [base + index]
907 908
  const Operator* LoadDataViewElement(ExternalArrayType const&);

909 910 911
  // store-typed-element buffer, [base + external + index], value
  const Operator* StoreTypedElement(ExternalArrayType const&);

912
  // store-data-view-element object, [base + index], value
913 914
  const Operator* StoreDataViewElement(ExternalArrayType const&);

915
  // Abort (for terminating execution on internal error).
916
  const Operator* RuntimeAbort(AbortReason reason);
917

918 919 920
  // Abort if the value input does not inhabit the given type
  const Operator* AssertType(Type type);

921 922
  const Operator* DateNow();

923
 private:
924 925
  Zone* zone() const { return zone_; }

926
  const SimplifiedOperatorGlobalCache& cache_;
927 928 929
  Zone* const zone_;

  DISALLOW_COPY_AND_ASSIGN(SimplifiedOperatorBuilder);
930
};
931 932 933 934

}  // namespace compiler
}  // namespace internal
}  // namespace v8
935 936

#endif  // V8_COMPILER_SIMPLIFIED_OPERATOR_H_