| 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 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 DCHECK(!isolate->has_pending_exception()); | 1235 DCHECK(!isolate->has_pending_exception()); |
| 1236 DCHECK(shared->is_compiled()); | 1236 DCHECK(shared->is_compiled()); |
| 1237 DCHECK(shared->HasDebugCode()); | 1237 DCHECK(shared->HasDebugCode()); |
| 1238 return true; | 1238 return true; |
| 1239 } | 1239 } |
| 1240 | 1240 |
| 1241 bool Compiler::CompileForLiveEdit(Handle<Script> script) { | 1241 bool Compiler::CompileForLiveEdit(Handle<Script> script) { |
| 1242 Isolate* isolate = script->GetIsolate(); | 1242 Isolate* isolate = script->GetIsolate(); |
| 1243 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1243 DCHECK(AllowCompilation::IsAllowed(isolate)); |
| 1244 | 1244 |
| 1245 // In order to ensure that live edit function info collection finds the newly |
| 1246 // generated shared function infos, clear the script's list temporarily |
| 1247 // and restore it at the end of this method. |
| 1248 Handle<Object> old_function_infos(script->shared_function_infos(), isolate); |
| 1249 script->set_shared_function_infos(Smi::FromInt(0)); |
| 1250 |
| 1245 // Start a compilation. | 1251 // Start a compilation. |
| 1246 Zone zone(isolate->allocator()); | 1252 Zone zone(isolate->allocator()); |
| 1247 ParseInfo parse_info(&zone, script); | 1253 ParseInfo parse_info(&zone, script); |
| 1248 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); | 1254 CompilationInfo info(&parse_info, Handle<JSFunction>::null()); |
| 1249 parse_info.set_global(); | 1255 parse_info.set_global(); |
| 1250 info.MarkAsDebug(); | 1256 info.MarkAsDebug(); |
| 1251 // TODO(635): support extensions. | 1257 // TODO(635): support extensions. |
| 1252 if (CompileToplevel(&info).is_null()) { | 1258 const bool compilation_succeeded = !CompileToplevel(&info).is_null(); |
| 1259 |
| 1260 // Restore the original function info list in order to remain side-effect |
| 1261 // free as much as possible, since some code expects the old shared function |
| 1262 // infos to stick around. |
| 1263 script->set_shared_function_infos(*old_function_infos); |
| 1264 |
| 1265 if (!compilation_succeeded) { |
| 1253 return false; | 1266 return false; |
| 1254 } | 1267 } |
| 1255 | 1268 |
| 1256 // Check postconditions on success. | 1269 // Check postconditions on success. |
| 1257 DCHECK(!isolate->has_pending_exception()); | 1270 DCHECK(!isolate->has_pending_exception()); |
| 1258 return true; | 1271 |
| 1272 return compilation_succeeded; |
| 1259 } | 1273 } |
| 1260 | 1274 |
| 1261 // TODO(turbofan): In the future, unoptimized code with deopt support could | 1275 // TODO(turbofan): In the future, unoptimized code with deopt support could |
| 1262 // be generated lazily once deopt is triggered. | 1276 // be generated lazily once deopt is triggered. |
| 1263 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { | 1277 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
| 1264 DCHECK_NOT_NULL(info->literal()); | 1278 DCHECK_NOT_NULL(info->literal()); |
| 1265 DCHECK_NOT_NULL(info->scope()); | 1279 DCHECK_NOT_NULL(info->scope()); |
| 1266 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1280 Handle<SharedFunctionInfo> shared = info->shared_info(); |
| 1267 if (!shared->has_deoptimization_support()) { | 1281 if (!shared->has_deoptimization_support()) { |
| 1268 Zone zone(info->isolate()->allocator()); | 1282 Zone zone(info->isolate()->allocator()); |
| (...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1760 MaybeHandle<Code> code; | 1774 MaybeHandle<Code> code; |
| 1761 if (cached.code != nullptr) code = handle(cached.code); | 1775 if (cached.code != nullptr) code = handle(cached.code); |
| 1762 Handle<Context> native_context(function->context()->native_context()); | 1776 Handle<Context> native_context(function->context()->native_context()); |
| 1763 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1777 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
| 1764 literals, BailoutId::None()); | 1778 literals, BailoutId::None()); |
| 1765 } | 1779 } |
| 1766 } | 1780 } |
| 1767 | 1781 |
| 1768 } // namespace internal | 1782 } // namespace internal |
| 1769 } // namespace v8 | 1783 } // namespace v8 |
| OLD | NEW |