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

Unified Diff: runtime/lib/isolate_patch.dart

Issue 2414173003: Check for the type of the the spawned function. (Closed)
Patch Set: Rename typedefs. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/isolate_patch.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/isolate_patch.dart
diff --git a/runtime/lib/isolate_patch.dart b/runtime/lib/isolate_patch.dart
index 7e4579a419072dd90df43b52fa71e1f8f12141e0..3a02c7ace6c62301c3c731364e128aefc6fa4e62 100644
--- a/runtime/lib/isolate_patch.dart
+++ b/runtime/lib/isolate_patch.dart
@@ -193,9 +193,9 @@ class _SendPortImpl implements SendPort {
void _sendInternal(var message) native "SendPortImpl_sendInternal_";
}
-typedef _MainFunction();
-typedef _MainFunctionArgs(args);
-typedef _MainFunctionArgsMessage(args, message);
+typedef _NullaryFunction();
+typedef _UnaryFunction(args);
+typedef _BinaryFunction(args, message);
/**
* Takes the real entry point as argument and invokes it with the
@@ -253,9 +253,9 @@ void _startIsolate(SendPort parentPort,
port.close();
if (isSpawnUri) {
- if (entryPoint is _MainFunctionArgsMessage) {
+ if (entryPoint is _BinaryFunction) {
entryPoint(args, message);
- } else if (entryPoint is _MainFunctionArgs) {
+ } else if (entryPoint is _UnaryFunction) {
entryPoint(args);
} else {
entryPoint();
@@ -310,6 +310,11 @@ void _startIsolate(SendPort parentPort,
// `paused` isn't handled yet.
RawReceivePort readyPort;
try {
+ // Check for the type of `entryPoint` on the spawning isolate to make
+ // error-handling easier.
+ if (entryPoint is! _UnaryFunction) {
+ throw new ArgumentError(entryPoint);
+ }
// The VM will invoke [_startIsolate] with entryPoint as argument.
readyPort = new RawReceivePort();
« no previous file with comments | « no previous file | sdk/lib/_internal/js_runtime/lib/isolate_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698