| 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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 700 if (info->is_osr() && !ignition_osr) return MaybeHandle<Code>(); | 700 if (info->is_osr() && !ignition_osr) return MaybeHandle<Code>(); |
| 701 if (!Compiler::EnsureBytecode(info)) { | 701 if (!Compiler::EnsureBytecode(info)) { |
| 702 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); | 702 if (isolate->has_pending_exception()) isolate->clear_pending_exception(); |
| 703 return MaybeHandle<Code>(); | 703 return MaybeHandle<Code>(); |
| 704 } | 704 } |
| 705 info->MarkAsOptimizeFromBytecode(); | 705 info->MarkAsOptimizeFromBytecode(); |
| 706 } | 706 } |
| 707 | 707 |
| 708 if (IsEvalToplevel(shared)) { | 708 if (IsEvalToplevel(shared)) { |
| 709 parse_info->set_eval(); | 709 parse_info->set_eval(); |
| 710 parse_info->set_toplevel(); | |
| 711 parse_info->set_allow_lazy_parsing(false); | 710 parse_info->set_allow_lazy_parsing(false); |
| 712 } | 711 } |
| 713 | 712 |
| 714 // Verify that OSR compilations are delegated to the correct graph builder. | 713 // Verify that OSR compilations are delegated to the correct graph builder. |
| 715 // Depending on the underlying frame the semantics of the {BailoutId} differ | 714 // Depending on the underlying frame the semantics of the {BailoutId} differ |
| 716 // and the various graph builders hard-code a certain semantic: | 715 // and the various graph builders hard-code a certain semantic: |
| 717 // - Interpreter : The BailoutId represents a bytecode offset. | 716 // - Interpreter : The BailoutId represents a bytecode offset. |
| 718 // - FullCodegen : The BailoutId represents the id of an AST node. | 717 // - FullCodegen : The BailoutId represents the id of an AST node. |
| 719 DCHECK_IMPLIES(info->is_osr() && ignition_osr, | 718 DCHECK_IMPLIES(info->is_osr() && ignition_osr, |
| 720 info->is_optimizing_from_bytecode()); | 719 info->is_optimizing_from_bytecode()); |
| (...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1038 DCHECK(!isolate->native_context().is_null()); | 1037 DCHECK(!isolate->native_context().is_null()); |
| 1039 ParseInfo* parse_info = info->parse_info(); | 1038 ParseInfo* parse_info = info->parse_info(); |
| 1040 Handle<Script> script = parse_info->script(); | 1039 Handle<Script> script = parse_info->script(); |
| 1041 | 1040 |
| 1042 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? | 1041 // TODO(svenpanne) Obscure place for this, perhaps move to OnBeforeCompile? |
| 1043 FixedArray* array = isolate->native_context()->embedder_data(); | 1042 FixedArray* array = isolate->native_context()->embedder_data(); |
| 1044 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); | 1043 script->set_context_data(array->get(v8::Context::kDebugIdIndex)); |
| 1045 | 1044 |
| 1046 isolate->debug()->OnBeforeCompile(script); | 1045 isolate->debug()->OnBeforeCompile(script); |
| 1047 | 1046 |
| 1048 parse_info->set_toplevel(); | |
| 1049 | |
| 1050 Handle<SharedFunctionInfo> result; | 1047 Handle<SharedFunctionInfo> result; |
| 1051 | 1048 |
| 1052 { VMState<COMPILER> state(info->isolate()); | 1049 { VMState<COMPILER> state(info->isolate()); |
| 1053 if (parse_info->literal() == NULL) { | 1050 if (parse_info->literal() == NULL) { |
| 1054 // Parse the script if needed (if it's already parsed, literal() is | 1051 // Parse the script if needed (if it's already parsed, literal() is |
| 1055 // non-NULL). If compiling for debugging, we may eagerly compile inner | 1052 // non-NULL). If compiling for debugging, we may eagerly compile inner |
| 1056 // functions, so do not parse lazily in that case. | 1053 // functions, so do not parse lazily in that case. |
| 1057 ScriptCompiler::CompileOptions options = parse_info->compile_options(); | 1054 ScriptCompiler::CompileOptions options = parse_info->compile_options(); |
| 1058 bool parse_allow_lazy = | 1055 bool parse_allow_lazy = |
| 1059 options == ScriptCompiler::kConsumeParserCache || | 1056 options == ScriptCompiler::kConsumeParserCache || |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1232 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { | 1229 bool Compiler::CompileDebugCode(Handle<JSFunction> function) { |
| 1233 Isolate* isolate = function->GetIsolate(); | 1230 Isolate* isolate = function->GetIsolate(); |
| 1234 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1231 DCHECK(AllowCompilation::IsAllowed(isolate)); |
| 1235 | 1232 |
| 1236 // Start a compilation. | 1233 // Start a compilation. |
| 1237 Zone zone(isolate->allocator()); | 1234 Zone zone(isolate->allocator()); |
| 1238 ParseInfo parse_info(&zone, function); | 1235 ParseInfo parse_info(&zone, function); |
| 1239 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1236 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
| 1240 if (IsEvalToplevel(handle(function->shared()))) { | 1237 if (IsEvalToplevel(handle(function->shared()))) { |
| 1241 parse_info.set_eval(); | 1238 parse_info.set_eval(); |
| 1242 parse_info.set_toplevel(); | |
| 1243 parse_info.set_allow_lazy_parsing(false); | 1239 parse_info.set_allow_lazy_parsing(false); |
| 1244 } | 1240 } |
| 1245 info.MarkAsDebug(); | 1241 info.MarkAsDebug(); |
| 1246 if (GetUnoptimizedCode(&info).is_null()) { | 1242 if (GetUnoptimizedCode(&info).is_null()) { |
| 1247 isolate->clear_pending_exception(); | 1243 isolate->clear_pending_exception(); |
| 1248 return false; | 1244 return false; |
| 1249 } | 1245 } |
| 1250 | 1246 |
| 1251 // Check postconditions on success. | 1247 // Check postconditions on success. |
| 1252 DCHECK(!isolate->has_pending_exception()); | 1248 DCHECK(!isolate->has_pending_exception()); |
| 1253 DCHECK(function->shared()->is_compiled()); | 1249 DCHECK(function->shared()->is_compiled()); |
| 1254 DCHECK(function->shared()->HasDebugCode()); | 1250 DCHECK(function->shared()->HasDebugCode()); |
| 1255 return true; | 1251 return true; |
| 1256 } | 1252 } |
| 1257 | 1253 |
| 1258 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { | 1254 bool Compiler::CompileDebugCode(Handle<SharedFunctionInfo> shared) { |
| 1259 Isolate* isolate = shared->GetIsolate(); | 1255 Isolate* isolate = shared->GetIsolate(); |
| 1260 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1256 DCHECK(AllowCompilation::IsAllowed(isolate)); |
| 1261 | 1257 |
| 1262 // Start a compilation. | 1258 // Start a compilation. |
| 1263 Zone zone(isolate->allocator()); | 1259 Zone zone(isolate->allocator()); |
| 1264 ParseInfo parse_info(&zone, shared); | 1260 ParseInfo parse_info(&zone, shared); |
| 1265 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1261 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
| 1266 if (IsEvalToplevel(shared)) { | 1262 if (IsEvalToplevel(shared)) { |
| 1267 parse_info.set_eval(); | 1263 parse_info.set_eval(); |
| 1268 parse_info.set_toplevel(); | |
| 1269 parse_info.set_allow_lazy_parsing(false); | 1264 parse_info.set_allow_lazy_parsing(false); |
| 1270 } | 1265 } |
| 1271 info.MarkAsDebug(); | 1266 info.MarkAsDebug(); |
| 1272 if (GetUnoptimizedCode(&info).is_null()) { | 1267 if (GetUnoptimizedCode(&info).is_null()) { |
| 1273 isolate->clear_pending_exception(); | 1268 isolate->clear_pending_exception(); |
| 1274 return false; | 1269 return false; |
| 1275 } | 1270 } |
| 1276 | 1271 |
| 1277 // Check postconditions on success. | 1272 // Check postconditions on success. |
| 1278 DCHECK(!isolate->has_pending_exception()); | 1273 DCHECK(!isolate->has_pending_exception()); |
| (...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 DCHECK(shared->is_compiled()); | 1853 DCHECK(shared->is_compiled()); |
| 1859 function->set_literals(cached.literals); | 1854 function->set_literals(cached.literals); |
| 1860 } else if (shared->is_compiled()) { | 1855 } else if (shared->is_compiled()) { |
| 1861 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. | 1856 // TODO(mvstanton): pass pretenure flag to EnsureLiterals. |
| 1862 JSFunction::EnsureLiterals(function); | 1857 JSFunction::EnsureLiterals(function); |
| 1863 } | 1858 } |
| 1864 } | 1859 } |
| 1865 | 1860 |
| 1866 } // namespace internal | 1861 } // namespace internal |
| 1867 } // namespace v8 | 1862 } // namespace v8 |
| OLD | NEW |