PPC/s390: [codegen] Optimize out calls to TurboAssembler::Assert*

Port c3ca815877

Original Commit Message:

    In release builds, FLAG_debug_code is statically false. Without LTO,
    this information is not available to callers of the various Assert
    functions though.
    This CL defines the methods as empty if V8_ENABLE_DEBUG_CODE is not set.
    This removes some calls from non-LTO builds, and might even slightly
    improve LTO builds if we enable more optimizations earlier in the
    pipeline.

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

Change-Id: I5c82eed38db6a2f49e833410554231bc61518b18
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3820068
Reviewed-by: Clemens Backes <clemensb@chromium.org>
Commit-Queue: Milad Farazmand <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#82344}
This commit is contained in:
Milad Fa 2022-08-09 14:15:23 -04:00 committed by V8 LUCI CQ
parent 01aed57e68
commit 45a74f3a51
4 changed files with 40 additions and 31 deletions

View File

@ -2063,10 +2063,6 @@ void MacroAssembler::EmitDecrementCounter(StatsCounter* counter, int value,
}
}
void TurboAssembler::Assert(Condition cond, AbortReason reason, CRegister cr) {
if (FLAG_debug_code) Check(cond, reason, cr);
}
void TurboAssembler::Check(Condition cond, AbortReason reason, CRegister cr) {
Label L;
b(cond, &L, cr);
@ -2133,6 +2129,11 @@ void MacroAssembler::LoadNativeContextSlot(Register dst, int index) {
LoadTaggedPointerField(dst, MemOperand(dst, Context::SlotOffset(index)), r0);
}
#ifdef V8_ENABLE_DEBUG_CODE
void TurboAssembler::Assert(Condition cond, AbortReason reason, CRegister cr) {
if (FLAG_debug_code) Check(cond, reason, cr);
}
void TurboAssembler::AssertNotSmi(Register object) {
if (FLAG_debug_code) {
static_assert(kSmiTag == 0);
@ -2235,6 +2236,7 @@ void MacroAssembler::AssertUndefinedOrAllocationSite(Register object,
bind(&done_checking);
}
}
#endif // V8_ENABLE_DEBUG_CODE
static const int kRegisterPassedArguments = 8;

View File

@ -668,7 +668,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Calls Abort(msg) if the condition cond is not satisfied.
// Use --debug_code to enable.
void Assert(Condition cond, AbortReason reason, CRegister cr = cr7);
void Assert(Condition cond, AbortReason reason,
CRegister cr = cr7) NOOP_UNLESS_DEBUG_CODE;
// Like Assert(), but always enabled.
void Check(Condition cond, AbortReason reason, CRegister cr = cr7);
@ -807,8 +808,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
// Abort execution if argument is a smi, enabled via --debug-code.
void AssertNotSmi(Register object);
void AssertSmi(Register object);
void AssertNotSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
void AssertSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
void ZeroExtByte(Register dst, Register src);
void ZeroExtHalfWord(Register dst, Register src);
@ -1383,26 +1384,27 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
#endif
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object);
void AssertConstructor(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object);
void AssertFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a callable JSFunction, enabled via
// --debug-code.
void AssertCallableFunction(Register object);
void AssertCallableFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSBoundFunction,
// enabled via --debug-code.
void AssertBoundFunction(Register object);
void AssertBoundFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSGeneratorObject (or subclass),
// enabled via --debug-code.
void AssertGeneratorObject(Register object);
void AssertGeneratorObject(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not undefined or an AllocationSite, enabled
// via --debug-code.
void AssertUndefinedOrAllocationSite(Register object, Register scratch);
void AssertUndefinedOrAllocationSite(Register object,
Register scratch) NOOP_UNLESS_DEBUG_CODE;
// ---------------------------------------------------------------------------
// Patching helpers.

View File

@ -2063,14 +2063,6 @@ void MacroAssembler::EmitDecrementCounter(StatsCounter* counter, int value,
}
}
void TurboAssembler::Assert(Condition cond, AbortReason reason, CRegister cr) {
if (FLAG_debug_code) Check(cond, reason, cr);
}
void TurboAssembler::AssertUnreachable(AbortReason reason) {
if (FLAG_debug_code) Abort(reason);
}
void TurboAssembler::Check(Condition cond, AbortReason reason, CRegister cr) {
Label L;
b(cond, &L);
@ -2139,6 +2131,15 @@ void MacroAssembler::LoadNativeContextSlot(Register dst, int index) {
LoadTaggedPointerField(dst, MemOperand(dst, Context::SlotOffset(index)));
}
#ifdef V8_ENABLE_DEBUG_CODE
void TurboAssembler::Assert(Condition cond, AbortReason reason, CRegister cr) {
if (FLAG_debug_code) Check(cond, reason, cr);
}
void TurboAssembler::AssertUnreachable(AbortReason reason) {
if (FLAG_debug_code) Abort(reason);
}
void TurboAssembler::AssertNotSmi(Register object) {
if (FLAG_debug_code) {
static_assert(kSmiTag == 0);
@ -2239,6 +2240,7 @@ void MacroAssembler::AssertUndefinedOrAllocationSite(Register object,
bind(&done_checking);
}
}
#endif // V8_ENABLE_DEBUG_CODE
static const int kRegisterPassedArguments = 5;

View File

@ -926,11 +926,12 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
// Calls Abort(msg) if the condition cond is not satisfied.
// Use --debug_code to enable.
void Assert(Condition cond, AbortReason reason, CRegister cr = cr7);
void Assert(Condition cond, AbortReason reason,
CRegister cr = cr7) NOOP_UNLESS_DEBUG_CODE;
// Like Assert(), but without condition.
// Use --debug-code to enable.
void AssertUnreachable(AbortReason reason);
void AssertUnreachable(AbortReason reason) NOOP_UNLESS_DEBUG_CODE;
// Like Assert(), but always enabled.
void Check(Condition cond, AbortReason reason, CRegister cr = cr7);
@ -1065,8 +1066,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
}
// Abort execution if argument is a smi, enabled via --debug-code.
void AssertNotSmi(Register object);
void AssertSmi(Register object);
void AssertNotSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
void AssertSmi(Register object) NOOP_UNLESS_DEBUG_CODE;
// Activation support.
void EnterFrame(StackFrame::Type type,
@ -1711,26 +1712,28 @@ class V8_EXPORT_PRIVATE MacroAssembler : public TurboAssembler {
#endif
// Abort execution if argument is not a Constructor, enabled via --debug-code.
void AssertConstructor(Register object, Register scratch);
void AssertConstructor(Register object,
Register scratch) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSFunction, enabled via --debug-code.
void AssertFunction(Register object);
void AssertFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a callable JSFunction, enabled via
// --debug-code.
void AssertCallableFunction(Register object);
void AssertCallableFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSBoundFunction,
// enabled via --debug-code.
void AssertBoundFunction(Register object);
void AssertBoundFunction(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not a JSGeneratorObject (or subclass),
// enabled via --debug-code.
void AssertGeneratorObject(Register object);
void AssertGeneratorObject(Register object) NOOP_UNLESS_DEBUG_CODE;
// Abort execution if argument is not undefined or an AllocationSite, enabled
// via --debug-code.
void AssertUndefinedOrAllocationSite(Register object, Register scratch);
void AssertUndefinedOrAllocationSite(Register object,
Register scratch) NOOP_UNLESS_DEBUG_CODE;
template <typename Field>
void DecodeField(Register dst, Register src) {