Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(160)

Unified Diff: src/objects.h

Issue 1952093002: fix Set::AsArray to not leave undefined holes in output array (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects.h
diff --git a/src/objects.h b/src/objects.h
index 45748500939bbd7ee82cdec3b3bb621dcd5c6303..8ec6236c5cd251333b66400cbec36ba5616073ee 100644
--- a/src/objects.h
+++ b/src/objects.h
@@ -3879,7 +3879,7 @@ class OrderedHashTable: public FixedArray {
static Handle<Derived> Shrink(Handle<Derived> table);
// Returns a new empty OrderedHashTable and records the clearing so that
- // exisiting iterators can be updated.
+ // existing iterators can be updated.
static Handle<Derived> Clear(Handle<Derived> table);
// Returns a true if the OrderedHashTable contains the key
@@ -3893,6 +3893,8 @@ class OrderedHashTable: public FixedArray {
return Smi::cast(get(kNumberOfDeletedElementsIndex))->value();
}
+ // Returns the number of contiguous entries in the data table, starting at 0,
+ // that either are real entries or have been deleted.
int UsedCapacity() { return NumberOfElements() + NumberOfDeletedElements(); }
int NumberOfBuckets() {
@@ -3924,7 +3926,11 @@ class OrderedHashTable: public FixedArray {
return Smi::cast(next_entry)->value();
}
- Object* KeyAt(int entry) { return get(EntryToIndex(entry)); }
+ // use KeyAt(i)->IsTheHole() to determine if this is a deleted entry.
+ Object* KeyAt(int entry) {
+ DCHECK_LT(entry, this->UsedCapacity());
+ return get(EntryToIndex(entry));
+ }
bool IsObsolete() {
return !get(kNextTableIndex)->IsSmi();
@@ -3985,6 +3991,7 @@ class OrderedHashTable: public FixedArray {
set(kNumberOfDeletedElementsIndex, Smi::FromInt(num));
}
+ // Returns the number elements that can fit into the allocated buffer.
int Capacity() {
return NumberOfBuckets() * kLoadFactor;
}
« no previous file with comments | « src/api.cc ('k') | test/cctest/test-api.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698