Skip to content
This repository has been archived by the owner on Oct 15, 2020. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'nodejs/master'
Browse files Browse the repository at this point in the history
Sync to nodejs/master (3/25/2016) at
nodejs/node@8363ede

PR-URL: #46
Reviewed-By: Sandeep Agarwal <Agarwal.Sandeep@microsoft.com>
Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
  • Loading branch information
Jianchun Xu committed Mar 28, 2016
2 parents 803af69 + 8363ede commit 88dc654
Show file tree
Hide file tree
Showing 148 changed files with 4,820 additions and 4,153 deletions.
191 changes: 191 additions & 0 deletions CHANGELOG.md

Large diffs are not rendered by default.

47 changes: 39 additions & 8 deletions android-configure
Original file line number Diff line number Diff line change
@@ -1,18 +1,49 @@
#!/bin/bash

if [ -z "$2" ]; then
ARCH=arm
else
ARCH="$2"
fi

CC_VER="4.9"
case $ARCH in
arm)
DEST_CPU="$ARCH"
SUFFIX="$ARCH-linux-androideabi"
TOOLCHAIN_NAME="$SUFFIX"
;;
x86)
DEST_CPU="ia32"
SUFFIX="i686-linux-android"
TOOLCHAIN_NAME="$ARCH"
;;
x86_64)
DEST_CPU="ia32"
SUFFIX="$ARCH-linux-android"
TOOLCHAIN_NAME="$ARCH"
;;
*)
echo "Unsupported architecture provided: $ARCH"
exit 1
;;
esac

export TOOLCHAIN=$PWD/android-toolchain
mkdir -p $TOOLCHAIN
$1/build/tools/make-standalone-toolchain.sh \
--toolchain=arm-linux-androideabi-4.9 \
--arch=arm \
--toolchain=$TOOLCHAIN_NAME-$CC_VER \
--arch=$ARCH \
--install-dir=$TOOLCHAIN \
--platform=android-21
export PATH=$TOOLCHAIN/bin:$PATH
export AR=$TOOLCHAIN/bin/arm-linux-androideabi-ar
export CC=$TOOLCHAIN/bin/arm-linux-androideabi-gcc
export CXX=$TOOLCHAIN/bin/arm-linux-androideabi-g++
export LINK=$TOOLCHAIN/bin/arm-linux-androideabi-g++
export AR=$TOOLCHAIN/bin/$SUFFIX-ar
export CC=$TOOLCHAIN/bin/$SUFFIX-gcc
export CXX=$TOOLCHAIN/bin/$SUFFIX-g++
export LINK=$TOOLCHAIN/bin/$SUFFIX-g++

./configure \
--dest-cpu=arm \
--dest-os=android
--dest-cpu=$DEST_CPU \
--dest-os=android \
--without-snapshot \
--openssl-no-asm
61 changes: 61 additions & 0 deletions benchmark/buffers/buffer-swap.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
'use strict';

const common = require('../common.js');

const bench = common.createBenchmark(main, {
method: ['swap16', 'swap32', 'htons', 'htonl'],
len: [4, 64, 512, 768, 1024, 1536, 2056, 4096, 8192],
n: [1e6]
});

// The htons and htonl methods below are used to benchmark the
// performance difference between doing the byteswap in pure
// javascript regardless of Buffer size as opposed to dropping
// down to the native layer for larger Buffer sizes.

Buffer.prototype.htons = function htons() {
if (this.length % 2 !== 0)
throw new RangeError();
for (var i = 0, n = 0; i < this.length; i += 2) {
n = this[i];
this[i] = this[i + 1];
this[i + 1] = n;
}
return this;
};

Buffer.prototype.htonl = function htonl() {
if (this.length % 2 !== 0)
throw new RangeError();
for (var i = 0, n = 0; i < this.length; i += 4) {
n = this[i];
this[i] = this[i + 3];
this[i + 3] = n;
n = this[i + 1];
this[i + 1] = this[i + 2];
this[i + 2] = n;
}
return this;
};

function createBuffer(len) {
const buf = Buffer.allocUnsafe(len);
for (var i = 1; i <= len; i++)
buf[i - 1] = i;
return buf;
}

function bufferSwap(n, buf, method) {
for (var i = 1; i <= n; i++)
buf[method]();
}

function main(conf) {
const method = conf.method;
const len = conf.len | 0;
const n = conf.n | 0;
const buf = createBuffer(len);
bench.start();
bufferSwap(n, buf, method);
bench.end(n);
}
14 changes: 3 additions & 11 deletions benchmark/http_simple.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ var http = require('http');

var port = parseInt(process.env.PORT || 8000);

var fixed = makeString(20 * 1024, 'C'),
var fixed = 'C'.repeat(20 * 1024),
storedBytes = {},
storedBuffer = {},
storedUnicode = {};
Expand Down Expand Up @@ -42,7 +42,7 @@ var server = module.exports = http.createServer(function(req, res) {
if (n <= 0)
throw new Error('bytes called with n <= 0');
if (storedBytes[n] === undefined) {
storedBytes[n] = makeString(n, 'C');
storedBytes[n] = 'C'.repeat(n);
}
body = storedBytes[n];

Expand All @@ -63,7 +63,7 @@ var server = module.exports = http.createServer(function(req, res) {
if (n <= 0)
throw new Error('unicode called with n <= 0');
if (storedUnicode[n] === undefined) {
storedUnicode[n] = makeString(n, '\u263A');
storedUnicode[n] = '\u263A'.repeat(n);
}
body = storedUnicode[n];

Expand Down Expand Up @@ -107,14 +107,6 @@ var server = module.exports = http.createServer(function(req, res) {
}
});

function makeString(size, c) {
var s = '';
while (s.length < size) {
s += c;
}
return s;
}

server.listen(port, function() {
if (module === require.main)
console.error('Listening at http://127.0.0.1:' + port + '/');
Expand Down
12 changes: 3 additions & 9 deletions benchmark/http_simple_auto.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@ var spawn = require('child_process').spawn;

var port = parseInt(process.env.PORT || 8000);

var fixed = '';
var i;
for (i = 0; i < 20 * 1024; i++) {
fixed += 'C';
}
var fixed = 'C'.repeat(20 * 1024);

var stored = {};
var storedBuffer = {};
Expand All @@ -30,16 +26,14 @@ var server = http.createServer(function(req, res) {
var n_chunks = parseInt(commands[3], 10);
var status = 200;
var n;
var i;

if (command == 'bytes') {
n = parseInt(arg, 10);
if (n <= 0)
throw new Error('bytes called with n <= 0');
if (stored[n] === undefined) {
stored[n] = '';
for (i = 0; i < n; i++) {
stored[n] += 'C';
}
stored[n] = 'C'.repeat(n);
}
body = stored[n];

Expand Down
28 changes: 28 additions & 0 deletions benchmark/misc/set-immediate-breadth-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
'use strict';

const common = require('../common.js');
const bench = common.createBenchmark(main, {
millions: [5]
});

function main(conf) {
const N = +conf.millions * 1e6;

process.on('exit', function() {
bench.end(N / 1e6);
});

function cb1(arg1) {}
function cb2(arg1, arg2) {}
function cb3(arg1, arg2, arg3) {}

bench.start();
for (let i = 0; i < N; i++) {
if (i % 3 === 0)
setImmediate(cb3, 512, true, null);
else if (i % 2 === 0)
setImmediate(cb2, false, 5.1);
else
setImmediate(cb1, 0);
}
}
21 changes: 21 additions & 0 deletions benchmark/misc/set-immediate-breadth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const common = require('../common.js');
const bench = common.createBenchmark(main, {
millions: [10]
});

function main(conf) {
const N = +conf.millions * 1e6;

process.on('exit', function() {
bench.end(N / 1e6);
});

function cb() {}

bench.start();
for (let i = 0; i < N; i++) {
setImmediate(cb);
}
}
47 changes: 47 additions & 0 deletions benchmark/misc/set-immediate-depth-args.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use strict';

const common = require('../common.js');
const bench = common.createBenchmark(main, {
millions: [10]
});

function main(conf) {
const N = +conf.millions * 1e6;

process.on('exit', function() {
bench.end(N / 1e6);
});

function cb3(n, arg2, arg3) {
if (--n) {
if (n % 3 === 0)
setImmediate(cb3, n, true, null);
else if (n % 2 === 0)
setImmediate(cb2, n, 5.1);
else
setImmediate(cb1, n);
}
}
function cb2(n, arg2) {
if (--n) {
if (n % 3 === 0)
setImmediate(cb3, n, true, null);
else if (n % 2 === 0)
setImmediate(cb2, n, 5.1);
else
setImmediate(cb1, n);
}
}
function cb1(n) {
if (--n) {
if (n % 3 === 0)
setImmediate(cb3, n, true, null);
else if (n % 2 === 0)
setImmediate(cb2, n, 5.1);
else
setImmediate(cb1, n);
}
}
bench.start();
setImmediate(cb1, N);
}
22 changes: 22 additions & 0 deletions benchmark/misc/set-immediate-depth.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';

const common = require('../common.js');
const bench = common.createBenchmark(main, {
millions: [10]
});

function main(conf) {
const N = +conf.millions * 1e6;
let n = N;

process.on('exit', function() {
bench.end(N / 1e6);
});

bench.start();
setImmediate(onNextTick);
function onNextTick() {
if (--n)
setImmediate(onNextTick);
}
}
5 changes: 1 addition & 4 deletions benchmark/static_http_server.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ var bytes = 1024 * 5;
var requests = 0;
var responses = 0;

var body = '';
for (var i = 0; i < bytes; i++) {
body += 'C';
}
var body = 'C'.repeat(bytes);

var server = http.createServer(function(req, res) {
res.writeHead(200, {
Expand Down
8 changes: 8 additions & 0 deletions common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@
'cflags': [ '-gxcoff' ],
'ldflags': [ '-Wl,-bbigtoc' ],
}],
['OS == "android"', {
'cflags': [ '-fPIE' ],
'ldflags': [ '-fPIE', '-pie' ]
}]
],
'msvs_settings': {
'VCCLCompilerTool': {
Expand Down Expand Up @@ -139,6 +143,10 @@
['OS!="mac" and OS!="win"', {
'cflags': [ '-fno-omit-frame-pointer' ],
}],
['OS == "android"', {
'cflags': [ '-fPIE' ],
'ldflags': [ '-fPIE', '-pie' ]
}]
],
'msvs_settings': {
'VCCLCompilerTool': {
Expand Down
8 changes: 8 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,12 @@ parser.add_option('--enable-static',
dest='enable_static',
help='build as static library')

parser.add_option('--no-browser-globals',
action='store_true',
dest='no_browser_globals',
help='do not export browser globals like setTimeout, console, etc. ' +
'(This mode is not officially supported for regular applications)')

parser.add_option('--engine',
action='store',
dest='engine',
Expand Down Expand Up @@ -771,6 +777,8 @@ def configure_node(o):
if options.enable_static:
o['variables']['node_target_type'] = 'static_library'

o['variables']['node_no_browser_globals'] = b(options.no_browser_globals)

if options.linked_module:
o['variables']['library_files'] = options.linked_module

Expand Down
Loading

0 comments on commit 88dc654

Please sign in to comment.