Skip to content

Commit

Permalink
Version 3.5.0-299.0.dev
Browse files Browse the repository at this point in the history
Merge 874c610 into dev
  • Loading branch information
Dart CI committed Jun 25, 2024
2 parents 65ab2f2 + 874c610 commit 38bb74f
Show file tree
Hide file tree
Showing 16 changed files with 354 additions and 488 deletions.
24 changes: 24 additions & 0 deletions docs/Building-for-Fuchsia.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Setup

Download and install the Dart source tree using the standard instructions for building Dart.

To build for Fuchsia, you must first update your `.gclient file with:
```
"custom_vars": {
"download_fuchsia_deps": True,
},
```

# Building

```bash
./tools/build.py --mode=release --os=fuchsia --arch=arm64 create_sdk runtime
```


# Testing

```bash
./tools/test.py -nvm-fuchsia-release-arm64 -j4 ffi
```

5 changes: 1 addition & 4 deletions pkg/dart2wasm/lib/closures.dart
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,8 @@ class ClosureLayouter extends RecursiveVisitor {
as ProcedureAttributesMetadataRepository)
.mapping;

void collect(List<FunctionNode> extraClosurizedFunctions) {
void collect() {
translator.component.accept(this);
for (FunctionNode function in extraClosurizedFunctions) {
_visitFunctionNode(function);
}
computeClusters();
}

Expand Down
9 changes: 9 additions & 0 deletions pkg/dart2wasm/lib/compile.dart
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ Future<CompilerOutput?> compileToModule(compiler.WasmCompilerOptions options,

mixin_deduplication.transformComponent(component);

// Patch `dart:_internal`s `mainTearOff` getter.
final internalLib = component.libraries
.singleWhere((lib) => lib.importUri.toString() == 'dart:_internal');
final mainTearOff = internalLib.procedures
.singleWhere((procedure) => procedure.name.text == 'mainTearOff');
mainTearOff.isExternal = false;
mainTearOff.function.body = ReturnStatement(
ConstantExpression(StaticTearOffConstant(component.mainMethod!)));

// Keep the flags in-sync with
// pkg/vm/test/transformations/type_flow/transformer_test.dart
globalTypeFlow.transformComponent(target, coreTypes, component,
Expand Down
33 changes: 12 additions & 21 deletions pkg/dart2wasm/lib/js/runtime_blob.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.

const jsRuntimeBlobPart1 = r'''
let buildArgsList;
// `modulePromise` is a promise to the `WebAssembly.module` object to be
// instantiated.
Expand Down Expand Up @@ -38,29 +37,23 @@ const jsRuntimeBlobPart3 = r'''
// Converts a Dart List to a JS array. Any Dart objects will be converted, but
// this will be cheap for JSValues.
function arrayFromDartList(constructor, list) {
const length = dartInstance.exports.$listLength(list);
const array = new constructor(length);
for (let i = 0; i < length; i++) {
array[i] = dartInstance.exports.$listRead(list, i);
}
return array;
}
buildArgsList = function(list) {
const dartList = dartInstance.exports.$makeStringList();
for (let i = 0; i < list.length; i++) {
dartInstance.exports.$listAdd(dartList, stringToDartString(list[i]));
}
return dartList;
const exports = dartInstance.exports;
const read = exports.$listRead;
const length = exports.$listLength(list);
const array = new constructor(length);
for (let i = 0; i < length; i++) {
array[i] = read(list, i);
}
return array;
}
// A special symbol attached to functions that wrap Dart functions.
const jsWrappedDartFunctionSymbol = Symbol("JSWrappedDartFunction");
function finalizeWrapper(dartFunction, wrapped) {
wrapped.dartFunction = dartFunction;
wrapped[jsWrappedDartFunctionSymbol] = true;
return wrapped;
wrapped.dartFunction = dartFunction;
wrapped[jsWrappedDartFunctionSymbol] = true;
return wrapped;
}
// Imports
Expand Down Expand Up @@ -112,8 +105,6 @@ const jsRuntimeBlobPart5 = r'''
// `moduleInstance` is the instantiated dart2wasm module
// `args` are any arguments that should be passed into the main function.
export const invoke = (moduleInstance, ...args) => {
const dartMain = moduleInstance.exports.$getMain();
const dartArgs = buildArgsList(args);
moduleInstance.exports.$invokeMain(dartMain, dartArgs);
moduleInstance.exports.$invokeMain(args);
}
''';
16 changes: 1 addition & 15 deletions pkg/dart2wasm/lib/translator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class Translator with KernelNodes {
final Set<Member> membersBeingGenerated = {};
final Map<Reference, Closures> constructorClosures = {};
final List<_FunctionGenerator> _pendingFunctions = [];
late final Procedure mainFunction;
late final w.ModuleBuilder m;
late final w.FunctionBuilder initFunction;
late final w.ValueType voidMarker;
Expand Down Expand Up @@ -296,13 +295,12 @@ class Translator with KernelNodes {
w.Module translate() {
m = w.ModuleBuilder(watchPoints: options.watchPoints);
voidMarker = w.RefType.def(w.StructType("void"), nullable: true);
mainFunction = component.mainMethod!;

// Collect imports and exports as the very first thing so the function types
// for the imports can be places in singleton recursion groups.
functions.collectImportsAndExports();

closureLayouter.collect([mainFunction.function]);
closureLayouter.collect();
classInfoCollector.collect();

initFunction =
Expand All @@ -314,8 +312,6 @@ class Translator with KernelNodes {

dispatchTable.build();

m.exports.export("\$getMain", generateGetMain(mainFunction));

functions.initialize();
while (!functions.isWorkListEmpty()) {
Reference reference = functions.popWorkList();
Expand Down Expand Up @@ -436,16 +432,6 @@ class Translator with KernelNodes {
}
}

w.BaseFunction generateGetMain(Procedure mainFunction) {
final getMain = m.functions.define(m.types
.defineFunction(const [], const [w.RefType.any(nullable: true)]));
constants.instantiateConstant(getMain, getMain.body,
StaticTearOffConstant(mainFunction), getMain.type.outputs.single);
getMain.body.end();

return getMain;
}

Class classForType(DartType type) {
return type is InterfaceType
? type.classNode
Expand Down
3 changes: 3 additions & 0 deletions pkg/front_end/lib/src/builder/library_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ abstract class SourceCompilationUnit implements CompilationUnit {
// TODO(johnniwinther): Remove this.
SourceLibraryBuilder get sourceLibraryBuilder;

// TODO(johnniwinther): Remove this.
TypeParameterScopeBuilder get libraryTypeParameterScopeBuilder;

abstract OffsetMap offsetMap;

LibraryFeatures get libraryFeatures;
Expand Down
26 changes: 15 additions & 11 deletions pkg/front_end/lib/src/source/outline_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,8 @@ class OutlineBuilder extends StackListenerImpl {
// should not shadow these unresolved types.
compilationUnit.currentTypeParameterScopeBuilder.resolveNamedTypes(
compilationUnit.currentTypeParameterScopeBuilder.typeVariables,
_libraryBuilder);
_libraryBuilder,
compilationUnit);
}

@override
Expand Down Expand Up @@ -1337,7 +1338,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.classDeclaration, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
} else {
Identifier identifier = name as Identifier;
final int startCharOffset =
Expand Down Expand Up @@ -1444,7 +1445,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.mixinDeclaration, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
} else {
Identifier identifier = name as Identifier;
int startOffset =
Expand Down Expand Up @@ -1743,7 +1744,8 @@ class OutlineBuilder extends StackListenerImpl {
_
) = _createSyntheticTypeVariables(
compilationUnit.currentTypeParameterScopeBuilder, scopeBuilder, null);
scopeBuilder.resolveNamedTypes(typeVariables, _libraryBuilder);
scopeBuilder.resolveNamedTypes(
typeVariables, _libraryBuilder, compilationUnit);

compilationUnit.addPrimaryConstructor(
offsetMap: _offsetMap,
Expand Down Expand Up @@ -1826,7 +1828,7 @@ class OutlineBuilder extends StackListenerImpl {
checkEmpty(beginToken.charOffset);
compilationUnit
.endNestedDeclaration(TypeParameterScopeKind.topLevelMethod, "#method")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
if (identifier is Identifier) {
final int startCharOffset =
metadata == null ? beginToken.charOffset : metadata.first.charOffset;
Expand Down Expand Up @@ -2152,7 +2154,8 @@ class OutlineBuilder extends StackListenerImpl {
"Unexpected identifier $identifier (${identifier.runtimeType})");
nativeMethodName = null;
inConstructor = false;
declarationBuilder.resolveNamedTypes(typeVariables, _libraryBuilder);
declarationBuilder.resolveNamedTypes(
typeVariables, _libraryBuilder, compilationUnit);
popDeclarationContext();
return;
}
Expand Down Expand Up @@ -2346,7 +2349,8 @@ class OutlineBuilder extends StackListenerImpl {
}
}

declarationBuilder.resolveNamedTypes(typeVariables, _libraryBuilder);
declarationBuilder.resolveNamedTypes(
typeVariables, _libraryBuilder, compilationUnit);
if (constructorName != null) {
if (isConst &&
bodyKind != MethodBody.Abstract &&
Expand Down Expand Up @@ -2520,7 +2524,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.namedMixinApplication, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
} else {
Identifier identifier = name as Identifier;
String classNameForErrors = identifier.name;
Expand Down Expand Up @@ -3100,7 +3104,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.enumDeclaration, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
}

compilationUnit.endIndexedContainer();
Expand Down Expand Up @@ -3300,7 +3304,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.typedef, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
popDeclarationContext(DeclarationContext.Typedef);
return;
}
Expand All @@ -3327,7 +3331,7 @@ class OutlineBuilder extends StackListenerImpl {
compilationUnit
.endNestedDeclaration(
TypeParameterScopeKind.functionType, "<syntax-error>")
.resolveNamedTypes(typeVariables, _libraryBuilder);
.resolveNamedTypes(typeVariables, _libraryBuilder, compilationUnit);
popDeclarationContext(DeclarationContext.Typedef);
return;
}
Expand Down
Loading

0 comments on commit 38bb74f

Please sign in to comment.