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 1068 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1079 if (!osr_ast_id.IsNone()) { | 1079 if (!osr_ast_id.IsNone()) { |
1080 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 1080 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
1081 } | 1081 } |
1082 PrintF("]\n"); | 1082 PrintF("]\n"); |
1083 } | 1083 } |
1084 return cached_code; | 1084 return cached_code; |
1085 } | 1085 } |
1086 | 1086 |
1087 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1087 DCHECK(AllowCompilation::IsAllowed(isolate)); |
1088 | 1088 |
1089 Handle<Code> current_code(shared->code()); | |
1090 if (!shared->is_compiled() || | 1089 if (!shared->is_compiled() || |
1091 shared->scope_info() == ScopeInfo::Empty(isolate)) { | 1090 shared->scope_info() == ScopeInfo::Empty(isolate)) { |
1092 // The function was never compiled. Compile it unoptimized first. | 1091 // The function was never compiled. Compile it unoptimized first. |
1093 // TODO(titzer): reuse the AST and scope info from this compile. | 1092 // TODO(titzer): reuse the AST and scope info from this compile. |
1094 CompilationInfoWithZone unoptimized(function); | 1093 CompilationInfoWithZone unoptimized(function); |
1095 unoptimized.EnableDeoptimizationSupport(); | 1094 unoptimized.EnableDeoptimizationSupport(); |
1096 if (!GetUnoptimizedCodeCommon(&unoptimized).ToHandle(¤t_code)) { | 1095 Handle<Code> unoptimized_code; |
| 1096 if (!GetUnoptimizedCodeCommon(&unoptimized).ToHandle(&unoptimized_code)) { |
1097 return MaybeHandle<Code>(); | 1097 return MaybeHandle<Code>(); |
1098 } | 1098 } |
1099 shared->ReplaceCode(*current_code); | 1099 shared->ReplaceCode(*unoptimized_code); |
1100 } | 1100 } |
1101 | 1101 |
1102 current_code->set_profiler_ticks(0); | 1102 shared->code()->set_profiler_ticks(0); |
1103 | 1103 |
1104 // TODO(mstarzinger): We cannot properly deserialize a scope chain containing | 1104 // TODO(mstarzinger): We cannot properly deserialize a scope chain containing |
1105 // an eval scope and hence would fail at parsing the eval source again. | 1105 // an eval scope and hence would fail at parsing the eval source again. |
1106 if (shared->disable_optimization_reason() == kEval) { | 1106 if (shared->disable_optimization_reason() == kEval) { |
1107 return MaybeHandle<Code>(); | 1107 return MaybeHandle<Code>(); |
1108 } | 1108 } |
1109 | 1109 |
1110 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the | 1110 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the |
1111 // builtin context, hence Genesis::InstallExperimentalNatives would fail. | 1111 // builtin context, hence Genesis::InstallExperimentalNatives would fail. |
1112 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { | 1112 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { |
1113 return MaybeHandle<Code>(); | 1113 return MaybeHandle<Code>(); |
1114 } | 1114 } |
1115 | 1115 |
1116 base::SmartPointer<CompilationInfo> info( | 1116 base::SmartPointer<CompilationInfo> info( |
1117 new CompilationInfoWithZone(function)); | 1117 new CompilationInfoWithZone(function)); |
1118 VMState<COMPILER> state(isolate); | 1118 VMState<COMPILER> state(isolate); |
1119 DCHECK(!isolate->has_pending_exception()); | 1119 DCHECK(!isolate->has_pending_exception()); |
1120 PostponeInterruptsScope postpone(isolate); | 1120 PostponeInterruptsScope postpone(isolate); |
1121 | 1121 |
1122 info->SetOptimizingForOsr(osr_ast_id, current_code); | 1122 info->SetOptimizingForOsr(osr_ast_id); |
1123 | 1123 |
1124 if (mode == Compiler::CONCURRENT) { | 1124 if (mode == Compiler::CONCURRENT) { |
1125 if (GetOptimizedCodeLater(info.get())) { | 1125 if (GetOptimizedCodeLater(info.get())) { |
1126 info.Detach(); // The background recompile job owns this now. | 1126 info.Detach(); // The background recompile job owns this now. |
1127 return isolate->builtins()->InOptimizationQueue(); | 1127 return isolate->builtins()->InOptimizationQueue(); |
1128 } | 1128 } |
1129 } else { | 1129 } else { |
1130 info->set_osr_frame(osr_frame); | 1130 info->set_osr_frame(osr_frame); |
1131 if (GetOptimizedCodeNow(info.get())) return info->code(); | 1131 if (GetOptimizedCodeNow(info.get())) return info->code(); |
1132 } | 1132 } |
(...skipping 839 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1972 | 1972 |
1973 #if DEBUG | 1973 #if DEBUG |
1974 void CompilationInfo::PrintAstForTesting() { | 1974 void CompilationInfo::PrintAstForTesting() { |
1975 PrintF("--- Source from AST ---\n%s\n", | 1975 PrintF("--- Source from AST ---\n%s\n", |
1976 PrettyPrinter(isolate()).PrintProgram(literal())); | 1976 PrettyPrinter(isolate()).PrintProgram(literal())); |
1977 } | 1977 } |
1978 #endif | 1978 #endif |
1979 | 1979 |
1980 } // namespace internal | 1980 } // namespace internal |
1981 } // namespace v8 | 1981 } // namespace v8 |
OLD | NEW |