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

Unified Diff: src/runtime.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
« src/objects.h ('K') | « src/objects-inl.h ('k') | src/v8-counters.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/runtime.cc
===================================================================
--- src/runtime.cc (revision 147)
+++ src/runtime.cc (working copy)
@@ -3328,10 +3328,26 @@
}
// Compile eval() source.
+ bool is_global_context = context->IsGlobalContext();
Kasper Lund 2008/09/05 09:16:29 I think you should move this code to the Compiler
Feng Qian 2008/09/09 03:42:50 Done.
Handle<String> source(String::cast(args[0]));
- Handle<JSFunction> boilerplate =
- Compiler::CompileEval(context->IsGlobalContext(), source);
- if (boilerplate.is_null()) return Failure::Exception();
+ Object* obj = Heap::LookupEvalCache(is_global_context, *source);
+ if (obj->IsFailure()) return obj;
+
+ Handle<JSFunction> boilerplate;
+ if (!obj->IsJSFunction()) {
+ Counters::eval_cache_misses.Increment();
+ boilerplate = Compiler::CompileEval(is_global_context, source);
+ if (boilerplate.is_null()) return Failure::Exception();
+
+ Object* obj =
+ Heap::PutInEvalCache(is_global_context, *source, *boilerplate);
+ if (obj->IsFailure()) return obj;
+
+ } else {
+ Counters::eval_cache_hits.Increment();
+ boilerplate = Handle<JSFunction>(JSFunction::cast(obj));
+ }
+
Handle<JSFunction> fun =
Factory::NewFunctionFromBoilerplate(boilerplate, context);
return *fun;
« src/objects.h ('K') | « src/objects-inl.h ('k') | src/v8-counters.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698