Skip to content

Commit bc139b2

Browse files
author
Dart CI
committed
Version 2.14.0-106.0.dev
Merge commit '02a8dd90e11286eb8427a12011c0fbeebe50f50f' into 'dev'
2 parents f0990e7 + 02a8dd9 commit bc139b2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1686
-762
lines changed

pkg/native_stack_traces/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## 0.4.3
4+
5+
- Exported some more of the ELF utilities for use in Dart tests.
6+
37
## 0.4.2
48

59
- When decoding a stack trace, frames corresponding to the functions

pkg/native_stack_traces/lib/elf.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
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-
export 'src/elf.dart' show Elf, Symbol;
5+
export 'src/elf.dart' show Elf, Section, Symbol;
66
export 'src/constants.dart'
77
show
88
isolateDataSymbolName,

pkg/native_stack_traces/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: native_stack_traces
22
description: Utilities for working with non-symbolic stack traces.
3-
version: 0.4.2
3+
version: 0.4.3
44

55
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/native_stack_traces
66

runtime/tests/vm/dart/v8_snapshot_profile_writer_test.dart

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -189,12 +189,17 @@ Future<void> testAOT(String dillPath,
189189
final expectedSize =
190190
profile.nodes.fold<int>(0, (size, n) => size + n.selfSize);
191191

192+
// May not be ELF, but another format.
193+
final elf = Elf.fromFile(snapshotPath);
194+
192195
var checkedSize = false;
193196
if (!useAsm) {
194-
// Verify that the total size of the snapshot text and data sections is
195-
// the same as the sum of the shallow sizes of all objects in the profile.
196-
// This ensures that all bytes are accounted for in some way.
197-
final elf = Elf.fromFile(snapshotPath);
197+
// Verify that the total size of the snapshot text and data section
198+
// symbols is the same as the sum of the shallow sizes of all objects in
199+
// the profile. This ensures that all bytes are accounted for in some way.
200+
//
201+
// We only check this when generating ELF directly because that's when
202+
// we're guaranteed the symbols will have non-zero size.
198203
Expect.isNotNull(elf);
199204
elf!; // To refine type to non-nullable version.
200205

@@ -215,10 +220,54 @@ Future<void> testAOT(String dillPath,
215220

216221
Expect.equals(
217222
expectedSize, actualSize, "failed on $description snapshot");
223+
Expect.equals(expectedSize, actualSize,
224+
"symbol size check failed on $description snapshot");
225+
checkedSize = true;
226+
}
227+
228+
// See Elf::kPages in runtime/vm/elf.h, which is also used for assembly
229+
// padding.
230+
final segmentAlignment = 16 * 1024;
231+
232+
if (elf != null) {
233+
// Verify that the total size of the snapshot text and data sections is
234+
// approximately the sum of the shallow sizes of all objects in the
235+
// profile. As sections might be merged by the assembler when useAsm is
236+
// true, we need to account for possible padding.
237+
final textSections = elf.namedSections(".text");
238+
Expect.isNotEmpty(textSections);
239+
Expect.isTrue(
240+
textSections.length <= 2, "More text sections than expected");
241+
final dataSections = elf.namedSections(".rodata");
242+
Expect.isNotEmpty(dataSections);
243+
Expect.isTrue(
244+
dataSections.length <= 2, "More data sections than expected");
245+
246+
var actualSize = 0;
247+
for (final section in textSections) {
248+
actualSize += section.length;
249+
}
250+
for (final section in dataSections) {
251+
actualSize += section.length;
252+
}
253+
254+
final mergedCount = (2 - textSections.length) + (2 - dataSections.length);
255+
final possiblePadding = mergedCount * segmentAlignment;
256+
257+
Expect.approxEquals(
258+
expectedSize,
259+
actualSize,
260+
possiblePadding,
261+
"section size failed on $description snapshot" +
262+
(!useAsm ? ", but symbol size test passed" : ""));
218263
checkedSize = true;
219264
}
220265

221266
if (stripUtil || stripFlag) {
267+
// Verify that the actual size of the stripped snapshot is close to the
268+
// sum of the shallow sizes of all objects in the profile. They will not
269+
// be exactly equal because of global headers, padding, and non-text/data
270+
// sections.
222271
var strippedSnapshotPath = snapshotPath;
223272
if (stripUtil) {
224273
strippedSnapshotPath = snapshotPath + '.stripped';
@@ -227,20 +276,18 @@ Future<void> testAOT(String dillPath,
227276
print("Stripped snapshot generated at $strippedSnapshotPath.");
228277
}
229278

230-
// Verify that the actual size of the stripped snapshot is close to the
231-
// sum of the shallow sizes of all objects in the profile. They will not
232-
// be exactly equal because of global headers and padding.
233279
final actualSize = await File(strippedSnapshotPath).length();
234280

235-
// See Elf::kPages in runtime/vm/elf.h, which is also used for assembly
236-
// padding.
237-
final segmentAlignment = 16 * 1024;
238281
// Not every byte is accounted for by the snapshot profile, and data and
239282
// instruction segments are padded to an alignment boundary.
240283
final tolerance = 0.03 * actualSize + 2 * segmentAlignment;
241284

242-
Expect.approxEquals(expectedSize, actualSize, tolerance,
243-
"failed on $description snapshot");
285+
Expect.approxEquals(
286+
expectedSize,
287+
actualSize,
288+
tolerance,
289+
"total size check failed on $description snapshot" +
290+
(elf != null ? ", but section size checks passed" : ""));
244291
checkedSize = true;
245292
}
246293

runtime/tests/vm/dart_2/v8_snapshot_profile_writer_test.dart

Lines changed: 59 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,17 @@ Future<void> testAOT(String dillPath,
197197
final expectedSize =
198198
profile.nodes.fold<int>(0, (size, n) => size + n.selfSize);
199199

200+
// May not be ELF, but another format.
201+
final elf = Elf.fromFile(snapshotPath);
202+
200203
var checkedSize = false;
201204
if (!useAsm) {
202-
// Verify that the total size of the snapshot text and data sections is
203-
// the same as the sum of the shallow sizes of all objects in the profile.
204-
// This ensures that all bytes are accounted for in some way.
205-
final elf = Elf.fromFile(snapshotPath);
205+
// Verify that the total size of the snapshot text and data section
206+
// symbols is the same as the sum of the shallow sizes of all objects in
207+
// the profile. This ensures that all bytes are accounted for in some way.
208+
//
209+
// We only check this when generating ELF directly because that's when
210+
// we're guaranteed the symbols will have non-zero size.
206211
Expect.isNotNull(elf);
207212

208213
final vmTextSectionSymbol = elf.dynamicSymbolFor(vmSymbolName);
@@ -220,12 +225,54 @@ Future<void> testAOT(String dillPath,
220225
isolateTextSectionSymbol.size +
221226
isolateDataSectionSymbol.size;
222227

223-
Expect.equals(
224-
expectedSize, actualSize, "failed on $description snapshot");
228+
Expect.equals(expectedSize, actualSize,
229+
"symbol size check failed on $description snapshot");
230+
checkedSize = true;
231+
}
232+
233+
// See Elf::kPages in runtime/vm/elf.h, which is also used for assembly
234+
// padding.
235+
final segmentAlignment = 16 * 1024;
236+
237+
if (elf != null) {
238+
// Verify that the total size of the snapshot text and data sections is
239+
// approximately the sum of the shallow sizes of all objects in the
240+
// profile. As sections might be merged by the assembler when useAsm is
241+
// true, we need to account for possible padding.
242+
final textSections = elf.namedSections(".text");
243+
Expect.isNotEmpty(textSections);
244+
Expect.isTrue(
245+
textSections.length <= 2, "More text sections than expected");
246+
final dataSections = elf.namedSections(".rodata");
247+
Expect.isNotEmpty(dataSections);
248+
Expect.isTrue(
249+
dataSections.length <= 2, "More data sections than expected");
250+
251+
var actualSize = 0;
252+
for (final section in textSections) {
253+
actualSize += section.length;
254+
}
255+
for (final section in dataSections) {
256+
actualSize += section.length;
257+
}
258+
259+
final mergedCount = (2 - textSections.length) + (2 - dataSections.length);
260+
final possiblePadding = mergedCount * segmentAlignment;
261+
262+
Expect.approxEquals(
263+
expectedSize,
264+
actualSize,
265+
possiblePadding,
266+
"section size failed on $description snapshot" +
267+
(!useAsm ? ", but symbol size test passed" : ""));
225268
checkedSize = true;
226269
}
227270

228271
if (stripUtil || stripFlag) {
272+
// Verify that the actual size of the stripped snapshot is close to the
273+
// sum of the shallow sizes of all objects in the profile. They will not
274+
// be exactly equal because of global headers, padding, and non-text/data
275+
// sections.
229276
var strippedSnapshotPath = snapshotPath;
230277
if (stripUtil) {
231278
strippedSnapshotPath = snapshotPath + '.stripped';
@@ -234,20 +281,18 @@ Future<void> testAOT(String dillPath,
234281
print("Stripped snapshot generated at $strippedSnapshotPath.");
235282
}
236283

237-
// Verify that the actual size of the stripped snapshot is close to the
238-
// sum of the shallow sizes of all objects in the profile. They will not
239-
// be exactly equal because of global headers and padding.
240284
final actualSize = await File(strippedSnapshotPath).length();
241285

242-
// See Elf::kPages in runtime/vm/elf.h, which is also used for assembly
243-
// padding.
244-
final segmentAlignment = 16 * 1024;
245286
// Not every byte is accounted for by the snapshot profile, and data and
246287
// instruction segments are padded to an alignment boundary.
247288
final tolerance = 0.03 * actualSize + 2 * segmentAlignment;
248289

249-
Expect.approxEquals(expectedSize, actualSize, tolerance,
250-
"failed on $description snapshot");
290+
Expect.approxEquals(
291+
expectedSize,
292+
actualSize,
293+
tolerance,
294+
"total size check failed on $description snapshot" +
295+
(elf != null ? ", but section size checks passed" : ""));
251296
checkedSize = true;
252297
}
253298

runtime/vm/benchmark_test.cc

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ BENCHMARK(CorelibCompileAll) {
4848
TransitionNativeToVM transition(thread);
4949
StackZone zone(thread);
5050
HANDLESCOPE(thread);
51-
Timer timer(true, "Compile all of Core lib benchmark");
51+
Timer timer;
5252
timer.Start();
5353
const Error& error =
5454
Error::Handle(Library::CompileAll(/*ignore_error=*/true));
@@ -92,7 +92,7 @@ static char* ComputeKernelServicePath(const char* arg) {
9292
//
9393
BENCHMARK(CorelibIsolateStartup) {
9494
const int kNumIterations = 1000;
95-
Timer timer(true, "CorelibIsolateStartup");
95+
Timer timer;
9696
Isolate* isolate = thread->isolate();
9797
Dart_ExitIsolate();
9898
for (int i = 0; i < kNumIterations; i++) {
@@ -192,7 +192,7 @@ BENCHMARK(UseDartApi) {
192192
result = Dart_Invoke(lib, NewString("benchmark"), 1, args);
193193
EXPECT_VALID(result);
194194

195-
Timer timer(true, "UseDartApi benchmark");
195+
Timer timer;
196196
timer.Start();
197197
result = Dart_Invoke(lib, NewString("benchmark"), 1, args);
198198
EXPECT_VALID(result);
@@ -208,7 +208,7 @@ static void NoopFinalizer(void* isolate_callback_data, void* peer) {}
208208
//
209209
BENCHMARK(DartStringAccess) {
210210
const int kNumIterations = 10000000;
211-
Timer timer(true, "DartStringAccess benchmark");
211+
Timer timer;
212212
timer.Start();
213213
Dart_EnterScope();
214214

@@ -281,7 +281,7 @@ BENCHMARK(KernelServiceCompileAll) {
281281
result = Dart_FinalizeLoading(false);
282282
EXPECT_VALID(result);
283283

284-
Timer timer(true, "Compile all of kernel service benchmark");
284+
Timer timer;
285285
timer.Start();
286286
#if !defined(PRODUCT)
287287
const bool old_flag = FLAG_background_compilation;
@@ -303,7 +303,7 @@ BENCHMARK(KernelServiceCompileAll) {
303303
// Measure frame lookup during stack traversal.
304304
//
305305
static void StackFrame_accessFrame(Dart_NativeArguments args) {
306-
Timer timer(true, "LookupDartCode benchmark");
306+
Timer timer;
307307
timer.Start();
308308
{
309309
Thread* thread = Thread::Current();
@@ -474,7 +474,7 @@ BENCHMARK(CreateMirrorSystem) {
474474

475475
Dart_Handle lib = TestCase::LoadTestScript(kScriptChars, NULL);
476476

477-
Timer timer(true, "currentMirrorSystem() benchmark");
477+
Timer timer;
478478
timer.Start();
479479
Dart_Handle result = Dart_Invoke(lib, NewString("benchmark"), 0, NULL);
480480
EXPECT_VALID(result);
@@ -496,7 +496,7 @@ BENCHMARK(EnterExitIsolate) {
496496
Api::CheckAndFinalizePendingClasses(thread);
497497
}
498498
Dart_Isolate isolate = Dart_CurrentIsolate();
499-
Timer timer(true, "Enter and Exit isolate");
499+
Timer timer;
500500
timer.Start();
501501
for (intptr_t i = 0; i < kLoopCount; i++) {
502502
Dart_ExitIsolate();
@@ -513,7 +513,7 @@ BENCHMARK(SerializeNull) {
513513
HANDLESCOPE(thread);
514514
const Object& null_object = Object::Handle();
515515
const intptr_t kLoopCount = 1000000;
516-
Timer timer(true, "Serialize Null");
516+
Timer timer;
517517
timer.Start();
518518
for (intptr_t i = 0; i < kLoopCount; i++) {
519519
StackZone zone(thread);
@@ -536,7 +536,7 @@ BENCHMARK(SerializeSmi) {
536536
HANDLESCOPE(thread);
537537
const Integer& smi_object = Integer::Handle(Smi::New(42));
538538
const intptr_t kLoopCount = 1000000;
539-
Timer timer(true, "Serialize Smi");
539+
Timer timer;
540540
timer.Start();
541541
for (intptr_t i = 0; i < kLoopCount; i++) {
542542
StackZone zone(thread);
@@ -561,7 +561,7 @@ BENCHMARK(SimpleMessage) {
561561
array_object.SetAt(0, Integer::Handle(Smi::New(42)));
562562
array_object.SetAt(1, Object::Handle());
563563
const intptr_t kLoopCount = 1000000;
564-
Timer timer(true, "Simple Message");
564+
Timer timer;
565565
timer.Start();
566566
for (intptr_t i = 0; i < kLoopCount; i++) {
567567
StackZone zone(thread);
@@ -595,7 +595,7 @@ BENCHMARK(LargeMap) {
595595
Instance& map = Instance::Handle();
596596
map ^= Api::UnwrapHandle(h_result);
597597
const intptr_t kLoopCount = 100;
598-
Timer timer(true, "Large Map");
598+
Timer timer;
599599
timer.Start();
600600
for (intptr_t i = 0; i < kLoopCount; i++) {
601601
StackZone zone(thread);

0 commit comments

Comments
 (0)