This is a big commit that touches just about every file in the src/ directory. The V8 API has changed in significant ways. The most important changes are: * Binding functions take a const v8::FunctionCallbackInfo<T>& argument rather than a const v8::Arguments& argument. * Binding functions return void rather than v8::Handle<v8::Value>. The return value is returned with the args.GetReturnValue().Set() family of functions. * v8::Persistent<T> no longer derives from v8::Handle<T> and no longer allows you to directly dereference the object that the persistent handle points to. This means that the common pattern of caching oft-used JS values in a persistent handle no longer quite works, you first need to reconstruct a v8::Local<T> from the persistent handle with the Local<T>::New(isolate, persistent) factory method. A handful of (internal) convenience classes and functions have been added to make dealing with the new API a little easier. The most visible one is node::Cached<T>, which wraps a v8::Persistent<T> with some template sugar. It can hold arbitrary types but so far it's exclusively used for v8::Strings (which was by far the most commonly cached handle type.)
All compile time warnings about using deprecated APIs have been suppressed by updating node's API. Though there are still many function calls that can accept Isolate, and still need to be updated. node_isolate had to be added as an extern variable in node.h and node_object_wrap.h Also a couple small fixes for Error handling. Before v8 3.16.6 the error stack message was lazily written when it was needed, which allowed you to change the message after instantiation. Then the stack would be written with the new message the first time it was accessed. Though that has changed. Now it creates the stack message on instantiation. So setting a different message afterwards won't be displayed. This is not a complete fix for the problem. Getting error without any message isn't very useful.
Turn call-as-function calls into constructor calls. Makes the following snippet work: var buf = ArrayBuffer(32); // no 'new' but does the right thing
Convert the Buffer to an ArrayBuffer. The typed_array.buffer property should be an ArrayBuffer to avoid confusion: a Buffer doesn't have a byteLength property and more importantly, its slice() method works subtly different. That means that before this commit: var buf = new Buffer(1); var arr = new Int8Array(buf); assert.equal(arr.buffer, buf); assert(arr.buffer instanceof Buffer); And now: var buf = new Buffer(1); var arr = new Int8Array(buf); assert.notEqual(arr.buffer, buf); assert(arr.buffer instanceof ArrayBuffer);
Make the DataView constructor throw an exception when the first argument is not an ArrayBuffer. Follows the spec and the browsers.
We're going to fix this differently. The real bug is that Buffer::HasInstance() returns true for typed arrays. This reverts commit 01ee551.
We're going to follow browser behavior here. This reverts commit 7b0770b.
This is commit 01ee551, except for the DataView type this time. Make the behavior of DataView consistent with that of typed arrays: make a copy of the backing store.
Follow browser behavior, only share the backing store when it's a ArrayBuffer. That is: var abuf = new ArrayBuffer(32); var a = new Int8Array(abuf); var b = new Int8Array(abuf); a = 0; b = 1; assert(a === b); // a and b share memory But: var a = new Int8Array(32); var b = new Int8Array(a); a = 0; b = 1; assert(a !== b); // a and b don't share memory The typed arrays spec allows both `a === b` and `a !=== b` but Chrome and Firefox implement the behavior where memory is not shared. Copying the memory is less efficient but let's do it anyway for the sake of the Principle of Least Surprise. Fixes #4714.
V8 seems to be particularly slow converting an undefined value to false in BooleanValue. Revert this when we upgrade to V8 3.17, or whenever the fix discussed in http://code.google.com/p/v8/issues/detail?id=2487 lands in V8.
Conflicts: AUTHORS ChangeLog Makefile src/node_version.h
Implement load and store swizzling operations. This reduces an unneeded back and forth between types and additionally keeps the value in the swappable type until it is swapped. This is important for correctness when dealing with floating point, to avoid the possibility of loading the bits of a signaling NaN (because it isn't yet swapped) into the FPU. This additionally produces better code (comments are mine): gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) setValue<double>: movd %xmm0, %rax ; fp reg -> gen reg bswapq %rax ; 64-bit byte swap movq %rax, (%r15,%r12) ; store
Implement swizzling with compiler intrinsics and be aware of the native endianness to correctly swap on big endian machines. This introduces a template function to swap the bytes of a value, and macros for the low level swap (taking advantage of gcc and msvc intrinsics). This produces code like the following (comments are mine): gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.11.00) setValue<double>: movd %xmm0, %rax ; fp reg -> gen reg bswapq %rax ; 64-bit byte swap movd %rax, %xmm0 ; gen reg -> fp reg movq %xmm0, (%r15,%r12) ; store
When Mikael Bourges-Sevenier added support for Uint8ClampedArray in 67fc1da, the new type was not added to SizeOfArrayElementForType().
Although it is not used externally by node, it is needed by upstream and Plask. This effectively reverts: commit 1444801 Author: Aaron Jacobs <email@example.com> Date: Thu Mar 15 13:26:35 2012 +1100 typed arrays: unexport SizeOfArrayElementForType() It isn't used anywhere else, so made it an implementation detail in v8_typed_array.cc.
Instead of duplicating V8's logic (including clamping), just simply call into V8's Get() and Set() methods, which handles all conversions and typing.
Conflicts: AUTHORS ChangeLog LICENSE Makefile deps/http_parser/test.c deps/npm/AUTHORS deps/npm/html/api/bin.html deps/npm/html/api/bugs.html deps/npm/html/api/commands.html deps/npm/html/api/config.html deps/npm/html/api/deprecate.html deps/npm/html/api/docs.html deps/npm/html/api/edit.html deps/npm/html/api/explore.html deps/npm/html/api/help-search.html deps/npm/html/api/init.html deps/npm/html/api/install.html deps/npm/html/api/link.html deps/npm/html/api/load.html deps/npm/html/api/ls.html deps/npm/html/api/npm.html deps/npm/html/api/outdated.html deps/npm/html/api/owner.html deps/npm/html/api/pack.html deps/npm/html/api/prefix.html deps/npm/html/api/prune.html deps/npm/html/api/publish.html deps/npm/html/api/rebuild.html deps/npm/html/api/restart.html deps/npm/html/api/root.html deps/npm/html/api/run-script.html deps/npm/html/api/search.html deps/npm/html/api/shrinkwrap.html deps/npm/html/api/start.html deps/npm/html/api/stop.html deps/npm/html/api/submodule.html deps/npm/html/api/tag.html deps/npm/html/api/test.html deps/npm/html/api/uninstall.html deps/npm/html/api/unpublish.html deps/npm/html/api/update.html deps/npm/html/api/version.html deps/npm/html/api/view.html deps/npm/html/api/whoami.html deps/npm/html/doc/README.html deps/npm/html/doc/adduser.html deps/npm/html/doc/bin.html deps/npm/html/doc/bugs.html deps/npm/html/doc/build.html deps/npm/html/doc/bundle.html deps/npm/html/doc/cache.html deps/npm/html/doc/changelog.html deps/npm/html/doc/coding-style.html deps/npm/html/doc/completion.html deps/npm/html/doc/config.html deps/npm/html/doc/deprecate.html deps/npm/html/doc/developers.html deps/npm/html/doc/disputes.html deps/npm/html/doc/docs.html deps/npm/html/doc/edit.html deps/npm/html/doc/explore.html deps/npm/html/doc/faq.html deps/npm/html/doc/folders.html deps/npm/html/doc/help-search.html deps/npm/html/doc/help.html deps/npm/html/doc/index.html deps/npm/html/doc/init.html deps/npm/html/doc/install.html deps/npm/html/doc/json.html deps/npm/html/doc/link.html deps/npm/html/doc/list.html deps/npm/html/doc/npm.html deps/npm/html/doc/outdated.html deps/npm/html/doc/owner.html deps/npm/html/doc/pack.html deps/npm/html/doc/prefix.html deps/npm/html/doc/prune.html deps/npm/html/doc/publish.html deps/npm/html/doc/rebuild.html deps/npm/html/doc/registry.html deps/npm/html/doc/removing-npm.html deps/npm/html/doc/restart.html deps/npm/html/doc/root.html deps/npm/html/doc/run-script.html deps/npm/html/doc/scripts.html deps/npm/html/doc/search.html deps/npm/html/doc/semver.html deps/npm/html/doc/shrinkwrap.html deps/npm/html/doc/star.html deps/npm/html/doc/start.html deps/npm/html/doc/stop.html deps/npm/html/doc/submodule.html deps/npm/html/doc/tag.html deps/npm/html/doc/test.html deps/npm/html/doc/uninstall.html deps/npm/html/doc/unpublish.html deps/npm/html/doc/update.html deps/npm/html/doc/version.html deps/npm/html/doc/view.html deps/npm/html/doc/whoami.html deps/npm/lib/npm.js deps/npm/man/man1/npm.1 deps/npm/man/man3/npm.3 deps/npm/node_modules/fstream-npm/fstream-npm.js deps/npm/node_modules/fstream-npm/node_modules/fstream-ignore/package.json deps/npm/node_modules/fstream-npm/package.json deps/npm/node_modules/node-gyp/LICENSE deps/npm/node_modules/node-gyp/lib/build.js deps/npm/node_modules/node-gyp/lib/install.js deps/npm/node_modules/node-gyp/node_modules/ansi/package.json deps/npm/node_modules/node-gyp/node_modules/glob/package.json deps/npm/node_modules/node-gyp/package.json deps/npm/package.json deps/uv/test/test-fs.c deps/v8/src/regexp-macro-assembler-tracer.cc deps/v8/src/version.cc src/node_version.h src/platform_sunos.cc test/simple/test-net-write-after-close.js wscript
It isn't used anywhere else, so made it an implementation detail in v8_typed_array.cc.