Move hashmap into src/base.
We ported hashmap.h into libsampler as a workaround before, so the main focus of this patch is to reduce code duplication. This patch moves the hashmap into src/base as well as creates DefaultAllocationPolicy using malloc and free. BUG=v8:5050 LOG=n Review-Url: https://codereview.chromium.org/2010243003 Cr-Commit-Position: refs/heads/master@{#36873}
This commit is contained in:
parent
cb05c2df7c
commit
2fd55667a6
4
BUILD.gn
4
BUILD.gn
@ -1180,7 +1180,6 @@ v8_source_set("v8_base") {
|
||||
"src/handles-inl.h",
|
||||
"src/handles.cc",
|
||||
"src/handles.h",
|
||||
"src/hashmap.h",
|
||||
"src/heap-symbols.h",
|
||||
"src/heap/array-buffer-tracker.cc",
|
||||
"src/heap/array-buffer-tracker.h",
|
||||
@ -1898,6 +1897,7 @@ v8_source_set("v8_libbase") {
|
||||
"src/base/format-macros.h",
|
||||
"src/base/functional.cc",
|
||||
"src/base/functional.h",
|
||||
"src/base/hashmap.h",
|
||||
"src/base/iterator.h",
|
||||
"src/base/lazy-instance.h",
|
||||
"src/base/logging.cc",
|
||||
@ -1997,8 +1997,6 @@ v8_source_set("v8_libplatform") {
|
||||
|
||||
v8_source_set("v8_libsampler") {
|
||||
sources = [
|
||||
"src/libsampler/hashmap.h",
|
||||
"src/libsampler/utils.h",
|
||||
"src/libsampler/v8-sampler.cc",
|
||||
"src/libsampler/v8-sampler.h",
|
||||
]
|
||||
|
@ -13,7 +13,7 @@ namespace internal {
|
||||
RootIndexMap::RootIndexMap(Isolate* isolate) {
|
||||
map_ = isolate->root_index_map();
|
||||
if (map_ != NULL) return;
|
||||
map_ = new HashMap(HashMap::PointersMatch);
|
||||
map_ = new base::HashMap(base::HashMap::PointersMatch);
|
||||
for (uint32_t i = 0; i < Heap::kStrongRootListLength; i++) {
|
||||
Heap::RootListIndex root_index = static_cast<Heap::RootListIndex>(i);
|
||||
Object* root = isolate->heap()->root(root_index);
|
||||
@ -22,7 +22,7 @@ RootIndexMap::RootIndexMap(Isolate* isolate) {
|
||||
// not be referenced through the root list in the snapshot.
|
||||
if (isolate->heap()->RootCanBeTreatedAsConstant(root_index)) {
|
||||
HeapObject* heap_object = HeapObject::cast(root);
|
||||
HashMap::Entry* entry = LookupEntry(map_, heap_object, false);
|
||||
base::HashMap::Entry* entry = LookupEntry(map_, heap_object, false);
|
||||
if (entry != NULL) {
|
||||
// Some are initialized to a previous value in the root list.
|
||||
DCHECK_LT(GetValue(entry), i);
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define V8_ADDRESS_MAP_H_
|
||||
|
||||
#include "src/assert-scope.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/objects.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -14,16 +14,17 @@ namespace internal {
|
||||
|
||||
class AddressMapBase {
|
||||
protected:
|
||||
static void SetValue(HashMap::Entry* entry, uint32_t v) {
|
||||
static void SetValue(base::HashMap::Entry* entry, uint32_t v) {
|
||||
entry->value = reinterpret_cast<void*>(v);
|
||||
}
|
||||
|
||||
static uint32_t GetValue(HashMap::Entry* entry) {
|
||||
static uint32_t GetValue(base::HashMap::Entry* entry) {
|
||||
return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
|
||||
}
|
||||
|
||||
inline static HashMap::Entry* LookupEntry(HashMap* map, HeapObject* obj,
|
||||
bool insert) {
|
||||
inline static base::HashMap::Entry* LookupEntry(base::HashMap* map,
|
||||
HeapObject* obj,
|
||||
bool insert) {
|
||||
if (insert) {
|
||||
map->LookupOrInsert(Key(obj), Hash(obj));
|
||||
}
|
||||
@ -47,13 +48,13 @@ class RootIndexMap : public AddressMapBase {
|
||||
static const int kInvalidRootIndex = -1;
|
||||
|
||||
int Lookup(HeapObject* obj) {
|
||||
HashMap::Entry* entry = LookupEntry(map_, obj, false);
|
||||
base::HashMap::Entry* entry = LookupEntry(map_, obj, false);
|
||||
if (entry) return GetValue(entry);
|
||||
return kInvalidRootIndex;
|
||||
}
|
||||
|
||||
private:
|
||||
HashMap* map_;
|
||||
base::HashMap* map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(RootIndexMap);
|
||||
};
|
||||
@ -180,18 +181,18 @@ class SerializerReferenceMap : public AddressMapBase {
|
||||
public:
|
||||
SerializerReferenceMap()
|
||||
: no_allocation_(),
|
||||
map_(HashMap::PointersMatch),
|
||||
map_(base::HashMap::PointersMatch),
|
||||
attached_reference_index_(0) {}
|
||||
|
||||
SerializerReference Lookup(HeapObject* obj) {
|
||||
HashMap::Entry* entry = LookupEntry(&map_, obj, false);
|
||||
base::HashMap::Entry* entry = LookupEntry(&map_, obj, false);
|
||||
return entry ? SerializerReference(GetValue(entry)) : SerializerReference();
|
||||
}
|
||||
|
||||
void Add(HeapObject* obj, SerializerReference b) {
|
||||
DCHECK(b.is_valid());
|
||||
DCHECK_NULL(LookupEntry(&map_, obj, false));
|
||||
HashMap::Entry* entry = LookupEntry(&map_, obj, true);
|
||||
base::HashMap::Entry* entry = LookupEntry(&map_, obj, true);
|
||||
SetValue(entry, b.bitfield_);
|
||||
}
|
||||
|
||||
@ -204,7 +205,7 @@ class SerializerReferenceMap : public AddressMapBase {
|
||||
|
||||
private:
|
||||
DisallowHeapAllocation no_allocation_;
|
||||
HashMap map_;
|
||||
base::HashMap map_;
|
||||
int attached_reference_index_;
|
||||
DISALLOW_COPY_AND_ASSIGN(SerializerReferenceMap);
|
||||
};
|
||||
|
@ -633,9 +633,7 @@ void Simulator::set_last_debugger_input(char* input) {
|
||||
last_debugger_input_ = input;
|
||||
}
|
||||
|
||||
|
||||
void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
void* start_addr,
|
||||
void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
|
||||
size_t size) {
|
||||
intptr_t start = reinterpret_cast<intptr_t>(start_addr);
|
||||
int intra_line = (start & CachePage::kLineMask);
|
||||
@ -656,10 +654,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
v8::internal::HashMap::Entry* entry =
|
||||
i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
|
||||
base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
if (entry->value == NULL) {
|
||||
CachePage* new_page = new CachePage();
|
||||
entry->value = new_page;
|
||||
@ -669,9 +665,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
|
||||
|
||||
// Flush from start up to and not including start + size.
|
||||
void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
|
||||
intptr_t start,
|
||||
int size) {
|
||||
void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) {
|
||||
DCHECK(size <= CachePage::kPageSize);
|
||||
DCHECK(AllOnOnePage(start, size - 1));
|
||||
DCHECK((start & CachePage::kLineMask) == 0);
|
||||
@ -683,9 +677,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
|
||||
memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
|
||||
}
|
||||
|
||||
|
||||
void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
Instruction* instr) {
|
||||
void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
|
||||
intptr_t address = reinterpret_cast<intptr_t>(instr);
|
||||
void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
|
||||
void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
|
||||
@ -718,7 +710,7 @@ void Simulator::Initialize(Isolate* isolate) {
|
||||
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
i_cache_ = isolate_->simulator_i_cache();
|
||||
if (i_cache_ == NULL) {
|
||||
i_cache_ = new v8::internal::HashMap(&ICacheMatch);
|
||||
i_cache_ = new base::HashMap(&ICacheMatch);
|
||||
isolate_->set_simulator_i_cache(i_cache_);
|
||||
}
|
||||
Initialize(isolate);
|
||||
@ -850,10 +842,10 @@ class Redirection {
|
||||
|
||||
|
||||
// static
|
||||
void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
|
||||
void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
|
||||
Redirection::DeleteChain(first);
|
||||
if (i_cache != nullptr) {
|
||||
for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
entry = i_cache->Next(entry)) {
|
||||
delete static_cast<CachePage*>(entry->value);
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class SimulatorStack : public v8::internal::AllStatic {
|
||||
|
||||
#include "src/arm/constants-arm.h"
|
||||
#include "src/assembler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -200,7 +200,7 @@ class Simulator {
|
||||
// Call on program start.
|
||||
static void Initialize(Isolate* isolate);
|
||||
|
||||
static void TearDown(HashMap* i_cache, Redirection* first);
|
||||
static void TearDown(base::HashMap* i_cache, Redirection* first);
|
||||
|
||||
// V8 generally calls into generated JS code with 5 parameters and into
|
||||
// generated RegExp code with 7 parameters. This is a convenience function,
|
||||
@ -222,8 +222,7 @@ class Simulator {
|
||||
char* last_debugger_input() { return last_debugger_input_; }
|
||||
|
||||
// ICache checking.
|
||||
static void FlushICache(v8::internal::HashMap* i_cache, void* start,
|
||||
size_t size);
|
||||
static void FlushICache(base::HashMap* i_cache, void* start, size_t size);
|
||||
|
||||
// Returns true if pc register contains one of the 'special_values' defined
|
||||
// below (bad_lr, end_sim_pc).
|
||||
@ -342,10 +341,9 @@ class Simulator {
|
||||
void InstructionDecode(Instruction* instr);
|
||||
|
||||
// ICache.
|
||||
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
int size);
|
||||
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
|
||||
static void CheckICache(base::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size);
|
||||
static CachePage* GetCachePage(base::HashMap* i_cache, void* page);
|
||||
|
||||
// Runtime call support.
|
||||
static void* RedirectExternalReference(
|
||||
@ -405,7 +403,7 @@ class Simulator {
|
||||
char* last_debugger_input_;
|
||||
|
||||
// Icache simulation
|
||||
v8::internal::HashMap* i_cache_;
|
||||
base::HashMap* i_cache_;
|
||||
|
||||
// Registered breakpoints.
|
||||
Instruction* break_pc_;
|
||||
|
@ -524,7 +524,7 @@ class Redirection {
|
||||
|
||||
|
||||
// static
|
||||
void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
|
||||
void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
|
||||
Redirection::DeleteChain(first);
|
||||
}
|
||||
|
||||
|
@ -151,8 +151,7 @@ typedef SimRegisterBase SimFPRegister; // v0-v31
|
||||
|
||||
class Simulator : public DecoderVisitor {
|
||||
public:
|
||||
static void FlushICache(v8::internal::HashMap* i_cache, void* start,
|
||||
size_t size) {
|
||||
static void FlushICache(base::HashMap* i_cache, void* start, size_t size) {
|
||||
USE(i_cache);
|
||||
USE(start);
|
||||
USE(size);
|
||||
@ -168,7 +167,7 @@ class Simulator : public DecoderVisitor {
|
||||
|
||||
static void Initialize(Isolate* isolate);
|
||||
|
||||
static void TearDown(HashMap* i_cache, Redirection* first);
|
||||
static void TearDown(base::HashMap* i_cache, Redirection* first);
|
||||
|
||||
static Simulator* current(v8::internal::Isolate* isolate);
|
||||
|
||||
|
@ -360,7 +360,7 @@ AstRawString* AstValueFactory::GetString(uint32_t hash, bool is_one_byte,
|
||||
// against the AstRawStrings which are in the string_table_. We should not
|
||||
// return this AstRawString.
|
||||
AstRawString key(is_one_byte, literal_bytes, hash);
|
||||
HashMap::Entry* entry = string_table_.LookupOrInsert(&key, hash);
|
||||
base::HashMap::Entry* entry = string_table_.LookupOrInsert(&key, hash);
|
||||
if (entry->value == NULL) {
|
||||
// Copy literal contents for later comparison.
|
||||
int length = literal_bytes.length();
|
||||
|
@ -29,7 +29,7 @@
|
||||
#define V8_AST_AST_VALUE_FACTORY_H_
|
||||
|
||||
#include "src/api.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
// AstString, AstValue and AstValueFactory are for storing strings and values
|
||||
@ -352,7 +352,7 @@ class AstValueFactory {
|
||||
static bool AstRawStringCompare(void* a, void* b);
|
||||
|
||||
// All strings are copied here, one after another (no NULLs inbetween).
|
||||
HashMap string_table_;
|
||||
base::HashMap string_table_;
|
||||
// For keeping track of all AstValues and AstRawStrings we've created (so that
|
||||
// they can be internalized later).
|
||||
List<AstValue*> values_;
|
||||
|
@ -8,14 +8,14 @@
|
||||
|
||||
#include "src/ast/prettyprinter.h"
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/builtins.h"
|
||||
#include "src/code-stubs.h"
|
||||
#include "src/contexts.h"
|
||||
#include "src/conversions.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/parsing/parser.h"
|
||||
#include "src/property.h"
|
||||
#include "src/property-details.h"
|
||||
#include "src/property.h"
|
||||
#include "src/string-stream.h"
|
||||
#include "src/type-info.h"
|
||||
|
||||
|
@ -130,7 +130,8 @@ class FeedbackVectorSlotCache {
|
||||
public:
|
||||
explicit FeedbackVectorSlotCache(Zone* zone)
|
||||
: zone_(zone),
|
||||
hash_map_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity,
|
||||
hash_map_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)) {}
|
||||
|
||||
void Put(Variable* variable, FeedbackVectorSlot slot) {
|
||||
@ -1551,13 +1552,14 @@ class ObjectLiteral final : public MaterializedLiteral {
|
||||
|
||||
|
||||
// A map from property names to getter/setter pairs allocated in the zone.
|
||||
class AccessorTable : public TemplateHashMap<Literal, ObjectLiteral::Accessors,
|
||||
ZoneAllocationPolicy> {
|
||||
class AccessorTable
|
||||
: public base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
|
||||
ZoneAllocationPolicy> {
|
||||
public:
|
||||
explicit AccessorTable(Zone* zone)
|
||||
: TemplateHashMap<Literal, ObjectLiteral::Accessors,
|
||||
ZoneAllocationPolicy>(Literal::Match,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
: base::TemplateHashMap<Literal, ObjectLiteral::Accessors,
|
||||
ZoneAllocationPolicy>(Literal::Match,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
zone_(zone) {}
|
||||
|
||||
Iterator lookup(Literal* literal) {
|
||||
|
@ -6,7 +6,7 @@
|
||||
#define V8_AST_SCOPES_H_
|
||||
|
||||
#include "src/ast/ast.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/pending-compilation-error-handler.h"
|
||||
#include "src/zone.h"
|
||||
|
||||
|
@ -2,21 +2,29 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_HASHMAP_H_
|
||||
#define V8_HASHMAP_H_
|
||||
// The reason we write our own hash map instead of using unordered_map in STL,
|
||||
// is that STL containers use a mutex pool on debug build, which will lead to
|
||||
// deadlock when we are using async signal handler.
|
||||
|
||||
#ifndef V8_BASE_HASHMAP_H_
|
||||
#define V8_BASE_HASHMAP_H_
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/utils.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
namespace base {
|
||||
|
||||
template<class AllocationPolicy>
|
||||
class DefaultAllocationPolicy {
|
||||
public:
|
||||
V8_INLINE void* New(size_t size) { return malloc(size); }
|
||||
V8_INLINE static void Delete(void* p) { free(p); }
|
||||
};
|
||||
|
||||
template <class AllocationPolicy>
|
||||
class TemplateHashMapImpl {
|
||||
public:
|
||||
typedef bool (*MatchFun) (void* key1, void* key2);
|
||||
typedef bool (*MatchFun)(void* key1, void* key2);
|
||||
|
||||
// The default capacity. This is used by the call sites which want
|
||||
// to pass in a non-default AllocationPolicy but want to use the
|
||||
@ -38,7 +46,7 @@ class TemplateHashMapImpl {
|
||||
void* key;
|
||||
void* value;
|
||||
uint32_t hash; // The full hash value for key
|
||||
int order; // If you never remove entries this is the insertion order.
|
||||
int order; // If you never remove entries this is the insertion order.
|
||||
};
|
||||
|
||||
// If an entry with matching key is found, returns that entry.
|
||||
@ -79,9 +87,7 @@ class TemplateHashMapImpl {
|
||||
Entry* Next(Entry* p) const;
|
||||
|
||||
// Some match functions defined for convenience.
|
||||
static bool PointersMatch(void* key1, void* key2) {
|
||||
return key1 == key2;
|
||||
}
|
||||
static bool PointersMatch(void* key1, void* key2) { return key1 == key2; }
|
||||
|
||||
private:
|
||||
MatchFun match_;
|
||||
@ -95,22 +101,20 @@ class TemplateHashMapImpl {
|
||||
void Resize(AllocationPolicy allocator);
|
||||
};
|
||||
|
||||
typedef TemplateHashMapImpl<FreeStoreAllocationPolicy> HashMap;
|
||||
typedef TemplateHashMapImpl<DefaultAllocationPolicy> HashMap;
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
TemplateHashMapImpl<AllocationPolicy>::TemplateHashMapImpl(
|
||||
MatchFun match, uint32_t initial_capacity, AllocationPolicy allocator) {
|
||||
match_ = match;
|
||||
Initialize(initial_capacity, allocator);
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
TemplateHashMapImpl<AllocationPolicy>::~TemplateHashMapImpl() {
|
||||
AllocationPolicy::Delete(map_);
|
||||
}
|
||||
|
||||
|
||||
template <class AllocationPolicy>
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
TemplateHashMapImpl<AllocationPolicy>::Lookup(void* key, uint32_t hash) const {
|
||||
@ -118,7 +122,6 @@ TemplateHashMapImpl<AllocationPolicy>::Lookup(void* key, uint32_t hash) const {
|
||||
return p->key != NULL ? p : NULL;
|
||||
}
|
||||
|
||||
|
||||
template <class AllocationPolicy>
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
TemplateHashMapImpl<AllocationPolicy>::LookupOrInsert(
|
||||
@ -145,8 +148,7 @@ TemplateHashMapImpl<AllocationPolicy>::LookupOrInsert(
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
void* TemplateHashMapImpl<AllocationPolicy>::Remove(void* key, uint32_t hash) {
|
||||
// Lookup the entry for the key to remove.
|
||||
Entry* p = Probe(key, hash);
|
||||
@ -194,8 +196,7 @@ void* TemplateHashMapImpl<AllocationPolicy>::Remove(void* key, uint32_t hash) {
|
||||
// If the entry at position q has its initial position outside the range
|
||||
// between p and q it can be moved forward to position p and will still be
|
||||
// found. There is now a new candidate entry for clearing.
|
||||
if ((q > p && (r <= p || r > q)) ||
|
||||
(q < p && (r <= p && r > q))) {
|
||||
if ((q > p && (r <= p || r > q)) || (q < p && (r <= p && r > q))) {
|
||||
*p = *q;
|
||||
p = q;
|
||||
}
|
||||
@ -207,8 +208,7 @@ void* TemplateHashMapImpl<AllocationPolicy>::Remove(void* key, uint32_t hash) {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
void TemplateHashMapImpl<AllocationPolicy>::Clear() {
|
||||
// Mark all entries as empty.
|
||||
const Entry* end = map_end();
|
||||
@ -218,17 +218,15 @@ void TemplateHashMapImpl<AllocationPolicy>::Clear() {
|
||||
occupancy_ = 0;
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
TemplateHashMapImpl<AllocationPolicy>::Start() const {
|
||||
TemplateHashMapImpl<AllocationPolicy>::Start() const {
|
||||
return Next(map_ - 1);
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
TemplateHashMapImpl<AllocationPolicy>::Next(Entry* p) const {
|
||||
TemplateHashMapImpl<AllocationPolicy>::Next(Entry* p) const {
|
||||
const Entry* end = map_end();
|
||||
DCHECK(map_ - 1 <= p && p < end);
|
||||
for (p++; p < end; p++) {
|
||||
@ -239,7 +237,6 @@ typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
template <class AllocationPolicy>
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry*
|
||||
TemplateHashMapImpl<AllocationPolicy>::Probe(void* key, uint32_t hash) const {
|
||||
@ -261,22 +258,20 @@ TemplateHashMapImpl<AllocationPolicy>::Probe(void* key, uint32_t hash) const {
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
void TemplateHashMapImpl<AllocationPolicy>::Initialize(
|
||||
uint32_t capacity, AllocationPolicy allocator) {
|
||||
DCHECK(base::bits::IsPowerOfTwo32(capacity));
|
||||
map_ = reinterpret_cast<Entry*>(allocator.New(capacity * sizeof(Entry)));
|
||||
if (map_ == NULL) {
|
||||
v8::internal::FatalProcessOutOfMemory("HashMap::Initialize");
|
||||
FATAL("Out of memory: HashMap::Initialize");
|
||||
return;
|
||||
}
|
||||
capacity_ = capacity;
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
template<class AllocationPolicy>
|
||||
template <class AllocationPolicy>
|
||||
void TemplateHashMapImpl<AllocationPolicy>::Resize(AllocationPolicy allocator) {
|
||||
Entry* map = map_;
|
||||
uint32_t n = occupancy_;
|
||||
@ -298,12 +293,11 @@ void TemplateHashMapImpl<AllocationPolicy>::Resize(AllocationPolicy allocator) {
|
||||
AllocationPolicy::Delete(map);
|
||||
}
|
||||
|
||||
|
||||
// A hash map for pointer keys and values with an STL-like interface.
|
||||
template<class Key, class Value, class AllocationPolicy>
|
||||
class TemplateHashMap: private TemplateHashMapImpl<AllocationPolicy> {
|
||||
template <class Key, class Value, class AllocationPolicy>
|
||||
class TemplateHashMap : private TemplateHashMapImpl<AllocationPolicy> {
|
||||
public:
|
||||
STATIC_ASSERT(sizeof(Key*) == sizeof(void*)); // NOLINT
|
||||
STATIC_ASSERT(sizeof(Key*) == sizeof(void*)); // NOLINT
|
||||
STATIC_ASSERT(sizeof(Value*) == sizeof(void*)); // NOLINT
|
||||
struct value_type {
|
||||
Key* first;
|
||||
@ -318,12 +312,12 @@ class TemplateHashMap: private TemplateHashMapImpl<AllocationPolicy> {
|
||||
}
|
||||
|
||||
value_type* operator->() { return reinterpret_cast<value_type*>(entry_); }
|
||||
bool operator!=(const Iterator& other) { return entry_ != other.entry_; }
|
||||
bool operator!=(const Iterator& other) { return entry_ != other.entry_; }
|
||||
|
||||
private:
|
||||
Iterator(const TemplateHashMapImpl<AllocationPolicy>* map,
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry* entry) :
|
||||
map_(map), entry_(entry) { }
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry* entry)
|
||||
: map_(map), entry_(entry) {}
|
||||
|
||||
const TemplateHashMapImpl<AllocationPolicy>* map_;
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::Entry* entry_;
|
||||
@ -334,10 +328,10 @@ class TemplateHashMap: private TemplateHashMapImpl<AllocationPolicy> {
|
||||
TemplateHashMap(
|
||||
typename TemplateHashMapImpl<AllocationPolicy>::MatchFun match,
|
||||
AllocationPolicy allocator = AllocationPolicy())
|
||||
: TemplateHashMapImpl<AllocationPolicy>(
|
||||
: TemplateHashMapImpl<AllocationPolicy>(
|
||||
match,
|
||||
TemplateHashMapImpl<AllocationPolicy>::kDefaultHashMapCapacity,
|
||||
allocator) { }
|
||||
allocator) {}
|
||||
|
||||
Iterator begin() const { return Iterator(this, this->Start()); }
|
||||
Iterator end() const { return Iterator(this, NULL); }
|
||||
@ -350,7 +344,7 @@ class TemplateHashMap: private TemplateHashMapImpl<AllocationPolicy> {
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace internal
|
||||
} // namespace base
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_HASHMAP_H_
|
||||
#endif // V8_BASE_HASHMAP_H_
|
@ -236,7 +236,7 @@ class Genesis BASE_EMBEDDED {
|
||||
void set_state(RegisteredExtension* extension,
|
||||
ExtensionTraversalState state);
|
||||
private:
|
||||
HashMap map_;
|
||||
base::HashMap map_;
|
||||
DISALLOW_COPY_AND_ASSIGN(ExtensionStates);
|
||||
};
|
||||
|
||||
@ -3447,12 +3447,12 @@ static uint32_t Hash(RegisteredExtension* extension) {
|
||||
return v8::internal::ComputePointerHash(extension);
|
||||
}
|
||||
|
||||
|
||||
Genesis::ExtensionStates::ExtensionStates() : map_(HashMap::PointersMatch, 8) {}
|
||||
Genesis::ExtensionStates::ExtensionStates()
|
||||
: map_(base::HashMap::PointersMatch, 8) {}
|
||||
|
||||
Genesis::ExtensionTraversalState Genesis::ExtensionStates::get_state(
|
||||
RegisteredExtension* extension) {
|
||||
i::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension));
|
||||
base::HashMap::Entry* entry = map_.Lookup(extension, Hash(extension));
|
||||
if (entry == NULL) {
|
||||
return UNVISITED;
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ class CompilationCache {
|
||||
explicit CompilationCache(Isolate* isolate);
|
||||
~CompilationCache();
|
||||
|
||||
HashMap* EagerOptimizingSet();
|
||||
base::HashMap* EagerOptimizingSet();
|
||||
|
||||
// The number of sub caches covering the different types to cache.
|
||||
static const int kSubCacheCount = 4;
|
||||
|
14
src/d8.h
14
src/d8.h
@ -7,8 +7,8 @@
|
||||
|
||||
#ifndef V8_SHARED
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/time.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#else
|
||||
#include "include/v8.h"
|
||||
@ -61,13 +61,13 @@ class CounterMap {
|
||||
public:
|
||||
CounterMap(): hash_map_(Match) { }
|
||||
Counter* Lookup(const char* name) {
|
||||
i::HashMap::Entry* answer =
|
||||
base::HashMap::Entry* answer =
|
||||
hash_map_.Lookup(const_cast<char*>(name), Hash(name));
|
||||
if (!answer) return NULL;
|
||||
return reinterpret_cast<Counter*>(answer->value);
|
||||
}
|
||||
void Set(const char* name, Counter* value) {
|
||||
i::HashMap::Entry* answer =
|
||||
base::HashMap::Entry* answer =
|
||||
hash_map_.LookupOrInsert(const_cast<char*>(name), Hash(name));
|
||||
DCHECK(answer != NULL);
|
||||
answer->value = value;
|
||||
@ -81,14 +81,14 @@ class CounterMap {
|
||||
const char* CurrentKey() { return static_cast<const char*>(entry_->key); }
|
||||
Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); }
|
||||
private:
|
||||
i::HashMap* map_;
|
||||
i::HashMap::Entry* entry_;
|
||||
base::HashMap* map_;
|
||||
base::HashMap::Entry* entry_;
|
||||
};
|
||||
|
||||
private:
|
||||
static int Hash(const char* name);
|
||||
static bool Match(void* key1, void* key2);
|
||||
i::HashMap hash_map_;
|
||||
base::HashMap hash_map_;
|
||||
};
|
||||
#endif // !V8_SHARED
|
||||
|
||||
@ -350,7 +350,7 @@ class Shell : public i::AllStatic {
|
||||
|
||||
#ifndef V8_SHARED
|
||||
// TODO(binji): stupid implementation for now. Is there an easy way to hash an
|
||||
// object for use in i::HashMap? By pointer?
|
||||
// object for use in base::HashMap? By pointer?
|
||||
typedef i::List<Local<Object>> ObjectList;
|
||||
static bool SerializeValue(Isolate* isolate, Local<Value> value,
|
||||
const ObjectList& to_transfer,
|
||||
|
@ -9,13 +9,13 @@
|
||||
#include "src/arguments.h"
|
||||
#include "src/assembler.h"
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/debug/liveedit.h"
|
||||
#include "src/execution.h"
|
||||
#include "src/factory.h"
|
||||
#include "src/flags.h"
|
||||
#include "src/frames.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/interpreter/source-position-table.h"
|
||||
#include "src/runtime/runtime.h"
|
||||
#include "src/string-stream.h"
|
||||
|
@ -2012,17 +2012,19 @@ static uint32_t HashCodeAddress(Address addr) {
|
||||
return static_cast<uint32_t>((offset >> kCodeAlignmentBits) * kGoldenRatio);
|
||||
}
|
||||
|
||||
|
||||
static HashMap* GetLineMap() {
|
||||
static HashMap* line_map = NULL;
|
||||
if (line_map == NULL) line_map = new HashMap(&HashMap::PointersMatch);
|
||||
static base::HashMap* GetLineMap() {
|
||||
static base::HashMap* line_map = NULL;
|
||||
if (line_map == NULL) {
|
||||
line_map = new base::HashMap(&base::HashMap::PointersMatch);
|
||||
}
|
||||
return line_map;
|
||||
}
|
||||
|
||||
|
||||
static void PutLineInfo(Address addr, LineInfo* info) {
|
||||
HashMap* line_map = GetLineMap();
|
||||
HashMap::Entry* e = line_map->LookupOrInsert(addr, HashCodeAddress(addr));
|
||||
base::HashMap* line_map = GetLineMap();
|
||||
base::HashMap::Entry* e =
|
||||
line_map->LookupOrInsert(addr, HashCodeAddress(addr));
|
||||
if (e->value != NULL) delete static_cast<LineInfo*>(e->value);
|
||||
e->value = info;
|
||||
}
|
||||
|
@ -526,7 +526,7 @@ AllocationMemento* Heap::FindAllocationMemento(HeapObject* object) {
|
||||
|
||||
template <Heap::UpdateAllocationSiteMode mode>
|
||||
void Heap::UpdateAllocationSite(HeapObject* object,
|
||||
HashMap* pretenuring_feedback) {
|
||||
base::HashMap* pretenuring_feedback) {
|
||||
DCHECK(InFromSpace(object));
|
||||
if (!FLAG_allocation_site_pretenuring ||
|
||||
!AllocationSite::CanTrack(object->map()->instance_type()))
|
||||
@ -554,7 +554,7 @@ void Heap::UpdateAllocationSite(HeapObject* object,
|
||||
// to dereference the allocation site and rather have to postpone all checks
|
||||
// till actually merging the data.
|
||||
Address key = memento_candidate->GetAllocationSiteUnchecked();
|
||||
HashMap::Entry* e =
|
||||
base::HashMap::Entry* e =
|
||||
pretenuring_feedback->LookupOrInsert(key, ObjectHash(key));
|
||||
DCHECK(e != nullptr);
|
||||
(*bit_cast<intptr_t*>(&e->value))++;
|
||||
|
@ -501,11 +501,10 @@ void Heap::RepairFreeListsAfterDeserialization() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Heap::MergeAllocationSitePretenuringFeedback(
|
||||
const HashMap& local_pretenuring_feedback) {
|
||||
const base::HashMap& local_pretenuring_feedback) {
|
||||
AllocationSite* site = nullptr;
|
||||
for (HashMap::Entry* local_entry = local_pretenuring_feedback.Start();
|
||||
for (base::HashMap::Entry* local_entry = local_pretenuring_feedback.Start();
|
||||
local_entry != nullptr;
|
||||
local_entry = local_pretenuring_feedback.Next(local_entry)) {
|
||||
site = reinterpret_cast<AllocationSite*>(local_entry->key);
|
||||
@ -534,8 +533,8 @@ void Heap::MergeAllocationSitePretenuringFeedback(
|
||||
class Heap::PretenuringScope {
|
||||
public:
|
||||
explicit PretenuringScope(Heap* heap) : heap_(heap) {
|
||||
heap_->global_pretenuring_feedback_ =
|
||||
new HashMap(HashMap::PointersMatch, kInitialFeedbackCapacity);
|
||||
heap_->global_pretenuring_feedback_ = new base::HashMap(
|
||||
base::HashMap::PointersMatch, kInitialFeedbackCapacity);
|
||||
}
|
||||
|
||||
~PretenuringScope() {
|
||||
@ -561,7 +560,7 @@ void Heap::ProcessPretenuringFeedback() {
|
||||
|
||||
// Step 1: Digest feedback for recorded allocation sites.
|
||||
bool maximum_size_scavenge = MaximumSizeScavenge();
|
||||
for (HashMap::Entry* e = global_pretenuring_feedback_->Start();
|
||||
for (base::HashMap::Entry* e = global_pretenuring_feedback_->Start();
|
||||
e != nullptr; e = global_pretenuring_feedback_->Next(e)) {
|
||||
allocation_sites++;
|
||||
site = reinterpret_cast<AllocationSite*>(e->key);
|
||||
|
@ -1377,7 +1377,7 @@ class Heap {
|
||||
// value) is cached on the local pretenuring feedback.
|
||||
template <UpdateAllocationSiteMode mode>
|
||||
inline void UpdateAllocationSite(HeapObject* object,
|
||||
HashMap* pretenuring_feedback);
|
||||
base::HashMap* pretenuring_feedback);
|
||||
|
||||
// Removes an entry from the global pretenuring storage.
|
||||
inline void RemoveAllocationSitePretenuringFeedback(AllocationSite* site);
|
||||
@ -1386,7 +1386,7 @@ class Heap {
|
||||
// method needs to be called after evacuation, as allocation sites may be
|
||||
// evacuated and this method resolves forward pointers accordingly.
|
||||
void MergeAllocationSitePretenuringFeedback(
|
||||
const HashMap& local_pretenuring_feedback);
|
||||
const base::HashMap& local_pretenuring_feedback);
|
||||
|
||||
// =============================================================================
|
||||
|
||||
@ -2210,7 +2210,7 @@ class Heap {
|
||||
// storage is only alive temporary during a GC. The invariant is that all
|
||||
// pointers in this map are already fixed, i.e., they do not point to
|
||||
// forwarding pointers.
|
||||
HashMap* global_pretenuring_feedback_;
|
||||
base::HashMap* global_pretenuring_feedback_;
|
||||
|
||||
char trace_ring_buffer_[kTraceRingBufferSize];
|
||||
// If it's not full then the data is from 0 to ring_buffer_end_. If it's
|
||||
|
@ -1735,7 +1735,7 @@ class MarkCompactCollector::EvacuateNewSpaceVisitor final
|
||||
|
||||
explicit EvacuateNewSpaceVisitor(Heap* heap,
|
||||
CompactionSpaceCollection* compaction_spaces,
|
||||
HashMap* local_pretenuring_feedback)
|
||||
base::HashMap* local_pretenuring_feedback)
|
||||
: EvacuateVisitorBase(heap, compaction_spaces),
|
||||
buffer_(LocalAllocationBuffer::InvalidBuffer()),
|
||||
space_to_allocate_(NEW_SPACE),
|
||||
@ -1864,7 +1864,7 @@ class MarkCompactCollector::EvacuateNewSpaceVisitor final
|
||||
AllocationSpace space_to_allocate_;
|
||||
intptr_t promoted_size_;
|
||||
intptr_t semispace_copied_size_;
|
||||
HashMap* local_pretenuring_feedback_;
|
||||
base::HashMap* local_pretenuring_feedback_;
|
||||
};
|
||||
|
||||
class MarkCompactCollector::EvacuateNewSpacePageVisitor final
|
||||
@ -3052,7 +3052,7 @@ class MarkCompactCollector::Evacuator : public Malloced {
|
||||
explicit Evacuator(MarkCompactCollector* collector)
|
||||
: collector_(collector),
|
||||
compaction_spaces_(collector->heap()),
|
||||
local_pretenuring_feedback_(HashMap::PointersMatch,
|
||||
local_pretenuring_feedback_(base::HashMap::PointersMatch,
|
||||
kInitialLocalPretenuringFeedbackCapacity),
|
||||
new_space_visitor_(collector->heap(), &compaction_spaces_,
|
||||
&local_pretenuring_feedback_),
|
||||
@ -3101,7 +3101,7 @@ class MarkCompactCollector::Evacuator : public Malloced {
|
||||
|
||||
// Locally cached collector data.
|
||||
CompactionSpaceCollection compaction_spaces_;
|
||||
HashMap local_pretenuring_feedback_;
|
||||
base::HashMap local_pretenuring_feedback_;
|
||||
|
||||
// Visitors for the corresponding spaces.
|
||||
EvacuateNewSpaceVisitor new_space_visitor_;
|
||||
|
@ -2929,15 +2929,13 @@ HeapObject* LargeObjectIterator::Next() {
|
||||
// -----------------------------------------------------------------------------
|
||||
// LargeObjectSpace
|
||||
|
||||
|
||||
LargeObjectSpace::LargeObjectSpace(Heap* heap, AllocationSpace id)
|
||||
: Space(heap, id, NOT_EXECUTABLE), // Managed on a per-allocation basis
|
||||
first_page_(NULL),
|
||||
size_(0),
|
||||
page_count_(0),
|
||||
objects_size_(0),
|
||||
chunk_map_(HashMap::PointersMatch, 1024) {}
|
||||
|
||||
chunk_map_(base::HashMap::PointersMatch, 1024) {}
|
||||
|
||||
LargeObjectSpace::~LargeObjectSpace() {}
|
||||
|
||||
@ -2988,7 +2986,7 @@ AllocationResult LargeObjectSpace::AllocateRaw(int object_size,
|
||||
uintptr_t base = reinterpret_cast<uintptr_t>(page) / MemoryChunk::kAlignment;
|
||||
uintptr_t limit = base + (page->size() - 1) / MemoryChunk::kAlignment;
|
||||
for (uintptr_t key = base; key <= limit; key++) {
|
||||
HashMap::Entry* entry = chunk_map_.LookupOrInsert(
|
||||
base::HashMap::Entry* entry = chunk_map_.LookupOrInsert(
|
||||
reinterpret_cast<void*>(key), static_cast<uint32_t>(key));
|
||||
DCHECK(entry != NULL);
|
||||
entry->value = page;
|
||||
@ -3031,8 +3029,8 @@ Object* LargeObjectSpace::FindObject(Address a) {
|
||||
|
||||
LargePage* LargeObjectSpace::FindPage(Address a) {
|
||||
uintptr_t key = reinterpret_cast<uintptr_t>(a) / MemoryChunk::kAlignment;
|
||||
HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key),
|
||||
static_cast<uint32_t>(key));
|
||||
base::HashMap::Entry* e = chunk_map_.Lookup(reinterpret_cast<void*>(key),
|
||||
static_cast<uint32_t>(key));
|
||||
if (e != NULL) {
|
||||
DCHECK(e->value != NULL);
|
||||
LargePage* page = reinterpret_cast<LargePage*>(e->value);
|
||||
|
@ -11,9 +11,9 @@
|
||||
#include "src/base/atomic-utils.h"
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/mutex.h"
|
||||
#include "src/flags.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#include "src/objects.h"
|
||||
#include "src/utils.h"
|
||||
@ -3084,7 +3084,7 @@ class LargeObjectSpace : public Space {
|
||||
int page_count_; // number of chunks
|
||||
intptr_t objects_size_; // size of objects
|
||||
// Map MemoryChunk::kAlignment-aligned chunks to large pages covering them
|
||||
HashMap chunk_map_;
|
||||
base::HashMap chunk_map_;
|
||||
|
||||
friend class LargeObjectIterator;
|
||||
};
|
||||
|
@ -13,6 +13,7 @@
|
||||
#include "src/assert-scope.h"
|
||||
#include "src/base/accounting-allocator.h"
|
||||
#include "src/base/atomicops.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/builtins.h"
|
||||
#include "src/cancelable-task.h"
|
||||
#include "src/contexts.h"
|
||||
@ -22,7 +23,6 @@
|
||||
#include "src/futex-emulation.h"
|
||||
#include "src/global-handles.h"
|
||||
#include "src/handles.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/heap/heap.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/optimizing-compile-dispatcher.h"
|
||||
@ -359,9 +359,9 @@ class ThreadLocalTop BASE_EMBEDDED {
|
||||
|
||||
#if USE_SIMULATOR
|
||||
|
||||
#define ISOLATE_INIT_SIMULATOR_LIST(V) \
|
||||
V(bool, simulator_initialized, false) \
|
||||
V(HashMap*, simulator_i_cache, NULL) \
|
||||
#define ISOLATE_INIT_SIMULATOR_LIST(V) \
|
||||
V(bool, simulator_initialized, false) \
|
||||
V(base::HashMap*, simulator_i_cache, NULL) \
|
||||
V(Redirection*, simulator_redirection, NULL)
|
||||
#else
|
||||
|
||||
@ -407,8 +407,8 @@ typedef List<HeapObject*> DebugObjectCache;
|
||||
V(DebugObjectCache*, string_stream_debug_object_cache, NULL) \
|
||||
V(Object*, string_stream_current_security_token, NULL) \
|
||||
V(ExternalReferenceTable*, external_reference_table, NULL) \
|
||||
V(HashMap*, external_reference_map, NULL) \
|
||||
V(HashMap*, root_index_map, NULL) \
|
||||
V(base::HashMap*, external_reference_map, NULL) \
|
||||
V(base::HashMap*, root_index_map, NULL) \
|
||||
V(int, pending_microtask_count, 0) \
|
||||
V(HStatistics*, hstatistics, NULL) \
|
||||
V(CompilationStatistics*, turbo_statistics, NULL) \
|
||||
|
@ -1,278 +0,0 @@
|
||||
// Copyright 2012 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This file is ported from src/hashmap.h
|
||||
|
||||
#ifndef V8_LIBSAMPLER_HASHMAP_H_
|
||||
#define V8_LIBSAMPLER_HASHMAP_H_
|
||||
|
||||
#include "src/base/bits.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/libsampler/utils.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace sampler {
|
||||
|
||||
class HashMapImpl {
|
||||
public:
|
||||
typedef bool (*MatchFun) (void* key1, void* key2);
|
||||
|
||||
// The default capacity.
|
||||
static const uint32_t kDefaultHashMapCapacity = 8;
|
||||
|
||||
// initial_capacity is the size of the initial hash map;
|
||||
// it must be a power of 2 (and thus must not be 0).
|
||||
HashMapImpl(MatchFun match,
|
||||
uint32_t capacity = kDefaultHashMapCapacity);
|
||||
|
||||
~HashMapImpl();
|
||||
|
||||
// HashMap entries are (key, value, hash) triplets.
|
||||
// Some clients may not need to use the value slot
|
||||
// (e.g. implementers of sets, where the key is the value).
|
||||
struct Entry {
|
||||
void* key;
|
||||
void* value;
|
||||
uint32_t hash; // The full hash value for key
|
||||
int order; // If you never remove entries this is the insertion order.
|
||||
};
|
||||
|
||||
// If an entry with matching key is found, returns that entry.
|
||||
// Otherwise, NULL is returned.
|
||||
Entry* Lookup(void* key, uint32_t hash) const;
|
||||
|
||||
// If an entry with matching key is found, returns that entry.
|
||||
// If no matching entry is found, a new entry is inserted with
|
||||
// corresponding key, key hash, and NULL value.
|
||||
Entry* LookupOrInsert(void* key, uint32_t hash);
|
||||
|
||||
// Removes the entry with matching key.
|
||||
// It returns the value of the deleted entry
|
||||
// or null if there is no value for such key.
|
||||
void* Remove(void* key, uint32_t hash);
|
||||
|
||||
// Empties the hash map (occupancy() == 0).
|
||||
void Clear();
|
||||
|
||||
// The number of (non-empty) entries in the table.
|
||||
uint32_t occupancy() const { return occupancy_; }
|
||||
|
||||
// The capacity of the table. The implementation
|
||||
// makes sure that occupancy is at most 80% of
|
||||
// the table capacity.
|
||||
uint32_t capacity() const { return capacity_; }
|
||||
|
||||
// Iteration
|
||||
//
|
||||
// for (Entry* p = map.Start(); p != NULL; p = map.Next(p)) {
|
||||
// ...
|
||||
// }
|
||||
//
|
||||
// If entries are inserted during iteration, the effect of
|
||||
// calling Next() is undefined.
|
||||
Entry* Start() const;
|
||||
Entry* Next(Entry* p) const;
|
||||
|
||||
// Some match functions defined for convenience.
|
||||
static bool PointersMatch(void* key1, void* key2) {
|
||||
return key1 == key2;
|
||||
}
|
||||
|
||||
private:
|
||||
MatchFun match_;
|
||||
Entry* map_;
|
||||
uint32_t capacity_;
|
||||
uint32_t occupancy_;
|
||||
|
||||
Entry* map_end() const { return map_ + capacity_; }
|
||||
Entry* Probe(void* key, uint32_t hash) const;
|
||||
void Initialize(uint32_t capacity);
|
||||
void Resize();
|
||||
};
|
||||
|
||||
typedef HashMapImpl HashMap;
|
||||
|
||||
HashMapImpl::HashMapImpl(MatchFun match, uint32_t initial_capacity) {
|
||||
match_ = match;
|
||||
Initialize(initial_capacity);
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::~HashMapImpl() {
|
||||
Malloced::Delete(map_);
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::Entry* HashMapImpl::Lookup(void* key, uint32_t hash) const {
|
||||
Entry* p = Probe(key, hash);
|
||||
return p->key != NULL ? p : NULL;
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::Entry* HashMapImpl::LookupOrInsert(void* key, uint32_t hash) {
|
||||
// Find a matching entry.
|
||||
Entry* p = Probe(key, hash);
|
||||
if (p->key != NULL) {
|
||||
return p;
|
||||
}
|
||||
|
||||
// No entry found; insert one.
|
||||
p->key = key;
|
||||
p->value = NULL;
|
||||
p->hash = hash;
|
||||
p->order = occupancy_;
|
||||
occupancy_++;
|
||||
|
||||
// Grow the map if we reached >= 80% occupancy.
|
||||
if (occupancy_ + occupancy_ / 4 >= capacity_) {
|
||||
Resize();
|
||||
p = Probe(key, hash);
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void* HashMapImpl::Remove(void* key, uint32_t hash) {
|
||||
// Lookup the entry for the key to remove.
|
||||
Entry* p = Probe(key, hash);
|
||||
if (p->key == NULL) {
|
||||
// Key not found nothing to remove.
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void* value = p->value;
|
||||
// To remove an entry we need to ensure that it does not create an empty
|
||||
// entry that will cause the search for another entry to stop too soon. If all
|
||||
// the entries between the entry to remove and the next empty slot have their
|
||||
// initial position inside this interval, clearing the entry to remove will
|
||||
// not break the search. If, while searching for the next empty entry, an
|
||||
// entry is encountered which does not have its initial position between the
|
||||
// entry to remove and the position looked at, then this entry can be moved to
|
||||
// the place of the entry to remove without breaking the search for it. The
|
||||
// entry made vacant by this move is now the entry to remove and the process
|
||||
// starts over.
|
||||
// Algorithm from http://en.wikipedia.org/wiki/Open_addressing.
|
||||
|
||||
// This guarantees loop termination as there is at least one empty entry so
|
||||
// eventually the removed entry will have an empty entry after it.
|
||||
DCHECK(occupancy_ < capacity_);
|
||||
|
||||
// p is the candidate entry to clear. q is used to scan forwards.
|
||||
Entry* q = p; // Start at the entry to remove.
|
||||
while (true) {
|
||||
// Move q to the next entry.
|
||||
q = q + 1;
|
||||
if (q == map_end()) {
|
||||
q = map_;
|
||||
}
|
||||
|
||||
// All entries between p and q have their initial position between p and q
|
||||
// and the entry p can be cleared without breaking the search for these
|
||||
// entries.
|
||||
if (q->key == NULL) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Find the initial position for the entry at position q.
|
||||
Entry* r = map_ + (q->hash & (capacity_ - 1));
|
||||
|
||||
// If the entry at position q has its initial position outside the range
|
||||
// between p and q it can be moved forward to position p and will still be
|
||||
// found. There is now a new candidate entry for clearing.
|
||||
if ((q > p && (r <= p || r > q)) ||
|
||||
(q < p && (r <= p && r > q))) {
|
||||
*p = *q;
|
||||
p = q;
|
||||
}
|
||||
}
|
||||
|
||||
// Clear the entry which is allowed to en emptied.
|
||||
p->key = NULL;
|
||||
occupancy_--;
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
void HashMapImpl::Clear() {
|
||||
// Mark all entries as empty.
|
||||
const Entry* end = map_end();
|
||||
for (Entry* p = map_; p < end; p++) {
|
||||
p->key = NULL;
|
||||
}
|
||||
occupancy_ = 0;
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::Entry* HashMapImpl::Start() const {
|
||||
return Next(map_ - 1);
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::Entry* HashMapImpl::Next(Entry* p) const {
|
||||
const Entry* end = map_end();
|
||||
DCHECK(map_ - 1 <= p && p < end);
|
||||
for (p++; p < end; p++) {
|
||||
if (p->key != NULL) {
|
||||
return p;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
HashMapImpl::Entry* HashMapImpl::Probe(void* key, uint32_t hash) const {
|
||||
DCHECK(key != NULL);
|
||||
|
||||
DCHECK(base::bits::IsPowerOfTwo32(capacity_));
|
||||
Entry* p = map_ + (hash & (capacity_ - 1));
|
||||
const Entry* end = map_end();
|
||||
DCHECK(map_ <= p && p < end);
|
||||
|
||||
DCHECK(occupancy_ < capacity_); // Guarantees loop termination.
|
||||
while (p->key != NULL && (hash != p->hash || !match_(key, p->key))) {
|
||||
p++;
|
||||
if (p >= end) {
|
||||
p = map_;
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
void HashMapImpl::Initialize(uint32_t capacity) {
|
||||
DCHECK(base::bits::IsPowerOfTwo32(capacity));
|
||||
map_ = reinterpret_cast<Entry*>(Malloced::New(capacity * sizeof(Entry)));
|
||||
CHECK(map_ != NULL);
|
||||
capacity_ = capacity;
|
||||
Clear();
|
||||
}
|
||||
|
||||
|
||||
void HashMapImpl::Resize() {
|
||||
Entry* map = map_;
|
||||
uint32_t n = occupancy_;
|
||||
|
||||
// Allocate larger map.
|
||||
Initialize(capacity_ * 2);
|
||||
|
||||
// Rehash all current entries.
|
||||
for (Entry* p = map; n > 0; p++) {
|
||||
if (p->key != NULL) {
|
||||
Entry* entry = LookupOrInsert(p->key, p->hash);
|
||||
entry->value = p->value;
|
||||
entry->order = p->order;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
// Delete old map.
|
||||
Malloced::Delete(map);
|
||||
}
|
||||
|
||||
} // namespace sampler
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_LIBSAMPLER_HASHMAP_H_
|
@ -1,27 +0,0 @@
|
||||
// Copyright 2016 the V8 project authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#ifndef V8_LIBSAMPLER_UTILS_H_
|
||||
#define V8_LIBSAMPLER_UTILS_H_
|
||||
|
||||
#include "include/v8.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace sampler {
|
||||
|
||||
class Malloced {
|
||||
public:
|
||||
static void* New(size_t size) {
|
||||
return malloc(size);
|
||||
}
|
||||
|
||||
static void Delete(void* p) {
|
||||
free(p);
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace sampler
|
||||
} // namespace v8
|
||||
|
||||
#endif // V8_LIBSAMPLER_UTILS_H_
|
@ -47,9 +47,8 @@
|
||||
#include <map>
|
||||
|
||||
#include "src/base/atomic-utils.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/platform/platform.h"
|
||||
#include "src/libsampler/hashmap.h"
|
||||
|
||||
|
||||
#if V8_OS_ANDROID && !defined(__BIONIC_HAVE_UCONTEXT_T)
|
||||
|
||||
@ -219,15 +218,16 @@ class Sampler::PlatformData {
|
||||
|
||||
class SamplerManager {
|
||||
public:
|
||||
SamplerManager() : sampler_map_(HashMap::PointersMatch) {}
|
||||
SamplerManager() : sampler_map_(base::HashMap::PointersMatch) {}
|
||||
|
||||
void AddSampler(Sampler* sampler) {
|
||||
AtomicGuard atomic_guard(&samplers_access_counter_);
|
||||
DCHECK(sampler->IsActive() || !sampler->IsRegistered());
|
||||
// Add sampler into map if needed.
|
||||
pthread_t thread_id = sampler->platform_data()->vm_tid();
|
||||
HashMap::Entry* entry = sampler_map_.LookupOrInsert(ThreadKey(thread_id),
|
||||
ThreadHash(thread_id));
|
||||
base::HashMap::Entry* entry =
|
||||
sampler_map_.LookupOrInsert(ThreadKey(thread_id),
|
||||
ThreadHash(thread_id));
|
||||
DCHECK(entry != nullptr);
|
||||
if (entry->value == nullptr) {
|
||||
SamplerList* samplers = new SamplerList();
|
||||
@ -256,7 +256,7 @@ class SamplerManager {
|
||||
pthread_t thread_id = sampler->platform_data()->vm_tid();
|
||||
void* thread_key = ThreadKey(thread_id);
|
||||
uint32_t thread_hash = ThreadHash(thread_id);
|
||||
HashMap::Entry* entry = sampler_map_.Lookup(thread_key, thread_hash);
|
||||
base::HashMap::Entry* entry = sampler_map_.Lookup(thread_key, thread_hash);
|
||||
DCHECK(entry != nullptr);
|
||||
SamplerList* samplers = reinterpret_cast<SamplerList*>(entry->value);
|
||||
for (SamplerListIterator iter = samplers->begin(); iter != samplers->end();
|
||||
@ -277,7 +277,7 @@ class SamplerManager {
|
||||
AtomicGuard atomic_guard(&SamplerManager::samplers_access_counter_, false);
|
||||
if (!atomic_guard.is_success()) return;
|
||||
pthread_t thread_id = pthread_self();
|
||||
HashMap::Entry* entry =
|
||||
base::HashMap::Entry* entry =
|
||||
sampler_map_.Lookup(ThreadKey(thread_id), ThreadHash(thread_id));
|
||||
if (!entry) return;
|
||||
SamplerList& samplers = *static_cast<SamplerList*>(entry->value);
|
||||
@ -296,7 +296,7 @@ class SamplerManager {
|
||||
static SamplerManager* instance() { return instance_.Pointer(); }
|
||||
|
||||
private:
|
||||
HashMap sampler_map_;
|
||||
base::HashMap sampler_map_;
|
||||
static AtomicMutex samplers_access_counter_;
|
||||
static base::LazyInstance<SamplerManager>::type instance_;
|
||||
};
|
||||
|
@ -864,9 +864,7 @@ void Simulator::set_last_debugger_input(char* input) {
|
||||
last_debugger_input_ = input;
|
||||
}
|
||||
|
||||
|
||||
void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
void* start_addr,
|
||||
void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
|
||||
size_t size) {
|
||||
intptr_t start = reinterpret_cast<intptr_t>(start_addr);
|
||||
int intra_line = (start & CachePage::kLineMask);
|
||||
@ -887,10 +885,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
v8::internal::HashMap::Entry* entry =
|
||||
i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
|
||||
base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
if (entry->value == NULL) {
|
||||
CachePage* new_page = new CachePage();
|
||||
entry->value = new_page;
|
||||
@ -900,9 +896,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
|
||||
|
||||
// Flush from start up to and not including start + size.
|
||||
void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
|
||||
intptr_t start,
|
||||
int size) {
|
||||
void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) {
|
||||
DCHECK(size <= CachePage::kPageSize);
|
||||
DCHECK(AllOnOnePage(start, size - 1));
|
||||
DCHECK((start & CachePage::kLineMask) == 0);
|
||||
@ -914,9 +908,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache,
|
||||
memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
|
||||
}
|
||||
|
||||
|
||||
void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
Instruction* instr) {
|
||||
void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
|
||||
intptr_t address = reinterpret_cast<intptr_t>(instr);
|
||||
void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
|
||||
void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
|
||||
@ -949,7 +941,7 @@ void Simulator::Initialize(Isolate* isolate) {
|
||||
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
i_cache_ = isolate_->simulator_i_cache();
|
||||
if (i_cache_ == NULL) {
|
||||
i_cache_ = new v8::internal::HashMap(&ICacheMatch);
|
||||
i_cache_ = new base::HashMap(&ICacheMatch);
|
||||
isolate_->set_simulator_i_cache(i_cache_);
|
||||
}
|
||||
Initialize(isolate);
|
||||
@ -1062,10 +1054,10 @@ class Redirection {
|
||||
|
||||
|
||||
// static
|
||||
void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
|
||||
void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
|
||||
Redirection::DeleteChain(first);
|
||||
if (i_cache != nullptr) {
|
||||
for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
entry = i_cache->Next(entry)) {
|
||||
delete static_cast<CachePage*>(entry->value);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ class SimulatorStack : public v8::internal::AllStatic {
|
||||
// Running with a simulator.
|
||||
|
||||
#include "src/assembler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -216,7 +216,7 @@ class Simulator {
|
||||
// Call on program start.
|
||||
static void Initialize(Isolate* isolate);
|
||||
|
||||
static void TearDown(HashMap* i_cache, Redirection* first);
|
||||
static void TearDown(base::HashMap* i_cache, Redirection* first);
|
||||
|
||||
// V8 generally calls into generated JS code with 5 parameters and into
|
||||
// generated RegExp code with 7 parameters. This is a convenience function,
|
||||
@ -236,8 +236,7 @@ class Simulator {
|
||||
char* last_debugger_input() { return last_debugger_input_; }
|
||||
|
||||
// ICache checking.
|
||||
static void FlushICache(v8::internal::HashMap* i_cache, void* start,
|
||||
size_t size);
|
||||
static void FlushICache(base::HashMap* i_cache, void* start, size_t size);
|
||||
|
||||
// Returns true if pc register contains one of the 'special_values' defined
|
||||
// below (bad_ra, end_sim_pc).
|
||||
@ -401,10 +400,9 @@ class Simulator {
|
||||
}
|
||||
|
||||
// ICache.
|
||||
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
int size);
|
||||
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
|
||||
static void CheckICache(base::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size);
|
||||
static CachePage* GetCachePage(base::HashMap* i_cache, void* page);
|
||||
|
||||
enum Exception {
|
||||
none,
|
||||
@ -450,7 +448,7 @@ class Simulator {
|
||||
char* last_debugger_input_;
|
||||
|
||||
// Icache simulation.
|
||||
v8::internal::HashMap* i_cache_;
|
||||
base::HashMap* i_cache_;
|
||||
|
||||
v8::internal::Isolate* isolate_;
|
||||
|
||||
|
@ -801,9 +801,7 @@ void Simulator::set_last_debugger_input(char* input) {
|
||||
last_debugger_input_ = input;
|
||||
}
|
||||
|
||||
|
||||
void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
void* start_addr,
|
||||
void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
|
||||
size_t size) {
|
||||
int64_t start = reinterpret_cast<int64_t>(start_addr);
|
||||
int64_t intra_line = (start & CachePage::kLineMask);
|
||||
@ -824,10 +822,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
v8::internal::HashMap::Entry* entry =
|
||||
i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
|
||||
base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
if (entry->value == NULL) {
|
||||
CachePage* new_page = new CachePage();
|
||||
entry->value = new_page;
|
||||
@ -837,7 +833,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
|
||||
|
||||
// Flush from start up to and not including start + size.
|
||||
void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start,
|
||||
size_t size) {
|
||||
DCHECK(size <= CachePage::kPageSize);
|
||||
DCHECK(AllOnOnePage(start, size - 1));
|
||||
@ -850,9 +846,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
|
||||
}
|
||||
|
||||
|
||||
void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
Instruction* instr) {
|
||||
void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
|
||||
int64_t address = reinterpret_cast<int64_t>(instr);
|
||||
void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
|
||||
void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
|
||||
@ -885,7 +879,7 @@ void Simulator::Initialize(Isolate* isolate) {
|
||||
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
i_cache_ = isolate_->simulator_i_cache();
|
||||
if (i_cache_ == NULL) {
|
||||
i_cache_ = new v8::internal::HashMap(&ICacheMatch);
|
||||
i_cache_ = new base::HashMap(&ICacheMatch);
|
||||
isolate_->set_simulator_i_cache(i_cache_);
|
||||
}
|
||||
Initialize(isolate);
|
||||
@ -1000,10 +994,10 @@ class Redirection {
|
||||
|
||||
|
||||
// static
|
||||
void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
|
||||
void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
|
||||
Redirection::DeleteChain(first);
|
||||
if (i_cache != nullptr) {
|
||||
for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
entry = i_cache->Next(entry)) {
|
||||
delete static_cast<CachePage*>(entry->value);
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ class SimulatorStack : public v8::internal::AllStatic {
|
||||
// Running with a simulator.
|
||||
|
||||
#include "src/assembler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -226,7 +226,7 @@ class Simulator {
|
||||
// Call on program start.
|
||||
static void Initialize(Isolate* isolate);
|
||||
|
||||
static void TearDown(HashMap* i_cache, Redirection* first);
|
||||
static void TearDown(base::HashMap* i_cache, Redirection* first);
|
||||
|
||||
// V8 generally calls into generated JS code with 5 parameters and into
|
||||
// generated RegExp code with 7 parameters. This is a convenience function,
|
||||
@ -246,8 +246,7 @@ class Simulator {
|
||||
char* last_debugger_input() { return last_debugger_input_; }
|
||||
|
||||
// ICache checking.
|
||||
static void FlushICache(v8::internal::HashMap* i_cache, void* start,
|
||||
size_t size);
|
||||
static void FlushICache(base::HashMap* i_cache, void* start, size_t size);
|
||||
|
||||
// Returns true if pc register contains one of the 'special_values' defined
|
||||
// below (bad_ra, end_sim_pc).
|
||||
@ -415,10 +414,9 @@ class Simulator {
|
||||
}
|
||||
|
||||
// ICache.
|
||||
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
size_t size);
|
||||
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
|
||||
static void CheckICache(base::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(base::HashMap* i_cache, intptr_t start, size_t size);
|
||||
static CachePage* GetCachePage(base::HashMap* i_cache, void* page);
|
||||
|
||||
enum Exception {
|
||||
none,
|
||||
@ -463,7 +461,7 @@ class Simulator {
|
||||
char* last_debugger_input_;
|
||||
|
||||
// Icache simulation.
|
||||
v8::internal::HashMap* i_cache_;
|
||||
base::HashMap* i_cache_;
|
||||
|
||||
v8::internal::Isolate* isolate_;
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/bailout-reason.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/parsing/expression-classifier.h"
|
||||
#include "src/parsing/func-name-inferrer.h"
|
||||
|
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
#include "src/parsing/preparse-data.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/parsing/parser.h"
|
||||
#include "src/parsing/preparse-data.h"
|
||||
#include "src/parsing/preparse-data-format.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -6,8 +6,8 @@
|
||||
#define V8_PARSING_PREPARSE_DATA_H_
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/collector.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/parsing/preparse-data-format.h"
|
||||
|
||||
|
@ -9,7 +9,6 @@
|
||||
#include "src/conversions-inl.h"
|
||||
#include "src/conversions.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#include "src/parsing/parser-base.h"
|
||||
#include "src/parsing/preparse-data-format.h"
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/ast/scopes.h"
|
||||
#include "src/bailout-reason.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/parsing/expression-classifier.h"
|
||||
#include "src/parsing/func-name-inferrer.h"
|
||||
|
@ -1587,7 +1587,7 @@ int DuplicateFinder::AddSymbol(Vector<const uint8_t> key,
|
||||
int value) {
|
||||
uint32_t hash = Hash(key, is_one_byte);
|
||||
byte* encoding = BackupKey(key, is_one_byte);
|
||||
HashMap::Entry* entry = map_.LookupOrInsert(encoding, hash);
|
||||
base::HashMap::Entry* entry = map_.LookupOrInsert(encoding, hash);
|
||||
int old_value = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
|
||||
entry->value =
|
||||
reinterpret_cast<void*>(static_cast<intptr_t>(value | old_value));
|
||||
|
@ -8,16 +8,16 @@
|
||||
#define V8_PARSING_SCANNER_H_
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/char-predicates.h"
|
||||
#include "src/collector.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#include "src/messages.h"
|
||||
#include "src/parsing/token.h"
|
||||
#include "src/unicode.h"
|
||||
#include "src/unicode-decoder.h"
|
||||
#include "src/unicode.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -143,7 +143,7 @@ class DuplicateFinder {
|
||||
UnicodeCache* unicode_constants_;
|
||||
// Backing store used to store strings used as hashmap keys.
|
||||
SequenceCollector<unsigned char> backing_store_;
|
||||
HashMap map_;
|
||||
base::HashMap map_;
|
||||
// Buffer used for string->number->canonical string conversions.
|
||||
char number_buffer_[kBufferSize];
|
||||
};
|
||||
|
@ -66,7 +66,7 @@ class SimulatorStack : public v8::internal::AllStatic {
|
||||
// Running with a simulator.
|
||||
|
||||
#include "src/assembler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/ppc/constants-ppc.h"
|
||||
|
||||
namespace v8 {
|
||||
|
@ -190,12 +190,10 @@ void AllocationTracker::DeleteFunctionInfo(FunctionInfo** info) {
|
||||
delete *info;
|
||||
}
|
||||
|
||||
|
||||
AllocationTracker::AllocationTracker(
|
||||
HeapObjectsMap* ids, StringsStorage* names)
|
||||
AllocationTracker::AllocationTracker(HeapObjectsMap* ids, StringsStorage* names)
|
||||
: ids_(ids),
|
||||
names_(names),
|
||||
id_to_function_info_index_(HashMap::PointersMatch),
|
||||
id_to_function_info_index_(base::HashMap::PointersMatch),
|
||||
info_index_for_other_state_(0) {
|
||||
FunctionInfo* info = new FunctionInfo();
|
||||
info->name = "(root)";
|
||||
@ -261,7 +259,7 @@ static uint32_t SnapshotObjectIdHash(SnapshotObjectId id) {
|
||||
|
||||
unsigned AllocationTracker::AddFunctionInfo(SharedFunctionInfo* shared,
|
||||
SnapshotObjectId id) {
|
||||
HashMap::Entry* entry = id_to_function_info_index_.LookupOrInsert(
|
||||
base::HashMap::Entry* entry = id_to_function_info_index_.LookupOrInsert(
|
||||
reinterpret_cast<void*>(id), SnapshotObjectIdHash(id));
|
||||
if (entry->value == NULL) {
|
||||
FunctionInfo* info = new FunctionInfo();
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <map>
|
||||
|
||||
#include "include/v8-profiler.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/handles.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#include "src/vector.h"
|
||||
|
||||
@ -143,7 +143,7 @@ class AllocationTracker {
|
||||
AllocationTraceTree trace_tree_;
|
||||
unsigned allocation_trace_buffer_[kMaxAllocationTraceLength];
|
||||
List<FunctionInfo*> function_info_list_;
|
||||
HashMap id_to_function_info_index_;
|
||||
base::HashMap id_to_function_info_index_;
|
||||
List<UnresolvedLocation*> unresolved_locations_;
|
||||
unsigned info_index_for_other_state_;
|
||||
AddressToTraceMap address_to_trace_;
|
||||
|
@ -392,7 +392,7 @@ bool HeapObjectsMap::MoveObject(Address from, Address to, int object_size) {
|
||||
entries_.at(to_entry_info_index).addr = NULL;
|
||||
}
|
||||
} else {
|
||||
HashMap::Entry* to_entry =
|
||||
base::HashMap::Entry* to_entry =
|
||||
entries_map_.LookupOrInsert(to, ComputePointerHash(to));
|
||||
if (to_entry->value != NULL) {
|
||||
// We found the existing entry with to address for an old object.
|
||||
@ -428,7 +428,8 @@ void HeapObjectsMap::UpdateObjectSize(Address addr, int size) {
|
||||
|
||||
|
||||
SnapshotObjectId HeapObjectsMap::FindEntry(Address addr) {
|
||||
HashMap::Entry* entry = entries_map_.Lookup(addr, ComputePointerHash(addr));
|
||||
base::HashMap::Entry* entry =
|
||||
entries_map_.Lookup(addr, ComputePointerHash(addr));
|
||||
if (entry == NULL) return 0;
|
||||
int entry_index = static_cast<int>(reinterpret_cast<intptr_t>(entry->value));
|
||||
EntryInfo& entry_info = entries_.at(entry_index);
|
||||
@ -441,7 +442,7 @@ SnapshotObjectId HeapObjectsMap::FindOrAddEntry(Address addr,
|
||||
unsigned int size,
|
||||
bool accessed) {
|
||||
DCHECK(static_cast<uint32_t>(entries_.length()) > entries_map_.occupancy());
|
||||
HashMap::Entry* entry =
|
||||
base::HashMap::Entry* entry =
|
||||
entries_map_.LookupOrInsert(addr, ComputePointerHash(addr));
|
||||
if (entry->value != NULL) {
|
||||
int entry_index =
|
||||
@ -545,7 +546,7 @@ int HeapObjectsMap::FindUntrackedObjects() {
|
||||
for (HeapObject* obj = iterator.next();
|
||||
obj != NULL;
|
||||
obj = iterator.next()) {
|
||||
HashMap::Entry* entry =
|
||||
base::HashMap::Entry* entry =
|
||||
entries_map_.Lookup(obj->address(), ComputePointerHash(obj->address()));
|
||||
if (entry == NULL) {
|
||||
++untracked;
|
||||
@ -665,7 +666,7 @@ void HeapObjectsMap::RemoveDeadEntries() {
|
||||
entries_.at(first_free_entry) = entry_info;
|
||||
}
|
||||
entries_.at(first_free_entry).accessed = false;
|
||||
HashMap::Entry* entry = entries_map_.Lookup(
|
||||
base::HashMap::Entry* entry = entries_map_.Lookup(
|
||||
entry_info.addr, ComputePointerHash(entry_info.addr));
|
||||
DCHECK(entry);
|
||||
entry->value = reinterpret_cast<void*>(first_free_entry);
|
||||
@ -698,37 +699,28 @@ SnapshotObjectId HeapObjectsMap::GenerateId(v8::RetainedObjectInfo* info) {
|
||||
|
||||
|
||||
size_t HeapObjectsMap::GetUsedMemorySize() const {
|
||||
return
|
||||
sizeof(*this) +
|
||||
sizeof(HashMap::Entry) * entries_map_.capacity() +
|
||||
GetMemoryUsedByList(entries_) +
|
||||
GetMemoryUsedByList(time_intervals_);
|
||||
}
|
||||
|
||||
|
||||
HeapEntriesMap::HeapEntriesMap()
|
||||
: entries_(HashMap::PointersMatch) {
|
||||
return sizeof(*this) +
|
||||
sizeof(base::HashMap::Entry) * entries_map_.capacity() +
|
||||
GetMemoryUsedByList(entries_) + GetMemoryUsedByList(time_intervals_);
|
||||
}
|
||||
|
||||
HeapEntriesMap::HeapEntriesMap() : entries_(base::HashMap::PointersMatch) {}
|
||||
|
||||
int HeapEntriesMap::Map(HeapThing thing) {
|
||||
HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing));
|
||||
base::HashMap::Entry* cache_entry = entries_.Lookup(thing, Hash(thing));
|
||||
if (cache_entry == NULL) return HeapEntry::kNoEntry;
|
||||
return static_cast<int>(reinterpret_cast<intptr_t>(cache_entry->value));
|
||||
}
|
||||
|
||||
|
||||
void HeapEntriesMap::Pair(HeapThing thing, int entry) {
|
||||
HashMap::Entry* cache_entry = entries_.LookupOrInsert(thing, Hash(thing));
|
||||
base::HashMap::Entry* cache_entry =
|
||||
entries_.LookupOrInsert(thing, Hash(thing));
|
||||
DCHECK(cache_entry->value == NULL);
|
||||
cache_entry->value = reinterpret_cast<void*>(static_cast<intptr_t>(entry));
|
||||
}
|
||||
|
||||
|
||||
HeapObjectsSet::HeapObjectsSet()
|
||||
: entries_(HashMap::PointersMatch) {
|
||||
}
|
||||
|
||||
HeapObjectsSet::HeapObjectsSet() : entries_(base::HashMap::PointersMatch) {}
|
||||
|
||||
void HeapObjectsSet::Clear() {
|
||||
entries_.Clear();
|
||||
@ -751,7 +743,7 @@ void HeapObjectsSet::Insert(Object* obj) {
|
||||
|
||||
const char* HeapObjectsSet::GetTag(Object* obj) {
|
||||
HeapObject* object = HeapObject::cast(obj);
|
||||
HashMap::Entry* cache_entry =
|
||||
base::HashMap::Entry* cache_entry =
|
||||
entries_.Lookup(object, HeapEntriesMap::Hash(object));
|
||||
return cache_entry != NULL
|
||||
? reinterpret_cast<const char*>(cache_entry->value)
|
||||
@ -762,7 +754,7 @@ const char* HeapObjectsSet::GetTag(Object* obj) {
|
||||
void HeapObjectsSet::SetTag(Object* obj, const char* tag) {
|
||||
if (!obj->IsHeapObject()) return;
|
||||
HeapObject* object = HeapObject::cast(obj);
|
||||
HashMap::Entry* cache_entry =
|
||||
base::HashMap::Entry* cache_entry =
|
||||
entries_.LookupOrInsert(object, HeapEntriesMap::Hash(object));
|
||||
cache_entry->value = const_cast<char*>(tag);
|
||||
}
|
||||
@ -2254,8 +2246,7 @@ NativeObjectsExplorer::NativeObjectsExplorer(
|
||||
|
||||
|
||||
NativeObjectsExplorer::~NativeObjectsExplorer() {
|
||||
for (HashMap::Entry* p = objects_by_info_.Start();
|
||||
p != NULL;
|
||||
for (base::HashMap::Entry* p = objects_by_info_.Start(); p != NULL;
|
||||
p = objects_by_info_.Next(p)) {
|
||||
v8::RetainedObjectInfo* info =
|
||||
reinterpret_cast<v8::RetainedObjectInfo*>(p->key);
|
||||
@ -2264,8 +2255,7 @@ NativeObjectsExplorer::~NativeObjectsExplorer() {
|
||||
reinterpret_cast<List<HeapObject*>* >(p->value);
|
||||
delete objects;
|
||||
}
|
||||
for (HashMap::Entry* p = native_groups_.Start();
|
||||
p != NULL;
|
||||
for (base::HashMap::Entry* p = native_groups_.Start(); p != NULL;
|
||||
p = native_groups_.Next(p)) {
|
||||
v8::RetainedObjectInfo* info =
|
||||
reinterpret_cast<v8::RetainedObjectInfo*>(p->value);
|
||||
@ -2337,7 +2327,8 @@ void NativeObjectsExplorer::FillImplicitReferences() {
|
||||
|
||||
List<HeapObject*>* NativeObjectsExplorer::GetListMaybeDisposeInfo(
|
||||
v8::RetainedObjectInfo* info) {
|
||||
HashMap::Entry* entry = objects_by_info_.LookupOrInsert(info, InfoHash(info));
|
||||
base::HashMap::Entry* entry =
|
||||
objects_by_info_.LookupOrInsert(info, InfoHash(info));
|
||||
if (entry->value != NULL) {
|
||||
info->Dispose();
|
||||
} else {
|
||||
@ -2353,8 +2344,7 @@ bool NativeObjectsExplorer::IterateAndExtractReferences(
|
||||
FillRetainedObjects();
|
||||
FillImplicitReferences();
|
||||
if (EstimateObjectsCount() > 0) {
|
||||
for (HashMap::Entry* p = objects_by_info_.Start();
|
||||
p != NULL;
|
||||
for (base::HashMap::Entry* p = objects_by_info_.Start(); p != NULL;
|
||||
p = objects_by_info_.Next(p)) {
|
||||
v8::RetainedObjectInfo* info =
|
||||
reinterpret_cast<v8::RetainedObjectInfo*>(p->key);
|
||||
@ -2406,7 +2396,7 @@ NativeGroupRetainedObjectInfo* NativeObjectsExplorer::FindOrAddGroupInfo(
|
||||
label_copy,
|
||||
static_cast<int>(strlen(label_copy)),
|
||||
isolate_->heap()->HashSeed());
|
||||
HashMap::Entry* entry =
|
||||
base::HashMap::Entry* entry =
|
||||
native_groups_.LookupOrInsert(const_cast<char*>(label_copy), hash);
|
||||
if (entry->value == NULL) {
|
||||
entry->value = new NativeGroupRetainedObjectInfo(label);
|
||||
@ -2452,8 +2442,7 @@ void NativeObjectsExplorer::SetWrapperNativeReferences(
|
||||
|
||||
|
||||
void NativeObjectsExplorer::SetRootNativeRootsReference() {
|
||||
for (HashMap::Entry* entry = native_groups_.Start();
|
||||
entry;
|
||||
for (base::HashMap::Entry* entry = native_groups_.Start(); entry;
|
||||
entry = native_groups_.Next(entry)) {
|
||||
NativeGroupRetainedObjectInfo* group_info =
|
||||
static_cast<NativeGroupRetainedObjectInfo*>(entry->value);
|
||||
@ -2721,7 +2710,7 @@ void HeapSnapshotJSONSerializer::SerializeImpl() {
|
||||
|
||||
|
||||
int HeapSnapshotJSONSerializer::GetStringId(const char* s) {
|
||||
HashMap::Entry* cache_entry =
|
||||
base::HashMap::Entry* cache_entry =
|
||||
strings_.LookupOrInsert(const_cast<char*>(s), StringHash(s));
|
||||
if (cache_entry->value == NULL) {
|
||||
cache_entry->value = reinterpret_cast<void*>(next_string_id_++);
|
||||
@ -3106,8 +3095,7 @@ void HeapSnapshotJSONSerializer::SerializeString(const unsigned char* s) {
|
||||
void HeapSnapshotJSONSerializer::SerializeStrings() {
|
||||
ScopedVector<const unsigned char*> sorted_strings(
|
||||
strings_.occupancy() + 1);
|
||||
for (HashMap::Entry* entry = strings_.Start();
|
||||
entry != NULL;
|
||||
for (base::HashMap::Entry* entry = strings_.Start(); entry != NULL;
|
||||
entry = strings_.Next(entry)) {
|
||||
int index = static_cast<int>(reinterpret_cast<uintptr_t>(entry->value));
|
||||
sorted_strings[index] = reinterpret_cast<const unsigned char*>(entry->key);
|
||||
|
@ -259,7 +259,7 @@ class HeapObjectsMap {
|
||||
};
|
||||
|
||||
SnapshotObjectId next_id_;
|
||||
HashMap entries_map_;
|
||||
base::HashMap entries_map_;
|
||||
List<EntryInfo> entries_;
|
||||
List<TimeInterval> time_intervals_;
|
||||
Heap* heap_;
|
||||
@ -297,7 +297,7 @@ class HeapEntriesMap {
|
||||
v8::internal::kZeroHashSeed);
|
||||
}
|
||||
|
||||
HashMap entries_;
|
||||
base::HashMap entries_;
|
||||
|
||||
friend class HeapObjectsSet;
|
||||
|
||||
@ -316,7 +316,7 @@ class HeapObjectsSet {
|
||||
bool is_empty() const { return entries_.occupancy() == 0; }
|
||||
|
||||
private:
|
||||
HashMap entries_;
|
||||
base::HashMap entries_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(HeapObjectsSet);
|
||||
};
|
||||
@ -521,8 +521,8 @@ class NativeObjectsExplorer {
|
||||
bool embedder_queried_;
|
||||
HeapObjectsSet in_groups_;
|
||||
// RetainedObjectInfo* -> List<HeapObject*>*
|
||||
HashMap objects_by_info_;
|
||||
HashMap native_groups_;
|
||||
base::HashMap objects_by_info_;
|
||||
base::HashMap native_groups_;
|
||||
HeapEntriesAllocator* synthetic_entries_allocator_;
|
||||
HeapEntriesAllocator* native_entries_allocator_;
|
||||
// Used during references extraction.
|
||||
@ -609,7 +609,7 @@ class HeapSnapshotJSONSerializer {
|
||||
static const int kNodeFieldsCount;
|
||||
|
||||
HeapSnapshot* snapshot_;
|
||||
HashMap strings_;
|
||||
base::HashMap strings_;
|
||||
int next_node_id_;
|
||||
int next_string_id_;
|
||||
OutputStreamWriter* writer_;
|
||||
|
@ -170,14 +170,15 @@ void ProfileNode::CollectDeoptInfo(CodeEntry* entry) {
|
||||
|
||||
|
||||
ProfileNode* ProfileNode::FindChild(CodeEntry* entry) {
|
||||
HashMap::Entry* map_entry = children_.Lookup(entry, CodeEntryHash(entry));
|
||||
base::HashMap::Entry* map_entry =
|
||||
children_.Lookup(entry, CodeEntryHash(entry));
|
||||
return map_entry != NULL ?
|
||||
reinterpret_cast<ProfileNode*>(map_entry->value) : NULL;
|
||||
}
|
||||
|
||||
|
||||
ProfileNode* ProfileNode::FindOrAddChild(CodeEntry* entry) {
|
||||
HashMap::Entry* map_entry =
|
||||
base::HashMap::Entry* map_entry =
|
||||
children_.LookupOrInsert(entry, CodeEntryHash(entry));
|
||||
ProfileNode* node = reinterpret_cast<ProfileNode*>(map_entry->value);
|
||||
if (node == NULL) {
|
||||
@ -194,7 +195,7 @@ void ProfileNode::IncrementLineTicks(int src_line) {
|
||||
if (src_line == v8::CpuProfileNode::kNoLineNumberInfo) return;
|
||||
// Increment a hit counter of a certain source line.
|
||||
// Add a new source line if not found.
|
||||
HashMap::Entry* e =
|
||||
base::HashMap::Entry* e =
|
||||
line_ticks_.LookupOrInsert(reinterpret_cast<void*>(src_line), src_line);
|
||||
DCHECK(e);
|
||||
e->value = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(e->value) + 1);
|
||||
@ -212,7 +213,7 @@ bool ProfileNode::GetLineTicks(v8::CpuProfileNode::LineTick* entries,
|
||||
|
||||
v8::CpuProfileNode::LineTick* entry = entries;
|
||||
|
||||
for (HashMap::Entry* p = line_ticks_.Start(); p != NULL;
|
||||
for (base::HashMap::Entry *p = line_ticks_.Start(); p != NULL;
|
||||
p = line_ticks_.Next(p), entry++) {
|
||||
entry->line =
|
||||
static_cast<unsigned int>(reinterpret_cast<uintptr_t>(p->key));
|
||||
@ -250,8 +251,7 @@ void ProfileNode::Print(int indent) {
|
||||
base::OS::Print("%*s bailed out due to '%s'\n", indent + 10, "",
|
||||
bailout_reason);
|
||||
}
|
||||
for (HashMap::Entry* p = children_.Start();
|
||||
p != NULL;
|
||||
for (base::HashMap::Entry* p = children_.Start(); p != NULL;
|
||||
p = children_.Next(p)) {
|
||||
reinterpret_cast<ProfileNode*>(p->value)->Print(indent + 2);
|
||||
}
|
||||
@ -287,7 +287,7 @@ ProfileTree::~ProfileTree() {
|
||||
|
||||
unsigned ProfileTree::GetFunctionId(const ProfileNode* node) {
|
||||
CodeEntry* code_entry = node->entry();
|
||||
HashMap::Entry* entry =
|
||||
base::HashMap::Entry* entry =
|
||||
function_ids_.LookupOrInsert(code_entry, code_entry->GetHash());
|
||||
if (!entry->value) {
|
||||
entry->value = reinterpret_cast<void*>(next_function_id_++);
|
||||
|
@ -8,8 +8,8 @@
|
||||
#include <map>
|
||||
#include "include/v8-profiler.h"
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/compiler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/profiler/strings-storage.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -180,10 +180,10 @@ class ProfileNode {
|
||||
CodeEntry* entry_;
|
||||
unsigned self_ticks_;
|
||||
// Mapping from CodeEntry* to ProfileNode*
|
||||
HashMap children_;
|
||||
base::HashMap children_;
|
||||
List<ProfileNode*> children_list_;
|
||||
unsigned id_;
|
||||
HashMap line_ticks_;
|
||||
base::HashMap line_ticks_;
|
||||
|
||||
std::vector<CpuProfileDeoptInfo> deopt_infos_;
|
||||
|
||||
@ -220,7 +220,7 @@ class ProfileTree {
|
||||
Isolate* isolate_;
|
||||
|
||||
unsigned next_function_id_;
|
||||
HashMap function_ids_;
|
||||
base::HashMap function_ids_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ProfileTree);
|
||||
};
|
||||
|
@ -22,7 +22,8 @@ StringsStorage::StringsStorage(Heap* heap)
|
||||
|
||||
|
||||
StringsStorage::~StringsStorage() {
|
||||
for (HashMap::Entry* p = names_.Start(); p != NULL; p = names_.Next(p)) {
|
||||
for (base::HashMap::Entry* p = names_.Start(); p != NULL;
|
||||
p = names_.Next(p)) {
|
||||
DeleteArray(reinterpret_cast<const char*>(p->value));
|
||||
}
|
||||
}
|
||||
@ -30,7 +31,7 @@ StringsStorage::~StringsStorage() {
|
||||
|
||||
const char* StringsStorage::GetCopy(const char* src) {
|
||||
int len = static_cast<int>(strlen(src));
|
||||
HashMap::Entry* entry = GetEntry(src, len);
|
||||
base::HashMap::Entry* entry = GetEntry(src, len);
|
||||
if (entry->value == NULL) {
|
||||
Vector<char> dst = Vector<char>::New(len + 1);
|
||||
StrNCpy(dst, src, len);
|
||||
@ -52,7 +53,7 @@ const char* StringsStorage::GetFormatted(const char* format, ...) {
|
||||
|
||||
|
||||
const char* StringsStorage::AddOrDisposeString(char* str, int len) {
|
||||
HashMap::Entry* entry = GetEntry(str, len);
|
||||
base::HashMap::Entry* entry = GetEntry(str, len);
|
||||
if (entry->value == NULL) {
|
||||
// New entry added.
|
||||
entry->key = str;
|
||||
@ -107,15 +108,15 @@ const char* StringsStorage::GetFunctionName(const char* name) {
|
||||
|
||||
size_t StringsStorage::GetUsedMemorySize() const {
|
||||
size_t size = sizeof(*this);
|
||||
size += sizeof(HashMap::Entry) * names_.capacity();
|
||||
for (HashMap::Entry* p = names_.Start(); p != NULL; p = names_.Next(p)) {
|
||||
size += sizeof(base::HashMap::Entry) * names_.capacity();
|
||||
for (base::HashMap::Entry* p = names_.Start(); p != NULL;
|
||||
p = names_.Next(p)) {
|
||||
size += strlen(reinterpret_cast<const char*>(p->value)) + 1;
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) {
|
||||
base::HashMap::Entry* StringsStorage::GetEntry(const char* str, int len) {
|
||||
uint32_t hash = StringHasher::HashSequentialString(str, len, hash_seed_);
|
||||
return names_.LookupOrInsert(const_cast<char*>(str), hash);
|
||||
}
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#include "src/allocation.h"
|
||||
#include "src/base/compiler-specific.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
|
||||
namespace v8 {
|
||||
namespace internal {
|
||||
@ -34,10 +34,10 @@ class StringsStorage {
|
||||
|
||||
static bool StringsMatch(void* key1, void* key2);
|
||||
const char* AddOrDisposeString(char* str, int len);
|
||||
HashMap::Entry* GetEntry(const char* str, int len);
|
||||
base::HashMap::Entry* GetEntry(const char* str, int len);
|
||||
|
||||
uint32_t hash_seed_;
|
||||
HashMap names_;
|
||||
base::HashMap names_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(StringsStorage);
|
||||
};
|
||||
|
@ -701,7 +701,7 @@ void Simulator::set_last_debugger_input(char* input) {
|
||||
last_debugger_input_ = input;
|
||||
}
|
||||
|
||||
void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr,
|
||||
void Simulator::FlushICache(base::HashMap* i_cache, void* start_addr,
|
||||
size_t size) {
|
||||
intptr_t start = reinterpret_cast<intptr_t>(start_addr);
|
||||
int intra_line = (start & CachePage::kLineMask);
|
||||
@ -722,9 +722,8 @@ void Simulator::FlushICache(v8::internal::HashMap* i_cache, void* start_addr,
|
||||
}
|
||||
}
|
||||
|
||||
CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
v8::internal::HashMap::Entry* entry =
|
||||
i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
CachePage* Simulator::GetCachePage(base::HashMap* i_cache, void* page) {
|
||||
base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page));
|
||||
if (entry->value == NULL) {
|
||||
CachePage* new_page = new CachePage();
|
||||
entry->value = new_page;
|
||||
@ -733,8 +732,7 @@ CachePage* Simulator::GetCachePage(v8::internal::HashMap* i_cache, void* page) {
|
||||
}
|
||||
|
||||
// Flush from start up to and not including start + size.
|
||||
void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
int size) {
|
||||
void Simulator::FlushOnePage(base::HashMap* i_cache, intptr_t start, int size) {
|
||||
DCHECK(size <= CachePage::kPageSize);
|
||||
DCHECK(AllOnOnePage(start, size - 1));
|
||||
DCHECK((start & CachePage::kLineMask) == 0);
|
||||
@ -746,8 +744,7 @@ void Simulator::FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift);
|
||||
}
|
||||
|
||||
void Simulator::CheckICache(v8::internal::HashMap* i_cache,
|
||||
Instruction* instr) {
|
||||
void Simulator::CheckICache(base::HashMap* i_cache, Instruction* instr) {
|
||||
intptr_t address = reinterpret_cast<intptr_t>(instr);
|
||||
void* page = reinterpret_cast<void*>(address & (~CachePage::kPageMask));
|
||||
void* line = reinterpret_cast<void*>(address & (~CachePage::kLineMask));
|
||||
@ -1513,7 +1510,7 @@ void Simulator::EvalTableInit() {
|
||||
Simulator::Simulator(Isolate* isolate) : isolate_(isolate) {
|
||||
i_cache_ = isolate_->simulator_i_cache();
|
||||
if (i_cache_ == NULL) {
|
||||
i_cache_ = new v8::internal::HashMap(&ICacheMatch);
|
||||
i_cache_ = new base::HashMap(&ICacheMatch);
|
||||
isolate_->set_simulator_i_cache(i_cache_);
|
||||
}
|
||||
Initialize(isolate);
|
||||
@ -1654,10 +1651,10 @@ class Redirection {
|
||||
};
|
||||
|
||||
// static
|
||||
void Simulator::TearDown(HashMap* i_cache, Redirection* first) {
|
||||
void Simulator::TearDown(base::HashMap* i_cache, Redirection* first) {
|
||||
Redirection::DeleteChain(first);
|
||||
if (i_cache != nullptr) {
|
||||
for (HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr;
|
||||
entry = i_cache->Next(entry)) {
|
||||
delete static_cast<CachePage*>(entry->value);
|
||||
}
|
||||
|
@ -64,7 +64,7 @@ class SimulatorStack : public v8::internal::AllStatic {
|
||||
// Running with a simulator.
|
||||
|
||||
#include "src/assembler.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/s390/constants-s390.h"
|
||||
|
||||
namespace v8 {
|
||||
@ -211,7 +211,7 @@ class Simulator {
|
||||
// Call on program start.
|
||||
static void Initialize(Isolate* isolate);
|
||||
|
||||
static void TearDown(HashMap* i_cache, Redirection* first);
|
||||
static void TearDown(base::HashMap* i_cache, Redirection* first);
|
||||
|
||||
// V8 generally calls into generated JS code with 5 parameters and into
|
||||
// generated RegExp code with 7 parameters. This is a convenience function,
|
||||
@ -233,8 +233,7 @@ class Simulator {
|
||||
char* last_debugger_input() { return last_debugger_input_; }
|
||||
|
||||
// ICache checking.
|
||||
static void FlushICache(v8::internal::HashMap* i_cache, void* start,
|
||||
size_t size);
|
||||
static void FlushICache(base::HashMap* i_cache, void* start, size_t size);
|
||||
|
||||
// Returns true if pc register contains one of the 'special_values' defined
|
||||
// below (bad_lr, end_sim_pc).
|
||||
@ -444,10 +443,9 @@ class Simulator {
|
||||
void ExecuteInstruction(Instruction* instr, bool auto_incr_pc = true);
|
||||
|
||||
// ICache.
|
||||
static void CheckICache(v8::internal::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(v8::internal::HashMap* i_cache, intptr_t start,
|
||||
int size);
|
||||
static CachePage* GetCachePage(v8::internal::HashMap* i_cache, void* page);
|
||||
static void CheckICache(base::HashMap* i_cache, Instruction* instr);
|
||||
static void FlushOnePage(base::HashMap* i_cache, intptr_t start, int size);
|
||||
static CachePage* GetCachePage(base::HashMap* i_cache, void* page);
|
||||
|
||||
// Runtime call support.
|
||||
static void* RedirectExternalReference(
|
||||
@ -482,7 +480,7 @@ class Simulator {
|
||||
char* last_debugger_input_;
|
||||
|
||||
// Icache simulation
|
||||
v8::internal::HashMap* i_cache_;
|
||||
base::HashMap* i_cache_;
|
||||
|
||||
// Registered breakpoints.
|
||||
Instruction* break_pc_;
|
||||
|
@ -24,21 +24,21 @@ class PartialSerializer : public Serializer {
|
||||
private:
|
||||
class PartialCacheIndexMap : public AddressMapBase {
|
||||
public:
|
||||
PartialCacheIndexMap() : map_(HashMap::PointersMatch) {}
|
||||
PartialCacheIndexMap() : map_(base::HashMap::PointersMatch) {}
|
||||
|
||||
static const int kInvalidIndex = -1;
|
||||
|
||||
// Lookup object in the map. Return its index if found, or create
|
||||
// a new entry with new_index as value, and return kInvalidIndex.
|
||||
int LookupOrInsert(HeapObject* obj, int new_index) {
|
||||
HashMap::Entry* entry = LookupEntry(&map_, obj, false);
|
||||
base::HashMap::Entry* entry = LookupEntry(&map_, obj, false);
|
||||
if (entry != NULL) return GetValue(entry);
|
||||
SetValue(LookupEntry(&map_, obj, true), static_cast<uint32_t>(new_index));
|
||||
return kInvalidIndex;
|
||||
}
|
||||
|
||||
private:
|
||||
HashMap map_;
|
||||
base::HashMap map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap);
|
||||
};
|
||||
|
@ -14,7 +14,7 @@ namespace internal {
|
||||
ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
|
||||
map_ = isolate->external_reference_map();
|
||||
if (map_ != NULL) return;
|
||||
map_ = new HashMap(HashMap::PointersMatch);
|
||||
map_ = new base::HashMap(base::HashMap::PointersMatch);
|
||||
ExternalReferenceTable* table = ExternalReferenceTable::instance(isolate);
|
||||
for (int i = 0; i < table->size(); ++i) {
|
||||
Address addr = table->address(i);
|
||||
@ -31,16 +31,16 @@ ExternalReferenceEncoder::ExternalReferenceEncoder(Isolate* isolate) {
|
||||
|
||||
uint32_t ExternalReferenceEncoder::Encode(Address address) const {
|
||||
DCHECK_NOT_NULL(address);
|
||||
HashMap::Entry* entry =
|
||||
const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
|
||||
base::HashMap::Entry* entry =
|
||||
const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address));
|
||||
DCHECK_NOT_NULL(entry);
|
||||
return static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
|
||||
}
|
||||
|
||||
const char* ExternalReferenceEncoder::NameOfAddress(Isolate* isolate,
|
||||
Address address) const {
|
||||
HashMap::Entry* entry =
|
||||
const_cast<HashMap*>(map_)->Lookup(address, Hash(address));
|
||||
base::HashMap::Entry* entry =
|
||||
const_cast<base::HashMap*>(map_)->Lookup(address, Hash(address));
|
||||
if (entry == NULL) return "<unknown>";
|
||||
uint32_t i = static_cast<uint32_t>(reinterpret_cast<intptr_t>(entry->value));
|
||||
return ExternalReferenceTable::instance(isolate)->name(i);
|
||||
|
@ -28,7 +28,7 @@ class ExternalReferenceEncoder {
|
||||
kPointerSizeLog2);
|
||||
}
|
||||
|
||||
HashMap* map_;
|
||||
base::HashMap* map_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(ExternalReferenceEncoder);
|
||||
};
|
||||
|
@ -38,28 +38,29 @@ class CodeAddressMap : public CodeEventLogger {
|
||||
private:
|
||||
class NameMap {
|
||||
public:
|
||||
NameMap() : impl_(HashMap::PointersMatch) {}
|
||||
NameMap() : impl_(base::HashMap::PointersMatch) {}
|
||||
|
||||
~NameMap() {
|
||||
for (HashMap::Entry* p = impl_.Start(); p != NULL; p = impl_.Next(p)) {
|
||||
for (base::HashMap::Entry* p = impl_.Start(); p != NULL;
|
||||
p = impl_.Next(p)) {
|
||||
DeleteArray(static_cast<const char*>(p->value));
|
||||
}
|
||||
}
|
||||
|
||||
void Insert(Address code_address, const char* name, int name_size) {
|
||||
HashMap::Entry* entry = FindOrCreateEntry(code_address);
|
||||
base::HashMap::Entry* entry = FindOrCreateEntry(code_address);
|
||||
if (entry->value == NULL) {
|
||||
entry->value = CopyName(name, name_size);
|
||||
}
|
||||
}
|
||||
|
||||
const char* Lookup(Address code_address) {
|
||||
HashMap::Entry* entry = FindEntry(code_address);
|
||||
base::HashMap::Entry* entry = FindEntry(code_address);
|
||||
return (entry != NULL) ? static_cast<const char*>(entry->value) : NULL;
|
||||
}
|
||||
|
||||
void Remove(Address code_address) {
|
||||
HashMap::Entry* entry = FindEntry(code_address);
|
||||
base::HashMap::Entry* entry = FindEntry(code_address);
|
||||
if (entry != NULL) {
|
||||
DeleteArray(static_cast<char*>(entry->value));
|
||||
RemoveEntry(entry);
|
||||
@ -68,11 +69,11 @@ class CodeAddressMap : public CodeEventLogger {
|
||||
|
||||
void Move(Address from, Address to) {
|
||||
if (from == to) return;
|
||||
HashMap::Entry* from_entry = FindEntry(from);
|
||||
base::HashMap::Entry* from_entry = FindEntry(from);
|
||||
DCHECK(from_entry != NULL);
|
||||
void* value = from_entry->value;
|
||||
RemoveEntry(from_entry);
|
||||
HashMap::Entry* to_entry = FindOrCreateEntry(to);
|
||||
base::HashMap::Entry* to_entry = FindOrCreateEntry(to);
|
||||
DCHECK(to_entry->value == NULL);
|
||||
to_entry->value = value;
|
||||
}
|
||||
@ -89,20 +90,20 @@ class CodeAddressMap : public CodeEventLogger {
|
||||
return result;
|
||||
}
|
||||
|
||||
HashMap::Entry* FindOrCreateEntry(Address code_address) {
|
||||
base::HashMap::Entry* FindOrCreateEntry(Address code_address) {
|
||||
return impl_.LookupOrInsert(code_address,
|
||||
ComputePointerHash(code_address));
|
||||
}
|
||||
|
||||
HashMap::Entry* FindEntry(Address code_address) {
|
||||
base::HashMap::Entry* FindEntry(Address code_address) {
|
||||
return impl_.Lookup(code_address, ComputePointerHash(code_address));
|
||||
}
|
||||
|
||||
void RemoveEntry(HashMap::Entry* entry) {
|
||||
void RemoveEntry(base::HashMap::Entry* entry) {
|
||||
impl_.Remove(entry->key, entry->hash);
|
||||
}
|
||||
|
||||
HashMap impl_;
|
||||
base::HashMap impl_;
|
||||
|
||||
DISALLOW_COPY_AND_ASSIGN(NameMap);
|
||||
};
|
||||
|
@ -53,10 +53,10 @@ AsmTyper::AsmTyper(Isolate* isolate, Zone* zone, Script* script,
|
||||
stdlib_simd_##name##_types_(zone),
|
||||
SIMD128_TYPES(V)
|
||||
#undef V
|
||||
global_variable_type_(HashMap::PointersMatch,
|
||||
global_variable_type_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
local_variable_type_(HashMap::PointersMatch,
|
||||
local_variable_type_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
in_function_(false),
|
||||
|
@ -833,7 +833,6 @@
|
||||
'handles-inl.h',
|
||||
'handles.cc',
|
||||
'handles.h',
|
||||
'hashmap.h',
|
||||
'heap-symbols.h',
|
||||
'heap/array-buffer-tracker.cc',
|
||||
'heap/array-buffer-tracker.h',
|
||||
@ -1680,6 +1679,7 @@
|
||||
'base/format-macros.h',
|
||||
'base/functional.cc',
|
||||
'base/functional.h',
|
||||
'base/hashmap.h',
|
||||
'base/iterator.h',
|
||||
'base/lazy-instance.h',
|
||||
'base/logging.cc',
|
||||
@ -1959,8 +1959,6 @@
|
||||
'../include',
|
||||
],
|
||||
'sources': [
|
||||
'libsampler/hashmap.h',
|
||||
'libsampler/utils.h',
|
||||
'libsampler/v8-sampler.cc',
|
||||
'libsampler/v8-sampler.h'
|
||||
],
|
||||
|
@ -43,12 +43,13 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
public:
|
||||
AsmWasmBuilderImpl(Isolate* isolate, Zone* zone, FunctionLiteral* literal,
|
||||
AsmTyper* typer)
|
||||
: local_variables_(HashMap::PointersMatch,
|
||||
: local_variables_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
functions_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity,
|
||||
functions_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
global_variables_(HashMap::PointersMatch,
|
||||
global_variables_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
scope_(kModuleScope),
|
||||
@ -64,7 +65,7 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
init_function_index_(0),
|
||||
foreign_init_function_index_(0),
|
||||
next_table_index_(0),
|
||||
function_tables_(HashMap::PointersMatch,
|
||||
function_tables_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(zone)),
|
||||
imported_function_table_(this),
|
||||
@ -695,7 +696,8 @@ class AsmWasmBuilderImpl : public AstVisitor {
|
||||
|
||||
public:
|
||||
explicit ImportedFunctionTable(AsmWasmBuilderImpl* builder)
|
||||
: table_(HashMap::PointersMatch, ZoneHashMap::kDefaultHashMapCapacity,
|
||||
: table_(base::HashMap::PointersMatch,
|
||||
ZoneHashMap::kDefaultHashMapCapacity,
|
||||
ZoneAllocationPolicy(builder->zone())),
|
||||
builder_(builder) {}
|
||||
|
||||
|
@ -7,7 +7,7 @@
|
||||
|
||||
#ifndef V8_SHARED
|
||||
#include "src/allocation.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#else
|
||||
#include "include/v8.h"
|
||||
#include "src/base/compiler-specific.h"
|
||||
|
@ -8,9 +8,9 @@
|
||||
#include <limits>
|
||||
|
||||
#include "src/base/accounting-allocator.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/base/logging.h"
|
||||
#include "src/globals.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/list.h"
|
||||
#include "src/splay-tree.h"
|
||||
|
||||
@ -244,8 +244,7 @@ class ZoneSplayTree final : public SplayTree<Config, ZoneAllocationPolicy> {
|
||||
void operator delete(void* pointer, Zone* zone) { UNREACHABLE(); }
|
||||
};
|
||||
|
||||
|
||||
typedef TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
|
||||
typedef base::TemplateHashMapImpl<ZoneAllocationPolicy> ZoneHashMap;
|
||||
|
||||
} // namespace internal
|
||||
} // namespace v8
|
||||
|
@ -14610,9 +14610,8 @@ TEST(SetFunctionEntryHook) {
|
||||
test.RunTest();
|
||||
}
|
||||
|
||||
|
||||
static i::HashMap* code_map = NULL;
|
||||
static i::HashMap* jitcode_line_info = NULL;
|
||||
static v8::base::HashMap* code_map = NULL;
|
||||
static v8::base::HashMap* jitcode_line_info = NULL;
|
||||
static int saw_bar = 0;
|
||||
static int move_events = 0;
|
||||
|
||||
@ -14672,7 +14671,7 @@ static void event_handler(const v8::JitCodeEvent* event) {
|
||||
CHECK(event->code_start != NULL);
|
||||
CHECK_NE(0, static_cast<int>(event->code_len));
|
||||
CHECK(event->name.str != NULL);
|
||||
i::HashMap::Entry* entry = code_map->LookupOrInsert(
|
||||
v8::base::HashMap::Entry* entry = code_map->LookupOrInsert(
|
||||
event->code_start, i::ComputePointerHash(event->code_start));
|
||||
entry->value = reinterpret_cast<void*>(event->code_len);
|
||||
|
||||
@ -14691,7 +14690,8 @@ static void event_handler(const v8::JitCodeEvent* event) {
|
||||
// Compiler::RecordFunctionCompilation) and the line endings
|
||||
// calculations can cause a GC, which can move the newly created code
|
||||
// before its existence can be logged.
|
||||
i::HashMap::Entry* entry = code_map->Lookup(event->code_start, hash);
|
||||
v8::base::HashMap::Entry* entry =
|
||||
code_map->Lookup(event->code_start, hash);
|
||||
if (entry != NULL) {
|
||||
++move_events;
|
||||
|
||||
@ -14718,7 +14718,7 @@ static void event_handler(const v8::JitCodeEvent* event) {
|
||||
DummyJitCodeLineInfo* line_info = new DummyJitCodeLineInfo();
|
||||
v8::JitCodeEvent* temp_event = const_cast<v8::JitCodeEvent*>(event);
|
||||
temp_event->user_data = line_info;
|
||||
i::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert(
|
||||
v8::base::HashMap::Entry* entry = jitcode_line_info->LookupOrInsert(
|
||||
line_info, i::ComputePointerHash(line_info));
|
||||
entry->value = reinterpret_cast<void*>(line_info);
|
||||
}
|
||||
@ -14729,7 +14729,7 @@ static void event_handler(const v8::JitCodeEvent* event) {
|
||||
case v8::JitCodeEvent::CODE_END_LINE_INFO_RECORDING: {
|
||||
CHECK(event->user_data != NULL);
|
||||
uint32_t hash = i::ComputePointerHash(event->user_data);
|
||||
i::HashMap::Entry* entry =
|
||||
v8::base::HashMap::Entry* entry =
|
||||
jitcode_line_info->Lookup(event->user_data, hash);
|
||||
CHECK(entry != NULL);
|
||||
delete reinterpret_cast<DummyJitCodeLineInfo*>(event->user_data);
|
||||
@ -14739,7 +14739,7 @@ static void event_handler(const v8::JitCodeEvent* event) {
|
||||
case v8::JitCodeEvent::CODE_ADD_LINE_POS_INFO: {
|
||||
CHECK(event->user_data != NULL);
|
||||
uint32_t hash = i::ComputePointerHash(event->user_data);
|
||||
i::HashMap::Entry* entry =
|
||||
v8::base::HashMap::Entry* entry =
|
||||
jitcode_line_info->Lookup(event->user_data, hash);
|
||||
CHECK(entry != NULL);
|
||||
}
|
||||
@ -14781,10 +14781,10 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
|
||||
|
||||
{
|
||||
v8::HandleScope scope(isolate);
|
||||
i::HashMap code(MatchPointers);
|
||||
v8::base::HashMap code(MatchPointers);
|
||||
code_map = &code;
|
||||
|
||||
i::HashMap lineinfo(MatchPointers);
|
||||
v8::base::HashMap lineinfo(MatchPointers);
|
||||
jitcode_line_info = &lineinfo;
|
||||
|
||||
saw_bar = 0;
|
||||
@ -14847,10 +14847,10 @@ UNINITIALIZED_TEST(SetJitCodeEventHandler) {
|
||||
CompileRun(script);
|
||||
|
||||
// Now get code through initial iteration.
|
||||
i::HashMap code(MatchPointers);
|
||||
v8::base::HashMap code(MatchPointers);
|
||||
code_map = &code;
|
||||
|
||||
i::HashMap lineinfo(MatchPointers);
|
||||
v8::base::HashMap lineinfo(MatchPointers);
|
||||
jitcode_line_info = &lineinfo;
|
||||
|
||||
isolate->SetJitCodeEventHandler(v8::kJitCodeEventEnumExisting,
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include "src/v8.h"
|
||||
#include "test/cctest/cctest.h"
|
||||
|
||||
#include "src/hashmap.h"
|
||||
#include "src/base/hashmap.h"
|
||||
|
||||
using namespace v8::internal;
|
||||
|
||||
@ -48,7 +48,7 @@ class IntSet {
|
||||
|
||||
void Insert(int x) {
|
||||
CHECK_NE(0, x); // 0 corresponds to (void*)NULL - illegal key value
|
||||
HashMap::Entry* p =
|
||||
v8::base::HashMap::Entry* p =
|
||||
map_.LookupOrInsert(reinterpret_cast<void*>(x), hash_(x));
|
||||
CHECK(p != NULL); // insert is set!
|
||||
CHECK_EQ(reinterpret_cast<void*>(x), p->key);
|
||||
@ -61,7 +61,8 @@ class IntSet {
|
||||
}
|
||||
|
||||
bool Present(int x) {
|
||||
HashMap::Entry* p = map_.Lookup(reinterpret_cast<void*>(x), hash_(x));
|
||||
v8::base::HashMap::Entry* p =
|
||||
map_.Lookup(reinterpret_cast<void*>(x), hash_(x));
|
||||
if (p != NULL) {
|
||||
CHECK_EQ(reinterpret_cast<void*>(x), p->key);
|
||||
}
|
||||
@ -74,7 +75,8 @@ class IntSet {
|
||||
|
||||
uint32_t occupancy() const {
|
||||
uint32_t count = 0;
|
||||
for (HashMap::Entry* p = map_.Start(); p != NULL; p = map_.Next(p)) {
|
||||
for (v8::base::HashMap::Entry* p = map_.Start(); p != NULL;
|
||||
p = map_.Next(p)) {
|
||||
count++;
|
||||
}
|
||||
CHECK_EQ(map_.occupancy(), static_cast<double>(count));
|
||||
@ -83,7 +85,7 @@ class IntSet {
|
||||
|
||||
private:
|
||||
IntKeyHash hash_;
|
||||
HashMap map_;
|
||||
v8::base::HashMap map_;
|
||||
};
|
||||
|
||||
|
||||
|
@ -32,9 +32,9 @@
|
||||
#include "src/v8.h"
|
||||
|
||||
#include "include/v8-profiler.h"
|
||||
#include "src/base/hashmap.h"
|
||||
#include "src/collector.h"
|
||||
#include "src/debug/debug.h"
|
||||
#include "src/hashmap.h"
|
||||
#include "src/profiler/allocation-tracker.h"
|
||||
#include "src/profiler/heap-profiler.h"
|
||||
#include "src/profiler/heap-snapshot-generator-inl.h"
|
||||
@ -43,7 +43,6 @@
|
||||
using i::AllocationTraceNode;
|
||||
using i::AllocationTraceTree;
|
||||
using i::AllocationTracker;
|
||||
using i::HashMap;
|
||||
using i::ArrayVector;
|
||||
using i::Vector;
|
||||
|
||||
@ -66,7 +65,7 @@ class NamedEntriesDetector {
|
||||
}
|
||||
|
||||
void CheckAllReachables(i::HeapEntry* root) {
|
||||
i::HashMap visited(AddressesMatch);
|
||||
v8::base::HashMap visited(AddressesMatch);
|
||||
i::List<i::HeapEntry*> list(10);
|
||||
list.Add(root);
|
||||
CheckEntry(root);
|
||||
@ -76,7 +75,7 @@ class NamedEntriesDetector {
|
||||
for (int i = 0; i < children.length(); ++i) {
|
||||
if (children[i]->type() == i::HeapGraphEdge::kShortcut) continue;
|
||||
i::HeapEntry* child = children[i]->to();
|
||||
i::HashMap::Entry* entry = visited.LookupOrInsert(
|
||||
v8::base::HashMap::Entry* entry = visited.LookupOrInsert(
|
||||
reinterpret_cast<void*>(child),
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(child)));
|
||||
if (entry->value)
|
||||
@ -144,10 +143,10 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
|
||||
i::HeapSnapshot* heap_snapshot = const_cast<i::HeapSnapshot*>(
|
||||
reinterpret_cast<const i::HeapSnapshot*>(snapshot));
|
||||
|
||||
i::HashMap visited(AddressesMatch);
|
||||
v8::base::HashMap visited(AddressesMatch);
|
||||
i::List<i::HeapGraphEdge>& edges = heap_snapshot->edges();
|
||||
for (int i = 0; i < edges.length(); ++i) {
|
||||
i::HashMap::Entry* entry = visited.LookupOrInsert(
|
||||
v8::base::HashMap::Entry* entry = visited.LookupOrInsert(
|
||||
reinterpret_cast<void*>(edges[i].to()),
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(edges[i].to())));
|
||||
uint32_t ref_count = static_cast<uint32_t>(
|
||||
@ -157,7 +156,7 @@ static bool ValidateSnapshot(const v8::HeapSnapshot* snapshot, int depth = 3) {
|
||||
uint32_t unretained_entries_count = 0;
|
||||
i::List<i::HeapEntry>& entries = heap_snapshot->entries();
|
||||
for (int i = 0; i < entries.length(); ++i) {
|
||||
i::HashMap::Entry* entry = visited.Lookup(
|
||||
v8::base::HashMap::Entry* entry = visited.Lookup(
|
||||
reinterpret_cast<void*>(&entries[i]),
|
||||
static_cast<uint32_t>(reinterpret_cast<uintptr_t>(&entries[i])));
|
||||
if (!entry && entries[i].id() != 1) {
|
||||
|
Loading…
Reference in New Issue
Block a user