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

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

Issue 1703383002: - Do not repeatedly allocate and release Monitor objects. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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 | « runtime/vm/heap.cc ('k') | runtime/vm/thread_barrier.h » ('j') | no next file with comments »
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 "include/dart_api.h" 5 #include "include/dart_api.h"
6 #include "platform/assert.h" 6 #include "platform/assert.h"
7 #include "vm/globals.h" 7 #include "vm/globals.h"
8 #include "vm/isolate.h" 8 #include "vm/isolate.h"
9 #include "vm/lockers.h" 9 #include "vm/lockers.h"
10 #include "vm/thread_barrier.h" 10 #include "vm/thread_barrier.h"
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // 124 //
125 // Go through a number of rounds of scheduling interrupts and waiting until all 125 // Go through a number of rounds of scheduling interrupts and waiting until all
126 // unsynchronized busy-waiting tasks observe it (in the current implementation, 126 // unsynchronized busy-waiting tasks observe it (in the current implementation,
127 // the exact latency depends on cache coherence). Synchronization is then used 127 // the exact latency depends on cache coherence). Synchronization is then used
128 // to ensure that the response to the interrupt, i.e., starting a new round, 128 // to ensure that the response to the interrupt, i.e., starting a new round,
129 // happens *after* the interrupt is observed. Without this synchronization, the 129 // happens *after* the interrupt is observed. Without this synchronization, the
130 // compiler and/or CPU could reorder operations to make the tasks observe the 130 // compiler and/or CPU could reorder operations to make the tasks observe the
131 // round update *before* the interrupt is set. 131 // round update *before* the interrupt is set.
132 TEST_CASE(StackLimitInterrupts) { 132 TEST_CASE(StackLimitInterrupts) {
133 Isolate* isolate = Thread::Current()->isolate(); 133 Isolate* isolate = Thread::Current()->isolate();
134 ThreadBarrier barrier(InterruptChecker::kTaskCount + 1); 134 ThreadBarrier barrier(InterruptChecker::kTaskCount + 1,
135 isolate->heap()->barrier(),
136 isolate->heap()->barrier_done());
135 // Start all tasks. They will busy-wait until interrupted in the first round. 137 // Start all tasks. They will busy-wait until interrupted in the first round.
136 for (intptr_t task = 0; task < InterruptChecker::kTaskCount; task++) { 138 for (intptr_t task = 0; task < InterruptChecker::kTaskCount; task++) {
137 Dart::thread_pool()->Run(new InterruptChecker(isolate, &barrier)); 139 Dart::thread_pool()->Run(new InterruptChecker(isolate, &barrier));
138 } 140 }
139 // Wait for all tasks to get ready for the first round. 141 // Wait for all tasks to get ready for the first round.
140 barrier.Sync(); 142 barrier.Sync();
141 for (intptr_t i = 0; i < InterruptChecker::kIterations; ++i) { 143 for (intptr_t i = 0; i < InterruptChecker::kIterations; ++i) {
142 isolate->ScheduleInterrupts(Isolate::kVMInterrupt); 144 isolate->ScheduleInterrupts(Isolate::kVMInterrupt);
143 // Wait for all tasks to observe the interrupt. 145 // Wait for all tasks to observe the interrupt.
144 barrier.Sync(); 146 barrier.Sync();
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 // Restore, then clear interrupts. The world is as it was. 244 // Restore, then clear interrupts. The world is as it was.
243 interrupt_bits = isolate->GetAndClearInterrupts(); 245 interrupt_bits = isolate->GetAndClearInterrupts();
244 EXPECT_EQ(kMessageInterrupt, interrupt_bits); 246 EXPECT_EQ(kMessageInterrupt, interrupt_bits);
245 EXPECT_EQ(IsolateTestHelper::GetStackLimit(isolate), 247 EXPECT_EQ(IsolateTestHelper::GetStackLimit(isolate),
246 IsolateTestHelper::GetSavedStackLimit(isolate)); 248 IsolateTestHelper::GetSavedStackLimit(isolate));
247 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterruptsMask(isolate)); 249 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterruptsMask(isolate));
248 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterrupts(isolate)); 250 EXPECT_EQ(kZero, IsolateTestHelper::GetDeferredInterrupts(isolate));
249 } 251 }
250 252
251 } // namespace dart 253 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/heap.cc ('k') | runtime/vm/thread_barrier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698