mirror of https://github.com/lukechilds/node.git
Ryan Dahl
14 years ago
66 changed files with 1133 additions and 156 deletions
@ -0,0 +1,65 @@ |
|||
// Copyright 2011 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
// Regression test for GVN on field loads.
|
|||
|
|||
function bar() {} |
|||
|
|||
// Make sure there is a transition on adding "bar" inobject property.
|
|||
var b = new bar(); |
|||
b.bar = "bar"; |
|||
|
|||
function test(a) { |
|||
var b = new Array(10); |
|||
for (var i = 0; i < 10; i++) { |
|||
b[i] = new bar(); |
|||
} |
|||
|
|||
for (var i = 0; i < 10; i++) { |
|||
b[i].bar = a.foo; |
|||
} |
|||
} |
|||
|
|||
// Create an object with fast backing store properties.
|
|||
var a = {}; |
|||
a.p1 = ""; |
|||
a.p2 = ""; |
|||
a.p3 = ""; |
|||
a.p4 = ""; |
|||
a.p5 = ""; |
|||
a.p6 = ""; |
|||
a.p7 = ""; |
|||
a.p8 = ""; |
|||
a.p9 = ""; |
|||
a.p10 = ""; |
|||
a.p11 = ""; |
|||
a.foo = "foo"; |
|||
for (var i = 0; i < 100000; i++) { |
|||
test(a); |
|||
} |
|||
|
|||
test(""); |
@ -0,0 +1,52 @@ |
|||
// Copyright 2011 the V8 project authors. All rights reserved.
|
|||
// Redistribution and use in source and binary forms, with or without
|
|||
// modification, are permitted provided that the following conditions are
|
|||
// met:
|
|||
//
|
|||
// * Redistributions of source code must retain the above copyright
|
|||
// notice, this list of conditions and the following disclaimer.
|
|||
// * Redistributions in binary form must reproduce the above
|
|||
// copyright notice, this list of conditions and the following
|
|||
// disclaimer in the documentation and/or other materials provided
|
|||
// with the distribution.
|
|||
// * Neither the name of Google Inc. nor the names of its
|
|||
// contributors may be used to endorse or promote products derived
|
|||
// from this software without specific prior written permission.
|
|||
//
|
|||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|||
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|||
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|||
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|||
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|||
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|||
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|||
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|||
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|||
|
|||
// Do not generate debug code since that will space things differently
|
|||
// in the generated code.
|
|||
// Flags: --allow-natives-syntax --expose-gc --nodebug-code
|
|||
|
|||
// Regression test for issue where we did not pad the relocation
|
|||
// information enough to have room for lazy deoptimization.
|
|||
|
|||
function kaboom() { |
|||
var a = function () {}, |
|||
b = function () {}, |
|||
c, d = function () { var d = []; }, |
|||
e = function () { var e = {}; }; |
|||
c = function () { d(); b(); }; |
|||
return function (x, y) { |
|||
c(); |
|||
a(); |
|||
return function f() { }({}); |
|||
}; |
|||
} |
|||
|
|||
kaboom(); |
|||
|
|||
%DeoptimizeFunction(kaboom); |
|||
|
|||
gc(); |
After Width: | Height: | Size: 1.4 KiB |
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1,71 @@ |
|||
// Flags: --expose_gc
|
|||
|
|||
function newBuffer(size, value) { |
|||
var buffer = new Buffer(size); |
|||
while (size--) { |
|||
buffer[size] = value; |
|||
} |
|||
//buffer[buffer.length-2]= 0x0d;
|
|||
buffer[buffer.length - 1] = 0x0a; |
|||
return buffer; |
|||
} |
|||
|
|||
|
|||
var common = require('../common'); |
|||
var fs = require('fs'); |
|||
var testFileName = require('path').join(common.tmpDir, 'GH-814_testFile.txt'); |
|||
var testFileFD = fs.openSync(testFileName, 'w'); |
|||
console.log(testFileName); |
|||
|
|||
|
|||
|
|||
var kBufSize = 128 * 1024; |
|||
var PASS = true; |
|||
var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
|
|||
var bufPool = []; |
|||
|
|||
|
|||
|
|||
var tail = require('child_process').spawn('tail', ['-f', testFileName]); |
|||
tail.stdout.on('data', tailCB); |
|||
|
|||
function tailCB(data) { |
|||
PASS = data.toString().indexOf('.') < 0; |
|||
} |
|||
|
|||
|
|||
|
|||
var timeToQuit = Date.now() + 8e3; //Test during no more than this seconds.
|
|||
(function main() { |
|||
|
|||
if (PASS) { |
|||
fs.write(testFileFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, cb); |
|||
gc(); |
|||
var nuBuf = new Buffer(kBufSize); |
|||
neverWrittenBuffer.copy(nuBuf); |
|||
if (bufPool.push(nuBuf) > 100) { |
|||
bufPool.length = 0; |
|||
} |
|||
} |
|||
else { |
|||
throw Error("Buffer GC'ed test -> FAIL"); |
|||
} |
|||
|
|||
if (Date.now() < timeToQuit) { |
|||
process.nextTick(main); |
|||
} |
|||
else { |
|||
tail.kill(); |
|||
console.log("Buffer GC'ed test -> PASS (OK)"); |
|||
} |
|||
|
|||
})(); |
|||
|
|||
|
|||
function cb(err, written) { |
|||
if (err) { |
|||
throw err; |
|||
} |
|||
} |
|||
|
|||
|
@ -0,0 +1,85 @@ |
|||
// Flags: --expose_gc
|
|||
|
|||
var common = require('../common'); |
|||
|
|||
var fs = require('fs'); |
|||
var testFileName = require('path').join(common.tmpDir, 'GH-814_test.txt'); |
|||
var testFD = fs.openSync(testFileName, 'w'); |
|||
console.error(testFileName + '\n'); |
|||
|
|||
|
|||
var tailProc = require('child_process').spawn('tail', ['-f', testFileName]); |
|||
tailProc.stdout.on('data', tailCB); |
|||
|
|||
function tailCB(data) { |
|||
PASS = data.toString().indexOf('.') < 0; |
|||
|
|||
if (PASS) { |
|||
//console.error('i');
|
|||
} else { |
|||
console.error('[FAIL]\n DATA -> '); |
|||
console.error(data); |
|||
console.error('\n'); |
|||
throw Error('Buffers GC test -> FAIL'); |
|||
} |
|||
} |
|||
|
|||
|
|||
var PASS = true; |
|||
var bufPool = []; |
|||
var kBufSize = 16 * 1024 * 1024; |
|||
var neverWrittenBuffer = newBuffer(kBufSize, 0x2e); //0x2e === '.'
|
|||
|
|||
var timeToQuit = Date.now() + 5e3; //Test should last no more than this.
|
|||
writer(); |
|||
|
|||
function writer() { |
|||
|
|||
if (PASS) { |
|||
if (Date.now() > timeToQuit) { |
|||
setTimeout(function() { |
|||
process.kill(tailProc.pid); |
|||
console.error('\nBuffers GC test -> PASS (OK)\n'); |
|||
}, 555); |
|||
} else { |
|||
fs.write(testFD, newBuffer(kBufSize, 0x61), 0, kBufSize, -1, writerCB); |
|||
gc(); |
|||
gc(); |
|||
gc(); |
|||
gc(); |
|||
gc(); |
|||
gc(); |
|||
var nuBuf = new Buffer(kBufSize); |
|||
neverWrittenBuffer.copy(nuBuf); |
|||
if (bufPool.push(nuBuf) > 100) { |
|||
bufPool.length = 0; |
|||
} |
|||
process.nextTick(writer); |
|||
//console.error('o');
|
|||
} |
|||
} |
|||
|
|||
} |
|||
|
|||
function writerCB(err, written) { |
|||
//console.error('cb.');
|
|||
if (err) { |
|||
throw err; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
// ******************* UTILITIES
|
|||
|
|||
|
|||
function newBuffer(size, value) { |
|||
var buffer = new Buffer(size); |
|||
while (size--) { |
|||
buffer[size] = value; |
|||
} |
|||
buffer[buffer.length - 1] = 0x0d; |
|||
buffer[buffer.length - 1] = 0x0a; |
|||
return buffer; |
|||
} |
@ -0,0 +1,150 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
var http = require('http'), |
|||
https = require('https'), |
|||
fs = require('fs'), |
|||
common = require('../common'), |
|||
assert = require('assert'), |
|||
options = { |
|||
key: fs.readFileSync(common.fixturesDir + '/keys/agent1-key.pem'), |
|||
cert: fs.readFileSync(common.fixturesDir + '/keys/agent1-cert.pem') |
|||
}, |
|||
httpServer = http.createServer(reqHandler), |
|||
httpsServer = https.createServer(options, reqHandler); |
|||
|
|||
function reqHandler(req, res) { |
|||
console.log('Got request: ' + req.headers.host + ' ' + req.url); |
|||
assert.equal(req.headers.host, 'localhost:' + common.PORT, |
|||
'Wrong host header for req[' + req.url + ']: ' + |
|||
req.headers.host); |
|||
res.writeHead(200, {}); |
|||
//process.nextTick(function() { res.end('ok'); });
|
|||
res.end('ok'); |
|||
} |
|||
|
|||
function thrower(er) { |
|||
throw er; |
|||
} |
|||
|
|||
testHttp(); |
|||
|
|||
function testHttp() { |
|||
|
|||
console.log('testing http on port ' + common.PORT); |
|||
|
|||
var counter = 0; |
|||
|
|||
function cb() { |
|||
counter--; |
|||
console.log('back from http request. counter = ' + counter); |
|||
if (counter === 0) { |
|||
httpServer.close(); |
|||
testHttps(); |
|||
} |
|||
} |
|||
|
|||
httpServer.listen(common.PORT, function(er) { |
|||
console.error('listening on ' + common.PORT); |
|||
|
|||
if (er) throw er; |
|||
|
|||
http.get({ method: 'GET', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower); |
|||
|
|||
http.request({ method: 'GET', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
http.request({ method: 'POST', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
http.request({ method: 'PUT', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
http.request({ method: 'DELETE', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
}); |
|||
} |
|||
|
|||
function testHttps() { |
|||
|
|||
console.log('testing https on port ' + common.PORT); |
|||
|
|||
var counter = 0; |
|||
|
|||
function cb() { |
|||
counter--; |
|||
console.log('back from https request. counter = ' + counter); |
|||
if (counter === 0) { |
|||
httpsServer.close(); |
|||
console.log('ok'); |
|||
} |
|||
} |
|||
|
|||
httpsServer.listen(common.PORT, function(er) { |
|||
if (er) throw er; |
|||
|
|||
https.get({ method: 'GET', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower); |
|||
|
|||
https.request({ method: 'GET', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
https.request({ method: 'POST', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
https.request({ method: 'PUT', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
|
|||
https.request({ method: 'DELETE', |
|||
path: '/' + (counter++), |
|||
host: 'localhost', |
|||
//agent: false,
|
|||
port: common.PORT }, cb).on('error', thrower).end(); |
|||
}); |
|||
} |
@ -0,0 +1,82 @@ |
|||
// Copyright Joyent, Inc. and other Node contributors.
|
|||
//
|
|||
// Permission is hereby granted, free of charge, to any person obtaining a
|
|||
// copy of this software and associated documentation files (the
|
|||
// "Software"), to deal in the Software without restriction, including
|
|||
// without limitation the rights to use, copy, modify, merge, publish,
|
|||
// distribute, sublicense, and/or sell copies of the Software, and to permit
|
|||
// persons to whom the Software is furnished to do so, subject to the
|
|||
// following conditions:
|
|||
//
|
|||
// The above copyright notice and this permission notice shall be included
|
|||
// in all copies or substantial portions of the Software.
|
|||
//
|
|||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
|||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|||
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
|
|||
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
|||
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|||
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|||
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
|
|||
// This test asserts that Stream.prototype.pipe does not leave listeners
|
|||
// hanging on the source or dest.
|
|||
|
|||
var stream = require('stream'); |
|||
var assert = require('assert'); |
|||
var util = require('util'); |
|||
|
|||
function Writable () { |
|||
this.writable = true; |
|||
stream.Stream.call(this); |
|||
} |
|||
util.inherits(Writable, stream.Stream); |
|||
Writable.prototype.end = function () {} |
|||
|
|||
function Readable () { |
|||
this.readable = true; |
|||
stream.Stream.call(this); |
|||
} |
|||
util.inherits(Readable, stream.Stream); |
|||
|
|||
var i = 0; |
|||
var limit = 100; |
|||
|
|||
var w = new Writable(); |
|||
|
|||
console.error = function (text) { |
|||
throw new Error(text); |
|||
} |
|||
|
|||
var r; |
|||
|
|||
for (i = 0; i < limit; i++) { |
|||
r = new Readable() |
|||
r.pipe(w) |
|||
r.emit('end') |
|||
} |
|||
assert.equal(0, r.listeners('end').length); |
|||
|
|||
for (i = 0; i < limit; i++) { |
|||
r = new Readable() |
|||
r.pipe(w) |
|||
r.emit('close') |
|||
} |
|||
assert.equal(0, r.listeners('close').length); |
|||
|
|||
r = new Readable(); |
|||
|
|||
for (i = 0; i < limit; i++) { |
|||
w = new Writable(); |
|||
r.pipe(w); |
|||
w.emit('end'); |
|||
} |
|||
assert.equal(0, w.listeners('end').length); |
|||
|
|||
for (i = 0; i < limit; i++) { |
|||
w = new Writable(); |
|||
r.pipe(w); |
|||
w.emit('close'); |
|||
} |
|||
assert.equal(0, w.listeners('close').length); |
|||
|
Loading…
Reference in new issue