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

Unified Diff: src/base/hashmap.h

Issue 2522223002: Fix zone in which temp-zone parsed data is allocated for the function scope on the boundary. (Closed)
Patch Set: Also free map_ Created 4 years, 1 month 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/ast/scopes.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/base/hashmap.h
diff --git a/src/base/hashmap.h b/src/base/hashmap.h
index d2fc1337a646e77cd833bce3c6881aeb59e25f01..e643b2f2acb17bd8c2821f4f84513101222ef9c8 100644
--- a/src/base/hashmap.h
+++ b/src/base/hashmap.h
@@ -70,6 +70,14 @@ class TemplateHashMapImpl {
// Empties the hash map (occupancy() == 0).
void Clear();
+ // Empties the map and makes it unusable for allocation.
+ void Invalidate() {
+ AllocationPolicy::Delete(map_);
+ map_ = nullptr;
+ occupancy_ = 0;
+ capacity_ = 0;
+ }
+
// The number of (non-empty) entries in the table.
uint32_t occupancy() const { return occupancy_; }
@@ -89,6 +97,14 @@ class TemplateHashMapImpl {
Entry* Start() const;
Entry* Next(Entry* entry) const;
+ void Reset(AllocationPolicy allocator) {
+ Initialize(capacity_, allocator);
+ occupancy_ = 0;
+ }
+
+ protected:
+ void Initialize(uint32_t capacity, AllocationPolicy allocator);
+
private:
Entry* map_;
uint32_t capacity_;
@@ -102,7 +118,6 @@ class TemplateHashMapImpl {
Entry* FillEmptyEntry(Entry* entry, const Key& key, const Value& value,
uint32_t hash,
AllocationPolicy allocator = AllocationPolicy());
- void Initialize(uint32_t capacity, AllocationPolicy allocator);
void Resize(AllocationPolicy allocator);
};
template <typename Key, typename Value, typename MatchFun,
« no previous file with comments | « src/ast/scopes.cc ('k') | src/parsing/parser.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698