| 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/native_arguments.h" | 14 #include "vm/native_arguments.h" |
| 15 #include "vm/verifier.h" | 15 #include "vm/verifier.h" |
| 16 | 16 |
| 17 #include "include/dart_api.h" | 17 #include "include/dart_api.h" |
| 18 | 18 |
| 19 namespace dart { | 19 namespace dart { |
| 20 | 20 |
| 21 // Forward declarations. | 21 // Forward declarations. |
| 22 class Class; | 22 class Class; |
| 23 class String; | 23 class String; |
| 24 | 24 |
| 25 // We have three variants of native functions: |
| 26 // - bootstrap natives, which are called directly from stub code. The callee is |
| 27 // responsible for safepoint transitions and setting up handle scopes as |
| 28 // needed. Only VM-defined natives are bootstrap natives; they cannot be |
| 29 // defined by embedders or native extensions. |
| 30 // - no scope natives, which are called through a wrapper function. The wrapper |
| 31 // function handles the safepoint transition. The callee is responsible for |
| 32 // setting up API scopes as needed. |
| 33 // - auto scope natives, which are called through a wrapper function. The |
| 34 // wrapper function handles the safepoint transition and sets up an API |
| 35 // scope. |
| 36 |
| 25 typedef void (*NativeFunction)(NativeArguments* arguments); | 37 typedef void (*NativeFunction)(NativeArguments* arguments); |
| 26 | 38 |
| 27 | 39 |
| 28 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name | 40 #define NATIVE_ENTRY_FUNCTION(name) BootstrapNatives::DN_##name |
| 29 | 41 |
| 30 #ifdef DEBUG | 42 #ifdef DEBUG |
| 31 #define SET_NATIVE_RETVAL(args, value) \ | 43 #define SET_NATIVE_RETVAL(args, value) \ |
| 32 RawObject* retval = value; \ | 44 RawObject* retval = value; \ |
| 33 ASSERT(retval->IsDartInstance()); \ | 45 ASSERT(retval->IsDartInstance()); \ |
| 34 arguments->SetReturnUnsafe(retval); | 46 arguments->SetReturnUnsafe(retval); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 | 112 |
| 101 // Resolve specified dart native function to the actual native entrypoint. | 113 // Resolve specified dart native function to the actual native entrypoint. |
| 102 static NativeFunction ResolveNative(const Library& library, | 114 static NativeFunction ResolveNative(const Library& library, |
| 103 const String& function_name, | 115 const String& function_name, |
| 104 int number_of_arguments, | 116 int number_of_arguments, |
| 105 bool* auto_setup_scope); | 117 bool* auto_setup_scope); |
| 106 static const uint8_t* ResolveSymbolInLibrary(const Library& library, | 118 static const uint8_t* ResolveSymbolInLibrary(const Library& library, |
| 107 uword pc); | 119 uword pc); |
| 108 static const uint8_t* ResolveSymbol(uword pc); | 120 static const uint8_t* ResolveSymbol(uword pc); |
| 109 | 121 |
| 110 static uword NativeCallWrapperEntry(); | 122 static uword NoScopeNativeCallWrapperEntry(); |
| 111 static void NativeCallWrapper(Dart_NativeArguments args, | 123 static void NoScopeNativeCallWrapper(Dart_NativeArguments args, |
| 112 Dart_NativeFunction func); | 124 Dart_NativeFunction func); |
| 125 |
| 126 static uword AutoScopeNativeCallWrapperEntry(); |
| 127 static void AutoScopeNativeCallWrapper(Dart_NativeArguments args, |
| 128 Dart_NativeFunction func); |
| 113 | 129 |
| 114 // DBC does not support lazy native call linking. | 130 // DBC does not support lazy native call linking. |
| 115 #if !defined(TARGET_ARCH_DBC) | 131 #if !defined(TARGET_ARCH_DBC) |
| 116 static uword LinkNativeCallEntry(); | 132 static uword LinkNativeCallEntry(); |
| 117 static void LinkNativeCall(Dart_NativeArguments args); | 133 static void LinkNativeCall(Dart_NativeArguments args); |
| 118 #endif | 134 #endif |
| 119 | 135 |
| 120 private: | 136 private: |
| 121 static void NativeCallWrapperNoStackCheck(Dart_NativeArguments args, | 137 static void NoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args, |
| 122 Dart_NativeFunction func); | 138 Dart_NativeFunction func); |
| 139 static void AutoScopeNativeCallWrapperNoStackCheck(Dart_NativeArguments args, |
| 140 Dart_NativeFunction func); |
| 123 | 141 |
| 124 static bool ReturnValueIsError(NativeArguments* arguments); | 142 static bool ReturnValueIsError(NativeArguments* arguments); |
| 125 static void PropagateErrors(NativeArguments* arguments); | 143 static void PropagateErrors(NativeArguments* arguments); |
| 126 }; | 144 }; |
| 127 | 145 |
| 128 } // namespace dart | 146 } // namespace dart |
| 129 | 147 |
| 130 #endif // RUNTIME_VM_NATIVE_ENTRY_H_ | 148 #endif // RUNTIME_VM_NATIVE_ENTRY_H_ |
| OLD | NEW |