Browse Source

Add --use-uv command-line flag to use libuv backend

v0.7.4-release
Ryan Dahl 14 years ago
parent
commit
710f8e2acc
  1. 0
      lib/net_legacy.js
  2. 2
      lib/tty_posix.js
  3. 17
      src/node.cc
  4. 17
      src/node.js

0
lib/net.js → lib/net_legacy.js

2
lib/tty_posix.js

@ -21,7 +21,7 @@
var binding = process.binding('stdio'), var binding = process.binding('stdio'),
net = require('net'), net = require('net_legacy'), // FIXME
inherits = require('util').inherits, inherits = require('util').inherits,
spawn = require('child_process').spawn; spawn = require('child_process').spawn;

17
src/node.cc

@ -123,6 +123,18 @@ static uv_async_t eio_want_poll_notifier;
static uv_async_t eio_done_poll_notifier; static uv_async_t eio_done_poll_notifier;
static uv_idle_t eio_poller; static uv_idle_t eio_poller;
// XXX use_uv defaults to false on POSIX platforms and to true on Windows
// platforms. This can be set with "--use-uv" command-line flag. We intend
// to remove the legacy backend once the libuv backend is passing all of the
// tests.
#ifdef __POSIX__
static bool use_uv = false;
#else
static bool use_uv = true;
#endif
// Buffer for getpwnam_r(), getgrpam_r() and other misc callers; keep this // Buffer for getpwnam_r(), getgrpam_r() and other misc callers; keep this
// scoped at file-level rather than method-level to avoid excess stack usage. // scoped at file-level rather than method-level to avoid excess stack usage.
static char getbuf[PATH_MAX + 1]; static char getbuf[PATH_MAX + 1];
@ -2082,6 +2094,7 @@ Handle<Object> SetupProcessObject(int argc, char *argv[]) {
process->Set(String::NewSymbol("pid"), Integer::New(getpid())); process->Set(String::NewSymbol("pid"), Integer::New(getpid()));
process->Set(String::NewSymbol("cov"), cov ? True() : False()); process->Set(String::NewSymbol("cov"), cov ? True() : False());
process->Set(String::NewSymbol("useUV"), use_uv ? True() : False());
// -e, --eval // -e, --eval
if (eval_string) { if (eval_string) {
@ -2225,6 +2238,7 @@ static void PrintHelp() {
" --vars print various compiled-in variables\n" " --vars print various compiled-in variables\n"
" --max-stack-size=val set max v8 stack size (bytes)\n" " --max-stack-size=val set max v8 stack size (bytes)\n"
" --cov code coverage; writes node-cov.json \n" " --cov code coverage; writes node-cov.json \n"
" --use-uv use the libuv backend\n"
"\n" "\n"
"Enviromental variables:\n" "Enviromental variables:\n"
"NODE_PATH ':'-separated list of directories\n" "NODE_PATH ':'-separated list of directories\n"
@ -2250,6 +2264,9 @@ static void ParseArgs(int argc, char **argv) {
} else if (!strcmp(arg, "--cov")) { } else if (!strcmp(arg, "--cov")) {
cov = true; cov = true;
argv[i] = const_cast<char*>(""); argv[i] = const_cast<char*>("");
} else if (!strcmp(arg, "--use-uv")) {
use_uv = true;
argv[i] = const_cast<char*>("");
} else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) { } else if (strcmp(arg, "--version") == 0 || strcmp(arg, "-v") == 0) {
printf("%s\n", NODE_VERSION); printf("%s\n", NODE_VERSION);
exit(0); exit(0);

17
src/node.js

@ -387,7 +387,19 @@
var Script = process.binding('evals').NodeScript; var Script = process.binding('evals').NodeScript;
var runInThisContext = Script.runInThisContext; var runInThisContext = Script.runInThisContext;
// A special hook to test the new platform layer. Use the command-line
// flag --use-uv to enable the libuv backend instead of the legacy
// backend.
function translateId(id) {
if (id == 'net') {
return process.useUV ? 'net_uv' : 'net_legacy';
} else {
return id;
}
}
function NativeModule(id) { function NativeModule(id) {
id = translateId(id);
this.filename = id + '.js'; this.filename = id + '.js';
this.id = id; this.id = id;
this.exports = {}; this.exports = {};
@ -398,6 +410,8 @@
NativeModule._cache = {}; NativeModule._cache = {};
NativeModule.require = function(id) { NativeModule.require = function(id) {
id = translateId(id);
if (id == 'native_module') { if (id == 'native_module') {
return NativeModule; return NativeModule;
} }
@ -420,14 +434,17 @@
}; };
NativeModule.getCached = function(id) { NativeModule.getCached = function(id) {
id = translateId(id);
return NativeModule._cache[id]; return NativeModule._cache[id];
} }
NativeModule.exists = function(id) { NativeModule.exists = function(id) {
id = translateId(id);
return (id in NativeModule._source); return (id in NativeModule._source);
} }
NativeModule.getSource = function(id) { NativeModule.getSource = function(id) {
id = translateId(id);
return NativeModule._source[id]; return NativeModule._source[id];
} }

Loading…
Cancel
Save