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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 TypeFeedbackVector::New(info->isolate(), feedback_metadata); | 491 TypeFeedbackVector::New(info->isolate(), feedback_metadata); |
492 info->shared_info()->set_feedback_vector(*feedback_vector); | 492 info->shared_info()->set_feedback_vector(*feedback_vector); |
493 } | 493 } |
494 | 494 |
495 // It's very important that recompiles do not alter the structure of the type | 495 // It's very important that recompiles do not alter the structure of the type |
496 // feedback vector. Verify that the structure fits the function literal. | 496 // feedback vector. Verify that the structure fits the function literal. |
497 CHECK(!info->shared_info()->feedback_vector()->metadata()->SpecDiffersFrom( | 497 CHECK(!info->shared_info()->feedback_vector()->metadata()->SpecDiffersFrom( |
498 info->literal()->feedback_vector_spec())); | 498 info->literal()->feedback_vector_spec())); |
499 } | 499 } |
500 | 500 |
501 bool CompileUnoptimizedCode(CompilationInfo* info) { | 501 bool UseIgnition(CompilationInfo* info) { |
502 DCHECK(AllowCompilation::IsAllowed(info->isolate())); | 502 // We only get here without a shared function info is when compiling a script |
503 if (!Compiler::Analyze(info->parse_info()) || | 503 // for live edit. We cannot (yet) use Ignition to compile for live edit. |
504 !(EnsureFeedbackVector(info), FullCodeGenerator::MakeCode(info))) { | 504 if (!info->has_shared_info()) { |
505 Isolate* isolate = info->isolate(); | 505 DCHECK(info->isolate()->debug()->live_edit_enabled()); |
506 if (!isolate->has_pending_exception()) isolate->StackOverflow(); | |
507 return false; | 506 return false; |
508 } | 507 } |
509 return true; | |
510 } | |
511 | 508 |
512 bool UseIgnition(CompilationInfo* info) { | |
513 // TODO(4681): Generator functions are not yet supported. | 509 // TODO(4681): Generator functions are not yet supported. |
514 if (info->shared_info()->is_generator()) { | 510 if (info->shared_info()->is_generator()) { |
515 return false; | 511 return false; |
516 } | 512 } |
517 | 513 |
518 // Checks whether top level functions should be passed by the filter. | 514 // Checks whether top level functions should be passed by the filter. |
519 if (info->shared_info()->is_toplevel()) { | 515 if (info->shared_info()->is_toplevel()) { |
520 Vector<const char> filter = CStrVector(FLAG_ignition_filter); | 516 Vector<const char> filter = CStrVector(FLAG_ignition_filter); |
521 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); | 517 return (filter.length() == 0) || (filter.length() == 1 && filter[0] == '*'); |
522 } | 518 } |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1066 DCHECK_NOT_NULL(info->literal()); | 1062 DCHECK_NOT_NULL(info->literal()); |
1067 if (!Rewriter::Rewrite(info)) return false; | 1063 if (!Rewriter::Rewrite(info)) return false; |
1068 if (!Scope::Analyze(info)) return false; | 1064 if (!Scope::Analyze(info)) return false; |
1069 if (!Renumber(info)) return false; | 1065 if (!Renumber(info)) return false; |
1070 DCHECK_NOT_NULL(info->scope()); | 1066 DCHECK_NOT_NULL(info->scope()); |
1071 return true; | 1067 return true; |
1072 } | 1068 } |
1073 | 1069 |
1074 bool Compiler::ParseAndAnalyze(ParseInfo* info) { | 1070 bool Compiler::ParseAndAnalyze(ParseInfo* info) { |
1075 if (!Parser::ParseStatic(info)) return false; | 1071 if (!Parser::ParseStatic(info)) return false; |
1076 return Compiler::Analyze(info); | 1072 if (!Compiler::Analyze(info)) return false; |
| 1073 DCHECK_NOT_NULL(info->literal()); |
| 1074 DCHECK_NOT_NULL(info->scope()); |
| 1075 return true; |
1077 } | 1076 } |
1078 | 1077 |
1079 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { | 1078 bool Compiler::Compile(Handle<JSFunction> function, ClearExceptionFlag flag) { |
1080 if (function->is_compiled()) return true; | 1079 if (function->is_compiled()) return true; |
1081 | 1080 |
1082 MaybeHandle<Code> maybe_code = GetLazyCode(function); | 1081 MaybeHandle<Code> maybe_code = GetLazyCode(function); |
1083 Handle<Code> code; | 1082 Handle<Code> code; |
1084 if (!maybe_code.ToHandle(&code)) { | 1083 if (!maybe_code.ToHandle(&code)) { |
1085 if (flag == CLEAR_EXCEPTION) { | 1084 if (flag == CLEAR_EXCEPTION) { |
1086 function->GetIsolate()->clear_pending_exception(); | 1085 function->GetIsolate()->clear_pending_exception(); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1199 ParseInfo parse_info(&zone, script); | 1198 ParseInfo parse_info(&zone, script); |
1200 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1199 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
1201 PostponeInterruptsScope postpone(info.isolate()); | 1200 PostponeInterruptsScope postpone(info.isolate()); |
1202 VMState<COMPILER> state(info.isolate()); | 1201 VMState<COMPILER> state(info.isolate()); |
1203 | 1202 |
1204 info.MarkAsDebug(); | 1203 info.MarkAsDebug(); |
1205 info.parse_info()->set_global(); | 1204 info.parse_info()->set_global(); |
1206 if (!Parser::ParseStatic(info.parse_info())) return; | 1205 if (!Parser::ParseStatic(info.parse_info())) return; |
1207 | 1206 |
1208 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); | 1207 LiveEditFunctionTracker tracker(info.isolate(), parse_info.literal()); |
1209 if (!CompileUnoptimizedCode(&info)) return; | 1208 if (!CompileBaselineCode(&info)) return; |
1210 tracker.RecordRootFunctionInfo(info.code()); | 1209 tracker.RecordRootFunctionInfo(info.code()); |
1211 } | 1210 } |
1212 | 1211 |
1213 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( | 1212 MaybeHandle<JSFunction> Compiler::GetFunctionFromEval( |
1214 Handle<String> source, Handle<SharedFunctionInfo> outer_info, | 1213 Handle<String> source, Handle<SharedFunctionInfo> outer_info, |
1215 Handle<Context> context, LanguageMode language_mode, | 1214 Handle<Context> context, LanguageMode language_mode, |
1216 ParseRestriction restriction, int line_offset, int column_offset, | 1215 ParseRestriction restriction, int line_offset, int column_offset, |
1217 Handle<Object> script_name, ScriptOriginOptions options) { | 1216 Handle<Object> script_name, ScriptOriginOptions options) { |
1218 Isolate* isolate = source->GetIsolate(); | 1217 Isolate* isolate = source->GetIsolate(); |
1219 int source_length = source->length(); | 1218 int source_length = source->length(); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1670 MaybeHandle<Code> code; | 1669 MaybeHandle<Code> code; |
1671 if (cached.code != nullptr) code = handle(cached.code); | 1670 if (cached.code != nullptr) code = handle(cached.code); |
1672 Handle<Context> native_context(function->context()->native_context()); | 1671 Handle<Context> native_context(function->context()->native_context()); |
1673 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1672 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1674 literals, BailoutId::None()); | 1673 literals, BailoutId::None()); |
1675 } | 1674 } |
1676 } | 1675 } |
1677 | 1676 |
1678 } // namespace internal | 1677 } // namespace internal |
1679 } // namespace v8 | 1678 } // namespace v8 |
OLD | NEW |