OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/compiler.h" | 5 #include "vm/compiler.h" |
6 | 6 |
7 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
8 | 8 |
9 #include "vm/ast_printer.h" | 9 #include "vm/ast_printer.h" |
10 #include "vm/block_scheduler.h" | 10 #include "vm/block_scheduler.h" |
(...skipping 1674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1685 // evaluating the initializer value. | 1685 // evaluating the initializer value. |
1686 ASSERT(field.StaticValue() == Object::transition_sentinel().raw()); | 1686 ASSERT(field.StaticValue() == Object::transition_sentinel().raw()); |
1687 LongJumpScope jump; | 1687 LongJumpScope jump; |
1688 if (setjmp(*jump.Set()) == 0) { | 1688 if (setjmp(*jump.Set()) == 0) { |
1689 Thread* const thread = Thread::Current(); | 1689 Thread* const thread = Thread::Current(); |
1690 NoOOBMessageScope no_msg_scope(thread); | 1690 NoOOBMessageScope no_msg_scope(thread); |
1691 NoReloadScope no_reload_scope(thread->isolate(), thread); | 1691 NoReloadScope no_reload_scope(thread->isolate(), thread); |
1692 // Under lazy compilation initializer has not yet been created, so create | 1692 // Under lazy compilation initializer has not yet been created, so create |
1693 // it now, but don't bother remembering it because it won't be used again. | 1693 // it now, but don't bother remembering it because it won't be used again. |
1694 ASSERT(!field.HasPrecompiledInitializer()); | 1694 ASSERT(!field.HasPrecompiledInitializer()); |
1695 Function& initializer = Function::Handle(thread->zone()); | |
1696 { | 1695 { |
1697 #if !defined(PRODUCT) | 1696 #if !defined(PRODUCT) |
1698 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); | 1697 VMTagScope tagScope(thread, VMTag::kCompileUnoptimizedTagId); |
1699 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), | 1698 TimelineDurationScope tds(thread, Timeline::GetCompilerStream(), |
1700 "CompileStaticInitializer"); | 1699 "CompileStaticInitializer"); |
1701 if (tds.enabled()) { | 1700 if (tds.enabled()) { |
1702 tds.SetNumArguments(1); | 1701 tds.SetNumArguments(1); |
1703 tds.CopyArgument(0, "field", field.ToCString()); | 1702 tds.CopyArgument(0, "field", field.ToCString()); |
1704 } | 1703 } |
1705 #endif // !defined(PRODUCT) | 1704 #endif // !defined(PRODUCT) |
1706 | 1705 |
1707 StackZone stack_zone(thread); | 1706 StackZone stack_zone(thread); |
1708 Zone* zone = stack_zone.GetZone(); | 1707 Zone* zone = stack_zone.GetZone(); |
1709 ParsedFunction* parsed_function; | 1708 ParsedFunction* parsed_function; |
1710 | 1709 |
1711 // Create a one-time-use function to evaluate the initializer and invoke | 1710 // Create a one-time-use function to evaluate the initializer and invoke |
1712 // it immediately. | 1711 // it immediately. |
1713 if (field.kernel_field() != NULL) { | 1712 if (field.kernel_field() != NULL) { |
1714 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); | 1713 parsed_function = kernel::ParseStaticFieldInitializer(zone, field); |
1715 } else { | 1714 } else { |
1716 parsed_function = Parser::ParseStaticFieldInitializer(field); | 1715 parsed_function = Parser::ParseStaticFieldInitializer(field); |
1717 parsed_function->AllocateVariables(); | 1716 parsed_function->AllocateVariables(); |
1718 } | 1717 } |
1719 | 1718 |
1720 // Non-optimized code generator. | 1719 // Non-optimized code generator. |
1721 DartCompilationPipeline pipeline; | 1720 DartCompilationPipeline pipeline; |
1722 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); | 1721 CompileParsedFunctionHelper helper(parsed_function, false, kNoOSRDeoptId); |
1723 helper.Compile(&pipeline); | 1722 const Code& code = Code::Handle(helper.Compile(&pipeline)); |
Vyacheslav Egorov (Google)
2017/04/03 17:05:19
Maybe fix Compiler::ExecuteOnce(...) in the same w
kustermann
2017/04/03 17:35:18
Done.
| |
1724 initializer = parsed_function->function().raw(); | 1723 if (!code.IsNull()) { |
1725 Code::Handle(initializer.unoptimized_code()) | 1724 const Function& initializer = parsed_function->function(); |
1726 .set_var_descriptors(Object::empty_var_descriptors()); | 1725 code.set_var_descriptors(Object::empty_var_descriptors()); |
1726 // Invoke the function to evaluate the expression. | |
1727 return DartEntry::InvokeFunction(initializer, Object::empty_array()); | |
1728 } | |
1727 } | 1729 } |
1728 // Invoke the function to evaluate the expression. | |
1729 return DartEntry::InvokeFunction(initializer, Object::empty_array()); | |
1730 } else { | |
1731 Thread* const thread = Thread::Current(); | |
1732 StackZone zone(thread); | |
1733 const Error& error = Error::Handle(thread->zone(), thread->sticky_error()); | |
1734 thread->clear_sticky_error(); | |
1735 return error.raw(); | |
1736 } | 1730 } |
1737 UNREACHABLE(); | 1731 |
1738 return Object::null(); | 1732 Thread* const thread = Thread::Current(); |
1733 StackZone zone(thread); | |
1734 const Error& error = Error::Handle(thread->zone(), thread->sticky_error()); | |
1735 thread->clear_sticky_error(); | |
1736 return error.raw(); | |
1739 } | 1737 } |
1740 | 1738 |
1741 | 1739 |
1742 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { | 1740 RawObject* Compiler::ExecuteOnce(SequenceNode* fragment) { |
1743 #ifdef DART_PRECOMPILER | 1741 #ifdef DART_PRECOMPILER |
1744 if (FLAG_precompiled_mode) { | 1742 if (FLAG_precompiled_mode) { |
1745 return Precompiler::ExecuteOnce(fragment); | 1743 return Precompiler::ExecuteOnce(fragment); |
1746 } | 1744 } |
1747 #endif | 1745 #endif |
1748 LongJumpScope jump; | 1746 LongJumpScope jump; |
(...skipping 564 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2313 | 2311 |
2314 | 2312 |
2315 bool BackgroundCompiler::IsDisabled() { | 2313 bool BackgroundCompiler::IsDisabled() { |
2316 UNREACHABLE(); | 2314 UNREACHABLE(); |
2317 return true; | 2315 return true; |
2318 } | 2316 } |
2319 | 2317 |
2320 #endif // DART_PRECOMPILED_RUNTIME | 2318 #endif // DART_PRECOMPILED_RUNTIME |
2321 | 2319 |
2322 } // namespace dart | 2320 } // namespace dart |
OLD | NEW |