embedded-v8

How to build V8 without “external startup data”?

99封情书 提交于 2020-01-02 09:09:13
问题 I want a standalone JavaScript library for embedding. I already build V8 and its working correctly, but binary needs two "external data" files. I don want this files. I was trying to build V8 without "external startup data". I tried to set v8_use_external_startup_data : 0, in build.common.gypi and build/standalone.gypi, but then make is reporting failure at some point. I'm using following code to build v8: git clone https://chromium.googlesource.com/chromium/tool/depot_tools.git export PATH=

SetInternalFieldCount on constructor->InstanceTemplate() did not work for the instantiated object

吃可爱长大的小学妹 提交于 2019-12-25 00:52:53
问题 This post is about exposing C++ objects to the v8 javascript engine. To attach a C++ object to a javascript object, I make use of the GetInternalField() and External APIs. Before you can set or get any internal field, you have to call SetInternalFieldCount() on the corresponding ObjectTemplate . Since I want to expose a constructor function to the JS, I created a FunctionTemplate , set a C++ function that attache the native object to the JS object to that template, and finally

Use of TerminateExecution in V8

本小妞迷上赌 提交于 2019-12-22 00:43:04
问题 I'm experimenting with V8 at the moment. I want to be able to run some (possibly long-running) javascript in one thread and then be able to terminate the execution "gracefully" at will from another thread. I've written this simple snippet to test the concept of Lockers and the usage of TerminateExecution: void breaker( Isolate* isolate, int tid ) { getchar(); //wait for keyboard input on stdin std::cout << "Breaking V8 execution" << std::endl; v8::Locker locker( isolate ); //lock the isolate

Why does v8 saves the source code of native javascript in generated binaries?

空扰寡人 提交于 2019-12-20 14:36:20
问题 I've been studying the v8 source, particularly at how the 'mksnapshot' tool includes a compiled image of the native javascript files(runtime.js, json.js...) in the v8 binaries and noticed that it also includes a (somewhat) minified version of the source. For example, when inspecting the contents of the d8 executable, I see the following snippet: var $JSON=global.JSON; function Revive(a,b,c){ var d=a[b]; if((%_IsObject(d))){ if((%_IsArray(d))){ var g=d.length; and at the start of 'src/json.js'

Installing PHPv8js on Ubuntu

◇◆丶佛笑我妖孽 提交于 2019-12-18 03:36:04
问题 I'm having some trouble installing phpv8js on Ubuntu. I've made sure I have a recent version of libv8 installed and have the required version of PHP but the install fails using PECL. Here's the output: libtool: compile: g++ -I. -I/tmp/pear/temp/v8js -DPHP_ATOM_INC -I/tmp/pear/temp/pear-build-rootFyySRS/v8js-0.1.2/include -I/tmp/pear/temp/pear-build-rootFyySRS/v8js-0.1.2/main -I/tmp/pear/temp/v8js -I/usr/include/php5 -I/usr/include/php5/main -I/usr/include/php5/TSRM -I/usr/include/php5/Zend -I

Can't access V8 Context in “callback” function

我的梦境 提交于 2019-12-13 00:15:16
问题 I am writing a NodeJS addon where I use a C library that lets you register a callback at certain events. When the callback is fired I want to call a NodeJS callback function. The problem is that in my C callback function I get a segmentation fault when trying to do anything V8 related, like creating a HandleScope. In test.js: ... myaddon.register(function(data) { console.log("data: " + JSON.stringify(data)); }); ... In test.c: #include <stdlib.h> #include <stdio.h> #include <string.h>

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

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

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

喜你入骨 提交于 2019-12-09 19:08:46
问题 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

C++ Console app, SetWindowsHookEx, Callback is never called

橙三吉。 提交于 2019-12-07 11:43:41
问题 I have a little console application that has an embedded v8 engine, and I would like to add a hook to register key events. This all worked before when I was using Qt and QtScript, but I am porting it all over to straight C++ in VC++ 2008. The application compiles and runs, but the hook is never called, here is the relevant code: In main() HWND hwndC = GetConsoleWindow() ; HINSTANCE hInst = (HINSTANCE)GetWindowLong( hwndC, GWL_HINSTANCE ); if (SetWindowsHookEx(WH_KEYBOARD_LL, HookProc, hInst,