Skip to content

Commit c354fb9

Browse files
backesCommit Bot
authored andcommitted
[Liftoff] Add histogram for bailout reasons
This CL adds a new enum {LiftoffBailoutReason}, and tracks this reason for each bailout. This will give us data to prioritize extensions of Liftoff for new proposals or last missing instructions. Since we also track the {kSuccess} case, we will also see what percentage of functions can be compiled with Liftoff overall. R=mstarzinger@chromium.org CC=jwd@chromium.org Change-Id: I42b6a14c5a298ddda7053c195e8b650dc1fe66dc Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1634910 Reviewed-by: Andreas Haas <ahaas@chromium.org> Commit-Queue: Clemens Hammacher <clemensh@chromium.org> Cr-Commit-Position: refs/heads/master@{#61939}
1 parent 2f37999 commit c354fb9

10 files changed

Lines changed: 174 additions & 114 deletions

src/logging/counters-definitions.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ namespace internal {
8989
0, 100, 32) \
9090
/* number of code GCs triggered per native module, collected on code GC */ \
9191
HR(wasm_module_num_triggered_code_gcs, \
92-
V8.WasmModuleNumberOfCodeGCsTriggered, 1, 128, 20)
92+
V8.WasmModuleNumberOfCodeGCsTriggered, 1, 128, 20) \
93+
/* bailout reason if Liftoff failed, or {kSuccess} (per function) */ \
94+
HR(liftoff_bailout_reasons, V8.LiftoffBailoutReasons, 0, 20, 21)
9395

9496
#define HISTOGRAM_TIMER_LIST(HT) \
9597
/* Timer histograms, not thread safe: HT(name, caption, max, unit) */ \

src/wasm/baseline/arm/liftoff-assembler-arm.h

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include "src/wasm/baseline/liftoff-assembler.h"
99

10-
#define BAILOUT(reason) bailout("arm " reason)
11-
1210
namespace v8 {
1311
namespace internal {
1412
namespace wasm {
@@ -223,7 +221,7 @@ inline void EmitFloatMinOrMax(LiftoffAssembler* assm, RegisterType dst,
223221

224222
int LiftoffAssembler::PrepareStackFrame() {
225223
if (!CpuFeatures::IsSupported(ARMv7)) {
226-
BAILOUT("Armv6 not supported");
224+
bailout(kUnsupportedArchitecture, "Armv6 not supported");
227225
return 0;
228226
}
229227
uint32_t offset = static_cast<uint32_t>(pc_offset());
@@ -247,7 +245,8 @@ void LiftoffAssembler::PatchPrepareStackFrame(int offset,
247245
// before checking it.
248246
// TODO(arm): Remove this when the stack check mechanism will be updated.
249247
if (bytes > KB / 2) {
250-
BAILOUT("Stack limited to 512 bytes to avoid a bug in StackCheck");
248+
bailout(kOtherReason,
249+
"Stack limited to 512 bytes to avoid a bug in StackCheck");
251250
return;
252251
}
253252
#endif
@@ -750,7 +749,7 @@ void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs,
750749
Label* trap_div_by_zero,
751750
Label* trap_div_unrepresentable) {
752751
if (!CpuFeatures::IsSupported(SUDIV)) {
753-
BAILOUT("i32_divs");
752+
bailout(kMissingCPUFeature, "i32_divs");
754753
return;
755754
}
756755
CpuFeatureScope scope(this, SUDIV);
@@ -778,7 +777,7 @@ void LiftoffAssembler::emit_i32_divs(Register dst, Register lhs, Register rhs,
778777
void LiftoffAssembler::emit_i32_divu(Register dst, Register lhs, Register rhs,
779778
Label* trap_div_by_zero) {
780779
if (!CpuFeatures::IsSupported(SUDIV)) {
781-
BAILOUT("i32_divu");
780+
bailout(kMissingCPUFeature, "i32_divu");
782781
return;
783782
}
784783
CpuFeatureScope scope(this, SUDIV);
@@ -793,7 +792,7 @@ void LiftoffAssembler::emit_i32_rems(Register dst, Register lhs, Register rhs,
793792
if (!CpuFeatures::IsSupported(SUDIV)) {
794793
// When this case is handled, a check for ARMv7 is required to use mls.
795794
// Mls support is implied with SUDIV support.
796-
BAILOUT("i32_rems");
795+
bailout(kMissingCPUFeature, "i32_rems");
797796
return;
798797
}
799798
CpuFeatureScope scope(this, SUDIV);
@@ -814,7 +813,7 @@ void LiftoffAssembler::emit_i32_remu(Register dst, Register lhs, Register rhs,
814813
if (!CpuFeatures::IsSupported(SUDIV)) {
815814
// When this case is handled, a check for ARMv7 is required to use mls.
816815
// Mls support is implied with SUDIV support.
817-
BAILOUT("i32_remu");
816+
bailout(kMissingCPUFeature, "i32_remu");
818817
return;
819818
}
820819
CpuFeatureScope scope(this, SUDIV);
@@ -1564,6 +1563,4 @@ void LiftoffStackSlots::Construct() {
15641563
} // namespace internal
15651564
} // namespace v8
15661565

1567-
#undef BAILOUT
1568-
15691566
#endif // V8_WASM_BASELINE_ARM_LIFTOFF_ASSEMBLER_ARM_H_

src/wasm/baseline/arm64/liftoff-assembler-arm64.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77

88
#include "src/wasm/baseline/liftoff-assembler.h"
99

10-
#define BAILOUT(reason) bailout("arm64 " reason)
11-
1210
namespace v8 {
1311
namespace internal {
1412
namespace wasm {
@@ -135,7 +133,7 @@ void LiftoffAssembler::PatchPrepareStackFrame(int offset,
135133
if (!IsImmAddSub(bytes)) {
136134
// Stack greater than 4M! Because this is a quite improbable case, we
137135
// just fallback to Turbofan.
138-
BAILOUT("Stack too big");
136+
bailout(kOtherReason, "Stack too big");
139137
return;
140138
}
141139
}
@@ -144,7 +142,8 @@ void LiftoffAssembler::PatchPrepareStackFrame(int offset,
144142
// before checking it.
145143
// TODO(arm): Remove this when the stack check mechanism will be updated.
146144
if (bytes > KB / 2) {
147-
BAILOUT("Stack limited to 512 bytes to avoid a bug in StackCheck");
145+
bailout(kOtherReason,
146+
"Stack limited to 512 bytes to avoid a bug in StackCheck");
148147
return;
149148
}
150149
#endif
@@ -1088,6 +1087,4 @@ void LiftoffStackSlots::Construct() {
10881087
} // namespace internal
10891088
} // namespace v8
10901089

1091-
#undef BAILOUT
1092-
10931090
#endif // V8_WASM_BASELINE_ARM64_LIFTOFF_ASSEMBLER_ARM64_H_

src/wasm/baseline/ia32/liftoff-assembler-ia32.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ namespace v8 {
1414
namespace internal {
1515
namespace wasm {
1616

17-
#define REQUIRE_CPU_FEATURE(name, ...) \
18-
if (!CpuFeatures::IsSupported(name)) { \
19-
bailout("no " #name); \
20-
return __VA_ARGS__; \
21-
} \
17+
#define REQUIRE_CPU_FEATURE(name, ...) \
18+
if (!CpuFeatures::IsSupported(name)) { \
19+
bailout(kMissingCPUFeature, "no " #name); \
20+
return __VA_ARGS__; \
21+
} \
2222
CpuFeatureScope feature(this, name);
2323

2424
namespace liftoff {
@@ -1390,7 +1390,7 @@ template <typename dst_type, typename src_type>
13901390
inline bool EmitTruncateFloatToInt(LiftoffAssembler* assm, Register dst,
13911391
DoubleRegister src, Label* trap) {
13921392
if (!CpuFeatures::IsSupported(SSE4_1)) {
1393-
assm->bailout("no SSE4.1");
1393+
assm->bailout(kMissingCPUFeature, "no SSE4.1");
13941394
return true;
13951395
}
13961396
CpuFeatureScope feature(assm, SSE4_1);

src/wasm/baseline/liftoff-assembler.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include "src/codegen/macro-assembler.h"
1414
#include "src/execution/frames.h"
1515
#include "src/wasm/baseline/liftoff-assembler-defs.h"
16+
#include "src/wasm/baseline/liftoff-compiler.h"
1617
#include "src/wasm/baseline/liftoff-register.h"
1718
#include "src/wasm/function-body-decoder.h"
1819
#include "src/wasm/wasm-code-manager.h"
@@ -635,13 +636,16 @@ class LiftoffAssembler : public TurboAssembler {
635636
CacheState* cache_state() { return &cache_state_; }
636637
const CacheState* cache_state() const { return &cache_state_; }
637638

638-
bool did_bailout() { return bailout_reason_ != nullptr; }
639-
const char* bailout_reason() const { return bailout_reason_; }
639+
bool did_bailout() { return bailout_reason_ != kSuccess; }
640+
LiftoffBailoutReason bailout_reason() const { return bailout_reason_; }
641+
const char* bailout_detail() const { return bailout_detail_; }
640642

641-
void bailout(const char* reason) {
642-
if (bailout_reason_ != nullptr) return;
643+
void bailout(LiftoffBailoutReason reason, const char* detail) {
644+
DCHECK_NE(kSuccess, reason);
645+
if (bailout_reason_ != kSuccess) return;
643646
AbortCompilation();
644647
bailout_reason_ = reason;
648+
bailout_detail_ = detail;
645649
}
646650

647651
private:
@@ -655,7 +659,8 @@ class LiftoffAssembler : public TurboAssembler {
655659
"Reconsider this inlining if ValueType gets bigger");
656660
CacheState cache_state_;
657661
uint32_t num_used_spill_slots_ = 0;
658-
const char* bailout_reason_ = nullptr;
662+
LiftoffBailoutReason bailout_reason_ = kSuccess;
663+
const char* bailout_detail_ = nullptr;
659664

660665
LiftoffRegister SpillOneRegister(LiftoffRegList candidates,
661666
LiftoffRegList pinned);

0 commit comments

Comments
 (0)