37#ifdef V8_CODE_COMMENTS
55 const bool serializer = isolate->serializer_enabled();
56 const bool generating_embedded_builtin =
57 isolate->IsGeneratingEmbeddedBuiltins();
59 options.enable_root_relative_access =
60 !serializer && !generating_embedded_builtin;
70 options.enable_simulator_code = !serializer ||
v8_flags.target_is_simulator;
73#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_ARM64 || V8_TARGET_ARCH_LOONG64 || \
74 V8_TARGET_ARCH_RISCV64
75 options.code_range_base = isolate->
heap()->code_range_base();
77 bool short_builtin_calls =
78 isolate->is_short_builtin_calls_enabled() &&
79 !generating_embedded_builtin &&
83 if (short_builtin_calls) {
93 explicit DefaultAssemblerBuffer(
int size)
94 :
buffer_(
base::OwnedVector<uint8_t>::NewForOverwrite(
101 uint8_t*
start()
const override {
return buffer_.begin(); }
103 int size()
const override {
return static_cast<int>(
buffer_.size()); }
105 std::unique_ptr<AssemblerBuffer> Grow(
int new_size)
override {
107 return std::make_unique<DefaultAssemblerBuffer>(new_size);
114class ExternalAssemblerBufferImpl :
public AssemblerBuffer {
116 ExternalAssemblerBufferImpl(uint8_t*
start,
int size)
121 int size()
const override {
return size_; }
123 std::unique_ptr<AssemblerBuffer> Grow(
int new_size)
override {
124 FATAL(
"Cannot grow external assembler buffer");
127 void*
operator new(std::size_t
count);
128 void operator delete(
void* ptr)
noexcept;
136 ExternalAssemblerBufferImpl)
static thread_local char tls_singleton_storage
137 [
sizeof(ExternalAssemblerBufferImpl)];
139static thread_local bool tls_singleton_taken{
false};
141void* ExternalAssemblerBufferImpl::operator
new(std::size_t
count) {
142 DCHECK_EQ(count,
sizeof(ExternalAssemblerBufferImpl));
144 tls_singleton_taken =
true;
145 return tls_singleton_storage;
147 return ::operator
new(
count);
150void ExternalAssemblerBufferImpl::operator
delete(
void* ptr)
noexcept {
151 if (
V8_LIKELY(ptr == tls_singleton_storage)) {
152 DCHECK(tls_singleton_taken);
153 tls_singleton_taken =
false;
156 ::operator
delete(ptr);
163 return std::make_unique<ExternalAssemblerBufferImpl>(
164 reinterpret_cast<uint8_t*
>(
start), size);
168 return std::make_unique<DefaultAssemblerBuffer>(size);
181 std::unique_ptr<AssemblerBuffer> buffer)
184 enabled_cpu_features_(0),
185 predictable_code_size_(false),
186 constant_pool_available_(false),
187 jump_optimization_info_(nullptr) {
208 old_enabled_ =
assembler_->enabled_cpu_features();
213 assembler_->set_enabled_cpu_features(old_enabled_);
269 if (current > 0 && !target.is_null() &&
280 intptr_t code_target_index)
const {
289 if (!
object.is_null()) {
292 return entry->second;
307 if (!
v8_flags.code_comments)
return 0;
309 options().emit_code_comments);
318#ifdef V8_CODE_COMMENTS
319int Assembler::CodeComment::depth()
const {
return assembler_->comment_depth_; }
320void Assembler::CodeComment::Open(
const std::string& comment,
322 std::stringstream sstream;
323 sstream << std::setfill(
' ') << std::setw(depth() * kIndentWidth + 2);
324 sstream <<
"[ " << comment;
326 assembler_->RecordComment(sstream.str(), loc);
329void Assembler::CodeComment::Close() {
331 std::string comment =
"]";
332 comment.insert(0, depth() * kIndentWidth,
' ');
335 assembler_->RecordComment(comment, SourceLocation());
void RequestHeapNumber(HeapNumberRequest request)
std::unique_ptr< AssemblerBuffer > buffer_
static constexpr int kDefaultBufferSize
IndirectHandle< Code > GetCodeTarget(intptr_t code_target_index) const
AssemblerBase(const AssemblerOptions &options, std::unique_ptr< AssemblerBuffer >)
EmbeddedObjectIndex AddEmbeddedObject(IndirectHandle< HeapObject > object)
std::unordered_map< IndirectHandle< HeapObject >, EmbeddedObjectIndex, IndirectHandle< HeapObject >::hash, IndirectHandle< HeapObject >::equal_to > embedded_objects_map_
void Print(Isolate *isolate)
std::vector< IndirectHandle< HeapObject > > embedded_objects_
std::forward_list< HeapNumberRequest > heap_number_requests_
size_t EmbeddedObjectIndex
CodeCommentsWriter code_comments_writer_
int AddCodeTarget(IndirectHandle< Code > target)
IndirectHandle< HeapObject > GetEmbeddedObject(EmbeddedObjectIndex index) const
static constexpr int kMinimalBufferSize
std::vector< IndirectHandle< Code > > code_targets_
void RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data=0)
static constexpr int kGap
void RecordDeoptReason(DeoptimizeReason reason, uint32_t node_id, SourcePosition position, int id)
CpuFeatureScope(AssemblerBase *assembler, CpuFeature f, CheckPolicy check=kCheckSupported)
static bool IsSupported(CpuFeature f)
static bool supports_wasm_simd_128_
static unsigned supported_
static unsigned icache_line_size_
static unsigned dcache_line_size_
static bool supports_cetss_
static V8_EXPORT_PRIVATE int Decode(Isolate *isolate, std::ostream &os, uint8_t *begin, uint8_t *end, CodeReference code={}, Address current_pc=kNullAddress, size_t range_limit=0)
void set_offset(int offset)
double heap_number() const
HeapNumberRequest(double heap_number, int offset=-1)
static constexpr int kMaxSize
base::OwnedVector< uint8_t > buffer_
BytecodeAssembler & assembler_
DirectHandle< JSReceiver > options
constexpr bool IsPowerOfTwo(T value)
V8_INLINE void ZapCode(Address addr, size_t size_in_bytes)
bool IsSmiDouble(double value)
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 space
std::unique_ptr< AssemblerBuffer > NewAssemblerBuffer(int size)
constexpr BlockAddrMode db
V8_EXPORT_PRIVATE FlagValues v8_flags
static constexpr Address kNullAddress
std::unique_ptr< AssemblerBuffer > ExternalAssemblerBuffer(void *start, int size)
#define DCHECK_LE(v1, v2)
#define CHECK_IMPLIES(lhs, rhs)
#define DCHECK_IMPLIES(v1, v2)
#define DCHECK(condition)
#define DCHECK_LT(v1, v2)
#define DCHECK_EQ(v1, v2)
bool record_reloc_info_for_serialization
static AssemblerOptions Default(Isolate *isolate)
other heap size max size of the shared heap(in Mbytes)
#define V8_LIKELY(condition)