[iwyu] Make "stub-cache.h" header stand-alone.
R=ishell@chromium.org Change-Id: I3e69c94d43d4db7255ec46f94c43f1411795ca9d Reviewed-on: https://chromium-review.googlesource.com/666957 Reviewed-by: Igor Sheludko <ishell@chromium.org> Commit-Queue: Michael Starzinger <mstarzinger@chromium.org> Cr-Commit-Position: refs/heads/master@{#48016}
This commit is contained in:
parent
9ba8c3374d
commit
8898e57644
@ -4,14 +4,10 @@
|
||||
|
||||
#include "src/external-reference-table.h"
|
||||
|
||||
#include "src/objects/name-inl.h" // TODO(mstarzinger): For stub-cache.h only!
|
||||
|
||||
#include "src/accessors.h"
|
||||
#include "src/assembler.h"
|
||||
#include "src/counters.h"
|
||||
#include "src/deoptimizer.h"
|
||||
#include "src/ic/stub-cache.h"
|
||||
#include "src/objects-inl.h"
|
||||
|
||||
#if defined(DEBUG) && defined(V8_OS_LINUX) && !defined(V8_OS_ANDROID)
|
||||
#define SYMBOLIZE_FUNCTION
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/objects/name-inl.h" // TODO(mstarzinger): For stub-cache.h only!
|
||||
|
||||
#include "src/ic/stub-cache.h"
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
@ -28,6 +26,35 @@ void StubCache::Initialize() {
|
||||
Clear();
|
||||
}
|
||||
|
||||
// Hash algorithm for the primary table. This algorithm is replicated in
|
||||
// assembler for every architecture. Returns an index into the table that
|
||||
// is scaled by 1 << kCacheIndexShift.
|
||||
int StubCache::PrimaryOffset(Name* name, Map* map) {
|
||||
STATIC_ASSERT(kCacheIndexShift == Name::kHashShift);
|
||||
// Compute the hash of the name (use entire hash field).
|
||||
DCHECK(name->HasHashCode());
|
||||
uint32_t field = name->hash_field();
|
||||
// Using only the low bits in 64-bit mode is unlikely to increase the
|
||||
// risk of collision even if the heap is spread over an area larger than
|
||||
// 4Gb (and not at all if it isn't).
|
||||
uint32_t map_low32bits =
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
|
||||
// Base the offset on a simple combination of name and map.
|
||||
uint32_t key = (map_low32bits + field) ^ kPrimaryMagic;
|
||||
return key & ((kPrimaryTableSize - 1) << kCacheIndexShift);
|
||||
}
|
||||
|
||||
// Hash algorithm for the secondary table. This algorithm is replicated in
|
||||
// assembler for every architecture. Returns an index into the table that
|
||||
// is scaled by 1 << kCacheIndexShift.
|
||||
int StubCache::SecondaryOffset(Name* name, int seed) {
|
||||
// Use the seed from the primary cache in the secondary cache.
|
||||
uint32_t name_low32bits =
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
|
||||
uint32_t key = (seed - name_low32bits) + kSecondaryMagic;
|
||||
return key & ((kSecondaryTableSize - 1) << kCacheIndexShift);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
namespace {
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
#define V8_STUB_CACHE_H_
|
||||
|
||||
#include "src/macro-assembler.h"
|
||||
#include "src/objects/name.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -110,31 +111,12 @@ class StubCache {
|
||||
// Hash algorithm for the primary table. This algorithm is replicated in
|
||||
// assembler for every architecture. Returns an index into the table that
|
||||
// is scaled by 1 << kCacheIndexShift.
|
||||
static int PrimaryOffset(Name* name, Map* map) {
|
||||
STATIC_ASSERT(kCacheIndexShift == Name::kHashShift);
|
||||
// Compute the hash of the name (use entire hash field).
|
||||
DCHECK(name->HasHashCode());
|
||||
uint32_t field = name->hash_field();
|
||||
// Using only the low bits in 64-bit mode is unlikely to increase the
|
||||
// risk of collision even if the heap is spread over an area larger than
|
||||
// 4Gb (and not at all if it isn't).
|
||||
uint32_t map_low32bits =
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(map));
|
||||
// Base the offset on a simple combination of name and map.
|
||||
uint32_t key = (map_low32bits + field) ^ kPrimaryMagic;
|
||||
return key & ((kPrimaryTableSize - 1) << kCacheIndexShift);
|
||||
}
|
||||
static int PrimaryOffset(Name* name, Map* map);
|
||||
|
||||
// Hash algorithm for the secondary table. This algorithm is replicated in
|
||||
// assembler for every architecture. Returns an index into the table that
|
||||
// is scaled by 1 << kCacheIndexShift.
|
||||
static int SecondaryOffset(Name* name, int seed) {
|
||||
// Use the seed from the primary cache in the secondary cache.
|
||||
uint32_t name_low32bits =
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(name));
|
||||
uint32_t key = (seed - name_low32bits) + kSecondaryMagic;
|
||||
return key & ((kSecondaryTableSize - 1) << kCacheIndexShift);
|
||||
}
|
||||
static int SecondaryOffset(Name* name, int seed);
|
||||
|
||||
// Compute the entry for a given offset in exactly the same way as
|
||||
// we do in generated code. We generate an hash code that already
|
||||
|
Loading…
Reference in New Issue
Block a user