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

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

Issue 1358773002: Load the native call wrapper via Thread. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
« 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/bootstrap.h" 9 #include "vm/bootstrap.h"
10 #include "vm/code_patcher.h" 10 #include "vm/code_patcher.h"
11 #include "vm/dart_api_impl.h" 11 #include "vm/dart_api_impl.h"
12 #include "vm/dart_api_state.h" 12 #include "vm/dart_api_state.h"
13 #include "vm/object_store.h" 13 #include "vm/object_store.h"
14 #include "vm/reusable_handles.h" 14 #include "vm/reusable_handles.h"
15 #include "vm/stack_frame.h" 15 #include "vm/stack_frame.h"
16 #include "vm/symbols.h" 16 #include "vm/symbols.h"
17 #include "vm/tags.h" 17 #include "vm/tags.h"
18 18
19 19
20 namespace dart { 20 namespace dart {
21 21
22 DEFINE_FLAG(bool, trace_natives, false, 22 DEFINE_FLAG(bool, trace_natives, false,
23 "Trace invocation of natives (debug mode only)"); 23 "Trace invocation of natives (debug mode only)");
24 24
25 25
26 static ExternalLabel native_call_label(
27 reinterpret_cast<uword>(&NativeEntry::NativeCallWrapper));
28
29
30 static ExternalLabel link_native_call_label(
31 reinterpret_cast<uword>(&NativeEntry::LinkNativeCall));
32
33
34 NativeFunction NativeEntry::ResolveNative(const Library& library, 26 NativeFunction NativeEntry::ResolveNative(const Library& library,
35 const String& function_name, 27 const String& function_name,
36 int number_of_arguments, 28 int number_of_arguments,
37 bool* auto_setup_scope) { 29 bool* auto_setup_scope) {
38 // Now resolve the native function to the corresponding native entrypoint. 30 // Now resolve the native function to the corresponding native entrypoint.
39 if (library.native_entry_resolver() == 0) { 31 if (library.native_entry_resolver() == 0) {
40 // Native methods are not allowed in the library to which this 32 // Native methods are not allowed in the library to which this
41 // class belongs in. 33 // class belongs in.
42 return NULL; 34 return NULL;
43 } 35 }
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 ASSERT(!lib.IsNull()); 69 ASSERT(!lib.IsNull());
78 const uint8_t* r = ResolveSymbolInLibrary(lib, pc); 70 const uint8_t* r = ResolveSymbolInLibrary(lib, pc);
79 if (r != NULL) { 71 if (r != NULL) {
80 return r; 72 return r;
81 } 73 }
82 } 74 }
83 return NULL; 75 return NULL;
84 } 76 }
85 77
86 78
87 const ExternalLabel& NativeEntry::NativeCallWrapperLabel() { 79 uword NativeEntry::NativeCallWrapperEntry() {
88 return native_call_label; 80 uword entry = reinterpret_cast<uword>(NativeEntry::NativeCallWrapper);
81 #if defined(USING_SIMULATOR)
82 entry = Simulator::RedirectExternalReference(
83 entry, Simulator::kNativeCall, NativeEntry::kNumCallWrapperArguments);
84 #endif
85 return entry;
89 } 86 }
90 87
91 88
92 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, 89 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args,
93 Dart_NativeFunction func) { 90 Dart_NativeFunction func) {
94 CHECK_STACK_ALIGNMENT; 91 CHECK_STACK_ALIGNMENT;
95 VERIFY_ON_TRANSITION; 92 VERIFY_ON_TRANSITION;
96 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 93 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
97 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ 94 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */
98 MSAN_UNPOISON(arguments, sizeof(*arguments)); 95 MSAN_UNPOISON(arguments, sizeof(*arguments));
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 ASSERT(it.CurrentTokenKind() == Token::kSTRING); 157 ASSERT(it.CurrentTokenKind() == Token::kSTRING);
161 const String& native_name = String::Handle(it.CurrentLiteral()); 158 const String& native_name = String::Handle(it.CurrentLiteral());
162 159
163 const int num_params = NativeArguments::ParameterCountForResolution(func); 160 const int num_params = NativeArguments::ParameterCountForResolution(func);
164 bool auto_setup_scope = true; 161 bool auto_setup_scope = true;
165 return NativeEntry::ResolveNative( 162 return NativeEntry::ResolveNative(
166 library, native_name, num_params, &auto_setup_scope); 163 library, native_name, num_params, &auto_setup_scope);
167 } 164 }
168 165
169 166
170 const ExternalLabel& NativeEntry::LinkNativeCallLabel() { 167 uword NativeEntry::LinkNativeCallEntry() {
171 return link_native_call_label; 168 uword entry = reinterpret_cast<uword>(NativeEntry::LinkNativeCall);
169 #if defined(USING_SIMULATOR)
170 entry = Simulator::RedirectExternalReference(
171 entry, Simulator::kBootstrapNativeCall, NativeEntry::kNumArguments);
172 #endif
173 return entry;
172 } 174 }
173 175
174 176
175 void NativeEntry::LinkNativeCall(Dart_NativeArguments args) { 177 void NativeEntry::LinkNativeCall(Dart_NativeArguments args) {
176 CHECK_STACK_ALIGNMENT; 178 CHECK_STACK_ALIGNMENT;
177 VERIFY_ON_TRANSITION; 179 VERIFY_ON_TRANSITION;
178 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 180 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
179 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ 181 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */
180 MSAN_UNPOISON(arguments, sizeof(*arguments)); 182 MSAN_UNPOISON(arguments, sizeof(*arguments));
181 TRACE_NATIVE_CALL("%s", "LinkNative"); 183 TRACE_NATIVE_CALL("%s", "LinkNative");
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 if (call_through_wrapper) { 268 if (call_through_wrapper) {
267 NativeEntry::NativeCallWrapper( 269 NativeEntry::NativeCallWrapper(
268 args, reinterpret_cast<Dart_NativeFunction>(target_function)); 270 args, reinterpret_cast<Dart_NativeFunction>(target_function));
269 } else { 271 } else {
270 target_function(arguments); 272 target_function(arguments);
271 } 273 }
272 } 274 }
273 275
274 276
275 } // namespace dart 277 } // 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