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

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

Issue 2250823002: Partially implement DBC profiler. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: . Created 4 years, 4 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 <setjmp.h> // NOLINT 5 #include <setjmp.h> // NOLINT
6 #include <stdlib.h> 6 #include <stdlib.h>
7 7
8 #include "vm/globals.h" 8 #include "vm/globals.h"
9 #if defined(TARGET_ARCH_DBC) 9 #if defined(TARGET_ARCH_DBC)
10 10
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 RawObject*** SP) { 535 RawObject*** SP) {
536 RawObject** callee_fp = call_top + kDartFrameFixedSize; 536 RawObject** callee_fp = call_top + kDartFrameFixedSize;
537 537
538 RawFunction* function = FrameFunction(callee_fp); 538 RawFunction* function = FrameFunction(callee_fp);
539 RawCode* code = function->ptr()->code_; 539 RawCode* code = function->ptr()->code_;
540 callee_fp[kPcMarkerSlotFromFp] = code; 540 callee_fp[kPcMarkerSlotFromFp] = code;
541 callee_fp[kSavedCallerPcSlotFromFp] = reinterpret_cast<RawObject*>(*pc); 541 callee_fp[kSavedCallerPcSlotFromFp] = reinterpret_cast<RawObject*>(*pc);
542 callee_fp[kSavedCallerFpSlotFromFp] = reinterpret_cast<RawObject*>(*FP); 542 callee_fp[kSavedCallerFpSlotFromFp] = reinterpret_cast<RawObject*>(*FP);
543 *pp = code->ptr()->object_pool_->ptr(); 543 *pp = code->ptr()->object_pool_->ptr();
544 *pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_); 544 *pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_);
545 pc_ = reinterpret_cast<uword>(*pc); // For the profiler.
Cutch 2016/08/19 13:49:31 weird indentation
rmacnak 2016/08/19 23:28:17 It is indented the same as the other lines, the as
545 *FP = callee_fp; 546 *FP = callee_fp;
546 *SP = *FP - 1; 547 *SP = *FP - 1;
547 } 548 }
548 549
549 550
550 void Simulator::InlineCacheMiss(int checked_args, 551 void Simulator::InlineCacheMiss(int checked_args,
551 Thread* thread, 552 Thread* thread,
552 RawICData* icdata, 553 RawICData* icdata,
553 RawObject** args, 554 RawObject** args,
554 RawObject** top, 555 RawObject** top,
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 static DART_NOINLINE bool InvokeRuntime( 688 static DART_NOINLINE bool InvokeRuntime(
688 Thread* thread, 689 Thread* thread,
689 Simulator* sim, 690 Simulator* sim,
690 RuntimeFunction drt, 691 RuntimeFunction drt,
691 const NativeArguments& args) { 692 const NativeArguments& args) {
692 SimulatorSetjmpBuffer buffer(sim); 693 SimulatorSetjmpBuffer buffer(sim);
693 if (!setjmp(buffer.buffer_)) { 694 if (!setjmp(buffer.buffer_)) {
694 thread->set_vm_tag(reinterpret_cast<uword>(drt)); 695 thread->set_vm_tag(reinterpret_cast<uword>(drt));
695 drt(args); 696 drt(args);
696 thread->set_vm_tag(VMTag::kDartTagId); 697 thread->set_vm_tag(VMTag::kDartTagId);
698 thread->set_top_exit_frame_info(0);
697 return true; 699 return true;
698 } else { 700 } else {
699 return false; 701 return false;
700 } 702 }
701 } 703 }
702 704
703 705
704 static DART_NOINLINE bool InvokeNative( 706 static DART_NOINLINE bool InvokeNative(
705 Thread* thread, 707 Thread* thread,
706 Simulator* sim, 708 Simulator* sim,
707 SimulatorBootstrapNativeCall f, 709 SimulatorBootstrapNativeCall f,
708 NativeArguments* args) { 710 NativeArguments* args) {
709 SimulatorSetjmpBuffer buffer(sim); 711 SimulatorSetjmpBuffer buffer(sim);
710 if (!setjmp(buffer.buffer_)) { 712 if (!setjmp(buffer.buffer_)) {
711 thread->set_vm_tag(reinterpret_cast<uword>(f)); 713 thread->set_vm_tag(reinterpret_cast<uword>(f));
712 f(args); 714 f(args);
713 thread->set_vm_tag(VMTag::kDartTagId); 715 thread->set_vm_tag(VMTag::kDartTagId);
716 thread->set_top_exit_frame_info(0);
714 return true; 717 return true;
715 } else { 718 } else {
716 return false; 719 return false;
717 } 720 }
718 } 721 }
719 722
720 723
721 static DART_NOINLINE bool InvokeNativeWrapper( 724 static DART_NOINLINE bool InvokeNativeWrapper(
722 Thread* thread, 725 Thread* thread,
723 Simulator* sim, 726 Simulator* sim,
724 Dart_NativeFunction f, 727 Dart_NativeFunction f,
725 NativeArguments* args) { 728 NativeArguments* args) {
726 SimulatorSetjmpBuffer buffer(sim); 729 SimulatorSetjmpBuffer buffer(sim);
727 if (!setjmp(buffer.buffer_)) { 730 if (!setjmp(buffer.buffer_)) {
728 thread->set_vm_tag(reinterpret_cast<uword>(f)); 731 thread->set_vm_tag(reinterpret_cast<uword>(f));
729 NativeEntry::NativeCallWrapper(reinterpret_cast<Dart_NativeArguments>(args), 732 NativeEntry::NativeCallWrapper(reinterpret_cast<Dart_NativeArguments>(args),
730 f); 733 f);
731 thread->set_vm_tag(VMTag::kDartTagId); 734 thread->set_vm_tag(VMTag::kDartTagId);
735 thread->set_top_exit_frame_info(0);
732 return true; 736 return true;
733 } else { 737 } else {
734 return false; 738 return false;
735 } 739 }
736 } 740 }
737 741
738 // Note: all macro helpers are intended to be used only inside Simulator::Call. 742 // Note: all macro helpers are intended to be used only inside Simulator::Call.
739 743
740 // Decode opcode and A part of the given value and dispatch to the 744 // Decode opcode and A part of the given value and dispatch to the
741 // corresponding bytecode handler. 745 // corresponding bytecode handler.
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
923 // SP > | fp_ | | 927 // SP > | fp_ | |
924 // FP > | ........... | > normal Dart frame (see stack_frame_dbc.h) 928 // FP > | ........... | > normal Dart frame (see stack_frame_dbc.h)
925 // | 929 // |
926 // v 930 // v
927 // 931 //
928 FP = fp_ + 1 + arguments.Length() + kDartFrameFixedSize; 932 FP = fp_ + 1 + arguments.Length() + kDartFrameFixedSize;
929 SP = FP - 1; 933 SP = FP - 1;
930 934
931 // Save outer top_exit_frame_info. 935 // Save outer top_exit_frame_info.
932 fp_[0] = reinterpret_cast<RawObject*>(thread->top_exit_frame_info()); 936 fp_[0] = reinterpret_cast<RawObject*>(thread->top_exit_frame_info());
937 thread->set_top_exit_frame_info(0);
933 938
934 // Copy arguments and setup the Dart frame. 939 // Copy arguments and setup the Dart frame.
935 const intptr_t argc = arguments.Length(); 940 const intptr_t argc = arguments.Length();
936 for (intptr_t i = 0; i < argc; i++) { 941 for (intptr_t i = 0; i < argc; i++) {
937 fp_[1 + i] = arguments.At(i); 942 fp_[1 + i] = arguments.At(i);
938 } 943 }
939 944
940 FP[kFunctionSlotFromFp] = code.function(); 945 FP[kFunctionSlotFromFp] = code.function();
941 FP[kPcMarkerSlotFromFp] = code.raw(); 946 FP[kPcMarkerSlotFromFp] = code.raw();
942 FP[kSavedCallerPcSlotFromFp] = reinterpret_cast<RawObject*>((argc << 2) | 2); 947 FP[kSavedCallerPcSlotFromFp] = reinterpret_cast<RawObject*>((argc << 2) | 2);
943 FP[kSavedCallerFpSlotFromFp] = reinterpret_cast<RawObject*>(fp_); 948 FP[kSavedCallerFpSlotFromFp] = reinterpret_cast<RawObject*>(fp_);
944 949
945 // Load argument descriptor. 950 // Load argument descriptor.
946 argdesc = arguments_descriptor.raw(); 951 argdesc = arguments_descriptor.raw();
947 952
948 // Ready to start executing bytecode. Load entry point and corresponding 953 // Ready to start executing bytecode. Load entry point and corresponding
949 // object pool. 954 // object pool.
950 pc = reinterpret_cast<uint32_t*>(code.raw()->ptr()->entry_point_); 955 pc = reinterpret_cast<uint32_t*>(code.raw()->ptr()->entry_point_);
956 pc_ = reinterpret_cast<uword>(pc); // For the profiler.
951 pp = code.object_pool()->ptr(); 957 pp = code.object_pool()->ptr();
952 958
953 // Cache some frequently used values in the frame. 959 // Cache some frequently used values in the frame.
954 RawBool* true_value = Bool::True().raw(); 960 RawBool* true_value = Bool::True().raw();
955 RawBool* false_value = Bool::False().raw(); 961 RawBool* false_value = Bool::False().raw();
956 RawObject* null_value = Object::null(); 962 RawObject* null_value = Object::null();
957 RawObject* empty_context = thread->isolate()->object_store()->empty_context(); 963 RawObject* empty_context = thread->isolate()->object_store()->empty_context();
958 964
959 #if defined(DEBUG) 965 #if defined(DEBUG)
960 Function& function_h = Function::Handle(); 966 Function& function_h = Function::Handle();
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
1162 FP[1] = 0; 1168 FP[1] = 0;
1163 Exit(thread, FP, FP + 2, pc); 1169 Exit(thread, FP, FP + 2, pc);
1164 NativeArguments args(thread, 1, FP, FP + 1); 1170 NativeArguments args(thread, 1, FP, FP + 1);
1165 INVOKE_RUNTIME(DRT_CompileFunction, args); 1171 INVOKE_RUNTIME(DRT_CompileFunction, args);
1166 { 1172 {
1167 // Function should be compiled now, dispatch to its entry point. 1173 // Function should be compiled now, dispatch to its entry point.
1168 RawCode* code = FrameFunction(FP)->ptr()->code_; 1174 RawCode* code = FrameFunction(FP)->ptr()->code_;
1169 SimulatorHelpers::SetFrameCode(FP, code); 1175 SimulatorHelpers::SetFrameCode(FP, code);
1170 pp = code->ptr()->object_pool_->ptr(); 1176 pp = code->ptr()->object_pool_->ptr();
1171 pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_); 1177 pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_);
1178 pc_ = reinterpret_cast<uword>(pc); // For the profiler.
1172 } 1179 }
1173 DISPATCH(); 1180 DISPATCH();
1174 } 1181 }
1175 1182
1176 { 1183 {
1177 BYTECODE(HotCheck, A_D); 1184 BYTECODE(HotCheck, A_D);
1178 const uint8_t increment = rA; 1185 const uint8_t increment = rA;
1179 const uint16_t threshold = rD; 1186 const uint16_t threshold = rD;
1180 RawFunction* f = FrameFunction(FP); 1187 RawFunction* f = FrameFunction(FP);
1181 int32_t counter = f->ptr()->usage_counter_; 1188 int32_t counter = f->ptr()->usage_counter_;
1182 // Note: we don't increment usage counter in the prologue of optimized 1189 // Note: we don't increment usage counter in the prologue of optimized
1183 // functions. 1190 // functions.
1184 if (increment) { 1191 if (increment) {
1185 counter += increment; 1192 counter += increment;
1186 f->ptr()->usage_counter_ = counter; 1193 f->ptr()->usage_counter_ = counter;
1187 } 1194 }
1188 if (counter >= threshold) { 1195 if (counter >= threshold) {
1189 FP[0] = f; 1196 FP[0] = f;
1190 FP[1] = 0; 1197 FP[1] = 0;
1191 Exit(thread, FP, FP + 2, pc); 1198 Exit(thread, FP, FP + 2, pc);
1192 NativeArguments args(thread, 1, FP, FP + 1); 1199 NativeArguments args(thread, 1, FP, FP + 1);
1193 INVOKE_RUNTIME(DRT_OptimizeInvokedFunction, args); 1200 INVOKE_RUNTIME(DRT_OptimizeInvokedFunction, args);
1194 { 1201 {
1195 // DRT_OptimizeInvokedFunction returns the code object to execute. 1202 // DRT_OptimizeInvokedFunction returns the code object to execute.
1196 ASSERT(FP[1]->GetClassId() == kCodeCid); 1203 ASSERT(FP[1]->GetClassId() == kCodeCid);
1197 RawCode* code = static_cast<RawCode*>(FP[1]); 1204 RawCode* code = static_cast<RawCode*>(FP[1]);
1198 SimulatorHelpers::SetFrameCode(FP, code); 1205 SimulatorHelpers::SetFrameCode(FP, code);
1199 pp = code->ptr()->object_pool_->ptr(); 1206 pp = code->ptr()->object_pool_->ptr();
1200 pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_); 1207 pc = reinterpret_cast<uint32_t*>(code->ptr()->entry_point_);
1208 pc_ = reinterpret_cast<uword>(pc); // For the profiler.
1201 } 1209 }
1202 } 1210 }
1203 DISPATCH(); 1211 DISPATCH();
1204 } 1212 }
1205 1213
1206 { 1214 {
1207 BYTECODE(CheckStack, A); 1215 BYTECODE(CheckStack, A);
1208 { 1216 {
1209 if (reinterpret_cast<uword>(SP) >= thread->stack_limit()) { 1217 if (reinterpret_cast<uword>(SP) >= thread->stack_limit()) {
1210 Exit(thread, FP, SP + 1, pc); 1218 Exit(thread, FP, SP + 1, pc);
(...skipping 872 matching lines...) Expand 10 before | Expand all | Expand 10 after
2083 result = FP[rA]; 2091 result = FP[rA];
2084 goto ReturnImpl; 2092 goto ReturnImpl;
2085 2093
2086 BYTECODE(ReturnTOS, 0); 2094 BYTECODE(ReturnTOS, 0);
2087 result = *SP; 2095 result = *SP;
2088 // Fall through to the ReturnImpl. 2096 // Fall through to the ReturnImpl.
2089 2097
2090 ReturnImpl: 2098 ReturnImpl:
2091 // Restore caller PC. 2099 // Restore caller PC.
2092 pc = SavedCallerPC(FP); 2100 pc = SavedCallerPC(FP);
2101 pc_ = reinterpret_cast<uword>(pc); // For the profiler.
2093 2102
2094 // Check if it is a fake PC marking the entry frame. 2103 // Check if it is a fake PC marking the entry frame.
2095 if ((reinterpret_cast<uword>(pc) & 2) != 0) { 2104 if ((reinterpret_cast<uword>(pc) & 2) != 0) {
2096 const intptr_t argc = reinterpret_cast<uword>(pc) >> 2; 2105 const intptr_t argc = reinterpret_cast<uword>(pc) >> 2;
2097 fp_ = sp_ = 2106 fp_ = sp_ =
2098 reinterpret_cast<RawObject**>(FrameArguments(FP, argc + 1)[0]); 2107 reinterpret_cast<RawObject**>(FrameArguments(FP, argc + 1)[0]);
2099 thread->set_top_exit_frame_info(reinterpret_cast<uword>(sp_)); 2108 thread->set_top_exit_frame_info(reinterpret_cast<uword>(sp_));
2100 thread->set_top_resource(top_resource); 2109 thread->set_top_resource(top_resource);
2101 thread->set_vm_tag(vm_tag); 2110 thread->set_vm_tag(vm_tag);
2102 return result; 2111 return result;
(...skipping 807 matching lines...) Expand 10 before | Expand all | Expand 10 after
2910 } 2919 }
2911 const intptr_t materialization_arg_count = 2920 const intptr_t materialization_arg_count =
2912 Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize; 2921 Smi::Value(RAW_CAST(Smi, *SP--)) / kWordSize;
2913 if (is_lazy) { 2922 if (is_lazy) {
2914 // Reload the result. It might have been relocated by GC. 2923 // Reload the result. It might have been relocated by GC.
2915 result = *SP--; 2924 result = *SP--;
2916 } 2925 }
2917 2926
2918 // Restore caller PC. 2927 // Restore caller PC.
2919 pc = SavedCallerPC(FP); 2928 pc = SavedCallerPC(FP);
2929 pc_ = reinterpret_cast<uword>(pc); // For the profiler.
2920 2930
2921 // Check if it is a fake PC marking the entry frame. 2931 // Check if it is a fake PC marking the entry frame.
2922 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0); 2932 ASSERT((reinterpret_cast<uword>(pc) & 2) == 0);
2923 2933
2924 // Restore SP, FP and PP. Push result and dispatch. 2934 // Restore SP, FP and PP. Push result and dispatch.
2925 // Note: unlike in a normal return sequence we don't need to drop 2935 // Note: unlike in a normal return sequence we don't need to drop
2926 // arguments - those are not part of the innermost deoptimization 2936 // arguments - those are not part of the innermost deoptimization
2927 // environment they were dropped by FlowGraphCompiler::RecordAfterCall. 2937 // environment they were dropped by FlowGraphCompiler::RecordAfterCall.
2928 2938
2929 // If the result is not preserved, the unoptimized frame ends at the 2939 // If the result is not preserved, the unoptimized frame ends at the
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
3048 pc_ = pc; 3058 pc_ = pc;
3049 special_[kExceptionSpecialIndex] = raw_exception; 3059 special_[kExceptionSpecialIndex] = raw_exception;
3050 special_[kStacktraceSpecialIndex] = raw_stacktrace; 3060 special_[kStacktraceSpecialIndex] = raw_stacktrace;
3051 buf->Longjmp(); 3061 buf->Longjmp();
3052 UNREACHABLE(); 3062 UNREACHABLE();
3053 } 3063 }
3054 3064
3055 } // namespace dart 3065 } // namespace dart
3056 3066
3057 #endif // defined TARGET_ARCH_DBC 3067 #endif // defined TARGET_ARCH_DBC
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698