| 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 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1566 } else { | 1566 } else { |
| 1567 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || | 1567 DCHECK(compile_options == ScriptCompiler::kConsumeParserCache || |
| 1568 compile_options == ScriptCompiler::kConsumeCodeCache); | 1568 compile_options == ScriptCompiler::kConsumeCodeCache); |
| 1569 DCHECK(cached_data && *cached_data); | 1569 DCHECK(cached_data && *cached_data); |
| 1570 DCHECK(extension == NULL); | 1570 DCHECK(extension == NULL); |
| 1571 } | 1571 } |
| 1572 int source_length = source->length(); | 1572 int source_length = source->length(); |
| 1573 isolate->counters()->total_load_size()->Increment(source_length); | 1573 isolate->counters()->total_load_size()->Increment(source_length); |
| 1574 isolate->counters()->total_compile_size()->Increment(source_length); | 1574 isolate->counters()->total_compile_size()->Increment(source_length); |
| 1575 | 1575 |
| 1576 // TODO(rossberg): The natives do not yet obey strong mode rules | 1576 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); |
| 1577 // (for example, some macros use '=='). | |
| 1578 bool use_strong = FLAG_use_strong && !isolate->bootstrapper()->IsActive(); | |
| 1579 LanguageMode language_mode = | |
| 1580 construct_language_mode(FLAG_use_strict, use_strong); | |
| 1581 | |
| 1582 CompilationCache* compilation_cache = isolate->compilation_cache(); | 1577 CompilationCache* compilation_cache = isolate->compilation_cache(); |
| 1583 | 1578 |
| 1584 // Do a lookup in the compilation cache but not for extensions. | 1579 // Do a lookup in the compilation cache but not for extensions. |
| 1585 MaybeHandle<SharedFunctionInfo> maybe_result; | 1580 MaybeHandle<SharedFunctionInfo> maybe_result; |
| 1586 Handle<SharedFunctionInfo> result; | 1581 Handle<SharedFunctionInfo> result; |
| 1587 if (extension == NULL) { | 1582 if (extension == NULL) { |
| 1588 // First check per-isolate compilation cache. | 1583 // First check per-isolate compilation cache. |
| 1589 maybe_result = compilation_cache->LookupScript( | 1584 maybe_result = compilation_cache->LookupScript( |
| 1590 source, script_name, line_offset, column_offset, resource_options, | 1585 source, script_name, line_offset, column_offset, resource_options, |
| 1591 context, language_mode); | 1586 context, language_mode); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1683 return result; | 1678 return result; |
| 1684 } | 1679 } |
| 1685 | 1680 |
| 1686 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript( | 1681 Handle<SharedFunctionInfo> Compiler::GetSharedFunctionInfoForStreamedScript( |
| 1687 Handle<Script> script, ParseInfo* parse_info, int source_length) { | 1682 Handle<Script> script, ParseInfo* parse_info, int source_length) { |
| 1688 Isolate* isolate = script->GetIsolate(); | 1683 Isolate* isolate = script->GetIsolate(); |
| 1689 // TODO(titzer): increment the counters in caller. | 1684 // TODO(titzer): increment the counters in caller. |
| 1690 isolate->counters()->total_load_size()->Increment(source_length); | 1685 isolate->counters()->total_load_size()->Increment(source_length); |
| 1691 isolate->counters()->total_compile_size()->Increment(source_length); | 1686 isolate->counters()->total_compile_size()->Increment(source_length); |
| 1692 | 1687 |
| 1693 LanguageMode language_mode = | 1688 LanguageMode language_mode = construct_language_mode(FLAG_use_strict); |
| 1694 construct_language_mode(FLAG_use_strict, FLAG_use_strong); | |
| 1695 parse_info->set_language_mode( | 1689 parse_info->set_language_mode( |
| 1696 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); | 1690 static_cast<LanguageMode>(parse_info->language_mode() | language_mode)); |
| 1697 | 1691 |
| 1698 CompilationInfo compile_info(parse_info); | 1692 CompilationInfo compile_info(parse_info); |
| 1699 | 1693 |
| 1700 // The source was parsed lazily, so compiling for debugging is not possible. | 1694 // The source was parsed lazily, so compiling for debugging is not possible. |
| 1701 DCHECK(!compile_info.is_debug()); | 1695 DCHECK(!compile_info.is_debug()); |
| 1702 | 1696 |
| 1703 Handle<SharedFunctionInfo> result = CompileToplevel(&compile_info); | 1697 Handle<SharedFunctionInfo> result = CompileToplevel(&compile_info); |
| 1704 if (!result.is_null()) isolate->debug()->OnAfterCompile(script); | 1698 if (!result.is_null()) isolate->debug()->OnAfterCompile(script); |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1958 | 1952 |
| 1959 #if DEBUG | 1953 #if DEBUG |
| 1960 void CompilationInfo::PrintAstForTesting() { | 1954 void CompilationInfo::PrintAstForTesting() { |
| 1961 PrintF("--- Source from AST ---\n%s\n", | 1955 PrintF("--- Source from AST ---\n%s\n", |
| 1962 PrettyPrinter(isolate()).PrintProgram(literal())); | 1956 PrettyPrinter(isolate()).PrintProgram(literal())); |
| 1963 } | 1957 } |
| 1964 #endif | 1958 #endif |
| 1965 | 1959 |
| 1966 } // namespace internal | 1960 } // namespace internal |
| 1967 } // namespace v8 | 1961 } // namespace v8 |
| OLD | NEW |