OLD | NEW |
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 #ifndef RUNTIME_VM_NATIVE_ENTRY_H_ | 5 #ifndef RUNTIME_VM_NATIVE_ENTRY_H_ |
6 #define RUNTIME_VM_NATIVE_ENTRY_H_ | 6 #define RUNTIME_VM_NATIVE_ENTRY_H_ |
7 | 7 |
8 #include "platform/memory_sanitizer.h" | 8 #include "platform/memory_sanitizer.h" |
9 | 9 |
10 #include "vm/allocation.h" | 10 #include "vm/allocation.h" |
11 #include "vm/assembler.h" | 11 #include "vm/assembler.h" |
12 #include "vm/code_generator.h" | 12 #include "vm/code_generator.h" |
13 #include "vm/exceptions.h" | 13 #include "vm/exceptions.h" |
| 14 #include "vm/log.h" |
14 #include "vm/native_arguments.h" | 15 #include "vm/native_arguments.h" |
15 #include "vm/verifier.h" | 16 #include "vm/verifier.h" |
16 | 17 |
17 #include "include/dart_api.h" | 18 #include "include/dart_api.h" |
18 | 19 |
19 namespace dart { | 20 namespace dart { |
20 | 21 |
21 // Forward declarations. | 22 // Forward declarations. |
22 class Class; | 23 class Class; |
23 class String; | 24 class String; |
24 | 25 |
25 // We have three variants of native functions: | 26 // We have three variants of native functions: |
26 // - bootstrap natives, which are called directly from stub code. The callee is | 27 // - bootstrap natives, which are called directly from stub code. The callee is |
27 // responsible for safepoint transitions and setting up handle scopes as | 28 // responsible for safepoint transitions and setting up handle scopes as |
28 // needed. Only VM-defined natives are bootstrap natives; they cannot be | 29 // needed. Only VM-defined natives are bootstrap natives; they cannot be |
29 // defined by embedders or native extensions. | 30 // defined by embedders or native extensions. |
30 // - no scope natives, which are called through a wrapper function. The wrapper | 31 // - no scope natives, which are called through a wrapper function. The wrapper |
31 // function handles the safepoint transition. The callee is responsible for | 32 // function handles the safepoint transition. The callee is responsible for |
32 // setting up API scopes as needed. | 33 // setting up API scopes as needed. |
33 // - auto scope natives, which are called through a wrapper function. The | 34 // - auto scope natives, which are called through a wrapper function. The |
34 // wrapper function handles the safepoint transition and sets up an API | 35 // wrapper function handles the safepoint transition and sets up an API |
35 // scope. | 36 // scope. |
36 | 37 |
37 typedef void (*NativeFunction)(NativeArguments* arguments); | 38 typedef void (*NativeFunction)(NativeArguments* arguments); |
38 | 39 |
| 40 #ifndef PRODUCT |
| 41 #define TRACE_NATIVE_CALL(format, name) \ |
| 42 if (FLAG_trace_natives) { \ |
| 43 THR_Print("Calling native: " format "\n", name); \ |
| 44 } |
| 45 #else |
| 46 #define TRACE_NATIVE_CALL(format, name) \ |
| 47 do { \ |
| 48 } while (0) |
| 49 #endif |
39 | 50 |
40 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name | 51 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name |
41 | 52 |
42 #ifdef DEBUG | 53 #ifdef DEBUG |
43 #define SET_NATIVE_RETVAL(args, value) \ | 54 #define SET_NATIVE_RETVAL(args, value) \ |
44 RawObject* retval = value; \ | 55 RawObject* retval = value; \ |
45 ASSERT(retval->IsDartInstance()); \ | 56 ASSERT(retval->IsDartInstance()); \ |
46 arguments->SetReturnUnsafe(retval); | 57 arguments->SetReturnUnsafe(retval); |
47 #else | 58 #else |
48 #define SET_NATIVE_RETVAL(arguments, value) arguments->SetReturnUnsafe(value); | 59 #define SET_NATIVE_RETVAL(arguments, value) arguments->SetReturnUnsafe(value); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 static void AutoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args, | 150 static void AutoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args, |
140 Dart_NativeFunction func); | 151 Dart_NativeFunction func); |
141 | 152 |
142 static bool ReturnValueIsError(NativeArguments* arguments); | 153 static bool ReturnValueIsError(NativeArguments* arguments); |
143 static void PropagateErrors(NativeArguments* arguments); | 154 static void PropagateErrors(NativeArguments* arguments); |
144 }; | 155 }; |
145 | 156 |
146 } // namespace dart | 157 } // namespace dart |
147 | 158 |
148 #endif // RUNTIME_VM_NATIVE_ENTRY_H_ | 159 #endif // RUNTIME_VM_NATIVE_ENTRY_H_ |
OLD | NEW |