aboutsummaryrefslogtreecommitdiff
path: root/deps/v8/src/ic/stub-cache.cc
diff options
context:
space:
mode:
authorMichaël Zasso <targos@protonmail.com>2017-12-05 16:41:55 +0100
committerMichaël Zasso <targos@protonmail.com>2017-12-06 12:52:07 +0100
commit1854ba04e9a68f062beb299dd6e1479279b26363 (patch)
treed5b2df9b8c1deb6388f7a728fca8e1c98c779abe /deps/v8/src/ic/stub-cache.cc
parentb52c23b75f96e1c9d2c7b3a7e5619170d0a0d8e1 (diff)
downloadandroid-node-v8-1854ba04e9a68f062beb299dd6e1479279b26363.tar.gz
android-node-v8-1854ba04e9a68f062beb299dd6e1479279b26363.tar.bz2
android-node-v8-1854ba04e9a68f062beb299dd6e1479279b26363.zip
deps: update V8 to 6.3.292.46
PR-URL: https://github.com/nodejs/node/pull/16271 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Myles Borins <myles.borins@gmail.com>
Diffstat (limited to 'deps/v8/src/ic/stub-cache.cc')
-rw-r--r--deps/v8/src/ic/stub-cache.cc42
1 files changed, 31 insertions, 11 deletions
diff --git a/deps/v8/src/ic/stub-cache.cc b/deps/v8/src/ic/stub-cache.cc
index 46ac580a70..ecdf8c83e1 100644
--- a/deps/v8/src/ic/stub-cache.cc
+++ b/deps/v8/src/ic/stub-cache.cc
@@ -13,8 +13,7 @@
namespace v8 {
namespace internal {
-StubCache::StubCache(Isolate* isolate, Code::Kind ic_kind)
- : isolate_(isolate), ic_kind_(ic_kind) {
+StubCache::StubCache(Isolate* isolate) : isolate_(isolate) {
// Ensure the nullptr (aka Smi::kZero) which StubCache::Get() returns
// when the entry is not found is not considered as a handler.
DCHECK(!IC::IsHandler(nullptr));
@@ -26,6 +25,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 {
@@ -37,15 +65,7 @@ bool CommonStubCacheChecks(StubCache* stub_cache, Name* name, Map* map,
DCHECK(!name->GetHeap()->InNewSpace(handler));
DCHECK(name->IsUniqueName());
DCHECK(name->HasHashCode());
- if (handler) {
- DCHECK(IC::IsHandler(handler));
- if (handler->IsCode()) {
- Code::Flags code_flags = Code::cast(handler)->flags();
- Code::Kind ic_code_kind = stub_cache->ic_kind();
- DCHECK_EQ(ic_code_kind, Code::ExtractExtraICStateFromFlags(code_flags));
- DCHECK_EQ(Code::HANDLER, Code::ExtractKindFromFlags(code_flags));
- }
- }
+ if (handler) DCHECK(IC::IsHandler(handler));
return true;
}