Skip to content

Commit

Permalink
Version 2.19.0-421.0.dev
Browse files Browse the repository at this point in the history
Merge a06f10c into dev
  • Loading branch information
Dart CI committed Nov 22, 2022
2 parents f774b9a + a06f10c commit d2766b3
Show file tree
Hide file tree
Showing 27 changed files with 2,801 additions and 2,326 deletions.
4 changes: 1 addition & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@
- **Breaking changes to the preview feature `@staticInterop`**:
- Classes with this annotation are now disallowed from using `external`
generative constructors. Use `external factory`s for these classes instead,
and the behavior should be identical. This includes use of synthetic
constructors. See [#48730][] and [#49941][] for more details.
and the behavior should be identical. See [#48730][] for more details.
- Classes with this annotation's external extension members are now disallowed
from using type parameters e.g. `external void method<T>(T t)`. Use a
non-`external` extension method for type parameters instead. See [#49350][]
Expand All @@ -155,7 +154,6 @@
annotation. This is to avoid confusing type behavior.

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

### Tools
Expand Down
12 changes: 0 additions & 12 deletions pkg/_fe_analyzer_shared/lib/src/messages/codes_generated.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7563,18 +7563,6 @@ Message _withArgumentsJsInteropStaticInteropNoJSAnnotation(String name) {
arguments: {'name': name});
}

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Code<Null> codeJsInteropStaticInteropSyntheticConstructor =
messageJsInteropStaticInteropSyntheticConstructor;

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const MessageCode messageJsInteropStaticInteropSyntheticConstructor = const MessageCode(
"JsInteropStaticInteropSyntheticConstructor",
problemMessage:
r"""Synthetic constructors on `@staticInterop` classes can not be used.""",
correctionMessage:
r"""Declare an external factory constructor for this `@staticInterop` class and use that instead.""");

// DO NOT EDIT. THIS FILE IS GENERATED. SEE TOP OF FILE.
const Template<Message Function(String name)>
templateJsInteropStaticInteropTrustTypesUsageNotAllowed =
Expand Down
30 changes: 0 additions & 30 deletions pkg/_js_interop_checks/lib/js_interop_checks.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
// 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.

// Used for importing CFE utility functions for constructor tear-offs.
import 'package:front_end/src/api_prototype/lowering_predicates.dart';
import 'package:kernel/core_types.dart';
import 'package:kernel/kernel.dart';
import 'package:kernel/target/targets.dart';
Expand All @@ -23,7 +21,6 @@ import 'package:_fe_analyzer_shared/src/messages/codes.dart'
messageJsInteropOperatorsNotSupported,
messageJsInteropStaticInteropExternalExtensionMembersWithTypeParameters,
messageJsInteropStaticInteropGenerativeConstructor,
messageJsInteropStaticInteropSyntheticConstructor,
templateJsInteropDartClassExtendsJSClass,
templateJsInteropNonStaticWithStaticInteropSupertype,
templateJsInteropStaticInteropNoJSAnnotation,
Expand All @@ -46,7 +43,6 @@ class JsInteropChecks extends RecursiveVisitor {
bool _classHasJSAnnotation = false;
bool _classHasAnonymousAnnotation = false;
bool _classHasStaticInteropAnnotation = false;
bool _inTearoff = false;
bool _libraryHasJSAnnotation = false;
Map<Reference, Extension>? _libraryExtensionsIndex;
// TODO(joshualitt): These checks add value for our users, but unfortunately
Expand Down Expand Up @@ -373,9 +369,7 @@ class JsInteropChecks extends RecursiveVisitor {
procedure.fileUri);
}
}
_inTearoff = isTearOffLowering(procedure);
super.visitProcedure(procedure);
_inTearoff = false;
}

@override
Expand Down Expand Up @@ -419,30 +413,6 @@ class JsInteropChecks extends RecursiveVisitor {
}
}

@override
void visitConstructorInvocation(ConstructorInvocation node) {
var constructor = node.target;
if (constructor.isSynthetic &&
// Synthetic tear-offs are created for synthetic constructors by
// invoking them, so they need to be excluded here.
!_inTearoff &&
hasStaticInteropAnnotation(constructor.enclosingClass)) {
// TODO(srujzs): This is insufficient to disallow use of synthetic
// constructors, as tear-offs may be used. However, use of such tear-offs
// are lowered as a StaticTearOffConstant. This means that we'll need a
// constant visitor in order to handle that correctly. It should be rare
// for users to use those tear-offs in favor of just invocation, but it's
// plausible. For now, in order to avoid the complexity and the extra
// visiting, we don't check tear-off usage.
_diagnosticsReporter.report(
messageJsInteropStaticInteropSyntheticConstructor,
node.fileOffset,
node.name.text.length,
node.location?.file);
}
super.visitConstructorInvocation(node);
}

/// Reports an error if [functionNode] has named parameters.
void _checkNoNamedParameters(FunctionNode functionNode) {
// ignore: unnecessary_null_comparison
Expand Down
21 changes: 9 additions & 12 deletions pkg/dart2wasm/lib/dynamic_dispatch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ class DynamicDispatcher {
// all we care about is code size, we might do best to use constant maps or
// one function per selector. On the other hand, we could also try a hybrid
// IC like approach using globals, rewiring logic, and a state machine.
// TODO(joshualitt): Handle the case of a null receiver.
w.Local cidLocal = addLocal(w.NumType.i32);

// Outer block searches through the methods and invokes the method if it
Expand Down Expand Up @@ -155,28 +154,26 @@ class DynamicDispatcher {
}
translator.functions.activateSelector(selector);
for (int classID in selector.classIds) {
final Reference target = selector.targets[classID]!;
if (target.asMember.isAbstract) {
continue;
}

b.local_get(cidLocal);
b.i32_const(classID);
b.i32_eq();
b.if_();

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

pushArguments(selector);
b.local_get(cidLocal);
int offset = selector.offset!;
if (offset != 0) {
b.i32_const(offset);
b.i32_add();
}
b.call_indirect(selector.signature);

final w.BaseFunction targetFunction =
translator.functions.getFunction(target);
b.call(targetFunction);

w.ValueType result =
translator.outputOrVoid(selector.signature.outputs);
Expand Down
2 changes: 0 additions & 2 deletions pkg/front_end/messages.status
Original file line number Diff line number Diff line change
Expand Up @@ -608,8 +608,6 @@ JsInteropStaticInteropMockNotStaticInteropType/analyzerCode: Fail # Web compiler
JsInteropStaticInteropMockNotStaticInteropType/example: Fail # Web compiler specific
JsInteropStaticInteropNoJSAnnotation/analyzerCode: Fail # Web compiler specific
JsInteropStaticInteropNoJSAnnotation/example: Fail # Web compiler specific
JsInteropStaticInteropSyntheticConstructor/analyzerCode: Fail # Web compiler specific
JsInteropStaticInteropSyntheticConstructor/example: Fail # Web compiler specific
JsInteropStaticInteropTrustTypesUsageNotAllowed/analyzerCode: Fail # Web compiler specific
JsInteropStaticInteropTrustTypesUsageNotAllowed/example: Fail # Web compiler specific
JsInteropStaticInteropTrustTypesUsedWithoutStaticInterop/analyzerCode: Fail # Web compiler specific
Expand Down
4 changes: 0 additions & 4 deletions pkg/front_end/messages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5316,10 +5316,6 @@ JsInteropStaticInteropNoJSAnnotation:
problemMessage: "`@staticInterop` classes should also have the `@JS` annotation."
correctionMessage: "Add `@JS` to class '#name'."

JsInteropStaticInteropSyntheticConstructor:
problemMessage: "Synthetic constructors on `@staticInterop` classes can not be used."
correctionMessage: "Declare an external factory constructor for this `@staticInterop` class and use that instead."

JsInteropStaticInteropWithInstanceMembers:
problemMessage: "JS interop class '#name' with `@staticInterop` annotation cannot declare instance members."
correctionMessage: "Try moving the instance member to a static extension."
Expand Down
46 changes: 46 additions & 0 deletions runtime/include/dart_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,52 @@ DART_EXPORT void Dart_KillIsolate(Dart_Isolate isolate);
*/
DART_EXPORT void Dart_NotifyIdle(int64_t deadline);

typedef void (*Dart_HeapSamplingCallback)(void* isolate_group_data,
Dart_Handle cls_name,
Dart_WeakPersistentHandle obj,
uintptr_t size);

/**
* Starts the heap sampling profiler for each thread in the VM.
*/
DART_EXPORT void Dart_EnableHeapSampling();

/*
* Stops the heap sampling profiler for each thread in the VM.
*/
DART_EXPORT void Dart_DisableHeapSampling();

/*
* Registers a callback that is invoked once per sampled allocation.
*
* Important notes:
*
* - When invoked, |cls_name| will be a handle to a Dart String representing
* the class name of the allocated object. This handle is stable and can be
* used as an identifier as it has the lifetime of its isolate group.
*
* - |obj| is a weak persistent handle to the object which caused the
* allocation. The value of this handle will be set to null when the object is
* garbage collected. |obj| should only be used to determine whether the
* object has been collected as there is no guarantee that it has been fully
* initialized. This handle should eventually be freed with
* Dart_DeleteWeakPersistentHandle once the embedder no longer needs it.
*
* - The provided callback must not call into the VM and should do as little
* work as possible to avoid performance penalities.
*/
DART_EXPORT void Dart_RegisterHeapSamplingCallback(
Dart_HeapSamplingCallback callback);

/*
* Sets the average heap sampling rate based on a number of |bytes| for each
* thread.
*
* In other words, approximately every |bytes| allocated will create a sample.
* Defaults to 512 KiB.
*/
DART_EXPORT void Dart_SetHeapSamplingPeriod(intptr_t bytes);

/**
* Notifies the VM that the embedder expects the application's working set has
* recently shrunk significantly and is not expected to rise in the near future.
Expand Down
14 changes: 12 additions & 2 deletions runtime/vm/class_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class JSONStream;
template <typename T>
class MallocGrowableArray;
class ObjectPointerVisitor;
class PersistentHandle;

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

PersistentHandle* UserVisibleNameFor(intptr_t cid) {
return classes_.At<kClassNameIndex>(cid);
}

void SetUserVisibleNameFor(intptr_t cid, PersistentHandle* name) {
classes_.At<kClassNameIndex>(cid) = name;
}
#else
void UpdateCachedAllocationTracingStateTablePointer() {}
#endif // !defined(PRODUCT)
Expand Down Expand Up @@ -542,7 +550,8 @@ class ClassTable : public MallocAllocated {
kSizeIndex,
kUnboxedFieldBitmapIndex,
#if !defined(PRODUCT)
kAllocationTracingStateIndex
kAllocationTracingStateIndex,
kClassNameIndex,
#endif
};

Expand All @@ -551,7 +560,8 @@ class ClassTable : public MallocAllocated {
ClassPtr,
uint32_t,
UnboxedFieldBitmap,
uint8_t>
uint8_t,
PersistentHandle*>
classes_;
#else
CidIndexedTable<ClassIdTagType, ClassPtr, uint32_t, UnboxedFieldBitmap>
Expand Down
Loading

0 comments on commit d2766b3

Please sign in to comment.