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 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1111 ? info->isolate()->counters()->compile_eval() | 1111 ? info->isolate()->counters()->compile_eval() |
1112 : info->isolate()->counters()->compile(); | 1112 : info->isolate()->counters()->compile(); |
1113 HistogramTimerScope timer(rate); | 1113 HistogramTimerScope timer(rate); |
1114 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), | 1114 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8.compile"), |
1115 parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile"); | 1115 parse_info->is_eval() ? "V8.CompileEval" : "V8.Compile"); |
1116 | 1116 |
1117 // Allocate a shared function info object. | 1117 // Allocate a shared function info object. |
1118 DCHECK_EQ(kNoSourcePosition, lit->function_token_position()); | 1118 DCHECK_EQ(kNoSourcePosition, lit->function_token_position()); |
1119 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); | 1119 result = NewSharedFunctionInfoForLiteral(isolate, lit, script); |
1120 result->set_is_toplevel(true); | 1120 result->set_is_toplevel(true); |
1121 if (parse_info->is_eval()) { | |
1122 // Eval scripts cannot be (re-)compiled without context. | |
1123 result->set_allows_lazy_compilation_without_context(false); | |
1124 } | |
1125 parse_info->set_shared_info(result); | 1121 parse_info->set_shared_info(result); |
1126 | 1122 |
1127 // Compile the code. | 1123 // Compile the code. |
1128 if (!CompileUnoptimizedCode(info)) { | 1124 if (!CompileUnoptimizedCode(info)) { |
1129 return Handle<SharedFunctionInfo>::null(); | 1125 return Handle<SharedFunctionInfo>::null(); |
1130 } | 1126 } |
1131 | 1127 |
1132 // Update the shared function info with the scope info. | 1128 // Update the shared function info with the scope info. |
1133 InstallSharedScopeInfo(info, result); | 1129 InstallSharedScopeInfo(info, result); |
1134 | 1130 |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1290 } | 1286 } |
1291 | 1287 |
1292 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { | 1288 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { |
1293 Isolate* isolate = shared->GetIsolate(); | 1289 Isolate* isolate = shared->GetIsolate(); |
1294 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1290 DCHECK(AllowCompilation::IsAllowed(isolate)); |
1295 | 1291 |
1296 // Start a compilation. | 1292 // Start a compilation. |
1297 Zone zone(isolate->allocator()); | 1293 Zone zone(isolate->allocator()); |
1298 ParseInfo parse_info(&zone, shared); | 1294 ParseInfo parse_info(&zone, shared); |
1299 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1295 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
1300 DCHECK(shared->allows_lazy_compilation_without_context()); | 1296 if (IsEvalToplevel(shared)) { |
1301 DCHECK(!IsEvalToplevel(shared)); | 1297 parse_info.set_eval(); |
| 1298 parse_info.set_toplevel(); |
| 1299 parse_info.set_allow_lazy_parsing(false); |
| 1300 parse_info.set_lazy(false); |
| 1301 } |
1302 info.MarkAsDebug(); | 1302 info.MarkAsDebug(); |
1303 if (GetUnoptimizedCode(&info).is_null()) { | 1303 if (GetUnoptimizedCode(&info).is_null()) { |
1304 isolate->clear_pending_exception(); | 1304 isolate->clear_pending_exception(); |
1305 return false; | 1305 return false; |
1306 } | 1306 } |
1307 | 1307 |
1308 // Check postconditions on success. | 1308 // Check postconditions on success. |
1309 DCHECK(!isolate->has_pending_exception()); | 1309 DCHECK(!isolate->has_pending_exception()); |
1310 DCHECK(shared->is_compiled()); | 1310 DCHECK(shared->is_compiled()); |
1311 DCHECK(shared->HasDebugCode()); | 1311 DCHECK(shared->HasDebugCode()); |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 DCHECK(shared->is_compiled()); | 1888 DCHECK(shared->is_compiled()); |
1889 function->set_literals(cached.literals); | 1889 function->set_literals(cached.literals); |
1890 } else if (shared->is_compiled()) { | 1890 } else if (shared->is_compiled()) { |
1891 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1891 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
1892 JSFunction::EnsureLiterals(function); | 1892 JSFunction::EnsureLiterals(function); |
1893 } | 1893 } |
1894 } | 1894 } |
1895 | 1895 |
1896 } // namespace internal | 1896 } // namespace internal |
1897 } // namespace v8 | 1897 } // namespace v8 |
OLD | NEW |