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 1340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1351 } else { | 1351 } else { |
1352 info.MarkAsGlobal(); | 1352 info.MarkAsGlobal(); |
1353 } | 1353 } |
1354 info.SetCachedData(cached_data, compile_options); | 1354 info.SetCachedData(cached_data, compile_options); |
1355 info.SetExtension(extension); | 1355 info.SetExtension(extension); |
1356 info.SetContext(context); | 1356 info.SetContext(context); |
1357 if (FLAG_serialize_toplevel && | 1357 if (FLAG_serialize_toplevel && |
1358 compile_options == ScriptCompiler::kProduceCodeCache) { | 1358 compile_options == ScriptCompiler::kProduceCodeCache) { |
1359 info.PrepareForSerializing(); | 1359 info.PrepareForSerializing(); |
1360 } | 1360 } |
1361 if (FLAG_use_strict) { | 1361 |
1362 info.SetLanguageMode( | 1362 LanguageMode language_mode = |
1363 static_cast<LanguageMode>(info.language_mode() | STRICT_BIT)); | 1363 construct_language_mode(FLAG_use_strict, FLAG_use_strong); |
1364 } | 1364 info.SetLanguageMode( |
| 1365 static_cast<LanguageMode>(info.language_mode() | language_mode)); |
1365 | 1366 |
1366 result = CompileToplevel(&info); | 1367 result = CompileToplevel(&info); |
1367 if (extension == NULL && !result.is_null() && !result->dont_cache()) { | 1368 if (extension == NULL && !result.is_null() && !result->dont_cache()) { |
1368 compilation_cache->PutScript(source, context, result); | 1369 compilation_cache->PutScript(source, context, result); |
1369 if (FLAG_serialize_toplevel && | 1370 if (FLAG_serialize_toplevel && |
1370 compile_options == ScriptCompiler::kProduceCodeCache) { | 1371 compile_options == ScriptCompiler::kProduceCodeCache) { |
1371 HistogramTimerScope histogram_timer( | 1372 HistogramTimerScope histogram_timer( |
1372 isolate->counters()->compile_serialize()); | 1373 isolate->counters()->compile_serialize()); |
1373 *cached_data = CodeSerializer::Serialize(isolate, result, source); | 1374 *cached_data = CodeSerializer::Serialize(isolate, result, source); |
1374 if (FLAG_profile_deserialization) { | 1375 if (FLAG_profile_deserialization) { |
(...skipping 10 matching lines...) Expand all Loading... |
1385 return result; | 1386 return result; |
1386 } | 1387 } |
1387 | 1388 |
1388 | 1389 |
1389 Handle<SharedFunctionInfo> Compiler::CompileStreamedScript( | 1390 Handle<SharedFunctionInfo> Compiler::CompileStreamedScript( |
1390 CompilationInfo* info, int source_length) { | 1391 CompilationInfo* info, int source_length) { |
1391 Isolate* isolate = info->isolate(); | 1392 Isolate* isolate = info->isolate(); |
1392 isolate->counters()->total_load_size()->Increment(source_length); | 1393 isolate->counters()->total_load_size()->Increment(source_length); |
1393 isolate->counters()->total_compile_size()->Increment(source_length); | 1394 isolate->counters()->total_compile_size()->Increment(source_length); |
1394 | 1395 |
1395 if (FLAG_use_strict) { | 1396 LanguageMode language_mode = |
1396 info->SetLanguageMode( | 1397 construct_language_mode(FLAG_use_strict, FLAG_use_strong); |
1397 static_cast<LanguageMode>(info->language_mode() | STRICT_BIT)); | 1398 info->SetLanguageMode( |
1398 } | 1399 static_cast<LanguageMode>(info->language_mode() | language_mode)); |
| 1400 |
1399 // TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the | 1401 // TODO(marja): FLAG_serialize_toplevel is not honoured and won't be; when the |
1400 // real code caching lands, streaming needs to be adapted to use it. | 1402 // real code caching lands, streaming needs to be adapted to use it. |
1401 return CompileToplevel(info); | 1403 return CompileToplevel(info); |
1402 } | 1404 } |
1403 | 1405 |
1404 | 1406 |
1405 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo( | 1407 Handle<SharedFunctionInfo> Compiler::BuildFunctionInfo( |
1406 FunctionLiteral* literal, Handle<Script> script, | 1408 FunctionLiteral* literal, Handle<Script> script, |
1407 CompilationInfo* outer_info) { | 1409 CompilationInfo* outer_info) { |
1408 // Precondition: code has been parsed and scopes have been analyzed. | 1410 // Precondition: code has been parsed and scopes have been analyzed. |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1614 } | 1616 } |
1615 | 1617 |
1616 | 1618 |
1617 #if DEBUG | 1619 #if DEBUG |
1618 void CompilationInfo::PrintAstForTesting() { | 1620 void CompilationInfo::PrintAstForTesting() { |
1619 PrintF("--- Source from AST ---\n%s\n", | 1621 PrintF("--- Source from AST ---\n%s\n", |
1620 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1622 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1621 } | 1623 } |
1622 #endif | 1624 #endif |
1623 } } // namespace v8::internal | 1625 } } // namespace v8::internal |
OLD | NEW |