From be72c2c5001cde4c0578befaa59464404cce63b3 Mon Sep 17 00:00:00 2001 From: Joris Koster Date: Fri, 22 Jan 2016 14:12:23 +0100 Subject: [PATCH 1/4] jxcore: moved node::removeCommons() outside AutoScope scope When the AutoScope object goes out of scope in the JXEngine::Destroy method it uses members of main_node_ that prior to this fix had already been destroyed by the node::removeCommons() call. This fix moves the node::removeCommons autoside the lifetime scope of the AutoScope object, such that it's guaranteed that all members of main_node_ are still dereferenceable. --- src/jxcore.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/jxcore.cc b/src/jxcore.cc index 5191c527..9b570f94 100644 --- a/src/jxcore.cc +++ b/src/jxcore.cc @@ -1063,6 +1063,7 @@ void JXEngine::InitializeEmbeddedEngine(int argc, char **argv) { void JXEngine::Destroy() { ENGINE_LOG_THIS("JXEngine", "Destroy"); + { AutoScope _scope_(this, true); { customLock(CSLOCK_JOBS); @@ -1109,7 +1110,7 @@ void JXEngine::Destroy() { jx_engine_map::iterator it = jx_engine_instances.find(main_node_->threadId); if (it != jx_engine_instances.end()) jx_engine_instances.erase(it); customUnlock(CSLOCK_JOBS); - + } node::removeCommons(); } #endif From 6bc99dc114166ea333b85cf6623d125c3432c310 Mon Sep 17 00:00:00 2001 From: Marc McIntosh Date: Sun, 24 Jan 2016 08:58:35 +0000 Subject: [PATCH 2/4] new file: build_scripts/ARCH/PKGBUILD modified: build_scripts/ARCH/README.md deleted: build_scripts/ARCH/arm/PKGBUILD deleted: build_scripts/ARCH/arm/jxcore.install deleted: build_scripts/ARCH/aur/PKGBUILD deleted: build_scripts/ARCH/aur/jxcore.install --- build_scripts/ARCH/PKGBUILD | 94 +++++++++++++++++++++++++++ build_scripts/ARCH/README.md | 10 +-- build_scripts/ARCH/arm/PKGBUILD | 59 ----------------- build_scripts/ARCH/arm/jxcore.install | 14 ---- build_scripts/ARCH/aur/PKGBUILD | 59 ----------------- build_scripts/ARCH/aur/jxcore.install | 14 ---- 6 files changed, 96 insertions(+), 154 deletions(-) create mode 100644 build_scripts/ARCH/PKGBUILD delete mode 100644 build_scripts/ARCH/arm/PKGBUILD delete mode 100644 build_scripts/ARCH/arm/jxcore.install delete mode 100644 build_scripts/ARCH/aur/PKGBUILD delete mode 100644 build_scripts/ARCH/aur/jxcore.install diff --git a/build_scripts/ARCH/PKGBUILD b/build_scripts/ARCH/PKGBUILD new file mode 100644 index 00000000..75efc450 --- /dev/null +++ b/build_scripts/ARCH/PKGBUILD @@ -0,0 +1,94 @@ +# Maintainer: Marc McIntosh +pkgname=jxcore +pkgver=v0.3.0.7.r347.g1638e28 +pkgrel=1 +pkgdesc="Evented IO for SpiderMonkey and V8 JavaScript" +arch=('arm' 'armv6h' 'armv7h' 'i686' 'x86_64') +url="http://jxcore.io/" +license=('common') +depends=() +makedepends=('python2') +optdepends=() +conflicts=() +options=() +install= +source=('git+https://github.com/jxcore/jxcore') +noextract=() +md5sums=('SKIP') +pkgver() { + cd "$pkgname" + git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' +} +set_flags() { + + if [ "$CARCH" == "arm" ]; then + CONFIGFLAG="--with-arm-float-abi=soft --dest-cpu=arm" + CXXFLAGS="$CXXFLAGS -march=armv5t -mno-unaligned-access" + GYPFLAGS="-Darm_thumb -Darm_float_abi=soft -Darm_version=5 -Darm_fpu= -Darm_test_noprobe=on" + fi + + if [ "$CARCH" == "armv6h" ]; then + CONFIGFLAG="--with-arm-float-abi=hard --dest-cpu=arm" + GYPFLAGS="-Darm_thumb -Darm_float_abi=hard -Darm_version=6 -Darm_fpu=vfpv2" + fi + + if [ "$CARCH" == "armv7h" ]; then + CONFIGFLAG="--with-arm-float-abi=hard --dest-cpu=arm" + GYPFLAGS="-Darm_thumb -Darm_float_abi=hard -Darm_version=7 -Darm_fpu=vfpv3-d16" + fi + + if [ "$CARCH" == "i686" ]; then + CONFIGGLAG="--dest-cpu=ia32" + fi + + if [ "$CARCH" == "x86_64" ]; then + CONFIGFLAG="--dest-cpu=x64" + fi + + export CXXFLAGS + export GYPFLAGS +} +prepare(){ + cd "$srcdir/${pkgname}" + msg 'Fixing for python2 name' + find -type f -exec sed \ + -e 's_^#!/usr/bin/env python$_&2_' \ + -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \ + -e 's_^#!/usr/bin/python$_&2_' \ + -e "s_'python'_'python2'_" -i {} \; + find test/ -type f -exec sed 's_python _python2 _' -i {} \; +} +build() { + + cd "$srcdir/${pkgname}" + + set_flags + + export PYTHON=python2 + $PYTHON ./configure \ + --engine-mozilla \ + --dest-os="linux" \ + ${CONFIGFLAG} + make + +} + +check(){ + cd "$srcdir/${pkgname}" + make test || warning "Tests failed" +} + +package() { + cd "$srcdir/${pkgname}" + make DESTDIR="$pkgdir" install + + # install docs as per user request + install -d "$pkgdir/usr/share/doc/jxcore" + cp -r doc/api \ + "$pkgdir/usr/share/doc/jxcore" + + install -D -m644 JXCORE_LICENSE \ + "$pkgdir/usr/share/licenses/jxcore/LICENSE" +} + +# vim:set ts=2 sw=2 et: diff --git a/build_scripts/ARCH/README.md b/build_scripts/ARCH/README.md index bacc9a37..f03f2b55 100644 --- a/build_scripts/ARCH/README.md +++ b/build_scripts/ARCH/README.md @@ -1,12 +1,6 @@ -## i686 and x86_64 -jxcore can be installed from aur with yaourt: -'''bash -yaourt -S jxcore -''' -or using the files in either the aur or arm directories to make a tarball for pacman. '''bash mkdir -p ~/abs/jxcore -cp {PKGBUILD,jxcore.install} ~/abs/jxcore +cp PKGBUILD ~/abs/jxcore cd ~/abs/jxcore -makepkg -i +makepkg -si ''' diff --git a/build_scripts/ARCH/arm/PKGBUILD b/build_scripts/ARCH/arm/PKGBUILD deleted file mode 100644 index 0620684c..00000000 --- a/build_scripts/ARCH/arm/PKGBUILD +++ /dev/null @@ -1,59 +0,0 @@ -# Maintainer: Marc McIntosh -pkgname=jxcore -pkgver=v0.3.0.6.r23.g710a754 -pkgrel=1 -pkgdesc="Evented IO for SpiderMonkey and V8 JavaScript" -arch=('arm' 'armv6h' 'armv7h' 'aarch64') -url="http://jxcore.io/" -license=('common') -groups=() -depends=('openssl' 'zlib') -makedepends=('git' 'python2') -optdepends=('npm') -provides=() -conflicts=() -replaces=() -backup=() -options=() -install=('jxcore.install') -source=('git+https://github.com/jxcore/jxcore') -noextract=() -md5sums=('SKIP') -pkgver() { - cd "$pkgname" - git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' -} -prepare(){ - cd "$srcdir/${pkgname}" - msg 'Fixing for python2 name' - find -type f -exec sed \ - -e 's_^#!/usr/bin/env python$_&2_' \ - -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \ - -e 's_^#!/usr/bin/python$_&2_' \ - -e "s_'python'_'python2'_" -i {} \; - find test/ -type f -exec sed 's_python _python2 _' -i {} \; -} -build() { - cd "$srcdir/${pkgname}" - [[ $CARCH == "arm" ]] && CONFIGFLAG="--with-arm-float-abi soft" - [[ $CARCH == "armv6h" ]] && CONFIGFLAG="--with-arm-float-abi hard" - [[ $CARCH == "armv7h" ]] && CONFIGFLAG="--with-arm-float-abi hard" - [[ $CARCH == "aarch64" ]] && CONFIGFLAG="--with-arm-float-abi hard" - export PYTHON=python2 - ./configure --prefix=/usr --engine-mozilla --without-npm \ - --shared-openssl --shared-zlib $CONFIGFLAG - make -} - -package() { - cd "$srcdir/${pkgname}" - make DESTDIR="$pkgdir" install - - # install docs as per user request - install -d "$pkgdir"/usr/share/doc/jxcore - cp -r doc/api \ - "$pkgdir"/usr/share/doc/jxcore - - install -D -m644 JXCORE_LICENSE \ - "$pkgdir"/usr/share/licenses/jxcore/LICENSE -} diff --git a/build_scripts/ARCH/arm/jxcore.install b/build_scripts/ARCH/arm/jxcore.install deleted file mode 100644 index 0153afe3..00000000 --- a/build_scripts/ARCH/arm/jxcore.install +++ /dev/null @@ -1,14 +0,0 @@ -pre_install() { - [ -f '/usr/include/node/ares.h' ] && sudo rm -f '/usr/include/node/ares.h' - [ -f '/usr/include/node/ares_version.h' ] && sudo rm -f '/usr/include/node/ares_version.h' - [ -f '/usr/include/node/common.gypi' ] && sudo rm -f '/usr/include/node/common.gypi' - [ -f '/usr/include/node/config.gypi' ] && sudo rm -f '/usr/include/node/config.gypi' - [ -f '/usr/include/node/nameser.h' ] && sudo rm -f '/usr/include/node/nameser.h' - [ -f '/usr/include/node/node.h' ] && sudo rm -f '/usr/include/node/node.h' - [ -f '/usr/include/node/node_buffer.h' ] && sudo rm -f '/usr/include/node/node_buffer.h' - [ -f '/usr/include/node/node_internals.h' ] && sudo rm -f '/usr/include/node/node_internals.h' - [ -f '/usr/include/node/node_object_wrap.h' ] && sudo rm -f '/usr/include/node/node_object_wrap.h' - [ -f '/usr/include/node/node_version.h' ] && sudo rm -f '/usr/include/node/node_version.h' - [ -f '/usr/share/man/man1/node.1.gz' ] && sudo rm -f '/usr/share/man/man1/node.1.gz' -} - diff --git a/build_scripts/ARCH/aur/PKGBUILD b/build_scripts/ARCH/aur/PKGBUILD deleted file mode 100644 index 0a173cd6..00000000 --- a/build_scripts/ARCH/aur/PKGBUILD +++ /dev/null @@ -1,59 +0,0 @@ -# Maintainer: Marc McIntosh -pkgname=jxcore -pkgver=v0.3.0.6.r198.gfa2dd55 -pkgrel=1 -pkgdesc="Evented IO for SpiderMonkey and V8 JavaScript" -arch=('i686' 'x86_64') -url="http://jxcore.io/" -license=('common') -groups=() -depends=('openssl' 'zlib') -makedepends=('git' 'python2') -optdepends=('npm') -provides=() -conflicts=() -replaces=() -backup=() -options=() -install=('jxcore.install') -source=('git+https://github.com/jxcore/jxcore') -noextract=() -md5sums=('SKIP') -pkgver() { - cd "$pkgname" - git describe --long --tags | sed 's/\([^-]*-g\)/r\1/;s/-/./g' -} -build() { - cd "$srcdir/${pkgname}" - msg 'Fixing for python2 name' - find -type f -exec sed \ - -e 's_^#!/usr/bin/env python$_&2_' \ - -e 's_^\(#!/usr/bin/python2\).[45]$_\1_' \ - -e 's_^#!/usr/bin/python$_&2_' \ - -e "s_'python'_'python2'_" -i {} \; - find test/ -type f -exec sed 's_python _python2 _' -i {} \; - export PYTHON=python2 - ./configure \ - --prefix=/usr \ - --engine-mozilla \ - --shared-openssl \ - --shared-zlib \ - --without-npm - make - -} - -package() { - cd "$srcdir/${pkgname}" - make DESTDIR="$pkgdir" install - - # install docs as per user request - install -d "$pkgdir"/usr/share/doc/jxcore - cp -r doc/api \ - "$pkgdir"/usr/share/doc/jxcore - - install -D -m644 JXCORE_LICENSE \ - "$pkgdir"/usr/share/licenses/jxcore/LICENSE -} - -# vim:set ts=2 sw=2 et: diff --git a/build_scripts/ARCH/aur/jxcore.install b/build_scripts/ARCH/aur/jxcore.install deleted file mode 100644 index 0153afe3..00000000 --- a/build_scripts/ARCH/aur/jxcore.install +++ /dev/null @@ -1,14 +0,0 @@ -pre_install() { - [ -f '/usr/include/node/ares.h' ] && sudo rm -f '/usr/include/node/ares.h' - [ -f '/usr/include/node/ares_version.h' ] && sudo rm -f '/usr/include/node/ares_version.h' - [ -f '/usr/include/node/common.gypi' ] && sudo rm -f '/usr/include/node/common.gypi' - [ -f '/usr/include/node/config.gypi' ] && sudo rm -f '/usr/include/node/config.gypi' - [ -f '/usr/include/node/nameser.h' ] && sudo rm -f '/usr/include/node/nameser.h' - [ -f '/usr/include/node/node.h' ] && sudo rm -f '/usr/include/node/node.h' - [ -f '/usr/include/node/node_buffer.h' ] && sudo rm -f '/usr/include/node/node_buffer.h' - [ -f '/usr/include/node/node_internals.h' ] && sudo rm -f '/usr/include/node/node_internals.h' - [ -f '/usr/include/node/node_object_wrap.h' ] && sudo rm -f '/usr/include/node/node_object_wrap.h' - [ -f '/usr/include/node/node_version.h' ] && sudo rm -f '/usr/include/node/node_version.h' - [ -f '/usr/share/man/man1/node.1.gz' ] && sudo rm -f '/usr/share/man/man1/node.1.gz' -} - From 52694e88148dca2f8dd962ae24545e4fd7e94d33 Mon Sep 17 00:00:00 2001 From: kzc Date: Tue, 26 Jan 2016 15:33:03 -0500 Subject: [PATCH 3/4] remove unnecessary not null checks before delete --- src/jx/Proxy/Mozilla_340/MozJS/MozValue.cc | 10 +++++----- src/wrappers/node_crypto.cc | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/jx/Proxy/Mozilla_340/MozJS/MozValue.cc b/src/jx/Proxy/Mozilla_340/MozJS/MozValue.cc index c0696514..d511ee3d 100644 --- a/src/jx/Proxy/Mozilla_340/MozJS/MozValue.cc +++ b/src/jx/Proxy/Mozilla_340/MozJS/MozValue.cc @@ -1075,7 +1075,7 @@ void Value::empty_finalize(JSFreeOp *fop, JSObject *obj) { JSContext *ctx = Isolate::GetByThreadId(*tid)->GetRaw(); Value val(obj, ctx); ff->target(val, JS_GetPrivate(obj)); - delete (ff); + delete ff; val.rooted_ = true; val.RemoveRoot(); return; @@ -1511,7 +1511,7 @@ Value Value::NewInstance(int argc, Value *_args) { rval.ctx_ = ctx_; rval.value_ = JS::ObjectOrNullValue(NewInstance(argc, args)); - if (args != NULL) delete []args; + delete[] args; return rval; } @@ -1535,14 +1535,14 @@ Value Value::Call(const char *name, int argc, Value *_args) const { JS::RootedValue rov(ctx_); JS::MutableHandle mt_rval(&rov); if (!Call(name, argc, args, mt_rval)) { - if (args != NULL) delete[] args; + delete[] args; return Value(); } rval.empty_ = false; rval.value_ = mt_rval.get(); - if (args != NULL) delete[] args; + delete[] args; return rval; } @@ -1637,7 +1637,7 @@ Value Value::Call(const Value &host, int argc, Value *_args) const { mt_rval); rval.value_ = mt_rval.get(); - if (args != NULL) delete []args; + delete[] args; return rval; } diff --git a/src/wrappers/node_crypto.cc b/src/wrappers/node_crypto.cc index 095745eb..23358b00 100644 --- a/src/wrappers/node_crypto.cc +++ b/src/wrappers/node_crypto.cc @@ -2145,7 +2145,7 @@ class Cipher : public ObjectWrap { JS_LOCAL_VALUE outString; outString = Encode(out, out_len, BUFFER); - if (out) delete[] out; + delete[] out; RETURN_PARAM(outString); } @@ -2433,7 +2433,7 @@ class Decipher : public ObjectWrap { JS_LOCAL_VALUE outString; outString = Encode(out, out_len, BUFFER); - if (out) delete[] out; + delete[] out; RETURN_PARAM(outString); } From 9e8b7685114a521888a3cc25f36257574e7d5eb2 Mon Sep 17 00:00:00 2001 From: kzc Date: Tue, 26 Jan 2016 16:08:05 -0500 Subject: [PATCH 4/4] Replace util.inherits with node 5.5.0 implementation. Add a polyfill for Object.setPrototypeOf for v8 3.14. --- lib/util.js | 52 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/lib/util.js b/lib/util.js index 75fa6feb..6d338bdb 100644 --- a/lib/util.js +++ b/lib/util.js @@ -531,30 +531,46 @@ function pump(readStream, writeStream, callback) { exports.pump = exports.deprecate(pump, 'util.pump() is deprecated. Use readableStream.pipe() instead.'); +// Object.setPrototypeOf polyfill needed for V8 3.14 version of util.inherits. +// Should be a no-op on other engines. +if (!Object.setPrototypeOf) { + Object.setPrototypeOf = function(obj, proto) { + obj.__proto__ = proto; + return obj; + }; +} /** - * Inherit the prototype methods from one constructor into another. The - * Function.prototype.inherits from lang.js rewritten as a standalone function - * (not on Function.prototype). NOTE: If this file is to be loaded during - * bootstrapping this function needs to be rewritten using some native functions - * as prototype setup using normal JavaScript does not work as expected during - * bootstrapping (see mirror.js in r114903). + * Inherit the prototype methods from one constructor into another. + * + * The Function.prototype.inherits from lang.js rewritten as a standalone + * function (not on Function.prototype). NOTE: If this file is to be loaded + * during bootstrapping this function needs to be rewritten using some native + * functions as prototype setup using normal JavaScript does not work as + * expected during bootstrapping (see mirror.js in r114903). * - * @param {function} - * ctor Constructor function which needs to inherit the prototype. - * @param {function} - * superCtor Constructor function to inherit prototype from. + * @param {function} ctor Constructor function which needs to inherit the + * prototype. + * @param {function} superCtor Constructor function to inherit prototype from. + * @throws {TypeError} Will error if either constructor is null, or if + * the super constructor lacks a prototype. */ exports.inherits = function(ctor, superCtor) { + + if (ctor === undefined || ctor === null) + throw new TypeError('The constructor to "inherits" must not be ' + + 'null or undefined'); + + if (superCtor === undefined || superCtor === null) + throw new TypeError('The super constructor to "inherits" must not ' + + 'be null or undefined'); + + if (superCtor.prototype === undefined) + throw new TypeError('The super constructor to "inherits" must ' + + 'have a prototype'); + ctor.super_ = superCtor; - ctor.prototype = Object.create(superCtor.prototype, { - constructor: { - value: ctor, - enumerable: false, - writable: true, - configurable: true - } - }); + Object.setPrototypeOf(ctor.prototype, superCtor.prototype); }; exports._extend = function(origin, add) {