Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit d2766b3

Browse files
author
Dart CI
committed
Version 2.19.0-421.0.dev
Merge a06f10c into dev
2 parents f774b9a + a06f10c commit d2766b3

27 files changed

+2801
-2326
lines changed

CHANGELOG.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@
142142
- **Breaking changes to the preview feature `@staticInterop`**:
143143
- Classes with this annotation are now disallowed from using `external`
144144
generative constructors. Use `external factory`s for these classes instead,
145-
and the behavior should be identical. This includes use of synthetic
146-
constructors. See [#48730][] and [#49941][] for more details.
145+
and the behavior should be identical. See [#48730][] for more details.
147146
- Classes with this annotation's external extension members are now disallowed
148147
from using type parameters e.g. `external void method<T>(T t)`. Use a
149148
non-`external` extension method for type parameters instead. See [#49350][]
@@ -155,7 +154,6 @@
155154
annotation. This is to avoid confusing type behavior.
156155

157156
[#48730]: https://github.com/dart-lang/sdk/issues/48730
158-
[#49941]: https://github.com/dart-lang/sdk/issues/49941
159157
[#49350]: https://github.com/dart-lang/sdk/issues/49350
160158

161159
### Tools

pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7563,18 +7563,6 @@ Message _withArgumentsJsInteropStaticInteropNoJSAnnotation(String name) {
75637563
arguments: {'name': name});
75647564
}
75657565

7566-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7567-
const Code<Null> codeJsInteropStaticInteropSyntheticConstructor =
7568-
messageJsInteropStaticInteropSyntheticConstructor;
7569-
7570-
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
7571-
const MessageCode messageJsInteropStaticInteropSyntheticConstructor = const MessageCode(
7572-
"JsInteropStaticInteropSyntheticConstructor",
7573-
problemMessage:
7574-
r"""Synthetic constructors on `@staticInterop` classes can not be used.""",
7575-
correctionMessage:
7576-
r"""Declare an external factory constructor for this `@staticInterop` class and use that instead.""");
7577-
75787566
// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
75797567
const Template<Message Function(String name)>
75807568
templateJsInteropStaticInteropTrustTypesUsageNotAllowed =

pkg/_js_interop_checks/lib/js_interop_checks.dart

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
// Used for importing CFE utility functions for constructor tear-offs.
6-
import 'package:front_end/src/api_prototype/lowering_predicates.dart';
75
import 'package:kernel/core_types.dart';
86
import 'package:kernel/kernel.dart';
97
import 'package:kernel/target/targets.dart';
@@ -23,7 +21,6 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
2321
messageJsInteropOperatorsNotSupported,
2422
messageJsInteropStaticInteropExternalExtensionMembersWithTypeParameters,
2523
messageJsInteropStaticInteropGenerativeConstructor,
26-
messageJsInteropStaticInteropSyntheticConstructor,
2724
templateJsInteropDartClassExtendsJSClass,
2825
templateJsInteropNonStaticWithStaticInteropSupertype,
2926
templateJsInteropStaticInteropNoJSAnnotation,
@@ -46,7 +43,6 @@ class JsInteropChecks extends RecursiveVisitor {
4643
bool _classHasJSAnnotation = false;
4744
bool _classHasAnonymousAnnotation = false;
4845
bool _classHasStaticInteropAnnotation = false;
49-
bool _inTearoff = false;
5046
bool _libraryHasJSAnnotation = false;
5147
Map<Reference, Extension>? _libraryExtensionsIndex;
5248
// TODO(joshualitt): These checks add value for our users, but unfortunately
@@ -373,9 +369,7 @@ class JsInteropChecks extends RecursiveVisitor {
373369
procedure.fileUri);
374370
}
375371
}
376-
_inTearoff = isTearOffLowering(procedure);
377372
super.visitProcedure(procedure);
378-
_inTearoff = false;
379373
}
380374

381375
@override
@@ -419,30 +413,6 @@ class JsInteropChecks extends RecursiveVisitor {
419413
}
420414
}
421415

422-
@override
423-
void visitConstructorInvocation(ConstructorInvocation node) {
424-
var constructor = node.target;
425-
if (constructor.isSynthetic &&
426-
// Synthetic tear-offs are created for synthetic constructors by
427-
// invoking them, so they need to be excluded here.
428-
!_inTearoff &&
429-
hasStaticInteropAnnotation(constructor.enclosingClass)) {
430-
// TODO(srujzs): This is insufficient to disallow use of synthetic
431-
// constructors, as tear-offs may be used. However, use of such tear-offs
432-
// are lowered as a StaticTearOffConstant. This means that we'll need a
433-
// constant visitor in order to handle that correctly. It should be rare
434-
// for users to use those tear-offs in favor of just invocation, but it's
435-
// plausible. For now, in order to avoid the complexity and the extra
436-
// visiting, we don't check tear-off usage.
437-
_diagnosticsReporter.report(
438-
messageJsInteropStaticInteropSyntheticConstructor,
439-
node.fileOffset,
440-
node.name.text.length,
441-
node.location?.file);
442-
}
443-
super.visitConstructorInvocation(node);
444-
}
445-
446416
/// Reports an error if [functionNode] has named parameters.
447417
void _checkNoNamedParameters(FunctionNode functionNode) {
448418
// ignore: unnecessary_null_comparison

pkg/dart2wasm/lib/dynamic_dispatch.dart

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,6 @@ class DynamicDispatcher {
113113
// all we care about is code size, we might do best to use constant maps or
114114
// one function per selector. On the other hand, we could also try a hybrid
115115
// IC like approach using globals, rewiring logic, and a state machine.
116-
// TODO(joshualitt): Handle the case of a null receiver.
117116
w.Local cidLocal = addLocal(w.NumType.i32);
118117

119118
// Outer block searches through the methods and invokes the method if it
@@ -155,28 +154,26 @@ class DynamicDispatcher {
155154
}
156155
translator.functions.activateSelector(selector);
157156
for (int classID in selector.classIds) {
157+
final Reference target = selector.targets[classID]!;
158+
if (target.asMember.isAbstract) {
159+
continue;
160+
}
161+
158162
b.local_get(cidLocal);
159163
b.i32_const(classID);
160164
b.i32_eq();
161165
b.if_();
162166

163-
// TODO(joshualitt): We should be able to make this a direct
164-
// invocation. However, there appear to be corner cases today where we
165-
// still need to do the actual invocation as an indirect call, for
166-
// example if the procedure we are invoking is abstract.
167167
b.comment("Dynamic invocation of '${selector.name}'");
168168
b.local_get(receiverVar);
169169
translator.convertType(function, translator.topInfo.nullableType,
170170
selector.signature.inputs[0]);
171171

172172
pushArguments(selector);
173-
b.local_get(cidLocal);
174-
int offset = selector.offset!;
175-
if (offset != 0) {
176-
b.i32_const(offset);
177-
b.i32_add();
178-
}
179-
b.call_indirect(selector.signature);
173+
174+
final w.BaseFunction targetFunction =
175+
translator.functions.getFunction(target);
176+
b.call(targetFunction);
180177

181178
w.ValueType result =
182179
translator.outputOrVoid(selector.signature.outputs);

pkg/front_end/messages.status

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -608,8 +608,6 @@ JsInteropStaticInteropMockNotStaticInteropType/analyzerCode: Fail # Web compiler
608608
JsInteropStaticInteropMockNotStaticInteropType/example: Fail # Web compiler specific
609609
JsInteropStaticInteropNoJSAnnotation/analyzerCode: Fail # Web compiler specific
610610
JsInteropStaticInteropNoJSAnnotation/example: Fail # Web compiler specific
611-
JsInteropStaticInteropSyntheticConstructor/analyzerCode: Fail # Web compiler specific
612-
JsInteropStaticInteropSyntheticConstructor/example: Fail # Web compiler specific
613611
JsInteropStaticInteropTrustTypesUsageNotAllowed/analyzerCode: Fail # Web compiler specific
614612
JsInteropStaticInteropTrustTypesUsageNotAllowed/example: Fail # Web compiler specific
615613
JsInteropStaticInteropTrustTypesUsedWithoutStaticInterop/analyzerCode: Fail # Web compiler specific

pkg/front_end/messages.yaml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5316,10 +5316,6 @@ JsInteropStaticInteropNoJSAnnotation:
53165316
problemMessage: "`@staticInterop` classes should also have the `@JS` annotation."
53175317
correctionMessage: "Add `@JS` to class '#name'."
53185318

5319-
JsInteropStaticInteropSyntheticConstructor:
5320-
problemMessage: "Synthetic constructors on `@staticInterop` classes can not be used."
5321-
correctionMessage: "Declare an external factory constructor for this `@staticInterop` class and use that instead."
5322-
53235319
JsInteropStaticInteropWithInstanceMembers:
53245320
problemMessage: "JS interop class '#name' with `@staticInterop` annotation cannot declare instance members."
53255321
correctionMessage: "Try moving the instance member to a static extension."

runtime/include/dart_api.h

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,52 @@ DART_EXPORT void Dart_KillIsolate(Dart_Isolate isolate);
12701270
*/
12711271
DART_EXPORT void Dart_NotifyIdle(int64_t deadline);
12721272

1273+
typedef void (*Dart_HeapSamplingCallback)(void* isolate_group_data,
1274+
Dart_Handle cls_name,
1275+
Dart_WeakPersistentHandle obj,
1276+
uintptr_t size);
1277+
1278+
/**
1279+
* Starts the heap sampling profiler for each thread in the VM.
1280+
*/
1281+
DART_EXPORT void Dart_EnableHeapSampling();
1282+
1283+
/*
1284+
* Stops the heap sampling profiler for each thread in the VM.
1285+
*/
1286+
DART_EXPORT void Dart_DisableHeapSampling();
1287+
1288+
/*
1289+
* Registers a callback that is invoked once per sampled allocation.
1290+
*
1291+
* Important notes:
1292+
*
1293+
* - When invoked, |cls_name| will be a handle to a Dart String representing
1294+
* the class name of the allocated object. This handle is stable and can be
1295+
* used as an identifier as it has the lifetime of its isolate group.
1296+
*
1297+
* - |obj| is a weak persistent handle to the object which caused the
1298+
* allocation. The value of this handle will be set to null when the object is
1299+
* garbage collected. |obj| should only be used to determine whether the
1300+
* object has been collected as there is no guarantee that it has been fully
1301+
* initialized. This handle should eventually be freed with
1302+
* Dart_DeleteWeakPersistentHandle once the embedder no longer needs it.
1303+
*
1304+
* - The provided callback must not call into the VM and should do as little
1305+
* work as possible to avoid performance penalities.
1306+
*/
1307+
DART_EXPORT void Dart_RegisterHeapSamplingCallback(
1308+
Dart_HeapSamplingCallback callback);
1309+
1310+
/*
1311+
* Sets the average heap sampling rate based on a number of |bytes| for each
1312+
* thread.
1313+
*
1314+
* In other words, approximately every |bytes| allocated will create a sample.
1315+
* Defaults to 512 KiB.
1316+
*/
1317+
DART_EXPORT void Dart_SetHeapSamplingPeriod(intptr_t bytes);
1318+
12731319
/**
12741320
* Notifies the VM that the embedder expects the application's working set has
12751321
* recently shrunk significantly and is not expected to rise in the near future.

runtime/vm/class_table.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class JSONStream;
3232
template <typename T>
3333
class MallocGrowableArray;
3434
class ObjectPointerVisitor;
35+
class PersistentHandle;
3536

3637
// A 64-bit bitmap describing unboxed fields in a class.
3738
//
@@ -424,6 +425,13 @@ class ClassTable : public MallocAllocated {
424425
classes_.GetColumn<kAllocationTracingStateIndex>());
425426
}
426427

428+
PersistentHandle* UserVisibleNameFor(intptr_t cid) {
429+
return classes_.At<kClassNameIndex>(cid);
430+
}
431+
432+
void SetUserVisibleNameFor(intptr_t cid, PersistentHandle* name) {
433+
classes_.At<kClassNameIndex>(cid) = name;
434+
}
427435
#else
428436
void UpdateCachedAllocationTracingStateTablePointer() {}
429437
#endif // !defined(PRODUCT)
@@ -542,7 +550,8 @@ class ClassTable : public MallocAllocated {
542550
kSizeIndex,
543551
kUnboxedFieldBitmapIndex,
544552
#if !defined(PRODUCT)
545-
kAllocationTracingStateIndex
553+
kAllocationTracingStateIndex,
554+
kClassNameIndex,
546555
#endif
547556
};
548557

@@ -551,7 +560,8 @@ class ClassTable : public MallocAllocated {
551560
ClassPtr,
552561
uint32_t,
553562
UnboxedFieldBitmap,
554-
uint8_t>
563+
uint8_t,
564+
PersistentHandle*>
555565
classes_;
556566
#else
557567
CidIndexedTable<ClassIdTagType, ClassPtr, uint32_t, UnboxedFieldBitmap>

0 commit comments

Comments
 (0)