OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler.h" | 7 #include "src/compiler.h" |
8 | 8 |
9 #include "src/ast-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/ast-this-access-visitor.h" | 10 #include "src/ast-this-access-visitor.h" |
(...skipping 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1257 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); | 1257 shared_info->ResetForNewContext(isolate->heap()->global_ic_age()); |
1258 } | 1258 } |
1259 | 1259 |
1260 return isolate->factory()->NewFunctionFromSharedFunctionInfo( | 1260 return isolate->factory()->NewFunctionFromSharedFunctionInfo( |
1261 shared_info, context, NOT_TENURED); | 1261 shared_info, context, NOT_TENURED); |
1262 } | 1262 } |
1263 | 1263 |
1264 | 1264 |
1265 Handle<SharedFunctionInfo> Compiler::CompileScript( | 1265 Handle<SharedFunctionInfo> Compiler::CompileScript( |
1266 Handle<String> source, Handle<Object> script_name, int line_offset, | 1266 Handle<String> source, Handle<Object> script_name, int line_offset, |
1267 int column_offset, bool is_shared_cross_origin, Handle<Context> context, | 1267 int column_offset, bool is_internal_script, bool is_shared_cross_origin, |
1268 v8::Extension* extension, ScriptData** cached_data, | 1268 Handle<Context> context, v8::Extension* extension, ScriptData** cached_data, |
1269 ScriptCompiler::CompileOptions compile_options, NativesFlag natives) { | 1269 ScriptCompiler::CompileOptions compile_options, NativesFlag natives) { |
1270 Isolate* isolate = source->GetIsolate(); | 1270 Isolate* isolate = source->GetIsolate(); |
1271 HistogramTimerScope total(isolate->counters()->compile_script(), true); | 1271 HistogramTimerScope total(isolate->counters()->compile_script(), true); |
1272 | 1272 |
1273 if (compile_options == ScriptCompiler::kNoCompileOptions) { | 1273 if (compile_options == ScriptCompiler::kNoCompileOptions) { |
1274 cached_data = NULL; | 1274 cached_data = NULL; |
1275 } else if (compile_options == ScriptCompiler::kProduceParserCache || | 1275 } else if (compile_options == ScriptCompiler::kProduceParserCache || |
1276 compile_options == ScriptCompiler::kProduceCodeCache) { | 1276 compile_options == ScriptCompiler::kProduceCodeCache) { |
1277 DCHECK(cached_data && !*cached_data); | 1277 DCHECK(cached_data && !*cached_data); |
1278 DCHECK(extension == NULL); | 1278 DCHECK(extension == NULL); |
1279 DCHECK(!isolate->debug()->is_loaded()); | 1279 DCHECK(!isolate->debug()->is_loaded()); |
1280 } else { | 1280 } else { |
1281 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || | 1281 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || |
1282 compile_options == ScriptCompiler::kConsumeCodeCache); | 1282 compile_options == ScriptCompiler::kConsumeCodeCache); |
1283 DCHECK(cached_data && *cached_data); | 1283 DCHECK(cached_data && *cached_data); |
1284 DCHECK(extension == NULL); | 1284 DCHECK(extension == NULL); |
1285 } | 1285 } |
1286 int source_length = source->length(); | 1286 int source_length = source->length(); |
1287 isolate->counters()->total_load_size()->Increment(source_length); | 1287 isolate->counters()->total_load_size()->Increment(source_length); |
1288 isolate->counters()->total_compile_size()->Increment(source_length); | 1288 isolate->counters()->total_compile_size()->Increment(source_length); |
1289 | 1289 |
1290 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1290 CompilationCache* compilation_cache = isolate->compilation_cache(); |
1291 | 1291 |
1292 // Do a lookup in the compilation cache but not for extensions. | 1292 // Do a lookup in the compilation cache but not for extensions. |
1293 MaybeHandle<SharedFunctionInfo> maybe_result; | 1293 MaybeHandle<SharedFunctionInfo> maybe_result; |
1294 Handle<SharedFunctionInfo> result; | 1294 Handle<SharedFunctionInfo> result; |
1295 if (extension == NULL) { | 1295 if (extension == NULL) { |
1296 maybe_result = compilation_cache->LookupScript( | 1296 maybe_result = compilation_cache->LookupScript( |
1297 source, script_name, line_offset, column_offset, is_shared_cross_origin, | 1297 source, script_name, line_offset, column_offset, is_internal_script, |
1298 context); | 1298 is_shared_cross_origin, context); |
1299 if (maybe_result.is_null() && FLAG_serialize_toplevel && | 1299 if (maybe_result.is_null() && FLAG_serialize_toplevel && |
1300 compile_options == ScriptCompiler::kConsumeCodeCache && | 1300 compile_options == ScriptCompiler::kConsumeCodeCache && |
1301 !isolate->debug()->is_loaded()) { | 1301 !isolate->debug()->is_loaded()) { |
1302 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); | 1302 HistogramTimerScope timer(isolate->counters()->compile_deserialize()); |
1303 Handle<SharedFunctionInfo> result; | 1303 Handle<SharedFunctionInfo> result; |
1304 if (CodeSerializer::Deserialize(isolate, *cached_data, source) | 1304 if (CodeSerializer::Deserialize(isolate, *cached_data, source) |
1305 .ToHandle(&result)) { | 1305 .ToHandle(&result)) { |
1306 return result; | 1306 return result; |
1307 } | 1307 } |
1308 // Deserializer failed. Fall through to compile. | 1308 // Deserializer failed. Fall through to compile. |
(...skipping 13 matching lines...) Expand all Loading... |
1322 Handle<Script> script = isolate->factory()->NewScript(source); | 1322 Handle<Script> script = isolate->factory()->NewScript(source); |
1323 if (natives == NATIVES_CODE) { | 1323 if (natives == NATIVES_CODE) { |
1324 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); | 1324 script->set_type(Smi::FromInt(Script::TYPE_NATIVE)); |
1325 } | 1325 } |
1326 if (!script_name.is_null()) { | 1326 if (!script_name.is_null()) { |
1327 script->set_name(*script_name); | 1327 script->set_name(*script_name); |
1328 script->set_line_offset(Smi::FromInt(line_offset)); | 1328 script->set_line_offset(Smi::FromInt(line_offset)); |
1329 script->set_column_offset(Smi::FromInt(column_offset)); | 1329 script->set_column_offset(Smi::FromInt(column_offset)); |
1330 } | 1330 } |
1331 script->set_is_shared_cross_origin(is_shared_cross_origin); | 1331 script->set_is_shared_cross_origin(is_shared_cross_origin); |
| 1332 script->set_is_internal_script(is_internal_script); |
1332 | 1333 |
1333 // Compile the function and add it to the cache. | 1334 // Compile the function and add it to the cache. |
1334 CompilationInfoWithZone info(script); | 1335 CompilationInfoWithZone info(script); |
1335 info.MarkAsGlobal(); | 1336 info.MarkAsGlobal(); |
1336 info.SetCachedData(cached_data, compile_options); | 1337 info.SetCachedData(cached_data, compile_options); |
1337 info.SetExtension(extension); | 1338 info.SetExtension(extension); |
1338 info.SetContext(context); | 1339 info.SetContext(context); |
1339 if (FLAG_serialize_toplevel && | 1340 if (FLAG_serialize_toplevel && |
1340 compile_options == ScriptCompiler::kProduceCodeCache) { | 1341 compile_options == ScriptCompiler::kProduceCodeCache) { |
1341 info.PrepareForSerializing(); | 1342 info.PrepareForSerializing(); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1583 AllowHandleDereference allow_deref; | 1584 AllowHandleDereference allow_deref; |
1584 bool tracing_on = info()->IsStub() | 1585 bool tracing_on = info()->IsStub() |
1585 ? FLAG_trace_hydrogen_stubs | 1586 ? FLAG_trace_hydrogen_stubs |
1586 : (FLAG_trace_hydrogen && | 1587 : (FLAG_trace_hydrogen && |
1587 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); | 1588 info()->closure()->PassesFilter(FLAG_trace_hydrogen_filter)); |
1588 return (tracing_on && | 1589 return (tracing_on && |
1589 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); | 1590 base::OS::StrChr(const_cast<char*>(FLAG_trace_phase), name_[0]) != NULL); |
1590 } | 1591 } |
1591 | 1592 |
1592 } } // namespace v8::internal | 1593 } } // namespace v8::internal |
OLD | NEW |