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

Unified Diff: runtime/vm/precompiler.h

Issue 1275653002: Tree-shaking: use a hash set for tracking live selectors, drop uncompiled functions. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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 | « runtime/vm/hash_map.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/precompiler.h
diff --git a/runtime/vm/precompiler.h b/runtime/vm/precompiler.h
index 158a8ba88803215eb9bcf4805595f048ebb51d98..1d98aeb99a1a9951d3f9bea5abf42644a88c8f10 100644
--- a/runtime/vm/precompiler.h
+++ b/runtime/vm/precompiler.h
@@ -6,6 +6,8 @@
#define VM_PRECOMPILER_H_
#include "vm/allocation.h"
+#include "vm/hash_map.h"
+#include "vm/object.h"
namespace dart {
@@ -18,6 +20,62 @@ class GrowableObjectArray;
class RawError;
class String;
+class SymbolPair {
+ public:
+ // Typedefs needed for the DirectChainedHashMap template.
+ typedef const String* Key;
+ typedef bool Value;
Florian Schneider 2015/08/06 08:21:19 I think you can do something simpler: typedef Str
+ typedef SymbolPair Pair;
+
+ SymbolPair() : key_(NULL), value_(false) {}
+ SymbolPair(Key key, Value value) : key_(key), value_(value) {
+ ASSERT(key->IsNotTemporaryScopedHandle());
+ }
+
+ static Key KeyOf(Pair kv) { return kv.key_; }
+
+ static Value ValueOf(Pair kv) { return kv.value_; }
+
+ static inline intptr_t Hashcode(Key key) {
+ return key->Hash();
+ }
+
+ static inline bool IsKeyEqual(Pair pair, Key key) {
+ return pair.key_->raw() == key->raw();
+ }
+
+ private:
+ Key key_;
+ Value value_;
+};
+
+
+class SymbolSet : public ValueObject {
+ public:
+ explicit SymbolSet(Zone* zone) : zone_(zone), map_() {}
+
+ void Add(const String& symbol) {
+ ASSERT(symbol.IsSymbol());
+ if (symbol.IsNotTemporaryScopedHandle()) {
+ SymbolPair pair(&symbol, true);
+ map_.Insert(pair);
+ } else {
+ SymbolPair pair(&String::ZoneHandle(zone_, symbol.raw()), true);
+ map_.Insert(pair);
+ }
+ }
+
+ bool Includes(const String& symbol) {
+ ASSERT(symbol.IsSymbol());
+ return map_.Lookup(&symbol);
+ }
+
+ private:
+ Zone* zone_;
+ DirectChainedHashMap<SymbolPair> map_;
+};
+
+
class Precompiler : public ValueObject {
public:
static RawError* CompileAll();
@@ -41,6 +99,8 @@ class Precompiler : public ValueObject {
void ProcessFunction(const Function& function);
void CheckForNewDynamicFunctions();
+ void DropUncompiledFunctions();
+
Thread* thread() const { return thread_; }
Zone* zone() const { return zone_; }
Isolate* isolate() const { return isolate_; }
@@ -52,11 +112,13 @@ class Precompiler : public ValueObject {
bool changed_;
intptr_t function_count_;
intptr_t class_count_;
+ intptr_t selector_count_;
+ intptr_t dropped_function_count_;
const GrowableObjectArray& libraries_;
const GrowableObjectArray& pending_functions_;
const GrowableObjectArray& collected_closures_;
- const GrowableObjectArray& sent_selectors_;
+ SymbolSet sent_selectors_;
Error& error_;
};
« no previous file with comments | « runtime/vm/hash_map.h ('k') | runtime/vm/precompiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698