Commit 85b95a03 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[printing] Fix printing the GlobalObject

Due to the dictionary refactoring we ended up calling the superclass' helper
which in turn made us decode the values wrongly for the GlobalDictionary.

Change-Id: I4298b6a437ef2d84b69b7e980470c3cf5af79944
Reviewed-on: https://chromium-review.googlesource.com/561701Reviewed-by: 's avatarIgor Sheludko <ishell@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#46449}
parent 4aebf129
...@@ -15700,21 +15700,23 @@ int JSObject::GetFastElementsUsage() { ...@@ -15700,21 +15700,23 @@ int JSObject::GetFastElementsUsage() {
// we keep it here instead to satisfy certain compilers. // we keep it here instead to satisfy certain compilers.
#ifdef OBJECT_PRINT #ifdef OBJECT_PRINT
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
void Dictionary<Derived, Shape>::Print(std::ostream& os) { // NOLINT void Dictionary<Derived, Shape>::Print(std::ostream& os) {
DisallowHeapAllocation no_gc;
Isolate* isolate = this->GetIsolate(); Isolate* isolate = this->GetIsolate();
int capacity = this->Capacity(); Derived* dictionary = Derived::cast(this);
int capacity = dictionary->Capacity();
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
Object* k = this->KeyAt(i); Object* k = dictionary->KeyAt(i);
if (Shape::IsLive(isolate, k)) { if (!Shape::IsLive(isolate, k)) continue;
os << "\n "; if (!dictionary->ToKey(isolate, i, &k)) continue;
if (k->IsString()) { os << "\n ";
String::cast(k)->StringPrint(os); if (k->IsString()) {
} else { String::cast(k)->StringPrint(os);
os << Brief(k); } else {
} os << Brief(k);
os << ": " << Brief(this->ValueAt(i)) << " ";
this->DetailsAt(i).PrintAsSlowTo(os);
} }
os << ": " << Brief(dictionary->ValueAt(i)) << " ";
dictionary->DetailsAt(i).PrintAsSlowTo(os);
} }
} }
template <typename Derived, typename Shape> template <typename Derived, typename Shape>
...@@ -16225,13 +16227,12 @@ void HashTable<Derived, Shape>::Rehash(Derived* new_table) { ...@@ -16225,13 +16227,12 @@ void HashTable<Derived, Shape>::Rehash(Derived* new_table) {
for (int i = 0; i < capacity; i++) { for (int i = 0; i < capacity; i++) {
uint32_t from_index = EntryToIndex(i); uint32_t from_index = EntryToIndex(i);
Object* k = this->get(from_index); Object* k = this->get(from_index);
if (Shape::IsLive(isolate, k)) { if (!Shape::IsLive(isolate, k)) continue;
uint32_t hash = Shape::HashForObject(isolate, k); uint32_t hash = Shape::HashForObject(isolate, k);
uint32_t insertion_index = uint32_t insertion_index =
EntryToIndex(new_table->FindInsertionEntry(hash)); EntryToIndex(new_table->FindInsertionEntry(hash));
for (int j = 0; j < Shape::kEntrySize; j++) { for (int j = 0; j < Shape::kEntrySize; j++) {
new_table->set(insertion_index + j, get(from_index + j), mode); new_table->set(insertion_index + j, get(from_index + j), mode);
}
} }
} }
new_table->SetNumberOfElements(NumberOfElements()); new_table->SetNumberOfElements(NumberOfElements());
...@@ -16281,21 +16282,20 @@ void HashTable<Derived, Shape>::Rehash() { ...@@ -16281,21 +16282,20 @@ void HashTable<Derived, Shape>::Rehash() {
done = true; done = true;
for (uint32_t current = 0; current < capacity; current++) { for (uint32_t current = 0; current < capacity; current++) {
Object* current_key = KeyAt(current); Object* current_key = KeyAt(current);
if (Shape::IsLive(isolate, current_key)) { if (!Shape::IsLive(isolate, current_key)) continue;
uint32_t target = EntryForProbe(current_key, probe, current); uint32_t target = EntryForProbe(current_key, probe, current);
if (current == target) continue; if (current == target) continue;
Object* target_key = KeyAt(target); Object* target_key = KeyAt(target);
if (!Shape::IsLive(isolate, target_key) || if (!Shape::IsLive(isolate, target_key) ||
EntryForProbe(target_key, probe, target) != target) { EntryForProbe(target_key, probe, target) != target) {
// Put the current element into the correct position. // Put the current element into the correct position.
Swap(current, target, mode); Swap(current, target, mode);
// The other element will be processed on the next iteration. // The other element will be processed on the next iteration.
current--; current--;
} else { } else {
// The place for the current element is occupied. Leave the element // The place for the current element is occupied. Leave the element
// for the next probe. // for the next probe.
done = false; done = false;
}
} }
} }
} }
......
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