Commit d622ff90 authored by Dan Elphick's avatar Dan Elphick Committed by Commit Bot

[explicit isolates] Remove GetIsolate from HashTable/HashSets

Bug: v8:7786
Change-Id: If9615f5dffc40937f9f35a209730d530be6b424b
Reviewed-on: https://chromium-review.googlesource.com/1134986Reviewed-by: 's avatarLeszek Swirski <leszeks@chromium.org>
Reviewed-by: 's avatarPeter Marshall <petermarshall@chromium.org>
Commit-Queue: Dan Elphick <delphick@chromium.org>
Cr-Commit-Position: refs/heads/master@{#54407}
parent dad67377
...@@ -341,7 +341,7 @@ void UncacheTemplateInstantiation(Isolate* isolate, int serial_number, ...@@ -341,7 +341,7 @@ void UncacheTemplateInstantiation(Isolate* isolate, int serial_number,
isolate->slow_template_instantiations_cache(); isolate->slow_template_instantiations_cache();
int entry = cache->FindEntry(serial_number); int entry = cache->FindEntry(serial_number);
DCHECK_NE(SimpleNumberDictionary::kNotFound, entry); DCHECK_NE(SimpleNumberDictionary::kNotFound, entry);
cache = SimpleNumberDictionary::DeleteEntry(cache, entry); cache = SimpleNumberDictionary::DeleteEntry(isolate, cache, entry);
isolate->native_context()->set_slow_template_instantiations_cache(*cache); isolate->native_context()->set_slow_template_instantiations_cache(*cache);
} }
} }
......
...@@ -98,7 +98,7 @@ void CodeStub::DeleteStubFromCacheForTesting() { ...@@ -98,7 +98,7 @@ void CodeStub::DeleteStubFromCacheForTesting() {
Handle<SimpleNumberDictionary> dict(heap->code_stubs(), isolate()); Handle<SimpleNumberDictionary> dict(heap->code_stubs(), isolate());
int entry = dict->FindEntry(GetKey()); int entry = dict->FindEntry(GetKey());
DCHECK_NE(SimpleNumberDictionary::kNotFound, entry); DCHECK_NE(SimpleNumberDictionary::kNotFound, entry);
dict = SimpleNumberDictionary::DeleteEntry(dict, entry); dict = SimpleNumberDictionary::DeleteEntry(isolate(), dict, entry);
heap->SetRootCodeStubs(*dict); heap->SetRootCodeStubs(*dict);
} }
......
...@@ -248,7 +248,8 @@ void CompilationCacheRegExp::Put(Handle<String> source, ...@@ -248,7 +248,8 @@ void CompilationCacheRegExp::Put(Handle<String> source,
Handle<FixedArray> data) { Handle<FixedArray> data) {
HandleScope scope(isolate()); HandleScope scope(isolate());
Handle<CompilationCacheTable> table = GetFirstTable(); Handle<CompilationCacheTable> table = GetFirstTable();
SetFirstTable(CompilationCacheTable::PutRegExp(table, source, flags, data)); SetFirstTable(
CompilationCacheTable::PutRegExp(isolate(), table, source, flags, data));
} }
void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) { void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) {
......
...@@ -1520,7 +1520,7 @@ class DictionaryElementsAccessor ...@@ -1520,7 +1520,7 @@ class DictionaryElementsAccessor
static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) { static void DeleteImpl(Handle<JSObject> obj, uint32_t entry) {
Handle<NumberDictionary> dict(NumberDictionary::cast(obj->elements()), Handle<NumberDictionary> dict(NumberDictionary::cast(obj->elements()),
obj->GetIsolate()); obj->GetIsolate());
dict = NumberDictionary::DeleteEntry(dict, entry); dict = NumberDictionary::DeleteEntry(obj->GetIsolate(), dict, entry);
obj->set_elements(*dict); obj->set_elements(*dict);
} }
...@@ -4000,7 +4000,7 @@ class SlowSloppyArgumentsElementsAccessor ...@@ -4000,7 +4000,7 @@ class SlowSloppyArgumentsElementsAccessor
Handle<NumberDictionary> dict(NumberDictionary::cast(elements->arguments()), Handle<NumberDictionary> dict(NumberDictionary::cast(elements->arguments()),
isolate); isolate);
int length = elements->parameter_map_length(); int length = elements->parameter_map_length();
dict = NumberDictionary::DeleteEntry(dict, entry - length); dict = NumberDictionary::DeleteEntry(isolate, dict, entry - length);
elements->set_arguments(*dict); elements->set_arguments(*dict);
} }
static void AddImpl(Handle<JSObject> object, uint32_t index, static void AddImpl(Handle<JSObject> object, uint32_t index,
......
...@@ -216,7 +216,7 @@ void KeyAccumulator::AddShadowingKey(Handle<Object> key) { ...@@ -216,7 +216,7 @@ void KeyAccumulator::AddShadowingKey(Handle<Object> key) {
if (shadowing_keys_.is_null()) { if (shadowing_keys_.is_null()) {
shadowing_keys_ = ObjectHashSet::New(isolate_, 16); shadowing_keys_ = ObjectHashSet::New(isolate_, 16);
} }
shadowing_keys_ = ObjectHashSet::Add(shadowing_keys_, key); shadowing_keys_ = ObjectHashSet::Add(isolate(), shadowing_keys_, key);
} }
namespace { namespace {
......
This diff is collapsed.
...@@ -1649,7 +1649,7 @@ class HeapObject: public Object { ...@@ -1649,7 +1649,7 @@ class HeapObject: public Object {
bool CanBeRehashed() const; bool CanBeRehashed() const;
// Rehash the object based on the layout inferred from its map. // Rehash the object based on the layout inferred from its map.
void RehashBasedOnMap(); void RehashBasedOnMap(Isolate* isolate);
// Layout description. // Layout description.
// First field in a heap object is map. // First field in a heap object is map.
......
...@@ -93,7 +93,7 @@ class CompilationCacheTable ...@@ -93,7 +93,7 @@ class CompilationCacheTable
Handle<Context> native_context, Handle<FeedbackCell> feedback_cell, Handle<Context> native_context, Handle<FeedbackCell> feedback_cell,
int position); int position);
static Handle<CompilationCacheTable> PutRegExp( static Handle<CompilationCacheTable> PutRegExp(
Handle<CompilationCacheTable> cache, Handle<String> src, Isolate* isolate, Handle<CompilationCacheTable> cache, Handle<String> src,
JSRegExp::Flags flags, Handle<FixedArray> value); JSRegExp::Flags flags, Handle<FixedArray> value);
void Remove(Object* value); void Remove(Object* value);
void Age(); void Age();
......
...@@ -49,12 +49,12 @@ class Dictionary : public HashTable<Derived, Shape> { ...@@ -49,12 +49,12 @@ class Dictionary : public HashTable<Derived, Shape> {
// Delete a property from the dictionary. // Delete a property from the dictionary.
V8_WARN_UNUSED_RESULT static Handle<Derived> DeleteEntry( V8_WARN_UNUSED_RESULT static Handle<Derived> DeleteEntry(
Handle<Derived> dictionary, int entry); Isolate* isolate, Handle<Derived> dictionary, int entry);
// Attempt to shrink the dictionary after deletion of key. // Attempt to shrink the dictionary after deletion of key.
V8_WARN_UNUSED_RESULT static inline Handle<Derived> Shrink( V8_WARN_UNUSED_RESULT static inline Handle<Derived> Shrink(
Handle<Derived> dictionary) { Isolate* isolate, Handle<Derived> dictionary) {
return DerivedHashTable::Shrink(dictionary); return DerivedHashTable::Shrink(isolate, dictionary);
} }
int NumberOfEnumerableProperties(); int NumberOfEnumerableProperties();
...@@ -174,7 +174,8 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> { ...@@ -174,7 +174,8 @@ class BaseNameDictionary : public Dictionary<Derived, Shape> {
KeyAccumulator* accumulator); KeyAccumulator* accumulator);
// Ensure enough space for n additional elements. // Ensure enough space for n additional elements.
static Handle<Derived> EnsureCapacity(Handle<Derived> dictionary, int n); static Handle<Derived> EnsureCapacity(Isolate* isolate,
Handle<Derived> dictionary, int n);
V8_WARN_UNUSED_RESULT static Handle<Derived> AddNoUpdateNextEnumerationIndex( V8_WARN_UNUSED_RESULT static Handle<Derived> AddNoUpdateNextEnumerationIndex(
Handle<Derived> dictionary, Key key, Handle<Object> value, Handle<Derived> dictionary, Key key, Handle<Object> value,
......
...@@ -149,7 +149,7 @@ class HashTable : public HashTableBase { ...@@ -149,7 +149,7 @@ class HashTable : public HashTableBase {
int FindEntry(Isolate* isolate, Key key); int FindEntry(Isolate* isolate, Key key);
// Rehashes the table in-place. // Rehashes the table in-place.
void Rehash(); void Rehash(Isolate* isolate);
// Tells whether k is a real key. The hole and undefined are not allowed // Tells whether k is a real key. The hole and undefined are not allowed
// as keys and can be used to indicate missing or deleted elements. // as keys and can be used to indicate missing or deleted elements.
...@@ -185,7 +185,8 @@ class HashTable : public HashTableBase { ...@@ -185,7 +185,8 @@ class HashTable : public HashTableBase {
// Ensure enough space for n additional elements. // Ensure enough space for n additional elements.
V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity( V8_WARN_UNUSED_RESULT static Handle<Derived> EnsureCapacity(
Handle<Derived> table, int n, PretenureFlag pretenure = NOT_TENURED); Isolate* isolate, Handle<Derived> table, int n,
PretenureFlag pretenure = NOT_TENURED);
// Returns true if this table has sufficient capacity for adding n elements. // Returns true if this table has sufficient capacity for adding n elements.
bool HasSufficientCapacityToAdd(int number_of_additional_elements); bool HasSufficientCapacityToAdd(int number_of_additional_elements);
...@@ -202,7 +203,7 @@ class HashTable : public HashTableBase { ...@@ -202,7 +203,7 @@ class HashTable : public HashTableBase {
// Attempt to shrink hash table after removal of key. // Attempt to shrink hash table after removal of key.
V8_WARN_UNUSED_RESULT static Handle<Derived> Shrink( V8_WARN_UNUSED_RESULT static Handle<Derived> Shrink(
Handle<Derived> table, int additionalCapacity = 0); Isolate* isolate, Handle<Derived> table, int additionalCapacity = 0);
private: private:
// Ensure that kMaxRegularCapacity yields a non-large object dictionary. // Ensure that kMaxRegularCapacity yields a non-large object dictionary.
...@@ -226,12 +227,13 @@ class HashTable : public HashTableBase { ...@@ -226,12 +227,13 @@ class HashTable : public HashTableBase {
// Returns _expected_ if one of entries given by the first _probe_ probes is // Returns _expected_ if one of entries given by the first _probe_ probes is
// equal to _expected_. Otherwise, returns the entry given by the probe // equal to _expected_. Otherwise, returns the entry given by the probe
// number _probe_. // number _probe_.
uint32_t EntryForProbe(Object* k, int probe, uint32_t expected); uint32_t EntryForProbe(Isolate* isolate, Object* k, int probe,
uint32_t expected);
void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode); void Swap(uint32_t entry1, uint32_t entry2, WriteBarrierMode mode);
// Rehashes this hash-table into the new table. // Rehashes this hash-table into the new table.
void Rehash(Derived* new_table); void Rehash(Isolate* isolate, Derived* new_table);
}; };
// HashTableKey is an abstract superclass for virtual key behavior. // HashTableKey is an abstract superclass for virtual key behavior.
...@@ -287,14 +289,16 @@ class ObjectHashTableBase : public HashTable<Derived, Shape> { ...@@ -287,14 +289,16 @@ class ObjectHashTableBase : public HashTable<Derived, Shape> {
// Adds (or overwrites) the value associated with the given key. // Adds (or overwrites) the value associated with the given key.
static Handle<Derived> Put(Handle<Derived> table, Handle<Object> key, static Handle<Derived> Put(Handle<Derived> table, Handle<Object> key,
Handle<Object> value); Handle<Object> value);
static Handle<Derived> Put(Handle<Derived> table, Handle<Object> key, static Handle<Derived> Put(Isolate* isolate, Handle<Derived> table,
Handle<Object> value, int32_t hash); Handle<Object> key, Handle<Object> value,
int32_t hash);
// Returns an ObjectHashTable (possibly |table|) where |key| has been removed. // Returns an ObjectHashTable (possibly |table|) where |key| has been removed.
static Handle<Derived> Remove(Handle<Derived> table, Handle<Object> key, static Handle<Derived> Remove(Isolate* isolate, Handle<Derived> table,
bool* was_present); Handle<Object> key, bool* was_present);
static Handle<Derived> Remove(Handle<Derived> table, Handle<Object> key, static Handle<Derived> Remove(Isolate* isolate, Handle<Derived> table,
bool* was_present, int32_t hash); Handle<Object> key, bool* was_present,
int32_t hash);
// Returns the index to the value of an entry. // Returns the index to the value of an entry.
static inline int EntryToValueIndex(int entry) { static inline int EntryToValueIndex(int entry) {
...@@ -343,7 +347,7 @@ class ObjectHashSetShape : public ObjectHashTableShape { ...@@ -343,7 +347,7 @@ class ObjectHashSetShape : public ObjectHashTableShape {
class ObjectHashSet : public HashTable<ObjectHashSet, ObjectHashSetShape> { class ObjectHashSet : public HashTable<ObjectHashSet, ObjectHashSetShape> {
public: public:
static Handle<ObjectHashSet> Add(Handle<ObjectHashSet> set, static Handle<ObjectHashSet> Add(Isolate* isolate, Handle<ObjectHashSet> set,
Handle<Object> key); Handle<Object> key);
inline bool Has(Isolate* isolate, Handle<Object> key, int32_t hash); inline bool Has(Isolate* isolate, Handle<Object> key, int32_t hash);
......
...@@ -67,7 +67,8 @@ class StringTable : public HashTable<StringTable, StringTableShape> { ...@@ -67,7 +67,8 @@ class StringTable : public HashTable<StringTable, StringTableShape> {
// Shink the StringTable if it's very empty (kMaxEmptyFactor) to avoid the // Shink the StringTable if it's very empty (kMaxEmptyFactor) to avoid the
// performance overhead of re-allocating the StringTable over and over again. // performance overhead of re-allocating the StringTable over and over again.
static Handle<StringTable> CautiousShrink(Handle<StringTable> table); static Handle<StringTable> CautiousShrink(Isolate* isolate,
Handle<StringTable> table);
// Looks up a string that is equal to the given string and returns // Looks up a string that is equal to the given string and returns
// string handle if it is found, or an empty handle otherwise. // string handle if it is found, or an empty handle otherwise.
......
...@@ -688,7 +688,8 @@ RUNTIME_FUNCTION(Runtime_ShrinkPropertyDictionary) { ...@@ -688,7 +688,8 @@ RUNTIME_FUNCTION(Runtime_ShrinkPropertyDictionary) {
DCHECK_EQ(1, args.length()); DCHECK_EQ(1, args.length());
CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0); CONVERT_ARG_HANDLE_CHECKED(JSReceiver, receiver, 0);
Handle<NameDictionary> dictionary(receiver->property_dictionary(), isolate); Handle<NameDictionary> dictionary(receiver->property_dictionary(), isolate);
Handle<NameDictionary> new_properties = NameDictionary::Shrink(dictionary); Handle<NameDictionary> new_properties =
NameDictionary::Shrink(isolate, dictionary);
receiver->SetProperties(*new_properties); receiver->SetProperties(*new_properties);
return Smi::kZero; return Smi::kZero;
} }
......
...@@ -45,7 +45,7 @@ bool Deserializer<AllocatorT>::IsLazyDeserializationEnabled() const { ...@@ -45,7 +45,7 @@ bool Deserializer<AllocatorT>::IsLazyDeserializationEnabled() const {
template <class AllocatorT> template <class AllocatorT>
void Deserializer<AllocatorT>::Rehash() { void Deserializer<AllocatorT>::Rehash() {
DCHECK(can_rehash() || deserializing_user_code()); DCHECK(can_rehash() || deserializing_user_code());
for (const auto& item : to_rehash_) item->RehashBasedOnMap(); for (const auto& item : to_rehash_) item->RehashBasedOnMap(isolate());
} }
template <class AllocatorT> template <class AllocatorT>
......
...@@ -73,7 +73,7 @@ static void TestHashMap(Handle<HashMap> table) { ...@@ -73,7 +73,7 @@ static void TestHashMap(Handle<HashMap> table) {
// Keys that have been removed are mapped to the hole. // Keys that have been removed are mapped to the hole.
bool was_present = false; bool was_present = false;
table = HashMap::Remove(table, a, &was_present); table = HashMap::Remove(isolate, table, a, &was_present);
CHECK(was_present); CHECK(was_present);
CHECK_EQ(0, table->NumberOfElements()); CHECK_EQ(0, table->NumberOfElements());
CHECK_EQ(table->Lookup(a), roots.the_hole_value()); CHECK_EQ(table->Lookup(a), roots.the_hole_value());
...@@ -125,7 +125,7 @@ static void TestHashSet(Handle<HashSet> table) { ...@@ -125,7 +125,7 @@ static void TestHashSet(Handle<HashSet> table) {
Handle<JSObject> a = factory->NewJSArray(7); Handle<JSObject> a = factory->NewJSArray(7);
Handle<JSObject> b = factory->NewJSArray(11); Handle<JSObject> b = factory->NewJSArray(11);
table = HashSet::Add(table, a); table = HashSet::Add(isolate, table, a);
CHECK_EQ(1, table->NumberOfElements()); CHECK_EQ(1, table->NumberOfElements());
CHECK(table->Has(isolate, a)); CHECK(table->Has(isolate, a));
CHECK(!table->Has(isolate, b)); CHECK(!table->Has(isolate, b));
...@@ -137,7 +137,7 @@ static void TestHashSet(Handle<HashSet> table) { ...@@ -137,7 +137,7 @@ static void TestHashSet(Handle<HashSet> table) {
CHECK(!table->Has(isolate, b)); CHECK(!table->Has(isolate, b));
// Keys that are overwritten should not change number of elements. // Keys that are overwritten should not change number of elements.
table = HashSet::Add(table, a); table = HashSet::Add(isolate, table, a);
CHECK_EQ(1, table->NumberOfElements()); CHECK_EQ(1, table->NumberOfElements());
CHECK(table->Has(isolate, a)); CHECK(table->Has(isolate, a));
CHECK(!table->Has(isolate, b)); CHECK(!table->Has(isolate, b));
...@@ -155,7 +155,7 @@ static void TestHashSet(Handle<HashSet> table) { ...@@ -155,7 +155,7 @@ static void TestHashSet(Handle<HashSet> table) {
// an identity hash code generated. // an identity hash code generated.
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
Handle<JSReceiver> key = factory->NewJSArray(7); Handle<JSReceiver> key = factory->NewJSArray(7);
table = HashSet::Add(table, key); table = HashSet::Add(isolate, table, key);
CHECK_EQ(table->NumberOfElements(), i + 2); CHECK_EQ(table->NumberOfElements(), i + 2);
CHECK(table->Has(isolate, key)); CHECK(table->Has(isolate, key));
CHECK(key->GetIdentityHash(isolate)->IsSmi()); CHECK(key->GetIdentityHash(isolate)->IsSmi());
...@@ -217,7 +217,7 @@ TEST(HashTableRehash) { ...@@ -217,7 +217,7 @@ TEST(HashTableRehash) {
for (int i = 0; i < capacity - 1; i++) { for (int i = 0; i < capacity - 1; i++) {
t->insert(i, i * i, i); t->insert(i, i * i, i);
} }
t->Rehash(); t->Rehash(isolate);
for (int i = 0; i < capacity - 1; i++) { for (int i = 0; i < capacity - 1; i++) {
CHECK_EQ(i, t->lookup(i * i)); CHECK_EQ(i, t->lookup(i * i));
} }
...@@ -230,7 +230,7 @@ TEST(HashTableRehash) { ...@@ -230,7 +230,7 @@ TEST(HashTableRehash) {
for (int i = 0; i < capacity / 2; i++) { for (int i = 0; i < capacity / 2; i++) {
t->insert(i, i * i, i); t->insert(i, i * i, i);
} }
t->Rehash(); t->Rehash(isolate);
for (int i = 0; i < capacity / 2; i++) { for (int i = 0; i < capacity / 2; i++) {
CHECK_EQ(i, t->lookup(i * i)); CHECK_EQ(i, t->lookup(i * i));
} }
......
...@@ -143,11 +143,11 @@ TEST_F(ObjectWithIsolate, DictionaryGrowth) { ...@@ -143,11 +143,11 @@ TEST_F(ObjectWithIsolate, DictionaryGrowth) {
// If we grow by larger chunks, the next (sufficiently big) power of 2 is // If we grow by larger chunks, the next (sufficiently big) power of 2 is
// chosen as the capacity. // chosen as the capacity.
dict = NumberDictionary::New(isolate(), 1); dict = NumberDictionary::New(isolate(), 1);
dict = NumberDictionary::EnsureCapacity(dict, 65); dict = NumberDictionary::EnsureCapacity(isolate(), dict, 65);
CHECK_EQ(128, dict->Capacity()); CHECK_EQ(128, dict->Capacity());
dict = NumberDictionary::New(isolate(), 1); dict = NumberDictionary::New(isolate(), 1);
dict = NumberDictionary::EnsureCapacity(dict, 30); dict = NumberDictionary::EnsureCapacity(isolate(), dict, 30);
CHECK_EQ(64, dict->Capacity()); CHECK_EQ(64, dict->Capacity());
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment