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

Side by Side Diff: runtime/lib/isolate.cc

Issue 1154673004: Add "checked" parameter to Isolate.spawnUri. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Skip test for everything but VM for now. Created 5 years, 6 months 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 | « no previous file | runtime/lib/isolate_patch.dart » ('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) 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 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 void* init_data = parent_isolate->init_callback_data(); 174 void* init_data = parent_isolate->init_callback_data();
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 // TODO(iposva): Evaluate whether it's ok to override the embedder's setup.
185 // Currently the strict_compilation flag is ignored if it's false and
186 // checked-mode was enabled using a command-line flag. The command-line flag
187 // overrides the user code's request.
188 child_isolate->set_strict_compilation(state->checked_mode());
184 if (!state->is_spawn_uri()) { 189 if (!state->is_spawn_uri()) {
185 // For isolates spawned using the spawnFunction semantics we set 190 // For isolates spawned using the spawn semantics we set
186 // the origin_id to the origin_id of the parent isolate. 191 // the origin_id to the origin_id of the parent isolate.
187 child_isolate->set_origin_id(parent_isolate->origin_id()); 192 child_isolate->set_origin_id(parent_isolate->origin_id());
188 } 193 }
189 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate)); 194 state->set_isolate(reinterpret_cast<Isolate*>(child_isolate));
190 return true; 195 return true;
191 } 196 }
192 197
193 198
194 static void Spawn(Isolate* parent_isolate, IsolateSpawnState* state) { 199 static void Spawn(Isolate* parent_isolate, IsolateSpawnState* state) {
195 Thread::ExitIsolate(); 200 Thread::ExitIsolate();
(...skipping 26 matching lines...) Expand all
222 Function& func = Function::Handle(); 227 Function& func = Function::Handle();
223 func = Closure::function(closure); 228 func = Closure::function(closure);
224 if (func.IsImplicitClosureFunction() && func.is_static()) { 229 if (func.IsImplicitClosureFunction() && func.is_static()) {
225 #if defined(DEBUG) 230 #if defined(DEBUG)
226 Context& ctx = Context::Handle(); 231 Context& ctx = Context::Handle();
227 ctx = Closure::context(closure); 232 ctx = Closure::context(closure);
228 ASSERT(ctx.num_variables() == 0); 233 ASSERT(ctx.num_variables() == 0);
229 #endif 234 #endif
230 // Get the parent function so that we get the right function name. 235 // Get the parent function so that we get the right function name.
231 func = func.parent_function(); 236 func = func.parent_function();
237 bool checkedFlag = isolate->strict_compilation();
232 Spawn(isolate, new IsolateSpawnState(port.Id(), 238 Spawn(isolate, new IsolateSpawnState(port.Id(),
233 func, 239 func,
234 message, 240 message,
235 paused.value())); 241 paused.value(),
242 checkedFlag));
236 return Object::null(); 243 return Object::null();
237 } 244 }
238 } 245 }
239 const String& msg = String::Handle(String::New( 246 const String& msg = String::Handle(String::New(
240 "Isolate.spawn expects to be passed a static or top-level function")); 247 "Isolate.spawn expects to be passed a static or top-level function"));
241 Exceptions::ThrowArgumentError(msg); 248 Exceptions::ThrowArgumentError(msg);
242 return Object::null(); 249 return Object::null();
243 } 250 }
244 251
245 252
246 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 6) { 253 DEFINE_NATIVE_ENTRY(Isolate_spawnUri, 7) {
247 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0)); 254 GET_NON_NULL_NATIVE_ARGUMENT(SendPort, port, arguments->NativeArgAt(0));
248 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1)); 255 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(1));
249 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2)); 256 GET_NON_NULL_NATIVE_ARGUMENT(Instance, args, arguments->NativeArgAt(2));
250 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3)); 257 GET_NON_NULL_NATIVE_ARGUMENT(Instance, message, arguments->NativeArgAt(3));
251 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4)); 258 GET_NON_NULL_NATIVE_ARGUMENT(Bool, paused, arguments->NativeArgAt(4));
252 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(5)); 259 GET_NATIVE_ARGUMENT(Bool, checked, arguments->NativeArgAt(5));
260 GET_NATIVE_ARGUMENT(String, package_root, arguments->NativeArgAt(6));
253 261
254 // Canonicalize the uri with respect to the current isolate. 262 // Canonicalize the uri with respect to the current isolate.
255 char* error = NULL; 263 char* error = NULL;
256 char* canonical_uri = NULL; 264 char* canonical_uri = NULL;
257 const Library& root_lib = 265 const Library& root_lib =
258 Library::Handle(isolate->object_store()->root_library()); 266 Library::Handle(isolate->object_store()->root_library());
259 if (!CanonicalizeUri(isolate, root_lib, uri, 267 if (!CanonicalizeUri(isolate, root_lib, uri,
260 &canonical_uri, &error)) { 268 &canonical_uri, &error)) {
261 const String& msg = String::Handle(String::New(error)); 269 const String& msg = String::Handle(String::New(error));
262 ThrowIsolateSpawnException(msg); 270 ThrowIsolateSpawnException(msg);
263 } 271 }
264 272
265 char* utf8_package_root = NULL; 273 char* utf8_package_root = NULL;
266 if (!package_root.IsNull()) { 274 if (!package_root.IsNull()) {
267 const intptr_t len = Utf8::Length(package_root); 275 const intptr_t len = Utf8::Length(package_root);
268 utf8_package_root = zone->Alloc<char>(len + 1); 276 utf8_package_root = zone->Alloc<char>(len + 1);
269 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len); 277 package_root.ToUTF8(reinterpret_cast<uint8_t*>(utf8_package_root), len);
270 utf8_package_root[len] = '\0'; 278 utf8_package_root[len] = '\0';
271 } 279 }
272 280
281 bool checkedFlag;
282 if (checked.IsNull()) {
283 checkedFlag = isolate->strict_compilation();
284 } else {
285 checkedFlag = checked.value();
286 }
287
273 Spawn(isolate, new IsolateSpawnState(port.Id(), 288 Spawn(isolate, new IsolateSpawnState(port.Id(),
274 canonical_uri, 289 canonical_uri,
275 utf8_package_root, 290 utf8_package_root,
276 args, 291 args,
277 message, 292 message,
278 paused.value())); 293 paused.value(),
294 checkedFlag));
279 return Object::null(); 295 return Object::null();
280 } 296 }
281 297
282 298
283 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) { 299 DEFINE_NATIVE_ENTRY(Isolate_getPortAndCapabilitiesOfCurrentIsolate, 0) {
284 const Array& result = Array::Handle(Array::New(3)); 300 const Array& result = Array::Handle(Array::New(3));
285 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port()))); 301 result.SetAt(0, SendPort::Handle(SendPort::New(isolate->main_port())));
286 result.SetAt(1, Capability::Handle( 302 result.SetAt(1, Capability::Handle(
287 Capability::New(isolate->pause_capability()))); 303 Capability::New(isolate->pause_capability())));
288 result.SetAt(2, Capability::Handle( 304 result.SetAt(2, Capability::Handle(
(...skipping 13 matching lines...) Expand all
302 MessageWriter writer(&data, &allocator, false); 318 MessageWriter writer(&data, &allocator, false);
303 writer.WriteMessage(msg); 319 writer.WriteMessage(msg);
304 320
305 PortMap::PostMessage(new Message(port.Id(), 321 PortMap::PostMessage(new Message(port.Id(),
306 data, writer.BytesWritten(), 322 data, writer.BytesWritten(),
307 Message::kOOBPriority)); 323 Message::kOOBPriority));
308 return Object::null(); 324 return Object::null();
309 } 325 }
310 326
311 } // namespace dart 327 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698