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

Unified Diff: src/compilation-cache.cc

Issue 669057: - Fixed the compilation cache so Put works.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 10 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 | « no previous file | src/objects.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compilation-cache.cc
===================================================================
--- src/compilation-cache.cc (revision 4014)
+++ src/compilation-cache.cc (working copy)
@@ -32,7 +32,6 @@
namespace v8 {
namespace internal {
-
// The number of sub caches covering the different types to cache.
static const int kSubCacheCount = 4;
@@ -47,6 +46,9 @@
// Initial size of each compilation cache table allocated.
static const int kInitialCacheSize = 64;
+// Index for the first generation in the cache.
+static const int kFirstGeneration = 0;
+
// The compilation cache consists of several generational sub-caches which uses
// this class as a base class. A sub-cache contains a compilation cache tables
// for each generation of the sub-cache. Since the same source code string has
@@ -63,6 +65,15 @@
// Get the compilation cache tables for a specific generation.
Handle<CompilationCacheTable> GetTable(int generation);
+ // Accessors for first generation.
+ Handle<CompilationCacheTable> GetFirstTable() {
+ return GetTable(kFirstGeneration);
+ }
+ void SetFirstTable(Handle<CompilationCacheTable> value) {
+ ASSERT(kFirstGeneration < generations_);
+ tables_[kFirstGeneration] = *value;
+ }
+
// Age the sub-cache by evicting the oldest generation and creating a new
// young generation.
void Age();
@@ -97,6 +108,10 @@
void Put(Handle<String> source, Handle<JSFunction> boilerplate);
private:
+ // Note: Returns a new hash table if operation results in expansion.
+ Handle<CompilationCacheTable> TablePut(Handle<String> source,
+ Handle<JSFunction> boilerplate);
+
bool HasOrigin(Handle<JSFunction> boilerplate,
Handle<Object> name,
int line_offset,
@@ -118,6 +133,12 @@
Handle<Context> context,
Handle<JSFunction> boilerplate);
+ private:
+ // Note: Returns a new hash table if operation results in expansion.
+ Handle<CompilationCacheTable> TablePut(Handle<String> source,
+ Handle<Context> context,
+ Handle<JSFunction> boilerplate);
+
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheEval);
};
@@ -133,6 +154,11 @@
void Put(Handle<String> source,
JSRegExp::Flags flags,
Handle<FixedArray> data);
+ private:
+ // Note: Returns a new hash table if operation results in expansion.
+ Handle<CompilationCacheTable> TablePut(Handle<String> source,
+ JSRegExp::Flags flags,
+ Handle<FixedArray> data);
DISALLOW_IMPLICIT_CONSTRUCTORS(CompilationCacheRegExp);
};
@@ -280,12 +306,19 @@
}
+Handle<CompilationCacheTable> CompilationCacheScript::TablePut(
+ Handle<String> source,
+ Handle<JSFunction> boilerplate) {
+ CALL_HEAP_FUNCTION(GetFirstTable()->Put(*source, *boilerplate),
+ CompilationCacheTable);
+}
+
+
void CompilationCacheScript::Put(Handle<String> source,
Handle<JSFunction> boilerplate) {
HandleScope scope;
ASSERT(boilerplate->IsBoilerplate());
- Handle<CompilationCacheTable> table = GetTable(0);
- CALL_HEAP_FUNCTION_VOID(table->Put(*source, *boilerplate));
+ SetFirstTable(TablePut(source, boilerplate));
}
@@ -319,13 +352,21 @@
}
+Handle<CompilationCacheTable> CompilationCacheEval::TablePut(
+ Handle<String> source,
+ Handle<Context> context,
+ Handle<JSFunction> boilerplate) {
+ CALL_HEAP_FUNCTION(GetFirstTable()->PutEval(*source, *context, *boilerplate),
+ CompilationCacheTable);
+}
+
+
void CompilationCacheEval::Put(Handle<String> source,
Handle<Context> context,
Handle<JSFunction> boilerplate) {
HandleScope scope;
ASSERT(boilerplate->IsBoilerplate());
- Handle<CompilationCacheTable> table = GetTable(0);
- CALL_HEAP_FUNCTION_VOID(table->PutEval(*source, *context, *boilerplate));
+ SetFirstTable(TablePut(source, context, boilerplate));
}
@@ -359,12 +400,20 @@
}
+Handle<CompilationCacheTable> CompilationCacheRegExp::TablePut(
+ Handle<String> source,
+ JSRegExp::Flags flags,
+ Handle<FixedArray> data) {
+ CALL_HEAP_FUNCTION(GetFirstTable()->PutRegExp(*source, flags, *data),
+ CompilationCacheTable);
+}
+
+
void CompilationCacheRegExp::Put(Handle<String> source,
JSRegExp::Flags flags,
Handle<FixedArray> data) {
HandleScope scope;
- Handle<CompilationCacheTable> table = GetTable(0);
- CALL_HEAP_FUNCTION_VOID(table->PutRegExp(*source, flags, *data));
+ SetFirstTable(TablePut(source, flags, data));
}
« no previous file with comments | « no previous file | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698