v8

Tail Call Optimization implementation in Javascript Engines

拈花ヽ惹草 提交于 2019-12-22 04:47:12
问题 As of February 2019 in Chrome Version 71.0.3578.98 on Mac , the following program throws Uncaught RangeError: Maximum call stack size exceeded error. at a count of 16516 . const a = x => { console.log(x) a(x + 1) } a(1) I've done quite a bit of Googling, but wasn't able to find any articles discussing Chrome or other browser support for Tail Call Optimization (TCO) or any future plans to implement it. My two questions are: Is TCO currently supported in Chrome or any other browser or

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

Understanding String heap size in Javascript / V8

久未见 提交于 2019-12-21 16:18:08
问题 Does anyone have a good understanding/explanation of how the heap size of strings are determined in Javascript with Chrome(V8)? Some examples of what I see in a heap dump: 1) Multiple copies of an identical 2 character strings (ie. "dt") with different @ object Ids all designated as OneByteStrings. The heapdump says each copy has a shallow & retained size of 32 bytes. It isn't clear how a two byte string has a retained size of 32 and why the strings don't appear to be interned. 2) Long object

Understanding String heap size in Javascript / V8

人盡茶涼 提交于 2019-12-21 16:18:08
问题 Does anyone have a good understanding/explanation of how the heap size of strings are determined in Javascript with Chrome(V8)? Some examples of what I see in a heap dump: 1) Multiple copies of an identical 2 character strings (ie. "dt") with different @ object Ids all designated as OneByteStrings. The heapdump says each copy has a shallow & retained size of 32 bytes. It isn't clear how a two byte string has a retained size of 32 and why the strings don't appear to be interned. 2) Long object

Does the .pipe() perform a memcpy in node.js?

妖精的绣舞 提交于 2019-12-21 04:18:20
问题 This is a conceptual query regarding system level optimisation. My understanding by reading the NodeJS Documentation is that pipes are handy to perform flow control on streams. Background: I have microphone stream coming in and I wanted to avoid an extra copy operation to conserve overall system MIPS. I understand that for audio streams this is not a great deal of MIPS being spent even if there was a memcopy under the hood, but I also have an extension planned to stream in camera frames at

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'

Fix therubyracer/libv8 (0.12.1) installation on Mavericks

白昼怎懂夜的黑 提交于 2019-12-20 11:13:54
问题 OK, I’m at the end of my tether with this. There are a few similar questions but they all refer to therubyracer 0.10, and they mostly conclude that the problem can be fixed by upgrading to 0.12. I’m having similar problems, but when I use 0.12. Similar questions Installing libv8 gem on Mavericks How to fix libv8 error from Gemfile on Mavericks? I’m having problems using ‘standard’ (xcode?) gcc, and both apple-gcc42 and gcc from homebrew. I’ve tried both --with-system-v8 and --without-system

Dumping whole array: console.log and console.dir output “… NUM more items]”

妖精的绣舞 提交于 2019-12-20 10:32:07
问题 I am trying to log a long array so I can copy it quickly in my terminal. However, if I try and log the array it looks like: ['item', 'item', >>more items<<< ... 399 more items ] How can I log the entire array so I can copy it really quickly? 回答1: Setting maxArrayLength There are a few methods all of which require setting maxArrayLength which otherwise defaults to 100. Provide the override as an option to console.log or console.dir console.log( myArry, {'maxArrayLength': null} ); Set util

What is the relationship between Node.js and V8?

岁酱吖の 提交于 2019-12-20 08:56:37
问题 I've been thinking about this question for a while and can't seem to find the answer. What is the relationship between Node.js and V8? and Can Node.js work without V8? 回答1: What is the relationship between Node.js and V8? V8 is the Javascript engine inside of node.js that parses and runs your Javascript. The same V8 engine is used inside of Chrome to run javascript in the Chrome browser. Google open-sourced the V8 engine and the builders of node.js used it to run Javascript in node.js. Can

Working with arrays in V8 (performance issue)

依然范特西╮ 提交于 2019-12-20 08:37:50
问题 I tried next code (it shows similar results in Google Chrome and nodejs): var t = new Array(200000); console.time('wtf'); for (var i = 0; i < 200000; ++i) {t.push(Math.random());} console.timeEnd('wtf'); wtf: 27839.499ms undefined I also runned next tests: var t = []; console.time('wtf'); for (var i = 0; i < 400000; ++i) {t.push(Math.random());} console.timeEnd('wtf'); wtf: 449.948ms undefined var t = []; console.time('wtf'); for (var i = 0; i < 400000; ++i) {t.push(undefined);} console