[x64] Make {Assembler::GrowBuffer} preserve most registers

This makes many callers of {GrowBuffer} a lot slimmer, by avoiding the
need to push and pop all values in otherwise caller-saved registers.
E.g. {emit_mov(Register, Operand)} was measured to be ~2x faster (from
2.3% of Liftoff compilation time to 1.2%).

R=bikineev@chromium.org
CC=dlehmann@chromium.org

Bug: v8:13565
Change-Id: I681747a491548adf1374187cd9f37520c153ef1a
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/4127230
Reviewed-by: Leszek Swirski <leszeks@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Reviewed-by: Anton Bikineev <bikineev@chromium.org>
Cr-Commit-Position: refs/heads/main@{#85147}
This commit is contained in:
Clemens Backes 2023-01-09 14:55:59 +01:00 committed by V8 LUCI CQ
parent 0d89b699eb
commit 8fe57bf641
2 changed files with 17 additions and 1 deletions

View File

@ -346,6 +346,7 @@ path. Add it with -I<path> to the command line
# define V8_HAS_ATTRIBUTE_NONNULL (__has_attribute(nonnull))
# define V8_HAS_ATTRIBUTE_NOINLINE (__has_attribute(noinline))
# define V8_HAS_ATTRIBUTE_UNUSED (__has_attribute(unused))
# define V8_HAS_ATTRIBUTE_PRESERVE_MOST (__has_attribute(preserve_most))
# define V8_HAS_ATTRIBUTE_VISIBILITY (__has_attribute(visibility))
# define V8_HAS_ATTRIBUTE_WARN_UNUSED_RESULT \
(__has_attribute(warn_unused_result))
@ -504,6 +505,21 @@ path. Add it with -I<path> to the command line
#endif
// A macro used to change the calling conventions to preserve all registers (no
// caller-saved registers). Use this for cold functions called from hot
// functions.
// Note: The attribute is considered experimental, so apply with care. Also,
// "preserve_most" is currently not handling the return value correctly, so only
// use it for functions returning void (see https://reviews.llvm.org/D141020).
// Use like:
// V8_NOINLINE V8_PRESERVE_MOST void UnlikelyMethod();
#if V8_HAS_ATTRIBUTE_PRESERVE_MOST
# define V8_PRESERVE_MOST __attribute__((preserve_most))
#else
# define V8_PRESERVE_MOST /* NOT SUPPORTED */
#endif
// A macro (V8_DEPRECATED) to mark classes or functions as deprecated.
#if defined(V8_DEPRECATION_WARNINGS)
# define V8_DEPRECATED(message) [[deprecated(message)]]

View File

@ -2131,7 +2131,7 @@ class V8_EXPORT_PRIVATE Assembler : public AssemblerBase {
}
// Code emission.
void GrowBuffer();
V8_NOINLINE V8_PRESERVE_MOST void GrowBuffer();
template <typename T>
static uint8_t* emit(uint8_t* __restrict pc, T t) {