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

Unified Diff: runtime/bin/socket_patch.dart

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/bin/socket_patch.dart
diff --git a/runtime/bin/socket_patch.dart b/runtime/bin/socket_patch.dart
index 0e7abdb4bf98b0f310f54bf90f848b97838de460..b46bf5ea4ca0aaee21e7d78918d0ce9ccdeb5e01 100644
--- a/runtime/bin/socket_patch.dart
+++ b/runtime/bin/socket_patch.dart
@@ -355,6 +355,8 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
static const int CLOSE_COMMAND = 8;
static const int SHUTDOWN_READ_COMMAND = 9;
static const int SHUTDOWN_WRITE_COMMAND = 10;
+ // The lower bits of RETURN_TOKEN_COMMAND messages contains the number
+ // of tokens returned.
static const int RETURN_TOKEN_COMMAND = 11;
static const int FIRST_COMMAND = CLOSE_COMMAND;
static const int LAST_COMMAND = RETURN_TOKEN_COMMAND;
@@ -410,6 +412,8 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
int available = 0;
+ int returnTokens = 0;
+
bool sendReadEvents = false;
bool readEventIssued = false;
@@ -818,8 +822,14 @@ class _NativeSocket extends NativeFieldWrapperClass1 {
}
}
}
- if (eventPort != null && !isClosing && !isClosed) {
- sendToEventHandler(1 << RETURN_TOKEN_COMMAND);
+ if (eventPort != null && !isClosing && !isClosed && !isListening) {
+ returnTokens++;
+ if (returnTokens == 8) {
+ // Return in batches of 8.
+ assert(returnTokens < (1 << FIRST_COMMAND));
+ sendToEventHandler((1 << RETURN_TOKEN_COMMAND) | returnTokens);
+ returnTokens = 0;
+ }
}
}
« no previous file with comments | « runtime/bin/eventhandler_macos.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698