Merge branch 'cherry' into dev

Version 1.24.0-dev.6.1

Cherry-pick 61300d19c60851fb306656d97e5bea42dcfe0aa8
Cherry-pick a0414390f9652e2b7cd212a0d1501c529946e344
Cherry-pick 03688818fa75bf7d75d91d2016e564d5f2178839
Cherry-pick e9e9835afc4633a0f4bb881c09a5dfb6d14fbc19
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 8031041..7b8a311 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,30 @@
   type `void` now allows the returned expression to have any type. For example,
   assuming the declaration `int x;`, it is now type correct to have
   `void f() => ++x;`.
+* A new function-type syntax has been added to the language.
+  Intuitively, the type of a function can be constructed by textually replacing
+  the function's name with `Function` in its declaration. For instance, the
+  type of `void foo() {}` would be `void Function()`. The new syntax may be used
+  wherever a type can be written. It is thus now possible to declare fields
+  containing functions without needing to write typedefs: `void Function() x;`.
+  The new function type has one restriction: it may not contain the old-style
+  function-type syntax for its parameters. The following is thus
+  illegal: `void Function(int f())`.
+  `typedefs` have been updated to support this new syntax.
+  Examples:
+  ```
+  typedef F = void Function();  // F is the name for a `void` callback.
+  int Function(int) f;  // A field `f` that contains an int->int function.
+
+  class A<T> {
+    // The parameter `callback` is a function that takes a `T` and returns
+    // `void`.
+    void forEach(void Function(T) callback);
+  }
+
+  // The new function type supports generic arguments.
+  typedef Invoker = T Function<T>(T Function() callback);
+  ```
 
 #### Strong Mode
 
@@ -24,6 +48,7 @@
 * The following is also a change in strong mode: During static analysis, a
   function or setter declared using `=>` with return type `void` now allows the
   returned expression to have any type.
+* The new function-type syntax is also supported by strong mode.
 
 ### Core library changes
 
diff --git a/runtime/bin/io_service_patch.dart b/runtime/bin/io_service_patch.dart
index 5d6b7bc..a9f0514 100644
--- a/runtime/bin/io_service_patch.dart
+++ b/runtime/bin/io_service_patch.dart
@@ -3,23 +3,39 @@
 // BSD-style license that can be found in the LICENSE file.
 
 class _IOServicePorts {
-  List<SendPort> _freeServicePorts = <SendPort>[];
-  HashMap<int, SendPort> _usedBy = new HashMap<int, SendPort>();
+  // We limit the number of IO Service ports per isolate so that we don't
+  // spawn too many threads all at once, which can crash the VM on Windows.
+  static const int maxPorts = 32;
+  List<SendPort> _ports = <SendPort>[];
+  List<SendPort> _freePorts = <SendPort>[];
+  HashMap<int, SendPort> _usedPorts = new HashMap<int, SendPort>();
 
   _IOServicePorts();
 
-  SendPort _getFreePort(int forRequestId) {
-    if (_freeServicePorts.isEmpty) {
-      _freeServicePorts.add(_newServicePort());
+  SendPort _getPort(int forRequestId) {
+    if (_freePorts.isEmpty && _usedPorts.length < maxPorts) {
+      final SendPort port = _newServicePort();
+      _ports.add(port);
+      _freePorts.add(port);
     }
-    SendPort freePort = _freeServicePorts.removeLast();
-    assert(!_usedBy.containsKey(forRequestId));
-    _usedBy[forRequestId] = freePort;
-    return freePort;
+    if (!_freePorts.isEmpty) {
+      final SendPort port = _freePorts.removeLast();
+      assert(!_usedPorts.containsKey(forRequestId));
+      _usedPorts[forRequestId] = port;
+      return port;
+    }
+    // We have already allocated the max number of ports. Re-use an
+    // existing one.
+    final SendPort port = _ports[forRequestId % maxPorts];
+    _usedPorts[forRequestId] = port;
+    return port;
   }
 
   void _returnPort(int forRequestId) {
-    _freeServicePorts.add(_usedBy.remove(forRequestId));
+    final SendPort port = _usedPorts.remove(forRequestId);
+    if (!_usedPorts.values.contains(port)) {
+      _freePorts.add(port);
+    }
   }
 
   static SendPort _newServicePort() native "IOService_NewServicePort";
@@ -39,9 +55,9 @@
     do {
       id = _getNextId();
     } while (_messageMap.containsKey(id));
-    SendPort servicePort = _servicePorts._getFreePort(id);
+    final SendPort servicePort = _servicePorts._getPort(id);
     _ensureInitialize();
-    var completer = new Completer();
+    final Completer completer = new Completer();
     _messageMap[id] = completer;
     try {
       servicePort.send([id, _replyToPort, request, data]);
diff --git a/sdk/BUILD.gn b/sdk/BUILD.gn
index fa5f73e..51c44d0 100644
--- a/sdk/BUILD.gn
+++ b/sdk/BUILD.gn
@@ -20,7 +20,10 @@
   dart_platform_sdk = false
 }
 
-if (is_fuchsia || is_fuchsia_host) {
+if (is_fuchsia ||
+    is_fuchsia_host ||
+    current_cpu == "arm64" ||
+    current_cpu == "arm") {
   dart_platform_sdk = true
 }
 
@@ -460,6 +463,7 @@
   visibility = [
     ":copy_dev_compiler_sdk",
     ":copy_dev_compiler_require_js",
+    ":copy_dev_compiler_tools",
   ]
   source = "../pkg/dev_compiler/lib/js"
   dest = "$root_out_dir/dart-sdk/lib/dev_compiler"
@@ -479,6 +483,24 @@
   ]
 }
 
+# This rule copies tools to go along with ddc.
+copy("copy_dev_compiler_tools") {
+  visibility = [ ":copy_dev_compiler_sdk" ]
+  deps = [
+    ":copy_dev_compiler_js",
+    "../utils/dartdevc:dartdevc_web",
+    "../utils/dartdevc:stack_trace_mapper",
+  ]
+  dart_out = get_label_info("../utils/dartdevc:dartdevc_web", "root_out_dir")
+  sources = [
+    "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js",
+    "$dart_out/dev_compiler/build/web/ddc_web_compiler.js",
+  ]
+  outputs = [
+    "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}",
+  ]
+}
+
 # This is the main rule for copying ddc's dependencies to lib/
 group("copy_dev_compiler_sdk") {
   visibility = [ ":create_full_sdk" ]
@@ -486,6 +508,7 @@
     ":copy_dev_compiler_js",
     ":copy_dev_compiler_require_js",
     ":copy_dev_compiler_summary",
+    ":copy_dev_compiler_tools",
   ]
 }
 
@@ -711,9 +734,9 @@
 # Parts specific to the full SDK.
 group("create_full_sdk") {
   visibility = [
-    ":copy_dev_compiler_tools",
     ":create_sdk",
   ]
+
   deps = [
     ":copy_dev_compiler_sdk",
     ":copy_full_sdk_libraries",
@@ -733,20 +756,3 @@
     deps += [ ":create_full_sdk" ]
   }
 }
-
-# This rule copies tools to go along with ddc.
-copy("copy_dev_compiler_tools") {
-  deps = [
-    ":create_full_sdk",
-    "../utils/dartdevc:dartdevc_web",
-    "../utils/dartdevc:stack_trace_mapper",
-  ]
-  dart_out = get_label_info("../utils/dartdevc:dartdevc_web", "root_out_dir")
-  sources = [
-    "$dart_out/dev_compiler/build/web/dart_stack_trace_mapper.js",
-    "$dart_out/dev_compiler/build/web/ddc_web_compiler.js",
-  ]
-  outputs = [
-    "$root_out_dir/dart-sdk/lib/dev_compiler/web/{{source_file_part}}",
-  ]
-}
diff --git a/sdk/lib/js/dartium/cached_patches.dart b/sdk/lib/js/dartium/cached_patches.dart
index e284118..9dd5891 100644
--- a/sdk/lib/js/dartium/cached_patches.dart
+++ b/sdk/lib/js/dartium/cached_patches.dart
@@ -982,6 +982,15 @@
   get runtimeType => DomTokenList;
   toString() => super.toString();
 }
+@patch class DragEvent {
+  static Type get instanceRuntimeType => DragEventImpl;
+
+}
+class DragEventImpl extends DragEvent implements js_library.JSObjectInterfacesDom {
+  DragEventImpl.internal_() : super.internal_();
+  get runtimeType => DragEvent;
+  toString() => super.toString();
+}
 @patch class EffectModel {
   static Type get instanceRuntimeType => EffectModelImpl;
 
diff --git a/tools/VERSION b/tools/VERSION
index 0277ead..d308062 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -28,4 +28,4 @@
 MINOR 24
 PATCH 0
 PRERELEASE 6
-PRERELEASE_PATCH 0
+PRERELEASE_PATCH 1