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

Unified Diff: src/compilation-cache.cc

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 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/compilation-cache.h ('k') | src/compiler.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compilation-cache.cc
diff --git a/src/compilation-cache.cc b/src/compilation-cache.cc
index c642faca2d82ec3f3ed46fc8d41c3441afcb6e6a..489604fd6a5780b57991e5de9f816a4164963375 100644
--- a/src/compilation-cache.cc
+++ b/src/compilation-cache.cc
@@ -51,7 +51,8 @@ CompilationCache::CompilationCache()
eval_global_(kEvalGlobalGenerations),
eval_contextual_(kEvalContextualGenerations),
reg_exp_(kRegExpGenerations),
- enabled_(true) {
+ enabled_(true),
+ eager_optimizing_set_(NULL) {
CompilationSubCache* subcaches[kSubCacheCount] =
{&script_, &eval_global_, &eval_contextual_, &reg_exp_};
for (int i = 0; i < kSubCacheCount; ++i) {
@@ -60,6 +61,12 @@ CompilationCache::CompilationCache()
}
+CompilationCache::~CompilationCache() {
+ delete eager_optimizing_set_;
+ eager_optimizing_set_ = NULL;
+}
+
+
static Handle<CompilationCacheTable> AllocateTable(int size) {
Isolate* isolate = Isolate::Current();
CALL_HEAP_FUNCTION(isolate,
@@ -82,7 +89,6 @@ Handle<CompilationCacheTable> CompilationSubCache::GetTable(int generation) {
return result;
}
-
void CompilationSubCache::Age() {
// Age the generations implicitly killing off the oldest.
for (int i = generations_ - 1; i > 0; i--) {
@@ -114,6 +120,18 @@ void CompilationSubCache::Clear() {
}
+void CompilationSubCache::Remove(Handle<SharedFunctionInfo> function_info) {
+ // Probe the script generation tables. Make sure not to leak handles
+ // into the caller's handle scope.
+ { HandleScope scope;
+ for (int generation = 0; generation < generations(); generation++) {
+ Handle<CompilationCacheTable> table = GetTable(generation);
+ table->Remove(*function_info);
+ }
+ }
+}
+
+
CompilationCacheScript::CompilationCacheScript(int generations)
: CompilationSubCache(generations),
script_histogram_(NULL),
@@ -351,6 +369,15 @@ void CompilationCacheRegExp::Put(Handle<String> source,
}
+void CompilationCache::Remove(Handle<SharedFunctionInfo> function_info) {
+ if (!IsEnabled()) return;
+
+ eval_global_.Remove(function_info);
+ eval_contextual_.Remove(function_info);
+ script_.Remove(function_info);
+}
+
+
Handle<SharedFunctionInfo> CompilationCache::LookupScript(Handle<String> source,
Handle<Object> name,
int line_offset,
@@ -429,6 +456,47 @@ void CompilationCache::PutRegExp(Handle<String> source,
}
+static bool SourceHashCompare(void* key1, void* key2) {
+ return key1 == key2;
+}
+
+
+HashMap* CompilationCache::EagerOptimizingSet() {
+ if (eager_optimizing_set_ == NULL) {
+ eager_optimizing_set_ = new HashMap(&SourceHashCompare);
+ }
+ return eager_optimizing_set_;
+}
+
+
+bool CompilationCache::ShouldOptimizeEagerly(Handle<JSFunction> function) {
+ if (FLAG_opt_eagerly) return true;
+ uint32_t hash = function->SourceHash();
+ void* key = reinterpret_cast<void*>(hash);
+ return EagerOptimizingSet()->Lookup(key, hash, false) != NULL;
+}
+
+
+void CompilationCache::MarkForEagerOptimizing(Handle<JSFunction> function) {
+ uint32_t hash = function->SourceHash();
+ void* key = reinterpret_cast<void*>(hash);
+ EagerOptimizingSet()->Lookup(key, hash, true);
+}
+
+
+void CompilationCache::MarkForLazyOptimizing(Handle<JSFunction> function) {
+ uint32_t hash = function->SourceHash();
+ void* key = reinterpret_cast<void*>(hash);
+ EagerOptimizingSet()->Remove(key, hash);
+}
+
+
+void CompilationCache::ResetEagerOptimizingData() {
+ HashMap* set = EagerOptimizingSet();
+ if (set->occupancy() > 0) set->Clear();
+}
+
+
void CompilationCache::Clear() {
for (int i = 0; i < kSubCacheCount; i++) {
subcaches_[i]->Clear();
« no previous file with comments | « src/compilation-cache.h ('k') | src/compiler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698