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

Unified Diff: src/heap.cc

Issue 457: Added a EvalCache that caches eval'ed scripts and compiled function boilerpla... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 12 years, 3 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: src/heap.cc
===================================================================
--- src/heap.cc (revision 147)
+++ src/heap.cc (working copy)
@@ -435,6 +435,10 @@
void Heap::MarkCompactPrologue() {
+ // Empty eval caches
+ Heap::eval_cache_global_ = Heap::null_value();
+ Heap::eval_cache_non_global_ = Heap::null_value();
+
RegExpImpl::OldSpaceCollectionPrologue();
Top::MarkCompactPrologue();
ThreadManager::MarkCompactPrologue();
@@ -1194,6 +1198,10 @@
if (obj->IsFailure()) return false;
natives_source_cache_ = FixedArray::cast(obj);
+ // Initialized eval cache to null value.
+ eval_cache_global_ = null_value();
+ eval_cache_non_global_ = null_value();
+
return true;
}
@@ -2253,6 +2261,34 @@
}
+Object* Heap::LookupEvalCache(bool is_global_context, String* src) {
+ Object* cache = is_global_context ?
+ eval_cache_global_ : eval_cache_non_global_;
+ return cache == null_value() ?
+ null_value() : EvalCache::cast(cache)->Lookup(src);
+}
+
+
+Object* Heap::PutInEvalCache(bool is_global_context, String* src,
+ JSFunction* value) {
+ Object** cache_ptr = is_global_context ?
+ &eval_cache_global_ : &eval_cache_non_global_;
+
+ if (*cache_ptr == null_value()) {
+ Object* obj = EvalCache::Allocate(kInitialEvalCacheSize);
+ if (obj->IsFailure()) return false;
+ *cache_ptr = obj;
+ }
+
+ Object* new_cache =
+ EvalCache::cast(*cache_ptr)->Put(src, value);
+ if (new_cache->IsFailure()) return new_cache;
+ *cache_ptr = new_cache;
+
+ return value;
+}
+
+
#ifdef DEBUG
void Heap::ZapFromSpace() {
ASSERT(HAS_HEAP_OBJECT_TAG(kFromSpaceZapValue));

Powered by Google App Engine
This is Rietveld 408576698