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 1070 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1081 if (!osr_ast_id.IsNone()) { | 1081 if (!osr_ast_id.IsNone()) { |
1082 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); | 1082 PrintF(" at OSR AST id %d", osr_ast_id.ToInt()); |
1083 } | 1083 } |
1084 PrintF("]\n"); | 1084 PrintF("]\n"); |
1085 } | 1085 } |
1086 return cached_code; | 1086 return cached_code; |
1087 } | 1087 } |
1088 | 1088 |
1089 DCHECK(AllowCompilation::IsAllowed(isolate)); | 1089 DCHECK(AllowCompilation::IsAllowed(isolate)); |
1090 | 1090 |
1091 if (!shared->is_compiled() || | 1091 if (shared->is_compiled()) { |
1092 shared->scope_info() == ScopeInfo::Empty(isolate)) { | 1092 shared->code()->set_profiler_ticks(0); |
1093 // The function was never compiled. Compile it unoptimized first. | |
1094 // TODO(titzer): reuse the AST and scope info from this compile. | |
1095 CompilationInfoWithZone unoptimized(function); | |
1096 unoptimized.EnableDeoptimizationSupport(); | |
1097 Handle<Code> unoptimized_code; | |
1098 if (!GetUnoptimizedCodeCommon(&unoptimized).ToHandle(&unoptimized_code)) { | |
1099 return MaybeHandle<Code>(); | |
1100 } | |
1101 shared->ReplaceCode(*unoptimized_code); | |
1102 } | 1093 } |
1103 | 1094 |
1104 shared->code()->set_profiler_ticks(0); | |
1105 | |
1106 // TODO(mstarzinger): We cannot properly deserialize a scope chain containing | 1095 // TODO(mstarzinger): We cannot properly deserialize a scope chain containing |
1107 // an eval scope and hence would fail at parsing the eval source again. | 1096 // an eval scope and hence would fail at parsing the eval source again. |
1108 if (shared->disable_optimization_reason() == kEval) { | 1097 if (shared->disable_optimization_reason() == kEval) { |
1109 return MaybeHandle<Code>(); | 1098 return MaybeHandle<Code>(); |
1110 } | 1099 } |
1111 | 1100 |
1112 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the | 1101 // TODO(mstarzinger): We cannot properly deserialize a scope chain for the |
1113 // builtin context, hence Genesis::InstallExperimentalNatives would fail. | 1102 // builtin context, hence Genesis::InstallExperimentalNatives would fail. |
1114 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { | 1103 if (shared->is_toplevel() && isolate->bootstrapper()->IsActive()) { |
1115 return MaybeHandle<Code>(); | 1104 return MaybeHandle<Code>(); |
(...skipping 858 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1974 | 1963 |
1975 #if DEBUG | 1964 #if DEBUG |
1976 void CompilationInfo::PrintAstForTesting() { | 1965 void CompilationInfo::PrintAstForTesting() { |
1977 PrintF("--- Source from AST ---\n%s\n", | 1966 PrintF("--- Source from AST ---\n%s\n", |
1978 PrettyPrinter(isolate()).PrintProgram(literal())); | 1967 PrettyPrinter(isolate()).PrintProgram(literal())); |
1979 } | 1968 } |
1980 #endif | 1969 #endif |
1981 | 1970 |
1982 } // namespace internal | 1971 } // namespace internal |
1983 } // namespace v8 | 1972 } // namespace v8 |
OLD | NEW |