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-numbering.h" | 9 #include "src/ast-numbering.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
105 : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(), | 105 : CompilationInfo(parse_info, nullptr, BASE, parse_info->isolate(), |
106 parse_info->zone()) { | 106 parse_info->zone()) { |
107 // Compiling for the snapshot typically results in different code than | 107 // Compiling for the snapshot typically results in different code than |
108 // compiling later on. This means that code recompiled with deoptimization | 108 // compiling later on. This means that code recompiled with deoptimization |
109 // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 109 // support won't be "equivalent" (as defined by SharedFunctionInfo:: |
110 // EnableDeoptimizationSupport), so it will replace the old code and all | 110 // EnableDeoptimizationSupport), so it will replace the old code and all |
111 // its type feedback. To avoid this, always compile functions in the snapshot | 111 // its type feedback. To avoid this, always compile functions in the snapshot |
112 // with deoptimization support. | 112 // with deoptimization support. |
113 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 113 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); |
114 | 114 |
| 115 if (isolate_->debug()->is_active()) MarkAsDebug(); |
115 if (FLAG_context_specialization) MarkAsContextSpecializing(); | 116 if (FLAG_context_specialization) MarkAsContextSpecializing(); |
116 if (FLAG_turbo_inlining) MarkAsInliningEnabled(); | 117 if (FLAG_turbo_inlining) MarkAsInliningEnabled(); |
117 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); | 118 if (FLAG_turbo_source_positions) MarkAsSourcePositionsEnabled(); |
118 if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); | 119 if (FLAG_turbo_splitting) MarkAsSplittingEnabled(); |
119 if (FLAG_turbo_types) MarkAsTypingEnabled(); | 120 if (FLAG_turbo_types) MarkAsTypingEnabled(); |
120 | 121 |
121 if (has_shared_info()) { | 122 if (has_shared_info()) { |
122 if (shared_info()->is_compiled()) { | 123 if (shared_info()->is_compiled()) { |
123 // We should initialize the CompilationInfo feedback vector from the | 124 // We should initialize the CompilationInfo feedback vector from the |
124 // passed in shared info, rather than creating a new one. | 125 // passed in shared info, rather than creating a new one. |
(...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1158 script->set_origin_options(options); | 1159 script->set_origin_options(options); |
1159 Zone zone; | 1160 Zone zone; |
1160 ParseInfo parse_info(&zone, script); | 1161 ParseInfo parse_info(&zone, script); |
1161 CompilationInfo info(&parse_info); | 1162 CompilationInfo info(&parse_info); |
1162 parse_info.set_eval(); | 1163 parse_info.set_eval(); |
1163 if (context->IsNativeContext()) parse_info.set_global(); | 1164 if (context->IsNativeContext()) parse_info.set_global(); |
1164 parse_info.set_language_mode(language_mode); | 1165 parse_info.set_language_mode(language_mode); |
1165 parse_info.set_parse_restriction(restriction); | 1166 parse_info.set_parse_restriction(restriction); |
1166 parse_info.set_context(context); | 1167 parse_info.set_context(context); |
1167 | 1168 |
1168 info.MarkAsDebug(); | 1169 // If we eval from debug code, compile for debugging as well. |
| 1170 if (outer_info->HasDebugCode()) info.MarkAsDebug(); |
1169 Debug::RecordEvalCaller(script); | 1171 Debug::RecordEvalCaller(script); |
1170 | 1172 |
1171 shared_info = CompileToplevel(&info); | 1173 shared_info = CompileToplevel(&info); |
1172 | 1174 |
1173 if (shared_info.is_null()) { | 1175 if (shared_info.is_null()) { |
1174 return MaybeHandle<JSFunction>(); | 1176 return MaybeHandle<JSFunction>(); |
1175 } else { | 1177 } else { |
1176 // Explicitly disable optimization for eval code. We're not yet prepared | 1178 // Explicitly disable optimization for eval code. We're not yet prepared |
1177 // to handle eval-code in the optimizing compiler. | 1179 // to handle eval-code in the optimizing compiler. |
1178 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { | 1180 if (restriction != ONLY_SINGLE_FUNCTION_LITERAL) { |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1623 | 1625 |
1624 | 1626 |
1625 #if DEBUG | 1627 #if DEBUG |
1626 void CompilationInfo::PrintAstForTesting() { | 1628 void CompilationInfo::PrintAstForTesting() { |
1627 PrintF("--- Source from AST ---\n%s\n", | 1629 PrintF("--- Source from AST ---\n%s\n", |
1628 PrettyPrinter(isolate(), zone()).PrintProgram(function())); | 1630 PrettyPrinter(isolate(), zone()).PrintProgram(function())); |
1629 } | 1631 } |
1630 #endif | 1632 #endif |
1631 } // namespace internal | 1633 } // namespace internal |
1632 } // namespace v8 | 1634 } // namespace v8 |
OLD | NEW |