Permalink
Browse files

Revert isolates support.

  • Loading branch information...
1 parent a9723df commit e0a8d8294deb7f5dc072ab4f7b9d9f578fcabc23 @bnoordhuis committed Feb 3, 2012
Showing with 413 additions and 2,256 deletions.
  1. +0 −6 configure
  2. +14 −50 lib/_debugger.js
  3. +4 −65 lib/child_process.js
  4. +0 −12 node.gyp
  5. +9 −10 src/cares_wrap.cc
  6. +4 −5 src/fs_event_wrap.cc
  7. +2 −3 src/handle_wrap.cc
  8. +0 −109 src/ngx-queue.h
  9. +129 −151 src/node.cc
  10. +0 −4 src/node.h
  11. +0 −32 src/node.js
  12. +33 −35 src/node_buffer.cc
  13. +1 −0 src/node_buffer.h
  14. +20 −27 src/node_crypto.cc
  15. +0 −4 src/node_extensions.h
  16. +25 −29 src/node_file.cc
  17. +51 −47 src/node_http_parser.cc
  18. +0 −15 src/node_internals.h
  19. +0 −815 src/node_isolate.cc
  20. +0 −185 src/node_isolate.h
  21. +29 −22 src/node_script.cc
  22. +10 −11 src/node_signal_watcher.cc
  23. +0 −48 src/node_vars.cc
  24. +0 −197 src/node_vars.h
  25. +3 −5 src/node_zlib.cc
  26. +4 −5 src/pipe_wrap.cc
  27. +3 −3 src/process_wrap.cc
  28. +18 −23 src/stream_wrap.cc
  29. +19 −23 src/tcp_wrap.cc
  30. +9 −10 src/timer_wrap.cc
  31. +3 −4 src/tty_wrap.cc
  32. +8 −9 src/udp_wrap.cc
  33. +0 −55 test/addons/shared-buffer/binding.cc
  34. +0 −8 test/addons/shared-buffer/binding.gyp
  35. +0 −19 test/addons/shared-buffer/test.js
  36. +1 −7 test/simple/test-child-process-fork.js
  37. +1 −5 test/simple/test-child-process-fork2.js
  38. +1 −5 test/simple/test-child-process-fork3.js
  39. +6 −13 test/simple/test-debugger-repl-utf8.js
  40. +6 −13 test/simple/test-debugger-repl.js
  41. +0 −68 test/simple/test-isolates-ping-pong.js
  42. +0 −60 test/simple/test-isolates0.js
  43. +0 −13 test/simple/test-isolates1.js
  44. +0 −13 test/simple/test-isolates2.js
  45. +0 −13 test/simple/test-isolates3.js
View
@@ -32,11 +32,6 @@ parser.add_option("--without-waf",
dest="without_waf",
help="Don\'t install node-waf")
-parser.add_option("--without-isolates",
- action="store_true",
- dest="without_isolates",
- help="Build without isolates (no threads, single loop) [Default: False]")
-
parser.add_option("--without-ssl",
action="store_true",
dest="without_ssl",
@@ -172,7 +167,6 @@ def target_arch():
def configure_node(o):
# TODO add gdb
- o['variables']['node_use_isolates'] = b(not options.without_isolates)
o['variables']['node_prefix'] = options.prefix if options.prefix else ''
o['variables']['node_use_dtrace'] = b(options.with_dtrace)
o['variables']['node_install_npm'] = b(not options.without_npm)
View
@@ -25,7 +25,7 @@ var util = require('util'),
vm = require('vm'),
repl = require('repl'),
inherits = util.inherits,
- fork = require('child_process').fork;
+ spawn = require('child_process').spawn;
exports.start = function(argv, stdin, stdout) {
argv || (argv = process.argv.slice(2));
@@ -39,7 +39,7 @@ exports.start = function(argv, stdin, stdout) {
stdin = stdin || process.openStdin();
stdout = stdout || process.stdout;
- var args = argv,
+ var args = ['--debug-brk'].concat(argv),
interface = new Interface(stdin, stdout, args);
stdin.resume();
@@ -169,8 +169,6 @@ function Client() {
this.scripts = {};
this.breakpoints = [];
- this.isolates = process.features.isolates;
-
// Note that 'Protocol' requires strings instead of Buffers.
socket.setEncoding('utf8');
socket.on('data', function(d) {
@@ -1597,51 +1595,20 @@ Interface.prototype.trySpawn = function(cb) {
}
}
- var client = self.client = new Client(),
- connectionAttempts = 0;
-
if (!this.child) {
- if (client.isolates) {
- this.child = fork(this.args.shift(), this.args, {
- thread: true,
- debug: function(d) {
- d.onmessage = function(event) {
- client._onResponse({
- headers: {},
- body: JSON.parse(event)
- });
- };
-
- // Monkey patch client to send requests directly to debugger
- client.req = function(req, cb) {
- req.type = 'request';
- cb.request_seq = req.seq = this.protocol.reqSeq++;
- this._reqCallbacks.push(cb);
-
- d.write(JSON.stringify(req));
- };
-
- client.emit('ready');
-
- client._onResponse({
- headers: { Type: 'connect' },
- body: {}
- });
- },
- debugBrk: true
- });
- this.child.kill = function() {
- self.error('isolate.kill is not implemented yet!');
- };
- } else {
- this.child = fork('--debug-brk', this.args);
- }
+ this.child = spawn(process.execPath, this.args);
+
+ this.child.stdout.on('data', this.childPrint.bind(this));
+ this.child.stderr.on('data', this.childPrint.bind(this));
}
this.pause();
+ var client = self.client = new Client(),
+ connectionAttempts = 0;
+
client.once('ready', function() {
- if (!client.isolates) self.stdout.write(' ok\n');
+ self.stdout.write(' ok\n');
// Restore breakpoints
breakpoints.forEach(function(bp) {
@@ -1689,14 +1656,11 @@ Interface.prototype.trySpawn = function(cb) {
function attemptConnect() {
++connectionAttempts;
self.stdout.write('.');
-
client.connect(port, host);
}
- if (!client.isolates) {
- setTimeout(function() {
- self.print('connecting..', true);
- attemptConnect();
- }, 50);
- }
+ setTimeout(function() {
+ self.print('connecting..', true);
+ attemptConnect();
+ }, 50);
};
View
@@ -209,11 +209,11 @@ exports.fork = function(modulePath /*, args, options*/) {
options.env.NODE_CHANNEL_FD = 42;
// stdin is the IPC channel.
- if (!options.thread) options.stdinStream = createPipe(true);
+ options.stdinStream = createPipe(true);
var child = spawn(process.execPath, args, options);
- if (!options.thread) setupChannel(child, options.stdinStream);
+ setupChannel(child, options.stdinStream);
return child;
};
@@ -370,7 +370,7 @@ var spawn = exports.spawn = function(file, args, options) {
envPairs.push(key + '=' + env[key]);
}
- var child = (options && options.thread) ? (new Isolate) : (new ChildProcess);
+ var child = new ChildProcess();
child.spawn({
file: file,
@@ -379,8 +379,7 @@ var spawn = exports.spawn = function(file, args, options) {
windowsVerbatimArguments: !!(options && options.windowsVerbatimArguments),
envPairs: envPairs,
customFds: options ? options.customFds : null,
- stdinStream: options ? options.stdinStream : null,
- options: options
+ stdinStream: options ? options.stdinStream : null
});
return child;
@@ -537,63 +536,3 @@ ChildProcess.prototype.kill = function(sig) {
// TODO: raise error if r == -1?
}
};
-
-
-// Lazy loaded.
-var isolates = null;
-
-
-function Isolate() {
- if (!process.features.isolates) {
- throw new Error('Compiled without isolates support.');
- }
-
- if (!isolates) {
- isolates = process.binding('isolates');
- }
-
- this._handle = null;
-}
-inherits(Isolate, EventEmitter); // maybe inherit from ChildProcess?
-
-
-Isolate.prototype.spawn = function(options) {
- var self = this;
-
- if (self._handle) throw new Error('Isolate already running.');
- self._handle = isolates.create(options.args, options.options);
- if (!self._handle) throw new Error('Cannot create isolate.');
-
- self._handle.onmessage = function(msg, recvHandle) {
- msg = JSON.parse('' + msg);
-
- // Update simultaneous accepts on Windows
- net._setSimultaneousAccepts(recvHandle);
-
- self.emit('message', msg, recvHandle);
- };
-
- self._handle.onexit = function() {
- self._handle = null;
- self.emit('exit');
- };
-};
-
-
-Isolate.prototype.kill = function(sig) {
- if (!this._handle) throw new Error('Isolate not running.');
- // ignore silently for now, need a way to signal the other thread
-};
-
-
-Isolate.prototype.send = function(msg, sendHandle) {
- if (typeof msg === 'undefined') throw new TypeError('Bad argument.');
- if (!this._handle) throw new Error('Isolate not running.');
- msg = JSON.stringify(msg);
- msg = new Buffer(msg);
-
- // Update simultaneous accepts on Windows
- net._setSimultaneousAccepts(sendHandle);
-
- return this._handle.send(msg, sendHandle);
-};
View
@@ -8,7 +8,6 @@
'node_use_dtrace': 'false',
'node_use_openssl%': 'true',
'node_use_system_openssl%': 'false',
- 'node_use_isolates%': 'true',
'library_files': [
'src/node.js',
'lib/_debugger.js',
@@ -73,9 +72,7 @@
'src/cares_wrap.cc',
'src/handle_wrap.cc',
'src/node.cc',
- 'src/node_vars.cc',
'src/node_buffer.cc',
- 'src/node_isolate.cc',
'src/node_constants.cc',
'src/node_extensions.cc',
'src/node_file.cc',
@@ -95,12 +92,9 @@
'src/v8_typed_array.cc',
'src/udp_wrap.cc',
# headers to make for a more pleasant IDE experience
- 'src/ngx-queue.h',
'src/handle_wrap.h',
'src/node.h',
- 'src/node_vars.h',
'src/node_buffer.h',
- 'src/node_isolate.h',
'src/node_constants.h',
'src/node_crypto.h',
'src/node_extensions.h',
@@ -133,12 +127,6 @@
],
'conditions': [
- [ 'node_use_isolates=="true"', {
- 'defines': [ 'HAVE_ISOLATES=1' ],
- }, {
- 'defines': [ 'HAVE_ISOLATES=0' ],
- }],
-
[ 'node_use_openssl=="true"', {
'defines': [ 'HAVE_OPENSSL=1' ],
'sources': [ 'src/node_crypto.cc' ],
View
@@ -22,7 +22,6 @@
#include <assert.h>
#include <node.h>
#include <req_wrap.h>
-#include <node_vars.h>
#include <uv.h>
#include <string.h>
@@ -49,11 +48,6 @@
#endif
-#include <node_vars.h>
-#define oncomplete_sym NODE_VAR(oncomplete_sym)
-#define ares_channel NODE_VAR(ares_channel)
-
-
namespace node {
namespace cares_wrap {
@@ -75,6 +69,11 @@ using v8::Value;
typedef class ReqWrap<uv_getaddrinfo_t> GetAddrInfoReqWrap;
+static Persistent<String> oncomplete_sym;
+
+static ares_channel ares_channel;
+
+
static Local<Array> HostentToAddresses(struct hostent* host) {
HandleScope scope;
Local<Array> addresses = Array::New();
@@ -608,7 +607,7 @@ void AfterGetAddrInfo(uv_getaddrinfo_t* req, int status, struct addrinfo* res) {
if (status) {
// Error
- SetErrno(uv_last_error(Loop()));
+ SetErrno(uv_last_error(uv_default_loop()));
argv[0] = Local<Value>::New(Null());
} else {
// Success
@@ -711,7 +710,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
hints.ai_family = fam;
hints.ai_socktype = SOCK_STREAM;
- int r = uv_getaddrinfo(Loop(),
+ int r = uv_getaddrinfo(uv_default_loop(),
&req_wrap->req_,
AfterGetAddrInfo,
*hostname,
@@ -720,7 +719,7 @@ static Handle<Value> GetAddrInfo(const Arguments& args) {
req_wrap->Dispatched();
if (r) {
- SetErrno(uv_last_error(Loop()));
+ SetErrno(uv_last_error(uv_default_loop()));
delete req_wrap;
return scope.Close(v8::Null());
} else {
@@ -737,7 +736,7 @@ static void Initialize(Handle<Object> target) {
assert(r == ARES_SUCCESS);
struct ares_options options;
- uv_ares_init_options(Loop(), &ares_channel, &options, 0);
+ uv_ares_init_options(uv_default_loop(), &ares_channel, &options, 0);
assert(r == 0);
NODE_SET_METHOD(target, "queryA", Query<QueryAWrap>);
View
@@ -21,7 +21,6 @@
#include <node.h>
#include <handle_wrap.h>
-#include <node_vars.h>
#include <stdlib.h>
@@ -110,15 +109,15 @@ Handle<Value> FSEventWrap::Start(const Arguments& args) {
String::Utf8Value path(args[0]->ToString());
- int r = uv_fs_event_init(Loop(), &wrap->handle_, *path, OnEvent, 0);
+ int r = uv_fs_event_init(uv_default_loop(), &wrap->handle_, *path, OnEvent, 0);
if (r == 0) {
// Check for persistent argument
if (!args[1]->IsTrue()) {
- uv_unref(Loop());
+ uv_unref(uv_default_loop());
}
wrap->initialized_ = true;
} else {
- SetErrno(uv_last_error(Loop()));
+ SetErrno(uv_last_error(uv_default_loop()));
}
return scope.Close(Integer::New(r));
@@ -146,7 +145,7 @@ void FSEventWrap::OnEvent(uv_fs_event_t* handle, const char* filename,
// assumption that a rename implicitly means an attribute change. Not too
// unreasonable, right? Still, we should revisit this before v1.0.
if (status) {
- SetErrno(uv_last_error(Loop()));
+ SetErrno(uv_last_error(uv_default_loop()));
eventStr = String::Empty();
}
else if (events & UV_RENAME) {
View
@@ -21,7 +21,6 @@
#include <node.h>
#include <handle_wrap.h>
-#include <node_vars.h>
namespace node {
@@ -71,7 +70,7 @@ Handle<Value> HandleWrap::Unref(const Arguments& args) {
}
wrap->unref = true;
- uv_unref(Loop());
+ uv_unref(uv_default_loop());
return v8::Undefined();
}
@@ -89,7 +88,7 @@ Handle<Value> HandleWrap::Ref(const Arguments& args) {
}
wrap->unref = false;
- uv_ref(Loop());
+ uv_ref(uv_default_loop());
return v8::Undefined();
}
Oops, something went wrong.

0 comments on commit e0a8d82

Please sign in to comment.