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

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

Issue 1473403003: Move ApiLocalScope out of class ApiState into class Thread so that the API local handles and zone e… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: code-review-patch Created 5 years 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_api_impl.cc ('k') | runtime/vm/object.cc » ('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"
(...skipping 18 matching lines...) Expand all
29 bool* auto_setup_scope) { 29 bool* auto_setup_scope) {
30 // Now resolve the native function to the corresponding native entrypoint. 30 // Now resolve the native function to the corresponding native entrypoint.
31 if (library.native_entry_resolver() == 0) { 31 if (library.native_entry_resolver() == 0) {
32 // Native methods are not allowed in the library to which this 32 // Native methods are not allowed in the library to which this
33 // class belongs in. 33 // class belongs in.
34 return NULL; 34 return NULL;
35 } 35 }
36 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries. 36 Dart_EnterScope(); // Enter a new Dart API scope as we invoke API entries.
37 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); 37 Dart_NativeEntryResolver resolver = library.native_entry_resolver();
38 Dart_NativeFunction native_function = 38 Dart_NativeFunction native_function =
39 resolver(Api::NewHandle(Isolate::Current(), function_name.raw()), 39 resolver(Api::NewHandle(Thread::Current(), function_name.raw()),
40 number_of_arguments, auto_setup_scope); 40 number_of_arguments, auto_setup_scope);
41 Dart_ExitScope(); // Exit the Dart API scope. 41 Dart_ExitScope(); // Exit the Dart API scope.
42 return reinterpret_cast<NativeFunction>(native_function); 42 return reinterpret_cast<NativeFunction>(native_function);
43 } 43 }
44 44
45 45
46 const uint8_t* NativeEntry::ResolveSymbolInLibrary(const Library& library, 46 const uint8_t* NativeEntry::ResolveSymbolInLibrary(const Library& library,
47 uword pc) { 47 uword pc) {
48 Dart_NativeEntrySymbol symbol_resolver = 48 Dart_NativeEntrySymbol symbol_resolver =
49 library.native_entry_symbol_resolver(); 49 library.native_entry_symbol_resolver();
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
91 CHECK_STACK_ALIGNMENT; 91 CHECK_STACK_ALIGNMENT;
92 VERIFY_ON_TRANSITION; 92 VERIFY_ON_TRANSITION;
93 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); 93 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args);
94 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ 94 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */
95 MSAN_UNPOISON(arguments, sizeof(*arguments)); 95 MSAN_UNPOISON(arguments, sizeof(*arguments));
96 Thread* thread = arguments->thread(); 96 Thread* thread = arguments->thread();
97 Isolate* isolate = thread->isolate(); 97 Isolate* isolate = thread->isolate();
98 98
99 ApiState* state = isolate->api_state(); 99 ApiState* state = isolate->api_state();
100 ASSERT(state != NULL); 100 ASSERT(state != NULL);
101 ApiLocalScope* current_top_scope = state->top_scope(); 101 ApiLocalScope* current_top_scope = thread->api_top_scope();
102 ApiLocalScope* scope = state->reusable_scope(); 102 ApiLocalScope* scope = thread->api_reusable_scope();
103 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func)); 103 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func));
104 if (scope == NULL) { 104 if (scope == NULL) {
105 scope = new ApiLocalScope(current_top_scope, 105 scope = new ApiLocalScope(current_top_scope,
106 thread->top_exit_frame_info()); 106 thread->top_exit_frame_info());
107 ASSERT(scope != NULL); 107 ASSERT(scope != NULL);
108 } else { 108 } else {
109 scope->Reinit(thread, 109 scope->Reinit(thread,
110 current_top_scope, 110 current_top_scope,
111 thread->top_exit_frame_info()); 111 thread->top_exit_frame_info());
112 state->set_reusable_scope(NULL); 112 thread->set_api_reusable_scope(NULL);
113 } 113 }
114 state->set_top_scope(scope); // New scope is now the top scope. 114 thread->set_api_top_scope(scope); // New scope is now the top scope.
115 115
116 func(args); 116 func(args);
117 117
118 ASSERT(current_top_scope == scope->previous()); 118 ASSERT(current_top_scope == scope->previous());
119 state->set_top_scope(current_top_scope); // Reset top scope to previous. 119 thread->set_api_top_scope(current_top_scope); // Reset top scope to previous.
120 if (state->reusable_scope() == NULL) { 120 if (thread->api_reusable_scope() == NULL) {
121 scope->Reset(thread); // Reset the old scope which we just exited. 121 scope->Reset(thread); // Reset the old scope which we just exited.
122 state->set_reusable_scope(scope); 122 thread->set_api_reusable_scope(scope);
123 } else { 123 } else {
124 ASSERT(state->reusable_scope() != scope); 124 ASSERT(thread->api_reusable_scope() != scope);
125 delete scope; 125 delete scope;
126 } 126 }
127 DEOPTIMIZE_ALOT; 127 DEOPTIMIZE_ALOT;
128 VERIFY_ON_TRANSITION; 128 VERIFY_ON_TRANSITION;
129 } 129 }
130 130
131 131
132 static NativeFunction ResolveNativeFunction(Zone* zone, 132 static NativeFunction ResolveNativeFunction(Zone* zone,
133 const Function& func, 133 const Function& func,
134 bool* is_bootstrap_native) { 134 bool* is_bootstrap_native) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 if (call_through_wrapper) { 252 if (call_through_wrapper) {
253 NativeEntry::NativeCallWrapper( 253 NativeEntry::NativeCallWrapper(
254 args, reinterpret_cast<Dart_NativeFunction>(target_function)); 254 args, reinterpret_cast<Dart_NativeFunction>(target_function));
255 } else { 255 } else {
256 target_function(arguments); 256 target_function(arguments);
257 } 257 }
258 } 258 }
259 259
260 260
261 } // namespace dart 261 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/native_api_impl.cc ('k') | runtime/vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698