v8

How does V8 manage the memory of object instances?

怎甘沉沦 提交于 2019-12-03 08:59:45
http://code.google.com/apis/v8/design.html The above page explains the optimization technique v8 team uses to enable fast property access. But how about it's object instances? New properties can be added to the object anytime, so it should be allowed to grow in size. Does it simply allocate the memory with a default size and when it hits the size limit creates a new buffer and copy the old instance to the new buffer? Or there's another cool trick? Newly allocated JavaScript object in V8 look like ( -> means "points to"): [ class ] -> ... ; pointer to the hidden class [ properties ] -> [empty

C++ - Qt + v8 under msvc2012

匿名 (未验证) 提交于 2019-12-03 08:56:10
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Recently, I've started a project under Qt5.1.0 . After some development, I choose to make a scripting system under Javascript with Google V8 . Under Windows 7 x64 , the only way to compile V8 is under msvc2012 , and I got 3 .lib files to use. In a single project using ONLY V8 , everything works well. But integrating V8 with an existent project using Qt5 it's a bit more complicated. Here is an example of a minimal code I'm using : (Of course, there is more file in this project...) #include <QApplication> #include <v8.h> using namespace v8;

javascript V8 optimisation and “leaking arguments”

人走茶凉 提交于 2019-12-03 08:23:54
I read in various places that it's advisable to be careful with the arguments object and that this is ok... var i = arguments.length, args = new Array(i); while (i--) args[i] = arguments[i]; But, is this ok or not?... function makeArray (l) { var i = l.length, array = new Array(i); while (i--) array[i] = l[i]; return array; }; //... //EDIT: put the function on an object to better represent the actual case var o = {}; o.f = function (callback) { var args = makeArray (arguments); callback.apply(args[0] = this, args); }; What is meant by "leaking arguments" and how does it affect optimisation? I

How do you include another js file in Google's v8?

大城市里の小女人 提交于 2019-12-03 08:21:53
问题 How do you include another script file inside a .js script file in v8? There's the <script> tag in HTML but how can it be done inside a v8 embedded program? 回答1: You have to add this functionality manually, here is how I did it: Handle<Value> Include(const Arguments& args) { for (int i = 0; i < args.Length(); i++) { String::Utf8Value str(args[i]); // load_file loads the file with this name into a string, // I imagine you can write a function to do this :) std::string js_file = load_file(*str)

Converting from v8::Arguments to C++ Types

我的未来我决定 提交于 2019-12-03 08:14:46
问题 I'm playing with creating Node.js modules in C++, but I'm stumped on the v8::Arguments class. Lets say I have a Javascript class for sending emails, which has a method with this signature: Mailer::sendEmail(Array recipients, String sender, String message); Which would be called like this: mailer.sendEmail(["joe@gmail.com", "sally@gmail.com"], "fred@gmail.com", "Hi there"); Now in C++ land, I have a class function with this signature: SendEmail(const v8::Arguments& args) Which is backing my

Embed basic WebKit + V8 in my app

匿名 (未验证) 提交于 2019-12-03 07:50:05
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I want a very basic HTML/CSS/JS renderer embedded in my app using WebKit and preferably V8. All I need is to always render one page and possibly make network and local requests (load JSON/msgpack). I don't need prefetch, tabs, omnibox, profiles and other chromium features, but from what I see looking at CEF is that it embeds a full featured chromium. Are there any other solutions? 文章来源: Embed basic WebKit + V8 in my app

Access the Abstract Syntax Tree of V8 Engine

无人久伴 提交于 2019-12-03 07:42:39
问题 Is it possible to access the AST of the v8 engine, for a given JavaScript code? I'm working on a JavaScript Static Analyzer using V8 engine. 回答1: This is pretty old but maybe the answer helps someone stumbling upon this. The answer is yes, assuming you are willing to modify V8 and compile your own version of it. If so, then in compiler.cc you find a spot where MakeCode is called throughout MakeFunctionInfo which transforms the AST that is stored in the passed in CompilationInfo object into

Relationship between event loop,libuv and v8 engine

限于喜欢 提交于 2019-12-03 07:05:06
I am learning through the architecture of Node.js. I have following questions. Is event loop a part of libuv or v8? Is event queue a part of event loop? are event queue generated by libuv or v8 engine or event loop itself? What is the connection between libuv and v8 engine? If event loop is single threaded, does libuv come into picture to create multiple threads to handle File I/O? Does browsers have event loop mechanism or just Node.js does? The event loop is, first and foremost, a high-level concept that's a fundamental part of the JavaScript programming model. Practically, every V8 embedder

What is the design rationale behind HandleScope?

孤者浪人 提交于 2019-12-03 07:04:24
问题 V8 requires a HandleScope to be declared in order to clean up any Local handles that were created within scope. I understand that HandleScope will dereference these handles for garbage collection, but I'm interested in why each Local class doesn't do the dereferencing themselves like most internal ref_ptr type helpers. My thought is that HandleScope can do it more efficiently by dumping a large number of handles all at once rather than one by one as they would in a ref_ptr type scoped class.

Which is faster, Clojure or ClojureScript (and why)?

孤人 提交于 2019-12-03 07:04:21
问题 If I had to guess, I'm pretty sure the answer is Clojure, but I'm not sure why. Logically (to me) it seems like ClojureScript should be faster: Both are "dynamic", but ClojureScript Compiles to JavaScript, running on V8 V8 engine is arguably the fastest dynamic language engine there is V8 is written in C whereas Clojure: Is also dynamic Runs in JVM, which has no built-in dynamic support, so I'm thinking thus JVM has to do whatever V8 is doing too, to enable dynamic support and Java is slower