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

Side by Side Diff: runtime/bin/eventhandler_android.cc

Issue 209333014: Speed up GetRandomBytes by only entering signal-blocking scope once. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add validation and apply in other scenario. Created 6 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « runtime/bin/crypto_macos.cc ('k') | runtime/bin/eventhandler_linux.cc » ('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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "bin/eventhandler.h" 8 #include "bin/eventhandler.h"
9 9
10 #include <errno.h> // NOLINT 10 #include <errno.h> // NOLINT
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 perror("Interrupt message failure:"); 155 perror("Interrupt message failure:");
156 } 156 }
157 FATAL1("Interrupt message failure. Wrote %d bytes.", result); 157 FATAL1("Interrupt message failure. Wrote %d bytes.", result);
158 } 158 }
159 } 159 }
160 160
161 161
162 void EventHandlerImplementation::HandleInterruptFd() { 162 void EventHandlerImplementation::HandleInterruptFd() {
163 const intptr_t MAX_MESSAGES = kInterruptMessageSize; 163 const intptr_t MAX_MESSAGES = kInterruptMessageSize;
164 InterruptMessage msg[MAX_MESSAGES]; 164 InterruptMessage msg[MAX_MESSAGES];
165 ssize_t bytes = TEMP_FAILURE_RETRY( 165 ssize_t bytes = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
166 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize)); 166 read(interrupt_fds_[0], msg, MAX_MESSAGES * kInterruptMessageSize));
167 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) { 167 for (ssize_t i = 0; i < bytes / kInterruptMessageSize; i++) {
168 if (msg[i].id == kTimerId) { 168 if (msg[i].id == kTimerId) {
169 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data); 169 timeout_queue_.UpdateTimeout(msg[i].dart_port, msg[i].data);
170 } else if (msg[i].id == kShutdownId) { 170 } else if (msg[i].id == kShutdownId) {
171 shutdown_ = true; 171 shutdown_ = true;
172 } else { 172 } else {
173 SocketData* sd = GetSocketData(msg[i].id); 173 SocketData* sd = GetSocketData(msg[i].id);
174 if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) { 174 if ((msg[i].data & (1 << kShutdownReadCommand)) != 0) {
175 ASSERT(msg[i].data == (1 << kShutdownReadCommand)); 175 ASSERT(msg[i].data == (1 << kShutdownReadCommand));
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 TimerUtils::GetCurrentTimeMilliseconds(); 283 TimerUtils::GetCurrentTimeMilliseconds();
284 if (millis <= 0) { 284 if (millis <= 0) {
285 DartUtils::PostNull(timeout_queue_.CurrentPort()); 285 DartUtils::PostNull(timeout_queue_.CurrentPort());
286 timeout_queue_.RemoveCurrent(); 286 timeout_queue_.RemoveCurrent();
287 } 287 }
288 } 288 }
289 } 289 }
290 290
291 291
292 void EventHandlerImplementation::Poll(uword args) { 292 void EventHandlerImplementation::Poll(uword args) {
293 ThreadSignalBlocker signal_blocker(SIGPROF);
293 static const intptr_t kMaxEvents = 16; 294 static const intptr_t kMaxEvents = 16;
294 struct epoll_event events[kMaxEvents]; 295 struct epoll_event events[kMaxEvents];
295 EventHandlerImplementation* handler = 296 EventHandlerImplementation* handler =
296 reinterpret_cast<EventHandlerImplementation*>(args); 297 reinterpret_cast<EventHandlerImplementation*>(args);
297 ASSERT(handler != NULL); 298 ASSERT(handler != NULL);
298 while (!handler->shutdown_) { 299 while (!handler->shutdown_) {
299 int64_t millis = handler->GetTimeout(); 300 int64_t millis = handler->GetTimeout();
300 ASSERT(millis == kInfinityTimeout || millis >= 0); 301 ASSERT(millis == kInfinityTimeout || millis >= 0);
301 if (millis > kMaxInt32) millis = kMaxInt32; 302 if (millis > kMaxInt32) millis = kMaxInt32;
302 intptr_t result = TEMP_FAILURE_RETRY(epoll_wait(handler->epoll_fd_, 303 intptr_t result = TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
303 events, 304 epoll_wait(handler->epoll_fd_, events, kMaxEvents, millis));
304 kMaxEvents,
305 millis));
306 ASSERT(EAGAIN == EWOULDBLOCK); 305 ASSERT(EAGAIN == EWOULDBLOCK);
307 if (result == -1) { 306 if (result == -1) {
308 if (errno != EWOULDBLOCK) { 307 if (errno != EWOULDBLOCK) {
309 perror("Poll failed"); 308 perror("Poll failed");
310 } 309 }
311 } else { 310 } else {
312 handler->HandleTimeout(); 311 handler->HandleTimeout();
313 handler->HandleEvents(events, result); 312 handler->HandleEvents(events, result);
314 } 313 }
315 } 314 }
(...skipping 29 matching lines...) Expand all
345 344
346 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 345 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
347 // The hashmap does not support keys with value 0. 346 // The hashmap does not support keys with value 0.
348 return dart::Utils::WordHash(fd + 1); 347 return dart::Utils::WordHash(fd + 1);
349 } 348 }
350 349
351 } // namespace bin 350 } // namespace bin
352 } // namespace dart 351 } // namespace dart
353 352
354 #endif // defined(TARGET_OS_ANDROID) 353 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/bin/crypto_macos.cc ('k') | runtime/bin/eventhandler_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698