OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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/compilation-info.h" | 5 #include "src/compilation-info.h" |
6 | 6 |
7 #include "src/api.h" | 7 #include "src/api.h" |
8 #include "src/ast/ast.h" | 8 #include "src/ast/ast.h" |
9 #include "src/ast/scopes.h" | 9 #include "src/ast/scopes.h" |
10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
11 #include "src/parsing/parse-info.h" | 11 #include "src/parsing/parse-info.h" |
12 | 12 |
13 namespace v8 { | 13 namespace v8 { |
14 namespace internal { | 14 namespace internal { |
15 | 15 |
16 #define PARSE_INFO_GETTER(type, name) \ | 16 #define PARSE_INFO_GETTER(type, name) \ |
17 type CompilationInfo::name() const { \ | 17 type CompilationInfo::name() const { \ |
18 CHECK(parse_info()); \ | 18 CHECK(parse_info()); \ |
19 return parse_info()->name(); \ | 19 return parse_info()->name(); \ |
20 } | 20 } |
21 | 21 |
22 #define PARSE_INFO_GETTER_WITH_DEFAULT(type, name, def) \ | 22 #define PARSE_INFO_GETTER_WITH_DEFAULT(type, name, def) \ |
23 type CompilationInfo::name() const { \ | 23 type CompilationInfo::name() const { \ |
24 return parse_info() ? parse_info()->name() : def; \ | 24 return parse_info() ? parse_info()->name() : def; \ |
25 } | 25 } |
26 | 26 |
27 PARSE_INFO_GETTER(Handle<Script>, script) | 27 PARSE_INFO_GETTER(Handle<Script>, script) |
28 PARSE_INFO_GETTER(FunctionLiteral*, literal) | 28 PARSE_INFO_GETTER(FunctionLiteral*, literal) |
29 PARSE_INFO_GETTER_WITH_DEFAULT(DeclarationScope*, scope, nullptr) | 29 PARSE_INFO_GETTER_WITH_DEFAULT(DeclarationScope*, scope, nullptr) |
30 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, | |
31 Handle<Context>::null()) | |
32 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) | 30 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) |
33 | 31 |
34 #undef PARSE_INFO_GETTER | 32 #undef PARSE_INFO_GETTER |
35 #undef PARSE_INFO_GETTER_WITH_DEFAULT | 33 #undef PARSE_INFO_GETTER_WITH_DEFAULT |
36 | 34 |
37 bool CompilationInfo::has_shared_info() const { | 35 bool CompilationInfo::has_shared_info() const { |
38 return parse_info_ && !parse_info_->shared_info().is_null(); | 36 return parse_info_ && !parse_info_->shared_info().is_null(); |
39 } | 37 } |
40 | 38 |
41 CompilationInfo::CompilationInfo(ParseInfo* parse_info, | 39 CompilationInfo::CompilationInfo(ParseInfo* parse_info, |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 CompilationInfo::SourcePositionRecordingMode() const { | 169 CompilationInfo::SourcePositionRecordingMode() const { |
172 return parse_info() && parse_info()->is_native() | 170 return parse_info() && parse_info()->is_native() |
173 ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS | 171 ? SourcePositionTableBuilder::OMIT_SOURCE_POSITIONS |
174 : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS; | 172 : SourcePositionTableBuilder::RECORD_SOURCE_POSITIONS; |
175 } | 173 } |
176 | 174 |
177 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { | 175 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { |
178 return is_sloppy(parse_info()->language_mode()) && !parse_info()->is_native(); | 176 return is_sloppy(parse_info()->language_mode()) && !parse_info()->is_native(); |
179 } | 177 } |
180 | 178 |
| 179 bool CompilationInfo::has_context() const { return !closure().is_null(); } |
| 180 |
| 181 Context* CompilationInfo::context() const { |
| 182 return has_context() ? closure()->context() : nullptr; |
| 183 } |
| 184 |
181 bool CompilationInfo::has_native_context() const { | 185 bool CompilationInfo::has_native_context() const { |
182 return !closure().is_null() && (closure()->native_context() != nullptr); | 186 return !closure().is_null() && (closure()->native_context() != nullptr); |
183 } | 187 } |
184 | 188 |
185 Context* CompilationInfo::native_context() const { | 189 Context* CompilationInfo::native_context() const { |
186 return has_native_context() ? closure()->native_context() : nullptr; | 190 return has_native_context() ? closure()->native_context() : nullptr; |
187 } | 191 } |
188 | 192 |
189 bool CompilationInfo::has_global_object() const { return has_native_context(); } | 193 bool CompilationInfo::has_global_object() const { return has_native_context(); } |
190 | 194 |
(...skipping 13 matching lines...) Expand all Loading... |
204 inlined_functions_.push_back(InlinedFunctionHolder( | 208 inlined_functions_.push_back(InlinedFunctionHolder( |
205 inlined_function, handle(inlined_function->code()))); | 209 inlined_function, handle(inlined_function->code()))); |
206 } | 210 } |
207 | 211 |
208 Code::Kind CompilationInfo::output_code_kind() const { | 212 Code::Kind CompilationInfo::output_code_kind() const { |
209 return Code::ExtractKindFromFlags(code_flags_); | 213 return Code::ExtractKindFromFlags(code_flags_); |
210 } | 214 } |
211 | 215 |
212 } // namespace internal | 216 } // namespace internal |
213 } // namespace v8 | 217 } // namespace v8 |
OLD | NEW |