Commit 99ca63fd authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/s390: [builtins][masm] Move hot flags to the beginning of IsolateData

Port 8a56da44

Original Commit Message:

    ... so that the offset fits into the maximum offset for load byte
    instruction for arm/arm64 (Ldrb) in order to produce smaller code.

    Update code generation so that the loading of the flag value is
    combined with the comparison operation where possible.

    Additionally, this CL moves the Isolate::is_profiling flag to the
    IsolateData so that it can be loaded directly via roots register which
    removes one indirection.

    The fields moved in the IsolateData:
     - is_marking_flag and is_minor_marking_flag (checked by write barriers)
     - is_profiling (checked on API callbacks/getter calls)
     - stack_is_iterable (not super hot, checked during deoptimization).

    the field size expectations clear.

R=ishell@chromium.org, joransiu@ca.ibm.com, junyan@redhat.com, midawson@redhat.com
BUG=
LOG=N

Change-Id: Ibafb23e9a035caffe6921a304a3d318b54732167
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3862227Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#82790}
parent 788be906
......@@ -3206,8 +3206,9 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ stw(r16, MemOperand(r17, kLevelOffset));
Label profiler_enabled, done_api_call;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ lbz(scratch, MemOperand(scratch, 0));
__ lbz(scratch,
__ ExternalReferenceAsOperand(
ExternalReference::is_profiling_address(isolate), scratch));
__ cmpi(scratch, Operand::Zero());
__ bne(&profiler_enabled);
#ifdef V8_RUNTIME_CALL_STATS
......
......@@ -3193,8 +3193,9 @@ static void CallApiFunctionAndReturn(MacroAssembler* masm,
__ StoreU32(r8, MemOperand(r9, kLevelOffset));
Label profiler_enabled, done_api_call;
__ Move(scratch, ExternalReference::is_profiling_address(isolate));
__ LoadU8(scratch, MemOperand(scratch, 0));
__ LoadU8(scratch,
__ ExternalReferenceAsOperand(
ExternalReference::is_profiling_address(isolate), scratch));
__ CmpS64(scratch, Operand::Zero());
__ bne(&profiler_enabled, Label::kNear);
#ifdef V8_RUNTIME_CALL_STATS
......
......@@ -140,6 +140,36 @@ void TurboAssembler::LoadRootRegisterOffset(Register destination,
}
}
MemOperand TurboAssembler::ExternalReferenceAsOperand(
ExternalReference reference, Register scratch) {
if (root_array_available_ && options().enable_root_relative_access) {
int64_t offset =
RootRegisterOffsetForExternalReference(isolate(), reference);
if (is_int32(offset)) {
return MemOperand(kRootRegister, static_cast<int32_t>(offset));
}
}
if (root_array_available_ && options().isolate_independent_code) {
if (IsAddressableThroughRootRegister(isolate(), reference)) {
// Some external references can be efficiently loaded as an offset from
// kRootRegister.
intptr_t offset =
RootRegisterOffsetForExternalReference(isolate(), reference);
CHECK(is_int32(offset));
return MemOperand(kRootRegister, static_cast<int32_t>(offset));
} else {
// Otherwise, do a memory load from the external reference table.
LoadU64(scratch,
MemOperand(kRootRegister,
RootRegisterOffsetForExternalReferenceTableEntry(
isolate(), reference)));
return MemOperand(scratch, 0);
}
}
Move(scratch, reference);
return MemOperand(scratch, 0);
}
void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode,
Condition cond, CRegister cr) {
Label skip;
......
......@@ -697,6 +697,15 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void LoadRootRegisterOffset(Register destination, intptr_t offset) final;
void LoadRootRelative(Register destination, int32_t offset) final;
// Operand pointing to an external reference.
// May emit code to set up the scratch register. The operand is
// only guaranteed to be correct as long as the scratch register
// isn't changed.
// If the operand is used more than once, use a scratch register
// that is guaranteed not to be clobbered.
MemOperand ExternalReferenceAsOperand(ExternalReference reference,
Register scratch);
// Jump, Call, and Ret pseudo instructions implementing inter-working.
void Jump(Register target);
void Jump(Address target, RelocInfo::Mode rmode, Condition cond = al,
......
......@@ -366,6 +366,36 @@ void TurboAssembler::LoadRootRegisterOffset(Register destination,
}
}
MemOperand TurboAssembler::ExternalReferenceAsOperand(
ExternalReference reference, Register scratch) {
if (root_array_available_ && options().enable_root_relative_access) {
int64_t offset =
RootRegisterOffsetForExternalReference(isolate(), reference);
if (is_int32(offset)) {
return MemOperand(kRootRegister, static_cast<int32_t>(offset));
}
}
if (root_array_available_ && options().isolate_independent_code) {
if (IsAddressableThroughRootRegister(isolate(), reference)) {
// Some external references can be efficiently loaded as an offset from
// kRootRegister.
intptr_t offset =
RootRegisterOffsetForExternalReference(isolate(), reference);
CHECK(is_int32(offset));
return MemOperand(kRootRegister, static_cast<int32_t>(offset));
} else {
// Otherwise, do a memory load from the external reference table.
LoadU64(scratch,
MemOperand(kRootRegister,
RootRegisterOffsetForExternalReferenceTableEntry(
isolate(), reference)));
return MemOperand(scratch, 0);
}
}
Move(scratch, reference);
return MemOperand(scratch, 0);
}
void TurboAssembler::Jump(Register target, Condition cond) { b(cond, target); }
void TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode,
......
......@@ -84,6 +84,15 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void LoadRootRegisterOffset(Register destination, intptr_t offset) final;
void LoadRootRelative(Register destination, int32_t offset) final;
// Operand pointing to an external reference.
// May emit code to set up the scratch register. The operand is
// only guaranteed to be correct as long as the scratch register
// isn't changed.
// If the operand is used more than once, use a scratch register
// that is guaranteed not to be clobbered.
MemOperand ExternalReferenceAsOperand(ExternalReference reference,
Register scratch);
// Jump, Call, and Ret pseudo instructions implementing inter-working.
void Jump(Register target, Condition cond = al);
void Jump(Address target, RelocInfo::Mode rmode, Condition cond = al);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment