Dear v8 gurus, please help.
I see that there's a useful class v8::internal::ObjectHashTable that I
could use instead of the stacks to handle circular references.
But when I'm adding #include <objects.h> in my clone.cc file:
#define BUILDING_NODE_EXTENSION
#include <node.h>
#include <objects.h>
using namespace v8;
Handle<Value> Clone(const Arguments& args) {
node-gyp fails with this error:
wicked@wicked-desktop:~/Alawar/node-v8-clone$ node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | ia32
gyp info spawn python
gyp info spawn args [ '/home/wicked/.node-gyp/0.8.15/tools/gyp/gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/home/wicked/Alawar/node-v8-clone/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/home/wicked/.node-gyp/0.8.15/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/home/wicked/.node-gyp/0.8.15',
gyp info spawn args '-Dmodule_root_dir=/home/wicked/Alawar/node-v8-clone',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/wicked/Alawar/node-v8-clone/build'
CXX(target) Release/obj.target/clone/src/clone.o
../src/clone.cc:1:0: warning: "BUILDING_NODE_EXTENSION" redefined
<command-line>:0:0: note: this is the location of the previous definition
../src/clone.cc:3:21: fatal error: objects.h: No such file or directory
compilation terminated.
make: *** [Release/obj.target/clone/src/clone.o] Error 1
make: Leaving directory `/home/wicked/Alawar/node-v8-clone/build'
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit
(/usr/lib/node_modules/node-gyp/lib/build.js:232:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:99:17)
gyp ERR! stack at Process._handle.onexit (child_process.js:678:10)
gyp ERR! System Linux 2.6.38-16-generic-pae
gyp ERR! command "node" "/usr/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/wicked/Alawar/node-v8-clone
gyp ERR! node -v v0.8.15
gyp ERR! node-gyp -v v0.7.3
gyp ERR! not ok
Please help! What am I doing wrong?
воскресенье, 25 ноября 2012 г., 2:30:17 UTC+7 пользователь Alexey
Kupershtokh написал:
>
> Finished pure c++ deep cloning with handling circular references (tests
> pass).
> Bit it's slower than the js version on small structures :)
> Therefore I would like someone to review the c++ code.
>
> четверг, 22 ноября 2012 г., 18:05:18 UTC+7 пользователь Alexey Kupershtokh
> написал:
>>
>> I see that almost every framework (underscore, lodash, moo, etc) creates
>> its own clone function.
>> But v8 engine already has it.
>> So I've created a module that exposes v8's clone function. Just as a
>> proof of concept. It needs assertions and currently fails with a
>> segmentation fault on inputs like null values.
>>
>> https://github.com/AlexeyKupershtokh/node-v8-clone
>>
>> According to the benchmarks it's:
>> 8x faster (50x on 1000-key obj) than this approach:
>> var result = {}; for (i in obj) result[i] = obj[i];
>> 12x faster (450x on 1000-key object) than this approach:
>> var result = {}; for (i in obj) if (obj.hasOwnProperty(i)) result[i] =
>> obj[i];
>>
>> So I wonder if the community needs this module.
>> Also node's core developers are welcome to criticize. Is it ok to expose
>> this function? What are possible drawbacks? Or maybe it's worth to include
>> this into the node.js core?
>>
>
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en