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

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

Issue 11468016: Rename GET_NATIVE_ARGUMENT macro to GET_NON_NULL_NATIVE_ARGUMENT. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/lib/math.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) 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 PortMap::CreatePort(arguments->isolate()->message_handler()); 118 PortMap::CreatePort(arguments->isolate()->message_handler());
119 const Object& port = Object::Handle(ReceivePortCreate(port_id)); 119 const Object& port = Object::Handle(ReceivePortCreate(port_id));
120 if (port.IsError()) { 120 if (port.IsError()) {
121 Exceptions::PropagateError(Error::Cast(port)); 121 Exceptions::PropagateError(Error::Cast(port));
122 } 122 }
123 return port.raw(); 123 return port.raw();
124 } 124 }
125 125
126 126
127 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) { 127 DEFINE_NATIVE_ENTRY(ReceivePortImpl_closeInternal, 1) {
128 GET_NATIVE_ARGUMENT(Smi, id, arguments->NativeArgAt(0)); 128 GET_NON_NULL_NATIVE_ARGUMENT(Smi, id, arguments->NativeArgAt(0));
129 PortMap::ClosePort(id.Value()); 129 PortMap::ClosePort(id.Value());
130 return Object::null(); 130 return Object::null();
131 } 131 }
132 132
133 133
134 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) { 134 DEFINE_NATIVE_ENTRY(SendPortImpl_sendInternal_, 3) {
135 GET_NATIVE_ARGUMENT(Smi, send_id, arguments->NativeArgAt(0)); 135 GET_NON_NULL_NATIVE_ARGUMENT(Smi, send_id, arguments->NativeArgAt(0));
136 GET_NATIVE_ARGUMENT(Smi, reply_id, arguments->NativeArgAt(1)); 136 GET_NON_NULL_NATIVE_ARGUMENT(Smi, reply_id, arguments->NativeArgAt(1));
137 // TODO(iposva): Allow for arbitrary messages to be sent. 137 // TODO(iposva): Allow for arbitrary messages to be sent.
138 GET_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(2)); 138 GET_NON_NULL_NATIVE_ARGUMENT(Instance, obj, arguments->NativeArgAt(2));
139 139
140 uint8_t* data = NULL; 140 uint8_t* data = NULL;
141 MessageWriter writer(&data, &allocator); 141 MessageWriter writer(&data, &allocator);
142 writer.WriteMessage(obj); 142 writer.WriteMessage(obj);
143 143
144 // TODO(turnidge): Throw an exception when the return value is false? 144 // TODO(turnidge): Throw an exception when the return value is false?
145 PortMap::PostMessage(new Message(send_id.Value(), reply_id.Value(), 145 PortMap::PostMessage(new Message(send_id.Value(), reply_id.Value(),
146 data, writer.BytesWritten(), 146 data, writer.BytesWritten(),
147 Message::kNormalPriority)); 147 Message::kNormalPriority));
148 return Object::null(); 148 return Object::null();
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state)); 391 state->isolate()->set_spawn_data(reinterpret_cast<uword>(state));
392 state->isolate()->message_handler()->Run( 392 state->isolate()->message_handler()->Run(
393 Dart::thread_pool(), RunIsolate, ShutdownIsolate, 393 Dart::thread_pool(), RunIsolate, ShutdownIsolate,
394 reinterpret_cast<uword>(state->isolate())); 394 reinterpret_cast<uword>(state->isolate()));
395 395
396 return port.raw(); 396 return port.raw();
397 } 397 }
398 398
399 399
400 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) { 400 DEFINE_NATIVE_ENTRY(isolate_spawnFunction, 1) {
401 GET_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0)); 401 GET_NON_NULL_NATIVE_ARGUMENT(Instance, closure, arguments->NativeArgAt(0));
402 bool throw_exception = false; 402 bool throw_exception = false;
403 Function& func = Function::Handle(); 403 Function& func = Function::Handle();
404 if (closure.IsClosure()) { 404 if (closure.IsClosure()) {
405 func ^= Closure::function(closure); 405 func ^= Closure::function(closure);
406 const Class& cls = Class::Handle(func.Owner()); 406 const Class& cls = Class::Handle(func.Owner());
407 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) { 407 if (!func.IsClosureFunction() || !func.is_static() || !cls.IsTopLevel()) {
408 throw_exception = true; 408 throw_exception = true;
409 } 409 }
410 } else { 410 } else {
411 throw_exception = true; 411 throw_exception = true;
412 } 412 }
413 if (throw_exception) { 413 if (throw_exception) {
414 const String& msg = String::Handle(String::New( 414 const String& msg = String::Handle(String::New(
415 "spawnFunction expects to be passed a closure to a top-level static " 415 "spawnFunction expects to be passed a closure to a top-level static "
416 "function")); 416 "function"));
417 ThrowIllegalArgException(msg); 417 ThrowIllegalArgException(msg);
418 } 418 }
419 419
420 #if defined(DEBUG) 420 #if defined(DEBUG)
421 const Context& ctx = Context::Handle(Closure::context(closure)); 421 const Context& ctx = Context::Handle(Closure::context(closure));
422 ASSERT(ctx.num_variables() == 0); 422 ASSERT(ctx.num_variables() == 0);
423 #endif 423 #endif
424 424
425 return Spawn(arguments, new SpawnState(func)); 425 return Spawn(arguments, new SpawnState(func));
426 } 426 }
427 427
428 428
429 DEFINE_NATIVE_ENTRY(isolate_spawnUri, 1) { 429 DEFINE_NATIVE_ENTRY(isolate_spawnUri, 1) {
430 GET_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(0)); 430 GET_NON_NULL_NATIVE_ARGUMENT(String, uri, arguments->NativeArgAt(0));
431 431
432 // Canonicalize the uri with respect to the current isolate. 432 // Canonicalize the uri with respect to the current isolate.
433 char* error = NULL; 433 char* error = NULL;
434 char* canonical_uri = NULL; 434 char* canonical_uri = NULL;
435 const Library& root_lib = 435 const Library& root_lib =
436 Library::Handle(arguments->isolate()->object_store()->root_library()); 436 Library::Handle(arguments->isolate()->object_store()->root_library());
437 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri, 437 if (!CanonicalizeUri(arguments->isolate(), root_lib, uri,
438 &canonical_uri, &error)) { 438 &canonical_uri, &error)) {
439 const String& msg = String::Handle(String::New(error)); 439 const String& msg = String::Handle(String::New(error));
440 free(error); 440 free(error);
441 ThrowIsolateSpawnException(msg); 441 ThrowIsolateSpawnException(msg);
442 } 442 }
443 443
444 return Spawn(arguments, new SpawnState(canonical_uri)); 444 return Spawn(arguments, new SpawnState(canonical_uri));
445 } 445 }
446 446
447 447
448 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { 448 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) {
449 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); 449 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port()));
450 if (port.IsError()) { 450 if (port.IsError()) {
451 Exceptions::PropagateError(Error::Cast(port)); 451 Exceptions::PropagateError(Error::Cast(port));
452 } 452 }
453 return port.raw(); 453 return port.raw();
454 } 454 }
455 455
456 } // namespace dart 456 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/lib/integers.cc ('k') | runtime/lib/math.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698