[maglev] Change PushDeferredCode to return a Label
Change PushDeferredCode into MakeDeferredCode, and have it return a Label*. This allows it to be passed in directly to functions expecting a Label, e.g. JumpToDeferredIf(cond, [](){...}); could be replaced by JumpIf(cond, MakeDeferredCode([](){...})); and we don't need to add "ToDeferred" overloads for the other Jump helpers (JumpIfSmi etc.). Bug: v8:7700 Change-Id: I716468030601964fba828666fde6aa4f2ed29c3a Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4218392 Auto-Submit: Leszek Swirski <leszeks@chromium.org> Reviewed-by: Victor Gomes <victorgomes@chromium.org> Commit-Queue: Victor Gomes <victorgomes@chromium.org> Cr-Commit-Position: refs/heads/main@{#85637}
This commit is contained in:
parent
7b86d3c7ec
commit
2c9f7ac40d
@ -314,7 +314,7 @@ void MaglevAssembler::Prologue(Graph* graph) {
|
||||
Register flags = temps.Acquire();
|
||||
Register feedback_vector = temps.Acquire();
|
||||
|
||||
DeferredCodeInfo* deferred_flags_need_processing = PushDeferredCode(
|
||||
Label* deferred_flags_need_processing = MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, Register flags, Register feedback_vector) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Optimized marker check");
|
||||
// TODO(leszeks): This could definitely be a builtin that we
|
||||
@ -328,7 +328,7 @@ void MaglevAssembler::Prologue(Graph* graph) {
|
||||
compilation_info()->toplevel_compilation_unit()->feedback().object());
|
||||
LoadFeedbackVectorFlagsAndJumpIfNeedsProcessing(
|
||||
flags, feedback_vector, CodeKind::MAGLEV,
|
||||
&deferred_flags_need_processing->deferred_code_label);
|
||||
deferred_flags_need_processing);
|
||||
}
|
||||
|
||||
EnterFrame(StackFrame::MAGLEV);
|
||||
@ -538,7 +538,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
Label cons_string;
|
||||
Label sliced_string;
|
||||
|
||||
DeferredCodeInfo* deferred_runtime_call = PushDeferredCode(
|
||||
Label* deferred_runtime_call = MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, RegisterSnapshot register_snapshot,
|
||||
ZoneLabelRef done, Register result, Register string, Register index) {
|
||||
DCHECK(!register_snapshot.live_registers.has(result));
|
||||
@ -598,7 +598,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
Cmp(representation, Immediate(kSlicedStringTag));
|
||||
B(&sliced_string, eq);
|
||||
Cmp(representation, Immediate(kThinStringTag));
|
||||
B(&deferred_runtime_call->deferred_code_label, ne);
|
||||
B(deferred_runtime_call, ne);
|
||||
// Fallthrough to thin string.
|
||||
}
|
||||
|
||||
@ -629,7 +629,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
Register second_string = instance_type;
|
||||
Ldr(second_string.W(), FieldMemOperand(string, ConsString::kSecondOffset));
|
||||
CompareRoot(second_string, RootIndex::kempty_string);
|
||||
B(&deferred_runtime_call->deferred_code_label, ne);
|
||||
B(deferred_runtime_call, ne);
|
||||
DecompressAnyTagged(string,
|
||||
FieldMemOperand(string, ConsString::kFirstOffset));
|
||||
B(&loop); // Try again with first string.
|
||||
|
@ -1247,7 +1247,7 @@ void CheckJSDataViewBounds::GenerateCode(MaglevAssembler* masm,
|
||||
}
|
||||
|
||||
ZoneLabelRef done_byte_length(masm);
|
||||
DeferredCodeInfo* deferred_get_byte_length = __ PushDeferredCode(
|
||||
Label* deferred_get_byte_length = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, CheckJSDataViewBounds* node, ZoneLabelRef done,
|
||||
Register object, Register index, Register byte_length) {
|
||||
RegisterSnapshot snapshot = node->register_snapshot();
|
||||
@ -1271,7 +1271,7 @@ void CheckJSDataViewBounds::GenerateCode(MaglevAssembler* masm,
|
||||
},
|
||||
this, done_byte_length, object, index, byte_length);
|
||||
__ Ldr(scratch.W(), FieldMemOperand(object, JSDataView::kBitFieldOffset));
|
||||
__ Cbnz(scratch.W(), &deferred_get_byte_length->deferred_code_label);
|
||||
__ Cbnz(scratch.W(), deferred_get_byte_length);
|
||||
|
||||
// Normal DataView (backed by AB / SAB) or non-length tracking backed by GSAB.
|
||||
__ LoadBoundedSizeFromObject(byte_length, object,
|
||||
@ -1421,7 +1421,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
WriteBarrierDescriptor::SlotAddressRegister());
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register array, GeneratorStore* node, int32_t offset) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -1453,7 +1453,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
// Consider hoisting the check out of the loop and duplicating the loop into
|
||||
// with and without write barrier.
|
||||
__ CheckPageFlag(array, MemoryChunk::kPointersFromHereAreInterestingMask,
|
||||
ne, &deferred_write_barrier->deferred_code_label);
|
||||
ne, deferred_write_barrier);
|
||||
|
||||
__ bind(*done);
|
||||
}
|
||||
@ -1464,7 +1464,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
context_input(), WriteBarrierDescriptor::SlotAddressRegister());
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_context_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_context_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register context,
|
||||
Register generator, GeneratorStore* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -1499,7 +1499,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
context, FieldMemOperand(generator, JSGeneratorObject::kContextOffset));
|
||||
__ AssertNotSmi(context);
|
||||
__ CheckPageFlag(generator, MemoryChunk::kPointersFromHereAreInterestingMask,
|
||||
ne, &deferred_context_write_barrier->deferred_code_label);
|
||||
ne, deferred_context_write_barrier);
|
||||
__ bind(*done);
|
||||
|
||||
MaglevAssembler::ScratchRegisterScope temps(masm);
|
||||
@ -1857,7 +1857,7 @@ void StoreMap::GenerateCode(MaglevAssembler* masm,
|
||||
__ StoreTaggedField(value, FieldMemOperand(object, HeapObject::kMapOffset));
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register object, StoreMap* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -1888,7 +1888,7 @@ void StoreMap::GenerateCode(MaglevAssembler* masm,
|
||||
|
||||
__ JumpIfSmi(value, *done);
|
||||
__ CheckPageFlag(object, MemoryChunk::kPointersFromHereAreInterestingMask, ne,
|
||||
&deferred_write_barrier->deferred_code_label);
|
||||
deferred_write_barrier);
|
||||
__ bind(*done);
|
||||
}
|
||||
|
||||
@ -2147,7 +2147,7 @@ void StoreTaggedFieldWithWriteBarrier::GenerateCode(
|
||||
__ StoreTaggedField(FieldMemOperand(object, offset()), value);
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register object, StoreTaggedFieldWithWriteBarrier* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -2178,7 +2178,7 @@ void StoreTaggedFieldWithWriteBarrier::GenerateCode(
|
||||
|
||||
__ JumpIfSmi(value, *done);
|
||||
__ CheckPageFlag(object, MemoryChunk::kPointersFromHereAreInterestingMask, ne,
|
||||
&deferred_write_barrier->deferred_code_label);
|
||||
deferred_write_barrier);
|
||||
|
||||
__ bind(*done);
|
||||
}
|
||||
@ -2246,7 +2246,7 @@ void ThrowIfNotSuperConstructor::SetValueLocationConstraints() {
|
||||
}
|
||||
void ThrowIfNotSuperConstructor::GenerateCode(MaglevAssembler* masm,
|
||||
const ProcessingState& state) {
|
||||
DeferredCodeInfo* deferred_abort = __ PushDeferredCode(
|
||||
Label* deferred_abort = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ThrowIfNotSuperConstructor* node) {
|
||||
__ Push(ToRegister(node->constructor()), ToRegister(node->function()));
|
||||
__ Move(kContextRegister, masm->native_context().object());
|
||||
@ -2260,7 +2260,7 @@ void ThrowIfNotSuperConstructor::GenerateCode(MaglevAssembler* masm,
|
||||
__ LoadMap(scratch, ToRegister(constructor()));
|
||||
__ Ldr(scratch, FieldMemOperand(scratch, Map::kBitFieldOffset));
|
||||
__ TestAndBranchIfAllClear(scratch, Map::Bits1::IsConstructorBit::kMask,
|
||||
&deferred_abort->deferred_code_label);
|
||||
deferred_abort);
|
||||
}
|
||||
|
||||
// ---
|
||||
|
@ -167,8 +167,8 @@ class DeferredCodeInfoImpl final : public DeferredCodeInfo {
|
||||
} // namespace detail
|
||||
|
||||
template <typename Function, typename... Args>
|
||||
inline DeferredCodeInfo* MaglevAssembler::PushDeferredCode(
|
||||
Function&& deferred_code_gen, Args&&... args) {
|
||||
inline Label* MaglevAssembler::MakeDeferredCode(Function&& deferred_code_gen,
|
||||
Args&&... args) {
|
||||
using FunctionPointer =
|
||||
typename detail::FunctionArgumentsTupleHelper<Function>::FunctionPointer;
|
||||
static_assert(
|
||||
@ -177,7 +177,7 @@ inline DeferredCodeInfo* MaglevAssembler::PushDeferredCode(
|
||||
std::declval<MaglevCompilationInfo*>(),
|
||||
std::declval<Args>()))...>,
|
||||
"Parameters of deferred_code_gen function should match arguments into "
|
||||
"PushDeferredCode");
|
||||
"MakeDeferredCode");
|
||||
|
||||
ScratchRegisterScope scratch_scope(this);
|
||||
using DeferredCodeInfoT = detail::DeferredCodeInfoImpl<Function>;
|
||||
@ -188,7 +188,7 @@ inline DeferredCodeInfo* MaglevAssembler::PushDeferredCode(
|
||||
std::forward<Args>(args)...);
|
||||
|
||||
code_gen_state()->PushDeferredCode(deferred_code);
|
||||
return deferred_code;
|
||||
return &deferred_code->deferred_code_label;
|
||||
}
|
||||
|
||||
// Note this doesn't take capturing lambdas by design, since state may
|
||||
@ -198,12 +198,12 @@ template <typename Function, typename... Args>
|
||||
inline void MaglevAssembler::JumpToDeferredIf(Condition cond,
|
||||
Function&& deferred_code_gen,
|
||||
Args&&... args) {
|
||||
DeferredCodeInfo* deferred_code = PushDeferredCode<Function, Args...>(
|
||||
std::forward<Function>(deferred_code_gen), std::forward<Args>(args)...);
|
||||
if (v8_flags.code_comments) {
|
||||
RecordComment("-- Jump to deferred code");
|
||||
}
|
||||
JumpIf(cond, &deferred_code->deferred_code_label);
|
||||
JumpIf(cond, MakeDeferredCode<Function, Args...>(
|
||||
std::forward<Function>(deferred_code_gen),
|
||||
std::forward<Args>(args)...));
|
||||
}
|
||||
|
||||
inline void MaglevAssembler::SmiToDouble(DoubleRegister result, Register smi) {
|
||||
|
@ -150,12 +150,10 @@ class MaglevAssembler : public MacroAssembler {
|
||||
inline void DefineExceptionHandlerAndLazyDeoptPoint(NodeBase* node);
|
||||
|
||||
template <typename Function, typename... Args>
|
||||
inline DeferredCodeInfo* PushDeferredCode(Function&& deferred_code_gen,
|
||||
Args&&... args);
|
||||
inline Label* MakeDeferredCode(Function&& deferred_code_gen, Args&&... args);
|
||||
template <typename Function, typename... Args>
|
||||
inline void JumpToDeferredIf(Condition cond, Function&& deferred_code_gen,
|
||||
Args&&... args);
|
||||
|
||||
template <typename NodeT>
|
||||
inline Label* GetDeoptLabel(NodeT* node, DeoptimizeReason reason);
|
||||
template <typename NodeT>
|
||||
|
@ -160,7 +160,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
Label cons_string;
|
||||
Label sliced_string;
|
||||
|
||||
DeferredCodeInfo* deferred_runtime_call = PushDeferredCode(
|
||||
Label* deferred_runtime_call = MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, RegisterSnapshot register_snapshot,
|
||||
ZoneLabelRef done, Register result, Register string, Register index) {
|
||||
DCHECK(!register_snapshot.live_registers.has(result));
|
||||
@ -218,7 +218,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
cmpl(representation, Immediate(kSlicedStringTag));
|
||||
j(equal, &sliced_string, Label::kNear);
|
||||
cmpl(representation, Immediate(kThinStringTag));
|
||||
j(not_equal, &deferred_runtime_call->deferred_code_label);
|
||||
j(not_equal, deferred_runtime_call);
|
||||
// Fallthrough to thin string.
|
||||
}
|
||||
|
||||
@ -244,7 +244,7 @@ void MaglevAssembler::StringCharCodeAt(RegisterSnapshot& register_snapshot,
|
||||
{
|
||||
CompareRoot(FieldOperand(string, ConsString::kSecondOffset),
|
||||
RootIndex::kempty_string);
|
||||
j(not_equal, &deferred_runtime_call->deferred_code_label);
|
||||
j(not_equal, deferred_runtime_call);
|
||||
DecompressAnyTagged(string, FieldOperand(string, ConsString::kFirstOffset));
|
||||
jmp(&loop, Label::kNear); // Try again with first string.
|
||||
}
|
||||
@ -499,7 +499,7 @@ void MaglevAssembler::Prologue(Graph* graph) {
|
||||
Register flags = rcx;
|
||||
Register feedback_vector = r9;
|
||||
|
||||
DeferredCodeInfo* deferred_flags_need_processing = PushDeferredCode(
|
||||
Label* deferred_flags_need_processing = MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, Register flags, Register feedback_vector) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Optimized marker check");
|
||||
// TODO(leszeks): This could definitely be a builtin that we
|
||||
@ -514,7 +514,7 @@ void MaglevAssembler::Prologue(Graph* graph) {
|
||||
compilation_info()->toplevel_compilation_unit()->feedback().object());
|
||||
LoadFeedbackVectorFlagsAndJumpIfNeedsProcessing(
|
||||
flags, feedback_vector, CodeKind::MAGLEV,
|
||||
&deferred_flags_need_processing->deferred_code_label);
|
||||
deferred_flags_need_processing);
|
||||
}
|
||||
|
||||
EnterFrame(StackFrame::MAGLEV);
|
||||
|
@ -71,7 +71,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
WriteBarrierDescriptor::SlotAddressRegister());
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register array, GeneratorStore* node, int32_t offset) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -107,7 +107,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
// with and without write barrier.
|
||||
__ CheckPageFlag(array, kScratchRegister,
|
||||
MemoryChunk::kPointersFromHereAreInterestingMask, not_zero,
|
||||
&deferred_write_barrier->deferred_code_label);
|
||||
deferred_write_barrier);
|
||||
|
||||
__ bind(*done);
|
||||
}
|
||||
@ -118,7 +118,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
context_input(), WriteBarrierDescriptor::SlotAddressRegister());
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_context_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_context_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register context,
|
||||
Register generator, GeneratorStore* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -156,7 +156,7 @@ void GeneratorStore::GenerateCode(MaglevAssembler* masm,
|
||||
__ AssertNotSmi(context);
|
||||
__ CheckPageFlag(generator, kScratchRegister,
|
||||
MemoryChunk::kPointersFromHereAreInterestingMask, not_zero,
|
||||
&deferred_context_write_barrier->deferred_code_label);
|
||||
deferred_context_write_barrier);
|
||||
__ bind(*done);
|
||||
|
||||
__ StoreTaggedSignedField(
|
||||
@ -1117,7 +1117,7 @@ void StoreMap::GenerateCode(MaglevAssembler* masm,
|
||||
kScratchRegister);
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register object, StoreMap* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -1150,7 +1150,7 @@ void StoreMap::GenerateCode(MaglevAssembler* masm,
|
||||
__ JumpIfSmi(value, *done);
|
||||
__ CheckPageFlag(object, kScratchRegister,
|
||||
MemoryChunk::kPointersFromHereAreInterestingMask, not_zero,
|
||||
&deferred_write_barrier->deferred_code_label);
|
||||
deferred_write_barrier);
|
||||
__ bind(*done);
|
||||
}
|
||||
|
||||
@ -1174,7 +1174,7 @@ void StoreTaggedFieldWithWriteBarrier::GenerateCode(
|
||||
__ StoreTaggedField(FieldOperand(object, offset()), value);
|
||||
|
||||
ZoneLabelRef done(masm);
|
||||
DeferredCodeInfo* deferred_write_barrier = __ PushDeferredCode(
|
||||
Label* deferred_write_barrier = __ MakeDeferredCode(
|
||||
[](MaglevAssembler* masm, ZoneLabelRef done, Register value,
|
||||
Register object, StoreTaggedFieldWithWriteBarrier* node) {
|
||||
ASM_CODE_COMMENT_STRING(masm, "Write barrier slow path");
|
||||
@ -1207,7 +1207,7 @@ void StoreTaggedFieldWithWriteBarrier::GenerateCode(
|
||||
__ JumpIfSmi(value, *done);
|
||||
__ CheckPageFlag(object, kScratchRegister,
|
||||
MemoryChunk::kPointersFromHereAreInterestingMask, not_zero,
|
||||
&deferred_write_barrier->deferred_code_label);
|
||||
deferred_write_barrier);
|
||||
__ bind(*done);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user