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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 | 53 |
54 PARSE_INFO_GETTER(Handle<Script>, script) | 54 PARSE_INFO_GETTER(Handle<Script>, script) |
55 PARSE_INFO_GETTER(bool, is_eval) | 55 PARSE_INFO_GETTER(bool, is_eval) |
56 PARSE_INFO_GETTER(bool, is_native) | 56 PARSE_INFO_GETTER(bool, is_native) |
57 PARSE_INFO_GETTER(bool, is_module) | 57 PARSE_INFO_GETTER(bool, is_module) |
58 PARSE_INFO_GETTER(FunctionLiteral*, literal) | 58 PARSE_INFO_GETTER(FunctionLiteral*, literal) |
59 PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT) | 59 PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT) |
60 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure, | 60 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<JSFunction>, closure, |
61 Handle<JSFunction>::null()) | 61 Handle<JSFunction>::null()) |
62 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) | 62 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) |
63 PARSE_INFO_GETTER(Handle<Context>, context) | 63 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, |
| 64 Handle<Context>::null()) |
64 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) | 65 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) |
65 | 66 |
66 #undef PARSE_INFO_GETTER | 67 #undef PARSE_INFO_GETTER |
67 #undef PARSE_INFO_GETTER_WITH_DEFAULT | 68 #undef PARSE_INFO_GETTER_WITH_DEFAULT |
68 | 69 |
69 // A wrapper around a CompilationInfo that detaches the Handles from | 70 // A wrapper around a CompilationInfo that detaches the Handles from |
70 // the underlying DeferredHandleScope and stores them in info_ on | 71 // the underlying DeferredHandleScope and stores them in info_ on |
71 // destruction. | 72 // destruction. |
72 class CompilationHandleScope BASE_EMBEDDED { | 73 class CompilationHandleScope BASE_EMBEDDED { |
73 public: | 74 public: |
(...skipping 29 matching lines...) Expand all Loading... |
103 }; | 104 }; |
104 | 105 |
105 // ---------------------------------------------------------------------------- | 106 // ---------------------------------------------------------------------------- |
106 // Implementation of CompilationInfo | 107 // Implementation of CompilationInfo |
107 | 108 |
108 bool CompilationInfo::has_shared_info() const { | 109 bool CompilationInfo::has_shared_info() const { |
109 return parse_info_ && !parse_info_->shared_info().is_null(); | 110 return parse_info_ && !parse_info_->shared_info().is_null(); |
110 } | 111 } |
111 | 112 |
112 | 113 |
113 bool CompilationInfo::has_context() const { | |
114 return parse_info_ && !parse_info_->context().is_null(); | |
115 } | |
116 | |
117 | |
118 CompilationInfo::CompilationInfo(ParseInfo* parse_info) | 114 CompilationInfo::CompilationInfo(ParseInfo* parse_info) |
119 : CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION), | 115 : CompilationInfo(parse_info, nullptr, Code::ComputeFlags(Code::FUNCTION), |
120 BASE, parse_info->isolate(), parse_info->zone()) { | 116 BASE, parse_info->isolate(), parse_info->zone()) { |
121 // Compiling for the snapshot typically results in different code than | 117 // Compiling for the snapshot typically results in different code than |
122 // compiling later on. This means that code recompiled with deoptimization | 118 // compiling later on. This means that code recompiled with deoptimization |
123 // support won't be "equivalent" (as defined by SharedFunctionInfo:: | 119 // support won't be "equivalent" (as defined by SharedFunctionInfo:: |
124 // EnableDeoptimizationSupport), so it will replace the old code and all | 120 // EnableDeoptimizationSupport), so it will replace the old code and all |
125 // its type feedback. To avoid this, always compile functions in the snapshot | 121 // its type feedback. To avoid this, always compile functions in the snapshot |
126 // with deoptimization support. | 122 // with deoptimization support. |
127 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); | 123 if (isolate_->serializer_enabled()) EnableDeoptimizationSupport(); |
(...skipping 1770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1898 MaybeHandle<Code> code; | 1894 MaybeHandle<Code> code; |
1899 if (cached.code != nullptr) code = handle(cached.code); | 1895 if (cached.code != nullptr) code = handle(cached.code); |
1900 Handle<Context> native_context(function->context()->native_context()); | 1896 Handle<Context> native_context(function->context()->native_context()); |
1901 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1897 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1902 literals, BailoutId::None()); | 1898 literals, BailoutId::None()); |
1903 } | 1899 } |
1904 } | 1900 } |
1905 | 1901 |
1906 } // namespace internal | 1902 } // namespace internal |
1907 } // namespace v8 | 1903 } // namespace v8 |
OLD | NEW |