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

Unified Diff: runtime/vm/precompiler.h

Issue 1387613003: Dedup stackmaps. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 2 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
Index: runtime/vm/precompiler.h
diff --git a/runtime/vm/precompiler.h b/runtime/vm/precompiler.h
index 3106984a178f95d30e37ea31d9c4b0a78deaf43b..e0e008bddbf4ce063ad0e41bdd820b6fa6df62b0 100644
--- a/runtime/vm/precompiler.h
+++ b/runtime/vm/precompiler.h
@@ -24,17 +24,18 @@ class SymbolPair {
public:
// Typedefs needed for the DirectChainedHashMap template.
typedef const String* Key;
- typedef bool Value;
+ typedef const String* Value;
typedef SymbolPair Pair;
- SymbolPair() : key_(NULL), value_(false) {}
- SymbolPair(Key key, Value value) : key_(key), value_(value) {
+ SymbolPair() : key_(NULL) {}
+ SymbolPair(Key key, Value value) : key_(key) {
ASSERT(key->IsNotTemporaryScopedHandle());
+ ASSERT(key == value);
}
static Key KeyOf(Pair kv) { return kv.key_; }
- static Value ValueOf(Pair kv) { return kv.value_; }
+ static Value ValueOf(Pair kv) { return kv.key_; }
static inline intptr_t Hashcode(Key key) {
return key->Hash();
@@ -46,7 +47,6 @@ class SymbolPair {
private:
Key key_;
Florian Schneider 2015/10/07 10:40:07 No need for key_ either. This is basicaly the sam
rmacnak 2015/10/07 22:19:06 Oh, I misunderstood this to be used as the backing
- Value value_;
};
@@ -57,17 +57,18 @@ class SymbolSet : public ValueObject {
void Add(const String& symbol) {
ASSERT(symbol.IsSymbol());
if (symbol.IsNotTemporaryScopedHandle()) {
- SymbolPair pair(&symbol, true);
+ SymbolPair pair(&symbol, &symbol);
map_.Insert(pair);
} else {
- SymbolPair pair(&String::ZoneHandle(zone_, symbol.raw()), true);
+ const String* zone_symbol = &String::ZoneHandle(zone_, symbol.raw());
+ SymbolPair pair(zone_symbol, zone_symbol);
map_.Insert(pair);
}
}
bool Includes(const String& symbol) {
ASSERT(symbol.IsSymbol());
- return map_.Lookup(&symbol);
+ return map_.Lookup(&symbol) != NULL;
}
private:
@@ -76,6 +77,55 @@ class SymbolSet : public ValueObject {
};
+class StackmapPair {
+ public:
+ // Typedefs needed for the DirectChainedHashMap template.
+ typedef const Stackmap* Key;
+ typedef const Stackmap* Value;
+ typedef StackmapPair Pair;
+
+ StackmapPair() : key_(NULL) {}
+ StackmapPair(Key key, Value value) : key_(key) {
+ ASSERT(key->IsNotTemporaryScopedHandle());
+ ASSERT(key == value);
+ }
+
+ static Key KeyOf(Pair kv) { return kv.key_; }
+
+ static Value ValueOf(Pair kv) { return kv.key_; }
+
+ static inline intptr_t Hashcode(Key key) {
Florian Schneider 2015/10/07 10:40:07 Can you avoid this class and use PointerKeyValueTr
rmacnak 2015/10/07 22:19:06 Not quite. It wants Stackmap::Equals(Stackmap*&) i
+ return key->PcOffset();
+ }
+
+ static inline bool IsKeyEqual(Pair pair, Key key) {
+ return pair.key_->Equals(*key);
+ }
+
+ private:
+ Key key_;
+};
+
+
+class StackmapSet : public ValueObject {
Florian Schneider 2015/10/07 10:40:07 typedef DirectChainedHashmap<PointerKeyValueTrait<
rmacnak 2015/10/07 22:19:06 Dropped StackmapSet and SymbolsSet for typedefs.
+ public:
+ explicit StackmapSet(Zone* zone) : zone_(zone), map_() {}
+
+ void Add(const Stackmap& stackmap) {
+ StackmapPair pair(&stackmap, &stackmap);
+ map_.Insert(pair);
+ }
+
+ const Stackmap* Lookup(const Stackmap& stackmap) {
+ return map_.Lookup(&stackmap);
+ }
+
+ private:
+ Zone* zone_;
+ DirectChainedHashMap<StackmapPair> map_;
+};
+
+
class Precompiler : public ValueObject {
public:
static RawError* CompileAll(
@@ -106,6 +156,9 @@ class Precompiler : public ValueObject {
void DropUncompiledFunctions();
void BindStaticCalls();
void BindStaticCalls(const Function& function);
+ void DedupStackmaps();
+ void DedupStackmaps(const Function& function);
+ RawStackmap* DedupStackmap(const Stackmap& stackmap);
Thread* thread() const { return thread_; }
Zone* zone() const { return zone_; }
@@ -127,6 +180,7 @@ class Precompiler : public ValueObject {
const GrowableObjectArray& pending_functions_;
const GrowableObjectArray& collected_closures_;
SymbolSet sent_selectors_;
+ StackmapSet stackmaps_;
Error& error_;
};
« no previous file with comments | « runtime/vm/object.h ('k') | runtime/vm/precompiler.cc » ('j') | runtime/vm/precompiler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698