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

Side by Side Diff: runtime/vm/compiler_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
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 "platform/assert.h" 5 #include "platform/assert.h"
6 #include "vm/class_finalizer.h" 6 #include "vm/class_finalizer.h"
7 #include "vm/code_patcher.h" 7 #include "vm/code_patcher.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/dart_api_impl.h" 9 #include "vm/dart_api_impl.h"
10 #include "vm/object.h" 10 #include "vm/object.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 EXPECT(!func.HasOptimizedCode()); 95 EXPECT(!func.HasOptimizedCode());
96 #if !defined(PRODUCT) 96 #if !defined(PRODUCT)
97 // Constant in product mode. 97 // Constant in product mode.
98 FLAG_background_compilation = true; 98 FLAG_background_compilation = true;
99 #endif 99 #endif
100 BackgroundCompiler::EnsureInit(thread); 100 BackgroundCompiler::EnsureInit(thread);
101 Isolate* isolate = thread->isolate(); 101 Isolate* isolate = thread->isolate();
102 ASSERT(isolate->background_compiler() != NULL); 102 ASSERT(isolate->background_compiler() != NULL);
103 isolate->background_compiler()->CompileOptimized(func); 103 isolate->background_compiler()->CompileOptimized(func);
104 Monitor* m = new Monitor(); 104 Monitor* m = new Monitor();
105 MonitorLocker ml(m); 105 {
106 while (!func.HasOptimizedCode()) { 106 MonitorLocker ml(m);
107 ml.WaitWithSafepointCheck(thread, 1); 107 while (!func.HasOptimizedCode()) {
108 ml.WaitWithSafepointCheck(thread, 1);
109 }
108 } 110 }
111 delete m;
109 BackgroundCompiler::Stop(isolate); 112 BackgroundCompiler::Stop(isolate);
110 } 113 }
111 114
112 115
113 TEST_CASE(RegenerateAllocStubs) { 116 TEST_CASE(RegenerateAllocStubs) {
114 const char* kScriptChars = 117 const char* kScriptChars =
115 "class A {\n" 118 "class A {\n"
116 "}\n" 119 "}\n"
117 "unOpt() => new A(); \n" 120 "unOpt() => new A(); \n"
118 "optIt() => new A(); \n" 121 "optIt() => new A(); \n"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT(val.IsInteger()); 221 EXPECT(val.IsInteger());
219 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value()); 222 EXPECT_EQ(7, Integer::Cast(val).AsInt64Value());
220 223
221 intptr_t final_class_table_size = 224 intptr_t final_class_table_size =
222 Isolate::Current()->class_table()->NumCids(); 225 Isolate::Current()->class_table()->NumCids();
223 // Eval should not eat into this non-renewable resource. 226 // Eval should not eat into this non-renewable resource.
224 EXPECT_EQ(initial_class_table_size, final_class_table_size); 227 EXPECT_EQ(initial_class_table_size, final_class_table_size);
225 } 228 }
226 229
227 } // namespace dart 230 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698