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(); |
1253 return false; | 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) { | |
1266 // Check postconditions on success. | |
1267 DCHECK(!isolate->has_pending_exception()); | |
Yang
2016/05/12 07:43:14
We could just rephrase this as DCHECK(!compilation
jgruber1
2016/05/12 08:26:46
Rewrote this part to again exit early on compilati
| |
1254 } | 1268 } |
1255 | 1269 |
1256 // Check postconditions on success. | 1270 return compilation_succeeded; |
1257 DCHECK(!isolate->has_pending_exception()); | |
1258 return true; | |
1259 } | 1271 } |
1260 | 1272 |
1261 // TODO(turbofan): In the future, unoptimized code with deopt support could | 1273 // TODO(turbofan): In the future, unoptimized code with deopt support could |
1262 // be generated lazily once deopt is triggered. | 1274 // be generated lazily once deopt is triggered. |
1263 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { | 1275 bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { |
1264 DCHECK_NOT_NULL(info->literal()); | 1276 DCHECK_NOT_NULL(info->literal()); |
1265 DCHECK_NOT_NULL(info->scope()); | 1277 DCHECK_NOT_NULL(info->scope()); |
1266 Handle<SharedFunctionInfo> shared = info->shared_info(); | 1278 Handle<SharedFunctionInfo> shared = info->shared_info(); |
1267 if (!shared->has_deoptimization_support()) { | 1279 if (!shared->has_deoptimization_support()) { |
1268 Zone zone(info->isolate()->allocator()); | 1280 Zone zone(info->isolate()->allocator()); |
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 MaybeHandle<Code> code; | 1772 MaybeHandle<Code> code; |
1761 if (cached.code != nullptr) code = handle(cached.code); | 1773 if (cached.code != nullptr) code = handle(cached.code); |
1762 Handle<Context> native_context(function->context()->native_context()); | 1774 Handle<Context> native_context(function->context()->native_context()); |
1763 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1775 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1764 literals, BailoutId::None()); | 1776 literals, BailoutId::None()); |
1765 } | 1777 } |
1766 } | 1778 } |
1767 | 1779 |
1768 } // namespace internal | 1780 } // namespace internal |
1769 } // namespace v8 | 1781 } // namespace v8 |
OLD | NEW |