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

Side by Side Diff: runtime/vm/bootstrap_natives.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
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/bootstrap.h" 5 #include "vm/bootstrap.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 8
9 #include "vm/bootstrap_natives.h" 9 #include "vm/bootstrap_natives.h"
10 #include "vm/dart_api_impl.h" 10 #include "vm/dart_api_impl.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 struct NativeEntries* entry = &(BootStrapEntries[i]); 46 struct NativeEntries* entry = &(BootStrapEntries[i]);
47 if ((strcmp(function_name, entry->name_) == 0) && 47 if ((strcmp(function_name, entry->name_) == 0) &&
48 (entry->argument_count_ == argument_count)) { 48 (entry->argument_count_ == argument_count)) {
49 return reinterpret_cast<Dart_NativeFunction>(entry->function_); 49 return reinterpret_cast<Dart_NativeFunction>(entry->function_);
50 } 50 }
51 } 51 }
52 return NULL; 52 return NULL;
53 } 53 }
54 54
55 55
56 const char* BootstrapNatives::ReverseLookup(Dart_NativeFunction* nf) {
57 int num_entries = sizeof(BootStrapEntries) / sizeof(struct NativeEntries);
58 for (int i = 0; i < num_entries; i++) {
59 struct NativeEntries* entry = &(BootStrapEntries[i]);
60 if (reinterpret_cast<Dart_NativeFunction*>(entry->function_) == nf) {
61 return entry->name_;
62 }
63 }
64 return NULL;
65 }
66
67
56 void Bootstrap::SetupNativeResolver() { 68 void Bootstrap::SetupNativeResolver() {
57 Library& library = Library::Handle(); 69 Library& library = Library::Handle();
58 70
59 Dart_NativeEntryResolver resolver = 71 Dart_NativeEntryResolver resolver =
60 reinterpret_cast<Dart_NativeEntryResolver>(BootstrapNatives::Lookup); 72 reinterpret_cast<Dart_NativeEntryResolver>(BootstrapNatives::Lookup);
61 73
74 Dart_NativeEntryReverseResolver reverse_resolver =
75 reinterpret_cast<Dart_NativeEntryReverseResolver>(
76 BootstrapNatives::ReverseLookup);
77
62 library = Library::AsyncLibrary(); 78 library = Library::AsyncLibrary();
63 ASSERT(!library.IsNull()); 79 ASSERT(!library.IsNull());
64 library.set_native_entry_resolver(resolver); 80 library.set_native_entry_resolver(resolver);
81 library.set_native_entry_reverse_resolver(reverse_resolver);
65 82
66 library = Library::CoreLibrary(); 83 library = Library::CoreLibrary();
67 ASSERT(!library.IsNull()); 84 ASSERT(!library.IsNull());
68 library.set_native_entry_resolver(resolver); 85 library.set_native_entry_resolver(resolver);
86 library.set_native_entry_reverse_resolver(reverse_resolver);
69 87
70 library = Library::MathLibrary(); 88 library = Library::MathLibrary();
71 ASSERT(!library.IsNull()); 89 ASSERT(!library.IsNull());
72 library.set_native_entry_resolver(resolver); 90 library.set_native_entry_resolver(resolver);
91 library.set_native_entry_reverse_resolver(reverse_resolver);
73 92
74 library = Library::MirrorsLibrary(); 93 library = Library::MirrorsLibrary();
75 ASSERT(!library.IsNull()); 94 ASSERT(!library.IsNull());
76 library.set_native_entry_resolver(resolver); 95 library.set_native_entry_resolver(resolver);
96 library.set_native_entry_reverse_resolver(reverse_resolver);
77 97
78 library = Library::InternalLibrary(); 98 library = Library::InternalLibrary();
79 ASSERT(!library.IsNull()); 99 ASSERT(!library.IsNull());
80 library.set_native_entry_resolver(resolver); 100 library.set_native_entry_resolver(resolver);
101 library.set_native_entry_reverse_resolver(reverse_resolver);
81 102
82 library = Library::IsolateLibrary(); 103 library = Library::IsolateLibrary();
83 ASSERT(!library.IsNull()); 104 ASSERT(!library.IsNull());
84 library.set_native_entry_resolver(resolver); 105 library.set_native_entry_resolver(resolver);
106 library.set_native_entry_reverse_resolver(reverse_resolver);
85 107
86 library = Library::TypedDataLibrary(); 108 library = Library::TypedDataLibrary();
87 ASSERT(!library.IsNull()); 109 ASSERT(!library.IsNull());
88 library.set_native_entry_resolver(resolver); 110 library.set_native_entry_resolver(resolver);
111 library.set_native_entry_reverse_resolver(reverse_resolver);
89 } 112 }
90 113
91 114
92 bool Bootstrap::IsBootstapResolver(Dart_NativeEntryResolver resolver) { 115 bool Bootstrap::IsBootstapResolver(Dart_NativeEntryResolver resolver) {
93 return (resolver == 116 return (resolver ==
94 reinterpret_cast<Dart_NativeEntryResolver>(BootstrapNatives::Lookup)); 117 reinterpret_cast<Dart_NativeEntryResolver>(BootstrapNatives::Lookup));
95 } 118 }
96 119
97 } // namespace dart 120 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698