Skip to content

Commit

Permalink
Version 3.8.0-14.0.dev
Browse files Browse the repository at this point in the history
Merge f2929bf into dev
  • Loading branch information
Dart CI committed Jan 20, 2025
2 parents 2611220 + f2929bf commit bf1e8ae
Show file tree
Hide file tree
Showing 29 changed files with 616 additions and 494 deletions.
13 changes: 11 additions & 2 deletions pkg/dart2wasm/lib/constant_evaluator.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,10 @@ import 'target.dart';
class ConstantEvaluator extends kernel.ConstantEvaluator
implements VMConstantEvaluator {
final bool _checkBounds;
final bool _minify;

final Procedure _dartInternalCheckBoundsGetter;
final Procedure _dartInternalMinifyGetter;

ConstantEvaluator(
WasmCompilerOptions options,
Expand All @@ -27,8 +29,11 @@ class ConstantEvaluator extends kernel.ConstantEvaluator
ClassHierarchy classHierarchy,
LibraryIndex libraryIndex)
: _checkBounds = !options.translatorOptions.omitBoundsChecks,
_minify = options.translatorOptions.minify,
_dartInternalCheckBoundsGetter = libraryIndex.getTopLevelProcedure(
"dart:_internal", "get:_checkBounds"),
"dart:_internal", "get:checkBounds"),
_dartInternalMinifyGetter =
libraryIndex.getTopLevelProcedure("dart:_internal", "get:minify"),
super(
target.dartLibrarySupport,
target.constantsBackend,
Expand All @@ -48,6 +53,9 @@ class ConstantEvaluator extends kernel.ConstantEvaluator
if (target == _dartInternalCheckBoundsGetter) {
return canonicalize(BoolConstant(_checkBounds));
}
if (target == _dartInternalMinifyGetter) {
return canonicalize(BoolConstant(_minify));
}

return super.visitStaticGet(node);
}
Expand All @@ -58,5 +66,6 @@ class ConstantEvaluator extends kernel.ConstantEvaluator
// error if they are not).
@override
bool shouldEvaluateMember(Member node) =>
node == _dartInternalCheckBoundsGetter;
node == _dartInternalCheckBoundsGetter ||
node == _dartInternalMinifyGetter;
}
Original file line number Diff line number Diff line change
Expand Up @@ -880,7 +880,7 @@ class DeclaredSourceConstructorBuilder
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (isConst && isAugmenting) {
origin.buildOutlineExpressions(
Expand Down
4 changes: 2 additions & 2 deletions pkg/front_end/lib/src/source/source_factory_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ class SourceFactoryBuilder extends SourceFunctionBuilderImpl {
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (_delayedDefaultValueCloner != null) {
delayedDefaultValueCloners.add(_delayedDefaultValueCloner!);
Expand Down Expand Up @@ -563,7 +563,7 @@ class RedirectingFactoryBuilder extends SourceFactoryBuilder {
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (_hasBuiltOutlines) return;

inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

if (isConst && isAugmenting) {
origin.buildOutlineExpressions(
Expand Down
11 changes: 5 additions & 6 deletions pkg/front_end/lib/src/source/source_function_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ abstract class SourceFunctionBuilderImpl extends SourceMemberBuilderImpl
void buildOutlineExpressions(ClassHierarchy classHierarchy,
List<DelayedDefaultValueCloner> delayedDefaultValueCloners) {
if (!hasBuiltOutlineExpressions) {
inferFormals(formals, classHierarchy);
formals?.infer(classHierarchy);

DeclarationBuilder? classOrExtensionBuilder =
isClassMember || isExtensionMember || isExtensionTypeMember
Expand Down Expand Up @@ -575,11 +575,10 @@ void reportAugmentationMismatch(
]);
}

/// Ensures the type of each of the [formals] is inferred.
void inferFormals(
List<FormalParameterBuilder>? formals, ClassHierarchy classHierarchy) {
if (formals != null) {
for (FormalParameterBuilder formal in formals) {
extension FormalsMethods on List<FormalParameterBuilder> {
/// Ensures the type of each of the formals is inferred.
void infer(ClassHierarchy classHierarchy) {
for (FormalParameterBuilder formal in this) {
TypeBuilder formalType = formal.type;
if (formalType is InferableTypeBuilder) {
formalType.inferType(classHierarchy);
Expand Down
10 changes: 5 additions & 5 deletions pkg/front_end/test/coverage_suite_expected.dart
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_constructor_builder.dart": (
hitCount: 891,
hitCount: 893,
missCount: 0,
),
// 100.0%.
Expand All @@ -941,13 +941,13 @@ const Map<String, ({int hitCount, int missCount})> _expect = {
),
// 100.0%.
"package:front_end/src/source/source_factory_builder.dart": (
hitCount: 593,
hitCount: 590,
missCount: 0,
),
// 100.0%.
// 99.60317460317461%.
"package:front_end/src/source/source_function_builder.dart": (
hitCount: 243,
missCount: 0,
hitCount: 251,
missCount: 1,
),
// 100.0%.
"package:front_end/src/source/source_library_builder.dart": (
Expand Down
25 changes: 14 additions & 11 deletions sdk/lib/_internal/wasm/lib/boxed_double.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.

import "dart:_error_utils";
import 'dart:_boxed_int' show intHashCode;
import 'dart:_internal' show doubleToIntBits, intBitsToDouble;
import 'dart:_js_helper' show JS, jsStringToDartString;
Expand Down Expand Up @@ -362,10 +363,12 @@ final class BoxedDouble implements double {
// See ECMAScript-262, 15.7.4.5 for details.

// Step 2.
// fractionDigits < 0 || fractionDigits > 20
if (fractionDigits.gtU(20)) {
throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
// 0 <= fractionDigits <= 20
RangeErrorUtils.checkValueBetweenZeroAndPositiveMax(
fractionDigits,
20,
"fractionDigits",
);

// Step 3.
double x = this;
Expand Down Expand Up @@ -406,10 +409,12 @@ final class BoxedDouble implements double {

// Step 7.
if (fractionDigits != null) {
// fractionDigits < 0 || fractionDigits > 20
if (fractionDigits.gtU(20)) {
throw new RangeError.range(fractionDigits, 0, 20, "fractionDigits");
}
// 0 <= fractionDigits <= 20
RangeErrorUtils.checkValueBetweenZeroAndPositiveMax(
fractionDigits,
20,
"fractionDigits",
);
}

if (isNaN) return "NaN";
Expand Down Expand Up @@ -442,9 +447,7 @@ final class BoxedDouble implements double {
// look at the fractionDigits first.

// Step 8.
if (precision < 1 || precision > 21) {
throw new RangeError.range(precision, 1, 21, "precision");
}
RangeErrorUtils.checkValueInInterval(precision, 1, 21, "precision");

if (isNaN) return "NaN";
if (this == double.infinity) return "Infinity";
Expand Down
7 changes: 4 additions & 3 deletions sdk/lib/_internal/wasm/lib/boxed_int.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.

import "dart:_error_utils";
import 'dart:_boxed_double';
import 'dart:_internal';
import 'dart:_wasm';
Expand Down Expand Up @@ -306,8 +307,8 @@ final class BoxedInt implements int {

// Returns pow(this, e) % m.
int modPow(int e, int m) {
if (e < 0) throw new RangeError.range(e, 0, null, "exponent");
if (m <= 0) throw new RangeError.range(m, 1, null, "modulus");
RangeErrorUtils.checkNotNegative(e, "exponent");
RangeErrorUtils.checkPositive(m, "modulus");
if (e == 0) return 1;

// This is floor(sqrt(2^63)).
Expand Down Expand Up @@ -407,7 +408,7 @@ final class BoxedInt implements int {

// Returns 1/this % m, with m > 0.
int modInverse(int m) {
if (m <= 0) throw new RangeError.range(m, 1, null, "modulus");
RangeErrorUtils.checkPositive(m, "modulus");
if (m == 1) return 0;
int t = this;
// t < 0 || t >= m, m is positive (checked above)
Expand Down
5 changes: 2 additions & 3 deletions sdk/lib/_internal/wasm/lib/boxed_int_to_string.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// 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.

import 'dart:_error_utils';
import 'dart:_internal';
import 'dart:_string';

Expand All @@ -17,9 +18,7 @@ class BoxedInt {
const _digits = "0123456789abcdefghijklmnopqrstuvwxyz";

String _intToRadixString(int value, int radix) {
if (radix < 2 || 36 < radix) {
throw new RangeError.range(radix, 2, 36, "radix");
}
RangeErrorUtils.checkValueInInterval(radix, 2, 36, "radix");
if (radix & (radix - 1) == 0) {
return _toPow2String(value, radix);
}
Expand Down
12 changes: 6 additions & 6 deletions sdk/lib/_internal/wasm/lib/compact_hash.dart
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,7 @@ class _CompactIterator<E> implements Iterator<E> {
E? _current;

_CompactIterator(this._table, this._data, this._len, this._offset, this._step)
: _checkSum = _table._checkSum;
: _checkSum = _table._checkSum;

bool moveNext() {
if (_table._isModifiedSince(_data, _checkSum)) {
Expand Down Expand Up @@ -812,7 +812,7 @@ class _CompactEntriesIterator<K, V> implements Iterator<MapEntry<K, V>> {
MapEntry<K, V>? _current;

_CompactEntriesIterator(this._table, this._data, this._len)
: _checkSum = _table._checkSum;
: _checkSum = _table._checkSum;

bool moveNext() {
if (_table._isModifiedSince(_data, _checkSum)) {
Expand Down Expand Up @@ -1248,13 +1248,13 @@ base class CompactLinkedCustomHashSet<E> extends _HashFieldBase
) : _validKey = validKey ?? TypeTest<E>().test;

Set<R> cast<R>() => Set.castFrom<E, R>(this);
Set<E> toSet() => CompactLinkedCustomHashSet<E>(_equality, _hasher, _validKey)
..addAll(this);
Set<E> toSet() =>
CompactLinkedCustomHashSet<E>(_equality, _hasher, _validKey)
..addAll(this);
}

@pragma('wasm:prefer-inline')
Map<K, V> createMapFromKeyValueListUnsafe<K, V>(
WasmArray<Object?> keyValuePairData,
int usedData,
) =>
DefaultMap<K, V>().._populateUnsafe(keyValuePairData, usedData);
) => DefaultMap<K, V>().._populateUnsafe(keyValuePairData, usedData);
14 changes: 12 additions & 2 deletions sdk/lib/_internal/wasm/lib/convert_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.

import "dart:_compact_hash" show createMapFromKeyValueListUnsafe;
import "dart:_error_utils";
import "dart:_internal"
show patch, POWERS_OF_TEN, unsafeCast, pushWasmArray, popWasmArray;
import "dart:_js_string_convert";
Expand Down Expand Up @@ -2006,7 +2007,11 @@ class _Utf8Decoder {

@patch
String convertSingle(List<int> codeUnits, int start, int? maybeEnd) {
int end = RangeError.checkValidRange(start, maybeEnd, codeUnits.length);
int end = RangeErrorUtils.checkValidRange(
start,
maybeEnd,
codeUnits.length,
);
if (start == end) return "";

if (codeUnits is JSUint8ArrayImpl) {
Expand Down Expand Up @@ -2103,7 +2108,12 @@ class _Utf8Decoder {

@patch
String convertChunked(List<int> codeUnits, int start, int? maybeEnd) {
int end = RangeError.checkValidRange(start, maybeEnd, codeUnits.length);
int end = RangeErrorUtils.checkValidRange(
start,
maybeEnd,
codeUnits.length,
);
if (start == end) return "";

final U8List bytes;
int errorOffset;
Expand Down
2 changes: 1 addition & 1 deletion sdk/lib/_internal/wasm/lib/core_patch.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import "dart:_internal"
doubleToIntBits,
EfficientLengthIterable,
FixedLengthListMixin,
indexCheckWithName,
intBitsToDouble,
IterableElementError,
jsonEncode,
Expand All @@ -25,6 +24,7 @@ import "dart:_internal"
WasmStringBase,
WasmTypedDataBase;

import 'dart:_error_utils';
import "dart:_internal" as _internal;

import 'dart:_js_helper'
Expand Down
Loading

0 comments on commit bf1e8ae

Please sign in to comment.