OLD | NEW |
---|---|
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 "platform/assert.h" | 5 #include "platform/assert.h" |
6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
175 Isolate* child_isolate = reinterpret_cast<Isolate*>( | 175 Isolate* child_isolate = reinterpret_cast<Isolate*>( |
176 (callback)(state->script_url(), | 176 (callback)(state->script_url(), |
177 state->function_name(), | 177 state->function_name(), |
178 state->package_root(), | 178 state->package_root(), |
179 init_data, | 179 init_data, |
180 error)); | 180 error)); |
181 if (child_isolate == NULL) { | 181 if (child_isolate == NULL) { |
182 return false; | 182 return false; |
183 } | 183 } |
184 if (!state->is_spawn_uri()) { | 184 if (!state->is_spawn_uri()) { |
185 // For isolates spawned using the spawnFunction semantics we set | 185 child_isolate->set_strict_compilation(parent_isolate->strict_compilation()); |
Ivan Posva
2015/05/29 15:18:17
This should be handled when we create the spawn st
Lasse Reichstein Nielsen
2015/06/02 15:26:44
Done.
| |
186 | |
187 // For isolates spawned using the spawn semantics we set | |
186 // the origin_id to the origin_id of the parent isolate. | 188 // the origin_id to the origin_id of the parent isolate. |
187 child_isolate->set_origin_id(parent_isolate->origin_id()); | 189 child_isolate->set_origin_id(parent_isolate->origin_id()); |
190 } else { | |
191 child_isolate->set_strict_compilation(state->checked_mode()); | |
188 } | 192 } |
189 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate)); | 193 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate)); |
190 return true; | 194 return true; |
191 } | 195 } |
192 | 196 |
193 | 197 |
194 static void Spawn(Isolate* parent_isolate, IsolateSpawnState* state) { | 198 static void Spawn(Isolate* parent_isolate, IsolateSpawnState* state) { |
195 Thread::ExitIsolate(); | 199 Thread::ExitIsolate(); |
196 // Create a new isolate. | 200 // Create a new isolate. |
197 char* error = NULL; | 201 char* error = NULL; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
236 return Object::null(); | 240 return Object::null(); |
237 } | 241 } |
238 } | 242 } |
239 const String& msg = String::Handle(String::New( | 243 const String& msg = String::Handle(String::New( |
240 "Isolate.spawn expects to be passed a static or top-level function")); | 244 "Isolate.spawn expects to be passed a static or top-level function")); |
241 Exceptions::ThrowArgumentError(msg); | 245 Exceptions::ThrowArgumentError(msg); |
242 return Object::null(); | 246 return Object::null(); |
243 } | 247 } |
244 | 248 |
245 | 249 |
246 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 6) { | 250 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 7) { |
247 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); | 251 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); |
248 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1)); | 252 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1)); |
249 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2)); | 253 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2)); |
250 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); | 254 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); |
251 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4)); | 255 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4)); |
252 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(5)); | 256 GET_NON_NULL_NATIVE_ARGUMENT(Bool, checked, arguments->NativeArgAt(5)); |
257 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(6)); | |
253 | 258 |
254 // Canonicalize the uri with respect to the current isolate. | 259 // Canonicalize the uri with respect to the current isolate. |
255 char* error = NULL; | 260 char* error = NULL; |
256 char* canonical_uri = NULL; | 261 char* canonical_uri = NULL; |
257 const Library& root_lib = | 262 const Library& root_lib = |
258 Library::Handle(isolate->object_store()->root_library()); | 263 Library::Handle(isolate->object_store()->root_library()); |
259 if (!CanonicalizeUri(isolate, root_lib, uri, | 264 if (!CanonicalizeUri(isolate, root_lib, uri, |
260 &canonical_uri, &error)) { | 265 &canonical_uri, &error)) { |
261 const String& msg = String::Handle(String::New(error)); | 266 const String& msg = String::Handle(String::New(error)); |
262 ThrowIsolateSpawnException(msg); | 267 ThrowIsolateSpawnException(msg); |
263 } | 268 } |
264 | 269 |
265 char* utf8_package_root = NULL; | 270 char* utf8_package_root = NULL; |
266 if (!package_root.IsNull()) { | 271 if (!package_root.IsNull()) { |
267 const intptr_t len = Utf8::Length(package_root); | 272 const intptr_t len = Utf8::Length(package_root); |
268 utf8_package_root = zone->Alloc<char>(len + 1); | 273 utf8_package_root = zone->Alloc<char>(len + 1); |
269 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); | 274 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); |
270 utf8_package_root[len] = '\0'; | 275 utf8_package_root[len] = '\0'; |
271 } | 276 } |
272 | 277 |
273 Spawn(isolate, new IsolateSpawnState(port.Id(), | 278 Spawn(isolate, new IsolateSpawnState(port.Id(), |
274 canonical_uri, | 279 canonical_uri, |
275 utf8_package_root, | 280 utf8_package_root, |
276 args, | 281 args, |
277 message, | 282 message, |
278 paused.value())); | 283 paused.value(), |
284 checked.value())); | |
279 return Object::null(); | 285 return Object::null(); |
280 } | 286 } |
281 | 287 |
282 | 288 |
283 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { | 289 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { |
284 const Array& result = Array::Handle(Array::New(3)); | 290 const Array& result = Array::Handle(Array::New(3)); |
285 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); | 291 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); |
286 result.SetAt(1, Capability::Handle( | 292 result.SetAt(1, Capability::Handle( |
287 Capability::New(isolate->pause_capability()))); | 293 Capability::New(isolate->pause_capability()))); |
288 result.SetAt(2, Capability::Handle( | 294 result.SetAt(2, Capability::Handle( |
(...skipping 13 matching lines...) Expand all Loading... | |
302 MessageWriter writer(&data, &allocator, false); | 308 MessageWriter writer(&data, &allocator, false); |
303 writer.WriteMessage(msg); | 309 writer.WriteMessage(msg); |
304 | 310 |
305 PortMap::PostMessage(new Message(port.Id(), | 311 PortMap::PostMessage(new Message(port.Id(), |
306 data, writer.BytesWritten(), | 312 data, writer.BytesWritten(), |
307 Message::kOOBPriority)); | 313 Message::kOOBPriority)); |
308 return Object::null(); | 314 return Object::null(); |
309 } | 315 } |
310 | 316 |
311 } // namespace dart | 317 } // namespace dart |
OLD | NEW |