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

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

Issue 136563002: Landing: Write protect executable pages in the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 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 | Annotate | Revision Log
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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
742 Error::Handle(Compiler::CompileFunction(target_function)); 742 Error::Handle(Compiler::CompileFunction(target_function));
743 if (!error.IsNull()) { 743 if (!error.IsNull()) {
744 Exceptions::PropagateError(error); 744 Exceptions::PropagateError(error);
745 } 745 }
746 } 746 }
747 const Code& target_code = Code::Handle(target_function.CurrentCode()); 747 const Code& target_code = Code::Handle(target_function.CurrentCode());
748 // Before patching verify that we are not repeatedly patching to the same 748 // Before patching verify that we are not repeatedly patching to the same
749 // target. 749 // target.
750 ASSERT(target_code.EntryPoint() != 750 ASSERT(target_code.EntryPoint() !=
751 CodePatcher::GetStaticCallTargetAt(caller_frame->pc(), caller_code)); 751 CodePatcher::GetStaticCallTargetAt(caller_frame->pc(), caller_code));
752 CodePatcher::PatchStaticCallAt(caller_frame->pc(), caller_code, 752 const Instructions& instrs =
753 target_code.EntryPoint()); 753 Instructions::Handle(caller_code.instructions());
754 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code); 754 {
755 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
756 CodePatcher::PatchStaticCallAt(caller_frame->pc(), caller_code,
757 target_code.EntryPoint());
758 caller_code.SetStaticCallTargetCodeAt(caller_frame->pc(), target_code);
759 }
755 if (FLAG_trace_patching) { 760 if (FLAG_trace_patching) {
756 OS::PrintErr("PatchStaticCall: patching from %#" Px " to '%s' %#" Px "\n", 761 OS::PrintErr("PatchStaticCall: patching from %#" Px " to '%s' %#" Px "\n",
757 caller_frame->pc(), 762 caller_frame->pc(),
758 target_function.ToFullyQualifiedCString(), 763 target_function.ToFullyQualifiedCString(),
759 target_code.EntryPoint()); 764 target_code.EntryPoint());
760 } 765 }
761 arguments.SetReturn(target_code); 766 arguments.SetReturn(target_code);
762 } 767 }
763 768
764 769
(...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); 1476 caller_code.GetStaticCallTargetFunctionAt(frame->pc()));
1472 const Code& target_code = Code::Handle( 1477 const Code& target_code = Code::Handle(
1473 caller_code.GetStaticCallTargetCodeAt(frame->pc())); 1478 caller_code.GetStaticCallTargetCodeAt(frame->pc()));
1474 ASSERT(!target_code.IsNull()); 1479 ASSERT(!target_code.IsNull());
1475 // Since there was a reference to the target_code in the caller_code, it is 1480 // Since there was a reference to the target_code in the caller_code, it is
1476 // not possible for the target_function's code to be disconnected. 1481 // not possible for the target_function's code to be disconnected.
1477 ASSERT(target_function.HasCode()); 1482 ASSERT(target_function.HasCode());
1478 ASSERT(target_function.raw() == target_code.function()); 1483 ASSERT(target_function.raw() == target_code.function());
1479 1484
1480 const Code& current_target_code = Code::Handle(target_function.CurrentCode()); 1485 const Code& current_target_code = Code::Handle(target_function.CurrentCode());
1481 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, 1486 const Instructions& instrs = Instructions::Handle(caller_code.instructions());
1482 current_target_code.EntryPoint()); 1487 {
1483 caller_code.SetStaticCallTargetCodeAt(frame->pc(), current_target_code); 1488 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
1489 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code,
1490 current_target_code.EntryPoint());
1491 caller_code.SetStaticCallTargetCodeAt(frame->pc(), current_target_code);
1492 }
1484 if (FLAG_trace_patching) { 1493 if (FLAG_trace_patching) {
1485 OS::PrintErr("FixCallersTarget: patching from %#" Px " to '%s' %#" Px "\n", 1494 OS::PrintErr("FixCallersTarget: patching from %#" Px " to '%s' %#" Px "\n",
1486 frame->pc(), 1495 frame->pc(),
1487 target_function.ToFullyQualifiedCString(), 1496 target_function.ToFullyQualifiedCString(),
1488 current_target_code.EntryPoint()); 1497 current_target_code.EntryPoint());
1489 } 1498 }
1490 arguments.SetReturn(current_target_code); 1499 arguments.SetReturn(current_target_code);
1491 } 1500 }
1492 1501
1493 1502
(...skipping 19 matching lines...) Expand all
1513 const Code& unoptimized_code = Code::Handle(function.unoptimized_code()); 1522 const Code& unoptimized_code = Code::Handle(function.unoptimized_code());
1514 ASSERT(!unoptimized_code.IsNull()); 1523 ASSERT(!unoptimized_code.IsNull());
1515 // The switch to unoptimized code may have already occurred. 1524 // The switch to unoptimized code may have already occurred.
1516 if (function.HasOptimizedCode()) { 1525 if (function.HasOptimizedCode()) {
1517 function.SwitchToUnoptimizedCode(); 1526 function.SwitchToUnoptimizedCode();
1518 } 1527 }
1519 // Patch call site (lazy deoptimization is quite rare, patching it twice 1528 // Patch call site (lazy deoptimization is quite rare, patching it twice
1520 // is not a performance issue). 1529 // is not a performance issue).
1521 uword lazy_deopt_jump = optimized_code.GetLazyDeoptPc(); 1530 uword lazy_deopt_jump = optimized_code.GetLazyDeoptPc();
1522 ASSERT(lazy_deopt_jump != 0); 1531 ASSERT(lazy_deopt_jump != 0);
1523 CodePatcher::InsertCallAt(pc, lazy_deopt_jump); 1532 const Instructions& instrs =
1533 Instructions::Handle(optimized_code.instructions());
1534 {
1535 WritableInstructionsScope writable(instrs.EntryPoint(), instrs.size());
1536 CodePatcher::InsertCallAt(pc, lazy_deopt_jump);
1537 }
1524 // Mark code as dead (do not GC its embedded objects). 1538 // Mark code as dead (do not GC its embedded objects).
1525 optimized_code.set_is_alive(false); 1539 optimized_code.set_is_alive(false);
1526 } 1540 }
1527 1541
1528 1542
1529 // Currently checks only that all optimized frames have kDeoptIndex 1543 // Currently checks only that all optimized frames have kDeoptIndex
1530 // and unoptimized code has the kDeoptAfter. 1544 // and unoptimized code has the kDeoptAfter.
1531 void DeoptimizeAll() { 1545 void DeoptimizeAll() {
1532 DartFrameIterator iterator; 1546 DartFrameIterator iterator;
1533 StackFrame* frame = iterator.NextFrame(); 1547 StackFrame* frame = iterator.NextFrame();
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
1739 // of the given value. 1753 // of the given value.
1740 // Arg0: Field object; 1754 // Arg0: Field object;
1741 // Arg1: Value that is being stored. 1755 // Arg1: Value that is being stored.
1742 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1756 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1743 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1757 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1744 const Object& value = Object::Handle(arguments.ArgAt(1)); 1758 const Object& value = Object::Handle(arguments.ArgAt(1));
1745 field.UpdateGuardedCidAndLength(value); 1759 field.UpdateGuardedCidAndLength(value);
1746 } 1760 }
1747 1761
1748 } // namespace dart 1762 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/assembler_x64.h ('k') | runtime/vm/code_patcher.h » ('j') | runtime/vm/freelist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698