embedded-v8

How to build V8 without “external startup data”?

前提是你 提交于 2019-12-06 13:46:04
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=`pwd`/depot_tools:"$PATH" fetch v8 gclient sync cd v8 git checkout branch-heads/5.1 # ... modifying gyni

Rubyracer (V8 binding for Ruby) performs really slow

折月煮酒 提交于 2019-12-06 13:02:41
So, I have a TCP server in eventmachine and therubyracer is used as a way to pre-pend operations (like filters or extensions) to the server. It all works charming when the server is not receiving a lot of data, but when it's being flooded (it is required sometimes) it becomes really slow. So, I did a small benchmark to see how slower the rubyracer is compared to Ruby, and I was shocked when I saw the results: user system total real V8: 0.060000 0.000000 0.060000 ( 0.059903) Ruby: 0.000000 0.000000 0.000000 ( 0.000524) I don't mind if it's slow, to be honest, but I don't want it to lock up my

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

血红的双手。 提交于 2019-12-05 17:42:11
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, NULL) == 0) { printf("Failed to set hook\n"); } else { printf("Hook established\n"); } g->RunScript

Use of TerminateExecution in V8

北慕城南 提交于 2019-12-04 19:29:20
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 v8::V8::TerminateExecution( tid ); //and terminate it } int main( int argc, char **argv ) { if( argc !=

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

Perl: Javascript::V8 templates - from the perl

喜你入骨 提交于 2019-12-03 12:49:41
问题 Looking for template engine like HTML::Mason (or Mason), so what "compiles" source components into perl code, but instead of perl-code will "compile" components into JavaScript code and after run/execute them with Javascript::V8 perl module. Motivation: Looking for solution for safe template language, what can edit users without compromising the server security . JavaScript is full featured language so using it is probably better/faster than some "mini languages" like TT or similar. The best

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

How to embed V8 in a Java application?

吃可爱长大的小学妹 提交于 2019-12-03 03:56:48
问题 I'm looking for a solution for embedding the Google JavaScript engine V8 in my Java application. Have you got some solutions? 回答1: You can use J2V8 https://github.com/eclipsesource/J2V8. It's even available in Maven Central. Below is a Hello, World! program using J2V8. package com.example; import com.eclipsesource.v8.V8; public class EclipseCon_snippet5 { public static class Printer { public void print(String string) { System.out.println(string); } } public static void main(String[] args) {

Perl: Javascript::V8 templates - from the perl

女生的网名这么多〃 提交于 2019-12-03 03:15:16
Looking for template engine like HTML::Mason (or Mason), so what "compiles" source components into perl code, but instead of perl-code will "compile" components into JavaScript code and after run/execute them with Javascript::V8 perl module. Motivation: Looking for solution for safe template language, what can edit users without compromising the server security . JavaScript is full featured language so using it is probably better/faster than some "mini languages" like TT or similar. The best for me would be an extension (rewrite) of Mason for compiling into Joose/JavaScript instead of Moose

Access the Abstract Syntax Tree of V8 Engine

自闭症网瘾萝莉.ら 提交于 2019-12-03 00:21:22
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. 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 native code. You need to write a class that inherits from AstVisitor then you can inspect the AST by inserting