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/compiler.h" | 5 #include "src/compiler.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "src/ast/ast-numbering.h" | 9 #include "src/ast/ast-numbering.h" |
10 #include "src/ast/prettyprinter.h" | 10 #include "src/ast/prettyprinter.h" |
(...skipping 1540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1551 } else { | 1551 } else { |
1552 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || | 1552 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || |
1553 compile_options == ScriptCompiler::kConsumeCodeCache); | 1553 compile_options == ScriptCompiler::kConsumeCodeCache); |
1554 DCHECK(cached_data && *cached_data); | 1554 DCHECK(cached_data && *cached_data); |
1555 DCHECK(extension == NULL); | 1555 DCHECK(extension == NULL); |
1556 } | 1556 } |
1557 int source_length = source->length(); | 1557 int source_length = source->length(); |
1558 isolate->counters()->total_load_size()->Increment(source_length); | 1558 isolate->counters()->total_load_size()->Increment(source_length); |
1559 isolate->counters()->total_compile_size()->Increment(source_length); | 1559 isolate->counters()->total_compile_size()->Increment(source_length); |
1560 | 1560 |
1561 // TODO(rossberg): The natives do not yet obey strong mode rules | 1561 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); |
1562 // (for example, some macros use '=='). | |
1563 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive(); | |
1564 LanguageMode language_mode = | |
1565 construct_language_mode(FLAG_use_strict, use_strong); | |
1566 | |
1567 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1562 CompilationCache* compilation_cache = isolate->compilation_cache(); |
1568 | 1563 |
1569 // Do a lookup in the compilation cache but not for extensions. | 1564 // Do a lookup in the compilation cache but not for extensions. |
1570 MaybeHandle<SharedFunctionInfo> maybe_result; | 1565 MaybeHandle<SharedFunctionInfo> maybe_result; |
1571 Handle<SharedFunctionInfo> result; | 1566 Handle<SharedFunctionInfo> result; |
1572 if (extension == NULL) { | 1567 if (extension == NULL) { |
1573 // First check per-isolate compilation cache. | 1568 // First check per-isolate compilation cache. |
1574 maybe_result = compilation_cache->LookupScript( | 1569 maybe_result = compilation_cache->LookupScript( |
1575 source, script_name, line_offset, column_offset, resource_options, | 1570 source, script_name, line_offset, column_offset, resource_options, |
1576 context, language_mode); | 1571 context, language_mode); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 } | 1664 } |
1670 | 1665 |
1671 | 1666 |
1672 Handle<SharedFunctionInfo> Compiler::CompileStreamedScript( | 1667 Handle<SharedFunctionInfo> Compiler::CompileStreamedScript( |
1673 Handle<Script> script, ParseInfo* parse_info, int source_length) { | 1668 Handle<Script> script, ParseInfo* parse_info, int source_length) { |
1674 Isolate* isolate = script->GetIsolate(); | 1669 Isolate* isolate = script->GetIsolate(); |
1675 // TODO(titzer): increment the counters in caller. | 1670 // TODO(titzer): increment the counters in caller. |
1676 isolate->counters()->total_load_size()->Increment(source_length); | 1671 isolate->counters()->total_load_size()->Increment(source_length); |
1677 isolate->counters()->total_compile_size()->Increment(source_length); | 1672 isolate->counters()->total_compile_size()->Increment(source_length); |
1678 | 1673 |
1679 LanguageMode language_mode = | 1674 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); |
1680 construct_language_mode(FLAG_use_strict, FLAG_use_strong); | |
1681 parse_info->set_language_mode( | 1675 parse_info->set_language_mode( |
1682 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); | 1676 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); |
1683 | 1677 |
1684 CompilationInfo compile_info(parse_info); | 1678 CompilationInfo compile_info(parse_info); |
1685 | 1679 |
1686 // The source was parsed lazily, so compiling for debugging is not possible. | 1680 // The source was parsed lazily, so compiling for debugging is not possible. |
1687 DCHECK(!compile_info.is_debug()); | 1681 DCHECK(!compile_info.is_debug()); |
1688 | 1682 |
1689 Handle<SharedFunctionInfo> result = CompileToplevel(&compile_info); | 1683 Handle<SharedFunctionInfo> result = CompileToplevel(&compile_info); |
1690 if (!result.is_null()) isolate->debug()->OnAfterCompile(script); | 1684 if (!result.is_null()) isolate->debug()->OnAfterCompile(script); |
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1911 | 1905 |
1912 #if DEBUG | 1906 #if DEBUG |
1913 void CompilationInfo::PrintAstForTesting() { | 1907 void CompilationInfo::PrintAstForTesting() { |
1914 PrintF("--- Source from AST ---\n%s\n", | 1908 PrintF("--- Source from AST ---\n%s\n", |
1915 PrettyPrinter(isolate()).PrintProgram(literal())); | 1909 PrettyPrinter(isolate()).PrintProgram(literal())); |
1916 } | 1910 } |
1917 #endif | 1911 #endif |
1918 | 1912 |
1919 } // namespace internal | 1913 } // namespace internal |
1920 } // namespace v8 | 1914 } // namespace v8 |
OLD | NEW |