chromium/v8/src/compiler/turboshaft/operations.cc

// Copyright 2022 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/turboshaft/operations.h"

#include <atomic>
#include <iomanip>
#include <optional>
#include <sstream>

#include "src/base/logging.h"
#include "src/base/platform/mutex.h"
#include "src/codegen/bailout-reason.h"
#include "src/codegen/machine-type.h"
#include "src/common/globals.h"
#include "src/compiler/backend/instruction-selector.h"
#include "src/compiler/frame-states.h"
#include "src/compiler/graph-visualizer.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/turboshaft/deopt-data.h"
#include "src/compiler/turboshaft/graph.h"
#include "src/handles/handles-inl.h"
#include "src/handles/maybe-handles-inl.h"
#include "src/objects/code-inl.h"

#ifdef DEBUG
// For InWritableSharedSpace
#include "src/objects/objects-inl.h"
#endif

namespace v8::internal {
std::ostream& operator<<(std::ostream& os, AbortReason reason) {}
}  // namespace v8::internal

namespace v8::internal::compiler::turboshaft {

void Operation::Print() const {}

Zone* get_zone(Graph* graph) {}

std::optional<Builtin> TryGetBuiltinId(const ConstantOp* target,
                                       JSHeapBroker* broker) {}

bool CallOp::IsStackCheck(const Graph& graph, JSHeapBroker* broker,
                          StackCheckKind kind) const {}

void CallOp::PrintOptions(std::ostream& os) const {}

void TailCallOp::PrintOptions(std::ostream& os) const {}

#if DEBUG
bool ValidOpInputRep(
    const Graph& graph, OpIndex input,
    std::initializer_list<RegisterRepresentation> expected_reps,
    std::optional<size_t> projection_index) {}

bool ValidOpInputRep(const Graph& graph, OpIndex input,
                     RegisterRepresentation expected_rep,
                     std::optional<size_t> projection_index) {}
#endif  // DEBUG

const char* OpcodeName(Opcode opcode) {}

std::ostream& operator<<(std::ostream& os, OperationPrintStyle styled_op) {}

std::ostream& operator<<(std::ostream& os, GenericBinopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, GenericUnopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, WordUnaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, OverflowCheckedUnaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, FloatUnaryOp::Kind kind) {}

// static
bool FloatUnaryOp::IsSupported(Kind kind, FloatRepresentation rep) {}

// static
bool WordUnaryOp::IsSupported(Kind kind, WordRepresentation rep) {}

std::ostream& operator<<(std::ostream& os, ShiftOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, ComparisonOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, ChangeOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, ChangeOrDeoptOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, TryChangeOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, TaggedBitcastOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, ChangeOp::Assumption assumption) {}

std::ostream& operator<<(std::ostream& os, SelectOp::Implementation kind) {}

std::ostream& operator<<(std::ostream& os, AtomicRMWOp::BinOp bin_op) {}

std::ostream& operator<<(std::ostream& os, AtomicWord32PairOp::Kind bin_op) {}

std::ostream& operator<<(std::ostream& os, FrameConstantOp::Kind kind) {}

void Operation::PrintInputs(std::ostream& os,
                            const std::string& op_index_prefix) const {}

void Operation::PrintOptions(std::ostream& os) const {}

void ConstantOp::PrintOptions(std::ostream& os) const {}

void ParameterOp::PrintOptions(std::ostream& os) const {}

MachineType LoadOp::machine_type() const {}

void LoadOp::PrintInputs(std::ostream& os,
                         const std::string& op_index_prefix) const {}
void LoadOp::PrintOptions(std::ostream& os) const {}

void AtomicRMWOp::PrintInputs(std::ostream& os,
                              const std::string& op_index_prefix) const {}

void AtomicRMWOp::PrintOptions(std::ostream& os) const {}

void AtomicWord32PairOp::PrintInputs(std::ostream& os,
                                     const std::string& op_index_prefix) const {}

void AtomicWord32PairOp::PrintOptions(std::ostream& os) const {}

void MemoryBarrierOp::PrintOptions(std::ostream& os) const {}

void StoreOp::PrintInputs(std::ostream& os,
                          const std::string& op_index_prefix) const {}
void StoreOp::PrintOptions(std::ostream& os) const {}

void AllocateOp::PrintOptions(std::ostream& os) const {}

void DecodeExternalPointerOp::PrintOptions(std::ostream& os) const {}

void FrameStateOp::PrintOptions(std::ostream& os) const {}

void FrameStateOp::Validate(const Graph& graph) const {}

void DeoptimizeIfOp::PrintOptions(std::ostream& os) const {}

void DidntThrowOp::Validate(const Graph& graph) const {}

void WordBinopOp::PrintOptions(std::ostream& os) const {}

void FloatBinopOp::PrintOptions(std::ostream& os) const {}

void Word32PairBinopOp::PrintOptions(std::ostream& os) const {}

void WordBinopDeoptOnOverflowOp::PrintOptions(std::ostream& os) const {}

void OverflowCheckedBinopOp::PrintOptions(std::ostream& os) const {}

std::ostream& operator<<(std::ostream& os, OpIndex idx) {}

std::ostream& operator<<(std::ostream& os, BlockIndex b) {}

std::ostream& operator<<(std::ostream& os, const Block* b) {}

std::ostream& operator<<(std::ostream& os, OpEffects effects) {}

void SwitchOp::PrintOptions(std::ostream& os) const {}

std::ostream& operator<<(std::ostream& os, ObjectIsOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os,
                         ObjectIsOp::InputAssumptions input_assumptions) {}

std::ostream& operator<<(std::ostream& os, NumericKind kind) {}

std::ostream& operator<<(std::ostream& os, ConvertOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os,
                         ConvertUntaggedToJSPrimitiveOp::JSPrimitiveKind kind) {}

std::ostream& operator<<(
    std::ostream& os,
    ConvertUntaggedToJSPrimitiveOp::InputInterpretation input_interpretation) {}

std::ostream& operator<<(
    std::ostream& os,
    ConvertUntaggedToJSPrimitiveOrDeoptOp::JSPrimitiveKind kind) {}

std::ostream& operator<<(
    std::ostream& os, ConvertUntaggedToJSPrimitiveOrDeoptOp::InputInterpretation
                          input_interpretation) {}

std::ostream& operator<<(std::ostream& os,
                         ConvertJSPrimitiveToUntaggedOp::UntaggedKind kind) {}

std::ostream& operator<<(
    std::ostream& os,
    ConvertJSPrimitiveToUntaggedOp::InputAssumptions input_assumptions) {}

std::ostream& operator<<(
    std::ostream& os,
    ConvertJSPrimitiveToUntaggedOrDeoptOp::UntaggedKind kind) {}

std::ostream& operator<<(
    std::ostream& os,
    ConvertJSPrimitiveToUntaggedOrDeoptOp::JSPrimitiveKind kind) {}

std::ostream& operator<<(std::ostream& os,
                         TruncateJSPrimitiveToUntaggedOp::UntaggedKind kind) {}

std::ostream& operator<<(
    std::ostream& os,
    TruncateJSPrimitiveToUntaggedOp::InputAssumptions input_assumptions) {}

std::ostream& operator<<(
    std::ostream& os,
    TruncateJSPrimitiveToUntaggedOrDeoptOp::UntaggedKind kind) {}

std::ostream& operator<<(std::ostream& os, NewArrayOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, DoubleArrayMinMaxOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, BigIntBinopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, BigIntComparisonOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, BigIntUnaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, StringAtOp::Kind kind) {}

#ifdef V8_INTL_SUPPORT
std::ostream& operator<<(std::ostream& os, StringToCaseIntlOp::Kind kind) {}
#endif  // V8_INTL_SUPPORT

std::ostream& operator<<(std::ostream& os, StringComparisonOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, ArgumentsLengthOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os,
                         TransitionAndStoreArrayElementOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, SameValueOp::Mode mode) {}

std::ostream& operator<<(std::ostream& os, FindOrderedHashEntryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os,
                         SpeculativeNumberBinopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, JSStackCheckOp::Kind kind) {}

#if V8_ENABLE_WEBASSEMBLY

const RegisterRepresentation& RepresentationFor(wasm::ValueType type) {}

namespace {
template <size_t size>
void PrintSimdValue(std::ostream& os, const uint8_t (&value)[size]) {}
}  // namespace

void Simd128ConstantOp::PrintOptions(std::ostream& os) const {}

std::ostream& operator<<(std::ostream& os, Simd128BinopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128UnaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128ReduceOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128ShiftOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128TestOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128SplatOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd128TernaryOp::Kind kind) {}

void Simd128ExtractLaneOp::PrintOptions(std::ostream& os) const {}

void Simd128ReplaceLaneOp::PrintOptions(std::ostream& os) const {}

void Simd128LaneMemoryOp::PrintOptions(std::ostream& os) const {}

void Simd128LoadTransformOp::PrintOptions(std::ostream& os) const {}

void Simd128ShuffleOp::PrintOptions(std::ostream& os) const {}

#if V8_ENABLE_WASM_SIMD256_REVEC
void Simd256ConstantOp::PrintOptions(std::ostream& os) const {}

void Simd256Extract128LaneOp::PrintOptions(std::ostream& os) const {}

void Simd256LoadTransformOp::PrintOptions(std::ostream& os) const {}

std::ostream& operator<<(std::ostream& os, Simd256UnaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd256TernaryOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd256BinopOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd256ShiftOp::Kind kind) {}

std::ostream& operator<<(std::ostream& os, Simd256SplatOp::Kind kind) {}

#ifdef V8_TARGET_ARCH_X64
void Simd256ShufdOp::PrintOptions(std::ostream& os) const {}

void Simd256ShufpsOp::PrintOptions(std::ostream& os) const {}

std::ostream& operator<<(std::ostream& os, Simd256UnpackOp::Kind kind) {}
#endif  // V8_TARGET_ARCH_X64
#endif  // V8_ENABLE_WASM_SIMD256_REVEC

void WasmAllocateArrayOp::PrintOptions(std::ostream& os) const {}

void ArrayGetOp::PrintOptions(std::ostream& os) const {}

#endif  // V8_ENABLE_WEBASSEBMLY

std::string Operation::ToString() const {}

base::LazyMutex SupportedOperations::mutex_ = LAZY_MUTEX_INITIALIZER;
SupportedOperations SupportedOperations::instance_;
bool SupportedOperations::initialized_;

void SupportedOperations::Initialize() {}

base::SmallVector<Block*, 4> SuccessorBlocks(const Block& block,
                                             const Graph& graph) {}

// static
bool SupportedOperations::IsUnalignedLoadSupported(MemoryRepresentation repr) {}

// static
bool SupportedOperations::IsUnalignedStoreSupported(MemoryRepresentation repr) {}

void CheckExceptionOp::Validate(const Graph& graph) const {}

namespace {
BlockIndex index_for_bound_block(const Block* block) {}
}  // namespace

size_t CallOp::hash_value(HashingStrategy strategy) const {}

size_t CheckExceptionOp::hash_value(HashingStrategy strategy) const {}

size_t GotoOp::hash_value(HashingStrategy strategy) const {}

size_t BranchOp::hash_value(HashingStrategy strategy) const {}

size_t SwitchOp::hash_value(HashingStrategy strategy) const {}

namespace {
// Ensures basic consistency of representation mapping.
class InputsRepFactoryCheck : InputsRepFactory {};
}  // namespace

bool IsUnlikelySuccessor(const Block* block, const Block* successor,
                         const Graph& graph) {}

bool Operation::IsOnlyUserOf(const Operation& value, const Graph& graph) const {}

}  // namespace v8::internal::compiler::turboshaft