v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
graph-builder.cc File Reference
#include "src/compiler/turboshaft/graph-builder.h"
#include <limits>
#include <numeric>
#include <optional>
#include <string_view>
#include "src/base/container-utils.h"
#include "src/base/logging.h"
#include "src/base/numerics/safe_conversions.h"
#include "src/base/small-vector.h"
#include "src/base/vector.h"
#include "src/codegen/bailout-reason.h"
#include "src/codegen/machine-type.h"
#include "src/common/globals.h"
#include "src/compiler/common-operator.h"
#include "src/compiler/compiler-source-position-table.h"
#include "src/compiler/fast-api-calls.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/machine-operator.h"
#include "src/compiler/node-aux-data.h"
#include "src/compiler/node-matchers.h"
#include "src/compiler/node-origin-table.h"
#include "src/compiler/node-properties.h"
#include "src/compiler/opcodes.h"
#include "src/compiler/operator.h"
#include "src/compiler/schedule.h"
#include "src/compiler/simplified-operator.h"
#include "src/compiler/state-values-utils.h"
#include "src/compiler/turboshaft/assembler.h"
#include "src/compiler/turboshaft/deopt-data.h"
#include "src/compiler/turboshaft/explicit-truncation-reducer.h"
#include "src/compiler/turboshaft/graph.h"
#include "src/compiler/turboshaft/operations.h"
#include "src/compiler/turboshaft/opmasks.h"
#include "src/compiler/turboshaft/phase.h"
#include "src/compiler/turboshaft/representations.h"
#include "src/compiler/turboshaft/variable-reducer.h"
#include "src/flags/flags.h"
#include "src/heap/factory-inl.h"
#include "src/objects/js-objects.h"
#include "src/objects/map.h"
#include "src/zone/zone-containers.h"
#include "src/compiler/turboshaft/define-assembler-macros.inc"
#include "src/compiler/turboshaft/undef-assembler-macros.inc"
Include dependency graph for graph-builder.cc:

Go to the source code of this file.

Namespaces

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

Macros

#define V8_COMPILER_TURBOSHAFT_ASSEMBLER_MACROS_DEFINED   1
 
#define TSA_DCHECK(assembler, condition)
 
#define TSA_SLOW_DCHECK(assembler, ...)
 
#define LIKELY(...)
 
#define UNLIKELY(...)
 
#define BIND(label, ...)
 
#define BIND_LOOP(loop_label, ...)
 
#define WHILE(...)
 
#define FOREACH_IMPL_2(arg, iterable)
 
#define FOREACH_IMPL_3(arg0, arg1, iterable)
 
#define FOREACH(...)
 
#define BREAK   Asm().ControlFlowHelper_Goto(loop_exit_xx, {})
 
#define CONTINUE   Asm().ControlFlowHelper_Goto(loop_header_xx, {})
 
#define GOTO(label, ...)
 
#define GOTO_IF(cond, label, ...)
 
#define GOTO_IF_NOT(cond, label, ...)
 
#define FORCE_UNROLL_LOOP
 
#define SUPPRESSED_DANGLING_ELSE_WARNING_IF(...)
 
#define SUPPRESSED_DANGLING_ELSE_WARNING_ELSE   else
 
#define NO_SHADOW
 
#define RE_SHADOW   _Pragma("GCC diagnostic pop")
 
#define IF(...)
 
#define IF_NOT(...)
 
#define ELSE
 
#define Assert(condition)
 
#define REDUCE(operation)
 
#define REDUCE_INPUT_GRAPH(operation)
 
#define __   Asm().
 
#define BINOP_CASE(opcode, assembler_op)
 
#define UNARY_CASE(opcode, assembler_op)
 
#define OBJECT_IS_CASE(kind)
 
#define CHECK_OBJECT_IS_CASE(code, kind, input_assumptions, reason, feedback)
 
#define CONVERT_PRIMITIVE_TO_OBJECT_CASE(name, kind, input_type, input_interpretation)
 
#define CONVERT_PRIMITIVE_TO_OBJECT_OR_DEOPT_CASE(name, kind, input_type, input_interpretation)
 
#define CONVERT_OBJECT_TO_PRIMITIVE_CASE(name, kind, input_assumptions)
 
#define TRUNCATE_OBJECT_TO_PRIMITIVE_CASE(name, kind, input_assumptions)
 
#define CHANGE_OR_DEOPT_INT_CASE(kind)
 
#define CASE(mode)
 
#define BIGINT_BINOP_CASE(op, kind)
 
#define ELSE_UNREACHABLE
 
#define BINOP(binop, size)
 
#define ATOMIC_WORD32_PAIR_BINOP(kind)
 

Functions

std::optional< BailoutReasonv8::internal::compiler::turboshaft::BuildGraph (PipelineData *data, Schedule *schedule, Zone *phase_zone, Linkage *linkage, JsWasmCallsSidetable *js_wasm_calls_sidetable)
 

Macro Definition Documentation

◆ __

#define __   Asm().

◆ Assert

#define Assert ( condition)
Value:
AssertImpl(condition, #condition, __FILE__, __LINE__)

◆ ATOMIC_WORD32_PAIR_BINOP

#define ATOMIC_WORD32_PAIR_BINOP ( kind)
Value:
case IrOpcode::kWord32AtomicPair##kind: \
return __ AtomicWord32PairBinop( \
Map(node->InputAt(0)), Map(node->InputAt(1)), Map(node->InputAt(2)), \
Map(node->InputAt(3)), AtomicRMWOp::BinOp::k##kind, 0);
Builtins::Kind kind
Definition builtins.cc:40
#define __

◆ BIGINT_BINOP_CASE

#define BIGINT_BINOP_CASE ( op,
kind )
Value:
case IrOpcode::kBigInt##op: \
DCHECK(dominating_frame_state.valid()); \
return __ BigIntBinop(Map(node->InputAt(0)), Map(node->InputAt(1)), \
dominating_frame_state, \
BigIntBinopOp::Kind::k##kind);

◆ BIND

#define BIND ( label,
... )
Value:
auto [CONCAT(is_bound_, __LINE__), ##__VA_ARGS__] = \
Asm().ControlFlowHelper_Bind(label); \
CONCAT(is_bound_, __LINE__)))
Label label
#define CONCAT(a,...)
Definition macros.h:22

◆ BIND_LOOP

#define BIND_LOOP ( loop_label,
... )
Value:
for(auto [CONCAT(run_loop_, __LINE__), ##__VA_ARGS__] = \
Asm().ControlFlowHelper_BindLoop(loop_label); CONCAT(run_loop_, __LINE__); \
Asm().ControlFlowHelper_EndLoop(loop_label), \
CONCAT(run_loop_, __LINE__) = false)

◆ BINOP

#define BINOP ( binop,
size )
Value:
case IrOpcode::kWord##size##Atomic##binop: \
return __ AtomicRMW(base, offset, value, AtomicRMWOp::BinOp::k##binop, \
RegisterRepresentation::Word##size(), \
MemoryRepresentation::FromMachineType(p.type()), \
p.kind());
int32_t offset

◆ BINOP_CASE

#define BINOP_CASE ( opcode,
assembler_op )
Value:
case IrOpcode::k##opcode: \
return __ assembler_op(Map(node->InputAt(0)), Map(node->InputAt(1)));

◆ BREAK

#define BREAK   Asm().ControlFlowHelper_Goto(loop_exit_xx, {})

◆ CASE

#define CASE ( mode)
Value:
case CheckTaggedInputMode::k##mode: \
from_kind = \
ConvertJSPrimitiveToUntaggedOrDeoptOp::JSPrimitiveKind::k##mode; \
break;
too high values may cause the compiler to set high thresholds for inlining to as much as possible avoid inlined allocation of objects that cannot escape trace load stores from virtual maglev objects use TurboFan fast string builder analyze liveness of environment slots and zap dead values trace TurboFan load elimination emit data about basic block usage in builtins to this enable builtin reordering when run mksnapshot flag for emit warnings when applying builtin profile data verify register allocation in TurboFan randomly schedule instructions to stress dependency tracking enable store store elimination in TurboFan rewrite far to near simulate GC compiler thread race related to allow float parameters to be passed in simulator mode JS Wasm Run additional turbo_optimize_inlined_js_wasm_wrappers enable experimental feedback collection in generic lowering enable Turboshaft s WasmLoadElimination enable Turboshaft s low level load elimination for JS enable Turboshaft s escape analysis for string concatenation use enable Turbolev features that we want to ship in the not too far future trace individual Turboshaft reduction steps trace intermediate Turboshaft reduction steps invocation count threshold for early optimization Enables optimizations which favor memory size over execution speed Enables sampling allocation profiler with X as a sample interval min size of a semi the new space consists of two semi spaces max size of the Collect garbage after Collect garbage after keeps maps alive for< n > old space garbage collections print one detailed trace line in allocation gc speed threshold for starting incremental marking via a task in percent of available threshold for starting incremental marking immediately in percent of available Use a single schedule for determining a marking schedule between JS and C objects schedules the minor GC task with kUserVisible priority max worker number of concurrent for NumberOfWorkerThreads start background threads that allocate memory concurrent_array_buffer_sweeping use parallel threads to clear weak refs in the atomic pause trace progress of the incremental marking trace object counts and memory usage report a tick only when allocated zone memory changes by this amount TracingFlags::gc_stats TracingFlags::gc_stats track native contexts that are expected to be garbage collected verify heap pointers before and after GC memory reducer runs GC with ReduceMemoryFootprint flag Maximum number of memory reducer GCs scheduled Old gen GC speed is computed directly from gc tracer counters Perform compaction on full GCs based on V8 s default heuristics Perform compaction on every full GC Perform code space compaction when finalizing a full GC with stack Stress GC compaction to flush out bugs with moving objects flush of baseline code when it has not been executed recently Use time base code flushing instead of age Use a progress bar to scan large objects in increments when incremental marking is active force incremental marking for small heaps and run it more often force marking at random points between and force scavenge at random points between and reclaim otherwise unreachable unmodified wrapper objects when possible less compaction in non memory reducing mode use high priority threads for concurrent Marking Test mode only flag It allows an unit test to select evacuation candidates use incremental marking for CppHeap cppheap_concurrent_marking c value for membalancer A special constant to balance between memory and space tradeoff The smaller the more memory it uses enable use of SSE4 instructions if available enable use of AVX VNNI instructions if available enable use of POPCNT instruction if available force all emitted branches to be in long mode(MIPS/PPC only)") DEFINE_BOOL(partial_constant_pool

◆ CHANGE_OR_DEOPT_INT_CASE

#define CHANGE_OR_DEOPT_INT_CASE ( kind)
Value:
case IrOpcode::kChecked##kind: { \
DCHECK(dominating_frame_state.valid()); \
const CheckParameters& params = CheckParametersOf(node->op()); \
return __ ChangeOrDeopt(Map(node->InputAt(0)), dominating_frame_state, \
ChangeOrDeoptOp::Kind::k##kind, \
CheckForMinusZeroMode::kDontCheckForMinusZero, \
params.feedback()); \
}

◆ CHECK_OBJECT_IS_CASE

#define CHECK_OBJECT_IS_CASE ( code,
kind,
input_assumptions,
reason,
feedback )
Value:
case IrOpcode::k##code: { \
DCHECK(dominating_frame_state.valid()); \
V<Object> input = Map(node->InputAt(0)); \
V<Word32> check = \
__ ObjectIs(input, ObjectIsOp::Kind::k##kind, \
ObjectIsOp::InputAssumptions::k##input_assumptions); \
__ DeoptimizeIfNot(check, dominating_frame_state, \
DeoptimizeReason::k##reason, feedback); \
return input; \
}
#define V(Name)
Handle< Code > code

◆ CONTINUE

#define CONTINUE   Asm().ControlFlowHelper_Goto(loop_header_xx, {})

◆ CONVERT_OBJECT_TO_PRIMITIVE_CASE

#define CONVERT_OBJECT_TO_PRIMITIVE_CASE ( name,
kind,
input_assumptions )
Value:
case IrOpcode::k##name: \
return __ ConvertJSPrimitiveToUntagged( \
Map(node->InputAt(0)), \
ConvertJSPrimitiveToUntaggedOp::UntaggedKind::k##kind, \
ConvertJSPrimitiveToUntaggedOp::InputAssumptions:: \
k##input_assumptions);
const char * name
Definition builtins.cc:39

◆ CONVERT_PRIMITIVE_TO_OBJECT_CASE

#define CONVERT_PRIMITIVE_TO_OBJECT_CASE ( name,
kind,
input_type,
input_interpretation )
Value:
case IrOpcode::k##name: \
return __ ConvertUntaggedToJSPrimitive( \
Map(node->InputAt(0)), \
ConvertUntaggedToJSPrimitiveOp::JSPrimitiveKind::k##kind, \
V<input_type>::rep, \
ConvertUntaggedToJSPrimitiveOp::InputInterpretation:: \
k##input_interpretation, \
CheckForMinusZeroMode::kDontCheckForMinusZero);

◆ CONVERT_PRIMITIVE_TO_OBJECT_OR_DEOPT_CASE

#define CONVERT_PRIMITIVE_TO_OBJECT_OR_DEOPT_CASE ( name,
kind,
input_type,
input_interpretation )
Value:
case IrOpcode::k##name: { \
DCHECK(dominating_frame_state.valid()); \
const CheckParameters& params = CheckParametersOf(node->op()); \
return __ ConvertUntaggedToJSPrimitiveOrDeopt( \
Map(node->InputAt(0)), dominating_frame_state, \
ConvertUntaggedToJSPrimitiveOrDeoptOp::JSPrimitiveKind::k##kind, \
V<input_type>::rep, \
ConvertUntaggedToJSPrimitiveOrDeoptOp::InputInterpretation:: \
k##input_interpretation, \
params.feedback()); \
}

◆ ELSE

#define ELSE
Value:
iteration == 1 && (bound = Asm().ControlFlowHelper_BindElse(&state)))
#define SUPPRESSED_DANGLING_ELSE_WARNING_ELSE

◆ ELSE_UNREACHABLE

#define ELSE_UNREACHABLE
Value:
ELSE { \
__ RuntimeAbort(AbortReason::kFastCallFallbackInvalid); \
__ Unreachable(); \
}
#define ELSE

◆ FORCE_UNROLL_LOOP

#define FORCE_UNROLL_LOOP

◆ FOREACH

#define FOREACH ( ...)
Value:
CONCAT(FOREACH_IMPL_, COUNT_MACRO_ARGS(__VA_ARGS__))(__VA_ARGS__)
#define COUNT_MACRO_ARGS(...)
Definition macros.h:28

◆ FOREACH_IMPL_2

#define FOREACH_IMPL_2 ( arg,
iterable )
Value:
for (auto [CONCAT(run_loop_, __LINE__), iterable_xx, loop_header_yy, \
loop_exit_xx, current_iterator_xx, arg] = \
Asm().ControlFlowHelper_Foreach(iterable); \
CONCAT(run_loop_, __LINE__); \
Asm().ControlFlowHelper_EndForeachLoop( \
std::move(iterable_xx), loop_header_yy, loop_exit_xx, \
current_iterator_xx), \
CONCAT(run_loop_, __LINE__) = false)

◆ FOREACH_IMPL_3

#define FOREACH_IMPL_3 ( arg0,
arg1,
iterable )
Value:
for (auto [CONCAT(run_loop_, __LINE__), iterable_xx, loop_header_yy, \
loop_exit_xx, current_iterator_xx, arg0, arg1] = \
Asm().ControlFlowHelper_Foreach(iterable); \
CONCAT(run_loop_, __LINE__); \
Asm().ControlFlowHelper_EndForeachLoop( \
std::move(iterable_xx), loop_header_yy, loop_exit_xx, \
current_iterator_xx), \
CONCAT(run_loop_, __LINE__) = false)

◆ GOTO

#define GOTO ( label,
... )
Value:
Asm().ControlFlowHelper_Goto(label, {__VA_ARGS__})

◆ GOTO_IF

#define GOTO_IF ( cond,
label,
... )
Value:
Asm().ControlFlowHelper_GotoIf(cond, label, {__VA_ARGS__})

◆ GOTO_IF_NOT

#define GOTO_IF_NOT ( cond,
label,
... )
Value:
Asm().ControlFlowHelper_GotoIfNot(cond, label, {__VA_ARGS__})

◆ IF

#define IF ( ...)
Value:
NO_SHADOW \
SUPPRESSED_DANGLING_ELSE_WARNING_IF( \
typename std::decay_t<decltype(Asm())>::ControlFlowHelper_IfState state; \
true) \
for (int iteration = 0, bound = false; iteration < 3; \
(bound ? Asm().ControlFlowHelper_FinishIfBlock(&state) : (void)0), \
bound = false, iteration++) \
RE_SHADOW \
SUPPRESSED_DANGLING_ELSE_WARNING_IF(iteration == 2) { \
Asm().ControlFlowHelper_EndIf(&state); \
} \
iteration == 0 && \
(bound = Asm().ControlFlowHelper_BindIf(__VA_ARGS__, &state)))
#define FORCE_UNROLL_LOOP

◆ IF_NOT

#define IF_NOT ( ...)
Value:
NO_SHADOW \
SUPPRESSED_DANGLING_ELSE_WARNING_IF( \
typename std::decay_t<decltype(Asm())>::ControlFlowHelper_IfState state; \
true) \
for (int iteration = 0, bound = false; iteration < 3; \
(bound ? Asm().ControlFlowHelper_FinishIfBlock(&state) : (void)0), \
bound = false, iteration++) \
RE_SHADOW \
SUPPRESSED_DANGLING_ELSE_WARNING_IF(iteration == 2) { \
Asm().ControlFlowHelper_EndIf(&state); \
} \
iteration == 0 && \
(bound = Asm().ControlFlowHelper_BindIfNot(__VA_ARGS__, &state)))

◆ LIKELY

#define LIKELY ( ...)
Value:
ConditionWithHint(__VA_ARGS__, BranchHint::kTrue)

◆ NO_SHADOW

#define NO_SHADOW
Value:
_Pragma("GCC diagnostic push") \
_Pragma("GCC diagnostic ignored \"-Wshadow\"")

◆ OBJECT_IS_CASE

#define OBJECT_IS_CASE ( kind)
Value:
case IrOpcode::kObjectIs##kind: { \
return __ ObjectIs(Map(node->InputAt(0)), ObjectIsOp::Kind::k##kind, \
ObjectIsOp::InputAssumptions::kNone); \
}

◆ RE_SHADOW

#define RE_SHADOW   _Pragma("GCC diagnostic pop")

◆ REDUCE

#define REDUCE ( operation)
Value:
Reduce##operation

◆ REDUCE_INPUT_GRAPH

#define REDUCE_INPUT_GRAPH ( operation)
Value:
ReduceInputGraph##operation

◆ SUPPRESSED_DANGLING_ELSE_WARNING_ELSE

#define SUPPRESSED_DANGLING_ELSE_WARNING_ELSE   else

◆ SUPPRESSED_DANGLING_ELSE_WARNING_IF

#define SUPPRESSED_DANGLING_ELSE_WARNING_IF ( ...)
Value:
if (__VA_ARGS__)

◆ TRUNCATE_OBJECT_TO_PRIMITIVE_CASE

#define TRUNCATE_OBJECT_TO_PRIMITIVE_CASE ( name,
kind,
input_assumptions )
Value:
case IrOpcode::k##name: \
return __ TruncateJSPrimitiveToUntagged( \
Map(node->InputAt(0)), \
TruncateJSPrimitiveToUntaggedOp::UntaggedKind::k##kind, \
TruncateJSPrimitiveToUntaggedOp::InputAssumptions:: \
k##input_assumptions);

◆ TSA_DCHECK

#define TSA_DCHECK ( assembler,
condition )
Value:
(assembler)->Asm().Dcheck(condition, #condition, __FILE__, __LINE__ )
AssemblerT assembler

◆ TSA_SLOW_DCHECK

#define TSA_SLOW_DCHECK ( assembler,
... )
Value:
((void)0)

◆ UNARY_CASE

#define UNARY_CASE ( opcode,
assembler_op )
Value:
case IrOpcode::k##opcode: \
return __ assembler_op(Map(node->InputAt(0)));

◆ UNLIKELY

#define UNLIKELY ( ...)
Value:
ConditionWithHint(__VA_ARGS__, BranchHint::kFalse)

◆ V8_COMPILER_TURBOSHAFT_ASSEMBLER_MACROS_DEFINED

#define V8_COMPILER_TURBOSHAFT_ASSEMBLER_MACROS_DEFINED   1

◆ WHILE

#define WHILE ( ...)
Value:
for (auto [CONCAT(run_loop_, __LINE__), loop_header_xx, loop_exit_xx] \
= Asm().ControlFlowHelper_While([&]() { \
return Asm().resolve(ConstOrV<Word32>(__VA_ARGS__)); \
}); \
CONCAT(run_loop_, __LINE__); \
Asm().ControlFlowHelper_EndWhileLoop(loop_header_xx, loop_exit_xx), \
CONCAT(run_loop_, __LINE__) = false)

Variable Documentation

◆ assembler

AssemblerT assembler

Definition at line 71 of file graph-builder.cc.

◆ block

Block* block

Definition at line 92 of file graph-builder.cc.

◆ block_mapping

ZoneVector<BlockData> block_mapping {schedule.RpoBlockCount(), phase_zone}

Definition at line 96 of file graph-builder.cc.

◆ broker

JSHeapBroker* broker

Definition at line 68 of file graph-builder.cc.

◆ final_frame_state

OpIndex final_frame_state

Definition at line 93 of file graph-builder.cc.

◆ graph_zone

Zone* graph_zone

Definition at line 69 of file graph-builder.cc.

◆ inside_region

bool inside_region = false

Definition at line 97 of file graph-builder.cc.

◆ isolate

Isolate* isolate

Definition at line 67 of file graph-builder.cc.

◆ js_wasm_calls_sidetable

JsWasmCallsSidetable* js_wasm_calls_sidetable

Definition at line 74 of file graph-builder.cc.

◆ linkage

Linkage* linkage

Definition at line 65 of file graph-builder.cc.

◆ op_mapping

NodeAuxData<OpIndex> op_mapping {phase_zone}

Definition at line 95 of file graph-builder.cc.

◆ origins

NodeOriginTable* origins

Definition at line 73 of file graph-builder.cc.

◆ phase_zone

Zone* phase_zone

Definition at line 63 of file graph-builder.cc.

◆ pipeline_kind

TurboshaftPipelineKind pipeline_kind

Definition at line 75 of file graph-builder.cc.

◆ schedule

Schedule& schedule

Definition at line 64 of file graph-builder.cc.

◆ source_positions

SourcePositionTable* source_positions

Definition at line 72 of file graph-builder.cc.