v8
V8 is Google’s open source high-performance JavaScript and WebAssembly engine, written in C++.
Loading...
Searching...
No Matches
turbolev-graph-builder.cc File Reference
#include "src/compiler/turboshaft/turbolev-graph-builder.h"
#include <limits>
#include <memory>
#include <optional>
#include <type_traits>
#include "src/base/logging.h"
#include "src/base/small-vector.h"
#include "src/base/vector.h"
#include "src/codegen/bailout-reason.h"
#include "src/codegen/optimized-compilation-info.h"
#include "src/common/globals.h"
#include "src/compiler/access-builder.h"
#include "src/compiler/bytecode-analysis.h"
#include "src/compiler/bytecode-liveness-map.h"
#include "src/compiler/frame-states.h"
#include "src/compiler/globals.h"
#include "src/compiler/js-heap-broker.h"
#include "src/compiler/turboshaft/access-builder.h"
#include "src/compiler/turboshaft/assembler.h"
#include "src/compiler/turboshaft/graph.h"
#include "src/compiler/turboshaft/index.h"
#include "src/compiler/turboshaft/machine-optimization-reducer.h"
#include "src/compiler/turboshaft/maglev-early-lowering-reducer-inl.h"
#include "src/compiler/turboshaft/operations.h"
#include "src/compiler/turboshaft/phase.h"
#include "src/compiler/turboshaft/representations.h"
#include "src/compiler/turboshaft/required-optimization-reducer.h"
#include "src/compiler/turboshaft/sidetable.h"
#include "src/compiler/turboshaft/utils.h"
#include "src/compiler/turboshaft/value-numbering-reducer.h"
#include "src/compiler/turboshaft/variable-reducer.h"
#include "src/compiler/write-barrier-kind.h"
#include "src/deoptimizer/deoptimize-reason.h"
#include "src/handles/global-handles-inl.h"
#include "src/handles/handles.h"
#include "src/interpreter/bytecode-register.h"
#include "src/maglev/maglev-basic-block.h"
#include "src/maglev/maglev-compilation-info.h"
#include "src/maglev/maglev-compilation-unit.h"
#include "src/maglev/maglev-graph-builder.h"
#include "src/maglev/maglev-graph-labeller.h"
#include "src/maglev/maglev-graph-processor.h"
#include "src/maglev/maglev-graph-verifier.h"
#include "src/maglev/maglev-inlining.h"
#include "src/maglev/maglev-ir-inl.h"
#include "src/maglev/maglev-ir.h"
#include "src/maglev/maglev-phi-representation-selector.h"
#include "src/maglev/maglev-post-hoc-optimizations-processors.h"
#include "src/objects/elements-kind.h"
#include "src/objects/heap-object.h"
#include "src/objects/js-array-buffer.h"
#include "src/objects/map.h"
#include "src/objects/objects.h"
#include "src/objects/property-cell.h"
#include "src/zone/zone-containers.h"
#include "src/compiler/turboshaft/define-assembler-macros.inc"
#include "src/compiler/turboshaft/undef-assembler-macros.inc"

Go to the source code of this file.

Classes

class  v8::internal::compiler::turboshaft::BlockOriginTrackingReducer< Next >
 
class  v8::internal::compiler::turboshaft::GeneratorAnalyzer
 
class  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor
 
class  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor::Deduplicator
 
struct  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor::Deduplicator::DuplicatedId
 
class  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor::ThrowingScope
 
class  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor::NoThrowingScopeRequired
 
struct  v8::internal::compiler::turboshaft::GraphBuildingNodeProcessor::GeneratorSplitEdge
 
class  v8::internal::compiler::turboshaft::NodeProcessorBase
 

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 GET_FRAME_STATE_MAYBE_ABORT(name, deopt_info)
 
#define BAILOUT_IF_TOO_MANY_ARGUMENTS_FOR_CALL(count)
 
#define GENERATE_AND_MAP_BUILTIN_CALL(node, builtin, frame_state, arguments, ...)
 
#define RETURN_IF_UNREACHABLE()
 
#define PROCESS_BINOP_WITH_OVERFLOW(MaglevName, TurboshaftName, minus_zero_mode)
 
#define PROCESS_FLOAT64_BINOP(MaglevName, TurboshaftName)
 
#define PROCESS_INT32_BITWISE_BINOP(Name)
 
#define PROCESS_INT32_SHIFT(MaglevName, TurboshaftName)
 
#define CASE(MathName, ExpName, EnumName)
 
#define PROCESS_GENERIC_BINOP(Name)
 
#define PROCESS_GENERIC_UNOP(Name)
 

Functions

constexpr bool v8::internal::compiler::turboshaft::TooManyArgumentsForCall (size_t arguments_count)
 
void v8::internal::compiler::turboshaft::PrintBytecode (PipelineData &data, maglev::MaglevCompilationInfo *compilation_info)
 
void v8::internal::compiler::turboshaft::PrintMaglevGraph (PipelineData &data, maglev::MaglevCompilationInfo *compilation_info, maglev::Graph *maglev_graph, const char *msg)
 
void v8::internal::compiler::turboshaft::RunMaglevOptimizations (PipelineData *data, maglev::MaglevCompilationInfo *compilation_info, maglev::MaglevGraphBuilder &maglev_graph_builder, maglev::Graph *maglev_graph)
 

Macro Definition Documentation

◆ __

#define __   Asm().

◆ Assert

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

◆ BAILOUT_IF_TOO_MANY_ARGUMENTS_FOR_CALL

#define BAILOUT_IF_TOO_MANY_ARGUMENTS_FOR_CALL ( count)
Value:
{ \
if (TooManyArgumentsForCall(count)) { \
*bailout_ = BailoutReason::kTooManyArguments; \
return maglev::ProcessResult::kAbort; \
} \
}

Definition at line 431 of file turbolev-graph-builder.cc.

◆ 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)

◆ BREAK

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

◆ CASE

#define CASE ( MathName,
ExpName,
EnumName )
Value:
case maglev::Float64Ieee754Unary::Ieee754Function::k##EnumName: \
kind = FloatUnaryOp::Kind::k##EnumName; \
break;
Builtins::Kind kind
Definition builtins.cc:40

◆ CONTINUE

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

◆ ELSE

#define ELSE
Value:
iteration == 1 && (bound = Asm().ControlFlowHelper_BindElse(&state)))
#define SUPPRESSED_DANGLING_ELSE_WARNING_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)

◆ GENERATE_AND_MAP_BUILTIN_CALL

#define GENERATE_AND_MAP_BUILTIN_CALL ( node,
builtin,
frame_state,
arguments,
... )
Value:
SetMap(node, GenerateBuiltinCall(node, builtin, frame_state, arguments, \
##__VA_ARGS__));
#define BAILOUT_IF_TOO_MANY_ARGUMENTS_FOR_CALL(count)

Definition at line 439 of file turbolev-graph-builder.cc.

◆ GET_FRAME_STATE_MAYBE_ABORT

#define GET_FRAME_STATE_MAYBE_ABORT ( name,
deopt_info )
Value:
{ \
OptionalV<FrameState> _maybe_frame_state = BuildFrameState(deopt_info); \
if (!_maybe_frame_state.has_value()) { \
DCHECK(bailout_->has_value()); \
return maglev::ProcessResult::kAbort; \
} \
name = _maybe_frame_state.value(); \
}
#define V(Name)
const char * name
Definition builtins.cc:39

Definition at line 413 of file turbolev-graph-builder.cc.

◆ 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\"")

◆ PROCESS_BINOP_WITH_OVERFLOW

#define PROCESS_BINOP_WITH_OVERFLOW ( MaglevName,
TurboshaftName,
minus_zero_mode )
Value:
maglev::ProcessResult Process(maglev::Int32##MaglevName##WithOverflow* node, \
const maglev::ProcessingState& state) { \
GET_FRAME_STATE_MAYBE_ABORT(frame_state, node->eager_deopt_info()); \
SetMap(node, \
__ Word32##TurboshaftName##DeoptOnOverflow( \
Map(node->left_input()), Map(node->right_input()), frame_state, \
node->eager_deopt_info()->feedback_to_update(), \
CheckForMinusZeroMode::k##minus_zero_mode)); \
return maglev::ProcessResult::kContinue; \
}
#define __

Definition at line 3800 of file turbolev-graph-builder.cc.

◆ PROCESS_FLOAT64_BINOP

#define PROCESS_FLOAT64_BINOP ( MaglevName,
TurboshaftName )
Value:
maglev::ProcessResult Process(maglev::Float64##MaglevName* node, \
const maglev::ProcessingState& state) { \
SetMap(node, __ Float64##TurboshaftName(Map(node->left_input()), \
Map(node->right_input()))); \
return maglev::ProcessResult::kContinue; \
}

Definition at line 3851 of file turbolev-graph-builder.cc.

◆ PROCESS_GENERIC_BINOP

#define PROCESS_GENERIC_BINOP ( Name)
Value:
maglev::ProcessResult Process(maglev::Generic##Name* node, \
const maglev::ProcessingState& state) { \
ThrowingScope throwing_scope(this, node); \
GET_FRAME_STATE_MAYBE_ABORT(frame_state, node->lazy_deopt_info()); \
SetMap(node, \
__ Generic##Name(Map(node->left_input()), Map(node->right_input()), \
frame_state, native_context(), \
ShouldLazyDeoptOnThrow(node))); \
return maglev::ProcessResult::kContinue; \
}

Definition at line 4026 of file turbolev-graph-builder.cc.

◆ PROCESS_GENERIC_UNOP

#define PROCESS_GENERIC_UNOP ( Name)
Value:
maglev::ProcessResult Process(maglev::Generic##Name* node, \
const maglev::ProcessingState& state) { \
ThrowingScope throwing_scope(this, node); \
GET_FRAME_STATE_MAYBE_ABORT(frame_state, node->lazy_deopt_info()); \
SetMap(node, \
__ Generic##Name(Map(node->operand_input()), frame_state, \
native_context(), ShouldLazyDeoptOnThrow(node))); \
return maglev::ProcessResult::kContinue; \
}

Definition at line 4040 of file turbolev-graph-builder.cc.

◆ PROCESS_INT32_BITWISE_BINOP

#define PROCESS_INT32_BITWISE_BINOP ( Name)
Value:
maglev::ProcessResult Process(maglev::Int32Bitwise##Name* node, \
const maglev::ProcessingState& state) { \
SetMap(node, __ Word32Bitwise##Name(Map(node->left_input()), \
Map(node->right_input()))); \
return maglev::ProcessResult::kContinue; \
}

Definition at line 3866 of file turbolev-graph-builder.cc.

◆ PROCESS_INT32_SHIFT

#define PROCESS_INT32_SHIFT ( MaglevName,
TurboshaftName )
Value:
maglev::ProcessResult Process(maglev::Int32##MaglevName* node, \
const maglev::ProcessingState& state) { \
V<Word32> right = Map(node->right_input()); \
if (!SupportedOperations::word32_shift_is_safe()) { \
/* JavaScript spec says that the right-hand side of a shift should be \
* taken modulo 32. Some architectures do this automatically, some \
* don't. For those that don't, which do this modulo 32 with a `& 0x1f`. \
*/ \
right = __ Word32BitwiseAnd(right, 0x1f); \
} \
SetMap(node, __ Word32##TurboshaftName(Map(node->left_input()), right)); \
return maglev::ProcessResult::kContinue; \
}

Definition at line 3878 of file turbolev-graph-builder.cc.

◆ 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

◆ RETURN_IF_UNREACHABLE

#define RETURN_IF_UNREACHABLE ( )
Value:
if (__ generating_unreachable_operations()) { \
return maglev::ProcessResult::kContinue; \
}

Definition at line 451 of file turbolev-graph-builder.cc.

◆ 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__)

◆ 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)

◆ 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)