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
28
votes
4 answers

Relationship between event loop,libuv and v8 engine

I am learning through the architecture of Node.js. I have following questions. Is event loop a part of libuv or v8? Is event queue a part of event loop? are event queue generated by libuv or v8 engine or event loop itself? What is the connection…
Prem
  • 5,685
  • 15
  • 52
  • 95
28
votes
4 answers

JavaScript constructs/patterns to avoid on iOS Safari?

I have a web app that contains a huge amount of generated JavaScript. The memory consumption differs by a factor 6 between running the web app in Chrome on a Desktop compared to running the web app in a UIWebView on an (updated) iPad. What…
jpsecher
  • 4,461
  • 2
  • 33
  • 42
28
votes
5 answers

How can I see the machine code generated by v8?

Does anybody know how I can see the actual machine code that v8 generates from Javascript? I've gotten as far as Script::Compile() in src/api.cc but I can't figure out where to go from there.
user36128
  • 281
  • 1
  • 3
  • 3
28
votes
1 answer

What is an internal field count and what is SetInternalFieldCount used for?

I'm having trouble understanding what the SetInternalFieldCount() function actually does. In the v8 documentation the function is described as setting "the number of internal fields for objects generated from this template." Which is pretty self…
Loourr
  • 4,995
  • 10
  • 44
  • 68
28
votes
1 answer

Configuring v8's memory management to be smart for a node.js process

We run an XMPP server on node.js, on a machine with around 3.8 GB RAM. Here are the command line parameters we pass while invoking node : /opt/node/bin/node --max-old-space-size=3000 --trace-gc --trace-gc-verbose main.js However, we frequently…
Hitesh Gupta
  • 333
  • 1
  • 3
  • 8
28
votes
3 answers

Loading Node.js modules dynamically based on route

I'm doing a project in Node.js using express. Here's my directory structure: root |-start.js |-server.js |-lib/ | api/ | user_getDetails.js | user_register.js The lib/api/ directory has a number of JS files relating to the API.…
user775171
27
votes
6 answers

Increase JavaScript Heap size in create-react-app project

Node features the way to increase the heap size via passing in the --max-old-space-size command line flag. In create-react-app projects everything depends on the use of react-scripts. How can I pass in this parameter in such projects and where…
lukaswelte
  • 2,951
  • 1
  • 23
  • 45
27
votes
5 answers

Javascript eval() Exception - line number

In JavaScript I have a var str = ".a long string that contains many lines..." In case of exception that caused by eval(str); I had like to catch it and print the the line number that caused the exception. (the line internal to str..) Is it…
DuduAlul
  • 6,313
  • 7
  • 39
  • 63
27
votes
5 answers

Javascript serialization and performance with V8 and PostgreSQL

I have been experimenting with PostgreSQL and PL/V8, which embeds the V8 JavaScript engine into PostgreSQL. Using this, I can query into JSON data inside the database, which is rather awesome. The basic approach is as follows: CREATE or REPLACE…
Toby Hede
  • 36,755
  • 28
  • 133
  • 162
26
votes
3 answers

Node.js with V8 suitable for limited memory device?

Would like to know is node.js with V8 engine suitable to be deployed on limited memory device (e.g. 256mb) and running in parallel with other process. I read that it will hook up the resource of the machine. Is there way to limit the memory and…
TonyTakeshi
  • 5,869
  • 10
  • 51
  • 72
26
votes
4 answers

Fastest possible Javascript object serialization with Google V8

I need to serialize moderately complex objects with 1-100's of mixed type properties. JSON was used originally, then I switched to BSON which is marginally faster. Encoding 10000 sample objects JSON: 1807mS BSON: 1687mS MessagePack:…
user172783
26
votes
4 answers

Compile JavaScript to Native Code with V8

Is it really possible, with Google's V8 Engine, to compile JavaScript into Native Code, save it as a binary file, and execute it whenever I want through my software envorinment, on any machine?
Alon Gubkin
  • 56,458
  • 54
  • 195
  • 288
26
votes
2 answers

Throwing a JavaScript exception from C++ code using Google V8

I'm programming a JavaScript application which accesses some C++ code over Google's V8. Everything works fine, but I couldn't figure out how I can throw a JavaScript exception which can be catched in the JavaScript code from the C++ method. For…
Etan
  • 17,014
  • 17
  • 89
  • 148
25
votes
3 answers

Why is LIBUV needed in Node JS?

So, maybe this question is too noob and novice to be asked but I still have no clue why LIBUV got a place in Node JS Architecture? So here is my understanding of NodeJs architecture. Node Js is built over V8 V8 is capable of running code written…
Ankur Verma
  • 5,793
  • 12
  • 57
  • 93
25
votes
5 answers

Is JSON.stringify() deterministic in V8?

I've not seen (yet?) JSON.stringify to be non-deterministic in Node.JS. There is no guarantee it to be deterministic on the specification level. But what about V8; Is its implementation there deterministic? Is there a guarantee for it to remain…
brillout
  • 7,804
  • 11
  • 72
  • 84