Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(665)

Side by Side Diff: runtime/vm/code_generator.cc

Issue 2771013002: Add more safe points in compiler (Closed)
Patch Set: Fix logic error in compiler code installation, more safe points, remove safe point in zone code, ni… Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | runtime/vm/flow_graph.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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/code_generator.h" 5 #include "vm/code_generator.h"
6 6
7 #include "vm/assembler.h" 7 #include "vm/assembler.h"
8 #include "vm/ast.h" 8 #include "vm/ast.h"
9 #include "vm/code_patcher.h" 9 #include "vm/code_patcher.h"
10 #include "vm/compiler.h" 10 #include "vm/compiler.h"
(...skipping 1688 matching lines...) Expand 10 before | Expand all | Expand 10 after
1699 ASSERT(function.unoptimized_code() != Object::null()); 1699 ASSERT(function.unoptimized_code() != Object::null());
1700 intptr_t osr_id = 1700 intptr_t osr_id =
1701 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc()); 1701 Code::Handle(function.unoptimized_code()).GetDeoptIdForOsr(frame->pc());
1702 ASSERT(osr_id != Compiler::kNoOSRDeoptId); 1702 ASSERT(osr_id != Compiler::kNoOSRDeoptId);
1703 if (FLAG_trace_osr) { 1703 if (FLAG_trace_osr) {
1704 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n", 1704 OS::Print("Attempting OSR for %s at id=%" Pd ", count=%" Pd "\n",
1705 function.ToFullyQualifiedCString(), osr_id, 1705 function.ToFullyQualifiedCString(), osr_id,
1706 function.usage_counter()); 1706 function.usage_counter());
1707 } 1707 }
1708 1708
1709 // We need to save the original code because the way we check for the
1710 // success of the compiler pipeline is to see if it installed the new code.
1711 // We also need the original because the pipeline installs the code even
1712 // though it is OSR code and not usable for normal entry.
1709 const Code& original_code = Code::Handle(function.CurrentCode()); 1713 const Code& original_code = Code::Handle(function.CurrentCode());
1714
1710 // Since the code is referenced from the frame and the ZoneHandle, 1715 // Since the code is referenced from the frame and the ZoneHandle,
1711 // it cannot have been removed from the function. 1716 // it cannot have been removed from the function.
1712 ASSERT(!original_code.IsNull()); 1717 ASSERT(!original_code.IsNull());
1713 const Error& error = Error::Handle( 1718 const Error& error = Error::Handle(
1714 Compiler::CompileOptimizedFunction(thread, function, osr_id)); 1719 Compiler::CompileOptimizedFunction(thread, function, osr_id));
1715 if (!error.IsNull()) { 1720 if (!error.IsNull()) {
1716 Exceptions::PropagateError(error); 1721 Exceptions::PropagateError(error);
1717 } 1722 }
1718 1723
1719 const Code& optimized_code = Code::Handle(function.CurrentCode()); 1724 const Code& optimized_code = Code::Handle(function.CurrentCode());
1720 // The current code will not be changed in the case that the compiler 1725 // The current code will not be changed in the case that the compiler
1721 // bailed out during OSR compilation. 1726 // bailed out during OSR compilation.
1722 if (optimized_code.raw() != original_code.raw()) { 1727 if (optimized_code.raw() != original_code.raw()) {
1723 // The OSR code does not work for calling the function, so restore the 1728 // The OSR code does not work for calling the function, so restore the
1724 // unoptimized code. Patch the stack frame to return into the OSR 1729 // unoptimized code. Patch the stack frame to return into the OSR
1725 // code. 1730 // code.
1726 uword optimized_entry = 1731 uword optimized_entry =
1727 Instructions::UncheckedEntryPoint(optimized_code.instructions()); 1732 Instructions::UncheckedEntryPoint(optimized_code.instructions());
1733 // Unfortunately, while we were compiling, the background compiler may
Vyacheslav Egorov (Google) 2017/03/27 14:11:51 The comment is inaccurate: it is background compil
erikcorry 2017/03/30 14:10:19 I now made more serious changes to this section in
1734 // have completed a non-OSR compilation of the same code. Our call to the
1735 // compiler overwrote the optimized version with an unusable OSR version,
1736 // which doesn't have the right entry point. If it did that it also
1737 // disabled the old version, so we have to reenable it before we install
1738 // it. See https://github.com/dart-lang/sdk/issues/29160
1739 original_code.Enable();
1728 function.AttachCode(original_code); 1740 function.AttachCode(original_code);
1729 frame->set_pc(optimized_entry); 1741 frame->set_pc(optimized_entry);
1730 frame->set_pc_marker(optimized_code.raw()); 1742 frame->set_pc_marker(optimized_code.raw());
1731 } 1743 }
1732 } 1744 }
1733 } 1745 }
1734 1746
1735 1747
1736 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) { 1748 DEFINE_RUNTIME_ENTRY(TraceICCall, 2) {
1737 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0)); 1749 const ICData& ic_data = ICData::CheckedHandle(arguments.ArgAt(0));
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 const intptr_t elm_size = old_data.ElementSizeInBytes(); 2273 const intptr_t elm_size = old_data.ElementSizeInBytes();
2262 const TypedData& new_data = 2274 const TypedData& new_data =
2263 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld)); 2275 TypedData::Handle(TypedData::New(cid, new_size, Heap::kOld));
2264 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size); 2276 TypedData::Copy(new_data, 0, old_data, 0, old_size * elm_size);
2265 typed_data_cell.SetAt(0, new_data); 2277 typed_data_cell.SetAt(0, new_data);
2266 arguments.SetReturn(new_data); 2278 arguments.SetReturn(new_data);
2267 } 2279 }
2268 2280
2269 2281
2270 } // namespace dart 2282 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler.cc » ('j') | runtime/vm/flow_graph.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698