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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 type CompilationInfo::name() const { \ | 47 type CompilationInfo::name() const { \ |
48 return parse_info() ? parse_info()->name() : def; \ | 48 return parse_info() ? parse_info()->name() : def; \ |
49 } | 49 } |
50 | 50 |
51 | 51 |
52 PARSE_INFO_GETTER(Handle<Script>, script) | 52 PARSE_INFO_GETTER(Handle<Script>, script) |
53 PARSE_INFO_GETTER(bool, is_eval) | 53 PARSE_INFO_GETTER(bool, is_eval) |
54 PARSE_INFO_GETTER(bool, is_native) | 54 PARSE_INFO_GETTER(bool, is_native) |
55 PARSE_INFO_GETTER(bool, is_module) | 55 PARSE_INFO_GETTER(bool, is_module) |
56 PARSE_INFO_GETTER(FunctionLiteral*, literal) | 56 PARSE_INFO_GETTER(FunctionLiteral*, literal) |
57 PARSE_INFO_GETTER_WITH_DEFAULT(LanguageMode, language_mode, STRICT) | |
58 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) | 57 PARSE_INFO_GETTER_WITH_DEFAULT(Scope*, scope, nullptr) |
59 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, | 58 PARSE_INFO_GETTER_WITH_DEFAULT(Handle<Context>, context, |
60 Handle<Context>::null()) | 59 Handle<Context>::null()) |
61 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) | 60 PARSE_INFO_GETTER(Handle<SharedFunctionInfo>, shared_info) |
62 | 61 |
63 #undef PARSE_INFO_GETTER | 62 #undef PARSE_INFO_GETTER |
64 #undef PARSE_INFO_GETTER_WITH_DEFAULT | 63 #undef PARSE_INFO_GETTER_WITH_DEFAULT |
65 | 64 |
66 // A wrapper around a CompilationInfo that detaches the Handles from | 65 // A wrapper around a CompilationInfo that detaches the Handles from |
67 // the underlying DeferredHandleScope and stores them in info_ on | 66 // the underlying DeferredHandleScope and stores them in info_ on |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
263 return StackFrame::JS_TO_WASM; | 262 return StackFrame::JS_TO_WASM; |
264 case Code::WASM_TO_JS_FUNCTION: | 263 case Code::WASM_TO_JS_FUNCTION: |
265 return StackFrame::WASM_TO_JS; | 264 return StackFrame::WASM_TO_JS; |
266 default: | 265 default: |
267 UNIMPLEMENTED(); | 266 UNIMPLEMENTED(); |
268 return StackFrame::NONE; | 267 return StackFrame::NONE; |
269 } | 268 } |
270 } | 269 } |
271 | 270 |
272 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { | 271 bool CompilationInfo::ExpectsJSReceiverAsReceiver() { |
273 return is_sloppy(language_mode()) && !is_native(); | 272 return is_sloppy(parse_info()->language_mode()) && !is_native(); |
274 } | 273 } |
275 | 274 |
276 #if DEBUG | 275 #if DEBUG |
277 void CompilationInfo::PrintAstForTesting() { | 276 void CompilationInfo::PrintAstForTesting() { |
278 PrintF("--- Source from AST ---\n%s\n", | 277 PrintF("--- Source from AST ---\n%s\n", |
279 PrettyPrinter(isolate()).PrintProgram(literal())); | 278 PrettyPrinter(isolate()).PrintProgram(literal())); |
280 } | 279 } |
281 #endif | 280 #endif |
282 | 281 |
283 // ---------------------------------------------------------------------------- | 282 // ---------------------------------------------------------------------------- |
(...skipping 1236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1520 } | 1519 } |
1521 parse_info.set_compile_options(compile_options); | 1520 parse_info.set_compile_options(compile_options); |
1522 parse_info.set_extension(extension); | 1521 parse_info.set_extension(extension); |
1523 parse_info.set_context(context); | 1522 parse_info.set_context(context); |
1524 if (FLAG_serialize_toplevel && | 1523 if (FLAG_serialize_toplevel && |
1525 compile_options == ScriptCompiler::kProduceCodeCache) { | 1524 compile_options == ScriptCompiler::kProduceCodeCache) { |
1526 info.PrepareForSerializing(); | 1525 info.PrepareForSerializing(); |
1527 } | 1526 } |
1528 | 1527 |
1529 parse_info.set_language_mode( | 1528 parse_info.set_language_mode( |
1530 static_cast<LanguageMode>(info.language_mode() | language_mode)); | 1529 static_cast<LanguageMode>(parse_info.language_mode() | language_mode)); |
1531 result = CompileToplevel(&info); | 1530 result = CompileToplevel(&info); |
1532 if (extension == NULL && !result.is_null()) { | 1531 if (extension == NULL && !result.is_null()) { |
1533 compilation_cache->PutScript(source, context, language_mode, result); | 1532 compilation_cache->PutScript(source, context, language_mode, result); |
1534 if (FLAG_serialize_toplevel && | 1533 if (FLAG_serialize_toplevel && |
1535 compile_options == ScriptCompiler::kProduceCodeCache) { | 1534 compile_options == ScriptCompiler::kProduceCodeCache) { |
1536 HistogramTimerScope histogram_timer( | 1535 HistogramTimerScope histogram_timer( |
1537 isolate->counters()->compile_serialize()); | 1536 isolate->counters()->compile_serialize()); |
1538 TRACE_EVENT0("v8", "V8.CompileSerialize"); | 1537 TRACE_EVENT0("v8", "V8.CompileSerialize"); |
1539 *cached_data = CodeSerializer::Serialize(isolate, result, source); | 1538 *cached_data = CodeSerializer::Serialize(isolate, result, source); |
1540 if (FLAG_profile_deserialization) { | 1539 if (FLAG_profile_deserialization) { |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1806 MaybeHandle<Code> code; | 1805 MaybeHandle<Code> code; |
1807 if (cached.code != nullptr) code = handle(cached.code); | 1806 if (cached.code != nullptr) code = handle(cached.code); |
1808 Handle<Context> native_context(function->context()->native_context()); | 1807 Handle<Context> native_context(function->context()->native_context()); |
1809 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, | 1808 SharedFunctionInfo::AddToOptimizedCodeMap(shared, native_context, code, |
1810 literals, BailoutId::None()); | 1809 literals, BailoutId::None()); |
1811 } | 1810 } |
1812 } | 1811 } |
1813 | 1812 |
1814 } // namespace internal | 1813 } // namespace internal |
1815 } // namespace v8 | 1814 } // namespace v8 |
OLD | NEW |