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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 VERIFY_ON_TRANSITION; | 128 VERIFY_ON_TRANSITION; |
129 } | 129 } |
130 | 130 |
131 | 131 |
132 static bool IsNativeKeyword(const TokenStream::Iterator& it) { | 132 static bool IsNativeKeyword(const TokenStream::Iterator& it) { |
133 return Token::IsIdentifier(it.CurrentTokenKind()) && | 133 return Token::IsIdentifier(it.CurrentTokenKind()) && |
134 (it.CurrentLiteral() == Symbols::Native().raw()); | 134 (it.CurrentLiteral() == Symbols::Native().raw()); |
135 } | 135 } |
136 | 136 |
137 | 137 |
138 static NativeFunction ResolveNativeFunction(Isolate *isolate, | 138 static NativeFunction ResolveNativeFunction(Zone* zone, |
139 const Function& func, | 139 const Function& func, |
140 bool* is_bootstrap_native) { | 140 bool* is_bootstrap_native) { |
141 const Script& script = Script::Handle(isolate, func.script()); | 141 const Script& script = Script::Handle(zone, func.script()); |
142 const Class& cls = Class::Handle(isolate, func.Owner()); | 142 const Class& cls = Class::Handle(zone, func.Owner()); |
143 const Library& library = Library::Handle(isolate, cls.library()); | 143 const Library& library = Library::Handle(zone, cls.library()); |
144 | 144 |
145 *is_bootstrap_native = | 145 *is_bootstrap_native = |
146 Bootstrap::IsBootstapResolver(library.native_entry_resolver()); | 146 Bootstrap::IsBootstapResolver(library.native_entry_resolver()); |
147 | 147 |
148 TokenStream::Iterator it(TokenStream::Handle(isolate, script.tokens()), | 148 TokenStream::Iterator it(TokenStream::Handle(zone, script.tokens()), |
149 func.token_pos()); | 149 func.token_pos()); |
150 | 150 |
151 const intptr_t end_pos = func.end_token_pos(); | 151 const intptr_t end_pos = func.end_token_pos(); |
152 while (!IsNativeKeyword(it) && it.CurrentPosition() <= end_pos) { | 152 while (!IsNativeKeyword(it) && it.CurrentPosition() <= end_pos) { |
153 it.Advance(); | 153 it.Advance(); |
154 } | 154 } |
155 ASSERT(IsNativeKeyword(it)); | 155 ASSERT(IsNativeKeyword(it)); |
156 it.Advance(); | 156 it.Advance(); |
157 ASSERT(it.CurrentTokenKind() == Token::kSTRING); | 157 ASSERT(it.CurrentTokenKind() == Token::kSTRING); |
158 const String& native_name = String::Handle(it.CurrentLiteral()); | 158 const String& native_name = String::Handle(it.CurrentLiteral()); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
199 #ifdef USING_SIMULATOR | 199 #ifdef USING_SIMULATOR |
200 is_native_auto_setup_scope = func.IsNativeAutoSetupScope(); | 200 is_native_auto_setup_scope = func.IsNativeAutoSetupScope(); |
201 #endif | 201 #endif |
202 | 202 |
203 if (FLAG_trace_natives) { | 203 if (FLAG_trace_natives) { |
204 OS::Print("Resolving native target for %s\n", func.ToCString()); | 204 OS::Print("Resolving native target for %s\n", func.ToCString()); |
205 } | 205 } |
206 | 206 |
207 bool is_bootstrap_native = false; | 207 bool is_bootstrap_native = false; |
208 target_function = ResolveNativeFunction( | 208 target_function = ResolveNativeFunction( |
209 arguments->thread()->isolate(), func, &is_bootstrap_native); | 209 arguments->thread()->zone(), func, &is_bootstrap_native); |
210 ASSERT(target_function != NULL); | 210 ASSERT(target_function != NULL); |
211 | 211 |
212 #if defined(DEBUG) | 212 #if defined(DEBUG) |
213 { | 213 { |
214 NativeFunction current_function = NULL; | 214 NativeFunction current_function = NULL; |
215 const Code& current_trampoline = Code::Handle( | 215 const Code& current_trampoline = Code::Handle( |
216 CodePatcher::GetNativeCallAt(caller_frame->pc(), | 216 CodePatcher::GetNativeCallAt(caller_frame->pc(), |
217 code, | 217 code, |
218 ¤t_function)); | 218 ¤t_function)); |
219 #if !defined(USING_SIMULATOR) | 219 #if !defined(USING_SIMULATOR) |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 if (call_through_wrapper) { | 268 if (call_through_wrapper) { |
269 NativeEntry::NativeCallWrapper( | 269 NativeEntry::NativeCallWrapper( |
270 args, reinterpret_cast<Dart_NativeFunction>(target_function)); | 270 args, reinterpret_cast<Dart_NativeFunction>(target_function)); |
271 } else { | 271 } else { |
272 target_function(arguments); | 272 target_function(arguments); |
273 } | 273 } |
274 } | 274 } |
275 | 275 |
276 | 276 |
277 } // namespace dart | 277 } // namespace dart |
OLD | NEW |