v8

How v8 hashes the keys in a hash table

核能气质少年 提交于 2019-12-11 15:26:46
问题 In learning how to implement a robust hash table, I am wondering the algorithm v8 uses to create the hash from a key, and what they use as the key (for string keys). Most of the examples on hash table key generation are hello world examples and subject to collision attacks and other things. I am looking for an example of how a production system implements a hash table, such as v8. Looking through the v8 source has been helpful, but it is a bit over my head. 回答1: V8's string hashing

Constructing an object to return by value elsewhere

若如初见. 提交于 2019-12-11 13:46:02
问题 In a wrapper to interface the V8 JavaScript engine with C++ code, I'd like to call a C++ function passing it an object by value. The object is automatically constructed from data inside JavaScript. The C++ function to call takes an object of type T and a template is used to generate an adapter function A, returning T by value. The problem is that the adapter function A needs to call a JavaScript function passing it another C++ function B as a callback. The object of type T is constructed in

JavaScript Internals: At what interval does the event loop run?

跟風遠走 提交于 2019-12-11 13:26:40
问题 This is a question about JavaScript internals. Lets say I have 10 async tasks that all take x number of seconds to run. Whilst waiting for a response the script is idle. In the background the JavaScript engine is asking "Is there anything on the task queue". To my understanding this is a loop. Hence, event loop. I know in Node this is implemented with Libuv. I've read this article which explains a little: https://nikhilm.github.io/uvbook/basics.html Do JavaScript engines place any restriction

how to get the raw version of a template string in iojs

混江龙づ霸主 提交于 2019-12-11 10:30:25
问题 Is it possible to get the raw version of a template string in iojs ? var s = `foo${1+1}bar` console.log(s); // foo2bar In the previous example I would like to get the string: foo${1+1}bar edit1 : My need is to detect whether a template string depends on its context of if is is just a 'constant' string that may contain CR and LF 回答1: Is it possible to get the raw version of a template string in iojs ? No it is not. It's not possible to get the raw representation of the literal, just like there

The semantics of v8::ResourceConstraints?

只谈情不闲聊 提交于 2019-12-11 10:25:23
问题 The v8::ResourceConstraints class is defined as follows: class V8EXPORT ResourceConstraints { public: ResourceConstraints(); int max_young_space_size() const { return max_young_space_size_; } void set_max_young_space_size(int value) { max_young_space_size_ = value; } int max_old_space_size() const { return max_old_space_size_; } void set_max_old_space_size(int value) { max_old_space_size_ = value; } int max_executable_size() { return max_executable_size_; } void set_max_executable_size(int

How to create optimal world.topo.json file with IDs?

好久不见. 提交于 2019-12-11 10:03:04
问题 Given a massive shape file of world countries. Given I'am using Topojson@1.0 installed locally via npm install topojson@1.0 . talled locally via npm install topojson@1.0 . Given I have csv data for many countries such as FR,144145 EN,5643 DE,25667 ES,3567 US,83466 CN,34576 JA,69353 Given I want to bind that data to the Topojson+D3js generated SVG. Thus I want a light yet precise world-id.topojson file with the rights properties... so to ease up the CSV-SVG data biding via matchings ids. So, I

How to return a new object from NanAsyncWorker?

别说谁变了你拦得住时间么 提交于 2019-12-11 09:57:06
问题 I'm working on a node.js/io.js native plugin, and I need to create a new native object from an async callback. Using the nan helpers, I've got something that looks like: class MyObject : public node::ObjectWrap { /* definition */ }; class MyWorker : public NanAsyncWorker { bool varForMyObject; virtual void Execute() {/* do stuff and sets varForMyObject */} virtual void HandleOKCallback() { NanScope(); MyObject* obj = new MyObject(varForMyObject); Local<Value> argv[] = { NanNull(), obj // ???

V8 build for android on mac

点点圈 提交于 2019-12-11 09:05:22
问题 I try to build v8 for android on mac. My steps are below : Install depot_tools fetch v8 cd v8 git checkout branch-name (last stable version for android) echo "target_os = ['android']" >> ../.gclient && gclient sync --nohooks make android_arm.release android_ndk_root=[full path to ndk] It says that no archive symbol table (run ranlib) I search this issue. There is a bug for this state. But it is not solved yet. I try to create d8 and push the android device. How can I do it? EDIT v8 guide

v8 extracting a global object from nodejs in C++

旧时模样 提交于 2019-12-11 07:34:20
问题 I have compiled nodejs using the "--shared" configure option. In my C++ code I have started a script in node (in its own thread) : node::Start(argc, argv); I have executed the following javascript to put an object into the global space : global.someObject = new SomeObject; I am now in C++ (on another thread) and I want to access the global "someObject". I have been thinking of using code along these lines, however the isolate vairable is NULL : v8::Isolate* isolate = v8::Isolate::GetCurrent()

V8 C++ embedding issues

社会主义新天地 提交于 2019-12-11 06:13:16
问题 I am new to V8 embedding, and have just started to replace my current scripting language with the V8 library. However I am running into some really odd (For me at least) issues. It kinda feels like I am the only one doing what I am doing and I feel like I am doing something stupid. I have made a wrapper class to wrap V8 engine functions and to construct the engine when my wrapper is constructed (Try to ignore shitty variable names or silly styles): engine.h: namespace JSEngine { class Engine