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

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

Issue 208653012: Only return eventhandler tokens in stacks of 8, to avoid runtime calls. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Review fixes. Created 6 years, 9 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/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_LINUX) 6 #if defined(TARGET_OS_LINUX)
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 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 ASSERT(msg[i].data == (1 << kCloseCommand)); 202 ASSERT(msg[i].data == (1 << kCloseCommand));
203 // Close the socket and free system resources and move on to 203 // Close the socket and free system resources and move on to
204 // next message. 204 // next message.
205 RemoveFromEpollInstance(epoll_fd_, sd); 205 RemoveFromEpollInstance(epoll_fd_, sd);
206 intptr_t fd = sd->fd(); 206 intptr_t fd = sd->fd();
207 sd->Close(); 207 sd->Close();
208 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd)); 208 socket_map_.Remove(GetHashmapKeyFromFd(fd), GetHashmapHashFromFd(fd));
209 delete sd; 209 delete sd;
210 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent); 210 DartUtils::PostInt32(msg[i].dart_port, 1 << kDestroyedEvent);
211 } else if ((msg[i].data & (1 << kReturnTokenCommand)) != 0) { 211 } else if ((msg[i].data & (1 << kReturnTokenCommand)) != 0) {
212 if (sd->ReturnToken()) { 212 int count = msg[i].data & ((1 << kReturnTokenCommand) - 1);
213 AddToEpollInstance(epoll_fd_, sd); 213 for (int i = 0; i < count; i++) {
214 if (sd->ReturnToken()) {
215 AddToEpollInstance(epoll_fd_, sd);
216 }
214 } 217 }
215 } else { 218 } else {
216 // Setup events to wait for. 219 // Setup events to wait for.
217 sd->SetPortAndMask(msg[i].dart_port, msg[i].data); 220 sd->SetPortAndMask(msg[i].dart_port, msg[i].data);
218 AddToEpollInstance(epoll_fd_, sd); 221 AddToEpollInstance(epoll_fd_, sd);
219 } 222 }
220 } 223 }
221 } 224 }
222 } 225 }
223 226
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER( 272 VOID_TEMP_FAILURE_RETRY_NO_SIGNAL_BLOCKER(
270 read(timer_fd_, &val, sizeof(val))); 273 read(timer_fd_, &val, sizeof(val)));
271 if (timeout_queue_.HasTimeout()) { 274 if (timeout_queue_.HasTimeout()) {
272 DartUtils::PostNull(timeout_queue_.CurrentPort()); 275 DartUtils::PostNull(timeout_queue_.CurrentPort());
273 timeout_queue_.RemoveCurrent(); 276 timeout_queue_.RemoveCurrent();
274 } 277 }
275 } else { 278 } else {
276 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr); 279 SocketData* sd = reinterpret_cast<SocketData*>(events[i].data.ptr);
277 intptr_t event_mask = GetPollEvents(events[i].events, sd); 280 intptr_t event_mask = GetPollEvents(events[i].events, sd);
278 if (event_mask != 0) { 281 if (event_mask != 0) {
279 if (sd->TakeToken()) { 282 if (!sd->IsListeningSocket() && sd->TakeToken()) {
280 // Took last token, remove from epoll. 283 // Took last token, remove from epoll.
281 RemoveFromEpollInstance(epoll_fd_, sd); 284 RemoveFromEpollInstance(epoll_fd_, sd);
282 } 285 }
283 Dart_Port port = sd->port(); 286 Dart_Port port = sd->port();
284 ASSERT(port != 0); 287 ASSERT(port != 0);
285 DartUtils::PostInt32(port, event_mask); 288 DartUtils::PostInt32(port, event_mask);
286 } 289 }
287 } 290 }
288 } 291 }
289 if (interrupt_seen) { 292 if (interrupt_seen) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 349
347 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) { 350 uint32_t EventHandlerImplementation::GetHashmapHashFromFd(intptr_t fd) {
348 // The hashmap does not support keys with value 0. 351 // The hashmap does not support keys with value 0.
349 return dart::Utils::WordHash(fd + 1); 352 return dart::Utils::WordHash(fd + 1);
350 } 353 }
351 354
352 } // namespace bin 355 } // namespace bin
353 } // namespace dart 356 } // namespace dart
354 357
355 #endif // defined(TARGET_OS_LINUX) 358 #endif // defined(TARGET_OS_LINUX)
OLDNEW
« no previous file with comments | « runtime/bin/eventhandler_linux.h ('k') | runtime/bin/eventhandler_macos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698