v8

node.js的安装

不羁的心 提交于 2019-12-04 16:42:52
简介 Node.js 就是运行在服务端的 JavaScript,Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台。Node.js是一个事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascript的速度非常快,性能非常好。-_-! 性能到底怎么样不用是不知道的,这辈子汽车的V8引擎估计是用不上了,这个V8还是可以尝试一下。 根据你的系统平台去官网下载相应安装包 大专栏 node.js的安装 lank" rel="external noopener noreferrer">node.js官网 感觉linux下面第一个命令都要查看版本 12 $ node -v$ node --version 创建模块 暂不介绍,因为还没打算实际项目引入node.js 本篇仅做基本了解,一切疑问查询官网或者npm help 文档 来源: https://www.cnblogs.com/liuzhongrong/p/11874870.html

In V8 why does Isolate::GetCurrent() return NULL?

喜夏-厌秋 提交于 2019-12-04 16:25:45
I have compiled V8 on Ubuntu and have a very simple V8 program called isolate_test.cc. It is based on the Hello World example from Google : #include <v8.h> using namespace v8; int main(int argc, char* argv[]) { V8::initialize(); Isolate* isolate = Isolate::GetCurrent(); //Always returns NULL return 0; } The command I use to compile this program is: g++ -Iinclude -g isolate_test.cc -o isolate_test -Wl,--start-group out/x64.debug/obj.target/{tools/gyp/libv8_{base,snapshot},third_party/icu/libicu{uc,i18n,data}}.a -Wl,--end-group -lrt -lpthread Problem is Isolate::GetCurrent() always returns NULL

Javascript generator function — written in C++

二次信任 提交于 2019-12-04 16:23:28
Using the V8 C++ API, how can I implement the generator interface for use in Javascript? I'd like to create an object that can be used as the iterator for a for-of loop. Looks like the first thing that's necessary is to check for a property lookup for Symbol.iterator : NAN_PROPERTY_GETTER(My_Obj::Getter) { auto self = Nan::ObjectWrap::Unwrap<My_Obj>(info.This()); if (property->IsSymbol()) { if (Nan::Equals(property, v8::Symbol::GetIterator(info.GetIsolate())).FromJust()) { ... Respond with a function that takes no arguments. The function returns an object with a next property set to another

How does V8 manage the memory of object instances?

核能气质少年 提交于 2019-12-04 15:50:00
问题 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? 回答1: Newly allocated JavaScript object in V8

javascript V8 optimisation and “leaking arguments”

我的梦境 提交于 2019-12-04 13:21:29
问题 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

Storing handles to objects in a hashmap or set in Google's V8 engine

China☆狼群 提交于 2019-12-04 13:04:14
I would like to implement this functionality in an embedded JavaScript application that uses v8 engine. function myFunction1() { //do stuff } function myFunction2() { //do other stuff } myAddon.addCallback(myFunction1); myAddon.addCallback(myFunction2); myAddon.removeCallback(myFunction1); In order to do this I need to store these functions in a std::set like so void addCallback(const v8::FunctionCallbackInfo<v8::Value>& args) { v8::HandleScope scope(args.GetIsolate()); v8::Local<v8::Function> cb = v8::Local<v8::Function>::Cast(args[0]); std::set mySet = this->mySet; //now how do I insert a

Execute browser page/javascript from a script/command-line

六眼飞鱼酱① 提交于 2019-12-04 11:29:27
Hope this isnt a stupid question. I have recently had an idea about something which I am very curious about. I am a fan of Node.js (not really relevent here I think) and the V8 engine but I was wondering if its possible to run a browser (get it to execute JS) but INTERNALLY. What I mean by that is to create a program (possibly using the V8 engine) which can open a page (as if in the browser) and execute its javascript. For instance say I have the below file hosted on www.mysite.co.uk/home.php <!DOCTYPE html> <html> <head> <script> function myFunction() { //javascript AJAX call to www.mysite.co

Relationship between event loop,libuv and v8 engine

谁说我不能喝 提交于 2019-12-04 10:53:02
问题 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? 回答1: The event loop is, first and foremost, a high

Node.JS process uses 1.4 GB of memory, but heapdump is only 300 MB

社会主义新天地 提交于 2019-12-04 10:35:17
I'm running a Socket.IO server with Node.JS, which normally uses about 400 MB of memory, because there's a lot of data being cached to send to clients. However, after a couple of hours it suddenly starts growing to 1.4 GB of usage over about 40 minutes. Someone told me to use heapdump to find if there is a memory leak. The problem is that the heapdump only turned out to be 317 MB and nothing in it looks out of the ordinary, so I'm stuck with debugging. I've also run it with nodetime, which says that the V8 heap usage is around 400 MB, but the total V8 heap size is 1.4 GB. How do I find out

How do the various Javascript optimization projects affect DOM performance?

一曲冷凌霜 提交于 2019-12-04 09:53:55
There's a lot of capital C, capital S computer science going into Javascript via the Tracemonkey, Squirrelfish, and V8 projects. Do any of these projects (or others) address the performance of DOM operations, or are they purely Javascript computation related? The performance of pure DOM operations (getElementById/Tagname/Selector, nextChild, etc) are unaffected as they're already in pure C++. How the JS engine improvements will effect performance does depend to an extent on the particular techniques used for the performance improvements, as well as the performance of the DOM->JS bridge. An