| 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 #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" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 } | 126 } |
| 127 | 127 |
| 128 | 128 |
| 129 void NativeEntry::NativeCallWrapperNoStackCheck(Dart_NativeArguments args, | 129 void NativeEntry::NativeCallWrapperNoStackCheck(Dart_NativeArguments args, |
| 130 Dart_NativeFunction func) { | 130 Dart_NativeFunction func) { |
| 131 VERIFY_ON_TRANSITION; | 131 VERIFY_ON_TRANSITION; |
| 132 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 132 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
| 133 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ | 133 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ |
| 134 MSAN_UNPOISON(arguments, sizeof(*arguments)); | 134 MSAN_UNPOISON(arguments, sizeof(*arguments)); |
| 135 Thread* thread = arguments->thread(); | 135 Thread* thread = arguments->thread(); |
| 136 ASSERT(thread->execution_state() == Thread::kThreadInGenerated); |
| 136 if (!arguments->IsNativeAutoSetupScope()) { | 137 if (!arguments->IsNativeAutoSetupScope()) { |
| 137 TransitionGeneratedToNative transition(thread); | 138 TransitionGeneratedToNative transition(thread); |
| 138 func(args); | 139 func(args); |
| 139 if (ReturnValueIsError(arguments)) { | 140 if (ReturnValueIsError(arguments)) { |
| 140 PropagateErrors(arguments); | 141 PropagateErrors(arguments); |
| 141 } | 142 } |
| 142 } else { | 143 } else { |
| 143 Isolate* isolate = thread->isolate(); | 144 Isolate* isolate = thread->isolate(); |
| 144 ApiState* state = isolate->api_state(); | 145 ApiState* state = isolate->api_state(); |
| 145 ASSERT(state != NULL); | 146 ASSERT(state != NULL); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 167 ASSERT(current_top_scope == scope->previous()); | 168 ASSERT(current_top_scope == scope->previous()); |
| 168 thread->set_api_top_scope(current_top_scope); // Reset top scope to prev. | 169 thread->set_api_top_scope(current_top_scope); // Reset top scope to prev. |
| 169 if (thread->api_reusable_scope() == NULL) { | 170 if (thread->api_reusable_scope() == NULL) { |
| 170 scope->Reset(thread); // Reset the old scope which we just exited. | 171 scope->Reset(thread); // Reset the old scope which we just exited. |
| 171 thread->set_api_reusable_scope(scope); | 172 thread->set_api_reusable_scope(scope); |
| 172 } else { | 173 } else { |
| 173 ASSERT(thread->api_reusable_scope() != scope); | 174 ASSERT(thread->api_reusable_scope() != scope); |
| 174 delete scope; | 175 delete scope; |
| 175 } | 176 } |
| 176 DEOPTIMIZE_ALOT; | 177 DEOPTIMIZE_ALOT; |
| 177 VERIFY_ON_TRANSITION; | |
| 178 } | 178 } |
| 179 ASSERT(thread->execution_state() == Thread::kThreadInGenerated); |
| 180 VERIFY_ON_TRANSITION; |
| 179 } | 181 } |
| 180 | 182 |
| 181 | 183 |
| 182 // DBC does not support lazy native call linking. | 184 // DBC does not support lazy native call linking. |
| 183 #if !defined(TARGET_ARCH_DBC) | 185 #if !defined(TARGET_ARCH_DBC) |
| 184 static NativeFunction ResolveNativeFunction(Zone* zone, | 186 static NativeFunction ResolveNativeFunction(Zone* zone, |
| 185 const Function& func, | 187 const Function& func, |
| 186 bool* is_bootstrap_native) { | 188 bool* is_bootstrap_native) { |
| 187 const Class& cls = Class::Handle(zone, func.Owner()); | 189 const Class& cls = Class::Handle(zone, func.Owner()); |
| 188 const Library& library = Library::Handle(zone, cls.library()); | 190 const Library& library = Library::Handle(zone, cls.library()); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 NativeEntry::NativeCallWrapperNoStackCheck( | 299 NativeEntry::NativeCallWrapperNoStackCheck( |
| 298 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 300 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
| 299 } else { | 301 } else { |
| 300 target_function(arguments); | 302 target_function(arguments); |
| 301 } | 303 } |
| 302 } | 304 } |
| 303 #endif // !defined(TARGET_ARCH_DBC) | 305 #endif // !defined(TARGET_ARCH_DBC) |
| 304 | 306 |
| 305 | 307 |
| 306 } // namespace dart | 308 } // namespace dart |
| OLD | NEW |