18 Register size_in_bytes) {
19 __ SubS64(
object, size_in_bytes);
30void AllocateRaw(MaglevAssembler* masm, Isolate* isolate,
31 RegisterSnapshot register_snapshot, Register
object,
36 DCHECK(masm->allow_allocate());
43 ZoneLabelRef done(masm);
44 MaglevAssembler::TemporaryRegisterScope temps(masm);
45 Register scratch = temps.AcquireScratch();
51 Register new_top = object;
53 __ LoadU64(
object,
__ ExternalReferenceAsOperand(top, scratch));
54 __ AddU64(
object, size_in_bytes);
55 __ LoadU64(scratch,
__ ExternalReferenceAsOperand(limit, scratch));
56 __ CmpU64(new_top, scratch);
62 __ Move(
__ ExternalReferenceAsOperand(top, scratch), new_top);
69 Register
object,
int size_in_bytes,
73 alloc_type, alignment);
77 Register
object, Register size_in_bytes,
81 alloc_type, alignment);
85 TemporaryRegisterScope temps(
this);
86 Register scratch = temps.AcquireScratch();
89 CHECK(!graph->has_recursive_calls());
91 uint32_t source_frame_size =
92 graph->min_maglev_stackslots_for_unoptimized_frame_size();
100 Assert(
eq, AbortReason::kOsrUnexpectedStackSize);
103 uint32_t target_frame_size =
104 graph->tagged_stack_slots() + graph->untagged_stack_slots();
105 CHECK_LE(source_frame_size, target_frame_size);
107 if (source_frame_size < target_frame_size) {
109 uint32_t additional_tagged =
110 source_frame_size < graph->tagged_stack_slots()
111 ? graph->tagged_stack_slots() - source_frame_size
113 if (additional_tagged) {
116 for (
size_t i = 0;
i < additional_tagged; ++
i) {
119 uint32_t size_so_far = source_frame_size + additional_tagged;
120 CHECK_LE(size_so_far, target_frame_size);
121 if (size_so_far < target_frame_size) {
129 TemporaryRegisterScope temps(
this);
130 temps.Include({r6, r8});
131 Register scratch = temps.AcquireScratch();
136 if (graph->has_recursive_calls()) {
140#ifndef V8_ENABLE_LEAPTIERING
143 using D = MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor;
144 Register flags = D::GetRegisterParameter(D::kFlags);
145 Register feedback_vector = D::GetRegisterParameter(D::kFeedbackVector);
149 DCHECK(!temps.Available().has(flags));
150 DCHECK(!temps.Available().has(feedback_vector));
151 Move(feedback_vector,
153 TailCallBuiltin(Builtin::kMaglevOptimizeCodeOrTailCallOptimizedCodeSlot,
155 flags, feedback_vector, CodeKind::MAGLEV));
168 if (graph->tagged_stack_slots() > 0) {
174 const int kLoopUnrollSize = 8;
185 for (
int i = 0;
i < first_slots; ++
i) {
188 Register unroll_counter = temps.AcquireScratch();
195 for (
int i = 0;
i < kLoopUnrollSize; ++
i) {
198 SubS32(unroll_counter, Operand(1));
202 if (graph->untagged_stack_slots() > 0) {
211 Label* eager_deopt_entry,
212 size_t lazy_deopt_count,
213 Label* lazy_deopt_entry) {}
221 Assert(
le, AbortReason::kUnexpectedValue);
224 LoadRoot(table, RootIndex::kSingleCharacterStringTable);
230 Label* char_code_fits_one_byte,
231 Register
result, Register char_code,
233 CharCodeMaskMode mask_mode) {
236 ZoneLabelRef done(
this);
238 AndP(char_code, char_code, Operand(0xFFFF));
244 ZoneLabelRef done, Register
result, Register char_code,
251 if (char_code ==
result) {
252 __ Move(scratch, char_code);
256 DCHECK(!register_snapshot.live_tagged_registers.has(char_code));
257 register_snapshot.live_registers.set(char_code);
264 register_snapshot, done,
result, char_code, scratch);
265 if (char_code_fits_one_byte !=
nullptr) {
266 bind(char_code_fits_one_byte);
274 RegisterSnapshot& register_snapshot, Register
result, Register
string,
275 Register index, Register instance_type, Register scratch2,
276 Label* result_fits_one_byte) {
277 ZoneLabelRef done(
this);
285 RegisterSnapshot register_snapshot, ZoneLabelRef done, Register
result,
286 Register
string, Register index) {
288 DCHECK(!register_snapshot.live_registers.has(
string));
289 DCHECK(!register_snapshot.live_registers.has(index));
291 SaveRegisterStateForCall save_register_state(masm, register_snapshot);
304 save_register_state.DefineSafepoint();
320 AbortReason::kUnexpectedValue);
326 Check(
lt, AbortReason::kUnexpectedValue);
333 TemporaryRegisterScope temps(
this);
334 Register representation = temps.AcquireScratch();
345 bne(deferred_runtime_call);
356 bind(&sliced_string);
358 TemporaryRegisterScope temps(
this);
362 offsetof(SlicedString,
offset_));
372 Register second_string = instance_type;
375 CompareRoot(second_string, RootIndex::kempty_string);
376 bne(deferred_runtime_call);
384 Label two_byte_string;
387 beq(&two_byte_string);
394 b(result_fits_one_byte);
396 bind(&two_byte_string);
410 string_backup = scratch2;
411 Move(string_backup,
string);
415 Register first_code_point = scratch;
416 And(first_code_point,
result, Operand(0xfc00));
417 CmpS32(first_code_point, Operand(0xd800));
422 AddS32(index, index, Operand(1));
426 Register second_code_point = scratch;
434 And(scratch2, second_code_point, Operand(0xfc00));
435 CmpS32(scratch2, Operand(0xdc00));
438 int surrogate_offset = 0x10000 - (0xd800 << 10) - 0xdc00;
439 AddS32(second_code_point, second_code_point, Operand(surrogate_offset));
453 Move(
string, 0xdeadbeef);
456 Move(index, 0xdeadbeef);
462 ZoneLabelRef done(
this);
485 TemporaryRegisterScope temps(
this);
518 TemporaryRegisterScope temps(
this);
550 Label* success, Label* fail) {
551 TemporaryRegisterScope temps(
this);
#define Assert(condition)
void b(int branch_offset, Condition cond=al, RelocInfo::Mode rmode=RelocInfo::NO_INFO)
void bne(Register rj, Register rd, int32_t offset)
void bge(Register rj, Register rd, int32_t offset)
void bgt(Label *L, CRegister cr=cr0, LKBit lk=LeaveLK)
void beq(Register rj, Register rd, int32_t offset)
void ConvertIntToDouble(Register src, DoubleRegister dst)
void LoadU8(Register dst, const MemOperand &mem, Register scratch=no_reg)
void SmiUntag(Register reg, SBit s=LeaveCC)
void StoreF64(DoubleRegister src, const MemOperand &mem, Register scratch=no_reg)
void CompareRoot(Register obj, RootIndex index)
void LoadU16(Register dst, const MemOperand &mem, Register scratch=no_reg)
void BailoutIfDeoptimized()
void CmpU32(Register src1, const Operand &src2, Register scratch, CRegister cr=cr0)
void SmiTag(Register reg, SBit s=LeaveCC)
void MovDoubleToInt64(Register dst, DoubleRegister src)
void ConvertDoubleToUnsignedInt32(const Register dst, const DoubleRegister double_input, FPRoundingMode rounding_mode=kRoundToZero)
void And(Register dst, Register src1, const Operand &src2, Condition cond=al)
void ShiftLeftU32(Register dst, Register src, const Operand &value, RCBit r=LeaveRC)
void CmpU64(Register src1, const Operand &src2, Register scratch, CRegister cr=cr0)
void AddS32(Register dst, Register src, const Operand &value, Register scratch=r0, RCBit r=LeaveRC)
void LoadRoot(Register destination, RootIndex index) final
void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg=false)
void LoadU32(Register dst, const MemOperand &mem, Register scratch=no_reg)
void ConvertUnsignedIntToDouble(Register src, DoubleRegister dst)
void AddU32(Register dst, Register src1, Register src2)
void ShiftRightS64(Register dst, Register src, const Operand &value, RCBit r=LeaveRC)
void ConvertDoubleToInt32(const Register dst, const DoubleRegister double_input, FPRoundingMode rounding_mode=kRoundToZero)
void SubS32(Register dst, Register src, const Operand &value, Register scratch=r0, RCBit r=LeaveRC)
Condition LoadFeedbackVectorFlagsAndCheckIfNeedsProcessing(Register flags, Register feedback_vector, CodeKind current_code_kind)
void ShiftLeftU64(Register dst, Register src, const Operand &value, RCBit r=LeaveRC)
void CmpS64(Register src1, const Operand &src2, Register scratch, CRegister cr=cr0)
void Check(Condition cond, AbortReason reason)
void AllocateStackSpace(Register bytes)
void AssertZeroExtended(Register int32_register)
void CmpS32(Register src1, const Operand &src2, Register scratch, CRegister cr=cr0)
void StoreU16(Register src, const MemOperand &mem, Register scratch)
void AddU64(Register dst, const Operand &imm)
void LoadU64(Register dst, const MemOperand &mem, Register scratch=no_reg)
void TryInlineTruncateDoubleToI(Register result, DwVfpRegister input, Label *done)
void CmpF64(DoubleRegister src1, DoubleRegister src2)
void TailCallBuiltin(Builtin builtin, Condition cond=al)
void AndP(Register dst, Register src)
static V8_INLINE Operand Zero()
static constexpr int kFixedFrameSizeFromFp
static const int32_t kMaxOneByteCharCode
void LoadSingleCharacterString(Register result, int char_code)
void LoadAndUntagTaggedSignedField(Register result, Register object, int offset)
MaglevAssembler(Isolate *isolate, Zone *zone, MaglevCodeGenState *code_gen_state)
void AssertObjectTypeInRange(Register heap_object, InstanceType lower_limit, InstanceType higher_limit, AbortReason reason)
void StringFromCharCode(RegisterSnapshot register_snapshot, Label *char_code_fits_one_byte, Register result, Register char_code, Register scratch, CharCodeMaskMode mask_mode)
void Jump(Label *target, Label::Distance distance=Label::kFar)
void CallRuntime(Runtime::FunctionId fid)
void LoadInstanceType(Register instance_type, Register heap_object)
void Allocate(RegisterSnapshot register_snapshot, Register result, int size_in_bytes, AllocationType alloc_type=AllocationType::kYoung, AllocationAlignment alignment=kTaggedAligned)
void TryTruncateDoubleToUint32(Register dst, DoubleRegister src, Label *fail)
void StringCharCodeOrCodePointAt(BuiltinStringPrototypeCharCodeOrCodePointAt::Mode mode, RegisterSnapshot ®ister_snapshot, Register result, Register string, Register index, Register scratch1, Register scratch2, Label *result_fits_one_byte)
void AllocateTwoByteString(RegisterSnapshot register_snapshot, Register result, int length)
void Move(StackSlot dst, Register src)
void CallBuiltin(Builtin builtin)
void TryTruncateDoubleToInt32(Register dst, DoubleRegister src, Label *fail)
Label * MakeDeferredCode(Function &&deferred_code_gen, Args &&... args)
void JumpToDeferredIf(Condition cond, Function &&deferred_code_gen, Args &&... args)
void TruncateDoubleToInt32(Register dst, DoubleRegister src)
void MaybeEmitDeoptBuiltinsCall(size_t eager_deopt_count, Label *eager_deopt_entry, size_t lazy_deopt_count, Label *lazy_deopt_entry)
MaglevCompilationInfo * compilation_info() const
MaglevCodeGenState * code_gen_state() const
void OSRPrologue(Graph *graph)
void LoadTaggedFieldByIndex(Register result, Register object, Register index, int scale, int offset)
void TryChangeFloat64ToIndex(Register result, DoubleRegister value, Label *success, Label *fail)
void JumpIf(Condition cond, Label *target, Label::Distance distance=Label::kFar)
void LoadTaggedField(Register result, MemOperand operand)
#define ASM_CODE_COMMENT_STRING(asm,...)
ZoneVector< RpoNumber > & result
void AllocateSlow(MaglevAssembler *masm, RegisterSnapshot register_snapshot, Register object, Builtin builtin, T size_in_bytes, ZoneLabelRef done)
Builtin AllocateBuiltin(AllocationType alloc_type)
ExternalReference SpaceAllocationTopAddress(Isolate *isolate, AllocationType alloc_type)
void SubSizeAndTagObject(MaglevAssembler *masm, Register object, Register size_in_bytes)
void AllocateRaw(MaglevAssembler *masm, Isolate *isolate, RegisterSnapshot register_snapshot, Register object, T size_in_bytes, AllocationType alloc_type, AllocationAlignment alignment)
ExternalReference SpaceAllocationLimitAddress(Isolate *isolate, AllocationType alloc_type)
const uint32_t kStringEncodingMask
constexpr int kTaggedSize
@ kUnsignedGreaterThanEqual
DwVfpRegister DoubleRegister
const uint32_t kTwoByteStringTag
constexpr InstanceType LAST_STRING_TYPE
constexpr Register kJavaScriptCallArgCountRegister
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
MemOperand FieldMemOperand(Register object, int offset)
constexpr int kSystemPointerSize
constexpr Register kReturnRegister0
const uint32_t kStringRepresentationMask
constexpr Register kContextRegister
V8_EXPORT_PRIVATE bool AreAliased(const CPURegister ®1, const CPURegister ®2, const CPURegister ®3=NoReg, const CPURegister ®4=NoReg, const CPURegister ®5=NoReg, const CPURegister ®6=NoReg, const CPURegister ®7=NoReg, const CPURegister ®8=NoReg)
V8_EXPORT_PRIVATE FlagValues v8_flags
constexpr int kDoubleSize
constexpr Register kJavaScriptCallNewTargetRegister
constexpr Register kJSFunctionRegister
template const char * string
BytecodeSequenceNode * parent_
#define CHECK_LE(lhs, rhs)
#define DCHECK_NE(v1, v2)
#define DCHECK(condition)
#define DCHECK_EQ(v1, v2)
#define DCHECK_GT(v1, v2)
#define OFFSET_OF_DATA_START(Type)