From 7811fa6fec8e5b24620002b8f637e461176a7c6f Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 17 Feb 2010 17:07:08 -0800 Subject: [PATCH 01/46] Update example on index.html --- doc/index.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/index.html b/doc/index.html index 22ac939f3a..ba94ffac67 100644 --- a/doc/index.html +++ b/doc/index.html @@ -76,10 +76,10 @@ var server = tcp.createServer(function (socket) { socket.addListener("connect", function () { socket.write("hello\r\n"); }); - socket.addListener("receive", function (data) { + socket.addListener("data", function (data) { socket.write(data); }); - socket.addListener("eof", function () { + socket.addListener("end", function () { socket.write("goodbye\r\n"); socket.close(); }); From 4f01c74e9f8cb9850ec48462809bc9ff3cbdcb1c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 17 Feb 2010 18:41:46 -0800 Subject: [PATCH 02/46] Fix long lines in docs --- doc/api.txt | 75 ++++++++++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 29 deletions(-) diff --git a/doc/api.txt b/doc/api.txt index 45bdcc147a..93bb67196a 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -344,7 +344,8 @@ will already have thrown an exception: var promise = computeQuestion(23); setTimeout(function() { promise.addErrback(function() { - // This will never execute, the promise already threw an exception + // This will never execute, + // the promise already threw an exception }); }, 1000); ---------------------------------------- @@ -416,7 +417,8 @@ The contents of +foo.js+: ---------------------------------------- var circle = require("./circle"), var sys = require("sys"); -sys.puts("The area of a circle of radius 4 is " + circle.area(4)); +sys.puts( "The area of a circle of radius 4 is " + + circle.area(4)); ---------------------------------------- The contents of +circle.js+: @@ -635,12 +637,22 @@ fs.rename("/tmp/hello", "/tmp/world").addCallback(function () { See stat(2). - on success: Returns +fs.Stats+ object. It looks like this: + ------------------------------------------------------------------------------- - { dev: 2049, ino: 305352, mode: 16877, nlink: 12, uid: 1000, gid: 1000, - rdev: 0, size: 4096, blksize: 4096, blocks: 8, atime: - "2009-06-29T11:11:55Z", mtime: "2009-06-29T11:11:40Z", ctime: - "2009-06-29T11:11:40Z" }+ ------------------------------------------------------------------------------- +--------------------------------- +{ dev: 2049 +, ino: 305352 +, mode: 16877 +, nlink: 12 +, uid: 1000 +, gid: 1000 +, rdev: 0 +, size: 4096 +, blksize: 4096 +, blocks: 8 +, atime: "2009-06-29T11:11:55Z" +, mtime: "2009-06-29T11:11:40Z" +, ctime: "2009-06-29T11:11:40Z" +} +---------------------------------- + See the +fs.Stats+ section below for more information. @@ -1659,7 +1671,9 @@ node> require("path").join("/foo", "bar", "baz/asdf", "quux", "..") Normalize an array of path parts, taking care of +".."+ and +"."+ parts. Example: + ------------------------------------ -node> require("path").normalizeArray(["", "foo", "bar", "baz", "asdf", "quux", ".."]) +path.normalizeArray(["", + "foo", "bar", "baz", "asdf", "quux", ".."]) +// returns [ "", "foo", @@ -1674,7 +1688,8 @@ node> require("path").normalizeArray(["", "foo", "bar", "baz", "asdf", "quux", " Normalize a string path, taking care of +".."+ and +"."+ parts. Example: + ------------------------------------ -node> require("path").normalize("/foo/bar/baz/asdf/quux/..") +path.normalize("/foo/bar/baz/asdf/quux/..") +// returns "/foo/bar/baz/asdf" ------------------------------------ + @@ -1683,7 +1698,8 @@ node> require("path").normalize("/foo/bar/baz/asdf/quux/..") Return the directory name of a path. Similar to the Unix +dirname+ command. Example: + ------------------------------------ -node> require("path").dirname("/foo/bar/baz/asdf/quux") +path.dirname("/foo/bar/baz/asdf/quux") +// returns "/foo/bar/baz/asdf" ------------------------------------ + @@ -1692,9 +1708,12 @@ node> require("path").dirname("/foo/bar/baz/asdf/quux") Return the last portion of a path. Similar to the Unix +basename+ command. Example: + ------------------------------------ -node> require("path").basename("/foo/bar/baz/asdf/quux.html") +path.basename("/foo/bar/baz/asdf/quux.html") +// returns "quux.html" -node> require("path").basename("/foo/bar/baz/asdf/quux.html", ".html") + +path.basename("/foo/bar/baz/asdf/quux.html", ".html") +// returns "quux" ------------------------------------ + @@ -1704,9 +1723,12 @@ Return the extension of the path. Everything after the last '.', if there is no '.' then it returns an empty string. Examples: + ------------------------------------ -node> require("path").extname("index.html") +path.extname("index.html") +// returns ".html" -node> require("path").extname("index") + +path.extname("index") +// returns "" ------------------------------------ + @@ -1715,8 +1737,8 @@ node> require("path").extname("index") Test whether or not the given path exists. Then, call the +callback+ argument with either true or false. Example: + ------------------------------------ -require("path").exists("/etc/passwd", function (exists) { - require("sys").debug( exists ? "it's there" : "no passwd!" ); +path.exists("/etc/passwd", function (exists) { + sys.debug(exists ? "it's there" : "no passwd!"); }); ------------------------------------ @@ -1785,8 +1807,9 @@ Serialize an object to a query string. Optionally override the default separato Example: + ------------------------------------ -node> require("querystring").stringify({foo:"bar", baz : {quux:"asdf", oof : "rab"}, boo:[1,2,3]}) -"foo=bar&baz%5Bquux%5D=asdf&baz%5Boof%5D=rab&boo%5B%5D=1&boo%5B%5D=2&boo%5B%5D=3" +querystring.stringify({foo: 'bar'}) +// returns +"foo=bar" ------------------------------------ + @@ -1794,16 +1817,10 @@ node> require("querystring").stringify({foo:"bar", baz : {quux:"asdf", oof : "ra Deserialize a query string to an object. Optionally override the default separator and assignment characters. + ------------------------------------ -node> require("querystring").parse("foo=bar&baz%5Bquux%5D=asdf&baz%5Boof%5D=rab&boo%5B%5D=1") -{ - "foo": "bar", - "baz": { - "quux": "asdf", - "oof": "rab" - }, - "boo": [ - 1 - ] +querystring.parse('a=b&b=c') +// returns +{ 'a': 'b' +, 'b': 'c' } ------------------------------------ + From c2e58c9dee39accb16d2edd12a1f35394b967d4c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 17 Feb 2010 21:28:31 -0800 Subject: [PATCH 03/46] Remove a few wait() calls in the tests --- test/mjsunit/test-fs-write.js | 2 +- test/mjsunit/test-http-tls.js | 6 +++--- test/mjsunit/test-tcp-tls.js | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/mjsunit/test-fs-write.js b/test/mjsunit/test-fs-write.js index 198c932b0d..0211a82b3c 100644 --- a/test/mjsunit/test-fs-write.js +++ b/test/mjsunit/test-fs-write.js @@ -9,7 +9,7 @@ fs.open(fn, 'w', 0644).addCallback(function (file) { fs.close(file).addCallback(function() { fs.readFile(fn, process.UTF8).addCallback(function(contents) { found = contents; - fs.unlink(fn).wait(); + fs.unlinkSync(fn); }); }); }); diff --git a/test/mjsunit/test-http-tls.js b/test/mjsunit/test-http-tls.js index 2e5e4e84e1..da4ae18543 100644 --- a/test/mjsunit/test-http-tls.js +++ b/test/mjsunit/test-http-tls.js @@ -21,9 +21,9 @@ var responses_sent = 0; var responses_recvd = 0; var body0 = ""; var body1 = ""; -var caPem = fs.readFile(fixturesDir+"/test_ca.pem").wait(); -var certPem = fs.readFile(fixturesDir+"/test_cert.pem").wait(); -var keyPem = fs.readFile(fixturesDir+"/test_key.pem").wait(); +var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem"); +var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem"); +var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem"); var http_server=http.createServer(function (req, res) { diff --git a/test/mjsunit/test-tcp-tls.js b/test/mjsunit/test-tcp-tls.js index 80f85d33b0..060ca3349b 100644 --- a/test/mjsunit/test-tcp-tls.js +++ b/test/mjsunit/test-tcp-tls.js @@ -105,9 +105,9 @@ try { } if (have_tls) { - var caPem = fs.readFile(fixturesDir+"/test_ca.pem").wait(); - var certPem = fs.readFile(fixturesDir+"/test_cert.pem").wait(); - var keyPem = fs.readFile(fixturesDir+"/test_key.pem").wait(); + var caPem = fs.readFileSync(fixturesDir+"/test_ca.pem"); + var certPem = fs.readFileSync(fixturesDir+"/test_cert.pem"); + var keyPem = fs.readFileSync(fixturesDir+"/test_key.pem"); /* All are run at once, so run on different ports */ tlsTest(20443, "localhost", caPem, keyPem, certPem); From cb32883537bc7c499d08d57d005a6261ddb3cfd3 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Wed, 17 Feb 2010 22:43:28 -0800 Subject: [PATCH 04/46] Add authors file --- AUTHORS | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 AUTHORS diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000000..34df1a6356 --- /dev/null +++ b/AUTHORS @@ -0,0 +1,51 @@ +# Authors ordered by first contribution. + +Ryan Dahl +Urban Hafner +Joshaven Potter +Abe Fettig +Kevin van Zonneveld +Michael Carter +Jeff Smick +Jon Crosby +Felix Geisendörfer +Ray Morgan +Jérémy Lal +Isaac Z. Schlueter +Brandon Beacher +Connor Dunn +Johan Sørensen +Friedemann Altrock +Onne Gorter +Rhys Jones +Jan Lehnardt +Simon Willison +Chew Choon Keat +Jed Schmidt +Michaeljohn Clement +Karl Guertin +Xavier Shay +Christopher Lenz +TJ Holowaychuk +Johan Dahlberg +Simon Cornelius P. Umacob +Ryan McGrath +Rasmus Andersson +Micheil Smith +Jonas Pfenniger +Charles Lehner +Elliott Cable +Benjamin Thomas +Vanilla Hsu +Ben Williamson +Joseph Pecoraro +Alexis Sellier +Blaine Cook +Standa Opichal +Aaron Heckmann +Mikeal Rogers +Matt Brubeck +Michael Stillwell +Yuichiro MASUI +Mark Hansen +Zoran Tomicic From bcc032e43aac86d71739150009d8d75b5a9de26f Mon Sep 17 00:00:00 2001 From: Micheil Smith Date: Thu, 18 Feb 2010 19:02:55 +1100 Subject: [PATCH 05/46] Adding interface between node and libeio for Chmod. --- doc/api.txt | 6 +++++- src/node.js | 11 +++++++++++ src/node_file.cc | 25 +++++++++++++++++++++++++ test/mjsunit/test-fs-chmod.js | 27 +++++++++++++++++++++++++++ 4 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/mjsunit/test-fs-chmod.js diff --git a/doc/api.txt b/doc/api.txt index 93bb67196a..a3e5082254 100644 --- a/doc/api.txt +++ b/doc/api.txt @@ -632,7 +632,11 @@ fs.rename("/tmp/hello", "/tmp/world").addCallback(function () { - on success: no parameters. - on error: no parameters. - ++fs.chmod(path, mode)+ :: + See chmod(1) + - on success: no parameters. + - on error: no parameters. + +fs.stat(path)+ :: See stat(2). - on success: Returns +fs.Stats+ object. It looks like this: diff --git a/src/node.js b/src/node.js index 302790f41d..4506bd8eaa 100644 --- a/src/node.js +++ b/src/node.js @@ -769,6 +769,17 @@ var fsModule = createInternalModule("fs", function (exports) { return content; }; + + exports.chmod = function(path, mode){ + var promise = new events.Promise(); + process.fs.chmod(path, mode, callback(promise)); + return promise; + }; + + exports.chmodSync = function(path, mode){ + return process.fs.chmod(path, mode); + }; + }); var fs = fsModule.exports; diff --git a/src/node_file.cc b/src/node_file.cc index 16f404591e..adc0057dd9 100644 --- a/src/node_file.cc +++ b/src/node_file.cc @@ -54,6 +54,7 @@ static int After(eio_req *req) { case EIO_RMDIR: case EIO_MKDIR: case EIO_FTRUNCATE: + case EIO_CHMOD: argc = 0; break; @@ -428,6 +429,28 @@ static Handle Read(const Arguments& args) { } } +/* node.fs.chmod(fd, mode); + * Wrapper for chmod(1) / EIO_CHMOD + */ +static Handle Chmod(const Arguments& args){ + HandleScope scope; + + if(args.Length() < 2 || !args[0]->IsString() || !args[1]->IsInt32()) { + return THROW_BAD_ARGS; + } + String::Utf8Value path(args[0]->ToString()); + mode_t mode = static_cast(args[1]->Int32Value()); + + if(args[2]->IsFunction()) { + ASYNC_CALL(chmod, args[2], *path, mode); + } else { + int ret = chmod(*path, mode); + if (ret != 0) return ThrowException(errno_exception(errno)); + return Undefined(); + } +} + + void File::Initialize(Handle target) { HandleScope scope; @@ -443,6 +466,8 @@ void File::Initialize(Handle target) { NODE_SET_METHOD(target, "stat", Stat); NODE_SET_METHOD(target, "unlink", Unlink); NODE_SET_METHOD(target, "write", Write); + + NODE_SET_METHOD(target, "chmod", Chmod); errno_symbol = NODE_PSYMBOL("errno"); encoding_symbol = NODE_PSYMBOL("node:encoding"); diff --git a/test/mjsunit/test-fs-chmod.js b/test/mjsunit/test-fs-chmod.js new file mode 100644 index 0000000000..e4a012c5b8 --- /dev/null +++ b/test/mjsunit/test-fs-chmod.js @@ -0,0 +1,27 @@ +process.mixin(require("./common")); + +var got_error = false; +var success_count = 0; + +var __file = path.join(fixturesDir, "a.js"); + +var promise = fs.chmod(__file, 0777); + +promise.addCallback(function () { + puts(fs.statSync(__file).mode); + assert.equal("777", (fs.statSync(__file).mode & 0777).toString(8)); + + fs.chmodSync(__file, 0644); + assert.equal("644", (fs.statSync(__file).mode & 0777).toString(8)); + success_count++; +}); + +promise.addErrback(function () { + got_error = true; +}); + +process.addListener("exit", function () { + assert.equal(1, success_count); + assert.equal(false, got_error); +}); + From 3bb7ad6fea42545e9d84ba5cbef8b48e470790fc Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Thu, 18 Feb 2010 17:50:48 +0100 Subject: [PATCH 06/46] fixed process.mixin to properly copy getters/setters --- src/node.js | 45 +++++++++++++++++------------- test/mjsunit/test-process-mixin.js | 17 ++++++++++- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/node.js b/src/node.js index 4506bd8eaa..0d3da4c8e0 100644 --- a/src/node.js +++ b/src/node.js @@ -105,9 +105,10 @@ process.assert = function (x, msg) { // Copyright (c) 2009 John Resig // Dual licensed under the MIT and GPL licenses. // http://docs.jquery.com/License +// Modified for node.js (formely for copying properties correctly) process.mixin = function() { // copy reference to target object - var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, options; + var target = arguments[0] || {}, i = 1, length = arguments.length, deep = false, source; // Handle a deep copy situation if ( typeof target === "boolean" ) { @@ -129,27 +130,31 @@ process.mixin = function() { for ( ; i < length; i++ ) { // Only deal with non-null/undefined values - if ( (options = arguments[ i ]) != null ) { + if ( (source = arguments[i]) != null ) { // Extend the base object - for ( var name in options ) { - var src = target[ name ], copy = options[ name ]; - - // Prevent never-ending loop - if ( target === copy ) - continue; - - // Recurse if we're merging object values - if ( deep && copy && typeof copy === "object" ) { - target[ name ] = process.mixin( deep, - // Never move original objects, clone them - src || ( copy.length != null ? [ ] : { } ) - , copy ); - - // Don't bring in undefined values - } else { - target[ name ] = copy; + Object.getOwnPropertyNames(source).forEach(function(k){ + var d = Object.getOwnPropertyDescriptor(source, k); + if (d.get) { + target.__defineGetter__(k, d.get); + if (d.set) + target.__defineSetter__(k, d.set); } - } + else { + // Prevent never-ending loop + if (target === d.value) + continue; + + if (deep && d.value && typeof d.value === "object") { + target[k] = process.mixin(deep, + // Never move original objects, clone them + source || (d.value.length != null ? [] : {}) + , d.value); + } + else { + target[k] = d.value; + } + } + }); } } // Return the modified object diff --git a/test/mjsunit/test-process-mixin.js b/test/mjsunit/test-process-mixin.js index f3578251a2..502c229b35 100644 --- a/test/mjsunit/test-process-mixin.js +++ b/test/mjsunit/test-process-mixin.js @@ -19,4 +19,19 @@ var objectWithUndefinedValue = {foo: undefined}; target = {}; process.mixin(target, objectWithUndefinedValue); -assert.ok(target.hasOwnProperty('foo')); \ No newline at end of file +assert.ok(target.hasOwnProperty('foo')); + +// This test verifies getters and setters being copied correctly + +var source = { + _foo:'a', + get foo(){ return this._foo; }, + set foo(value){ this._foo = "did set to "+value; } +}; +var target = {}; +process.mixin(target, source); +target._foo = 'b'; +assert.equal(source.foo, 'a'); +assert.equal('b', target.foo, 'target.foo != "b" -- value/result was copied instead of getter function'); +source.foo = 'c'; +assert.equal('did set to c', source.foo, 'source.foo != "c" -- value was set instead of calling setter function'); From c5de1b635036236a11ce74acf10fe977acfc9503 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 18 Feb 2010 10:17:03 -0800 Subject: [PATCH 07/46] fix email in AUTHORS --- AUTHORS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 34df1a6356..2ee868c784 100644 --- a/AUTHORS +++ b/AUTHORS @@ -31,7 +31,7 @@ Johan Dahlberg Simon Cornelius P. Umacob Ryan McGrath Rasmus Andersson -Micheil Smith +Micheil Smith Jonas Pfenniger Charles Lehner Elliott Cable From ca02b4f5860ad3e0a8ac70ab51e089f5a374ec3d Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 18 Feb 2010 11:38:49 -0800 Subject: [PATCH 08/46] Fix AUTHORS again I hope I won't spend all my time now maintaining this file... --- AUTHORS | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index 2ee868c784..e50a1382ee 100644 --- a/AUTHORS +++ b/AUTHORS @@ -11,8 +11,9 @@ Jon Crosby Felix Geisendörfer Ray Morgan Jérémy Lal -Isaac Z. Schlueter +Isaac Z. Schlueter Brandon Beacher +Tim Caswell Connor Dunn Johan Sørensen Friedemann Altrock @@ -39,6 +40,7 @@ Benjamin Thomas Vanilla Hsu Ben Williamson Joseph Pecoraro +Erich Ocean Alexis Sellier Blaine Cook Standa Opichal From 860d008d5418cecd48c25369f2f8709a1f7ffb5c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 19 Feb 2010 09:37:20 -0800 Subject: [PATCH 09/46] Truly synchronous require() This is to reduce our dependency on wait(). For some reason this patch affects the timer test: % ./node test/mjsunit/test-timers.js diff: 989 diff: 989 diff: 1989 diff: 2989 Previously it showed: % ./node test/mjsunit/test-timers.js diff: 1000 diff: 1000 diff: 2000 diff: 3000 I'm not sure what caused this change, and it's rather disturbing. However I want to remove wait() as soon as possible and so am pushing this patch through. The module loading code is becoming increasingly ugly - this patch has not helped. A refactor needs to be done soon. --- src/node.js | 199 ++++++++++++++++----- test/mjsunit/test-remote-module-loading.js | 10 +- 2 files changed, 156 insertions(+), 53 deletions(-) diff --git a/src/node.js b/src/node.js index 0d3da4c8e0..17a994020f 100644 --- a/src/node.js +++ b/src/node.js @@ -857,6 +857,16 @@ var pathModule = createInternalModule("path", function (exports) { var path = pathModule.exports; +function existsSync (path) { + try { + fs.statSync(path); + return true; + } catch (e) { + return false; + } +} + + process.paths = [ path.join(process.installPrefix, "lib/node/libraries") ]; @@ -870,11 +880,16 @@ if (process.env["NODE_PATH"]) { } +/* Sync unless callback given */ function findModulePath (id, dirs, callback) { process.assert(dirs.constructor == Array); if (/^https?:\/\//.exec(id)) { - callback(id); + if (callback) { + callback(id); + } else { + throw new Error("Sync http require not allowed."); + } return; } @@ -883,8 +898,11 @@ function findModulePath (id, dirs, callback) { } if (dirs.length == 0) { - callback(); - return; + if (callback) { + callback(); + } else { + return; // sync returns null + } } var dir = dirs[0]; @@ -902,26 +920,37 @@ function findModulePath (id, dirs, callback) { path.join(dir, id, "index.addon") ]; - var searchLocations = function() { + function searchLocations () { var location = locations.shift(); - if (location === undefined) { - findModulePath(id, rest, callback); - return; + if (!location) { + return findModulePath(id, rest, callback); } - path.exists(location, function (found) { - if (found) { - callback(location); - return; + // if async + if (callback) { + path.exists(location, function (found) { + if (found) { + callback(location); + } else { + return searchLocations(); + } + }) + + // if sync + } else { + if (existsSync(location)) { + return location; + } else { + return searchLocations(); } - searchLocations(); - }); - }; - searchLocations(); + } + } + return searchLocations(); } -function resolveModulePath(request, parent) { +// sync - no i/o performed +function resolveModulePath(request, parent) { var id, paths; if (request.charAt(0) == "." && (request.charAt(1) == "/" || request.charAt(1) == ".")) { // Relative request @@ -939,6 +968,33 @@ function resolveModulePath(request, parent) { return [id, paths]; } + +function loadModuleSync (request, parent) { + var resolvedModule = resolveModulePath(request, parent); + var id = resolvedModule[0]; + var paths = resolvedModule[1]; + + debug("loadModuleSync REQUEST " + (request) + " parent: " + parent.id); + + var cachedModule = internalModuleCache[id] || parent.moduleCache[id]; + + if (cachedModule) { + debug("found " + JSON.stringify(id) + " in cache"); + return cachedModule.exports; + } else { + debug("looking for " + JSON.stringify(id) + " in " + JSON.stringify(paths)); + var filename = findModulePath(request, paths); + if (!filename) { + throw new Error("Cannot find module '" + request + "'"); + } else { + var module = new Module(id, parent); + module.loadSync(filename); + return module.exports; + } + } +} + + function loadModule (request, parent) { var // The promise returned from require.async() @@ -947,7 +1003,7 @@ function loadModule (request, parent) { id = resolvedModule[0], paths = resolvedModule[1]; - // debug("loadModule REQUEST " + (request) + " parent: " + JSON.stringify(parent)); + debug("loadModule REQUEST " + (request) + " parent: " + parent.id); var cachedModule = internalModuleCache[id] || parent.moduleCache[id]; if (cachedModule) { @@ -971,6 +1027,21 @@ function loadModule (request, parent) { return loadPromise; }; + +Module.prototype.loadSync = function (filename) { + debug("loadSync " + JSON.stringify(filename) + " for module " + JSON.stringify(this.id)); + + process.assert(!this.loaded); + this.filename = filename; + + if (filename.match(/\.node$/)) { + this._loadObjectSync(filename); + } else { + this._loadScriptSync(filename); + } +}; + + Module.prototype.load = function (filename, loadPromise) { debug("load " + JSON.stringify(filename) + " for module " + JSON.stringify(this.id)); @@ -981,13 +1052,20 @@ Module.prototype.load = function (filename, loadPromise) { this.filename = filename; if (filename.match(/\.node$/)) { - this.loadObject(filename, loadPromise); + this._loadObject(filename, loadPromise); } else { - this.loadScript(filename, loadPromise); + this._loadScript(filename, loadPromise); } }; -Module.prototype.loadObject = function (filename, loadPromise) { + +Module.prototype._loadObjectSync = function (filename) { + this.loaded = true; + process.dlopen(filename, this.exports); +}; + + +Module.prototype._loadObject = function (filename, loadPromise) { var self = this; // XXX Not yet supporting loading from HTTP. would need to download the // file, store it to tmp then run dlopen on it. @@ -998,11 +1076,10 @@ Module.prototype.loadObject = function (filename, loadPromise) { }); }; + function cat (id, loadPromise) { var promise; - debug(id); - if (id.match(/^http:\/\//)) { promise = new events.Promise(); loadModule('http', process.mainModule) @@ -1025,7 +1102,52 @@ function cat (id, loadPromise) { return promise; } -Module.prototype.loadScript = function (filename, loadPromise) { + +Module.prototype._loadContent = function (content, filename) { + var self = this; + // remove shebang + content = content.replace(/^\#\!.*/, ''); + + function requireAsync (url) { + return loadModule(url, self); // new child + } + + function require (path) { + return loadModuleSync(path, self); + } + + require.paths = process.paths; + require.async = requireAsync; + require.main = process.mainModule; + // create wrapper function + var wrapper = "(function (exports, require, module, __filename, __dirname) { " + + content + + "\n});"; + + try { + var compiledWrapper = process.compile(wrapper, filename); + compiledWrapper.apply(self.exports, [self.exports, require, self, filename, path.dirname(filename)]); + } catch (e) { + return e; + } +}; + + +Module.prototype._loadScriptSync = function (filename) { + var content = fs.readFileSync(filename); + // remove shebang + content = content.replace(/^\#\!.*/, ''); + + var e = this._loadContent(content, filename); + if (e) { + throw e; + } else { + this.loaded = true; + } +}; + + +Module.prototype._loadScript = function (filename, loadPromise) { var self = this; var catPromise = cat(filename, loadPromise); @@ -1034,41 +1156,20 @@ Module.prototype.loadScript = function (filename, loadPromise) { }); catPromise.addCallback(function (content) { - // remove shebang - content = content.replace(/^\#\!.*/, ''); - - function requireAsync (url) { - return loadModule(url, self); // new child - } - - function require (url) { - return requireAsync(url).wait(); - } - - require.paths = process.paths; - require.async = requireAsync; - require.main = process.mainModule; - // create wrapper function - var wrapper = "(function (exports, require, module, __filename, __dirname) { " - + content - + "\n});"; - - try { - var compiledWrapper = process.compile(wrapper, filename); - compiledWrapper.apply(self.exports, [self.exports, require, self, filename, path.dirname(filename)]); - } catch (e) { + var e = self._loadContent(content, filename); + if (e) { loadPromise.emitError(e); return; } - - self.waitChildrenLoad(function () { + self._waitChildrenLoad(function () { self.loaded = true; loadPromise.emitSuccess(self.exports); }); }); }; -Module.prototype.waitChildrenLoad = function (callback) { + +Module.prototype._waitChildrenLoad = function (callback) { var nloaded = 0; var children = this.children; for (var i = 0; i < children.length; i++) { diff --git a/test/mjsunit/test-remote-module-loading.js b/test/mjsunit/test-remote-module-loading.js index 2978f72add..6f6f82e080 100644 --- a/test/mjsunit/test-remote-module-loading.js +++ b/test/mjsunit/test-remote-module-loading.js @@ -17,9 +17,11 @@ var server = http.createServer(function(req, res) { }); server.listen(PORT); -var httpModule = require('http://localhost:'+PORT+'/moduleA.js'); -assert.equal('/moduleA.js', httpModule.httpPath()); -modulesLoaded++; +assert.throws(function () { + var httpModule = require('http://localhost:'+PORT+'/moduleA.js'); + assert.equal('/moduleA.js', httpModule.httpPath()); + modulesLoaded++; +}); var nodeBinary = process.ARGV[0]; var cmd = 'NODE_PATH='+libDir+' '+nodeBinary+' http://localhost:'+PORT+'/moduleB.js'; @@ -35,5 +37,5 @@ sys }); process.addListener('exit', function() { - assert.equal(2, modulesLoaded); + assert.equal(1, modulesLoaded); }); From 764783560ed8d2cd523e715567938f2c3afbb8d0 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 19 Feb 2010 10:16:02 -0800 Subject: [PATCH 10/46] Remove Promise.prototype.wait() I don't want users to have to think about coroutine safety. http://thread.gmane.org/gmane.comp.lang.javascript.nodejs/2468/focus=2603 --- src/node.js | 66 ------------- test/mjsunit/{ => disabled}/test-eio-race3.js | 5 +- test/mjsunit/test-promise-timeout.js | 11 +-- test/mjsunit/test-promise-wait.js | 98 ------------------- test/mjsunit/test-wait-ordering.js | 32 ------ 5 files changed, 5 insertions(+), 207 deletions(-) rename test/mjsunit/{ => disabled}/test-eio-race3.js (78%) delete mode 100644 test/mjsunit/test-promise-wait.js delete mode 100644 test/mjsunit/test-wait-ordering.js diff --git a/src/node.js b/src/node.js index 17a994020f..49ad8e97a1 100644 --- a/src/node.js +++ b/src/node.js @@ -281,72 +281,6 @@ var eventsModule = createInternalModule('events', function (exports) { return this.addListener("error", listener); }; - - /* Poor Man's coroutines */ - var coroutineStack = []; - - exports.Promise.prototype._destack = function () { - this._blocking = false; - - while (coroutineStack.length > 0 && - !coroutineStack[coroutineStack.length-1]._blocking) - { - coroutineStack.pop(); - process.unloop("one"); - } - }; - - exports.Promise.prototype.wait = function () { - var self = this; - var ret; - var hadError = false; - - if (this.hasFired) { - ret = (this._values.length == 1) - ? this._values[0] - : this.values; - - if (this.hasFired == 'success') { - return ret; - } else if (this.hasFired == 'error') { - throw ret; - } - } - - self.addCallback(function () { - if (arguments.length == 1) { - ret = arguments[0]; - } else if (arguments.length > 1) { - ret = Array.prototype.slice.call(arguments); - } - self._destack(); - }); - - self.addErrback(function (arg) { - hadError = true; - ret = arg; - self._destack(); - }); - - coroutineStack.push(self); - if (coroutineStack.length > 10) { - process.stdio.writeError("WARNING: promise.wait() is being called too often.\n"); - } - self._blocking = true; - - process.loop(); - - process.assert(self._blocking == false); - - if (hadError) { - if (ret) { - throw ret; - } else { - throw new Error("Promise completed with error (No arguments given.)"); - } - } - return ret; - }; }); var events = eventsModule.exports; diff --git a/test/mjsunit/test-eio-race3.js b/test/mjsunit/disabled/test-eio-race3.js similarity index 78% rename from test/mjsunit/test-eio-race3.js rename to test/mjsunit/disabled/test-eio-race3.js index af4411c28b..bcfc6e095d 100644 --- a/test/mjsunit/test-eio-race3.js +++ b/test/mjsunit/disabled/test-eio-race3.js @@ -1,5 +1,8 @@ +/* XXX Can this test be modified to not call the now-removed wait()? */ + process.mixin(require("./common")); + puts('first stat ...'); fs.stat(__filename) @@ -13,4 +16,4 @@ fs.stat(__filename) }) .addErrback(function() { throw new Exception(); - }); \ No newline at end of file + }); diff --git a/test/mjsunit/test-promise-timeout.js b/test/mjsunit/test-promise-timeout.js index b0b2727048..dc66247941 100644 --- a/test/mjsunit/test-promise-timeout.js +++ b/test/mjsunit/test-promise-timeout.js @@ -21,15 +21,6 @@ setTimeout(function() { promise.emitSuccess('Am I too late?'); }, 500); -var waitPromise = new events.Promise(); -try { - waitPromise.timeout(250).wait() -} catch (e) { - assert.equal(true, e instanceof Error); - assert.equal('timeout', e.message); - timeouts++; -} - var successPromise = new events.Promise(); successPromise.timeout(500); setTimeout(function() { @@ -52,5 +43,5 @@ errorPromise.addErrback(function(e) { }); process.addListener('exit', function() { - assert.equal(2, timeouts); + assert.equal(1, timeouts); }); diff --git a/test/mjsunit/test-promise-wait.js b/test/mjsunit/test-promise-wait.js deleted file mode 100644 index 9f33d08610..0000000000 --- a/test/mjsunit/test-promise-wait.js +++ /dev/null @@ -1,98 +0,0 @@ -process.mixin(require("./common")); -events = require('events'); - -var p1_done = false; -var p1 = new events.Promise(); -p1.addCallback(function () { - assert.equal(1, arguments.length); - assert.equal("single arg", arguments[0]); - p1_done = true; -}); - -var p2_done = false; -var p2 = new events.Promise(); -p2.addCallback(function () { - p2_done = true; - setTimeout(function () { - p1.emitSuccess("single arg"); - }, 100); -}); - -var p3_done = false; -var p3 = new events.Promise(); -p3.addCallback(function () { - p3_done = true; -}); - - - -var p4_done = false; -var p4 = new events.Promise(); -p4.addCallback(function () { - assert.equal(3, arguments.length); - assert.equal("a", arguments[0]); - assert.equal("b", arguments[1]); - assert.equal("c", arguments[2]); - p4_done = true; -}); - -var p5_done = false; -var p5 = new events.Promise(); -p5.addCallback(function () { - p5_done = true; - setTimeout(function () { - p4.emitSuccess("a","b","c"); - }, 100); -}); - -var p6 = new events.Promise(); -var p7 = new events.Promise(); -p7.addErrback(function() {}); - -p2.emitSuccess(); - -assert.equal(false, p1_done); -assert.equal(true, p2_done); -assert.equal(false, p3_done); - -var ret1 = p1.wait() -assert.equal("single arg", ret1); - -assert.equal(true, p1_done); -assert.equal(true, p2_done); -assert.equal(false, p3_done); - -p3.emitSuccess(); - -assert.equal(false, p4_done); -assert.equal(false, p5_done); - -p5.emitSuccess(); - -assert.equal(false, p4_done); -assert.equal(true, p5_done); - -var ret4 = p4.wait(); -assert.deepEqual(["a","b","c"], ret4); - -assert.equal(true, p4_done); - - -p6.emitSuccess("something"); -assert.equal("something", p6.wait()); -p7.emitError("argh!"); -var goterr; -try { - p7.wait(); -} catch(err) { - goterr = err; -} -assert.equal("argh!", goterr.toString()); - -process.addListener("exit", function () { - assert.equal(true, p1_done); - assert.equal(true, p2_done); - assert.equal(true, p3_done); - assert.equal(true, p4_done); - assert.equal(true, p5_done); -}); diff --git a/test/mjsunit/test-wait-ordering.js b/test/mjsunit/test-wait-ordering.js deleted file mode 100644 index 1cbcc0a0fb..0000000000 --- a/test/mjsunit/test-wait-ordering.js +++ /dev/null @@ -1,32 +0,0 @@ -process.mixin(require("./common")); -var events = require('events'); - -function timer (t) { - var promise = new events.Promise(); - setTimeout(function () { - promise.emitSuccess(); - }, t); - return promise; -} - -order = 0; -var a = new Date(); -function test_timeout_order(delay, desired_order) { - delay *= 10; - timer(0).addCallback(function() { - timer(delay).wait() - var b = new Date(); - assert.equal(true, b - a >= delay); - order++; - // A stronger assertion would be that the ordering is correct. - // With Poor Man's coroutines we cannot guarentee that. - // Replacing wait() with actual coroutines would solve that issue. - // assert.equal(desired_order, order); - }); -} -test_timeout_order(10, 6); // Why does this have the proper order?? -test_timeout_order(5, 5); -test_timeout_order(4, 4); -test_timeout_order(3, 3); -test_timeout_order(2, 2); -test_timeout_order(1, 1); From bcf163da27676e26108ec430a392baee84f2831c Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Fri, 19 Feb 2010 10:29:41 -0800 Subject: [PATCH 11/46] Upgrade V8 to 2.1.1 --- deps/v8/AUTHORS | 2 + deps/v8/ChangeLog | 14 + deps/v8/SConstruct | 35 +- deps/v8/include/v8.h | 122 +- deps/v8/samples/lineprocessor.cc | 2 +- deps/v8/src/SConscript | 20 + deps/v8/src/accessors.cc | 37 +- deps/v8/src/api.cc | 164 +- deps/v8/src/arm/assembler-arm.cc | 191 +- deps/v8/src/arm/assembler-arm.h | 9 +- deps/v8/src/arm/assembler-thumb2-inl.h | 30 +- deps/v8/src/arm/assembler-thumb2.cc | 227 ++- deps/v8/src/arm/assembler-thumb2.h | 25 +- deps/v8/src/arm/builtins-arm.cc | 143 +- deps/v8/src/arm/codegen-arm.cc | 902 +++++++-- deps/v8/src/arm/codegen-arm.h | 100 +- deps/v8/src/arm/debug-arm.cc | 10 +- deps/v8/src/arm/disasm-arm.cc | 25 +- deps/v8/src/arm/fast-codegen-arm.cc | 188 +- deps/v8/src/arm/full-codegen-arm.cc | 182 +- deps/v8/src/arm/ic-arm.cc | 214 ++- deps/v8/src/arm/macro-assembler-arm.cc | 264 ++- deps/v8/src/arm/macro-assembler-arm.h | 127 +- deps/v8/src/arm/simulator-arm.cc | 29 +- deps/v8/src/arm/stub-cache-arm.cc | 467 ++--- deps/v8/src/arm/virtual-frame-arm.cc | 12 +- deps/v8/src/arm/virtual-frame-arm.h | 9 +- deps/v8/src/array.js | 5 +- deps/v8/src/assembler.cc | 10 + deps/v8/src/assembler.h | 16 +- deps/v8/src/ast.h | 39 +- deps/v8/src/bootstrapper.cc | 177 +- deps/v8/src/bootstrapper.h | 3 - deps/v8/src/builtins.cc | 499 ++++- deps/v8/src/builtins.h | 10 +- deps/v8/src/checks.h | 4 +- deps/v8/src/code-stubs.cc | 16 +- deps/v8/src/code-stubs.h | 5 +- deps/v8/src/codegen-inl.h | 41 +- deps/v8/src/codegen.cc | 75 +- deps/v8/src/codegen.h | 41 +- deps/v8/src/compiler.cc | 145 +- deps/v8/src/compiler.h | 129 +- deps/v8/src/contexts.h | 1 - deps/v8/src/d8-readline.cc | 4 +- deps/v8/src/data-flow.cc | 318 +++- deps/v8/src/data-flow.h | 62 +- deps/v8/src/debug-delay.js | 8 +- deps/v8/src/debug.cc | 14 +- deps/v8/src/disassembler.cc | 2 +- deps/v8/src/execution.cc | 2 +- deps/v8/src/fast-codegen.cc | 225 ++- deps/v8/src/fast-codegen.h | 94 +- deps/v8/src/flag-definitions.h | 4 +- deps/v8/src/frame-element.cc | 4 - deps/v8/src/frame-element.h | 43 +- deps/v8/src/frames-inl.h | 2 + deps/v8/src/frames.cc | 7 +- deps/v8/src/full-codegen.cc | 105 +- deps/v8/src/full-codegen.h | 23 +- deps/v8/src/globals.h | 5 + deps/v8/src/handles.cc | 47 +- deps/v8/src/handles.h | 2 + deps/v8/src/heap.cc | 19 +- deps/v8/src/heap.h | 2 - deps/v8/src/ia32/assembler-ia32.cc | 59 +- deps/v8/src/ia32/assembler-ia32.h | 5 +- deps/v8/src/ia32/builtins-ia32.cc | 135 +- deps/v8/src/ia32/codegen-ia32.cc | 1644 +++++++++++----- deps/v8/src/ia32/codegen-ia32.h | 161 +- deps/v8/src/ia32/debug-ia32.cc | 3 +- deps/v8/src/ia32/disasm-ia32.cc | 1 - deps/v8/src/ia32/fast-codegen-ia32.cc | 195 +- deps/v8/src/ia32/full-codegen-ia32.cc | 194 +- deps/v8/src/ia32/ic-ia32.cc | 462 +++-- deps/v8/src/ia32/macro-assembler-ia32.cc | 149 +- deps/v8/src/ia32/macro-assembler-ia32.h | 57 +- deps/v8/src/ia32/stub-cache-ia32.cc | 634 +++++-- deps/v8/src/ia32/virtual-frame-ia32.cc | 107 +- deps/v8/src/ia32/virtual-frame-ia32.h | 23 +- deps/v8/src/ic.cc | 94 +- deps/v8/src/ic.h | 32 +- deps/v8/src/json-delay.js | 36 +- deps/v8/src/jump-target-inl.h | 3 + deps/v8/src/jump-target.cc | 50 +- deps/v8/src/liveedit.cc | 87 + deps/v8/src/liveedit.h | 78 + deps/v8/src/log-utils.cc | 9 - deps/v8/src/log-utils.h | 3 - deps/v8/src/log.cc | 98 +- deps/v8/src/log.h | 17 +- deps/v8/src/macro-assembler.h | 9 + deps/v8/src/math.js | 2 +- deps/v8/src/messages.js | 2 + deps/v8/src/mips/assembler-mips-inl.h | 215 +++ deps/v8/src/mips/assembler-mips.cc | 1208 ++++++++++++ deps/v8/src/mips/assembler-mips.h | 663 +++++++ deps/v8/src/mips/builtins-mips.cc | 109 ++ deps/v8/src/mips/codegen-mips-inl.h | 56 + deps/v8/src/mips/codegen-mips.cc | 501 +++++ deps/v8/src/mips/codegen-mips.h | 311 ++++ deps/v8/src/mips/constants-mips.cc | 323 ++++ deps/v8/src/mips/constants-mips.h | 525 ++++++ deps/v8/src/mips/cpu-mips.cc | 69 + deps/v8/src/mips/debug-mips.cc | 112 ++ deps/v8/src/mips/disasm-mips.cc | 784 ++++++++ deps/v8/src/mips/fast-codegen-mips.cc | 56 + deps/v8/src/mips/frames-mips.cc | 100 + deps/v8/src/mips/frames-mips.h | 164 ++ deps/v8/src/mips/full-codegen-mips.cc | 268 +++ deps/v8/src/mips/ic-mips.cc | 187 ++ deps/v8/src/mips/jump-target-mips.cc | 87 + deps/v8/src/mips/macro-assembler-mips.cc | 895 +++++++++ deps/v8/src/mips/macro-assembler-mips.h | 381 ++++ .../v8/src/mips/register-allocator-mips-inl.h | 137 ++ deps/v8/src/mips/register-allocator-mips.cc | 60 + deps/v8/src/mips/register-allocator-mips.h | 46 + deps/v8/src/mips/simulator-mips.cc | 1648 +++++++++++++++++ deps/v8/src/mips/simulator-mips.h | 311 ++++ deps/v8/src/mips/stub-cache-mips.cc | 384 ++++ deps/v8/src/mips/virtual-frame-mips.cc | 240 +++ deps/v8/src/mips/virtual-frame-mips.h | 548 ++++++ deps/v8/src/mirror-delay.js | 26 +- deps/v8/src/number-info.h | 72 + deps/v8/src/objects-debug.cc | 2 + deps/v8/src/objects-inl.h | 7 + deps/v8/src/objects.cc | 227 ++- deps/v8/src/objects.h | 11 +- deps/v8/src/parser.cc | 3 +- deps/v8/src/platform-linux.cc | 17 +- deps/v8/src/property.cc | 2 +- deps/v8/src/property.h | 27 +- deps/v8/src/register-allocator-inl.h | 35 + deps/v8/src/register-allocator.cc | 23 +- deps/v8/src/register-allocator.h | 37 +- deps/v8/src/runtime.cc | 184 +- deps/v8/src/runtime.h | 9 +- deps/v8/src/runtime.js | 63 +- deps/v8/src/simulator.h | 2 + deps/v8/src/string.js | 18 +- deps/v8/src/stub-cache.cc | 20 +- deps/v8/src/stub-cache.h | 32 +- deps/v8/src/top.cc | 7 +- deps/v8/src/top.h | 1 + deps/v8/src/utils.cc | 37 - deps/v8/src/utils.h | 42 - deps/v8/src/v8-counters.h | 134 +- deps/v8/src/v8.cc | 5 +- deps/v8/src/v8natives.js | 156 +- deps/v8/src/version.cc | 4 +- deps/v8/src/virtual-frame.cc | 46 +- deps/v8/src/virtual-frame.h | 2 + deps/v8/src/x64/assembler-x64.cc | 130 +- deps/v8/src/x64/assembler-x64.h | 17 +- deps/v8/src/x64/builtins-x64.cc | 145 +- deps/v8/src/x64/codegen-x64.cc | 502 +++-- deps/v8/src/x64/codegen-x64.h | 67 +- deps/v8/src/x64/disasm-x64.cc | 95 +- deps/v8/src/x64/fast-codegen-x64.cc | 196 +- deps/v8/src/x64/full-codegen-x64.cc | 148 +- deps/v8/src/x64/ic-x64.cc | 233 ++- deps/v8/src/x64/macro-assembler-x64.cc | 144 +- deps/v8/src/x64/macro-assembler-x64.h | 44 +- deps/v8/src/x64/stub-cache-x64.cc | 218 ++- deps/v8/src/x64/virtual-frame-x64.cc | 87 +- deps/v8/src/x64/virtual-frame-x64.h | 30 +- deps/v8/test/cctest/SConscript | 6 +- deps/v8/test/cctest/cctest.status | 20 + deps/v8/test/cctest/test-api.cc | 894 +++++++++ deps/v8/test/cctest/test-assembler-mips.cc | 257 +++ deps/v8/test/cctest/test-compiler.cc | 27 +- deps/v8/test/cctest/test-debug.cc | 50 +- deps/v8/test/cctest/test-log.cc | 324 ++-- deps/v8/test/cctest/test-regexp.cc | 2 + deps/v8/test/cctest/test-utils.cc | 105 -- deps/v8/test/es5conform/es5conform.status | 80 +- deps/v8/test/message/message.status | 5 + .../mjsunit/array-functions-prototype-misc.js | 314 ++++ deps/v8/test/mjsunit/array-shift.js | 71 + deps/v8/test/mjsunit/array-slice.js | 162 ++ deps/v8/test/mjsunit/array-splice.js | 535 +++--- deps/v8/test/mjsunit/array-unshift.js | 132 ++ deps/v8/test/mjsunit/bugs/618.js | 86 + deps/v8/test/mjsunit/codegen-coverage.js | 92 +- deps/v8/test/mjsunit/compiler/assignment.js | 264 +++ .../test/mjsunit/compiler/simple-bailouts.js | 127 ++ .../test/mjsunit/compiler/simple-binary-op.js | 40 + .../mjsunit/compiler/simple-global-access.js | 53 + .../mjsunit/compiler/this-property-refs.js | 64 + deps/v8/test/mjsunit/debug-compile-event.js | 6 + deps/v8/test/mjsunit/div-mod.js | 16 +- deps/v8/test/mjsunit/fuzz-natives.js | 19 +- deps/v8/test/mjsunit/json.js | 32 +- deps/v8/test/mjsunit/mjsunit.status | 4 + .../test/mjsunit/object-define-properties.js | 56 + .../v8/test/mjsunit/object-define-property.js | 499 +++++ .../mjsunit/object-get-own-property-names.js | 2 + deps/v8/test/mjsunit/regress/regress-603.js | 49 + deps/v8/test/mjsunit/regress/regress-612.js | 44 + .../setter-on-constructor-prototype.js | 111 ++ deps/v8/test/mjsunit/substr.js | 78 +- deps/v8/test/mjsunit/tools/logreader.js | 16 - deps/v8/test/mjsunit/tools/tickprocessor.js | 4 +- deps/v8/test/mjsunit/typeof.js | 2 +- deps/v8/test/sputnik/sputnik.status | 5 + deps/v8/tools/gyp/v8.gyp | 3 + deps/v8/tools/linux-tick-processor | 11 +- deps/v8/tools/logreader.js | 45 +- deps/v8/tools/tickprocessor.js | 13 + deps/v8/tools/visual_studio/v8_base.vcproj | 12 + .../v8/tools/visual_studio/v8_base_arm.vcproj | 12 + .../v8/tools/visual_studio/v8_base_x64.vcproj | 12 + deps/v8/tools/windows-tick-processor.bat | 26 +- 213 files changed, 23731 insertions(+), 4858 deletions(-) create mode 100644 deps/v8/src/liveedit.cc create mode 100644 deps/v8/src/liveedit.h create mode 100644 deps/v8/src/mips/assembler-mips-inl.h create mode 100644 deps/v8/src/mips/assembler-mips.cc create mode 100644 deps/v8/src/mips/assembler-mips.h create mode 100644 deps/v8/src/mips/builtins-mips.cc create mode 100644 deps/v8/src/mips/codegen-mips-inl.h create mode 100644 deps/v8/src/mips/codegen-mips.cc create mode 100644 deps/v8/src/mips/codegen-mips.h create mode 100644 deps/v8/src/mips/constants-mips.cc create mode 100644 deps/v8/src/mips/constants-mips.h create mode 100644 deps/v8/src/mips/cpu-mips.cc create mode 100644 deps/v8/src/mips/debug-mips.cc create mode 100644 deps/v8/src/mips/disasm-mips.cc create mode 100644 deps/v8/src/mips/fast-codegen-mips.cc create mode 100644 deps/v8/src/mips/frames-mips.cc create mode 100644 deps/v8/src/mips/frames-mips.h create mode 100644 deps/v8/src/mips/full-codegen-mips.cc create mode 100644 deps/v8/src/mips/ic-mips.cc create mode 100644 deps/v8/src/mips/jump-target-mips.cc create mode 100644 deps/v8/src/mips/macro-assembler-mips.cc create mode 100644 deps/v8/src/mips/macro-assembler-mips.h create mode 100644 deps/v8/src/mips/register-allocator-mips-inl.h create mode 100644 deps/v8/src/mips/register-allocator-mips.cc create mode 100644 deps/v8/src/mips/register-allocator-mips.h create mode 100644 deps/v8/src/mips/simulator-mips.cc create mode 100644 deps/v8/src/mips/simulator-mips.h create mode 100644 deps/v8/src/mips/stub-cache-mips.cc create mode 100644 deps/v8/src/mips/virtual-frame-mips.cc create mode 100644 deps/v8/src/mips/virtual-frame-mips.h create mode 100644 deps/v8/src/number-info.h create mode 100644 deps/v8/test/cctest/test-assembler-mips.cc create mode 100644 deps/v8/test/mjsunit/array-functions-prototype-misc.js create mode 100644 deps/v8/test/mjsunit/array-shift.js create mode 100644 deps/v8/test/mjsunit/array-slice.js create mode 100644 deps/v8/test/mjsunit/array-unshift.js create mode 100644 deps/v8/test/mjsunit/bugs/618.js create mode 100644 deps/v8/test/mjsunit/compiler/assignment.js create mode 100644 deps/v8/test/mjsunit/compiler/simple-bailouts.js create mode 100644 deps/v8/test/mjsunit/compiler/simple-binary-op.js create mode 100644 deps/v8/test/mjsunit/compiler/simple-global-access.js create mode 100644 deps/v8/test/mjsunit/compiler/this-property-refs.js create mode 100644 deps/v8/test/mjsunit/object-define-properties.js create mode 100644 deps/v8/test/mjsunit/object-define-property.js create mode 100644 deps/v8/test/mjsunit/regress/regress-603.js create mode 100644 deps/v8/test/mjsunit/regress/regress-612.js create mode 100644 deps/v8/test/mjsunit/setter-on-constructor-prototype.js mode change 100644 => 100755 deps/v8/test/mjsunit/substr.js diff --git a/deps/v8/AUTHORS b/deps/v8/AUTHORS index 5d712fc271..8b0db5c376 100644 --- a/deps/v8/AUTHORS +++ b/deps/v8/AUTHORS @@ -4,6 +4,7 @@ # Name/Organization Google Inc. +Sigma Designs Inc. Alexander Botero-Lowry Alexandre Vassalotti @@ -22,3 +23,4 @@ Rene Rebe Ryan Dahl Patrick Gansterer Subrato K De +Dineel D Sule diff --git a/deps/v8/ChangeLog b/deps/v8/ChangeLog index 29ecccd7d8..8d4cd22339 100644 --- a/deps/v8/ChangeLog +++ b/deps/v8/ChangeLog @@ -1,3 +1,17 @@ +2010-02-19: Version 2.1.1 + + [ES5] Implemented Object.defineProperty. + + Improved profiler support. + + Added SetPrototype method in the public V8 API. + + Added GetScriptOrigin and GetScriptLineNumber methods to Function + objects in the API. + + Performance improvements on all platforms. + + 2010-02-03: Version 2.1.0 Values are now always wrapped in objects when used as a receiver. diff --git a/deps/v8/SConstruct b/deps/v8/SConstruct index 98fc22fba1..5483663fd6 100644 --- a/deps/v8/SConstruct +++ b/deps/v8/SConstruct @@ -191,6 +191,17 @@ LIBRARY_FLAGS = { 'armvariant:arm': { 'CPPDEFINES': ['V8_ARM_VARIANT_ARM'] }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'simulator:none': { + 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'], + 'LDFLAGS': ['-EL'] + } + }, + 'simulator:mips': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, 'arch:x64': { 'CPPDEFINES': ['V8_TARGET_ARCH_X64'], 'CCFLAGS': ['-m64'], @@ -292,6 +303,9 @@ V8_EXTRA_FLAGS = { # used by the arm simulator. 'WARNINGFLAGS': ['/wd4996'] }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + }, 'disassembler:on': { 'CPPDEFINES': ['ENABLE_DISASSEMBLER'] } @@ -457,10 +471,22 @@ SAMPLE_FLAGS = { 'CCFLAGS': ['-m64'], 'LINKFLAGS': ['-m64'] }, + 'arch:mips': { + 'CPPDEFINES': ['V8_TARGET_ARCH_MIPS'], + 'simulator:none': { + 'CCFLAGS': ['-EL', '-mips32r2', '-Wa,-mips32r2', '-fno-inline'], + 'LINKFLAGS': ['-EL'], + 'LDFLAGS': ['-EL'] + } + }, 'simulator:arm': { 'CCFLAGS': ['-m32'], 'LINKFLAGS': ['-m32'] }, + 'simulator:mips': { + 'CCFLAGS': ['-m32'], + 'LINKFLAGS': ['-m32'] + }, 'mode:release': { 'CCFLAGS': ['-O2'] }, @@ -601,7 +627,7 @@ SIMPLE_OPTIONS = { 'help': 'the os to build for (' + OS_GUESS + ')' }, 'arch': { - 'values':['arm', 'ia32', 'x64'], + 'values':['arm', 'ia32', 'x64', 'mips'], 'default': ARCH_GUESS, 'help': 'the architecture to build for (' + ARCH_GUESS + ')' }, @@ -651,7 +677,7 @@ SIMPLE_OPTIONS = { 'help': 'use Microsoft Visual C++ link-time code generation' }, 'simulator': { - 'values': ['arm', 'none'], + 'values': ['arm', 'mips', 'none'], 'default': 'none', 'help': 'build with simulator' }, @@ -871,6 +897,11 @@ def PostprocessOptions(options): options['armvariant'] = 'arm' if (options['armvariant'] != 'none' and options['arch'] != 'arm'): options['armvariant'] = 'none' + if options['arch'] == 'mips': + if ('regexp' in ARGUMENTS) and options['regexp'] == 'native': + # Print a warning if native regexp is specified for mips + print "Warning: forcing regexp to interpreted for mips" + options['regexp'] = 'interpreted' def ParseEnvOverrides(arg, imports): diff --git a/deps/v8/include/v8.h b/deps/v8/include/v8.h index 6125286e80..13f8191703 100644 --- a/deps/v8/include/v8.h +++ b/deps/v8/include/v8.h @@ -534,51 +534,76 @@ class V8EXPORT ScriptOrigin { class V8EXPORT Script { public: - /** - * Compiles the specified script. The ScriptOrigin* and ScriptData* - * parameters are owned by the caller of Script::Compile. No - * references to these objects are kept after compilation finishes. - * - * The script object returned is context independent; when run it - * will use the currently entered context. - */ - static Local