v8

how to send string data into a javascript?

天大地大妈咪最大 提交于 2020-01-05 14:17:46
问题 I am using v8 and i faced next problem - i have an application which running a javascript file ( i simply read it into a string and than execute with Local<String> source = String::New(javascript); //javascript is string with js file Local<Script> script = Script::Compile(source); Local<Value> result = script->Run(); how can I send a string variable into this file? 回答1: Put a placeholder in the script source, like STRING_HERE . Then, before creating the source object, find that placeholder in

Calling V8 function causes access violation

本小妞迷上赌 提交于 2020-01-05 10:18:52
问题 I have a global event manager, allowing you to listen with lambdas to string event names. // somewhere in the ModuleScript class Event->Listen("WindowResize", [=]{ // ... }); Now, I want to register to events from JavaScript, too. Therefore, I wrote this callback. v8::Handle<v8::Value> ModuleScript::jsOn(const v8::Arguments& args) { // get pointer to class since we're in a static method ModuleScript *module = (ModuleScript*)HelperScript::Unwrap(args.Data()); // get event name we want to

How does V8 manage its heap?

可紊 提交于 2020-01-05 10:09:52
问题 I know when V8's Garbage Collection is working, it will trace from GC's root so that unreachable objects will be marked and then be swept. My question is how GC traverses traverse those objects? There must be a data structure to store all objects reachable or unreachable. Bitmap? Linked table? BTW, does JVM do the same? 回答1: AllenShow, Google's V8 Heap is organized into a couple of different spaces. There's a great post, "A tour of V8: Garbage Collection" which explains how the V8 heap is

Is it possible to see the values of browser based javascript variables in a web application that is not our own?

天大地大妈咪最大 提交于 2020-01-05 06:13:12
问题 This is related to this security question regarding what it is that secures credentials inside a single page webapp. Suppose we are using an app that is not ours and uses JWT Tokens for security. Are we able to log the contents through browser developer tooling or otherwise of the variables that the app uses for state. Specifically could someone log or see the contents of the JWT token that the user obtained post authentication? 回答1: Yes, it's entirely possible. Any user can just open the

V8 isolates mapped memory leaks

倾然丶 夕夏残阳落幕 提交于 2020-01-05 03:36:34
问题 V8 developer is needed. I've noticed that the following code leaks mapped memory (mmap, munmap), concretely the amount of mapped regions within cat /proc/<pid>/maps continuously grows and hits the system limit pretty quickly ( /proc/sys/vm/max_map_count ). void f() { auto platform = v8::platform::CreateDefaultPlatform(); v8::Isolate::CreateParams create_params; create_params.array_buffer_allocator = v8::ArrayBuffer::Allocator::NewDefaultAllocator(); v8::V8::InitializePlatform(platform); v8:

Node.js和Chrome V8 引擎了解

左心房为你撑大大i 提交于 2020-01-05 02:58:20
说起Node就不得不先介绍一个Chrome V8 引擎。 随着Web相关技术的发展,JavaScript所要承担的工作也越来越多,早就超越了“表单验证”的范畴,这就更需要快速的解析和执行JavaScript脚本。 而JavaScript本质上是一种解释型语言,与编译型语言不同的是它需要边执行边解析,而编译型语言在执行时已经完成编译,可直接执行,有更快的执行速度。V8引擎就是为解决这一问题而生,在node中也是采用该引擎来解析JavaScript。 V8引擎是一个JavaScript引擎实现,最初由一些语言方面专家设计,后被谷歌收购,随后谷歌对其进行了开源。V8使用C++开发,,在运行JavaScript之前,相比其它的JavaScript的引擎转换成字节码或解释执行,V8将其编译成原生机器码(IA-32, x86-64, ARM, or MIPS CPUs),并且使用了如内联缓存(inline caching)等方法来提高性能。有了这些功能,JavaScript程序在V8引擎下的运行速度媲美二进制程序。V8支持众多操作系统,如windows、linux、android等,也支持其他硬件架构,如IA32,X64,ARM等,具有很好的可移植和跨平台特性。 另外,JavaScript引擎的执行过程大致是: 源代码-→抽象语法树-→字节码-→JIT-→本地代码(V8引擎没有中间字节码)

V8 JavaScript Object vs Binary Tree

北城余情 提交于 2020-01-04 06:09:39
问题 Is there a faster way to search data in JavaScript (specifically on V8 via node.js , but without c/c++ modules) than using the JavaScript Object ? This may be outdated but it suggests a new class is dynamically generated for every single property. Which made me wonder if a binary tree implementation might be faster, however this does not appear to be the case. The binary tree implementation isn't well balanced so it might get better with balancing (only the first 26 values are roughly

When I execute a simple JS function twice in a row, does it cost twice the computing power?

瘦欲@ 提交于 2020-01-04 05:50:34
问题 A simplified example: function shorten(string) { return string.slice(0, 3); } const today = "Friday"; if (shorten(today) === "Fri") { console.log("Oh yeah it's " + shorten(today)); } shorten(today) is called twice here, which makes me feel bad. I believe we all run into this situation every day, and what we do is store the the value of shorten(today) in a variable first, then use that variable twice. My question is: are modern JS engines smart enough so that I actually don't need to worry

Rubyracer (V8 binding for Ruby) performs really slow

☆樱花仙子☆ 提交于 2020-01-02 14:12:55
问题 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

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=