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 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "src/asmjs/asm-js.h" | 10 #include "src/asmjs/asm-js.h" |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1029 | 1029 |
1030 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? | 1030 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? |
1031 FixedArray* array = isolate->native_context()->embedder_data(); | 1031 FixedArray* array = isolate->native_context()->embedder_data(); |
1032 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); | 1032 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); |
1033 | 1033 |
1034 isolate->debug()->OnBeforeCompile(script); | 1034 isolate->debug()->OnBeforeCompile(script); |
1035 | 1035 |
1036 Handle<SharedFunctionInfo> result; | 1036 Handle<SharedFunctionInfo> result; |
1037 | 1037 |
1038 { VMState<COMPILER> state(info->isolate()); | 1038 { VMState<COMPILER> state(info->isolate()); |
1039 if (parse_info->literal() == NULL) { | 1039 if (parse_info->literal() == nullptr && !Parse(parse_info)) { |
1040 // Parse the script if needed (if it's already parsed, literal() is | 1040 return Handle<SharedFunctionInfo>::null(); |
1041 // non-NULL). If compiling for debugging, we may eagerly compile inner | |
1042 // functions, so do not parse lazily in that case. | |
1043 ScriptCompiler::CompileOptions options = parse_info->compile_options(); | |
1044 bool parse_allow_lazy = | |
1045 options == ScriptCompiler::kConsumeParserCache || | |
1046 String::cast(script->source())->length() > FLAG_min_preparse_length; | |
1047 | |
1048 parse_info->set_allow_lazy_parsing(parse_allow_lazy); | |
1049 if (!parse_allow_lazy && | |
1050 (options == ScriptCompiler::kProduceParserCache || | |
1051 options == ScriptCompiler::kConsumeParserCache)) { | |
1052 // We are going to parse eagerly, but we either 1) have cached data | |
1053 // produced by lazy parsing or 2) are asked to generate cached data. | |
1054 // Eager parsing cannot benefit from cached data, and producing cached | |
1055 // data while parsing eagerly is not implemented. | |
1056 parse_info->set_cached_data(nullptr); | |
1057 parse_info->set_compile_options(ScriptCompiler::kNoCompileOptions); | |
1058 } | |
1059 | |
1060 if (!Parse(parse_info)) { | |
1061 return Handle<SharedFunctionInfo>::null(); | |
1062 } | |
1063 } | 1041 } |
1064 | 1042 |
1065 FunctionLiteral* lit = parse_info->literal(); | 1043 FunctionLiteral* lit = parse_info->literal(); |
1066 | 1044 |
1067 // Measure how long it takes to do the compilation; only take the | 1045 // Measure how long it takes to do the compilation; only take the |
1068 // rest of the function into account to avoid overlap with the | 1046 // rest of the function into account to avoid overlap with the |
1069 // parsing statistics. | 1047 // parsing statistics. |
1070 RuntimeCallTimerScope runtimeTimer( | 1048 RuntimeCallTimerScope runtimeTimer( |
1071 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval | 1049 isolate, parse_info->is_eval() ? &RuntimeCallStats::CompileEval |
1072 : &RuntimeCallStats::Compile); | 1050 : &RuntimeCallStats::Compile); |
(...skipping 761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1834 DCHECK(shared->is_compiled()); | 1812 DCHECK(shared->is_compiled()); |
1835 function->set_literals(cached.literals); | 1813 function->set_literals(cached.literals); |
1836 } else if (shared->is_compiled()) { | 1814 } else if (shared->is_compiled()) { |
1837 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1815 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1838 JSFunction::EnsureLiterals(function); | 1816 JSFunction::EnsureLiterals(function); |
1839 } | 1817 } |
1840 } | 1818 } |
1841 | 1819 |
1842 } // namespace internal | 1820 } // namespace internal |
1843 } // namespace v8 | 1821 } // namespace v8 |
OLD | NEW |