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

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

Issue 137483010: Add more timing information in the VM to track time spent is dart code Vs native code. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 10 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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/native_entry.h" 5 #include "vm/native_entry.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/dart_api_state.h" 10 #include "vm/dart_api_state.h"
(...skipping 12 matching lines...) Expand all
23 NativeFunction NativeEntry::ResolveNative(const Library& library, 23 NativeFunction NativeEntry::ResolveNative(const Library& library,
24 const String& function_name, 24 const String& function_name,
25 int number_of_arguments, 25 int number_of_arguments,
26 bool* auto_setup_scope) { 26 bool* auto_setup_scope) {
27 // Now resolve the native function to the corresponding native entrypoint. 27 // Now resolve the native function to the corresponding native entrypoint.
28 if (library.native_entry_resolver() == 0) { 28 if (library.native_entry_resolver() == 0) {
29 // Native methods are not allowed in the library to which this 29 // Native methods are not allowed in the library to which this
30 // class belongs in. 30 // class belongs in.
31 return NULL; 31 return NULL;
32 } 32 }
33 Isolate* isolate = Isolate::Current();
34 VmToNativeTimerScope timer(isolate);
33 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries. 35 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries.
34 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 36 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
35 Dart_NativeFunction native_function = 37 Dart_NativeFunction native_function =
36 resolver(Api::NewHandle(Isolate::Current(), function_name.raw()), 38 resolver(Api::NewHandle(isolate, function_name.raw()),
37 number_of_arguments, auto_setup_scope); 39 number_of_arguments, auto_setup_scope);
38 Dart_ExitScope(); // Exit the Dart API scope. 40 Dart_ExitScope(); // Exit the Dart API scope.
39 return reinterpret_cast<NativeFunction>(native_function); 41 return reinterpret_cast<NativeFunction>(native_function);
40 } 42 }
41 43
42 44
43 const ExternalLabel& NativeEntry::NativeCallWrapperLabel() { 45 const ExternalLabel& NativeEntry::NativeCallWrapperLabel() {
44 return native_call_label; 46 return native_call_label;
45 } 47 }
46 48
47 49
48 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, 50 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args,
49 Dart_NativeFunction func) { 51 Dart_NativeFunction func) {
50 CHECK_STACK_ALIGNMENT; 52 CHECK_STACK_ALIGNMENT;
51 VERIFY_ON_TRANSITION; 53 VERIFY_ON_TRANSITION;
52 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 54 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
53 Isolate* isolate = arguments->isolate(); 55 Isolate* isolate = arguments->isolate();
56 DartToVmTimerScope timer(isolate);
54 ApiState* state = isolate->api_state(); 57 ApiState* state = isolate->api_state();
55 ASSERT(state != NULL); 58 ASSERT(state != NULL);
56 ApiLocalScope* current_top_scope = state->top_scope(); 59 ApiLocalScope* current_top_scope = state->top_scope();
57 ApiLocalScope* scope = state->reusable_scope(); 60 ApiLocalScope* scope = state->reusable_scope();
58 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func)); 61 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func));
59 if (scope == NULL) { 62 if (scope == NULL) {
60 scope = new ApiLocalScope(current_top_scope, 63 scope = new ApiLocalScope(current_top_scope,
61 isolate->top_exit_frame_info()); 64 isolate->top_exit_frame_info());
62 ASSERT(scope != NULL); 65 ASSERT(scope != NULL);
63 } else { 66 } else {
64 scope->Reinit(isolate, 67 scope->Reinit(isolate,
65 current_top_scope, 68 current_top_scope,
66 isolate->top_exit_frame_info()); 69 isolate->top_exit_frame_info());
67 state->set_reusable_scope(NULL); 70 state->set_reusable_scope(NULL);
68 } 71 }
69 state->set_top_scope(scope); // New scope is now the top scope. 72 state->set_top_scope(scope); // New scope is now the top scope.
70 73
71 func(args); 74 {
75 VmToNativeTimerScope native_timer(isolate);
76 func(args);
77 }
72 78
73 ASSERT(current_top_scope == scope->previous()); 79 ASSERT(current_top_scope == scope->previous());
74 state->set_top_scope(current_top_scope); // Reset top scope to previous. 80 state->set_top_scope(current_top_scope); // Reset top scope to previous.
75 if (state->reusable_scope() == NULL) { 81 if (state->reusable_scope() == NULL) {
76 scope->Reset(isolate); // Reset the old scope which we just exited. 82 scope->Reset(isolate); // Reset the old scope which we just exited.
77 state->set_reusable_scope(scope); 83 state->set_reusable_scope(scope);
78 } else { 84 } else {
79 ASSERT(state->reusable_scope() != scope); 85 ASSERT(state->reusable_scope() != scope);
80 delete scope; 86 delete scope;
81 } 87 }
82 DEOPTIMIZE_ALOT; 88 DEOPTIMIZE_ALOT;
83 VERIFY_ON_TRANSITION; 89 VERIFY_ON_TRANSITION;
84 } 90 }
85 91
86 } // namespace dart 92 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698