Commit f436a324 authored by Clemens Backes's avatar Clemens Backes Committed by Commit Bot

[cleanup] Make RelocInfo::NONE have value 0

The {NONE} reloc info is the one used most often, i.e. for every
assembler call that takes an {Immediate} on x64 which is not
relocatable.
Hence assign value 0 to {NONE} such that constructing such immediates is
faster and also checking for this most common case is faster.

R=ishell@chromium.org

Bug: v8:10576
Change-Id: I3c048710b80dd31fa5b5d3b1415d72a24d95cb90
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2237136Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Clemens Backes <clemensb@chromium.org>
Cr-Commit-Position: refs/heads/master@{#68259}
parent 6e903d93
......@@ -54,6 +54,8 @@ class RelocInfo {
// Please note the order is important (see IsRealRelocMode, IsGCRelocMode,
// and IsShareableRelocMode predicates below).
NONE, // Never recorded value. Most common one, hence value 0.
CODE_TARGET,
RELATIVE_CODE_TARGET, // LAST_CODE_TARGET_MODE
COMPRESSED_EMBEDDED_OBJECT,
......@@ -89,7 +91,6 @@ class RelocInfo {
// Pseudo-types
NUMBER_OF_MODES,
NONE, // never recorded value
LAST_CODE_TARGET_MODE = RELATIVE_CODE_TARGET,
FIRST_REAL_RELOC_MODE = CODE_TARGET,
......@@ -123,10 +124,8 @@ class RelocInfo {
return mode <= LAST_GCED_ENUM;
}
static constexpr bool IsShareableRelocMode(Mode mode) {
static_assert(RelocInfo::NONE >= RelocInfo::FIRST_SHAREABLE_RELOC_MODE,
"Users of this function rely on NONE being a sharable "
"relocation mode.");
return mode >= RelocInfo::FIRST_SHAREABLE_RELOC_MODE;
return mode == RelocInfo::NONE ||
mode >= RelocInfo::FIRST_SHAREABLE_RELOC_MODE;
}
static constexpr bool IsCodeTarget(Mode mode) { return mode == CODE_TARGET; }
static constexpr bool IsCodeTargetMode(Mode mode) {
......
......@@ -443,7 +443,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void Move(Register dst, Address ptr, RelocInfo::Mode rmode) {
// This method must not be used with heap object references. The stored
// address is not GC safe. Use the handle version instead.
DCHECK(rmode > RelocInfo::LAST_GCED_ENUM);
DCHECK(rmode == RelocInfo::NONE || rmode > RelocInfo::LAST_GCED_ENUM);
movq(dst, Immediate64(ptr, rmode));
}
......
......@@ -239,7 +239,8 @@ const char* AbstractCode::Kind2String(Kind kind) {
bool Code::IsIsolateIndependent(Isolate* isolate) {
constexpr int all_real_modes_mask =
(1 << (RelocInfo::LAST_REAL_RELOC_MODE + 1)) - 1;
(1 << (RelocInfo::LAST_REAL_RELOC_MODE + 1)) -
(1 << (RelocInfo::FIRST_REAL_RELOC_MODE - 1)) - 1;
constexpr int mode_mask = all_real_modes_mask &
~RelocInfo::ModeMask(RelocInfo::CONST_POOL) &
~RelocInfo::ModeMask(RelocInfo::OFF_HEAP_TARGET) &
......
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