Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 831db94

Browse files
author
Dart CI
committed
Version 3.0.0-132.0.dev
Merge 9bb51aa into dev
2 parents be4936a + 9bb51aa commit 831db94

21 files changed

+98
-69
lines changed

pkg/analysis_server/lib/src/handler/legacy/completion_get_suggestions2.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ class CompletionGetSuggestions2Handler extends CompletionHandler
147147
return;
148148
}
149149

150-
var performance = OperationPerformanceImpl('<root>');
151150
await performance.runAsync(
152151
'request',
153152
(performance) async {

pkg/dart2wasm/lib/class_info.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class FieldIndex {
6161
check(translator.listBaseClass, "_data", FieldIndex.listArray);
6262
check(translator.hashFieldBaseClass, "_index", FieldIndex.hashBaseIndex);
6363
check(translator.hashFieldBaseClass, "_data", FieldIndex.hashBaseData);
64-
check(translator.functionClass, "context", FieldIndex.closureContext);
64+
check(translator.closureClass, "context", FieldIndex.closureContext);
6565
check(translator.typeClass, "isDeclaredNullable",
6666
FieldIndex.typeIsDeclaredNullable);
6767
check(translator.interfaceTypeClass, "typeArguments",
@@ -322,10 +322,10 @@ class ClassInfoCollector {
322322
void collect() {
323323
initializeTop();
324324

325-
// Subclasses of the `_Function` class are generated on the fly as fields
326-
// with function types are encountered. Therefore, `_Function` class must
325+
// Subclasses of the `_Closure` class are generated on the fly as fields
326+
// with function types are encountered. Therefore, `_Closure` class must
327327
// be early in the initialization order.
328-
initialize(translator.functionClass);
328+
initialize(translator.closureClass);
329329

330330
// Similarly `_Type` is needed for type parameter fields in classes and
331331
// needs to be initialized before we encounter a class with type

pkg/dart2wasm/lib/closures.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,7 @@ class ClosureLayouter extends RecursiveVisitor {
173173

174174
// Base struct for closures.
175175
late final w.StructType closureBaseStruct = _makeClosureStruct(
176-
"#ClosureBase",
177-
_vtableBaseStructBare,
178-
translator.classInfo[translator.functionClass]!.struct);
176+
"#ClosureBase", _vtableBaseStructBare, translator.closureInfo.struct);
179177

180178
late final w.RefType typeType =
181179
translator.classInfo[translator.typeClass]!.nonNullableType;
@@ -185,12 +183,12 @@ class ClosureLayouter extends RecursiveVisitor {
185183
w.StructType _makeClosureStruct(
186184
String name, w.StructType vtableStruct, w.StructType superType) {
187185
// A closure contains:
188-
// - A class ID (always the `_Function` class ID)
186+
// - A class ID (always the `_Closure` class ID)
189187
// - An identity hash
190188
// - A context reference (used for `this` in tear-offs)
191189
// - A vtable reference
192190
// - A `_FunctionType`
193-
return m.addStructType("#ClosureBase",
191+
return m.addStructType(name,
194192
fields: [
195193
w.FieldType(w.NumType.i32),
196194
w.FieldType(w.NumType.i32),
@@ -564,8 +562,6 @@ class ClosureLayouter extends RecursiveVisitor {
564562
ib.struct_new(instantiatedRepresentation.vtableStruct);
565563
ib.end();
566564

567-
ClassInfo info = translator.classInfo[translator.functionClass]!;
568-
569565
w.DefinedFunction instantiationFunction = m.addFunction(functionType, name);
570566
w.Local preciseClosure = instantiationFunction.addLocal(genericClosureType);
571567
w.Instructions b = instantiationFunction.body;
@@ -575,7 +571,7 @@ class ClosureLayouter extends RecursiveVisitor {
575571
w.Local typeParam(int i) => instantiationFunction.locals[1 + i];
576572

577573
// Header for the closure struct
578-
b.i32_const(info.classId);
574+
b.i32_const(translator.closureInfo.classId);
579575
b.i32_const(initialIdentityHash);
580576

581577
// Context for the instantiated closure, containing the original closure and

pkg/dart2wasm/lib/code_generator.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
204204
ClosureImplementation closure = translator.getTearOffClosure(procedure);
205205
w.StructType struct = closure.representation.closureStruct;
206206

207-
ClassInfo info = translator.classInfo[translator.functionClass]!;
207+
ClassInfo info = translator.closureInfo;
208208
translator.functions.allocateClass(info.classId);
209209

210210
b.i32_const(info.classId);
@@ -2345,7 +2345,7 @@ class CodeGenerator extends ExpressionVisitor1<w.ValueType, w.ValueType>
23452345
DartType functionType, void pushContext()) {
23462346
w.StructType struct = closure.representation.closureStruct;
23472347

2348-
ClassInfo info = translator.classInfo[translator.functionClass]!;
2348+
ClassInfo info = translator.closureInfo;
23492349
translator.functions.allocateClass(info.classId);
23502350

23512351
b.i32_const(info.classId);

pkg/dart2wasm/lib/constants.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ class ConstantCreator extends ConstantVisitor<ConstantInfo?> {
545545
w.StructType struct = closure.representation.closureStruct;
546546
w.RefType type = w.RefType.def(struct, nullable: false);
547547
return createConstant(constant, type, (function, b) {
548-
ClassInfo info = translator.classInfo[translator.functionClass]!;
548+
ClassInfo info = translator.closureInfo;
549549
translator.functions.allocateClass(info.classId);
550550

551551
b.i32_const(info.classId);
@@ -614,7 +614,7 @@ class ConstantCreator extends ConstantVisitor<ConstantInfo?> {
614614
final w.DefinedFunction dynamicCallEntry = makeDynamicCallEntry();
615615

616616
return createConstant(constant, type, (function, b) {
617-
ClassInfo info = translator.classInfo[translator.functionClass]!;
617+
ClassInfo info = translator.closureInfo;
618618
translator.functions.allocateClass(info.classId);
619619

620620
w.DefinedFunction makeTrampoline(

pkg/dart2wasm/lib/dynamic_forwarders.dart

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,7 @@ class Forwarder {
524524

525525
// Invoke "call" if the value is not a closure
526526
b.struct_get(translator.topInfo.struct, FieldIndex.classId);
527-
b.i32_const(translator.classInfo[translator.functionClass]!.classId);
527+
b.i32_const(translator.closureInfo.classId);
528528
b.i32_ne();
529529
b.if_();
530530
// Value is not a closure
@@ -539,8 +539,23 @@ class Forwarder {
539539
b.return_();
540540
b.end();
541541

542-
generateDynamicCall(translator, function, receiverLocal, typeArgsLocal,
543-
positionalArgsLocal, namedArgsLocal, noSuchMethodBlock);
542+
// Cast the closure to `#ClosureBase`
543+
final closureBaseType = w.RefType.def(
544+
translator.closureLayouter.closureBaseStruct,
545+
nullable: false);
546+
final closureLocal = function.addLocal(closureBaseType);
547+
b.local_get(receiverLocal);
548+
b.ref_cast(closureBaseType);
549+
b.local_set(closureLocal);
550+
551+
generateDynamicFunctionCall(
552+
translator,
553+
function,
554+
closureLocal,
555+
typeArgsLocal,
556+
positionalArgsLocal,
557+
namedArgsLocal,
558+
noSuchMethodBlock);
544559
b.return_();
545560

546561
b.end(); // class ID
@@ -592,15 +607,15 @@ enum _ForwarderKind {
592607
/// Generate code that checks shape and type of the closure and generate a call
593608
/// to its dynamic call vtable entry.
594609
///
595-
/// [closureLocal] should be a local with a closure value. Type of the local
596-
/// does not matter as long as it can be cast to `ref #ClosureBase`.
610+
/// [closureLocal] should be a local of type `ref #ClosureBase` containing a
611+
/// closure value.
597612
///
598613
/// [typeArgsLocal], [posArgsLocal], [namedArgsLocal] are the locals for type,
599614
/// positional, and named arguments, respectively. Types of these locals must
600615
/// be `ref _ListBase`.
601616
///
602617
/// [noSuchMethodBlock] is used as the `br` target when the shape check fails.
603-
void generateDynamicCall(
618+
void generateDynamicFunctionCall(
604619
Translator translator,
605620
w.DefinedFunction function,
606621
w.Local closureLocal,
@@ -617,19 +632,10 @@ void generateDynamicCall(
617632

618633
final b = function.body;
619634

620-
// Cast the closure to `#ClosureBase`
621-
final closureBaseType = w.RefType.def(
622-
translator.closureLayouter.closureBaseStruct,
623-
nullable: false);
624-
final closureBaseLocal = function.addLocal(closureBaseType);
625-
b.local_get(closureLocal);
626-
b.ref_cast(closureBaseType);
627-
b.local_set(closureBaseLocal);
628-
629635
// Read the `_FunctionType` field
630636
final functionTypeLocal =
631637
function.addLocal(translator.closureLayouter.functionTypeType);
632-
b.local_get(closureBaseLocal);
638+
b.local_get(closureLocal);
633639
b.struct_get(translator.closureLayouter.closureBaseStruct,
634640
FieldIndex.closureRuntimeType);
635641
b.local_tee(functionTypeLocal);
@@ -653,13 +659,13 @@ void generateDynamicCall(
653659
translator.functions.getFunction(translator.checkClosureType.reference));
654660

655661
// Type check passed, call vtable entry
656-
b.local_get(closureBaseLocal);
662+
b.local_get(closureLocal);
657663
b.local_get(typeArgsLocal);
658664
b.local_get(posArgsLocal);
659665
b.local_get(namedArgsLocal);
660666

661667
// Get vtable
662-
b.local_get(closureBaseLocal);
668+
b.local_get(closureLocal);
663669
b.struct_get(
664670
translator.closureLayouter.closureBaseStruct, FieldIndex.closureVtable);
665671

pkg/dart2wasm/lib/intrinsics.dart

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1486,8 +1486,7 @@ class Intrinsifier {
14861486
}
14871487
}
14881488

1489-
if (member.enclosingClass == translator.functionClass &&
1490-
name == "_equals") {
1489+
if (member.enclosingClass == translator.closureClass && name == "_equals") {
14911490
// Function equality works like this:
14921491
//
14931492
// - Function literals and local functions are only equal if they're the
@@ -1595,7 +1594,7 @@ class Intrinsifier {
15951594
name == "apply") {
15961595
assert(function.type.inputs.length == 3);
15971596

1598-
final closureLocal = function.locals[0]; // ref Object
1597+
final closureLocal = function.locals[0]; // ref #ClosureBase
15991598
final posArgsNullableLocal = function.locals[1]; // ref null Object,
16001599
final namedArgsLocal = function.locals[2]; // ref null Object
16011600

@@ -1654,8 +1653,8 @@ class Intrinsifier {
16541653

16551654
final noSuchMethodBlock = b.block();
16561655

1657-
generateDynamicCall(translator, function, closureLocal, typeArgsLocal,
1658-
posArgsLocal, namedArgsListLocal, noSuchMethodBlock);
1656+
generateDynamicFunctionCall(translator, function, closureLocal,
1657+
typeArgsLocal, posArgsLocal, namedArgsListLocal, noSuchMethodBlock);
16591658
b.return_();
16601659

16611660
b.end(); // noSuchMethodBlock

pkg/dart2wasm/lib/kernel_nodes.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ mixin KernelNodes {
3636
late final Class boxedDoubleClass =
3737
index.getClass("dart:core", "_BoxedDouble");
3838
late final Class boxedIntClass = index.getClass("dart:core", "_BoxedInt");
39-
late final Class functionClass = index.getClass("dart:core", "_Function");
39+
late final Class closureClass = index.getClass("dart:core", "_Closure");
4040
late final Class listBaseClass = index.getClass("dart:core", "_ListBase");
4141
late final Class fixedLengthListClass = index.getClass("dart:core", "_List");
4242
late final Class growableListClass =

pkg/dart2wasm/lib/translator.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ class Translator with KernelNodes {
106106
// Some convenience accessors for commonly used values.
107107
late final ClassInfo topInfo = classes[0];
108108
late final ClassInfo objectInfo = classInfo[coreTypes.objectClass]!;
109+
late final ClassInfo closureInfo = classInfo[closureClass]!;
109110
late final ClassInfo stackTraceInfo = classInfo[stackTraceClass]!;
110111
late final w.ArrayType listArrayType = (classInfo[listBaseClass]!
111112
.struct
@@ -468,6 +469,9 @@ class Translator with KernelNodes {
468469
} else if (isFfiCompound(cls)) {
469470
if (nullable) throw "FFI types can't be nullable";
470471
return w.NumType.i32;
472+
} else if (cls == coreTypes.functionClass) {
473+
return w.RefType.def(closureLayouter.closureBaseStruct,
474+
nullable: nullable);
471475
}
472476
}
473477
return w.RefType.def(info.repr.struct, nullable: nullable);

pkg/dart2wasm/lib/types.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,7 @@ class Types {
526526
b.drop();
527527
b.i32_const(1);
528528
} else if (type.classNode == coreTypes.functionClass) {
529-
ClassInfo functionInfo = translator.classInfo[translator.functionClass]!;
530-
b.ref_test(functionInfo.nonNullableType);
529+
b.ref_test(translator.closureInfo.nonNullableType);
531530
} else if (concrete.isEmpty) {
532531
b.drop();
533532
b.i32_const(0);

runtime/tests/vm/dart/use_resolve_dwarf_paths_flag_test.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ main(List<String> args) async {
3636
throw "Cannot run test as $platformDill does not exist";
3737
}
3838

39-
await withTempDir('dwarf-flag-test', (String tempDir) async {
39+
runTests(obfuscate: false);
40+
runTests(obfuscate: true);
41+
}
42+
43+
void runTests({required bool obfuscate}) async {
44+
final pathSuffix = obfuscate ? 'obfuscated' : 'cleartext';
45+
await withTempDir('dwarf-flag-test-$pathSuffix', (String tempDir) async {
4046
final cwDir = path.dirname(Platform.script.toFilePath());
4147
final script =
4248
path.join(cwDir, 'use_save_debugging_info_flag_program.dart');
@@ -53,6 +59,10 @@ main(List<String> args) async {
5359

5460
final scriptDwarfSnapshot = path.join(tempDir, 'dwarf.so');
5561
await run(genSnapshot, <String>[
62+
if (obfuscate) ...[
63+
'--obfuscate',
64+
'--save-obfuscation-map=${path.join(tempDir, 'obfuscation.map')}',
65+
],
5666
'--resolve-dwarf-paths',
5767
'--dwarf-stack-traces-mode',
5868
'--snapshot-kind=app-aot-elf',

runtime/tests/vm/dart_2/use_resolve_dwarf_paths_flag_test.dart

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@ main(List<String> args) async {
3838
throw "Cannot run test as $platformDill does not exist";
3939
}
4040

41-
await withTempDir('dwarf-flag-test', (String tempDir) async {
41+
runTests(obfuscate: false);
42+
runTests(obfuscate: true);
43+
}
44+
45+
void runTests({bool obfuscate}) async {
46+
final pathSuffix = obfuscate ? 'obfuscated' : 'cleartext';
47+
await withTempDir('dwarf-flag-test-$pathSuffix', (String tempDir) async {
4248
final cwDir = path.dirname(Platform.script.toFilePath());
4349
final script =
4450
path.join(cwDir, 'use_save_debugging_info_flag_program.dart');
@@ -56,6 +62,10 @@ main(List<String> args) async {
5662

5763
final scriptDwarfSnapshot = path.join(tempDir, 'dwarf.so');
5864
await run(genSnapshot, <String>[
65+
if (obfuscate) ...[
66+
'--obfuscate',
67+
'--save-obfuscation-map=${path.join(tempDir, 'obfuscation.map')}',
68+
],
5969
'--no-sound-null-safety',
6070
'--resolve-dwarf-paths',
6171
'--dwarf-stack-traces-mode',

runtime/vm/dwarf.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -887,25 +887,25 @@ void Dwarf::WriteLineNumberProgram(DwarfWriteStream* stream) {
887887
String& uri = String::Handle(zone_);
888888
for (intptr_t i = 0; i < scripts_.length(); i++) {
889889
const Script& script = *(scripts_[i]);
890+
const char* uri_cstr = nullptr;
890891
if (FLAG_resolve_dwarf_paths) {
891892
uri = script.resolved_url();
892893
// Strictly enforce this to catch unresolvable cases.
893894
if (uri.IsNull()) {
894895
FATAL("no resolved URI for Script %s available",
895896
script.ToCString());
896897
}
897-
} else {
898-
uri = script.url();
899-
}
900-
ASSERT(!uri.IsNull());
901-
auto uri_cstr = Deobfuscate(uri.ToCString());
902-
if (FLAG_resolve_dwarf_paths) {
903-
auto const converted_cstr = ConvertResolvedURI(uri_cstr);
898+
// resolved_url is never obfuscated, so just convert the prefix.
899+
auto const converted_cstr = ConvertResolvedURI(uri.ToCString());
904900
// Strictly enforce this to catch inconvertible cases.
905901
if (converted_cstr == nullptr) {
906902
FATAL("cannot convert resolved URI %s", uri_cstr);
907903
}
908904
uri_cstr = converted_cstr;
905+
} else {
906+
uri = script.url();
907+
ASSERT(!uri.IsNull());
908+
uri_cstr = Deobfuscate(uri.ToCString());
909909
}
910910
RELEASE_ASSERT(strlen(uri_cstr) != 0);
911911

sdk/lib/_internal/wasm/lib/class_id.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ class ClassID {
3232
external static int get cidFuture;
3333
@pragma("wasm:class-id", "dart.core#Function")
3434
external static int get cidFunction;
35-
@pragma("wasm:class-id", "dart.core#_Function")
36-
external static int get cid_Function;
35+
@pragma("wasm:class-id", "dart.core#_Closure")
36+
external static int get cid_Closure;
3737
@pragma("wasm:class-id", "dart.core#_List")
3838
external static int get cidFixedLengthList;
3939
@pragma("wasm:class-id", "dart.core#_ListBase")

0 commit comments

Comments
 (0)