Questions tagged [v8]

V8 is Google's open source JavaScript engine.

About V8

V8 is Google's Javascript engine that is used in Google Chrome (). It is written in C++ (), and is open source, which can be checked out by following the instructions on the v8 wiki.

V8 can run standalone, or can be embedded into C++ applications.

Documentation on V8 can be found on its wiki pages.

There are a number of flags that can be passed to V8 to expose its internals. For instance, --trace-deopt gets V8 to log code deoptimizations, and --expose-gc allows scripts to manually invoke a garbage collection. The full list of flags can be found by reading the source.

Links:

Tag Usage

Use this tag to ask questions about:

  • Usage of the V8 API
  • Performance and profiling with V8
  • How V8 works
2955 questions
1
vote
0 answers

Magick++/NAPI module memory leak

I'm writing a native module using node-addon-api that takes advantage of the Magick++ library. The module takes a file path to an image alongside some parameters and returns a buffer. I seem to have come across a pretty bad memory leak issue which…
Essem
  • 311
  • 2
  • 11
1
vote
3 answers

Why async/await performs better than threads if it is just a wrapper around them?

This topic was on my mind for a long time. Let's assume we have a typical web server, one in Node.js and the other in Java(or any other language with threads). Why would node perform better (handle more IO/network based requests per second) than a…
Two Horses
  • 1,401
  • 3
  • 14
  • 35
1
vote
2 answers

Why is if(1) faster than if(true)

I'm trying to make Conway's game of life in JavaScript and canvas, I have a matrix of 1280x720 that I use to store cells data, I'm currently storing the data as 1 = alive, 0 = dead, and then when I check if a cell is alive or not I simply do:…
Specy
  • 189
  • 2
  • 13
1
vote
1 answer

no suitable constructor exists to convert from "v8::Array *" to "v8::Local"

I am trying to cast the arguments passed to my C++ addon into arrays but I am running into the error in the title. This is my code: #include "node.h" #include "node_buffer.h" #include "v8.h" using namespace v8; using namespace std; namespace…
RDK961
  • 41
  • 6
1
vote
1 answer

v8 closures of promises questions on comment in source code

Was just looking at the v8 compiler specifically the line in promise-all-element-closure.tq : and I came across the lines. // Promise.allSettled, for each input element, has both a resolve and a // reject closure that share an…
foo_barbaz
  • 15
  • 3
1
vote
1 answer

Confusing explanation of DOM wrappers in v8 engine

I was trying to learn the design of why V8 API is structured the way it is and found a helpful doc as to relationship between various things like isolates, contexts etc: Link to V8 Binding There, I am confused by a certain paragraph: For…
Anurag Kalia
  • 4,668
  • 4
  • 21
  • 28
1
vote
1 answer

Undefined reference to v8 when linking c++ node addon using gyp

I'm trying to build a node addon using the opencv library. I'm compiling it using node-gyp. I've achieved to link opencv using the binding.gyp config file, but I have some issues with the v8 library. Here is my binding.gyp file: "targets": [ …
Lucas Gras
  • 961
  • 1
  • 7
  • 22
1
vote
0 answers

Node - "Unable to deserialize cloned data" when serializing multiple values

I want to implement a custom serializer for my class so I can use it for networking. However, d.readValue throws an error: "Unable to deserialize cloned data." Error: Unable to deserialize cloned data. at…
nathanfranke
  • 775
  • 1
  • 9
  • 19
1
vote
1 answer

Are Node.js buffers in C++ addon null terminated?

I am trying to create buffer in a .js file, and then passing that buffer to a c++ addon where I will call a Windows API. In the c++ addon I have: auto buf = node::Buffer::Data(args[0]); auto len = node::Buffer::Length(args[0]); Are there any…
seb35
  • 11
  • 1
1
vote
1 answer

'marking' an object for garbage collection in NodeJS

I'm working with some code in NodeJS, and some objects (i.e, 'events') will be medium-lived, and then discarded. I don't want them becoming a memory burden when I stop using them, and I want to know if there is a way to mark an object to be…
1
vote
0 answers

How to manage critical resources with embedded JavaScript in V8

In v8.h, the in-source documentation for Persistent::SetWeak says: As always, GC-based finalization should *not* be relied upon for any critical form of resource management! This suggests that if it is a critical resource, then you can't manage it…
Wyck
  • 10,311
  • 6
  • 39
  • 60
1
vote
1 answer

Can we use Chrome V8 functionalities from GAS?

Since Apps Script runs in Chrome V8 engine, would it be possible to use any of V8 functionalities from Apps Script? I was wondering if it will be possible to build tools like headless browser, webpage screenshot, etc using Apps Script. I haven't…
Severus Snape
  • 172
  • 1
  • 2
  • 12
1
vote
1 answer

How to detect a word on Safari using js?

In Chrome, Intl.v8BreakIterator works fine. Is there an alternative for this API on Safari?
1
vote
1 answer

Run A Function Right Before Nodejs Crashes Due to OOM

Is it possible to force a Node.js app to run a function (i.e. send an API call) right before it crashes due to OOM? I am trying to log the timestamps of OOM crashes, but this requires the ability to run a function right before the process gets…
Athena Wisdom
  • 6,101
  • 9
  • 36
  • 60
1
vote
1 answer

Inconsistent performance of Google's V8 executing WebAssembly

I'm trying to execute a rather trivial WebAssembly benchmark with Google's V8 engine (both in-browser using the current Version of Google Chrome (Version 83.0.4103.106, 64-bit) and via embedding V8 (Version 8.5.183) in a C++ program. All benchmarks…
fscheidl
  • 2,281
  • 3
  • 19
  • 33