24void LoadNewAllocationTop(MaglevAssembler* masm, Register new_top,
25 Register
object,
int size_in_bytes) {
26 __ leaq(new_top, Operand(
object, size_in_bytes));
29void LoadNewAllocationTop(MaglevAssembler* masm, Register new_top,
30 Register
object, Register size_in_bytes) {
31 __ Move(new_top,
object);
32 __ addq(new_top, size_in_bytes);
36void AllocateRaw(MaglevAssembler* masm, Isolate* isolate,
37 RegisterSnapshot register_snapshot, Register
object,
48 ZoneLabelRef done(masm);
51 __ Move(
object,
__ ExternalReferenceAsOperand(top));
52 LoadNewAllocationTop(masm, new_top,
object, size_in_bytes);
53 __ cmpq(new_top,
__ ExternalReferenceAsOperand(limit));
59 __ movq(
__ ExternalReferenceAsOperand(top), new_top);
66 Register
object,
int size_in_bytes,
70 alloc_type, alignment);
74 Register
object, Register size_in_bytes,
78 alloc_type, alignment);
91 LoadRoot(table, RootIndex::kSingleCharacterStringTable);
97 Label* char_code_fits_one_byte,
98 Register
result, Register char_code,
100 CharCodeMaskMode mask_mode) {
102 ZoneLabelRef done(
this);
104 andl(char_code, Immediate(0xFFFF));
110 ZoneLabelRef done, Register
result, Register char_code,
117 if (char_code ==
result) {
121 __ Move(scratch, char_code);
124 DCHECK(!register_snapshot.live_tagged_registers.has(char_code));
125 register_snapshot.live_registers.set(char_code);
131 register_snapshot, done,
result, char_code, scratch);
132 if (char_code_fits_one_byte !=
nullptr) {
133 bind(char_code_fits_one_byte);
141 RegisterSnapshot& register_snapshot, Register
result, Register
string,
142 Register index, Register scratch1, Register scratch2,
143 Label* result_fits_one_byte) {
144 ZoneLabelRef done(
this);
152 RegisterSnapshot register_snapshot, ZoneLabelRef done, Register
result,
153 Register
string, Register index) {
155 DCHECK(!register_snapshot.live_registers.has(
string));
156 DCHECK(!register_snapshot.live_registers.has(index));
158 SaveRegisterStateForCall save_register_state(masm, register_snapshot);
172 save_register_state.DefineSafepoint();
194 cmpl(index, scratch1);
198#if V8_STATIC_ROOTS_BOOL
208#if V8_STATIC_ROOTS_BOOL
209 using StringTypeRange = InstanceTypeChecker::kUniqueMapRangeOfStringType;
212 static_assert(StringTypeRange::kSeqString.first == 0);
216 static_assert(StringTypeRange::kSeqString.second + Map::kSize ==
217 StringTypeRange::kExternalString.first);
222 static_assert(StringTypeRange::kExternalString.second + Map::kSize ==
223 StringTypeRange::kConsString.first);
227 static_assert(StringTypeRange::kConsString.second + Map::kSize ==
228 StringTypeRange::kSlicedString.first);
232 static_assert(StringTypeRange::kSlicedString.second + Map::kSize ==
233 StringTypeRange::kThinString.first);
235 static_assert(StringTypeRange::kThinString.second ==
236 InstanceTypeChecker::kStringMapUpperBound);
241 movl(representation, instance_type);
261 bind(&sliced_string);
265 offsetof(SlicedString,
offset_));
274 RootIndex::kempty_string);
282 Label two_byte_string;
283#if V8_STATIC_ROOTS_BOOL
284 if (InstanceTypeChecker::kTwoByteStringMapBit == 0) {
286 InstanceTypeChecker::kStringMapEncodingMask,
302 jmp(result_fits_one_byte);
303 bind(&two_byte_string);
313 string_backup = scratch2;
314 movq(string_backup,
string);
319 Register first_code_point = scratch1;
321 andl(first_code_point, Immediate(0xfc00));
322 cmpl(first_code_point, Immediate(0xd800));
331 Register second_code_point = scratch1;
332 movzxwl(second_code_point,
335 movl(scratch2, second_code_point);
336 andl(scratch2, Immediate(0xfc00));
337 cmpl(scratch2, Immediate(0xdc00));
340 int surrogate_offset = 0x10000 - (0xd800 << 10) - 0xdc00;
341 addl(second_code_point, Immediate(surrogate_offset));
343 addl(
result, second_code_point);
355 movl(
string, Immediate(0xdeadbeef));
358 movl(index, Immediate(0xdeadbeef));
364 ZoneLabelRef done(
this);
368 cmpq(dst, Immediate(1));
407 cmpl(dst, Immediate(0));
412 Pextrd(high_word32_of_input, src, 1);
413 cmpl(high_word32_of_input, Immediate(0));
432 Ucomisd(src, converted_back);
438 cmpl(dst, Immediate(0));
443 Pextrd(high_word32_of_input, src, 1);
444 cmpl(high_word32_of_input, Immediate(0));
452 Label* success, Label* fail) {
470 CHECK(!graph->has_recursive_calls());
472 uint32_t source_frame_size =
473 graph->min_maglev_stackslots_for_unoptimized_frame_size();
484 uint32_t target_frame_size =
485 graph->tagged_stack_slots() + graph->untagged_stack_slots();
486 CHECK_LE(source_frame_size, target_frame_size);
488 if (source_frame_size < target_frame_size) {
491 uint32_t additional_tagged =
492 source_frame_size < graph->tagged_stack_slots()
493 ? graph->tagged_stack_slots() - source_frame_size
495 for (
size_t i = 0;
i < additional_tagged; ++
i) {
498 uint32_t size_so_far = source_frame_size + additional_tagged;
499 CHECK_LE(size_so_far, target_frame_size);
500 if (size_so_far < target_frame_size) {
514 if (graph->has_recursive_calls()) {
518#ifndef V8_ENABLE_LEAPTIERING
521 using D = MaglevOptimizeCodeOrTailCallOptimizedCodeSlotDescriptor;
522 Register feedback_vector = D::GetRegisterParameter(D::kFeedbackVector);
527 Move(feedback_vector,
529 TailCallBuiltin(Builtin::kMaglevOptimizeCodeOrTailCallOptimizedCodeSlot,
544 if (graph->tagged_stack_slots() > 0) {
551 const int kLoopUnrollSize = 8;
562 for (
int i = 0;
i < first_slots; ++
i) {
571 for (
int i = 0;
i < kLoopUnrollSize; ++
i) {
578 if (graph->untagged_stack_slots() > 0) {
586 Label* eager_deopt_entry,
587 size_t lazy_deopt_count,
588 Label* lazy_deopt_entry) {}
#define Assert(condition)
void shll(const VRegister &vd, const VRegister &vn, int shift)
void j(Condition cc, Label *L, Label::Distance distance=Label::kFar)
void pushq(Immediate value)
void movw(Register reg, uint32_t immediate, Condition cond=al)
void movl(Operand dst, Label *src)
void movq(XMMRegister dst, Operand src)
void Cvttsd2si(Register dst, XMMRegister src)
void Cvttsd2siq(Register dst, XMMRegister src)
void CmpInstanceTypeRange(Register map, Register instance_type_out, Register scratch, InstanceType lower_limit, InstanceType higher_limit)
void SmiUntag(Register reg, SBit s=LeaveCC)
void AssertNotSmi(Register object, AbortReason reason=AbortReason::kOperandIsASmi) NOOP_UNLESS_DEBUG_CODE
void CompareRoot(Register obj, RootIndex index)
void Cvtqsi2sd(XMMRegister dst, Register src)
void BailoutIfDeoptimized()
void SmiTag(Register reg, SBit s=LeaveCC)
void SbxCheck(Condition cc, AbortReason reason)
void LoadRoot(Register destination, RootIndex index) final
void EnterFrame(StackFrame::Type type, bool load_constant_pool_pointer_reg=false)
void Check(Condition cond, AbortReason reason)
void AllocateStackSpace(Register bytes)
void AssertZeroExtended(Register int32_register)
Condition CheckFeedbackVectorFlagsNeedsProcessing(Register feedback_vector, CodeKind current_code_kind)
void LoadMap(Register destination, Register object)
void TailCallBuiltin(Builtin builtin, Condition cond=al)
void Pextrd(Register dst, XMMRegister src, uint8_t imm8)
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 StringFromCharCode(RegisterSnapshot register_snapshot, Label *char_code_fits_one_byte, Register result, Register char_code, Register scratch, CharCodeMaskMode mask_mode)
void StringLength(Register result, Register string)
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 LoadMapForCompare(Register dst, Register obj)
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
void TestInt32AndJumpIfAllClear(Register r1, int32_t mask, Label *target, Label::Distance distance=Label::kFar)
void CompareInt32AndJumpIf(Register r1, Register r2, Condition cond, Label *target, Label::Distance distance=Label::kFar)
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)
void TestInt32AndJumpIfAnySet(Register r1, int32_t mask, Label *target, Label::Distance distance=Label::kFar)
void BindJumpTarget(Label *label)
#define ASM_CODE_COMMENT_STRING(asm,...)
#define V8_ENABLE_SANDBOX_BOOL
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 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 DoubleRegister kScratchDoubleReg
Operand FieldOperand(Register object, int offset)
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
constexpr int kSystemPointerSize
constexpr Register kReturnRegister0
constexpr Register kScratchRegister
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 kJavaScriptCallDispatchHandleRegister
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)