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/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_api_state.h" | 10 #include "vm/dart_api_state.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 | 83 |
84 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, | 84 void NativeEntry::NativeCallWrapper(Dart_NativeArguments args, |
85 Dart_NativeFunction func) { | 85 Dart_NativeFunction func) { |
86 CHECK_STACK_ALIGNMENT; | 86 CHECK_STACK_ALIGNMENT; |
87 VERIFY_ON_TRANSITION; | 87 VERIFY_ON_TRANSITION; |
88 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); | 88 NativeArguments* arguments = reinterpret_cast<NativeArguments*>(args); |
89 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ | 89 /* Tell MemorySanitizer 'arguments' is initialized by generated code. */ |
90 MSAN_UNPOISON(arguments, sizeof(*arguments)); | 90 MSAN_UNPOISON(arguments, sizeof(*arguments)); |
91 Isolate* isolate = arguments->thread()->isolate(); | 91 Thread* thread = arguments->thread(); |
| 92 Isolate* isolate = thread->isolate(); |
92 | 93 |
93 ApiState* state = isolate->api_state(); | 94 ApiState* state = isolate->api_state(); |
94 ASSERT(state != NULL); | 95 ASSERT(state != NULL); |
95 ApiLocalScope* current_top_scope = state->top_scope(); | 96 ApiLocalScope* current_top_scope = state->top_scope(); |
96 ApiLocalScope* scope = state->reusable_scope(); | 97 ApiLocalScope* scope = state->reusable_scope(); |
97 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func)); | 98 TRACE_NATIVE_CALL("0x%" Px "", reinterpret_cast<uintptr_t>(func)); |
98 if (scope == NULL) { | 99 if (scope == NULL) { |
99 scope = new ApiLocalScope(current_top_scope, | 100 scope = new ApiLocalScope(current_top_scope, |
100 isolate->top_exit_frame_info()); | 101 thread->top_exit_frame_info()); |
101 ASSERT(scope != NULL); | 102 ASSERT(scope != NULL); |
102 } else { | 103 } else { |
103 scope->Reinit(isolate, | 104 scope->Reinit(thread, |
104 current_top_scope, | 105 current_top_scope, |
105 isolate->top_exit_frame_info()); | 106 thread->top_exit_frame_info()); |
106 state->set_reusable_scope(NULL); | 107 state->set_reusable_scope(NULL); |
107 } | 108 } |
108 state->set_top_scope(scope); // New scope is now the top scope. | 109 state->set_top_scope(scope); // New scope is now the top scope. |
109 | 110 |
110 func(args); | 111 func(args); |
111 | 112 |
112 ASSERT(current_top_scope == scope->previous()); | 113 ASSERT(current_top_scope == scope->previous()); |
113 state->set_top_scope(current_top_scope); // Reset top scope to previous. | 114 state->set_top_scope(current_top_scope); // Reset top scope to previous. |
114 if (state->reusable_scope() == NULL) { | 115 if (state->reusable_scope() == NULL) { |
115 scope->Reset(isolate); // Reset the old scope which we just exited. | 116 scope->Reset(thread); // Reset the old scope which we just exited. |
116 state->set_reusable_scope(scope); | 117 state->set_reusable_scope(scope); |
117 } else { | 118 } else { |
118 ASSERT(state->reusable_scope() != scope); | 119 ASSERT(state->reusable_scope() != scope); |
119 delete scope; | 120 delete scope; |
120 } | 121 } |
121 DEOPTIMIZE_ALOT; | 122 DEOPTIMIZE_ALOT; |
122 VERIFY_ON_TRANSITION; | 123 VERIFY_ON_TRANSITION; |
123 } | 124 } |
124 | 125 |
125 } // namespace dart | 126 } // namespace dart |
OLD | NEW |