v8

How to link against v8?

点点圈 提交于 2019-12-10 18:24:23
问题 I successfully compiled v8 javascript engine (on windows) ; now I try to follow the Getting started article but I am stuck at this point: Compile hello_world.cpp, linking to the static libraries created in the build process. The example is for linux (and probably for an earlier version). I tried to link against all libraries that I could without success: User@PC:/cygdrive/c/Users/Yvain/Documents/depot_tools/v8/build/Release g++ -std=c++0x -I"C:\Users\Yvain\Documents\depot_tools\v8" -Llib -lv8

Is the Function() constructor not optimized by V8, like eval?

自闭症网瘾萝莉.ら 提交于 2019-12-10 14:53:24
问题 We are trying a way to receive web components via WebSockets. Those components contains custom scripts and they should be run in a context inside the component. In short, we have some script strings and want to run them. Right now we are using eval for this, something like this: function ctxEval(ctx, __script) { eval(__script); // return things with the ctx } and works as expected, but I'm reading that any function containing eval is not optimized by V8. I thought into converting it to new

Accessing USB devices from node-webkit?

前提是你 提交于 2019-12-10 13:56:45
问题 I'm building a node-webkit app that needs to run on all 3 main desktop environments (windows, mac and linux) I need my app to connect to a plugged in USB device and I'm having a bit of trouble working out exactly how to go about this. Is there an npm that would work across all OS's? Could I get one built in C++ that would work? Is there anything built in to node-webkit for interacting with devices (Devices API?) Thanks in advance. 回答1: You're almost certain to need a C/C++ module to make this

How to install v8-profiler using npm on windows 7?

烂漫一生 提交于 2019-12-10 13:08:41
问题 Tried to install v8-profiler on Windows7(64 bit) npm install v8-profiler Note: 1. The dependency was Python 2.7, I have installed and set the env. var. also Confirmed 'Visual C++ Redistributable Package' is installed. node-gyp module is also installed But still the error thrown is as follows: D:\Projects\Projects\MY_Prjct3\MY_Prjct>npm install v8-profiler npm http GET https://registry.npmjs.org/v8-profiler npm http 304 https://registry.npmjs.org/v8-profiler > v8-profiler@3.6.2-1 install D:

SetTimeout issue in Node.js

柔情痞子 提交于 2019-12-10 12:31:57
问题 I've the following code which runs fine under Chrome (V8) but fails inside node: var id; id = setTimeout("TimeoutHandler()", 10); console.log ('SET'); function TimeoutHandler() { clearTimeout(id); console.log ('CLEAR'); } Chrome output: SET CLEAR Nodejs output: SET timers.js:110 first._onTimeout(); ^ TypeError: Property '_onTimeout' of object [object Object] is not a function at Timer.listOnTimeout [as ontimeout] (timers.js:110:15) Any ideas why? Thanks 回答1: Unlike in most browsers,

how to determine source information of callback in v8

允我心安 提交于 2019-12-10 12:08:31
问题 Is it possible to determine the source information (file, line number, column number) of a callback in v8? function foo(callback) { var x = callback(); if (typeof x !== "string") { //hmmm, x is not as expected, I want to know more about the callback. } } 回答1: I'm not aware that you can do this in JavaScript, but if you can debug it, it should show you the file/line etc.. I guess doing that would depend exactly on your setup and I've never done it myself - it looks like node (uses v8) has some

How v8 stores fast objects

本秂侑毒 提交于 2019-12-10 11:04:51
问题 As a follow-up question to the answer to If v8 rehashes when an object grows, I am wondering how v8 actually stores "fast" objects. From the answer: Fast mode is typically much faster for property access - but requires the object's structure to be known. V8 will initially try to construct a template of what the object looks like called a "Hidden Class". The object will transform through hidden classes until V8 will give up and store the object as a slow property. Then I asked if v8 rehashes

Binary array using V8 engine

浪尽此生 提交于 2019-12-10 10:54:56
问题 I have an array of bytes defined as unsigned char ptr = new unsigned char[1024]; fillWithSomething(ptr, 1024); Then, I need to store the ptr variable in a Local< Array> variable of V8 Engine or another kind of V8 data type. Currently, I am converting the array of bytes into a string in order to store in a Local< String> variable, but this approach is inefficient to my application. Thanks in advance. UPDATED (thanks to Vyacheslav Egorov) I test the solution with an external array but I can't

In the V8 Javascript Engine, how do you add a FunctionTemplate as an attribute of another FunctionTemplate with the C++ API?

空扰寡人 提交于 2019-12-10 10:47:34
问题 I have a function set up to return a wrapped C++ object when called as new MyClass(); but I want to also be able to say MyClass.do_something(); I know how to do what I want in pure javascript: MyClass.prototype = { do_something: function(){}}; but how do I do the same in C++? I'm aware of the InstanceTemplate() and PrototypeTemplate() methods on v8::FunctionTemplate, but those seem to only be used in the creation of the new object returned when new MyClass() is called. How do I get at the

简单示例:NodeJs连接mysql数据库

拥有回忆 提交于 2019-12-10 10:43:56
开篇引用网上的说法: 简单的说 Node.js 就是运行在服务端的 JavaScript。Node.js 是一个基于Chrome JavaScript 运行时建立的一个平台。Node.js是一个事件驱动I/O服务端JavaScript环境,基于Google的V8引擎,V8引擎执行Javascript的速度非常快,性能非常好。 关于常见的五种I/O模型,大家可以自行搜索了解。 下面的示例,是基于NodeJS+express而做的。 NodeJs环境的安装在此不做陈述。下面假设你已经安装了NodeJS环境。然后通过 npm install express --save 示例代码如下: var mysql=require('mysql'); var express=require('express'); var app=express(); app.get('/getCode',function(req,res){ var connection = mysql.createConnection({ host : 'localhost', user : 'root', password : '******', database : 'codedb' }); connection.connect(); connection.query('SELECT * from sfk_acm_code'