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

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

Issue 227433004: Add runtime and native entry tags (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.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) 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"
11 #include "vm/object_store.h"
11 #include "vm/tags.h" 12 #include "vm/tags.h"
12 13
13 14
14 namespace dart { 15 namespace dart {
15 16
16 DEFINE_FLAG(bool, trace_natives, false, 17 DEFINE_FLAG(bool, trace_natives, false,
17 "Trace invocation of natives (debug mode only)"); 18 "Trace invocation of natives (debug mode only)");
18 19
19 20
20 static ExternalLabel native_call_label( 21 static ExternalLabel native_call_label(
(...skipping 14 matching lines...) Expand all
35 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries. 36 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries.
36 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 37 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
37 Dart_NativeFunction native_function = 38 Dart_NativeFunction native_function =
38 resolver(Api::NewHandle(Isolate::Current(), function_name.raw()), 39 resolver(Api::NewHandle(Isolate::Current(), function_name.raw()),
39 number_of_arguments, auto_setup_scope); 40 number_of_arguments, auto_setup_scope);
40 Dart_ExitScope(); // Exit the Dart API scope. 41 Dart_ExitScope(); // Exit the Dart API scope.
41 return reinterpret_cast<NativeFunction>(native_function); 42 return reinterpret_cast<NativeFunction>(native_function);
42 } 43 }
43 44
44 45
46 const uint8_t* NativeEntry::ResolveSymbolInLibrary(const Library& library,
47 uword pc) {
48 if (library.native_entry_symbol_resolver() == 0) {
49 // Cannot reverse lookup native entries.
50 return NULL;
51 }
52 Dart_NativeEntrySymbol symbol_resolver =
53 library.native_entry_symbol_resolver();
54 return symbol_resolver(reinterpret_cast<Dart_NativeFunction>(pc));
55 }
56
57
58 const uint8_t* NativeEntry::ResolveSymbol(uword pc) {
59 Isolate* isolate = Isolate::Current();
60 const GrowableObjectArray& libs =
61 GrowableObjectArray::Handle(isolate->object_store()->libraries());
62 ASSERT(!libs.IsNull());
63 intptr_t num_libs = libs.Length();
64 Library& lib = Library::Handle();
65 for (intptr_t i = 0; i < num_libs; i++) {
66 lib ^= libs.At(i);
67 ASSERT(!lib.IsNull());
68 const uint8_t* r = ResolveSymbolInLibrary(lib, pc);
69 if (r != NULL) {
70 return r;
71 }
72 }
73 return NULL;
74 }
75
76
45 const ExternalLabel& NativeEntry::NativeCallWrapperLabel() { 77 const ExternalLabel& NativeEntry::NativeCallWrapperLabel() {
46 return native_call_label; 78 return native_call_label;
47 } 79 }
48 80
49 81
50 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, 82 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args,
51 Dart_NativeFunction func) { 83 Dart_NativeFunction func) {
52 CHECK_STACK_ALIGNMENT; 84 CHECK_STACK_ALIGNMENT;
53 VERIFY_ON_TRANSITION; 85 VERIFY_ON_TRANSITION;
54 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 86 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
(...skipping 25 matching lines...) Expand all
80 state->set_reusable_scope(scope); 112 state->set_reusable_scope(scope);
81 } else { 113 } else {
82 ASSERT(state->reusable_scope() != scope); 114 ASSERT(state->reusable_scope() != scope);
83 delete scope; 115 delete scope;
84 } 116 }
85 DEOPTIMIZE_ALOT; 117 DEOPTIMIZE_ALOT;
86 VERIFY_ON_TRANSITION; 118 VERIFY_ON_TRANSITION;
87 } 119 }
88 120
89 } // namespace dart 121 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_entry.h ('k') | runtime/vm/object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698