Do not use defineGetter in src/node.js for better crankshaft perf
See: https://groups.google.com/d/topic/nodejs/xJqpp1_s6is/discussion
This commit is contained in:
parent
e3925b741c
commit
2a05fe784d
74
src/node.js
74
src/node.js
@ -71,12 +71,9 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
startup.globalConsole = function() {
|
startup.globalConsole = function() {
|
||||||
global.__defineGetter__('console', function() {
|
global.console = NativeModule.require('console');
|
||||||
return NativeModule.require('console');
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
startup._lazyConstants = null;
|
startup._lazyConstants = null;
|
||||||
|
|
||||||
startup.lazyConstants = function() {
|
startup.lazyConstants = function() {
|
||||||
@ -126,32 +123,29 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
startup.processStdio = function() {
|
startup.processStdio = function() {
|
||||||
var stdout, stdin;
|
var binding = process.binding('stdio'),
|
||||||
|
net = NativeModule.require('net'),
|
||||||
|
fs = NativeModule.require('fs'),
|
||||||
|
tty = NativeModule.require('tty');
|
||||||
|
|
||||||
process.__defineGetter__('stdout', function() {
|
// process.stdout
|
||||||
if (stdout) return stdout;
|
|
||||||
|
|
||||||
var binding = process.binding('stdio'),
|
var fd = binding.stdoutFD;
|
||||||
net = NativeModule.require('net'),
|
|
||||||
fs = NativeModule.require('fs'),
|
|
||||||
tty = NativeModule.require('tty'),
|
|
||||||
fd = binding.stdoutFD;
|
|
||||||
|
|
||||||
if (binding.isatty(fd)) {
|
if (binding.isatty(fd)) {
|
||||||
stdout = new tty.WriteStream(fd);
|
process.stdout = new tty.WriteStream(fd);
|
||||||
} else if (binding.isStdoutBlocking()) {
|
} else if (binding.isStdoutBlocking()) {
|
||||||
stdout = new fs.WriteStream(null, {fd: fd});
|
process.stdout = new fs.WriteStream(null, {fd: fd});
|
||||||
} else {
|
} else {
|
||||||
stdout = new net.Stream(fd);
|
process.stdout = new net.Stream(fd);
|
||||||
// FIXME Should probably have an option in net.Stream to create a
|
// FIXME Should probably have an option in net.Stream to create a
|
||||||
// stream from an existing fd which is writable only. But for now
|
// stream from an existing fd which is writable only. But for now
|
||||||
// we'll just add this hack and set the `readable` member to false.
|
// we'll just add this hack and set the `readable` member to false.
|
||||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||||
stdout.readable = false;
|
process.stdout.readable = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdout;
|
// process.stderr
|
||||||
});
|
|
||||||
|
|
||||||
var events = NativeModule.require('events');
|
var events = NativeModule.require('events');
|
||||||
var stderr = process.stderr = new events.EventEmitter();
|
var stderr = process.stderr = new events.EventEmitter();
|
||||||
@ -160,26 +154,18 @@
|
|||||||
stderr.write = process.binding('stdio').writeError;
|
stderr.write = process.binding('stdio').writeError;
|
||||||
stderr.end = stderr.destroy = stderr.destroySoon = function() { };
|
stderr.end = stderr.destroy = stderr.destroySoon = function() { };
|
||||||
|
|
||||||
process.__defineGetter__('stdin', function() {
|
// process.stdin
|
||||||
if (stdin) return stdin;
|
|
||||||
|
|
||||||
var binding = process.binding('stdio'),
|
var fd = binding.openStdin();
|
||||||
net = NativeModule.require('net'),
|
|
||||||
fs = NativeModule.require('fs'),
|
|
||||||
tty = NativeModule.require('tty'),
|
|
||||||
fd = binding.openStdin();
|
|
||||||
|
|
||||||
if (binding.isatty(fd)) {
|
if (binding.isatty(fd)) {
|
||||||
stdin = new tty.ReadStream(fd);
|
process.stdin = new tty.ReadStream(fd);
|
||||||
} else if (binding.isStdinBlocking()) {
|
} else if (binding.isStdinBlocking()) {
|
||||||
stdin = new fs.ReadStream(null, {fd: fd});
|
process.stdin = new fs.ReadStream(null, {fd: fd});
|
||||||
} else {
|
} else {
|
||||||
stdin = new net.Stream(fd);
|
process.stdin = new net.Stream(fd);
|
||||||
stdin.readable = true;
|
process.stdin.readable = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return stdin;
|
|
||||||
});
|
|
||||||
|
|
||||||
process.openStdin = function() {
|
process.openStdin = function() {
|
||||||
process.stdin.resume();
|
process.stdin.resume();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user