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

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

Issue 17554003: Change static calls in unoptimized code to always call via a stub. Using ICData, the call count of … (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 6 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
« no previous file with comments | « no previous file | runtime/vm/code_patcher.h » ('j') | no next file with comments »
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/bigint_operations.h" 9 #include "vm/bigint_operations.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
(...skipping 711 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 722
723 723
724 DEFINE_RUNTIME_ENTRY(ReThrow, 2) { 724 DEFINE_RUNTIME_ENTRY(ReThrow, 2) {
725 ASSERT(arguments.ArgCount() == kReThrowRuntimeEntry.argument_count()); 725 ASSERT(arguments.ArgCount() == kReThrowRuntimeEntry.argument_count());
726 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0)); 726 const Instance& exception = Instance::CheckedHandle(arguments.ArgAt(0));
727 const Instance& stacktrace = Instance::CheckedHandle(arguments.ArgAt(1)); 727 const Instance& stacktrace = Instance::CheckedHandle(arguments.ArgAt(1));
728 Exceptions::ReThrow(exception, stacktrace); 728 Exceptions::ReThrow(exception, stacktrace);
729 } 729 }
730 730
731 731
732 // Patches static call with the target's entry point. Compiles target if 732 // Patches static call in optimized code with the target's entry point.
733 // necessary. 733 // Compiles target if necessary.
734 DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) { 734 DEFINE_RUNTIME_ENTRY(PatchStaticCall, 0) {
735 ASSERT(arguments.ArgCount() == kPatchStaticCallRuntimeEntry.argument_count()); 735 ASSERT(arguments.ArgCount() == kPatchStaticCallRuntimeEntry.argument_count());
736 DartFrameIterator iterator; 736 DartFrameIterator iterator;
737 StackFrame* caller_frame = iterator.NextFrame(); 737 StackFrame* caller_frame = iterator.NextFrame();
738 ASSERT(caller_frame != NULL); 738 ASSERT(caller_frame != NULL);
739 const Code& caller_code = Code::Handle(caller_frame->LookupDartCode()); 739 const Code& caller_code = Code::Handle(caller_frame->LookupDartCode());
740 ASSERT(!caller_code.IsNull()); 740 ASSERT(!caller_code.IsNull());
741 ASSERT(caller_code.is_optimized());
741 const Function& target_function = Function::Handle( 742 const Function& target_function = Function::Handle(
742 caller_code.GetStaticCallTargetFunctionAt(caller_frame->pc())); 743 caller_code.GetStaticCallTargetFunctionAt(caller_frame->pc()));
743 if (!target_function.HasCode()) { 744 if (!target_function.HasCode()) {
744 const Error& error = 745 const Error& error =
745 Error::Handle(Compiler::CompileFunction(target_function)); 746 Error::Handle(Compiler::CompileFunction(target_function));
746 if (!error.IsNull()) { 747 if (!error.IsNull()) {
747 Exceptions::PropagateError(error); 748 Exceptions::PropagateError(error);
748 } 749 }
749 } 750 }
750 const Code& target_code = Code::Handle(target_function.CurrentCode()); 751 const Code& target_code = Code::Handle(target_function.CurrentCode());
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
828 kBreakpointStaticHandlerRuntimeEntry.argument_count()); 829 kBreakpointStaticHandlerRuntimeEntry.argument_count());
829 ASSERT(isolate->debugger() != NULL); 830 ASSERT(isolate->debugger() != NULL);
830 isolate->debugger()->SignalBpReached(); 831 isolate->debugger()->SignalBpReached();
831 // Make sure the static function that is about to be called is 832 // Make sure the static function that is about to be called is
832 // compiled. The stub will jump to the entry point without any 833 // compiled. The stub will jump to the entry point without any
833 // further tests. 834 // further tests.
834 DartFrameIterator iterator; 835 DartFrameIterator iterator;
835 StackFrame* caller_frame = iterator.NextFrame(); 836 StackFrame* caller_frame = iterator.NextFrame();
836 ASSERT(caller_frame != NULL); 837 ASSERT(caller_frame != NULL);
837 const Code& code = Code::Handle(caller_frame->LookupDartCode()); 838 const Code& code = Code::Handle(caller_frame->LookupDartCode());
839 ASSERT(!code.is_optimized());
838 const Function& function = 840 const Function& function =
839 Function::Handle(code.GetStaticCallTargetFunctionAt(caller_frame->pc())); 841 Function::Handle(CodePatcher::GetUnoptimizedStaticCallTargetAt(
842 caller_frame->pc(), code));
840 843
841 if (!function.HasCode()) { 844 if (!function.HasCode()) {
842 const Error& error = Error::Handle(Compiler::CompileFunction(function)); 845 const Error& error = Error::Handle(Compiler::CompileFunction(function));
843 if (!error.IsNull()) { 846 if (!error.IsNull()) {
844 Exceptions::PropagateError(error); 847 Exceptions::PropagateError(error);
845 } 848 }
846 } 849 }
847 arguments.SetReturn(Code::ZoneHandle(function.CurrentCode())); 850 arguments.SetReturn(Code::ZoneHandle(function.CurrentCode()));
848 } 851 }
849 852
(...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after
1396 frame = iterator.NextFrame(); 1399 frame = iterator.NextFrame();
1397 } 1400 }
1398 ASSERT(frame != NULL); 1401 ASSERT(frame != NULL);
1399 if (frame->IsEntryFrame()) { 1402 if (frame->IsEntryFrame()) {
1400 // Since function's current code is always unpatched, the entry frame always 1403 // Since function's current code is always unpatched, the entry frame always
1401 // calls to unpatched code. 1404 // calls to unpatched code.
1402 UNREACHABLE(); 1405 UNREACHABLE();
1403 } 1406 }
1404 ASSERT(frame->IsDartFrame()); 1407 ASSERT(frame->IsDartFrame());
1405 const Code& caller_code = Code::Handle(frame->LookupDartCode()); 1408 const Code& caller_code = Code::Handle(frame->LookupDartCode());
1409 ASSERT(caller_code.is_optimized());
1406 const Function& target_function = Function::Handle( 1410 const Function& target_function = Function::Handle(
1407 caller_code.GetStaticCallTargetFunctionAt(frame->pc())); 1411 caller_code.GetStaticCallTargetFunctionAt(frame->pc()));
1408 const Code& target_code = Code::Handle(target_function.CurrentCode()); 1412 const Code& target_code = Code::Handle(target_function.CurrentCode());
1409 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code, 1413 CodePatcher::PatchStaticCallAt(frame->pc(), caller_code,
1410 target_code.EntryPoint()); 1414 target_code.EntryPoint());
1411 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code); 1415 caller_code.SetStaticCallTargetCodeAt(frame->pc(), target_code);
1412 if (FLAG_trace_patching) { 1416 if (FLAG_trace_patching) {
1413 OS::PrintErr("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n", 1417 OS::PrintErr("FixCallersTarget: patching from %#"Px" to '%s' %#"Px"\n",
1414 frame->pc(), 1418 frame->pc(),
1415 Function::Handle(target_code.function()).ToFullyQualifiedCString(), 1419 Function::Handle(target_code.function()).ToFullyQualifiedCString(),
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
1803 // Arg1: Value that is being stored. 1807 // Arg1: Value that is being stored.
1804 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) { 1808 DEFINE_RUNTIME_ENTRY(UpdateFieldCid, 2) {
1805 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count()); 1809 ASSERT(arguments.ArgCount() == kUpdateFieldCidRuntimeEntry.argument_count());
1806 const Field& field = Field::CheckedHandle(arguments.ArgAt(0)); 1810 const Field& field = Field::CheckedHandle(arguments.ArgAt(0));
1807 const Object& value = Object::Handle(arguments.ArgAt(1)); 1811 const Object& value = Object::Handle(arguments.ArgAt(1));
1808 1812
1809 field.UpdateCid(value.GetClassId()); 1813 field.UpdateCid(value.GetClassId());
1810 } 1814 }
1811 1815
1812 } // namespace dart 1816 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/code_patcher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698