Commit 46f9931c authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[wasm] Add more likely and unlikely annotations

All error handling should be marked V8_UNLIKELY, because this is never
on the hot path.

R=thibaudm@chromium.org

Bug: v8:10576
Change-Id: I8bc996e96a2e90f21ec065fbce4656d311097f74
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2263153Reviewed-by: 's avatarThibaud Michaud <thibaudm@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68521}
parent 0366e2f8
...@@ -374,7 +374,7 @@ class Decoder { ...@@ -374,7 +374,7 @@ class Decoder {
constexpr bool is_last_byte = byte_index == kMaxLength - 1; constexpr bool is_last_byte = byte_index == kMaxLength - 1;
const bool at_end = validate && pc >= end_; const bool at_end = validate && pc >= end_;
byte b = 0; byte b = 0;
if (!at_end) { if (V8_LIKELY(!at_end)) {
DCHECK_LT(pc, end_); DCHECK_LT(pc, end_);
b = *pc; b = *pc;
TRACE_IF(trace, "%02x ", b); TRACE_IF(trace, "%02x ", b);
...@@ -392,7 +392,7 @@ class Decoder { ...@@ -392,7 +392,7 @@ class Decoder {
} }
if (advance_pc) pc_ = pc + (at_end ? 0 : 1); if (advance_pc) pc_ = pc + (at_end ? 0 : 1);
*length = byte_index + (at_end ? 0 : 1); *length = byte_index + (at_end ? 0 : 1);
if (validate && (at_end || (b & 0x80))) { if (validate && V8_UNLIKELY(at_end || (b & 0x80))) {
TRACE_IF(trace, at_end ? "<end> " : "<length overflow> "); TRACE_IF(trace, at_end ? "<end> " : "<length overflow> ");
errorf(pc, "expected %s", name); errorf(pc, "expected %s", name);
result = 0; result = 0;
...@@ -413,7 +413,7 @@ class Decoder { ...@@ -413,7 +413,7 @@ class Decoder {
(is_signed && checked_bits == kSignExtendedExtraBits); (is_signed && checked_bits == kSignExtendedExtraBits);
if (!validate) { if (!validate) {
DCHECK(valid_extra_bits); DCHECK(valid_extra_bits);
} else if (!valid_extra_bits) { } else if (V8_UNLIKELY(!valid_extra_bits)) {
error(pc, "extra bits in varint"); error(pc, "extra bits in varint");
result = 0; result = 0;
} }
......
...@@ -37,7 +37,7 @@ struct WasmException; ...@@ -37,7 +37,7 @@ struct WasmException;
// Return the evaluation of `condition` if validate==true, DCHECK that it's // Return the evaluation of `condition` if validate==true, DCHECK that it's
// true and always return true otherwise. // true and always return true otherwise.
#define VALIDATE(condition) \ #define VALIDATE(condition) \
(validate ? (condition) : [&] { \ (validate ? V8_LIKELY(condition) : [&] { \
DCHECK(condition); \ DCHECK(condition); \
return true; \ return true; \
}()) }())
......
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