Remove support for dart:isolate in dart2js.
Change-Id: I1216a0ac91d8a1d13b441809596e1a8b5e51bb34
Reviewed-on: https://dart-review.googlesource.com/54526
Commit-Queue: Sigmund Cherem <sigmund@google.com>
Reviewed-by: Stephen Adams <sra@google.com>
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 16ddcd7..de8ec75 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,16 @@
(Add new changes here, and they will be copied to the
change section for the next dev version)
+### Tool Changes
+
+#### dart2js
+
+* Several fixes to improve support for running output of dart2js as a webworker.
+
+* `dart:isolate` implementation removed. To launch background tasks,
+ please use webworkers instead. APIs for webworkers can be accessed from
+ `dart:html` or JS-interop.
+
### Language
* Changed the `cast` method to always change the type. Deprecated the
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart
index aae8110..5675a1c 100644
--- a/pkg/compiler/lib/src/common_elements.dart
+++ b/pkg/compiler/lib/src/common_elements.dart
@@ -1210,17 +1210,6 @@
_env.lookupLibrary(Uris.dart__js_embedded_names, required: true),
'JsBuiltin');
- // From dart:_isolate_helper
-
- FunctionEntity get startRootIsolate =>
- _findLibraryMember(isolateHelperLibrary, 'startRootIsolate');
-
- FunctionEntity get currentIsolate =>
- _findLibraryMember(isolateHelperLibrary, '_currentIsolate');
-
- FunctionEntity get callInIsolate =>
- _findLibraryMember(isolateHelperLibrary, '_callInIsolate');
-
static final Uri PACKAGE_EXPECT =
new Uri(scheme: 'package', path: 'expect/expect.dart');
diff --git a/pkg/compiler/lib/src/deferred_load.dart b/pkg/compiler/lib/src/deferred_load.dart
index a2375d3..1ccd493 100644
--- a/pkg/compiler/lib/src/deferred_load.dart
+++ b/pkg/compiler/lib/src/deferred_load.dart
@@ -687,8 +687,8 @@
// Also add "global" dependencies to the main output unit. These are
// things that the backend needs but cannot associate with a particular
- // element, for example, startRootIsolate. This set also contains
- // elements for which we lack precise information.
+ // element. This set also contains elements for which we lack precise
+ // information.
for (MemberEntity element
in closedWorld.backendUsage.globalFunctionDependencies) {
element = element is MethodElement ? element.implementation : element;
diff --git a/pkg/compiler/lib/src/dump_info.dart b/pkg/compiler/lib/src/dump_info.dart
index dee89c3..251dacd 100644
--- a/pkg/compiler/lib/src/dump_info.dart
+++ b/pkg/compiler/lib/src/dump_info.dart
@@ -637,7 +637,7 @@
dumpInfoDuration: new Duration(milliseconds: this.timing),
noSuchMethodEnabled: closedWorld.backendUsage.isNoSuchMethodUsed,
isRuntimeTypeUsed: closedWorld.backendUsage.isRuntimeTypeUsed,
- isIsolateInUse: closedWorld.backendUsage.isIsolateInUse,
+ isIsolateInUse: false,
isFunctionApplyUsed: closedWorld.backendUsage.isFunctionApplyUsed,
isMirrorsUsed: closedWorld.backendUsage.isMirrorsUsed,
minified: compiler.options.enableMinification);
diff --git a/pkg/compiler/lib/src/js_backend/backend_impact.dart b/pkg/compiler/lib/src/js_backend/backend_impact.dart
index eb81c27..71bec0c 100644
--- a/pkg/compiler/lib/src/js_backend/backend_impact.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_impact.dart
@@ -725,24 +725,6 @@
dynamicUses: [Selectors.noSuchMethod_]);
}
- BackendImpact _isolateSupport;
-
- /// Backend impact for isolate support.
- BackendImpact get isolateSupport {
- return _isolateSupport ??=
- new BackendImpact(globalUses: [_commonElements.startRootIsolate]);
- }
-
- BackendImpact _isolateSupportForResolution;
-
- /// Additional backend impact for isolate support in resolution.
- BackendImpact get isolateSupportForResolution {
- return _isolateSupportForResolution ??= new BackendImpact(globalUses: [
- _commonElements.currentIsolate,
- _commonElements.callInIsolate
- ]);
- }
-
BackendImpact _loadLibrary;
/// Backend impact for accessing a `loadLibrary` function on a deferred
diff --git a/pkg/compiler/lib/src/js_backend/backend_usage.dart b/pkg/compiler/lib/src/js_backend/backend_usage.dart
index ac81356..ed8dced 100644
--- a/pkg/compiler/lib/src/js_backend/backend_usage.dart
+++ b/pkg/compiler/lib/src/js_backend/backend_usage.dart
@@ -36,9 +36,6 @@
/// `true` of `Object.runtimeType` is used.
bool get isRuntimeTypeUsed;
- /// `true` if the `dart:isolate` library is in use.
- bool get isIsolateInUse;
-
/// `true` if `Function.apply` is used.
bool get isFunctionApplyUsed;
@@ -81,9 +78,6 @@
/// `true` of `Object.runtimeType` is used.
bool isRuntimeTypeUsed;
- /// `true` if the `dart:isolate` library is in use.
- bool isIsolateInUse;
-
/// `true` if `Function.apply` is used.
bool isFunctionApplyUsed;
@@ -120,9 +114,6 @@
/// `true` of `Object.runtimeType` is used.
bool isRuntimeTypeUsed = false;
- /// `true` if the `dart:isolate` library is in use.
- bool isIsolateInUse = false;
-
/// `true` if `Function.apply` is used.
bool isFunctionApplyUsed = false;
@@ -289,7 +280,6 @@
requiresPreamble: requiresPreamble,
isInvokeOnUsed: isInvokeOnUsed,
isRuntimeTypeUsed: isRuntimeTypeUsed,
- isIsolateInUse: isIsolateInUse,
isFunctionApplyUsed: isFunctionApplyUsed,
isMirrorsUsed: isMirrorsUsed,
isNoSuchMethodUsed: isNoSuchMethodUsed,
@@ -320,9 +310,6 @@
/// `true` of `Object.runtimeType` is used.
final bool isRuntimeTypeUsed;
- /// `true` if the `dart:isolate` library is in use.
- final bool isIsolateInUse;
-
/// `true` if `Function.apply` is used.
final bool isFunctionApplyUsed;
@@ -345,7 +332,6 @@
this.requiresPreamble,
this.isInvokeOnUsed,
this.isRuntimeTypeUsed,
- this.isIsolateInUse,
this.isFunctionApplyUsed,
this.isMirrorsUsed,
this.isNoSuchMethodUsed,
diff --git a/pkg/compiler/lib/src/js_backend/codegen_listener.dart b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
index b5d3feb..39c2fb4 100644
--- a/pkg/compiler/lib/src/js_backend/codegen_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/codegen_listener.dart
@@ -78,26 +78,6 @@
}
}
- /// Called to enable support for isolates. Any backend specific [WorldImpact]
- /// of this is returned.
- WorldImpact _enableIsolateSupport(FunctionEntity mainMethod) {
- WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
- // TODO(floitsch): We should also ensure that the class IsolateMessage is
- // instantiated. Currently, just enabling isolate support works.
- if (mainMethod != null) {
- // The JavaScript backend implements [Isolate.spawn] by looking up
- // top-level functions by name. So all top-level function tear-off
- // closures have a private name field.
- //
- // The JavaScript backend of [Isolate.spawnUri] uses the same internal
- // implementation as [Isolate.spawn], and fails if it cannot look main up
- // by name.
- impactBuilder.registerStaticUse(new StaticUse.staticTearOff(mainMethod));
- }
- _impacts.isolateSupport.registerImpact(impactBuilder, _elementEnvironment);
- return impactBuilder;
- }
-
/// Computes the [WorldImpact] of calling [mainMethod] as the entry point.
WorldImpact _computeMainImpact(FunctionEntity mainMethod) {
WorldImpactBuilderImpl mainImpact = new WorldImpactBuilderImpl();
@@ -107,11 +87,6 @@
.registerImpact(mainImpact, _elementEnvironment);
mainImpact.registerStaticUse(
new StaticUse.staticInvoke(mainMethod, callStructure));
- // If the main method takes arguments, this compilation could be the
- // target of Isolate.spawnUri. Strictly speaking, that can happen also if
- // main takes no arguments, but in this case the spawned isolate can't
- // communicate with the spawning isolate.
- mainImpact.addImpact(_enableIsolateSupport(mainMethod));
}
mainImpact.registerStaticUse(
new StaticUse.staticInvoke(mainMethod, CallStructure.NO_ARGS));
@@ -125,9 +100,6 @@
if (mainMethod != null) {
enqueuer.applyImpact(_computeMainImpact(mainMethod));
}
- if (_backendUsage.isIsolateInUse) {
- enqueuer.applyImpact(_enableIsolateSupport(mainMethod));
- }
}
@override
diff --git a/pkg/compiler/lib/src/js_backend/resolution_listener.dart b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
index 1183182..d0ecf6e 100644
--- a/pkg/compiler/lib/src/js_backend/resolution_listener.dart
+++ b/pkg/compiler/lib/src/js_backend/resolution_listener.dart
@@ -4,7 +4,7 @@
library js_backend.backend.resolution_listener;
-import '../common/names.dart' show Identifiers, Uris;
+import '../common/names.dart' show Identifiers;
import '../common_elements.dart' show CommonElements, ElementEnvironment;
import '../constants/values.dart';
import '../deferred_load.dart';
@@ -117,30 +117,6 @@
}
}
- /// Called to enable support for isolates. Any backend specific [WorldImpact]
- /// of this is returned.
- WorldImpact _enableIsolateSupport(FunctionEntity mainMethod) {
- WorldImpactBuilderImpl impactBuilder = new WorldImpactBuilderImpl();
- // TODO(floitsch): We should also ensure that the class IsolateMessage is
- // instantiated. Currently, just enabling isolate support works.
- if (mainMethod != null) {
- // The JavaScript backend implements [Isolate.spawn] by looking up
- // top-level functions by name. So all top-level function tear-off
- // closures have a private name field.
- //
- // The JavaScript backend of [Isolate.spawnUri] uses the same internal
- // implementation as [Isolate.spawn], and fails if it cannot look main up
- // by name.
- impactBuilder.registerStaticUse(new StaticUse.staticTearOff(mainMethod));
- }
- _impacts.isolateSupport.registerImpact(impactBuilder, _elementEnvironment);
- _backendUsage.processBackendImpact(_impacts.isolateSupport);
- _impacts.isolateSupportForResolution
- .registerImpact(impactBuilder, _elementEnvironment);
- _backendUsage.processBackendImpact(_impacts.isolateSupportForResolution);
- return impactBuilder;
- }
-
/// Computes the [WorldImpact] of calling [mainMethod] as the entry point.
WorldImpact _computeMainImpact(FunctionEntity mainMethod) {
WorldImpactBuilderImpl mainImpact = new WorldImpactBuilderImpl();
@@ -151,11 +127,6 @@
_backendUsage.processBackendImpact(_impacts.mainWithArguments);
mainImpact.registerStaticUse(
new StaticUse.staticInvoke(mainMethod, callStructure));
- // If the main method takes arguments, this compilation could be the
- // target of Isolate.spawnUri. Strictly speaking, that can happen also if
- // main takes no arguments, but in this case the spawned isolate can't
- // communicate with the spawning isolate.
- mainImpact.addImpact(_enableIsolateSupport(mainMethod));
}
mainImpact.registerStaticUse(
new StaticUse.staticInvoke(mainMethod, CallStructure.NO_ARGS));
@@ -311,17 +282,6 @@
}
}
- // Enable isolate support if we start using something from the isolate
- // library. We exclude constant fields, which are ending here because their
- // initializing expression is compiled.
- if (!_backendUsage.isIsolateInUse &&
- !(member.isField && member.isConst) &&
- member.library.canonicalUri == Uris.dart_isolate) {
- _backendUsage.isIsolateInUse = true;
- worldImpact
- .addImpact(_enableIsolateSupport(_elementEnvironment.mainFunction));
- }
-
if (member.isGetter && member.name == Identifiers.runtimeType_) {
// Enable runtime type support if we discover a getter called
// runtimeType. We have to enable runtime type before hitting the
@@ -425,10 +385,6 @@
_interceptorData.addInterceptorsForNativeClassMembers(cls);
} else if (cls == _commonElements.jsIndexingBehaviorInterface) {
_registerBackendImpact(impactBuilder, _impacts.jsIndexingBehavior);
- } else if (cls.library.canonicalUri == Uris.dart_isolate) {
- _backendUsage.isIsolateInUse = true;
- impactBuilder
- .addImpact(_enableIsolateSupport(_elementEnvironment.mainFunction));
}
_customElementsAnalysis.registerInstantiatedClass(cls);
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
index a158ff2..e333f45 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/emitter.dart
@@ -278,11 +278,6 @@
jsAst.Name get makeConstListProperty =>
namer.internalGlobal('makeConstantList');
- /// The name of the property that contains all field names.
- ///
- /// This property is added to constructors when isolate support is enabled.
- static const String FIELD_NAMES_PROPERTY_NAME = r"$__fields__";
-
/// For deferred loading we communicate the initializers via this global var.
final String deferredInitializers = r"$dart_deferred_initializers$";
@@ -374,13 +369,6 @@
generateEmbeddedGlobalAccessString(embeddedNames.TYPES);
return jsAst.js.expressionTemplateFor("$typesAccess[#]");
- case JsBuiltin.createDartClosureFromNameOfStaticFunction:
- // The global-functions map contains a map from name to tear-off
- // getters.
- String functionGettersMap =
- generateEmbeddedGlobalAccessString(embeddedNames.GLOBAL_FUNCTIONS);
- return jsAst.js.expressionTemplateFor("$functionGettersMap[#]()");
-
default:
reporter.internalError(
NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin");
@@ -1115,18 +1103,7 @@
cspPrecompiledFunctionFor(outputUnit)
.add(new jsAst.FunctionDeclaration(constructorName, constructorAst));
- String fieldNamesProperty = FIELD_NAMES_PROPERTY_NAME;
- bool hasIsolateSupport = _closedWorld.backendUsage.isIsolateInUse;
- jsAst.Node fieldNamesArray;
- if (hasIsolateSupport) {
- fieldNamesArray =
- new jsAst.ArrayInitializer(fields.map(js.quoteName).toList());
- } else {
- fieldNamesArray = new jsAst.LiteralNull();
- }
-
- cspPrecompiledFunctionFor(outputUnit).add(js.statement(
- r'''
+ cspPrecompiledFunctionFor(outputUnit).add(js.statement(r'''
{
#constructorName.#typeNameProperty = #constructorNameString;
// IE does not have a name property.
@@ -1134,18 +1111,11 @@
#constructorName.name = #constructorNameString;
$desc = $collectedClasses$.#constructorName[1];
#constructorName.prototype = $desc;
- ''' /* next string is not a raw string */ '''
- if (#hasIsolateSupport) {
- #constructorName.$fieldNamesProperty = #fieldNamesArray;
- }
- }''',
- {
- "constructorName": constructorName,
- "typeNameProperty": typeNameProperty,
- "constructorNameString": js.quoteName(constructorName),
- "hasIsolateSupport": hasIsolateSupport,
- "fieldNamesArray": fieldNamesArray
- }));
+ }''', {
+ "constructorName": constructorName,
+ "typeNameProperty": typeNameProperty,
+ "constructorNameString": js.quoteName(constructorName),
+ }));
cspPrecompiledConstructorNamesFor(outputUnit).add(js('#', constructorName));
}
diff --git a/pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart b/pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart
index e734b9d..b8df5d2 100644
--- a/pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/full_emitter/setup_program_builder.dart
@@ -35,8 +35,6 @@
ClosedWorld closedWorld) {
jsAst.Expression typeInformationAccess =
emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPE_INFORMATION);
- jsAst.Expression globalFunctionsAccess =
- emitter.generateEmbeddedGlobalAccess(embeddedNames.GLOBAL_FUNCTIONS);
jsAst.Expression staticsAccess =
emitter.generateEmbeddedGlobalAccess(embeddedNames.STATICS);
jsAst.Expression interceptedNamesAccess =
@@ -49,10 +47,6 @@
emitter.generateEmbeddedGlobalAccess(embeddedNames.LIBRARIES);
jsAst.Expression typesAccess =
emitter.generateEmbeddedGlobalAccess(embeddedNames.TYPES);
- jsAst.Expression createNewIsolateFunctionAccess =
- emitter.generateEmbeddedGlobalAccess(embeddedNames.CREATE_NEW_ISOLATE);
- jsAst.Expression classIdExtractorAccess =
- emitter.generateEmbeddedGlobalAccess(embeddedNames.CLASS_ID_EXTRACTOR);
jsAst.Expression allClassesAccess =
emitter.generateEmbeddedGlobalAccess(embeddedNames.ALL_CLASSES);
jsAst.Expression precompiledAccess =
@@ -63,12 +57,6 @@
emitter.generateEmbeddedGlobalAccess(embeddedNames.INTERCEPTORS_BY_TAG);
jsAst.Expression leafTagsAccess =
emitter.generateEmbeddedGlobalAccess(embeddedNames.LEAF_TAGS);
- jsAst.Expression initializeEmptyInstanceAccess = emitter
- .generateEmbeddedGlobalAccess(embeddedNames.INITIALIZE_EMPTY_INSTANCE);
- jsAst.Expression classFieldsExtractorAccess = emitter
- .generateEmbeddedGlobalAccess(embeddedNames.CLASS_FIELDS_EXTRACTOR);
- jsAst.Expression instanceFromClassIdAccess = emitter
- .generateEmbeddedGlobalAccess(embeddedNames.INSTANCE_FROM_CLASS_ID);
String reflectableField = namer.reflectableField;
String reflectionInfoField = namer.reflectionInfoField;
@@ -108,21 +96,12 @@
'staticsPropertyName': namer.staticsPropertyName,
'staticsPropertyNameString': js.quoteName(namer.staticsPropertyName),
'typeInformation': typeInformationAccess,
- 'globalFunctions': globalFunctionsAccess,
'enabledInvokeOn': closedWorld.backendUsage.isInvokeOnUsed,
'interceptedNames': interceptedNamesAccess,
'interceptedNamesSet': emitter.generateInterceptedNamesSet(),
'notInCspMode': !compiler.options.useContentSecurityPolicy,
'inCspMode': compiler.options.useContentSecurityPolicy,
'deferredAction': namer.deferredAction,
- 'hasIsolateSupport': program.hasIsolateSupport,
- 'fieldNamesProperty': js.string(Emitter.FIELD_NAMES_PROPERTY_NAME),
- 'createNewIsolateFunction': createNewIsolateFunctionAccess,
- 'isolateName': namer.isolateName,
- 'classIdExtractor': classIdExtractorAccess,
- 'classFieldsExtractor': classFieldsExtractorAccess,
- 'instanceFromClassId': instanceFromClassIdAccess,
- 'initializeEmptyInstance': initializeEmptyInstanceAccess,
'allClasses': allClassesAccess,
'debugFastObjects': DEBUG_FAST_OBJECTS,
'isTreeShakingDisabled': backend.mirrorsData.isTreeShakingDisabled,
@@ -232,13 +211,11 @@
var str = "function " + name + "(";
var body = "";
- if (#hasIsolateSupport) { var fieldNames = ""; }
for (var i = 0; i < fields.length; i++) {
if(i != 0) str += ", ";
var field = generateAccessor(fields[i], accessors, name);
- if (#hasIsolateSupport) { fieldNames += "'" + field + "',"; }
var parameter = "p_" + field;
str += parameter;
body += ("this." + field + " = " + parameter + ";\\n");
@@ -253,39 +230,11 @@
if (typeof defineClass.name != "string") {
str += name + ".name=\\"" + name + "\\";\\n";
}
- if (#hasIsolateSupport) {
- str += name + "." + #fieldNamesProperty + "=[" + fieldNames
- + "];\\n";
- }
str += accessors.join("");
return str;
}
- if (#hasIsolateSupport) {
- #createNewIsolateFunction = function() { return new #isolateName(); };
-
- #classIdExtractor = function(o) { return o.constructor.name; };
-
- #classFieldsExtractor = function(o) {
- var fieldNames = o.constructor.#fieldNamesProperty;
- if (!fieldNames) return []; // TODO(floitsch): do something else here.
- var result = [];
- result.length = fieldNames.length;
- for (var i = 0; i < fieldNames.length; i++) {
- result[i] = o[fieldNames[i]];
- }
- return result;
- };
-
- #instanceFromClassId = function(name) { return new #allClasses[name](); };
-
- #initializeEmptyInstance = function(name, o, fields) {
- #allClasses[name].apply(o, fields);
- return o;
- }
- }
-
// If the browser supports changing the prototype via __proto__, we make
// use of that feature. Otherwise, we copy the properties into a new
// constructor.
@@ -629,7 +578,6 @@
} else if (typeof element === "function") {
globalObject[previousProperty = property] = element;
functions.push(property);
- #globalFunctions[property] = element;
} else if (element.constructor === Array) {
if (#needsStructuredMemberInfo) {
addStubs(globalObject, element, property, true, functions);
@@ -732,9 +680,7 @@
f = tearOff(funcs, array, isStatic, name, isIntercepted);
prototype[name].\$getter = f;
f.\$getterStub = true;
- // Used to create an isolate using spawnFunction.
if (isStatic) {
- #globalFunctions[name] = f;
functions.push(getterStubName);
}
prototype[getterStubName] = f;
@@ -795,7 +741,6 @@
if (!#mangledGlobalNames) #mangledGlobalNames = map();
if (!#statics) #statics = map();
if (!#typeInformation) #typeInformation = map();
- if (!#globalFunctions) #globalFunctions = map();
if (#enabledInvokeOn)
if (!#interceptedNames) #interceptedNames = #interceptedNamesSet;
var libraries = #libraries;
diff --git a/pkg/compiler/lib/src/js_emitter/main_call_stub_generator.dart b/pkg/compiler/lib/src/js_emitter/main_call_stub_generator.dart
index e32b7cc..e20f889 100644
--- a/pkg/compiler/lib/src/js_emitter/main_call_stub_generator.dart
+++ b/pkg/compiler/lib/src/js_emitter/main_call_stub_generator.dart
@@ -6,44 +6,18 @@
import 'package:js_runtime/shared/embedded_names.dart' as embeddedNames;
-import '../common_elements.dart';
import '../elements/entities.dart';
import '../js/js.dart' as jsAst;
import '../js/js.dart' show js;
-import '../js_backend/backend_usage.dart' show BackendUsage;
import 'code_emitter_task.dart' show Emitter;
class MainCallStubGenerator {
- final CommonElements _commonElements;
- final Emitter _emitter;
- final BackendUsage _backendUsage;
-
- MainCallStubGenerator(
- this._commonElements, this._emitter, this._backendUsage);
-
- /// Returns the code equivalent to:
- /// `function(args) { $.startRootIsolate(X.main$closure(), args); }`
- jsAst.Expression _buildIsolateSetupClosure(
- FunctionEntity appMain, FunctionEntity isolateMain) {
- jsAst.Expression mainAccess = _emitter.isolateStaticClosureAccess(appMain);
- // Since we pass the closurized version of the main method to
- // the isolate method, we must make sure that it exists.
- return js('function(a){ #(#, a); }',
- [_emitter.staticFunctionAccess(isolateMain), mainAccess]);
- }
-
- jsAst.Statement generateInvokeMain(FunctionEntity main) {
- jsAst.Expression mainCallClosure = null;
- if (_backendUsage.isIsolateInUse) {
- FunctionEntity isolateMain = _commonElements.startRootIsolate;
- mainCallClosure = _buildIsolateSetupClosure(main, isolateMain);
- } else {
- mainCallClosure = _emitter.staticFunctionAccess(main);
- }
-
+ static jsAst.Statement generateInvokeMain(
+ Emitter emitter, FunctionEntity main) {
+ jsAst.Expression mainCallClosure = emitter.staticFunctionAccess(main);
jsAst.Expression currentScriptAccess =
- _emitter.generateEmbeddedGlobalAccess(embeddedNames.CURRENT_SCRIPT);
+ emitter.generateEmbeddedGlobalAccess(embeddedNames.CURRENT_SCRIPT);
// This code finds the currently executing script by listening to the
// onload event of all script tags and getting the first script which
diff --git a/pkg/compiler/lib/src/js_emitter/model.dart b/pkg/compiler/lib/src/js_emitter/model.dart
index 3634ee2..a66b830 100644
--- a/pkg/compiler/lib/src/js_emitter/model.dart
+++ b/pkg/compiler/lib/src/js_emitter/model.dart
@@ -16,7 +16,6 @@
final List<Holder> holders;
final bool outputContainsConstantList;
final bool needsNativeSupport;
- final bool hasIsolateSupport;
final bool hasSoftDeferredClasses;
/// A map from load id to the list of fragments that need to be loaded.
@@ -40,11 +39,9 @@
this.typeToInterceptorMap, this._metadataCollector, this.finalizers,
{this.needsNativeSupport,
this.outputContainsConstantList,
- this.hasIsolateSupport,
this.hasSoftDeferredClasses}) {
assert(needsNativeSupport != null);
assert(outputContainsConstantList != null);
- assert(hasIsolateSupport != null);
}
/// Accessor for the list of metadata entries for a given [OutputUnit].
diff --git a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
index 3008c2c..3a78a8f 100644
--- a/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
+++ b/pkg/compiler/lib/src/js_emitter/program_builder/program_builder.dart
@@ -277,7 +277,6 @@
_buildTypeToInterceptorMap(), _task.metadataCollector, finalizers,
needsNativeSupport: needsNativeSupport,
outputContainsConstantList: collector.outputContainsConstantList,
- hasIsolateSupport: _backendUsage.isIsolateInUse,
hasSoftDeferredClasses: _notSoftDeferred != null);
}
@@ -391,10 +390,8 @@
js.Statement _buildInvokeMain() {
if (_isMockCompilation) return js.js.comment("Mock compilation");
-
- MainCallStubGenerator generator = new MainCallStubGenerator(
- _commonElements, _task.emitter, _backendUsage);
- return generator.generateInvokeMain(_mainFunction);
+ return MainCallStubGenerator.generateInvokeMain(
+ _task.emitter, _mainFunction);
}
DeferredFragment _buildDeferredFragment(LibrariesMap librariesMap) {
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
index 4d150cc..29fb797 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/emitter.dart
@@ -5,7 +5,7 @@
library dart2js.js_emitter.startup_emitter;
import 'package:js_runtime/shared/embedded_names.dart'
- show JsBuiltin, METADATA, STATIC_FUNCTION_NAME_TO_CLOSURE, TYPES;
+ show JsBuiltin, METADATA, TYPES;
import '../../common.dart';
import '../../compiler.dart' show Compiler;
@@ -162,11 +162,6 @@
String typesAccess = _emitter.generateEmbeddedGlobalAccessString(TYPES);
return js.js.expressionTemplateFor("$typesAccess[#]");
- case JsBuiltin.createDartClosureFromNameOfStaticFunction:
- String functionAccess = _emitter.generateEmbeddedGlobalAccessString(
- STATIC_FUNCTION_NAME_TO_CLOSURE);
- return js.js.expressionTemplateFor("$functionAccess(#)");
-
default:
reporter.internalError(
NO_LOCATION_SPANNABLE, "Unhandled Builtin: $builtin");
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
index b47e96d..9bb77ff 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/fragment_emitter.dart
@@ -1399,75 +1399,6 @@
js.string(TYPE_TO_INTERCEPTOR_MAP), program.typeToInterceptorMap));
}
- if (program.hasIsolateSupport) {
- String staticStateName = namer.staticStateHolder;
- // TODO(floitsch): this doesn't create a new isolate, but just reuses
- // the current static state. Since we don't run multiple isolates in the
- // same JavaScript context (except for testing) this shouldn't have any
- // impact on real-world programs, though.
- globals.add(new js.Property(js.string(CREATE_NEW_ISOLATE),
- js.js('function () { return $staticStateName; }')));
-
- js.Expression nameToClosureFunction = js.js('''
- // First fetch the static function. From there we can execute its
- // getter function which builds a Dart closure.
- function(name) {
- var staticFunction = getGlobalFromName(name);
- var getterFunction = staticFunction.$tearOffPropertyName;
- return getterFunction();
- }''');
- globals.add(new js.Property(
- js.string(STATIC_FUNCTION_NAME_TO_CLOSURE), nameToClosureFunction));
-
- globals.add(new js.Property(js.string(CLASS_ID_EXTRACTOR),
- js.js('function(o) { return o.constructor.name; }')));
-
- js.Expression extractFieldsFunction = js.js('''
- function(o) {
- var constructor = o.constructor;
- var fieldNames = constructor.$cachedClassFieldNames;
- if (!fieldNames) {
- // Extract the fields from an empty unmodified object.
- var empty = new constructor();
- // This gives us the keys that the constructor sets.
- fieldNames = constructor.$cachedClassFieldNames = Object.keys(empty);
- }
- var result = new Array(fieldNames.length);
- for (var i = 0; i < fieldNames.length; i++) {
- result[i] = o[fieldNames[i]];
- }
- return result;
- }''');
- globals.add(new js.Property(
- js.string(CLASS_FIELDS_EXTRACTOR), extractFieldsFunction));
-
- js.Expression createInstanceFromClassIdFunction = js.js('''
- function(name) {
- var constructor = getGlobalFromName(name);
- return new constructor();
- }
- ''');
- globals.add(new js.Property(js.string(INSTANCE_FROM_CLASS_ID),
- createInstanceFromClassIdFunction));
-
- js.Expression initializeEmptyInstanceFunction = js.js('''
- function(name, o, fields) {
- var constructor = o.constructor;
- // By construction the object `o` is an empty object with the same
- // keys as the one we used in the extract-fields function.
- var fieldNames = Object.keys(o);
- if (fieldNames.length != fields.length) {
- throw new Error("Mismatch during deserialization.");
- }
- for (var i = 0; i < fields.length; i++) {
- o[fieldNames[i]] = fields[i];
- }
- return o;
- }''');
- globals.add(new js.Property(js.string(INITIALIZE_EMPTY_INSTANCE),
- initializeEmptyInstanceFunction));
- }
-
globals.add(emitMangledGlobalNames());
// The [MANGLED_NAMES] table must contain the mapping for const symbols.
diff --git a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
index 869439e..f2ba354 100644
--- a/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
+++ b/pkg/compiler/lib/src/js_emitter/startup_emitter/model_emitter.dart
@@ -9,17 +9,12 @@
import 'package:js_runtime/shared/embedded_names.dart'
show
- CLASS_FIELDS_EXTRACTOR,
- CLASS_ID_EXTRACTOR,
- CREATE_NEW_ISOLATE,
DEFERRED_INITIALIZED,
DEFERRED_LIBRARY_PARTS,
DEFERRED_PART_URIS,
DEFERRED_PART_HASHES,
GET_TYPE_FROM_NAME,
- INITIALIZE_EMPTY_INSTANCE,
INITIALIZE_LOADED_HUNK,
- INSTANCE_FROM_CLASS_ID,
INTERCEPTORS_BY_TAG,
IS_HUNK_INITIALIZED,
IS_HUNK_LOADED,
@@ -28,7 +23,6 @@
MANGLED_NAMES,
METADATA,
NATIVE_SUPERCLASS_TAG_NAME,
- STATIC_FUNCTION_NAME_TO_CLOSURE,
TYPE_TO_INTERCEPTOR_MAP,
TYPES;
diff --git a/pkg/compiler/lib/src/js_model/js_strategy.dart b/pkg/compiler/lib/src/js_model/js_strategy.dart
index 11fa8ee..c4c47a1 100644
--- a/pkg/compiler/lib/src/js_model/js_strategy.dart
+++ b/pkg/compiler/lib/src/js_model/js_strategy.dart
@@ -391,7 +391,6 @@
requiresPreamble: backendUsage.requiresPreamble,
isInvokeOnUsed: backendUsage.isInvokeOnUsed,
isRuntimeTypeUsed: backendUsage.isRuntimeTypeUsed,
- isIsolateInUse: backendUsage.isIsolateInUse,
isFunctionApplyUsed: backendUsage.isFunctionApplyUsed,
isMirrorsUsed: backendUsage.isMirrorsUsed,
isNoSuchMethodUsed: backendUsage.isNoSuchMethodUsed);
diff --git a/pkg/compiler/lib/src/ssa/builder.dart b/pkg/compiler/lib/src/ssa/builder.dart
index a18d29f..2616b59 100644
--- a/pkg/compiler/lib/src/ssa/builder.dart
+++ b/pkg/compiler/lib/src/ssa/builder.dart
@@ -2837,23 +2837,10 @@
node, 'Too many arguments to JS_CURRENT_ISOLATE_CONTEXT.');
}
- if (!backendUsage.isIsolateInUse) {
- // If the isolate library is not used, we just generate code
- // to fetch the static state.
- String name = namer.staticStateHolder;
- push(new HForeignCode(
- js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[],
- nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
- } else {
- // Call a helper method from the isolate library. The isolate
- // library uses its own isolate structure, that encapsulates
- // Leg's isolate.
- MethodElement element = commonElements.currentIsolate;
- if (element == null) {
- reporter.internalError(node, 'Isolate library and compiler mismatch.');
- }
- pushInvokeStatic(null, element, [], typeMask: commonMasks.dynamicType);
- }
+ String name = namer.staticStateHolder;
+ push(new HForeignCode(
+ js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[],
+ nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
}
void handleForeignJsGetFlag(ast.Send node) {
@@ -3025,27 +3012,6 @@
stack.add(graph.addConstantNull(closedWorld));
}
- void handleForeignJsCallInIsolate(ast.Send node) {
- Link<ast.Node> link = node.arguments;
- if (!backendUsage.isIsolateInUse) {
- // If the isolate library is not used, we just invoke the
- // closure.
- visit(link.tail.head);
- push(new HInvokeClosure(new Selector.callClosure(0),
- <HInstruction>[pop()], commonMasks.dynamicType, const <DartType>[]));
- } else {
- // Call a helper method from the isolate library.
- MethodElement element = commonElements.callInIsolate;
- if (element == null) {
- reporter.internalError(node, 'Isolate library and compiler mismatch.');
- }
- List<HInstruction> inputs = <HInstruction>[];
- addGenericSendArgumentsToList(link, inputs);
- pushInvokeStatic(node, element, inputs,
- typeMask: commonMasks.dynamicType);
- }
- }
-
FunctionSignature handleForeignRawFunctionRef(ast.Send node, String name) {
if (node.arguments.isEmpty || !node.arguments.tail.isEmpty) {
reporter.internalError(
@@ -3115,8 +3081,6 @@
handleForeignJs(node);
} else if (name == 'JS_CURRENT_ISOLATE_CONTEXT') {
handleForeignJsCurrentIsolateContext(node);
- } else if (name == 'JS_CALL_IN_ISOLATE') {
- handleForeignJsCallInIsolate(node);
} else if (name == 'DART_CLOSURE_TO_JS') {
handleForeignDartClosureToJs(node, 'DART_CLOSURE_TO_JS');
} else if (name == 'RAW_DART_FUNCTION_REF') {
diff --git a/pkg/compiler/lib/src/ssa/builder_kernel.dart b/pkg/compiler/lib/src/ssa/builder_kernel.dart
index 2d21372..8df2206 100644
--- a/pkg/compiler/lib/src/ssa/builder_kernel.dart
+++ b/pkg/compiler/lib/src/ssa/builder_kernel.dart
@@ -3410,9 +3410,9 @@
if (name == 'JS') {
handleForeignJs(invocation);
} else if (name == 'JS_CURRENT_ISOLATE_CONTEXT') {
+ // TODO(sigmund): delete. The only reference left to this foreign function
+ // is from the deprecated dart:mirrors code.
handleForeignJsCurrentIsolateContext(invocation);
- } else if (name == 'JS_CALL_IN_ISOLATE') {
- handleForeignJsCallInIsolate(invocation);
} else if (name == 'DART_CLOSURE_TO_JS') {
handleForeignDartClosureToJs(invocation, 'DART_CLOSURE_TO_JS');
} else if (name == 'RAW_DART_FUNCTION_REF') {
@@ -3525,57 +3525,12 @@
return;
}
- if (!backendUsage.isIsolateInUse) {
- // If the isolate library is not used, we just generate code
- // to fetch the static state.
- String name = namer.staticStateHolder;
- push(new HForeignCode(
- js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[],
- nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
- } else {
- // Call a helper method from the isolate library. The isolate library uses
- // its own isolate structure that encapsulates the isolate structure used
- // for binding to methods.
- FunctionEntity target = _commonElements.currentIsolate;
- if (target == null) {
- reporter.internalError(
- _elementMap.getSpannable(targetElement, invocation),
- 'Isolate library and compiler mismatch.');
- }
- _pushStaticInvocation(target, <HInstruction>[], commonMasks.dynamicType,
- const <DartType>[]);
- }
- }
-
- void handleForeignJsCallInIsolate(ir.StaticInvocation invocation) {
- if (_unexpectedForeignArguments(invocation,
- minPositional: 2, maxPositional: 2)) {
- // Result expected on stack.
- stack.add(graph.addConstantNull(closedWorld));
- return;
- }
-
- List<HInstruction> inputs = _visitPositionalArguments(invocation.arguments);
-
- if (!backendUsage.isIsolateInUse) {
- // If the isolate library is not used, we ignore the isolate argument and
- // just invoke the closure.
- push(new HInvokeClosure(
- new Selector.callClosure(0),
- <HInstruction>[inputs[1]],
- commonMasks.dynamicType,
- const <DartType>[]));
- } else {
- // Call a helper method from the isolate library.
- FunctionEntity callInIsolate = _commonElements.callInIsolate;
- if (callInIsolate == null) {
- reporter.internalError(
- _elementMap.getSpannable(targetElement, invocation),
- 'Isolate library and compiler mismatch.');
- }
- _pushStaticInvocation(
- callInIsolate, inputs, commonMasks.dynamicType, const <DartType>[]);
- }
+ // Isolates cannot be spawned, so we just generate code to fetch the static
+ // state.
+ String name = namer.staticStateHolder;
+ push(new HForeignCode(
+ js.js.parseForeignJS(name), commonMasks.dynamicType, <HInstruction>[],
+ nativeBehavior: native.NativeBehavior.DEPENDS_OTHER));
}
void handleForeignDartClosureToJs(
diff --git a/pkg/compiler/lib/src/universe/resolution_world_builder.dart b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
index 7983684..ed3c1b9 100644
--- a/pkg/compiler/lib/src/universe/resolution_world_builder.dart
+++ b/pkg/compiler/lib/src/universe/resolution_world_builder.dart
@@ -378,7 +378,6 @@
final ClassQueries classQueries;
bool hasRuntimeTypeSupport = false;
- bool hasIsolateSupport = false;
bool hasFunctionApplySupport = false;
bool _closed = false;
diff --git a/sdk/lib/_internal/js_runtime/lib/async_patch.dart b/sdk/lib/_internal/js_runtime/lib/async_patch.dart
index 0c5c995..eef525c 100644
--- a/sdk/lib/_internal/js_runtime/lib/async_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/async_patch.dart
@@ -8,14 +8,13 @@
show
patch,
ExceptionAndStackTrace,
- Primitives,
convertDartClosureToJS,
getTraceFromException,
requiresPreamble,
wrapException,
unwrapException;
-import 'dart:_isolate_helper'
- show IsolateNatives, TimerImpl, leaveJsAsync, enterJsAsync, isWorker;
+
+import 'dart:_isolate_helper' show TimerImpl;
import 'dart:_foreign_helper' show JS, JS_GET_FLAG;
@@ -47,7 +46,6 @@
var storedCallback;
internalCallback(_) {
- leaveJsAsync();
var f = storedCallback;
storedCallback = null;
f();
@@ -59,7 +57,6 @@
return (void callback()) {
assert(storedCallback == null);
- enterJsAsync();
storedCallback = callback;
// Because of a broken shadow-dom polyfill we have to change the
// children instead a cheap property.
@@ -76,24 +73,20 @@
static void _scheduleImmediateJsOverride(void callback()) {
internalCallback() {
- leaveJsAsync();
callback();
}
;
- enterJsAsync();
JS('void', 'self.scheduleImmediate(#)',
convertDartClosureToJS(internalCallback, 0));
}
static void _scheduleImmediateWithSetImmediate(void callback()) {
internalCallback() {
- leaveJsAsync();
callback();
}
;
- enterJsAsync();
JS('void', 'self.setImmediate(#)',
convertDartClosureToJS(internalCallback, 0));
}
diff --git a/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart b/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
index 0daec2f..4c6b4ab 100644
--- a/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/foreign_helper.dart
@@ -190,11 +190,6 @@
}
/**
- * Invokes [function] in the context of [isolate].
- */
-external JS_CALL_IN_ISOLATE(isolate, Function function);
-
-/**
* Converts the Dart closure [function] into a JavaScript closure.
*
* Warning: This is no different from [RAW_DART_FUNCTION_REF] which means care
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart b/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
index 1b9ccc2..01f890b 100644
--- a/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/isolate_helper.dart
@@ -4,1365 +4,87 @@
library _isolate_helper;
-import 'dart:_js_embedded_names'
- show
- CLASS_ID_EXTRACTOR,
- CLASS_FIELDS_EXTRACTOR,
- CREATE_NEW_ISOLATE,
- CURRENT_SCRIPT,
- INITIALIZE_EMPTY_INSTANCE,
- INSTANCE_FROM_CLASS_ID,
- STATIC_FUNCTION_NAME_PROPERTY_NAME;
-
import 'dart:async';
-import 'dart:collection' show Queue;
import 'dart:isolate';
-import 'dart:_native_typed_data' show NativeByteBuffer, NativeTypedData;
+
+import 'dart:_js_embedded_names' show CURRENT_SCRIPT;
import 'dart:_js_helper'
- show
- Closure,
- InternalMap,
- Primitives,
- convertDartClosureToJS,
- createDartClosureFromNameOfStaticFunction,
- isDartObject,
- random64,
- requiresPreamble;
+ show convertDartClosureToJS, random64, requiresPreamble;
-import 'dart:_foreign_helper'
- show
- DART_CLOSURE_TO_JS,
- JS,
- JS_CURRENT_ISOLATE_CONTEXT,
- JS_EMBEDDED_GLOBAL,
- JS_SET_STATIC_STATE,
- IsolateContext;
+import 'dart:_foreign_helper' show JS, JS_EMBEDDED_GLOBAL;
-import 'dart:_interceptors'
- show
- Interceptor,
- JSArray,
- JSExtendableArray,
- JSFixedArray,
- JSIndexable,
- JSMutableArray,
- JSObject;
-
-part 'isolate_serialization.dart';
-
-/**
- * Called by the compiler to support switching
- * between isolates when we get a callback from the DOM.
- */
-_callInIsolate(_IsolateContext isolate, Function function) {
- var result = isolate.eval(function);
- // If we are not already running the event-loop start it now.
- if (!_currentIsolate()._isExecutingEvent) _globalState.topEventLoop.run();
- return result;
-}
-
-/// Marks entering a JavaScript async operation to keep the worker alive.
-///
-/// To be called by library code before starting an async operation controlled
-/// by the JavaScript event handler.
-///
-/// Also call [leaveJsAsync] in all callback handlers marking the end of that
-/// async operation (also error handlers) so the worker can be released.
-///
-/// These functions only has to be called for code that can be run from a
-/// worker-isolate (so not for general dom operations).
-enterJsAsync() {}
-
-/// Marks leaving a javascript async operation.
-///
-/// See [enterJsAsync].
-leaveJsAsync() {}
+import 'dart:_interceptors' show JSExtendableArray;
/// Returns true if we are currently in a worker context.
-bool isWorker() => globalWindow == null && globalPostMessageDefined;
-
-/**
- * Called by the compiler to fetch the current isolate context.
- */
-_IsolateContext _currentIsolate() => _globalState.currentContext;
-
-/**
- * Wrapper that takes the dart entry point and runs it within an isolate. The
- * dart2js compiler will inject a call of the form
- * [: startRootIsolate(main); :] when it determines that this wrapping
- * is needed. For single-isolate applications (e.g. hello world), this
- * call is not emitted.
- */
-void startRootIsolate(entry, args) {
- if (args == null) args = [];
- if (args is! List) {
- throw new ArgumentError("Arguments to main must be a List: $args");
- }
- _globalState = new _Manager(entry);
- _globalState._initialize();
-
- // Don't start the main loop again, if we are in a worker.
- if (_globalState.isWorker) return;
- final rootContext = new _IsolateContext();
- _globalState.rootContext = rootContext;
- _globalState.isolates[rootContext.id] = rootContext;
-
- // BUG(5151491): Setting currentContext should not be necessary, but
- // because closures passed to the DOM as event handlers do not bind their
- // isolate automatically we try to give them a reasonable context to live in
- // by having a "default" isolate (the first one created).
- _globalState.currentContext = rootContext;
- if (entry is _MainFunctionArgs) {
- rootContext.eval(() {
- (entry as dynamic)(args);
- });
- } else if (entry is _MainFunctionArgsMessage) {
- rootContext.eval(() {
- (entry as dynamic)(args, null);
- });
- } else {
- rootContext.eval(entry);
- }
- _globalState.topEventLoop.run();
-}
-
-/********************************************************
- Inserted from lib/isolate/dart2js/isolateimpl.dart
- ********************************************************/
-
-/**
- * Concepts used here:
- *
- * "manager" - A manager contains one or more isolates, schedules their
- * execution, and performs other plumbing on their behalf. The isolate
- * present at the creation of the manager is designated as its "root isolate".
- * A manager may, for example, be implemented on a web Worker.
- *
- * [_Manager] - State present within a manager (exactly once, as a global).
- *
- * [_ManagerStub] - A handle held within one manager that allows interaction
- * with another manager. A target manager may be addressed by zero or more
- * [_ManagerStub]s.
- * TODO(ahe): The _ManagerStub concept is broken. It was an attempt
- * to create a common interface between the native Worker class and
- * _MainManagerStub.
- */
-
-/**
- * A native object that is shared across isolates. This object is visible to all
- * isolates running under the same manager (either UI or background web worker).
- *
- * This is code that is intended to 'escape' the isolate boundaries in order to
- * implement the semantics of isolates in JavaScript. Without this we would have
- * been forced to implement more code (including the top-level event loop) in
- * JavaScript itself.
- */
-// TODO(eub, sigmund): move the "manager" to be entirely in JS.
-// Running any Dart code outside the context of an isolate gives it
-// the chance to break the isolate abstraction.
-_Manager get _globalState => JS('_Manager', 'init.globalState');
-
-set _globalState(_Manager val) {
- JS('void', 'init.globalState = #', val);
-}
-
-/** State associated with the current manager. See [globalState]. */
-// TODO(sigmund): split in multiple classes: global, thread, main-worker states?
-class _Manager {
- /** Next available isolate id within this [_Manager]. */
- int nextIsolateId = 0;
-
- /** id assigned to this [_Manager]. */
- int currentManagerId = 0;
-
- /**
- * Next available manager id. Only used by the main manager to assign a unique
- * id to each manager created by it.
- */
- int nextManagerId = 1;
-
- /** Context for the currently running [Isolate]. */
- _IsolateContext currentContext = null;
-
- /** Context for the root [Isolate] that first run in this [_Manager]. */
- _IsolateContext rootContext = null;
-
- /** The top-level event loop. */
- _EventLoop topEventLoop;
-
- /** Whether this program is running from the command line. */
- bool fromCommandLine;
-
- /** Whether this [_Manager] is running as a web worker. */
- bool isWorker;
-
- /** Whether we support spawning web workers. */
- bool supportsWorkers;
-
- /**
- * Whether to use web workers when implementing isolates. Set to false for
- * debugging/testing.
- */
- bool get useWorkers => supportsWorkers;
-
- /**
- * Registry of isolates. Isolates must be registered if, and only if, receive
- * ports are alive. Normally no open receive-ports means that the isolate is
- * dead, but DOM callbacks could resurrect it.
- */
- Map<int, _IsolateContext> isolates;
-
- /** Reference to the main [_Manager]. Null in the main [_Manager] itself. */
- _MainManagerStub mainManager;
-
- /// Registry of active Web Workers. Only used in the main [_Manager].
- Map<int, dynamic /* Worker */ > managers;
-
- /** The entry point given by [startRootIsolate]. */
- final Function entry;
-
- _Manager(this.entry);
-
- _initialize() {
- _nativeDetectEnvironment();
- topEventLoop = new _EventLoop();
- isolates = new Map<int, _IsolateContext>();
- managers = new Map<int, dynamic>();
- if (isWorker) {
- // "if we are not the main manager ourself" is the intent.
- mainManager = new _MainManagerStub();
- _nativeInitWorkerMessageHandler();
- }
- }
-
- void _nativeDetectEnvironment() {
- bool isWindowDefined = globalWindow != null;
- bool isWorkerDefined = globalWorker != null;
-
- // `isWorker` must be initialized now, since `IsolateNatives.thisScript`
- // may access it.
- isWorker = !isWindowDefined && globalPostMessageDefined;
- supportsWorkers =
- isWorker || (isWorkerDefined && IsolateNatives.thisScript != null);
- fromCommandLine = !isWindowDefined && !isWorker;
- }
-
- void _nativeInitWorkerMessageHandler() {
- var function = JS(
- '',
- '(function (f, a) { return function (e) { f(a, e); }})(#, #)',
- DART_CLOSURE_TO_JS(IsolateNatives._processWorkerMessage),
- mainManager);
- JS('void', r'self.onmessage = #', function);
- // We ensure dartPrint is defined so that the implementation of the Dart
- // print method knows what to call.
- JS(
- '',
- '''self.dartPrint = self.dartPrint || (function(serialize) {
- return function (object) {
- if (self.console && self.console.log) {
- self.console.log(object)
- } else {
- self.postMessage(serialize(object));
- }
- }
-})(#)''',
- DART_CLOSURE_TO_JS(_serializePrintMessage));
- }
-
- static _serializePrintMessage(object) {
- return _serializeMessage({'command': 'print', 'msg': object});
- }
-
- /**
- * Close the worker running this code if all isolates are done and
- * there are no active async JavaScript tasks still running.
- */
- void maybeCloseWorker() {
- if (isWorker && isolates.isEmpty && topEventLoop._activeJsAsyncCount == 0) {
- mainManager.postMessage(_serializeMessage({'command': 'close'}));
- }
- }
-}
-
-/** Context information tracked for each isolate. */
-class _IsolateContext implements IsolateContext {
- /** Current isolate id. */
- final int id = _globalState.nextIsolateId++;
-
- /** Registry of receive ports currently active on this isolate. */
- final Map<int, RawReceivePortImpl> ports = new Map<int, RawReceivePortImpl>();
-
- /** Registry of weak receive ports currently active on this isolate. */
- final Set<int> weakPorts = new Set<int>();
-
- /** Holds isolate globals (statics and top-level properties). */
- // native object containing all globals of an isolate.
- final isolateStatics =
- JS('', '#()', JS_EMBEDDED_GLOBAL('', CREATE_NEW_ISOLATE));
-
- final RawReceivePortImpl controlPort = new RawReceivePortImpl._controlPort();
-
- final Capability pauseCapability = new Capability();
- final Capability terminateCapability = new Capability(); // License to kill.
-
- /// Boolean flag set when the initial method of the isolate has been executed.
- ///
- /// Used to avoid considering the isolate dead when it has no open
- /// receive ports and no scheduled timers, because it hasn't had time to
- /// create them yet.
- bool initialized = false;
-
- // TODO(lrn): Store these in single "PauseState" object, so they don't take
- // up as much room when not pausing.
- bool isPaused = false;
- List<_IsolateEvent> delayedEvents = [];
- Set<Capability> pauseTokens = new Set();
-
- // Container with the "on exit" handler send-ports and responses.
- var doneHandlers;
-
- /**
- * Queue of functions to call when the current event is complete.
- *
- * These events are not just put at the front of the event queue, because
- * they represent control messages, and should be handled even if the
- * event queue is paused.
- */
- var _scheduledControlEvents;
- bool _isExecutingEvent = false;
-
- /** Whether uncaught errors are considered fatal. */
- bool errorsAreFatal = true;
-
- // Set of ports that listen to uncaught errors.
- Set<SendPort> errorPorts = new Set();
-
- _IsolateContext() {
- this.registerWeak(controlPort._id, controlPort);
- }
-
- void addPause(Capability authentification, Capability resume) {
- if (pauseCapability != authentification) return;
- if (pauseTokens.add(resume) && !isPaused) {
- isPaused = true;
- }
- _updateGlobalState();
- }
-
- void removePause(Capability resume) {
- if (!isPaused) return;
- pauseTokens.remove(resume);
- if (pauseTokens.isEmpty) {
- while (delayedEvents.isNotEmpty) {
- _IsolateEvent event = delayedEvents.removeLast();
- _globalState.topEventLoop.prequeue(event);
- }
- isPaused = false;
- }
- _updateGlobalState();
- }
-
- void addDoneListener(SendPort responsePort, Object response) {
- if (doneHandlers == null) {
- doneHandlers = [];
- }
- for (int i = 0; i < doneHandlers.length; i += 2) {
- if (responsePort == doneHandlers[i]) {
- doneHandlers[i + 1] = response;
- return;
- }
- }
- doneHandlers.add(responsePort);
- doneHandlers.add(response);
- }
-
- void removeDoneListener(SendPort responsePort) {
- if (doneHandlers == null) return;
- for (int i = 0; i < doneHandlers.length; i += 2) {
- if (responsePort == doneHandlers[i]) {
- doneHandlers.removeRange(i, i + 2);
- return;
- }
- }
- }
-
- void setErrorsFatal(Capability authentification, bool errorsAreFatal) {
- if (terminateCapability != authentification) return;
- this.errorsAreFatal = errorsAreFatal;
- }
-
- void handlePing(SendPort responsePort, int pingType, Object response) {
- if (pingType == Isolate.immediate ||
- (pingType == Isolate.beforeNextEvent && !_isExecutingEvent)) {
- responsePort.send(response);
- return;
- }
- void respond() {
- responsePort.send(response);
- }
-
- assert(pingType == Isolate.beforeNextEvent);
- if (_scheduledControlEvents == null) {
- _scheduledControlEvents = new Queue();
- }
- _scheduledControlEvents.addLast(respond);
- }
-
- void handleKill(Capability authentification, int priority) {
- if (this.terminateCapability != authentification) return;
- if (priority == Isolate.immediate ||
- (priority == Isolate.beforeNextEvent && !_isExecutingEvent)) {
- kill();
- return;
- }
- assert(priority == Isolate.beforeNextEvent);
- if (_scheduledControlEvents == null) {
- _scheduledControlEvents = new Queue();
- }
- _scheduledControlEvents.addLast(kill);
- }
-
- void addErrorListener(SendPort port) {
- errorPorts.add(port);
- }
-
- void removeErrorListener(SendPort port) {
- errorPorts.remove(port);
- }
-
- /** Function called with an uncaught error. */
- void handleUncaughtError(error, StackTrace stackTrace) {
- // Just print the error if there is no error listener registered.
- if (errorPorts.isEmpty) {
- // An uncaught error in the root isolate will terminate the program?
- if (errorsAreFatal && identical(this, _globalState.rootContext)) {
- // The error will be rethrown to reach the global scope, so
- // don't print it.
- return;
- }
- if (JS('bool', 'self.console && self.console.error')) {
- JS('void', 'self.console.error(#, #)', error, stackTrace);
- } else {
- print(error);
- if (stackTrace != null) print(stackTrace);
- }
- return;
- }
- List message = new List(2)
- ..[0] = error.toString()
- ..[1] = (stackTrace == null) ? null : stackTrace.toString();
- for (SendPort port in errorPorts) port.send(message);
- }
-
- /**
- * Run [code] in the context of the isolate represented by [this].
- */
- dynamic eval(Function code) {
- var old = _globalState.currentContext;
- _globalState.currentContext = this;
- this._setGlobals();
- var result = null;
- var oldIsExecutingEvent = _isExecutingEvent;
- _isExecutingEvent = true;
- try {
- result = code();
- } catch (e, s) {
- handleUncaughtError(e, s);
- if (errorsAreFatal) {
- kill();
- // An uncaught error in the root context terminates all isolates.
- if (identical(this, _globalState.rootContext)) {
- rethrow;
- }
- }
- } finally {
- _isExecutingEvent = oldIsExecutingEvent;
- _globalState.currentContext = old;
- if (old != null) old._setGlobals();
- if (_scheduledControlEvents != null) {
- while (_scheduledControlEvents.isNotEmpty) {
- (_scheduledControlEvents.removeFirst())();
- }
- }
- }
- return result;
- }
-
- void _setGlobals() {
- JS_SET_STATIC_STATE(isolateStatics);
- }
-
- /**
- * Handle messages coming in on the control port.
- *
- * These events do not go through the event queue.
- * The `_globalState.currentContext` context is not set to this context
- * during the handling.
- */
- void handleControlMessage(message) {
- switch (message[0]) {
- case 'pause':
- addPause(message[1], message[2]);
- break;
- case 'resume':
- removePause(message[1]);
- break;
- case 'add-ondone':
- addDoneListener(message[1], message[2]);
- break;
- case 'remove-ondone':
- removeDoneListener(message[1]);
- break;
- case 'set-errors-fatal':
- setErrorsFatal(message[1], message[2]);
- break;
- case 'ping':
- handlePing(message[1], message[2], message[3]);
- break;
- case 'kill':
- handleKill(message[1], message[2]);
- break;
- case 'getErrors':
- addErrorListener(message[1]);
- break;
- case 'stopErrors':
- removeErrorListener(message[1]);
- break;
- default:
- }
- }
-
- /** Looks up a port registered for this isolate. */
- RawReceivePortImpl lookup(int portId) => ports[portId];
-
- void _addRegistration(int portId, RawReceivePortImpl port) {
- if (ports.containsKey(portId)) {
- throw new Exception('Registry: ports must be registered only once.');
- }
- ports[portId] = port;
- }
-
- /** Registers a port on this isolate. */
- void register(int portId, RawReceivePortImpl port) {
- _addRegistration(portId, port);
- _updateGlobalState();
- }
-
- /**
- * Registers a weak port on this isolate.
- *
- * The port does not keep the isolate active.
- */
- void registerWeak(int portId, RawReceivePortImpl port) {
- weakPorts.add(portId);
- _addRegistration(portId, port);
- }
-
- void _updateGlobalState() {
- if (ports.length - weakPorts.length > 0 || isPaused || !initialized) {
- _globalState.isolates[id] = this; // indicate this isolate is active
- } else {
- kill();
- }
- }
-
- void kill() {
- if (_scheduledControlEvents != null) {
- // Kill all pending events.
- _scheduledControlEvents.clear();
- }
- // Stop listening on all ports.
- // This should happen before sending events to done handlers, in case
- // we are listening on ourselves.
- // Closes all ports, including control port.
- for (var port in ports.values) {
- port._close();
- }
- ports.clear();
- weakPorts.clear();
- _globalState.isolates.remove(id); // indicate this isolate is not active
- errorPorts.clear();
- if (doneHandlers != null) {
- for (int i = 0; i < doneHandlers.length; i += 2) {
- SendPort responsePort = doneHandlers[i];
- Object response = doneHandlers[i + 1];
- responsePort.send(response);
- }
- doneHandlers = null;
- }
- }
-
- /** Unregister a port on this isolate. */
- void unregister(int portId) {
- ports.remove(portId);
- weakPorts.remove(portId);
- _updateGlobalState();
- }
-}
-
-/** Represent the event loop on a javascript thread (DOM or worker). */
-class _EventLoop {
- final Queue<_IsolateEvent> events = new Queue<_IsolateEvent>();
-
- /// The number of waiting callbacks not controlled by the dart event loop.
- ///
- /// This could be timers or http requests. The worker will only be killed if
- /// this count reaches 0.
- /// Access this by using [enterJsAsync] before starting a JavaScript async
- /// operation and [leaveJsAsync] when the callback has fired.
- int _activeJsAsyncCount = 0;
-
- _EventLoop();
-
- void enqueue(isolate, fn, msg) {
- events.addLast(new _IsolateEvent(isolate, fn, msg));
- }
-
- void prequeue(_IsolateEvent event) {
- events.addFirst(event);
- }
-
- _IsolateEvent dequeue() {
- if (events.isEmpty) return null;
- return events.removeFirst();
- }
-
- void checkOpenReceivePortsFromCommandLine() {
- if (_globalState.rootContext != null &&
- _globalState.isolates.containsKey(_globalState.rootContext.id) &&
- _globalState.fromCommandLine &&
- _globalState.rootContext.ports.isEmpty) {
- // We want to reach here only on the main [_Manager] and only
- // on the command-line. In the browser the isolate might
- // still be alive due to DOM callbacks, but the presumption is
- // that on the command-line, no future events can be injected
- // into the event queue once it's empty. Node has setTimeout
- // so this presumption is incorrect there. We think(?) that
- // in d8 this assumption is valid.
- throw new Exception('Program exited with open ReceivePorts.');
- }
- }
-
- /** Process a single event, if any. */
- bool runIteration() {
- final event = dequeue();
- if (event == null) {
- checkOpenReceivePortsFromCommandLine();
- _globalState.maybeCloseWorker();
- return false;
- }
- event.process();
- return true;
- }
-
- /**
- * Runs multiple iterations of the run-loop. If possible, each iteration is
- * run asynchronously.
- */
- void _runHelper() {
- if (globalWindow != null) {
- // Run each iteration from the browser's top event loop.
- void next() {
- if (!runIteration()) return;
- Timer.run(next);
- }
-
- next();
- } else {
- // Run synchronously until no more iterations are available.
- while (runIteration()) {}
- }
- }
-
- /**
- * Call [_runHelper] but ensure that worker exceptions are propagated.
- */
- void run() {
- if (!_globalState.isWorker) {
- _runHelper();
- } else {
- try {
- _runHelper();
- } catch (e, trace) {
- _globalState.mainManager.postMessage(
- _serializeMessage({'command': 'error', 'msg': '$e\n$trace'}));
- }
- }
- }
-}
-
-/** An event in the top-level event queue. */
-class _IsolateEvent {
- _IsolateContext isolate;
- Function fn;
- String message;
-
- _IsolateEvent(this.isolate, this.fn, this.message);
-
- void process() {
- if (isolate.isPaused) {
- isolate.delayedEvents.add(this);
- return;
- }
- isolate.eval(fn);
- }
-}
-
-/** A stub for interacting with the main manager. */
-class _MainManagerStub {
- void postMessage(msg) {
- // "self" is a way to refer to the global context object that
- // works in HTML pages and in Web Workers. It does not work in d8
- // and Firefox jsshell, because that would have been too easy.
- //
- // See: http://www.w3.org/TR/workers/#the-global-scope
- // and: http://www.w3.org/TR/Window/#dfn-self-attribute
- requiresPreamble();
- JS('void', r'self.postMessage(#)', msg);
- }
-}
-
-const String _SPAWNED_SIGNAL = 'spawned';
-const String _SPAWN_FAILED_SIGNAL = 'spawn failed';
-
-get globalWindow {
+bool isWorker() {
requiresPreamble();
- return JS('', 'self.window');
+ return JS('', '!self.window && !!self.postMessage');
}
-get globalWorker {
- requiresPreamble();
- return JS('', 'self.Worker');
+/// The src url for the script tag that loaded this code.
+String thisScript = computeThisScript();
+
+/// The src url for the script tag that loaded this function.
+///
+/// Used to create JavaScript workers and load deferred libraries.
+String computeThisScript() {
+ var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT);
+ if (currentScript != null) {
+ return JS('String', 'String(#.src)', currentScript);
+ }
+ // A worker has no script tag - so get an url from a stack-trace.
+ if (isWorker()) return _computeThisScriptFromTrace();
+ // An isolate that doesn't support workers, but doesn't have a
+ // currentScript either. This is most likely a Chrome extension.
+ return null;
}
-bool get globalPostMessageDefined {
- requiresPreamble();
- return JS('bool', '!!self.postMessage');
-}
-
-typedef _MainFunction();
-typedef _MainFunctionArgs(Null args);
-typedef _MainFunctionArgsMessage(Null args, Null message);
-
-/// Note: IsolateNatives depends on _globalState which is only set up correctly
-/// when 'dart:isolate' has been imported.
-class IsolateNatives {
- // We set [enableSpawnWorker] to true (not null) when calling isolate
- // primitives that require support for spawning workers. The field starts out
- // by being null, and dart2js' type inference will track if it can have a
- // non-null value. So by testing if this value is not null, we generate code
- // that dart2js knows is dead when worker support isn't needed.
- // TODO(herhut): Initialize this to false when able to track compile-time
- // constants.
- static var enableSpawnWorker;
-
- static String thisScript = computeThisScript();
-
- /// Returns the base path added to Uri.base to resolve `package:` Uris.
- ///
- /// This is used by `Isolate.resolvePackageUri` to load resources. The default
- /// value is `packages/` but users can override this by using the
- /// `defaultPackagesBase` hook.
- static String get packagesBase =>
- JS('String', r'self.defaultPackagesBase || "packages/"');
-
- /// Associates an ID with a native worker object.
- static final Expando<int> workerIds = new Expando<int>();
-
- /**
- * The src url for the script tag that loaded this function.
- *
- * Used to create JavaScript workers and load deferred libraries.
- */
- static String computeThisScript() {
- var currentScript = JS_EMBEDDED_GLOBAL('', CURRENT_SCRIPT);
- if (currentScript != null) {
- return JS('String', 'String(#.src)', currentScript);
- }
- // A worker has no script tag - so get an url from a stack-trace.
- if (isWorker()) return computeThisScriptFromTrace();
- // An isolate that doesn't support workers, but doesn't have a
- // currentScript either. This is most likely a Chrome extension.
- return null;
+String _computeThisScriptFromTrace() {
+ var stack = JS('String|Null', 'new Error().stack');
+ if (stack == null) {
+ // According to Internet Explorer documentation, the stack
+ // property is not set until the exception is thrown. The stack
+ // property was not provided until IE10.
+ stack = JS(
+ 'String|Null',
+ '(function() {'
+ 'try { throw new Error() } catch(e) { return e.stack }'
+ '})()');
+ if (stack == null) throw new UnsupportedError('No stack trace');
}
+ var pattern, matches;
- static String computeThisScriptFromTrace() {
- var stack = JS('String|Null', 'new Error().stack');
- if (stack == null) {
- // According to Internet Explorer documentation, the stack
- // property is not set until the exception is thrown. The stack
- // property was not provided until IE10.
- stack = JS(
- 'String|Null',
- '(function() {'
- 'try { throw new Error() } catch(e) { return e.stack }'
- '})()');
- if (stack == null) throw new UnsupportedError('No stack trace');
- }
- var pattern, matches;
+ // This pattern matches V8, Chrome, and Internet Explorer stack
+ // traces that look like this:
+ // Error
+ // at methodName (URI:LINE:COLUMN)
+ pattern = JS('', r'new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m")');
- // This pattern matches V8, Chrome, and Internet Explorer stack
- // traces that look like this:
- // Error
- // at methodName (URI:LINE:COLUMN)
- pattern =
- JS('', r'new RegExp("^ *at [^(]*\\((.*):[0-9]*:[0-9]*\\)$", "m")');
+ matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern);
+ if (matches != null) return JS('String', '#[1]', matches);
- matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern);
- if (matches != null) return JS('String', '#[1]', matches);
+ // This pattern matches Firefox stack traces that look like this:
+ // methodName@URI:LINE
+ pattern = JS('', r'new RegExp("^[^@]*@(.*):[0-9]*$", "m")');
- // This pattern matches Firefox stack traces that look like this:
- // methodName@URI:LINE
- pattern = JS('', r'new RegExp("^[^@]*@(.*):[0-9]*$", "m")');
+ matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern);
+ if (matches != null) return JS('String', '#[1]', matches);
- matches = JS('JSExtendableArray|Null', '#.match(#)', stack, pattern);
- if (matches != null) return JS('String', '#[1]', matches);
-
- throw new UnsupportedError('Cannot extract URI from "$stack"');
- }
-
- /**
- * Assume that [e] is a browser message event and extract its message data.
- * We don't import the dom explicitly so, when workers are disabled, this
- * library can also run on top of nodejs.
- */
- static _getEventData(e) => JS('', '#.data', e);
-
- /**
- * Process messages on a worker, either to control the worker instance or to
- * pass messages along to the isolate running in the worker.
- */
- static void _processWorkerMessage(/* Worker */ sender, e) {
- // Since we are listening on a global event, be graceful about other
- // messages that may not belong to the isolate communication.
- // See Issue #32438
- var data = _getEventData(e);
- if (!_isIsolateMessage(data)) return;
-
- var msg = _deserializeMessage(data);
- if (msg is! JSObject && msg is! Map) return;
-
- switch (msg['command']) {
- case 'start':
- _globalState.currentManagerId = msg['id'];
- String functionName = msg['functionName'];
- Function entryPoint = (functionName == null)
- ? _globalState.entry
- : _getJSFunctionFromName(functionName);
- var args = msg['args'];
- var message = _deserializeMessage(msg['msg']);
- var isSpawnUri = msg['isSpawnUri'];
- var startPaused = msg['startPaused'];
- var replyTo = _deserializeMessage(msg['replyTo']);
- var context = new _IsolateContext();
- _globalState.topEventLoop.enqueue(context, () {
- _startIsolate(
- entryPoint, args, message, isSpawnUri, startPaused, replyTo);
- }, 'worker-start');
- // Make sure we always have a current context in this worker.
- // TODO(7907): This is currently needed because we're using
- // Timers to implement Futures, and this isolate library
- // implementation uses Futures. We should either stop using
- // Futures in this library, or re-adapt if Futures get a
- // different implementation.
- _globalState.currentContext = context;
- _globalState.topEventLoop.run();
- break;
- case 'spawn-worker':
- if (enableSpawnWorker != null) handleSpawnWorkerRequest(msg);
- break;
- case 'message':
- SendPort port = msg['port'];
- // If the port has been closed, we ignore the message.
- if (port != null) {
- msg['port'].send(msg['msg']);
- }
- _globalState.topEventLoop.run();
- break;
- case 'close':
- _globalState.managers.remove(workerIds[sender]);
- JS('void', '#.terminate()', sender);
- _globalState.topEventLoop.run();
- break;
- case 'log':
- _log(msg['msg']);
- break;
- case 'print':
- if (_globalState.isWorker) {
- _globalState.mainManager
- .postMessage(_serializeMessage({'command': 'print', 'msg': msg}));
- } else {
- print(msg['msg']);
- }
- break;
- case 'error':
- throw msg['msg'];
- }
- }
-
- static handleSpawnWorkerRequest(msg) {
- var replyPort = msg['replyPort'];
- spawn(msg['functionName'], msg['uri'], msg['args'], msg['msg'], false,
- msg['isSpawnUri'], msg['startPaused']).then((msg) {
- replyPort.send(msg);
- }, onError: (String errorMessage) {
- replyPort.send([_SPAWN_FAILED_SIGNAL, errorMessage]);
- });
- }
-
- /** Log a message, forwarding to the main [_Manager] if appropriate. */
- static _log(msg) {
- if (_globalState.isWorker) {
- _globalState.mainManager
- .postMessage(_serializeMessage({'command': 'log', 'msg': msg}));
- } else {
- try {
- _consoleLog(msg);
- } catch (e, trace) {
- throw new Exception(trace);
- }
- }
- }
-
- static void _consoleLog(msg) {
- requiresPreamble();
- JS('void', r'self.console.log(#)', msg);
- }
-
- static _getJSFunctionFromName(String functionName) {
- return createDartClosureFromNameOfStaticFunction(functionName);
- }
-
- /**
- * Get a string name for the function, if possible. The result for
- * anonymous functions is browser-dependent -- it may be "" or "anonymous"
- * but you should probably not count on this.
- */
- static String _getJSFunctionName(Function f) {
- return (f is Closure)
- ? JS('String|Null', r'#[#]', f, STATIC_FUNCTION_NAME_PROPERTY_NAME)
- : null;
- }
-
- /** Create a new JavaScript object instance given its constructor. */
- static dynamic _allocate(var ctor) {
- return JS('', 'new #()', ctor);
- }
-
- static Future<List> spawnFunction(
- void topLevelFunction(Null message), var message, bool startPaused) {
- IsolateNatives.enableSpawnWorker = true;
- final name = _getJSFunctionName(topLevelFunction);
- if (name == null) {
- throw new UnsupportedError('only top-level functions can be spawned.');
- }
- bool isLight = false;
- bool isSpawnUri = false;
- return spawn(name, null, null, message, isLight, isSpawnUri, startPaused);
- }
-
- static Future<List> spawnUri(
- Uri uri, List<String> args, var message, bool startPaused) {
- IsolateNatives.enableSpawnWorker = true;
- bool isLight = false;
- bool isSpawnUri = true;
- return spawn(
- null, uri.toString(), args, message, isLight, isSpawnUri, startPaused);
- }
-
- // TODO(sigmund): clean up above, after we make the new API the default:
-
- /// If [uri] is `null` it is replaced with the current script.
- static Future<List> spawn(String functionName, String uri, List<String> args,
- message, bool isLight, bool isSpawnUri, bool startPaused) {
- // Assume that the compiled version of the Dart file lives just next to the
- // dart file.
- // TODO(floitsch): support precompiled version of dart2js output.
- if (uri != null && uri.endsWith('.dart')) uri += '.js';
-
- ReceivePort port = new ReceivePort();
- Completer<List> completer = new Completer();
- port.first.then((msg) {
- if (msg[0] == _SPAWNED_SIGNAL) {
- completer.complete(msg);
- } else {
- assert(msg[0] == _SPAWN_FAILED_SIGNAL);
- completer.completeError(msg[1]);
- }
- });
-
- SendPort signalReply = port.sendPort;
-
- if (_globalState.useWorkers && !isLight) {
- _startWorker(functionName, uri, args, message, isSpawnUri, startPaused,
- signalReply, (String message) => completer.completeError(message));
- } else {
- _startNonWorker(functionName, uri, args, message, isSpawnUri, startPaused,
- signalReply);
- }
- return completer.future;
- }
-
- static void _startWorker(
- String functionName,
- String uri,
- List<String> args,
- message,
- bool isSpawnUri,
- bool startPaused,
- SendPort replyPort,
- void onError(String message)) {
- // Make sure that the args list is a fresh generic list. A newly spawned
- // isolate should be able to assume that the arguments list is an
- // extendable list.
- if (args != null) args = new List<String>.from(args);
- if (_globalState.isWorker) {
- _globalState.mainManager.postMessage(_serializeMessage({
- 'command': 'spawn-worker',
- 'functionName': functionName,
- 'args': args,
- 'msg': message,
- 'uri': uri,
- 'isSpawnUri': isSpawnUri,
- 'startPaused': startPaused,
- 'replyPort': replyPort
- }));
- } else {
- _spawnWorker(functionName, uri, args, message, isSpawnUri, startPaused,
- replyPort, onError);
- }
- }
-
- static void _startNonWorker(
- String functionName,
- String uri,
- List<String> args,
- var message,
- bool isSpawnUri,
- bool startPaused,
- SendPort replyPort) {
- // TODO(eub): support IE9 using an iframe -- Dart issue 1702.
- if (uri != null) {
- throw new UnsupportedError(
- 'Currently spawnUri is not supported without web workers.');
- }
- // Clone the message to enforce the restrictions we have on isolate
- // messages.
- message = _clone(message);
- // Make sure that the args list is a fresh generic list. A newly spawned
- // isolate should be able to assume that the arguments list is an
- // extendable list.
- if (args != null) args = new List<String>.from(args);
- _globalState.topEventLoop.enqueue(new _IsolateContext(), () {
- final func = _getJSFunctionFromName(functionName);
- _startIsolate(func, args, message, isSpawnUri, startPaused, replyPort);
- }, 'nonworker start');
- }
-
- static Isolate get currentIsolate {
- _IsolateContext context = JS_CURRENT_ISOLATE_CONTEXT();
- return new Isolate(context.controlPort.sendPort,
- pauseCapability: context.pauseCapability,
- terminateCapability: context.terminateCapability);
- }
-
- static void _startIsolate(Function topLevel, List<String> args, message,
- bool isSpawnUri, bool startPaused, SendPort replyTo) {
- _IsolateContext context = JS_CURRENT_ISOLATE_CONTEXT();
- Primitives.initializeStatics(context.id);
- // The isolate's port does not keep the isolate open.
- replyTo.send([
- _SPAWNED_SIGNAL,
- context.controlPort.sendPort,
- context.pauseCapability,
- context.terminateCapability
- ]);
-
- void runStartFunction() {
- context.initialized = true;
- if (!isSpawnUri) {
- topLevel(message);
- } else if (topLevel is _MainFunctionArgsMessage) {
- topLevel(args, message);
- } else if (topLevel is _MainFunctionArgs) {
- topLevel(args);
- } else {
- topLevel();
- }
- context._updateGlobalState();
- }
-
- if (startPaused) {
- context.addPause(context.pauseCapability, context.pauseCapability);
- _globalState.topEventLoop
- .enqueue(context, runStartFunction, 'start isolate');
- } else {
- runStartFunction();
- }
- }
-
- /**
- * Spawns an isolate in a worker. [factoryName] is the Javascript constructor
- * name for the isolate entry point class.
- */
- static void _spawnWorker(
- functionName,
- String uri,
- List<String> args,
- message,
- bool isSpawnUri,
- bool startPaused,
- SendPort replyPort,
- void onError(String message)) {
- if (uri == null) uri = thisScript;
- final worker = JS('var', 'new Worker(#)', uri);
- // Trampolines are used when wanting to call a Dart closure from
- // JavaScript. The helper function DART_CLOSURE_TO_JS only accepts
- // top-level or static methods, and the trampoline allows us to capture
- // arguments and values which can be passed to a static method.
- final onerrorTrampoline = JS(
- '',
- '''
-(function (f, u, c) {
- return function(e) {
- return f(e, u, c)
- }
-})(#, #, #)''',
- DART_CLOSURE_TO_JS(workerOnError),
- uri,
- onError);
- JS('void', '#.onerror = #', worker, onerrorTrampoline);
-
- var processWorkerMessageTrampoline = JS(
- '',
- """
-(function (f, a) {
- return function (e) {
- // We can stop listening for errors when the first message is received as
- // we only listen for messages to determine if the uri was bad.
- e.onerror = null;
- return f(a, e);
- }
-})(#, #)""",
- DART_CLOSURE_TO_JS(_processWorkerMessage),
- worker);
- JS('void', '#.onmessage = #', worker, processWorkerMessageTrampoline);
- var workerId = _globalState.nextManagerId++;
- // We also store the id on the worker itself so that we can unregister it.
- workerIds[worker] = workerId;
- _globalState.managers[workerId] = worker;
- JS(
- 'void',
- '#.postMessage(#)',
- worker,
- _serializeMessage({
- 'command': 'start',
- 'id': workerId,
- // Note: we serialize replyPort twice because the child worker needs to
- // first deserialize the worker id, before it can correctly deserialize
- // the port (port deserialization is sensitive to what is the current
- // workerId).
- 'replyTo': _serializeMessage(replyPort),
- 'args': args,
- 'msg': _serializeMessage(message),
- 'isSpawnUri': isSpawnUri,
- 'startPaused': startPaused,
- 'functionName': functionName
- }));
- }
-
- static bool workerOnError(
- /* Event */ event,
- String uri,
- void onError(String message)) {
- // Attempt to shut up the browser, as the error has been handled. Chrome
- // ignores this :-(
- JS('void', '#.preventDefault()', event);
- String message = JS('String|Null', '#.message', event);
- if (message == null) {
- // Some browsers, including Chrome, fail to provide a proper error
- // event.
- message = 'Error spawning worker for $uri';
- } else {
- message = 'Error spawning worker for $uri ($message)';
- }
- onError(message);
- return true;
- }
-}
-
-/********************************************************
- Inserted from lib/isolate/dart2js/ports.dart
- ********************************************************/
-
-/** Common functionality to all send ports. */
-abstract class _BaseSendPort implements SendPort {
- /** Id for the destination isolate. */
- final int _isolateId;
-
- const _BaseSendPort(this._isolateId);
-
- void _checkReplyTo(SendPort replyTo) {
- if (replyTo != null &&
- replyTo is! _NativeJsSendPort &&
- replyTo is! _WorkerSendPort) {
- throw new Exception('SendPort.send: Illegal replyTo port type');
- }
- }
-
- void send(var message);
- bool operator ==(var other);
- int get hashCode;
-}
-
-/** A send port that delivers messages in-memory via native JavaScript calls. */
-class _NativeJsSendPort extends _BaseSendPort implements SendPort {
- final RawReceivePortImpl _receivePort;
-
- const _NativeJsSendPort(this._receivePort, int isolateId) : super(isolateId);
-
- void send(var message) {
- // Check that the isolate still runs and the port is still open
- final isolate = _globalState.isolates[_isolateId];
- if (isolate == null) return;
- if (_receivePort._isClosed) return;
- // Clone the message to enforce the restrictions we have on isolate
- // messages.
- var msg = _clone(message);
- if (isolate.controlPort == _receivePort) {
- isolate.handleControlMessage(msg);
- return;
- }
- _globalState.topEventLoop.enqueue(isolate, () {
- if (!_receivePort._isClosed) {
- _receivePort._add(msg);
- }
- }, 'receive');
- }
-
- bool operator ==(var other) =>
- (other is _NativeJsSendPort) && (_receivePort == other._receivePort);
-
- int get hashCode => _receivePort._id;
-}
-
-/** A send port that delivers messages via worker.postMessage. */
-// TODO(eub): abstract this for iframes.
-class _WorkerSendPort extends _BaseSendPort implements SendPort {
- final int _workerId;
- final int _receivePortId;
-
- const _WorkerSendPort(this._workerId, int isolateId, this._receivePortId)
- : super(isolateId);
-
- void send(var message) {
- final workerMessage =
- _serializeMessage({'command': 'message', 'port': this, 'msg': message});
-
- if (_globalState.isWorker) {
- // Communication from one worker to another go through the
- // main worker.
- _globalState.mainManager.postMessage(workerMessage);
- } else {
- // Deliver the message only if the worker is still alive.
- /* Worker */ var manager = _globalState.managers[_workerId];
- if (manager != null) {
- JS('void', '#.postMessage(#)', manager, workerMessage);
- }
- }
- }
-
- bool operator ==(var other) {
- return (other is _WorkerSendPort) &&
- (_workerId == other._workerId) &&
- (_isolateId == other._isolateId) &&
- (_receivePortId == other._receivePortId);
- }
-
- int get hashCode {
- // TODO(sigmund): use a standard hash when we get one available in corelib.
- return (_workerId << 16) ^ (_isolateId << 8) ^ _receivePortId;
- }
-}
-
-class RawReceivePortImpl implements RawReceivePort {
- static int _nextFreeId = 1;
-
- final int _id;
- Function _handler;
- bool _isClosed = false;
-
- RawReceivePortImpl(this._handler) : _id = _nextFreeId++ {
- _globalState.currentContext.register(_id, this);
- }
-
- RawReceivePortImpl.weak(this._handler) : _id = _nextFreeId++ {
- _globalState.currentContext.registerWeak(_id, this);
- }
-
- // Creates the control port of an isolate.
- // This is created before the isolate context object itself,
- // so it cannot access the static _nextFreeId field.
- RawReceivePortImpl._controlPort()
- : _handler = null,
- _id = 0;
-
- void set handler(Function newHandler) {
- _handler = newHandler;
- }
-
- // Close the port without unregistering it.
- // Used by an isolate context to close all ports when shutting down.
- void _close() {
- _isClosed = true;
- _handler = null;
- }
-
- void close() {
- if (_isClosed) return;
- _isClosed = true;
- _handler = null;
- _globalState.currentContext.unregister(_id);
- }
-
- void _add(dataEvent) {
- if (_isClosed) return;
- _handler(dataEvent);
- }
-
- SendPort get sendPort {
- return new _NativeJsSendPort(this, _globalState.currentContext.id);
- }
+ throw new UnsupportedError('Cannot extract URI from "$stack"');
}
class ReceivePortImpl extends Stream implements ReceivePort {
- final RawReceivePort _rawPort;
- StreamController _controller;
-
- ReceivePortImpl() : this.fromRawReceivePort(new RawReceivePortImpl(null));
-
- ReceivePortImpl.weak()
- : this.fromRawReceivePort(new RawReceivePortImpl.weak(null));
-
- ReceivePortImpl.fromRawReceivePort(this._rawPort) {
- _controller = new StreamController(onCancel: close, sync: true);
- _rawPort.handler = _controller.add;
- }
+ ReceivePortImpl();
StreamSubscription listen(void onData(var event),
{Function onError, void onDone(), bool cancelOnError}) {
- return _controller.stream.listen(onData,
- onError: onError, onDone: onDone, cancelOnError: cancelOnError);
+ throw new UnsupportedError("ReceivePort.listen");
}
- void close() {
- _rawPort.close();
- _controller.close();
- }
+ void close() {}
- SendPort get sendPort => _rawPort.sendPort;
+ SendPort get sendPort => throw new UnsupportedError("ReceivePort.sendPort");
}
class TimerImpl implements Timer {
@@ -1371,16 +93,13 @@
int _tick = 0;
TimerImpl(int milliseconds, void callback()) : _once = true {
- if (hasTimer()) {
+ if (_hasTimer()) {
void internalCallback() {
_handle = null;
- leaveJsAsync();
this._tick = 1;
callback();
}
- enterJsAsync();
-
_handle = JS('int', 'self.setTimeout(#, #)',
convertDartClosureToJS(internalCallback, 0), milliseconds);
} else {
@@ -1390,8 +109,7 @@
TimerImpl.periodic(int milliseconds, void callback(Timer timer))
: _once = false {
- if (hasTimer()) {
- enterJsAsync();
+ if (_hasTimer()) {
int start = JS('int', 'Date.now()');
_handle = JS(
'int',
@@ -1413,12 +131,16 @@
}
}
+ @override
+ bool get isActive => _handle != null;
+
+ @override
int get tick => _tick;
+ @override
void cancel() {
- if (hasTimer()) {
+ if (_hasTimer()) {
if (_handle == null) return;
- leaveJsAsync();
if (_once) {
JS('void', 'self.clearTimeout(#)', _handle);
} else {
@@ -1429,48 +151,9 @@
throw new UnsupportedError('Canceling a timer.');
}
}
-
- bool get isActive => _handle != null;
}
-bool hasTimer() {
+bool _hasTimer() {
requiresPreamble();
return JS('', 'self.setTimeout') != null;
}
-
-/**
- * Implementation class for [Capability].
- *
- * It has the same name to make it harder for users to distinguish.
- */
-class CapabilityImpl implements Capability {
- /** Internal random secret identifying the capability. */
- final int _id;
-
- CapabilityImpl() : this._internal(random64());
-
- CapabilityImpl._internal(this._id);
-
- int get hashCode {
- // Thomas Wang 32 bit Mix.
- // http://www.concentric.net/~Ttwang/tech/inthash.htm
- // (via https://gist.github.com/badboy/6267743)
- int hash = _id;
- hash = (hash >> 0) ^ (hash ~/ 0x100000000); // To 32 bit from ~64.
- hash = (~hash + (hash << 15)) & 0xFFFFFFFF;
- hash ^= hash >> 12;
- hash = (hash * 5) & 0xFFFFFFFF;
- hash ^= hash >> 4;
- hash = (hash * 2057) & 0xFFFFFFFF;
- hash ^= hash >> 16;
- return hash;
- }
-
- bool operator ==(Object other) {
- if (identical(other, this)) return true;
- if (other is CapabilityImpl) {
- return identical(_id, other._id);
- }
- return false;
- }
-}
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart
index 9cfeabf..cdb840b 100644
--- a/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart
+++ b/sdk/lib/_internal/js_runtime/lib/isolate_patch.dart
@@ -5,20 +5,16 @@
// Patch file for the dart:isolate library.
import "dart:async";
+import 'dart:_foreign_helper' show JS;
import 'dart:_js_helper' show patch;
-import 'dart:_isolate_helper'
- show CapabilityImpl, IsolateNatives, ReceivePortImpl, RawReceivePortImpl;
-
-typedef _UnaryFunction(Null arg);
+import 'dart:_isolate_helper' show ReceivePortImpl;
@patch
class Isolate {
- static final _currentIsolateCache = IsolateNatives.currentIsolate;
-
- // `current` must be a getter, not just a final field,
- // to match the external declaration.
@patch
- static Isolate get current => _currentIsolateCache;
+ static Isolate get current {
+ throw new UnsupportedError("Isolate.current");
+ }
@patch
static Future<Uri> get packageRoot {
@@ -30,15 +26,13 @@
throw new UnsupportedError("Isolate.packageConfig");
}
- static Uri _packageBase = Uri.base.resolve(IsolateNatives.packagesBase);
-
@patch
static Future<Uri> resolvePackageUri(Uri packageUri) {
if (packageUri.scheme != 'package') {
return new Future<Uri>.value(packageUri);
}
return new Future<Uri>.value(
- _packageBase.resolveUri(packageUri.replace(scheme: '')));
+ _packagesBase.resolveUri(packageUri.replace(scheme: '')));
}
@patch
@@ -47,41 +41,7 @@
bool errorsAreFatal,
SendPort onExit,
SendPort onError}) {
- bool forcePause =
- (errorsAreFatal != null) || (onExit != null) || (onError != null);
- try {
- // Check for the type of `entryPoint` on the spawning isolate to make
- // error-handling easier.
- if (entryPoint is! _UnaryFunction) {
- throw new ArgumentError(entryPoint);
- }
- // TODO: Consider passing the errorsAreFatal/onExit/onError values
- // as arguments to the internal spawnUri instead of setting
- // them after the isolate has been created.
- return IsolateNatives
- .spawnFunction(entryPoint, message, paused || forcePause)
- .then((msg) {
- var isolate = new Isolate(msg[1],
- pauseCapability: msg[2], terminateCapability: msg[3]);
- if (forcePause) {
- if (errorsAreFatal != null) {
- isolate.setErrorsFatal(errorsAreFatal);
- }
- if (onExit != null) {
- isolate.addOnExitListener(onExit);
- }
- if (onError != null) {
- isolate.addErrorListener(onError);
- }
- if (!paused) {
- isolate.resume(isolate.pauseCapability);
- }
- }
- return isolate;
- });
- } catch (e, st) {
- return new Future<Isolate>.error(e, st);
- }
+ throw new UnsupportedError("Isolate.spawn");
}
@patch
@@ -95,131 +55,55 @@
Uri packageRoot,
Uri packageConfig,
bool automaticPackageResolution: false}) {
- if (environment != null) throw new UnimplementedError("environment");
- if (packageRoot != null) throw new UnimplementedError("packageRoot");
- if (packageConfig != null) throw new UnimplementedError("packageConfig");
- // TODO(lrn): Figure out how to handle the automaticPackageResolution
- // parameter.
- bool forcePause =
- (errorsAreFatal != null) || (onExit != null) || (onError != null);
- try {
- if (args is List<String>) {
- for (int i = 0; i < args.length; i++) {
- if (args[i] is! String) {
- throw new ArgumentError("Args must be a list of Strings $args");
- }
- }
- } else if (args != null) {
- throw new ArgumentError("Args must be a list of Strings $args");
- }
- // TODO: Handle [packageRoot] somehow, possibly by throwing.
- // TODO: Consider passing the errorsAreFatal/onExit/onError values
- // as arguments to the internal spawnUri instead of setting
- // them after the isolate has been created.
- return IsolateNatives
- .spawnUri(uri, args, message, paused || forcePause)
- .then((msg) {
- var isolate = new Isolate(msg[1],
- pauseCapability: msg[2], terminateCapability: msg[3]);
- if (forcePause) {
- if (errorsAreFatal != null) {
- isolate.setErrorsFatal(errorsAreFatal);
- }
- if (onExit != null) {
- isolate.addOnExitListener(onExit);
- }
- if (onError != null) {
- isolate.addErrorListener(onError);
- }
- if (!paused) {
- isolate.resume(isolate.pauseCapability);
- }
- }
- return isolate;
- });
- } catch (e, st) {
- return new Future<Isolate>.error(e, st);
- }
+ throw new UnsupportedError("Isolate.spawnUri");
}
@patch
void _pause(Capability resumeCapability) {
- var message = new List(3)
- ..[0] = "pause"
- ..[1] = pauseCapability
- ..[2] = resumeCapability;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate._pause");
}
@patch
void resume(Capability resumeCapability) {
- var message = new List(2)
- ..[0] = "resume"
- ..[1] = resumeCapability;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.resume");
}
@patch
void addOnExitListener(SendPort responsePort, {Object response}) {
- // TODO(lrn): Can we have an internal method that checks if the receiving
- // isolate of a SendPort is still alive?
- var message = new List(3)
- ..[0] = "add-ondone"
- ..[1] = responsePort
- ..[2] = response;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.addOnExitListener");
}
@patch
void removeOnExitListener(SendPort responsePort) {
- var message = new List(2)
- ..[0] = "remove-ondone"
- ..[1] = responsePort;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.removeOnExitListener");
}
@patch
void setErrorsFatal(bool errorsAreFatal) {
- var message = new List(3)
- ..[0] = "set-errors-fatal"
- ..[1] = terminateCapability
- ..[2] = errorsAreFatal;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.setErrorsFatal");
}
@patch
void kill({int priority: beforeNextEvent}) {
- controlPort.send(["kill", terminateCapability, priority]);
+ throw new UnsupportedError("Isolate.kill");
}
@patch
void ping(SendPort responsePort, {Object response, int priority: immediate}) {
- var message = new List(4)
- ..[0] = "ping"
- ..[1] = responsePort
- ..[2] = priority
- ..[3] = response;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.ping");
}
@patch
void addErrorListener(SendPort port) {
- var message = new List(2)
- ..[0] = "getErrors"
- ..[1] = port;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.addErrorListener");
}
@patch
void removeErrorListener(SendPort port) {
- var message = new List(2)
- ..[0] = "stopErrors"
- ..[1] = port;
- controlPort.send(message);
+ throw new UnsupportedError("Isolate.removeErrorListener");
}
}
-/** Default factory for receive ports. */
@patch
class ReceivePort {
@patch
@@ -227,7 +111,7 @@
@patch
factory ReceivePort.fromRawReceivePort(RawReceivePort rawPort) {
- return new ReceivePortImpl.fromRawReceivePort(rawPort);
+ throw new UnsupportedError('new ReceivePort.fromRawReceivePort');
}
}
@@ -235,12 +119,22 @@
class RawReceivePort {
@patch
factory RawReceivePort([Function handler]) {
- return new RawReceivePortImpl(handler);
+ throw new UnsupportedError('new RawReceivePort');
}
}
@patch
class Capability {
@patch
- factory Capability() = CapabilityImpl;
+ factory Capability() {
+ throw new UnsupportedError('new Capability');
+ }
}
+
+/// Returns the base path added to Uri.base to resolve `package:` Uris.
+///
+/// This is used by `Isolate.resolvePackageUri` to load resources. The default
+/// value is `packages/` but users can override this by using the
+/// `defaultPackagesBase` hook.
+Uri _packagesBase =
+ Uri.base.resolve(JS('String', r'self.defaultPackagesBase || "packages/"'));
diff --git a/sdk/lib/_internal/js_runtime/lib/isolate_serialization.dart b/sdk/lib/_internal/js_runtime/lib/isolate_serialization.dart
deleted file mode 100644
index 7872979..0000000
--- a/sdk/lib/_internal/js_runtime/lib/isolate_serialization.dart
+++ /dev/null
@@ -1,412 +0,0 @@
-// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-part of _isolate_helper;
-
-/// Serialize [message].
-_serializeMessage(message) {
- return new _Serializer().serialize(message);
-}
-
-/// Deserialize [message].
-_deserializeMessage(message) {
- return new _Deserializer().deserialize(message);
-}
-
-bool _isIsolateMessage(message) {
- if (_isPrimitive(message)) return true;
- if (message is! JSArray) return false;
- if (message.isEmpty) return false;
- switch (message.first) {
- case "ref":
- case "buffer":
- case "typed":
- case "fixed":
- case "extendable":
- case "mutable":
- case "const":
- case "map":
- case "sendport":
- case "raw sendport":
- case "js-object":
- case "function":
- case "capability":
- case "dart":
- return true;
- default:
- return false;
- }
-}
-
-/// Clones the message.
-///
-/// Contrary to a `_deserializeMessage(_serializeMessage(x))` the `_clone`
-/// function will not try to adjust SendPort values and pass them through.
-_clone(message) {
- _Serializer serializer = new _Serializer(serializeSendPorts: false);
- _Deserializer deserializer = new _Deserializer();
- return deserializer.deserialize(serializer.serialize(message));
-}
-
-class _Serializer {
- final bool _serializeSendPorts;
- Map<dynamic, int> serializedObjectIds = new Map<dynamic, int>.identity();
-
- _Serializer({serializeSendPorts: true})
- : _serializeSendPorts = serializeSendPorts;
-
- /// Returns a message that can be transmitted through web-worker channels.
- serialize(x) {
- if (_isPrimitive(x)) return serializePrimitive(x);
-
- int serializationId = serializedObjectIds[x];
- if (serializationId != null) return makeRef(serializationId);
-
- serializationId = serializedObjectIds.length;
- serializedObjectIds[x] = serializationId;
-
- if (x is NativeByteBuffer) return serializeByteBuffer(x);
- if (x is NativeTypedData) return serializeTypedData(x);
- if (x is JSIndexable) return serializeJSIndexable(x);
- if (x is InternalMap) return serializeMap(x as dynamic);
-
- if (x is JSObject) return serializeJSObject(x);
-
- // We should not have any interceptors any more.
- if (x is Interceptor) unsupported(x);
-
- if (x is RawReceivePort) {
- unsupported(x, "RawReceivePorts can't be transmitted:");
- }
-
- // SendPorts need their workerIds adjusted (either during serialization or
- // deserialization).
- if (x is _NativeJsSendPort) return serializeJsSendPort(x);
- if (x is _WorkerSendPort) return serializeWorkerSendPort(x);
-
- if (x is Closure) return serializeClosure(x);
- if (x is CapabilityImpl) return serializeCapability(x);
-
- return serializeDartObject(x);
- }
-
- void unsupported(x, [String message]) {
- if (message == null) message = "Can't transmit:";
- throw new UnsupportedError("$message $x");
- }
-
- makeRef(int serializationId) => ["ref", serializationId];
-
- serializePrimitive(primitive) => primitive;
-
- serializeByteBuffer(NativeByteBuffer buffer) {
- return ["buffer", buffer];
- }
-
- serializeTypedData(NativeTypedData data) {
- return ["typed", data];
- }
-
- serializeJSIndexable(JSIndexable indexable) {
- // Strings are JSIndexable but should have been treated earlier.
- assert(indexable is! String);
- List serialized = serializeArray(indexable);
- if (indexable is JSFixedArray) return ["fixed", serialized];
- if (indexable is JSExtendableArray) return ["extendable", serialized];
- // MutableArray check must be last, since JSFixedArray and JSExtendableArray
- // extend JSMutableArray.
- if (indexable is JSMutableArray) return ["mutable", serialized];
- // The only JSArrays left are the const Lists (as in `const [1, 2]`).
- if (indexable is JSArray) return ["const", serialized];
- unsupported(indexable, "Can't serialize indexable: ");
- return null;
- }
-
- serializeArray(JSArray x) {
- List serialized = [];
- serialized.length = x.length;
- for (int i = 0; i < x.length; i++) {
- serialized[i] = serialize(x[i]);
- }
- return serialized;
- }
-
- serializeArrayInPlace(JSArray x) {
- for (int i = 0; i < x.length; i++) {
- x[i] = serialize(x[i]);
- }
- return x;
- }
-
- serializeMap(Map x) {
- Function serializeTearOff = serialize;
- return [
- 'map',
- x.keys.map(serializeTearOff).toList(),
- x.values.map(serializeTearOff).toList()
- ];
- }
-
- serializeJSObject(JSObject x) {
- // Don't serialize objects if their `constructor` property isn't `Object`
- // or undefined/null.
- // A different constructor is taken as a sign that the object has complex
- // internal state, or that it is a function, and won't be serialized.
- if (JS('bool', '!!(#.constructor)', x) &&
- JS('bool', 'x.constructor !== Object')) {
- unsupported(x, "Only plain JS Objects are supported:");
- }
- List keys = JS('JSArray', 'Object.keys(#)', x);
- List values = [];
- values.length = keys.length;
- for (int i = 0; i < keys.length; i++) {
- values[i] = serialize(JS('', '#[#]', x, keys[i]));
- }
- return ['js-object', keys, values];
- }
-
- serializeWorkerSendPort(_WorkerSendPort x) {
- if (_serializeSendPorts) {
- return ['sendport', x._workerId, x._isolateId, x._receivePortId];
- }
- return ['raw sendport', x];
- }
-
- serializeJsSendPort(_NativeJsSendPort x) {
- if (_serializeSendPorts) {
- int workerId = _globalState.currentManagerId;
- return ['sendport', workerId, x._isolateId, x._receivePort._id];
- }
- return ['raw sendport', x];
- }
-
- serializeCapability(CapabilityImpl x) => ['capability', x._id];
-
- serializeClosure(Closure x) {
- final name = IsolateNatives._getJSFunctionName(x);
- if (name == null) {
- unsupported(x, "Closures can't be transmitted:");
- }
- return ['function', name];
- }
-
- serializeDartObject(x) {
- if (!isDartObject(x)) unsupported(x);
- var classExtractor = JS_EMBEDDED_GLOBAL('', CLASS_ID_EXTRACTOR);
- var fieldsExtractor = JS_EMBEDDED_GLOBAL('', CLASS_FIELDS_EXTRACTOR);
- String classId = JS('String', '#(#)', classExtractor, x);
- List fields = JS('JSArray', '#(#)', fieldsExtractor, x);
- return ['dart', classId, serializeArrayInPlace(fields)];
- }
-}
-
-class _Deserializer {
- /// When `true`, encodes sendports specially so that they can be adjusted on
- /// the receiving end.
- ///
- /// When `false`, sendports are cloned like any other object.
- final bool _adjustSendPorts;
-
- List<dynamic> deserializedObjects = new List<dynamic>();
-
- _Deserializer({adjustSendPorts: true}) : _adjustSendPorts = adjustSendPorts;
-
- /// Returns a message that can be transmitted through web-worker channels.
- deserialize(x) {
- if (_isPrimitive(x)) return deserializePrimitive(x);
-
- if (x is! JSArray) throw new ArgumentError("Bad serialized message: $x");
-
- switch (x.first) {
- case "ref":
- return deserializeRef(x);
- case "buffer":
- return deserializeByteBuffer(x);
- case "typed":
- return deserializeTypedData(x);
- case "fixed":
- return deserializeFixed(x);
- case "extendable":
- return deserializeExtendable(x);
- case "mutable":
- return deserializeMutable(x);
- case "const":
- return deserializeConst(x);
- case "map":
- return deserializeMap(x);
- case "sendport":
- return deserializeSendPort(x);
- case "raw sendport":
- return deserializeRawSendPort(x);
- case "js-object":
- return deserializeJSObject(x);
- case "function":
- return deserializeClosure(x);
- case "capability":
- return deserializeCapability(x);
- case "dart":
- return deserializeDartObject(x);
- default:
- throw "couldn't deserialize: $x";
- }
- }
-
- deserializePrimitive(x) => x;
-
- // ['ref', id].
- deserializeRef(x) {
- assert(x[0] == 'ref');
- int serializationId = x[1];
- return deserializedObjects[serializationId];
- }
-
- // ['buffer', <byte buffer>].
- NativeByteBuffer deserializeByteBuffer(x) {
- assert(x[0] == 'buffer');
- NativeByteBuffer result = x[1];
- deserializedObjects.add(result);
- return result;
- }
-
- // ['typed', <typed array>].
- NativeTypedData deserializeTypedData(x) {
- assert(x[0] == 'typed');
- NativeTypedData result = x[1];
- deserializedObjects.add(result);
- return result;
- }
-
- // Updates the given array in place with its deserialized content.
- List deserializeArrayInPlace(JSArray x) {
- for (int i = 0; i < x.length; i++) {
- x[i] = deserialize(x[i]);
- }
- return x;
- }
-
- // ['fixed', <array>].
- List deserializeFixed(x) {
- assert(x[0] == 'fixed');
- List result = x[1];
- deserializedObjects.add(result);
- return new JSArray.markFixed(deserializeArrayInPlace(result));
- }
-
- // ['extendable', <array>].
- List deserializeExtendable(x) {
- assert(x[0] == 'extendable');
- List result = x[1];
- deserializedObjects.add(result);
- return new JSArray.markGrowable(deserializeArrayInPlace(result));
- }
-
- // ['mutable', <array>].
- List deserializeMutable(x) {
- assert(x[0] == 'mutable');
- List result = x[1];
- deserializedObjects.add(result);
- return deserializeArrayInPlace(result);
- }
-
- // ['const', <array>].
- List deserializeConst(x) {
- assert(x[0] == 'const');
- List result = x[1];
- deserializedObjects.add(result);
- // TODO(floitsch): need to mark list as non-changeable.
- return new JSArray.markFixed(deserializeArrayInPlace(result));
- }
-
- // ['map', <key-list>, <value-list>].
- Map deserializeMap(x) {
- assert(x[0] == 'map');
- List keys = x[1];
- List values = x[2];
- Map result = {};
- deserializedObjects.add(result);
- // We need to keep the order of how objects were serialized.
- // First deserialize all keys, and then only deserialize the values.
- keys = keys.map(deserialize).toList();
-
- for (int i = 0; i < keys.length; i++) {
- result[keys[i]] = deserialize(values[i]);
- }
- return result;
- }
-
- // ['sendport', <managerId>, <isolateId>, <receivePortId>].
- SendPort deserializeSendPort(x) {
- assert(x[0] == 'sendport');
- int managerId = x[1];
- int isolateId = x[2];
- int receivePortId = x[3];
- SendPort result;
- // If two isolates are in the same manager, we use NativeJsSendPorts to
- // deliver messages directly without using postMessage.
- if (managerId == _globalState.currentManagerId) {
- var isolate = _globalState.isolates[isolateId];
- if (isolate == null) return null; // Isolate has been closed.
- var receivePort = isolate.lookup(receivePortId);
- if (receivePort == null) return null; // Port has been closed.
- result = new _NativeJsSendPort(receivePort, isolateId);
- } else {
- result = new _WorkerSendPort(managerId, isolateId, receivePortId);
- }
- deserializedObjects.add(result);
- return result;
- }
-
- // ['raw sendport', <sendport>].
- SendPort deserializeRawSendPort(x) {
- assert(x[0] == 'raw sendport');
- SendPort result = x[1];
- deserializedObjects.add(result);
- return result;
- }
-
- // ['js-object', <key-list>, <value-list>].
- deserializeJSObject(x) {
- assert(x[0] == 'js-object');
- List keys = x[1];
- List values = x[2];
- var o = JS('', '{}');
- deserializedObjects.add(o);
- for (int i = 0; i < keys.length; i++) {
- JS('', '#[#]=#', o, keys[i], deserialize(values[i]));
- }
- return o;
- }
-
- // ['function', <name>].
- Function deserializeClosure(x) {
- assert(x[0] == 'function');
- String name = x[1];
- Function result = IsolateNatives._getJSFunctionFromName(name);
- deserializedObjects.add(result);
- return result;
- }
-
- // ['capability', <id>].
- Capability deserializeCapability(x) {
- assert(x[0] == 'capability');
- return new CapabilityImpl._internal(x[1]);
- }
-
- // ['dart', <class-id>, <field-list>].
- deserializeDartObject(x) {
- assert(x[0] == 'dart');
- String classId = x[1];
- List fields = x[2];
- var instanceFromClassId = JS_EMBEDDED_GLOBAL('', INSTANCE_FROM_CLASS_ID);
- var initializeObject = JS_EMBEDDED_GLOBAL('', INITIALIZE_EMPTY_INSTANCE);
-
- var emptyInstance = JS('', '#(#)', instanceFromClassId, classId);
- deserializedObjects.add(emptyInstance);
- deserializeArrayInPlace(fields);
- return JS(
- '', '#(#, #, #)', initializeObject, classId, emptyInstance, fields);
- }
-}
-
-bool _isPrimitive(x) => x == null || x is String || x is num || x is bool;
diff --git a/sdk/lib/_internal/js_runtime/lib/js_helper.dart b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
index a89baa8..43c687b 100644
--- a/sdk/lib/_internal/js_runtime/lib/js_helper.dart
+++ b/sdk/lib/_internal/js_runtime/lib/js_helper.dart
@@ -24,28 +24,16 @@
import 'dart:collection';
-import 'dart:_isolate_helper'
- show IsolateNatives, enterJsAsync, isWorker, leaveJsAsync;
+import 'dart:_isolate_helper' show thisScript, isWorker;
-import 'dart:async'
- show
- Completer,
- DeferredLoadException,
- Future,
- StreamController,
- Stream,
- StreamSubscription,
- scheduleMicrotask,
- Zone;
+import 'dart:async' show Completer, DeferredLoadException, Future;
import 'dart:_foreign_helper'
show
DART_CLOSURE_TO_JS,
JS,
JS_BUILTIN,
- JS_CALL_IN_ISOLATE,
JS_CONST,
- JS_CURRENT_ISOLATE_CONTEXT,
JS_EFFECT,
JS_EMBEDDED_GLOBAL,
JS_GET_FLAG,
@@ -62,11 +50,7 @@
import 'dart:_native_typed_data';
import 'dart:_js_names'
- show
- extractKeys,
- mangledNames,
- unmangleGlobalNameIfPreservedAnyways,
- unmangleAllIdentifiersIfPreservedAnyways;
+ show extractKeys, mangledNames, unmangleAllIdentifiersIfPreservedAnyways;
part 'annotations.dart';
part 'constant_map.dart';
@@ -226,16 +210,6 @@
'returns:var;effects:none;depends:none', JsBuiltin.getType, index);
}
-/// Returns a Dart closure for the global function with the given [name].
-///
-/// The [name] is the globally unique (minified) JavaScript name of the
-/// function. The name must be in correspondence with the propertyName that is
-/// used when creating a tear-off (see [fromTearOff]).
-Function createDartClosureFromNameOfStaticFunction(String name) {
- return JS_BUILTIN('returns:Function',
- JsBuiltin.createDartClosureFromNameOfStaticFunction, name);
-}
-
/// No-op method that is called to inform the compiler that preambles might
/// be needed when executing the resulting JS file in a command-line
/// JS engine.
@@ -2471,19 +2445,19 @@
return result;
}
-invokeClosure(Function closure, var isolate, int numberOfArguments, var arg1,
- var arg2, var arg3, var arg4) {
+invokeClosure(Function closure, int numberOfArguments, var arg1, var arg2,
+ var arg3, var arg4) {
switch (numberOfArguments) {
case 0:
- return JS_CALL_IN_ISOLATE(isolate, () => closure());
+ return closure();
case 1:
- return JS_CALL_IN_ISOLATE(isolate, () => closure(arg1));
+ return closure(arg1);
case 2:
- return JS_CALL_IN_ISOLATE(isolate, () => closure(arg1, arg2));
+ return closure(arg1, arg2);
case 3:
- return JS_CALL_IN_ISOLATE(isolate, () => closure(arg1, arg2, arg3));
+ return closure(arg1, arg2, arg3);
case 4:
- return JS_CALL_IN_ISOLATE(isolate, () => closure(arg1, arg2, arg3, arg4));
+ return closure(arg1, arg2, arg3, arg4);
}
throw new Exception('Unsupported number of arguments for wrapped closure');
}
@@ -2500,14 +2474,13 @@
function = JS(
'var',
r'''
- (function(closure, arity, context, invoke) {
+ (function(closure, arity, invoke) {
return function(a1, a2, a3, a4) {
- return invoke(closure, context, arity, a1, a2, a3, a4);
+ return invoke(closure, arity, a1, a2, a3, a4);
};
- })(#,#,#,#)''',
+ })(#,#,#)''',
closure,
arity,
- JS_CURRENT_ISOLATE_CONTEXT(),
DART_CLOSURE_TO_JS(invokeClosure));
JS('void', r'#.$identity = #', closure, function);
@@ -2548,9 +2521,6 @@
*
* In other words, creates a tear-off closure.
*
- * The [propertyName] argument is used by
- * [JsBuiltin.createDartClosureFromNameOfStaticFunction].
- *
* Called from [closureFromTearOff] as well as from reflection when tearing
* of a method via `getField`.
*
@@ -3826,7 +3796,7 @@
return future.then((_) => null);
}
- String uri = IsolateNatives.thisScript;
+ String uri = thisScript;
int index = uri.lastIndexOf('/');
uri = '${uri.substring(0, index + 1)}$hunkName';
@@ -3865,11 +3835,6 @@
}
} else if (isWorker()) {
// We are in a web worker. Load the code with an XMLHttpRequest.
- enterJsAsync();
- Future<Null> leavingFuture = completer.future.whenComplete(() {
- leaveJsAsync();
- });
-
int index = uri.lastIndexOf('/');
uri = '${uri.substring(0, index + 1)}$hunkName';
var xhr = JS('var', 'new XMLHttpRequest()');
diff --git a/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart b/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
index 36c5e25..284232a 100644
--- a/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
+++ b/sdk/lib/_internal/js_runtime/lib/shared/embedded_names.dart
@@ -138,43 +138,6 @@
/// This embedded global is set at startup, just before invoking `main`.
const CURRENT_SCRIPT = 'currentScript';
-/// Returns a function that creates a new Isolate (its static state).
-///
-/// (floitsch): Note that this embedded global will probably go away, since one
-/// JS heap will only contain one Dart isolate.
-const CREATE_NEW_ISOLATE = 'createNewIsolate';
-
-/// Returns a class-id of the given instance.
-///
-/// The extracted id can be used to built a new instance of the same type
-/// (see [INSTANCE_FROM_CLASS_ID].
-///
-/// This embedded global is used for serialization in the isolate-library.
-const CLASS_ID_EXTRACTOR = 'classIdExtractor';
-
-/// Returns an empty instance of the given class-id.
-///
-/// Given a class-id (see [CLASS_ID_EXTRACTOR]) returns an empty instance.
-///
-/// This embedded global is used for deserialization in the isolate-library.
-const INSTANCE_FROM_CLASS_ID = "instanceFromClassId";
-
-/// Returns a list of (mangled) field names for the given instance.
-///
-/// The list of fields can be used to extract the instance's values and then
-/// initialize an empty instance (see [INITIALIZE_EMPTY_INSTANCE].
-///
-/// This embedded global is used for serialization in the isolate-library.
-const CLASS_FIELDS_EXTRACTOR = 'classFieldsExtractor';
-
-/// Initializes the given empty instance with the given fields.
-///
-/// The given fields are in an array and must be in the same order as the
-/// field-names obtained by [CLASS_FIELDS_EXTRACTOR].
-///
-/// This embedded global is used for deserialization in the isolate-library.
-const INITIALIZE_EMPTY_INSTANCE = "initializeEmptyInstance";
-
/// Contains a map from load-ids to lists of part indexes.
///
/// To load the deferred library that is represented by the load-id, the runtime
@@ -250,29 +213,6 @@
/// An emitter-internal embedded global. This global is not used by the runtime.
const FINISHED_CLASSES = 'finishedClasses';
-/// An emitter-internal embedded global. This global is not used by the runtime.
-///
-/// The constant remains in this file to make sure that other embedded globals
-/// don't clash with it.
-///
-/// It can be used by the compiler to store a mapping from static function names
-/// to dart-closure getters (which can be useful for
-/// [JsBuiltin.createDartClosureFromNameOfStaticFunction].
-const GLOBAL_FUNCTIONS = 'globalFunctions';
-
-/// An emitter-internal embedded global. This global is not used by the runtime.
-///
-/// The constant remains in this file to make sure that other embedded globals
-/// don't clash with it.
-///
-/// This embedded global stores a function that returns a dart-closure getter
-/// for a given static function name.
-///
-/// This embedded global is used to implement
-/// [JsBuiltin.createDartClosureFromNameOfStaticFunction], and is only
-/// used with isolates.
-const STATIC_FUNCTION_NAME_TO_CLOSURE = 'staticFunctionNameToClosure';
-
/// A JavaScript object literal that maps the (minified) JavaScript constructor
/// name (as given by [JsBuiltin.rawRtiToJsConstructorName] to the
/// JavaScript constructor.
@@ -475,16 +415,4 @@
/// JS_BUILTIN('returns:var;effects:none;depends:none',
/// JsBuiltin.getType, index);
getType,
-
- /// Returns a Dart closure for the global function with the given [name].
- ///
- /// The [name] is the globally unique (minified) JavaScript name of the
- /// function (same as the one stored in [STATIC_FUNCTION_NAME_PROPERTY_NAME])
- ///
- /// This builtin is used when a static closure was sent to a different
- /// isolate.
- ///
- /// JS_BUILTIN('returns:Function',
- /// JsBuiltin.createDartClosureFromNameOfStaticFunction, name);
- createDartClosureFromNameOfStaticFunction,
}
diff --git a/tests/co19/co19-dart2js.status b/tests/co19/co19-dart2js.status
index d8f09d7..d802885 100644
--- a/tests/co19/co19-dart2js.status
+++ b/tests/co19/co19-dart2js.status
@@ -40,6 +40,7 @@
Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t07: MissingCompileTimeError # Issue 24332
Language/Expressions/Property_Extraction/Getter_Access_and_Method_Extraction/class_object_member_t08: MissingCompileTimeError # Issue 24332
Language/Expressions/Shift/syntax_t01/14: MissingRuntimeError # Please triage this failure
+Language/Expressions/Spawning_an_Isolate/new_isolate_t01: SkipByDesign
Language/Libraries_and_Scripts/Imports/invalid_uri_deferred_t02: CompileTimeError # Please triage this failure
Language/Metadata/before_export_t01: RuntimeError # Please triage this failure
Language/Metadata/before_import_t01: RuntimeError # Please triage this failure
@@ -179,18 +180,7 @@
LibTest/html/IFrameElement/addEventListener_A01_t04: Skip # https://github.com/dart-lang/sdk/issues/28873
LibTest/html/IFrameElement/enteredView_A01_t01: CompileTimeError # co19-roll r706: Please triage this failure
LibTest/html/Window/postMessage_A01_t01: Skip # https://github.com/dart-lang/sdk/issues/28873
-LibTest/isolate/Isolate/spawnUri_A01_t01: Fail # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t02: Fail # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t03: Fail # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t04: Fail # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t05: Fail # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t06: RuntimeError # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A01_t07: RuntimeError # Dart issue 15974
-LibTest/isolate/Isolate/spawnUri_A02_t01: RuntimeError, Pass # Dart issue 15617
-LibTest/isolate/Isolate/spawn_A02_t02: RuntimeError, Pass # Dart issue 15617
-LibTest/isolate/Isolate/spawn_A04_t01: SkipByDesign
-LibTest/isolate/Isolate/spawn_A04_t02: SkipByDesign
-LibTest/isolate/Isolate/spawn_A06_t06: Skip # Times out. Please triage this failure.
+LibTest/isolate/*: SkipByDesign # dart:isolate not supported.
LibTest/math/MutableRectangle/boundingBox_A01_t01: RuntimeError, Pass # co19-roll r706: Please triage this failure.
LibTest/math/Rectangle/boundingBox_A01_t01: RuntimeError, Pass # co19-roll r706: Please triage this failure.
LibTest/math/pow_A04_t01: Fail # co19-roll r587: Please triage this failure
@@ -1282,7 +1272,6 @@
LayoutTests/fast/text/line-break-after-question-mark_t01: RuntimeError # Please triage this failure
LayoutTests/fast/text/text-combine-shrink-to-fit_t01: RuntimeError # Please triage this failure
LibTest/async/Timer/Timer.periodic_A01_t01: Skip # Times out. Please triage this failure
-LibTest/isolate/Isolate/spawn_A01_t05: Skip # Times out. Please triage this failure
WebPlatformTest/shadow-dom/events/retargeting-focus-events/test-002_t01: Skip # Times out. Please triage this failure
[ $compiler == dart2js && $runtime == chrome && $system != macos ]
@@ -1467,13 +1456,6 @@
LibTest/core/int/remainder_A01_t01: Fail # Please triage this failure.
LibTest/core/int/remainder_A01_t03: Fail # Please triage this failure.
LibTest/core/int/toRadixString_A01_t01: Fail # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A01_t01: Skip # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A01_t02: Skip # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A01_t03: Skip # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A02_t01: RuntimeError # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A02_t02: Skip # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A02_t03: Skip # Please triage this failure.
-LibTest/isolate/Isolate/spawnUri_A02_t04: Skip # Please triage this failure.
LibTest/math/log_A01_t01: Fail # Please triage this failure.
LibTest/typed_data/Float32x4List/Float32x4List.view_A01_t02: RuntimeError # Please triage this failure.
LibTest/typed_data/Float32x4List/Float32x4List.view_A06_t01: RuntimeError # Please triage this failure.
@@ -1484,8 +1466,6 @@
LibTest/typed_data/Uint8ClampedList/map_A02_t01: Pass, Slow # Please triage this failure.
[ $compiler == dart2js && $runtime == d8 ]
-LibTest/isolate/Isolate/spawn_A03_t01: Pass # co19 issue 77
-LibTest/isolate/Isolate/spawn_A04_t02: RuntimeError # Please triage this failure.
LibTest/typed_data/Float32x4List/Float32x4List.view_A06_t01: Fail # co19-roll r587: Please triage this failure
LibTest/typed_data/Int32x4/operator_OR_A01_t01: RuntimeError # Issue 7728, timer not supported in jsshell
@@ -1494,9 +1474,6 @@
Language/Expressions/Instance_Creation/New/redirecting_factory_constructor_t02: RuntimeError
Language/Generics/malformed_t02: Crash
-[ $compiler == dart2js && $runtime == d8 && $fast_startup ]
-LibTest/isolate/Isolate/spawn_A04_t04: Pass # Technically fails, but since sync-async was turned on, this test completes before it fails. Underlying issue: #27558
-
[ $compiler == dart2js && $runtime == d8 && $fasta ]
LayoutTests/*: SkipByDesign
LibTest/html/*: SkipByDesign
@@ -5593,22 +5570,6 @@
LibTest/core/Stopwatch/start_A01_t03: RuntimeError # Issue 7728, timer not supported in jsshell
LibTest/core/Stopwatch/stop_A01_t01: RuntimeError # Issue 7728, timer not supported in jsshell
LibTest/core/Uri/Uri_A06_t03: Pass, Slow
-LibTest/isolate/Isolate/spawn_A03_t01: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A03_t03: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A03_t04: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A04_t02: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A04_t03: Fail # Please triage this failure
-LibTest/isolate/Isolate/spawn_A04_t04: Fail # Issue 27558
-LibTest/isolate/Isolate/spawn_A04_t05: Fail # Please triage this failure
-LibTest/isolate/Isolate/spawn_A06_t02: Fail # Please triage this failure
-LibTest/isolate/Isolate/spawn_A06_t03: Fail # Please triage this failure
-LibTest/isolate/Isolate/spawn_A06_t04: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A06_t05: RuntimeError # Please triage this failure
-LibTest/isolate/Isolate/spawn_A06_t07: Fail # Please triage this failure
-LibTest/isolate/RawReceivePort/close_A01_t01: RuntimeError # Issue 7728, timer not supported in jsshell
-LibTest/isolate/ReceivePort/asBroadcastStream_A03_t01: RuntimeError # Issue 7728, timer not supported in jsshell
-LibTest/isolate/ReceivePort/asBroadcastStream_A04_t03: RuntimeError # Issue 7728, timer not supported in jsshell
-LibTest/isolate/ReceivePort/close_A01_t01: RuntimeError # Issue 7728, timer not supported in jsshell
LibTest/typed_data/Float32List/toList_A01_t01: Skip # co19-roll r559: Please triage this failure
LibTest/typed_data/Float32x4List/Float32x4List.view_A06_t01: Fail # co19-roll r587: Please triage this failure
LibTest/typed_data/Float64List/toList_A01_t01: Skip # co19-roll r559: Please triage this failure
@@ -5626,9 +5587,6 @@
LibTest/core/Uri/Uri_A06_t03: Skip # Issue 18093, timeout.
LibTest/core/Uri/encodeQueryComponent_A01_t02: Skip # Issue 18093, timeout.
-[ $compiler == dart2js && $runtime == jsshell && $fast_startup ]
-LibTest/isolate/ReceivePort/asBroadcastStream_A03_t01: Fail # please triage
-
[ $compiler == dart2js && $runtime == safari ]
LayoutTests/fast/alignment/parse-align-items_t01: RuntimeError # Please triage this failure
LayoutTests/fast/alignment/parse-align-self_t01: RuntimeError # Please triage this failure
@@ -7108,7 +7066,6 @@
LibTest/html/Window/requestFileSystem_A01_t01: Crash
LibTest/html/Window/requestFileSystem_A01_t02: Crash
LibTest/html/Window/requestFileSystem_A02_t01: Crash
-LibTest/isolate/SendPort/send_A01_t03: RuntimeError
WebPlatformTest/html/semantics/embedded-content/the-audio-element/audio_constructor_t01: RuntimeError
[ $compiler == dart2js && $fasta && $host_checked ]
@@ -7261,9 +7218,6 @@
Language/Variables/final_t01/01: CompileTimeError # co19 issue 77
Language/Variables/final_t02/01: CompileTimeError # co19 issue 77
Language/Variables/local_variable_t01: MissingCompileTimeError # Issue 21050
-LibTest/isolate/SendPort/send_A01_t01: CompileTimeError # co19-roll r706: Please triage this failure
-LibTest/isolate/SendPort/send_A01_t02: CompileTimeError # co19-roll r706: Please triage this failure
-LibTest/isolate/SendPort/send_A01_t03: CompileTimeError # co19-roll r706: Please triage this failure
[ $compiler == dart2js && $jscl ]
LibTest/core/RegExp/Pattern_semantics/firstMatch_NonEmptyClassRanges_A01_t01: RuntimeError, OK # This is not rejected by V8. Issue 22200
diff --git a/tests/compiler/dart2js/equivalence/check_functions.dart b/tests/compiler/dart2js/equivalence/check_functions.dart
index b06c4ed..1a0222c 100644
--- a/tests/compiler/dart2js/equivalence/check_functions.dart
+++ b/tests/compiler/dart2js/equivalence/check_functions.dart
@@ -458,8 +458,6 @@
usage2.isInvokeOnUsed);
check(usage1, usage2, 'isRuntimeTypeUsed', usage1.isRuntimeTypeUsed,
usage2.isRuntimeTypeUsed);
- check(usage1, usage2, 'isIsolateInUse', usage1.isIsolateInUse,
- usage2.isIsolateInUse);
check(usage1, usage2, 'isFunctionApplyUsed', usage1.isFunctionApplyUsed,
usage2.isFunctionApplyUsed);
check(usage1, usage2, 'isNoSuchMethodUsed', usage1.isNoSuchMethodUsed,
@@ -915,8 +913,6 @@
backendUsage1.isRuntimeTypeUsed,
backendUsage2.isRuntimeTypeUsed,
"JavaScriptBackend.hasRuntimeTypeSupport mismatch");
- Expect.equals(backendUsage1.isIsolateInUse, backendUsage2.isIsolateInUse,
- "JavaScriptBackend.hasIsolateSupport mismatch");
}
void checkCodegenEnqueuers(CodegenEnqueuer enqueuer1, CodegenEnqueuer enqueuer2,
@@ -1026,8 +1022,6 @@
program1.outputContainsConstantList, program2.outputContainsConstantList);
check(program1, program2, 'needsNativeSupport', program1.needsNativeSupport,
program2.needsNativeSupport);
- check(program1, program2, 'hasIsolateSupport', program1.hasIsolateSupport,
- program2.hasIsolateSupport);
check(program1, program2, 'hasSoftDeferredClasses',
program1.hasSoftDeferredClasses, program2.hasSoftDeferredClasses);
checkMaps(
diff --git a/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart b/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart
index 6a30c60..d9ad5e6 100644
--- a/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart
+++ b/tests/compiler/dart2js/sourcemaps/stacktrace_test.dart
@@ -120,9 +120,6 @@
const LineException('_AsyncRun._scheduleImmediateJsOverride.internalCallback',
'async_patch.dart'),
const LineException('invokeClosure.<anonymous function>', 'js_helper.dart'),
- const LineException('_IsolateContext.eval', 'isolate_helper.dart'),
- const LineException('_callInIsolate', 'isolate_helper.dart'),
- const LineException('startRootIsolate', 'isolate_helper.dart'),
const LineException('invokeClosure', 'js_helper.dart'),
const LineException('convertDartClosureToJS', 'js_helper.dart'),
];
diff --git a/tests/compiler/dart2js_native/compute_this_script_test.dart b/tests/compiler/dart2js_native/compute_this_script_test.dart
index e8316e8..2cdfb52 100644
--- a/tests/compiler/dart2js_native/compute_this_script_test.dart
+++ b/tests/compiler/dart2js_native/compute_this_script_test.dart
@@ -5,15 +5,9 @@
// Test of IsolateNatives.computeThisScript().
import 'dart:_isolate_helper';
-// The isolate helper library is not correctly set up if the dart:isolate
-// library hasn't been loaded.
-import 'dart:isolate';
main() {
- // Need to use the isolate-library so dart2js correctly initializes the
- // library.
- Capability cab = new Capability();
- String script = IsolateNatives.computeThisScript();
+ String script = computeThisScript();
// This is somewhat brittle and relies on an implementation detail
// of our test runner, but I can think of no other way to test this.
diff --git a/tests/compiler/dart2js_native/internal_library_test.dart b/tests/compiler/dart2js_native/internal_library_test.dart
index 0bf6c4f..7f81f6c 100644
--- a/tests/compiler/dart2js_native/internal_library_test.dart
+++ b/tests/compiler/dart2js_native/internal_library_test.dart
@@ -5,8 +5,8 @@
// Test that a private library can be accessed from libraries in this special
// test folder.
-import 'dart:_isolate_helper';
+import 'dart:_js_helper';
void main() {
- print(startRootIsolate);
+ print(loadDeferredLibrary);
}
diff --git a/tests/corelib/corelib.status b/tests/corelib/corelib.status
index 99a89af..443fca5 100644
--- a/tests/corelib/corelib.status
+++ b/tests/corelib/corelib.status
@@ -93,6 +93,9 @@
list_as_map_test: Pass, Slow # TODO(kasperl): Please triage.
string_trimlr_test/unicode63: RuntimeError # Uses Unicode 6.2.0 or earlier.
+[ $compiler == dart2js && $runtime != d8 ]
+main_test: RuntimeError
+
[ $compiler == dart2js && $runtime == drt ]
string_trimlr_test/unicode63: RuntimeError # Uses Unicode 6.2.0 or earlier.
diff --git a/tests/html/html.status b/tests/html/html.status
index be29f94..972a95a 100644
--- a/tests/html/html.status
+++ b/tests/html/html.status
@@ -42,10 +42,12 @@
indexeddb_4_test: Pass, Timeout # Roll 50 failure
indexeddb_5_test: Pass, Timeout # Roll 50 failure
input_element_test/attributes: Fail # Issue 21555
+isolates_test: SkipByDesign
js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue #25759
js_typed_interop_side_cast_exp_test: Pass, RuntimeError # Roll 50 failure
mirrors_js_typed_interop_test: Pass, Slow
svgelement_test/PathElement: Pass, RuntimeError # Roll 50 failure
+worker_api_test: SkipByDesign
wrapping_collections_test: SkipByDesign # Testing an issue that is only relevant to Dartium
xhr_test/xhr: Pass, RuntimeError # Roll 50 failure
@@ -152,7 +154,6 @@
speechrecognition_test/supported: Fail # Safari Feature support statuses - All changes should be accompanied by platform support annotation changes.
touchevent_test/supported: Fail # Safari does not support TouchEvents
webgl_1_test: Pass, Fail # Issue 8219
-worker_api_test: Skip # Issue 13221
# The html tests were moved to lib_2/html, and there they should be made strong
# mode compliant. There's no sense in running the old versions here.
diff --git a/tests/isolate/isolate.status b/tests/isolate/isolate.status
index c5dcc41..d7fd1a0 100644
--- a/tests/isolate/isolate.status
+++ b/tests/isolate/isolate.status
@@ -6,29 +6,7 @@
browser/typed_data_message_test: StaticWarning
[ $compiler == dart2js ]
-browser/issue_12474_test: CompileTimeError # Issue 22529
-deferred_in_isolate2_test: SkipByDesign
-enum_const_test/02: RuntimeError # Issue 21817
-error_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-error_exit_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-exit_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-function_send1_test: SkipByDesign # Test uses a ".dart" URI.
-issue_21398_parent_isolate1_test: SkipByDesign # Test uses a ".dart" URI.
-issue_21398_parent_isolate2_test: SkipByDesign # Test uses a ".dart" URI.
-issue_21398_parent_isolate_test: SkipByDesign # Test uses a ".dart" URI.
-issue_24243_parent_isolate_test: SkipByDesign # Test uses a ".dart" URI.
-kill_self_synchronously_test: SkipByDesign # Unsupported operation: Platform._resolvedExecutable
-message3_test/constInstance: RuntimeError # Issue 21817
-message3_test/constList: RuntimeError # Issue 21817
-message3_test/constList_identical: RuntimeError # Issue 21817
-message3_test/constMap: RuntimeError # Issue 21817
-non_fatal_exception_in_timer_callback_test: Skip # Issue 23876
-spawn_uri_exported_main_test: SkipByDesign # Test uses a ".dart" URI.
-spawn_uri_missing_from_isolate_test: SkipByDesign
-spawn_uri_nested_vm_test: SkipByDesign # Test uses a ".dart" URI.
-spawn_uri_vm_test: SkipByDesign # Test uses a ".dart" URI.
-stacktrace_message_test: RuntimeError # Fails to send stacktrace object.
-timer_isolate_test: SkipByDesign
+*: SkipByDesign
[ $compiler == fasta ]
browser/compute_this_script_browser_test: CompileTimeError # TODO(ahe): Support dart:html in Fasta.
@@ -64,91 +42,6 @@
[ $compiler == dart2analyzer && $strong ]
*: Skip # Issue 28649
-[ $compiler == dart2js && $runtime == chrome ]
-function_send_test: Skip # Crashes Chrome 62: https://bugs.chromium.org/p/chromium/issues/detail?id=775506
-
-[ $compiler == dart2js && $runtime == chromeOnAndroid ]
-isolate_stress_test: Pass, Slow # TODO(kasperl): Please triage.
-mandel_isolate_test: Pass, Timeout # TODO(kasperl): Please triage.
-unresolved_ports_test: Pass, Timeout # Issue 15610
-
-[ $compiler == dart2js && $runtime == d8 && $fasta ]
-isolate_stress_test: RuntimeError
-
-[ $compiler == dart2js && $runtime != d8 ]
-error_at_spawn_test: Skip # Issue 23876
-error_exit_at_spawn_test: Skip # Issue 23876
-exit_at_spawn_test: Skip # Issue 23876
-message4_test: Skip # Issue 30247
-
-[ $compiler == dart2js && $runtime == jsshell ]
-pause_test: Fail, OK # non-zero timer not supported.
-timer_isolate_test: Fail, OK # Needs Timer to run.
-
-[ $compiler == dart2js && $runtime == safari ]
-cross_isolate_message_test: Skip # Issue 12627
-message_test: Skip # Issue 12627
-
-[ $compiler == dart2js && !$browser && $fast_startup ]
-isolate_current_test: Fail # please triage
-
-[ $compiler == dart2js && $fast_startup ]
-browser/compute_this_script_browser_test: Fail # mirrors not supported
-browser/typed_data_message_test: Fail # mirrors not supported
-count_test: Fail # mirrors not supported
-cross_isolate_message_test: Fail # mirrors not supported
-illegal_msg_function_test: Fail # mirrors not supported
-illegal_msg_mirror_test: Fail # mirrors not supported
-isolate_complex_messages_test: Fail # mirrors not supported
-mandel_isolate_test: Fail # mirrors not supported
-message2_test: Fail # mirrors not supported
-message_test: Fail # mirrors not supported
-mint_maker_test: Fail # mirrors not supported
-nested_spawn2_test: Fail # mirrors not supported
-nested_spawn_test: Fail # mirrors not supported
-raw_port_test: Fail # mirrors not supported
-remote_unittest_helper: Fail # mirrors not supported
-request_reply_test: Fail # mirrors not supported
-spawn_function_custom_class_test: Fail # mirrors not supported
-spawn_function_test: Fail # mirrors not supported
-stacktrace_message_test: Fail # mirrors not supported
-static_function_test: Fail # mirrors not supported
-unresolved_ports_test: Fail # mirrors not supported
-
-[ $compiler == dart2js && $fasta ]
-browser/compute_this_script_browser_test: RuntimeError # mirrors not supported
-browser/typed_data_message_test: RuntimeError # mirrors not supported
-compile_time_error_test/01: Crash
-count_test: RuntimeError # mirrors not supported
-cross_isolate_message_test: RuntimeError # mirrors not supported
-illegal_msg_function_test: RuntimeError # mirrors not supported
-illegal_msg_mirror_test: RuntimeError # mirrors not supported
-isolate_complex_messages_test: RuntimeError # mirrors not supported
-mandel_isolate_test: RuntimeError # mirrors not supported
-message2_test: RuntimeError # mirrors not supported
-message_test: RuntimeError # mirrors not supported
-mint_maker_test: RuntimeError # mirrors not supported
-nested_spawn2_test: RuntimeError # mirrors not supported
-nested_spawn_test: RuntimeError # mirrors not supported
-raw_port_test: RuntimeError # mirrors not supported
-remote_unittest_helper: RuntimeError # mirrors not supported
-request_reply_test: RuntimeError # mirrors not supported
-spawn_function_custom_class_test: RuntimeError # mirrors not supported
-spawn_function_test: RuntimeError # mirrors not supported
-stacktrace_message_test: RuntimeError # mirrors not supported
-static_function_test: RuntimeError # mirrors not supported
-unresolved_ports_test: RuntimeError # mirrors not supported
-
-[ $compiler == dart2js && $fasta && $host_checked ]
-deferred_in_isolate2_test: Crash
-
-[ $compiler == dart2js && $jscl ]
-browser/*: SkipByDesign # Browser specific tests
-spawn_uri_test: SkipByDesign # Loading another file is not supported in JS shell
-
-[ $compiler == dart2js && ($runtime == chrome || $runtime == chromeOnAndroid || $runtime == drt || $runtime == ff || $runtime == safari) ]
-isolate_stress_test: Pass, Slow # Issue 10697
-
[ $compiler == none && $runtime == vm && $system == fuchsia ]
*: Skip # Not yet triaged.
diff --git a/tests/language/language_dart2js.status b/tests/language/language_dart2js.status
index 15b1905..1f1f0d4 100644
--- a/tests/language/language_dart2js.status
+++ b/tests/language/language_dart2js.status
@@ -14,6 +14,7 @@
full_stacktrace2_test: Pass, RuntimeError # Issue 12698
full_stacktrace3_test: Pass, RuntimeError # Issue 12698
library_env_test/has_no_html_support: RuntimeError, OK
+main_test/03: MissingRuntimeError # dart:isolate not supported
vm/*: Skip # Issue 12699
[ $arch == ia32 && $compiler == dart2js && $runtime == d8 ]
@@ -132,9 +133,9 @@
const_init2_test/02: MissingCompileTimeError
deferred_constraints_constants_test/none: Crash # Unsupported operation: KernelDeferredLoadTask.addMirrorElementsForLibrary
deferred_constraints_constants_test/reference_after_load: Crash # Unsupported operation: KernelDeferredLoadTask.addMirrorElementsForLibrary
+deferred_constraints_type_annotation_test/type_annotation1: Fail # Missing dynamic type error
deferred_constraints_type_annotation_test/type_annotation_generic1: Fail # Missing dynamic type error
deferred_constraints_type_annotation_test/type_annotation_generic4: Fail # Missing dynamic type error
-deferred_constraints_type_annotation_test/type_annotation1: Fail # Missing dynamic type error
factory_redirection_test/08: Fail
factory_redirection_test/09: Fail
factory_redirection_test/10: Fail
diff --git a/tests/language_2/language_2_dart2js.status b/tests/language_2/language_2_dart2js.status
index c9eae6b..4be878c 100644
--- a/tests/language_2/language_2_dart2js.status
+++ b/tests/language_2/language_2_dart2js.status
@@ -695,7 +695,6 @@
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/none: RuntimeError
-main_test/03: RuntimeError
many_overridden_no_such_method_test: RuntimeError
method_override7_test/00: MissingCompileTimeError
method_override7_test/01: MissingCompileTimeError
@@ -1118,7 +1117,6 @@
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/none: RuntimeError
-main_test/03: RuntimeError
malbounded_instantiation_test/01: MissingCompileTimeError
malbounded_instantiation_test/02: MissingCompileTimeError
malbounded_instantiation_test/03: MissingCompileTimeError
@@ -1669,7 +1667,6 @@
local_function2_test/none: RuntimeError
local_function3_test/none: RuntimeError
local_function_test/none: RuntimeError
-main_test/03: RuntimeError
malbounded_instantiation_test/01: MissingCompileTimeError
malbounded_instantiation_test/02: MissingCompileTimeError
malbounded_instantiation_test/03: MissingCompileTimeError
diff --git a/tests/lib_2/lib_2_dart2js.status b/tests/lib_2/lib_2_dart2js.status
index 5250745..8b5c634 100644
--- a/tests/lib_2/lib_2_dart2js.status
+++ b/tests/lib_2/lib_2_dart2js.status
@@ -3,6 +3,7 @@
# BSD-style license that can be found in the LICENSE file.
[ $compiler == dart2js ]
+async/async_await_sync_completer_test: RuntimeError
async/future_or_strong_test: RuntimeError
convert/base64_test/01: Fail, OK # Uses bit-wise operations to detect invalid values. Some large invalid values accepted by dart2js.
convert/chunked_conversion_utf88_test: Slow, Pass
@@ -21,35 +22,15 @@
html/indexeddb_3_test: Pass, Timeout # Roll 50 failure
html/indexeddb_4_test: Pass, Timeout # Roll 50 failure
html/indexeddb_5_test: Pass, Timeout # Roll 50 failure
+html/isolates_test: SkipByDesign
html/js_typed_interop_default_arg_test/default_value: MissingCompileTimeError # Issue #25759
html/js_typed_interop_side_cast_exp_test: Pass, RuntimeError # Roll 50 failure
html/mirrors_js_typed_interop_test: Pass, Slow
html/svgelement_test/PathElement: Pass, RuntimeError # Roll 50 failure
+html/worker_api_test: SkipByDesign
html/wrapping_collections_test: SkipByDesign # Testing an issue that is only relevant to Dartium
html/xhr_test: Pass, Slow
-isolate/browser/issue_12474_test: CompileTimeError # Issue 22529
-isolate/deferred_in_isolate2_test: SkipByDesign
-isolate/enum_const_test/02: RuntimeError # Issue 21817
-isolate/error_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/error_exit_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/exit_at_spawnuri_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/function_send1_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/issue_21398_parent_isolate1_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/issue_21398_parent_isolate2_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/issue_21398_parent_isolate_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/issue_24243_parent_isolate_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/kill_self_synchronously_test: SkipByDesign # Unsupported operation: Platform._resolvedExecutable
-isolate/message3_test/constInstance: RuntimeError # Issue 21817
-isolate/message3_test/constList: RuntimeError # Issue 21817
-isolate/message3_test/constList_identical: RuntimeError # Issue 21817
-isolate/message3_test/constMap: RuntimeError # Issue 21817
-isolate/non_fatal_exception_in_timer_callback_test: Skip # Issue 23876
-isolate/spawn_uri_exported_main_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/spawn_uri_missing_from_isolate_test: SkipByDesign
-isolate/spawn_uri_nested_vm_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/spawn_uri_vm_test: SkipByDesign # Test uses a ".dart" URI.
-isolate/stacktrace_message_test: RuntimeError # Fails to send stacktrace object.
-isolate/timer_isolate_test: SkipByDesign
+isolate/*: SkipByDesign # No support for dart:isolate in dart4web (http://dartbug.com/30538)
math/double_pow_test: RuntimeError
math/low_test: RuntimeError
math/random_big_test: RuntimeError # Using bigint seeds for random.
@@ -88,8 +69,6 @@
html/fileapi_entry_test: Pass, RuntimeError
html/media_stream_test: RuntimeError # Please triage.
html/speechrecognition_test: RuntimeError # Please triage.
-isolate/function_send_test: Skip # Crashes Chrome 62: https://bugs.chromium.org/p/chromium/issues/detail?id=775506
-isolate/kill_self_synchronously_test: RuntimeError
[ $compiler == dart2js && $runtime == chrome && $csp ]
html/canvas_pixel_array_type_alias_test: RuntimeError
@@ -124,8 +103,6 @@
html/rtc_test: Fail # TODO(dart2js-team): Please triage this failure.
html/speechrecognition_test: Fail # TODO(dart2js-team): Please triage this failure.
html/xhr_test/json: Fail # TODO(dart2js-team): Please triage this failure.
-isolate/mandel_isolate_test: Pass, Timeout # TODO(kasperl): Please triage.
-isolate/unresolved_ports_test: Pass, Timeout # Issue 15610
typed_data/setRange_2_test: RuntimeError # TODO(dart2js-team): Please triage this failure.
typed_data/setRange_3_test: RuntimeError # TODO(dart2js-team): Please triage this failure.
@@ -356,22 +333,12 @@
html/xhr_cross_origin_test: RuntimeError
html/xhr_test: RuntimeError
html/xsltprocessor_test: RuntimeError
-isolate/browser/package_resolve_browser_hook2_test: RuntimeError
-isolate/browser/package_resolve_browser_hook_test: RuntimeError
-isolate/browser/package_resolve_browser_test: RuntimeError
-isolate/isolate_stress_test: RuntimeError
js/null_test: RuntimeError
js/prototype_access_test: RuntimeError
[ $compiler == dart2js && $runtime == d8 && $fasta && $minified ]
collection/list_test: RuntimeError
-[ $compiler == dart2js && $runtime != d8 ]
-isolate/error_at_spawn_test: Skip # Issue 23876
-isolate/error_exit_at_spawn_test: Skip # Issue 23876
-isolate/exit_at_spawn_test: Skip # Issue 23876
-isolate/message4_test: Skip # Issue 30247
-
[ $compiler == dart2js && $runtime != d8 && $runtime != jsshell ]
html/fontface_loaded_test: RuntimeError
html/html_mock_test: RuntimeError # Issue 31038
@@ -414,7 +381,6 @@
html/speechrecognition_test: RuntimeError # Please triage.
html/text_event_test: Fail # Issue 17893
html/webgl_1_test: Pass, Fail # Issue 8219
-isolate/kill_self_synchronously_test: RuntimeError
[ $compiler == dart2js && $runtime == ie11 ]
html/element_types_content_test: RuntimeError # Issue 29922
@@ -481,8 +447,6 @@
async/zone_create_periodic_timer_test: RuntimeError # Timer interface not supported: Issue 7728.
async/zone_create_timer2_test: RuntimeError # Timer interface not supported: Issue 7728.
async/zone_empty_description2_test: RuntimeError # Timer interface not supported: Issue 7728.
-isolate/pause_test: Fail, OK # non-zero timer not supported.
-isolate/timer_isolate_test: Fail, OK # Needs Timer to run.
[ $compiler == dart2js && $runtime != jsshell ]
async/timer_not_available_test: RuntimeError
@@ -501,8 +465,6 @@
html/fileapi_supported_throws_test: Skip # FileSystem not supported on Safari
html/js_mock_test: RuntimeError # Issue 32286
html/xhr_test: RuntimeError
-isolate/cross_isolate_message_test: Skip # Issue 12627
-isolate/message_test: Skip # Issue 12627
[ $compiler == dart2js && $system == linux ]
html/interactive_geolocation_test: Skip # Requires allowing geo location.
@@ -516,16 +478,12 @@
html/js_typed_interop_lazy_test/01: RuntimeError
html/notification_permission_test: Timeout, Pass # Issue 32002
html/private_extension_member_test: RuntimeError
-isolate/isolate_stress_test: Pass, Slow # Issue 10697
js/null_test: RuntimeError # Issue 30652
[ $compiler == dart2js && $browser && $csp ]
html/custom/element_upgrade_test: Fail # Issue 17298
html/custom/js_custom_test: Fail # Issue 14643
-[ $compiler == dart2js && !$browser && $fast_startup ]
-isolate/isolate_current_test: Fail # please triage
-
[ $compiler == dart2js && $checked ]
convert/utf85_test: Pass, Slow # Issue 12029.
html/js_function_getter_trust_types_test: Skip # --trust-type-annotations incompatible with --checked
@@ -709,25 +667,6 @@
html/custom/mirrors_2_test: Fail # mirrors not supported
html/custom/mirrors_test: Fail # mirrors not supported
html/mirrors_js_typed_interop_test: Fail # mirrors not supported
-isolate/browser/compute_this_script_browser_test: Fail # mirrors not supported
-isolate/browser/typed_data_message_test: Fail # mirrors not supported
-isolate/count_test: Fail # mirrors not supported
-isolate/cross_isolate_message_test: Fail # mirrors not supported
-isolate/illegal_msg_mirror_test: Fail # mirrors not supported
-isolate/mandel_isolate_test: Fail # mirrors not supported
-isolate/message2_test: Fail # mirrors not supported
-isolate/message_test: Fail # mirrors not supported
-isolate/mint_maker_test: Fail # mirrors not supported
-isolate/nested_spawn2_test: Fail # mirrors not supported
-isolate/nested_spawn_test: Fail # mirrors not supported
-isolate/raw_port_test: Fail # mirrors not supported
-isolate/remote_unittest_helper: Fail # mirrors not supported
-isolate/request_reply_test: Fail # mirrors not supported
-isolate/spawn_function_custom_class_test: Fail # mirrors not supported
-isolate/spawn_function_test: Fail # mirrors not supported
-isolate/stacktrace_message_test: Fail # mirrors not supported
-isolate/static_function_test: Fail # mirrors not supported
-isolate/unresolved_ports_test: Fail # mirrors not supported
mirrors/regress_16321_test/01: Pass # expects failure, but if fails for the wrong reason
[ $compiler == dart2js && $fast_startup && $fasta ]
@@ -745,26 +684,6 @@
html/indexeddb_5_test: RuntimeError
html/js_typed_interop_default_arg_test/explicit_argument: RuntimeError
html/js_typed_interop_test: RuntimeError
-isolate/browser/compute_this_script_browser_test: RuntimeError # mirrors not supported
-isolate/browser/typed_data_message_test: RuntimeError # mirrors not supported
-isolate/compile_time_error_test/01: Crash
-isolate/count_test: RuntimeError # mirrors not supported
-isolate/cross_isolate_message_test: RuntimeError # mirrors not supported
-isolate/illegal_msg_mirror_test: RuntimeError # mirrors not supported
-isolate/mandel_isolate_test: RuntimeError # mirrors not supported
-isolate/message2_test: RuntimeError # mirrors not supported
-isolate/message_test: RuntimeError # mirrors not supported
-isolate/mint_maker_test: RuntimeError # mirrors not supported
-isolate/nested_spawn2_test: RuntimeError # mirrors not supported
-isolate/nested_spawn_test: RuntimeError # mirrors not supported
-isolate/raw_port_test: RuntimeError # mirrors not supported
-isolate/remote_unittest_helper: RuntimeError # mirrors not supported
-isolate/request_reply_test: RuntimeError # mirrors not supported
-isolate/spawn_function_custom_class_test: RuntimeError # mirrors not supported
-isolate/spawn_function_test: RuntimeError # mirrors not supported
-isolate/stacktrace_message_test: RuntimeError # mirrors not supported
-isolate/static_function_test: RuntimeError # mirrors not supported
-isolate/unresolved_ports_test: RuntimeError # mirrors not supported
[ $compiler == dart2js && $fasta && $host_checked ]
async/stream_controller_async_test: Crash
@@ -780,8 +699,6 @@
html/js_typed_interop_default_arg_test/explicit_argument: CompileTimeError
html/js_typed_interop_side_cast_exp_test: Crash # 'file:*/pkg/compiler/lib/src/common_elements.dart': Failed assertion: line 405 pos 12: 'element.name == '=='': is not true.
html/js_typed_interop_test: CompileTimeError
-isolate/deferred_in_isolate2_test: Crash
-isolate/mint_maker_test: Crash
typed_data/typed_data_list_test: Crash
typed_data/typed_list_iterable_test: Crash
@@ -864,9 +781,6 @@
[ $compiler == dart2js && !$fasta ]
async/future_or_bad_type_test: MissingCompileTimeError
-[ $compiler == dart2js && $jscl ]
-isolate/spawn_uri_test: SkipByDesign # Loading another file is not supported in JS shell
-
[ $compiler == dart2js && $minified ]
html/canvas_pixel_array_type_alias_test/types2_runtimeTypeName: Fail, OK # Issue 12605
@@ -875,11 +789,6 @@
convert/streamed_conversion_json_utf8_decode_test: SkipSlow # Times out. Issue 22050
convert/streamed_conversion_json_utf8_encode_test: SkipSlow # Times out. Issue 22050
convert/streamed_conversion_utf8_decode_test: SkipSlow # Times out. Issue 22050
-isolate/kill_self_synchronously_test: RuntimeError
-
-[ $compiler == dart2js && ($runtime == d8 || $runtime == jsshell) ]
-isolate/browser/issue_12474_test: RuntimeError # packageRoot not implemented.
-isolate/large_byte_data_leak_test: RuntimeError
[ $compiler == dart2js && ($runtime == ff || $runtime == safari || $ie) ]
html/custom/attribute_changed_callback_test/unsupported_on_polyfill: Fail # Polyfill does not support