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

Unified Diff: src/bootstrapper.cc

Issue 1563005: Introduce fast native caches and use it in String.search. (Closed)
Patch Set: Last round :) Created 10 years, 8 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/arm/codegen-arm.cc ('k') | src/codegen.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index d88c8e7f0c3c64f0ee48eae4e9945402621c7791..3dd7c4a99ca8cd16df9d057aaa0168c3d9185c08 100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -228,6 +228,7 @@ class Genesis BASE_EMBEDDED {
// Used for creating a context from scratch.
void InstallNativeFunctions();
bool InstallNatives();
+ void InstallJSFunctionResultCaches();
// Used both for deserialized and from-scratch contexts to add the extensions
// provided.
static bool InstallExtensions(Handle<Context> global_context,
@@ -1301,6 +1302,44 @@ bool Genesis::InstallNatives() {
}
+// Do not forget to update macros.py with named constant
+// of cache id.
+#define JSFUNCTION_RESULT_CACHE_LIST(F) \
+ F(16, global_context()->regexp_function())
+
+
+static FixedArray* CreateCache(int size, JSFunction* factory) {
+ // Caches are supposed to live for a long time, allocate in old space.
+ int array_size = JSFunctionResultCache::kEntriesIndex + 2 * size;
+ Handle<FixedArray> cache =
+ Factory::NewFixedArrayWithHoles(array_size, TENURED);
+ cache->set(JSFunctionResultCache::kFactoryIndex, factory);
+ cache->set(JSFunctionResultCache::kFingerIndex,
+ Smi::FromInt(JSFunctionResultCache::kEntriesIndex));
+ cache->set(JSFunctionResultCache::kCacheSizeIndex,
+ Smi::FromInt(JSFunctionResultCache::kEntriesIndex));
+ return *cache;
+}
+
+
+void Genesis::InstallJSFunctionResultCaches() {
+ const int kNumberOfCaches = 0 +
+#define F(size, func) + 1
+ JSFUNCTION_RESULT_CACHE_LIST(F)
+#undef F
+ ;
+
+ Handle<FixedArray> caches = Factory::NewFixedArray(kNumberOfCaches, TENURED);
+
+ int index = 0;
+#define F(size, func) caches->set(index++, CreateCache(size, func));
+ JSFUNCTION_RESULT_CACHE_LIST(F)
+#undef F
+
+ global_context()->set_jsfunction_result_caches(*caches);
+}
+
+
int BootstrapperActive::nesting_ = 0;
@@ -1664,6 +1703,7 @@ Genesis::Genesis(Handle<Object> global_object,
HookUpGlobalProxy(inner_global, global_proxy);
InitializeGlobal(inner_global, empty_function);
if (!InstallNatives()) return;
+ InstallJSFunctionResultCaches();
MakeFunctionInstancePrototypeWritable();
« no previous file with comments | « src/arm/codegen-arm.cc ('k') | src/codegen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698