Index: src/compiler.cc |
diff --git a/src/compiler.cc b/src/compiler.cc |
index fdee097b438e4d07bf20f2e350664d6c5a0df976..4b539897b87b94cc66abbd27c2f2931ff9fb3354 100644 |
--- a/src/compiler.cc |
+++ b/src/compiler.cc |
@@ -115,7 +115,8 @@ void CompilationInfo::Initialize(Isolate* isolate, |
scope_ = NULL; |
global_scope_ = NULL; |
extension_ = NULL; |
- pre_parse_data_ = NULL; |
+ cached_data_ = NULL; |
+ cached_data_mode_ = NO_CACHED_DATA; |
zone_ = zone; |
deferred_handles_ = NULL; |
code_stub_ = NULL; |
@@ -782,15 +783,18 @@ static Handle<SharedFunctionInfo> CompileToplevel(CompilationInfo* info) { |
ASSERT(info->is_eval() || info->is_global()); |
bool parse_allow_lazy = |
- (info->pre_parse_data() != NULL || |
+ (info->cached_data_mode() == CONSUME_CACHED_DATA || |
String::cast(script->source())->length() > FLAG_min_preparse_length) && |
!DebuggerWantsEagerCompilation(info); |
- if (!parse_allow_lazy && info->pre_parse_data() != NULL) { |
- // We are going to parse eagerly, but we have preparse data produced by lazy |
- // preparsing. We cannot use it, since it won't contain all the symbols we |
- // need for eager parsing. |
- info->SetPreParseData(NULL); |
+ if (!parse_allow_lazy && info->cached_data_mode() != NO_CACHED_DATA) { |
+ // We are going to parse eagerly, but we either 1) have cached data produced |
+ // by lazy parsing or 2) are asked to generate cached data. We cannot use |
+ // the existing data, since it won't contain all the symbols we need for |
+ // eager parsing. In addition, it doesn't make sense to produce the data |
+ // when parsing eagerly. That data would contain all symbols, but no |
+ // functions, so it cannot be used to aid lazy parsing later. |
+ info->SetCachedData(NULL, NO_CACHED_DATA); |
} |
Handle<SharedFunctionInfo> result; |
@@ -910,15 +914,25 @@ Handle<JSFunction> Compiler::GetFunctionFromEval(Handle<String> source, |
} |
-Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source, |
- Handle<Object> script_name, |
- int line_offset, |
- int column_offset, |
- bool is_shared_cross_origin, |
- Handle<Context> context, |
- v8::Extension* extension, |
- ScriptDataImpl* pre_data, |
- NativesFlag natives) { |
+Handle<SharedFunctionInfo> Compiler::CompileScript( |
+ Handle<String> source, |
+ Handle<Object> script_name, |
+ int line_offset, |
+ int column_offset, |
+ bool is_shared_cross_origin, |
+ Handle<Context> context, |
+ v8::Extension* extension, |
+ ScriptDataImpl** cached_data, |
+ CachedDataMode cached_data_mode, |
+ NativesFlag natives) { |
+ if (cached_data_mode == NO_CACHED_DATA) { |
+ cached_data = NULL; |
+ } else if (cached_data_mode == PRODUCE_CACHED_DATA) { |
+ ASSERT(cached_data && !*cached_data); |
+ } else { |
+ ASSERT(cached_data_mode == CONSUME_CACHED_DATA); |
+ ASSERT(cached_data && *cached_data); |
+ } |
Isolate* isolate = source->GetIsolate(); |
int source_length = source->length(); |
isolate->counters()->total_load_size()->Increment(source_length); |
@@ -963,7 +977,7 @@ Handle<SharedFunctionInfo> Compiler::CompileScript(Handle<String> source, |
CompilationInfoWithZone info(script); |
info.MarkAsGlobal(); |
info.SetExtension(extension); |
- info.SetPreParseData(pre_data); |
+ info.SetCachedData(cached_data, cached_data_mode); |
info.SetContext(context); |
if (FLAG_use_strict) info.SetStrictMode(STRICT); |
result = CompileToplevel(&info); |