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

Commit efcdca0

Browse files
committed
Version 2.14.0-377.4.beta
* Cherry-pick d9bb68f to beta * Cherry-pick b225582 to beta * Cherry-pick 3097b72 to beta
2 parents cfc6ed0 + 34e2f72 commit efcdca0

File tree

12 files changed

+228
-12
lines changed

12 files changed

+228
-12
lines changed

pkg/vm_service/test/cpu_samples_stream_test.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
import 'dart:async';
66

7-
import 'package:test/test.dart';
7+
// TODO(bkonyi): re-import after sample streaming is fixed.
8+
// import 'package:test/test.dart';
89
import 'package:vm_service/vm_service.dart';
910

1011
import 'common/service_test_common.dart';
@@ -31,7 +32,9 @@ late StreamSubscription sub;
3132

3233
var tests = <IsolateTest>[
3334
(VmService service, IsolateRef isolate) async {
34-
final completer = Completer<void>();
35+
// TODO(bkonyi): re-enable after sample streaming is fixed.
36+
// See https://github.com/dart-lang/sdk/issues/46825
37+
/*final completer = Completer<void>();
3538
int count = 0;
3639
int previousOrigin = 0;
3740
sub = service.onProfilerEvent.listen((event) async {
@@ -56,6 +59,7 @@ var tests = <IsolateTest>[
5659
5760
await completer.future;
5861
await service.streamCancel(EventStreams.kProfiler);
62+
*/
5963
},
6064
];
6165

runtime/vm/datastream.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ class ReadStream : public ValueObject {
8585
};
8686

8787
// Reads 'len' bytes from the stream.
88-
void ReadBytes(uint8_t* addr, intptr_t len) {
88+
void ReadBytes(void* addr, intptr_t len) {
8989
ASSERT((end_ - current_) >= len);
9090
if (len != 0) {
9191
memmove(addr, current_, len);

runtime/vm/message_snapshot.cc

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ class BaseSerializer : public StackResource {
145145
void WriteWordWith32BitWrites(uword value) {
146146
stream_.WriteWordWith32BitWrites(value);
147147
}
148-
void WriteBytes(const uint8_t* addr, intptr_t len) {
148+
void WriteBytes(const void* addr, intptr_t len) {
149149
stream_.WriteBytes(addr, len);
150150
}
151151
void WriteAscii(const String& str) {
@@ -344,7 +344,7 @@ class BaseDeserializer : public ValueObject {
344344
}
345345
intptr_t ReadUnsigned() { return stream_.ReadUnsigned(); }
346346
uword ReadWordWith32BitReads() { return stream_.ReadWordWith32BitReads(); }
347-
void ReadBytes(uint8_t* addr, intptr_t len) { stream_.ReadBytes(addr, len); }
347+
void ReadBytes(void* addr, intptr_t len) { stream_.ReadBytes(addr, len); }
348348
const char* ReadAscii() {
349349
intptr_t len = ReadUnsigned();
350350
const char* result = reinterpret_cast<const char*>(CurrentBufferAddress());
@@ -1572,8 +1572,7 @@ class TypedDataMessageDeserializationCluster
15721572
d->AssignRef(data.ptr());
15731573
const intptr_t length_in_bytes = length * element_size;
15741574
NoSafepointScope no_safepoint;
1575-
uint8_t* cdata = reinterpret_cast<uint8_t*>(data.untag()->data());
1576-
d->ReadBytes(cdata, length_in_bytes);
1575+
d->ReadBytes(data.untag()->data(), length_in_bytes);
15771576
}
15781577
}
15791578

@@ -2066,6 +2065,60 @@ class TransferableTypedDataMessageDeserializationCluster
20662065
}
20672066
};
20682067

2068+
class Simd128MessageSerializationCluster : public MessageSerializationCluster {
2069+
public:
2070+
explicit Simd128MessageSerializationCluster(intptr_t cid)
2071+
: MessageSerializationCluster("Simd128",
2072+
MessagePhase::kBeforeTypes,
2073+
cid) {}
2074+
~Simd128MessageSerializationCluster() {}
2075+
2076+
void Trace(MessageSerializer* s, Object* object) { objects_.Add(object); }
2077+
2078+
void WriteNodes(MessageSerializer* s) {
2079+
intptr_t count = objects_.length();
2080+
s->WriteUnsigned(count);
2081+
for (intptr_t i = 0; i < count; i++) {
2082+
Object* vector = objects_[i];
2083+
s->AssignRef(vector);
2084+
ASSERT_EQUAL(Int32x4::value_offset(), Float32x4::value_offset());
2085+
ASSERT_EQUAL(Int32x4::value_offset(), Float64x2::value_offset());
2086+
s->WriteBytes(&(static_cast<Int32x4Ptr>(vector->ptr())->untag()->value_),
2087+
sizeof(simd128_value_t));
2088+
}
2089+
}
2090+
2091+
private:
2092+
GrowableArray<Object*> objects_;
2093+
};
2094+
2095+
class Simd128MessageDeserializationCluster
2096+
: public MessageDeserializationCluster {
2097+
public:
2098+
explicit Simd128MessageDeserializationCluster(intptr_t cid)
2099+
: MessageDeserializationCluster("Simd128"), cid_(cid) {}
2100+
~Simd128MessageDeserializationCluster() {}
2101+
2102+
void ReadNodes(MessageDeserializer* d) {
2103+
intptr_t count = d->ReadUnsigned();
2104+
for (intptr_t i = 0; i < count; i++) {
2105+
ASSERT_EQUAL(Int32x4::InstanceSize(), Float32x4::InstanceSize());
2106+
ASSERT_EQUAL(Int32x4::InstanceSize(), Float64x2::InstanceSize());
2107+
ObjectPtr vector =
2108+
Object::Allocate(cid_, Int32x4::InstanceSize(), Heap::kNew,
2109+
Int32x4::ContainsCompressedPointers());
2110+
d->AssignRef(vector);
2111+
ASSERT_EQUAL(Int32x4::value_offset(), Float32x4::value_offset());
2112+
ASSERT_EQUAL(Int32x4::value_offset(), Float64x2::value_offset());
2113+
d->ReadBytes(&(static_cast<Int32x4Ptr>(vector)->untag()->value_),
2114+
sizeof(simd128_value_t));
2115+
}
2116+
}
2117+
2118+
private:
2119+
const intptr_t cid_;
2120+
};
2121+
20692122
class RegExpMessageSerializationCluster : public MessageSerializationCluster {
20702123
public:
20712124
RegExpMessageSerializationCluster()
@@ -3233,6 +3286,10 @@ MessageSerializationCluster* BaseSerializer::NewClusterForClass(
32333286
return new (Z) OneByteStringMessageSerializationCluster(Z, is_canonical);
32343287
case kTwoByteStringCid:
32353288
return new (Z) TwoByteStringMessageSerializationCluster(Z, is_canonical);
3289+
case kInt32x4Cid:
3290+
case kFloat32x4Cid:
3291+
case kFloat64x2Cid:
3292+
return new (Z) Simd128MessageSerializationCluster(cid);
32363293
default:
32373294
break;
32383295
}
@@ -3321,6 +3378,11 @@ MessageDeserializationCluster* BaseDeserializer::ReadCluster() {
33213378
return new (Z) OneByteStringMessageDeserializationCluster(is_canonical);
33223379
case kTwoByteStringCid:
33233380
return new (Z) TwoByteStringMessageDeserializationCluster(is_canonical);
3381+
case kInt32x4Cid:
3382+
case kFloat32x4Cid:
3383+
case kFloat64x2Cid:
3384+
ASSERT(!is_canonical);
3385+
return new (Z) Simd128MessageDeserializationCluster(cid);
33243386
default:
33253387
break;
33263388
}

runtime/vm/object.cc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8949,9 +8949,11 @@ bool FunctionType::HasSameTypeParametersAndBounds(const FunctionType& other,
89498949
}
89508950
}
89518951
}
8952-
// Compare flags (IsGenericCovariantImpl).
8953-
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
8954-
return false;
8952+
if (kind != TypeEquality::kInSubtypeTest) {
8953+
// Compare flags (IsGenericCovariantImpl).
8954+
if (!Array::Equals(type_params.flags(), other_type_params.flags())) {
8955+
return false;
8956+
}
89558957
}
89568958
}
89578959
return true;

runtime/vm/object.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,6 +859,7 @@ class Object {
859859
friend void UntaggedObject::Validate(IsolateGroup* isolate_group) const;
860860
friend class Closure;
861861
friend class InstanceDeserializationCluster;
862+
friend class Simd128MessageDeserializationCluster;
862863
friend class OneByteString;
863864
friend class TwoByteString;
864865
friend class ExternalOneByteString;

runtime/vm/profiler.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,12 @@ Sample* SampleBlockBuffer::ReserveSampleImpl(Isolate* isolate,
306306
Sample* sample = nullptr;
307307
if (block != nullptr) {
308308
sample = block->ReserveSample();
309+
if (sample != nullptr && block->is_full()) {
310+
// TODO(bkonyi): remove once streaming is re-enabled.
311+
// https://github.com/dart-lang/sdk/issues/46825
312+
block->evictable_ = true;
313+
FreeBlock(block);
314+
}
309315
}
310316
if (sample != nullptr) {
311317
return sample;
@@ -330,8 +336,11 @@ Sample* SampleBlockBuffer::ReserveSampleImpl(Isolate* isolate,
330336
isolate->set_current_sample_block(next);
331337
}
332338
next->set_is_allocation_block(allocation_sample);
339+
333340
can_process_block_.store(true);
334-
isolate->mutator_thread()->ScheduleInterrupts(Thread::kVMInterrupt);
341+
// TODO(bkonyi): re-enable after block streaming is fixed.
342+
// See https://github.com/dart-lang/sdk/issues/46825
343+
// isolate->mutator_thread()->ScheduleInterrupts(Thread::kVMInterrupt);
335344
return ReserveSampleImpl(isolate, allocation_sample);
336345
}
337346

runtime/vm/raw_object.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3024,6 +3024,8 @@ class UntaggedInt32x4 : public UntaggedInstance {
30243024

30253025
ALIGN8 int32_t value_[4];
30263026

3027+
friend class Simd128MessageSerializationCluster;
3028+
friend class Simd128MessageDeserializationCluster;
30273029

30283030
public:
30293031
int32_t x() const { return value_[0]; }
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
import 'package:expect/expect.dart';
6+
7+
class A<X extends num> {
8+
void f<Y extends X>(Y y) {}
9+
}
10+
11+
typedef Func = void Function<Y extends int>(Y);
12+
13+
main() {
14+
A<num> a = new A<int>();
15+
dynamic f = (a as A<int>).f;
16+
Expect.isTrue(f is Func);
17+
print(f as Func);
18+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// @dart=2.9
6+
7+
import 'package:expect/expect.dart';
8+
9+
class A<X extends num> {
10+
void f<Y extends X>(Y y) {}
11+
}
12+
13+
typedef Func = void Function<Y extends int>(Y);
14+
15+
main() {
16+
A<num> a = new A<int>();
17+
dynamic f = (a as A<int>).f;
18+
Expect.isTrue(f is Func);
19+
print(f as Func);
20+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
// See https://github.com/dart-lang/sdk/issues/46793
6+
7+
import "dart:async";
8+
import "dart:isolate";
9+
import "dart:typed_data";
10+
11+
import "package:async_helper/async_helper.dart";
12+
import "package:expect/expect.dart";
13+
14+
main() {
15+
asyncStart();
16+
var port;
17+
port = new RawReceivePort((message) {
18+
print("Receive $message");
19+
20+
var int32x4 = message[0] as Int32x4;
21+
Expect.equals(-1, int32x4.x);
22+
Expect.equals(0, int32x4.y);
23+
Expect.equals(1, int32x4.z);
24+
Expect.equals(2, int32x4.w);
25+
26+
var float32x4 = message[1] as Float32x4;
27+
Expect.equals(-2.5, float32x4.x);
28+
Expect.equals(0.0, float32x4.y);
29+
Expect.equals(1.25, float32x4.z);
30+
Expect.equals(2.125, float32x4.w);
31+
32+
var float64x2 = message[2] as Float64x2;
33+
Expect.equals(16.5, float64x2.x);
34+
Expect.equals(-32.25, float64x2.y);
35+
36+
port.close();
37+
asyncEnd();
38+
});
39+
40+
41+
var list = [
42+
new Int32x4(-1, 0, 1, 2),
43+
new Float32x4(-2.5, 0.0, 1.25, 2.125),
44+
new Float64x2(16.5, -32.25),
45+
];
46+
print("Send $list");
47+
port.sendPort.send(list);
48+
}

0 commit comments

Comments
 (0)