Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(23)

Side by Side Diff: runtime/vm/benchmark_test.cc

Issue 2620413002: Fix various memory leaks in unit tests detected by a new version of ASAN. (Closed)
Patch Set: Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/compiler_test.cc » ('j') | runtime/vm/unit_test.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/benchmark_test.h" 5 #include "vm/benchmark_test.h"
6 6
7 #include "bin/builtin.h" 7 #include "bin/builtin.h"
8 #include "bin/file.h" 8 #include "bin/file.h"
9 #include "bin/isolate_data.h" 9 #include "bin/isolate_data.h"
10 10
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 SetExecutable(executable); 89 SetExecutable(executable);
90 Benchmark* benchmark = first_; 90 Benchmark* benchmark = first_;
91 while (benchmark != NULL) { 91 while (benchmark != NULL) {
92 benchmark->RunBenchmark(); 92 benchmark->RunBenchmark();
93 benchmark = benchmark->next_; 93 benchmark = benchmark->next_;
94 } 94 }
95 } 95 }
96 96
97 97
98 Dart_Isolate Benchmark::CreateIsolate(const uint8_t* buffer) { 98 Dart_Isolate Benchmark::CreateIsolate(const uint8_t* buffer) {
99 bin::IsolateData* isolate_data = new bin::IsolateData(NULL, NULL, NULL); 99 bin::IsolateData* isolate_data = NULL;
100 char* err = NULL; 100 char* err = NULL;
101 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, isolate_data, &err); 101 isolate_ = Dart_CreateIsolate(NULL, NULL, buffer, NULL, isolate_data, &err);
zra 2017/01/11 19:05:21 Any reason not to drop the variable and just pass
rmacnak 2017/01/11 19:11:08 Good point, done.
102 EXPECT(isolate_ != NULL); 102 EXPECT(isolate_ != NULL);
103 free(err); 103 free(err);
104 return isolate_; 104 return isolate_;
105 } 105 }
106 106
107 107
108 // 108 //
109 // Measure compile of all functions in dart core lib classes. 109 // Measure compile of all functions in dart core lib classes.
110 // 110 //
111 BENCHMARK(CorelibCompileAll) { 111 BENCHMARK(CorelibCompileAll) {
(...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 Api::CheckAndFinalizePendingClasses(thread); 513 Api::CheckAndFinalizePendingClasses(thread);
514 514
515 // Write snapshot with object content. 515 // Write snapshot with object content.
516 FullSnapshotWriter writer(Snapshot::kCore, &vm_isolate_snapshot_buffer, 516 FullSnapshotWriter writer(Snapshot::kCore, &vm_isolate_snapshot_buffer,
517 &isolate_snapshot_buffer, &malloc_allocator, 517 &isolate_snapshot_buffer, &malloc_allocator,
518 NULL /* instructions_writer */); 518 NULL /* instructions_writer */);
519 writer.WriteFullSnapshot(); 519 writer.WriteFullSnapshot();
520 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); 520 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
521 ASSERT(snapshot->kind() == Snapshot::kCore); 521 ASSERT(snapshot->kind() == Snapshot::kCore);
522 benchmark->set_score(snapshot->length()); 522 benchmark->set_score(snapshot->length());
523
524 free(vm_isolate_snapshot_buffer);
525 free(isolate_snapshot_buffer);
523 } 526 }
524 527
525 528
526 BENCHMARK_SIZE(StandaloneSnapshotSize) { 529 BENCHMARK_SIZE(StandaloneSnapshotSize) {
527 const char* kScriptChars = 530 const char* kScriptChars =
528 "import 'dart:async';\n" 531 "import 'dart:async';\n"
529 "import 'dart:core';\n" 532 "import 'dart:core';\n"
530 "import 'dart:collection';\n" 533 "import 'dart:collection';\n"
531 "import 'dart:_internal';\n" 534 "import 'dart:_internal';\n"
532 "import 'dart:convert';\n" 535 "import 'dart:convert';\n"
(...skipping 14 matching lines...) Expand all
547 Api::CheckAndFinalizePendingClasses(thread); 550 Api::CheckAndFinalizePendingClasses(thread);
548 551
549 // Write snapshot with object content. 552 // Write snapshot with object content.
550 FullSnapshotWriter writer(Snapshot::kCore, &vm_isolate_snapshot_buffer, 553 FullSnapshotWriter writer(Snapshot::kCore, &vm_isolate_snapshot_buffer,
551 &isolate_snapshot_buffer, &malloc_allocator, 554 &isolate_snapshot_buffer, &malloc_allocator,
552 NULL /* instructions_writer */); 555 NULL /* instructions_writer */);
553 writer.WriteFullSnapshot(); 556 writer.WriteFullSnapshot();
554 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer); 557 const Snapshot* snapshot = Snapshot::SetupFromBuffer(isolate_snapshot_buffer);
555 ASSERT(snapshot->kind() == Snapshot::kCore); 558 ASSERT(snapshot->kind() == Snapshot::kCore);
556 benchmark->set_score(snapshot->length()); 559 benchmark->set_score(snapshot->length());
560
561 free(vm_isolate_snapshot_buffer);
562 free(isolate_snapshot_buffer);
557 } 563 }
558 564
559 565
560 BENCHMARK(CreateMirrorSystem) { 566 BENCHMARK(CreateMirrorSystem) {
561 const char* kScriptChars = 567 const char* kScriptChars =
562 "import 'dart:mirrors';\n" 568 "import 'dart:mirrors';\n"
563 "\n" 569 "\n"
564 "void benchmark() {\n" 570 "void benchmark() {\n"
565 " currentMirrorSystem();\n" 571 " currentMirrorSystem();\n"
566 "}\n"; 572 "}\n";
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 int64_t elapsed_time = timer.TotalElapsedTime(); 712 int64_t elapsed_time = timer.TotalElapsedTime();
707 benchmark->set_score(elapsed_time); 713 benchmark->set_score(elapsed_time);
708 } 714 }
709 715
710 716
711 BENCHMARK_MEMORY(InitialRSS) { 717 BENCHMARK_MEMORY(InitialRSS) {
712 benchmark->set_score(OS::MaxRSS()); 718 benchmark->set_score(OS::MaxRSS());
713 } 719 }
714 720
715 } // namespace dart 721 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/compiler_test.cc » ('j') | runtime/vm/unit_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698