v8

How can I debug J2V8/node.js when running within JVM?

∥☆過路亽.° 提交于 2019-12-11 04:40:26
问题 Typically, I use node inspector (https://github.com/node-inspector/node-inspector) to debug node.js. Can this be used to attach to a remote node.js instance running in the JVM via J2V8? Also, it looks like the dev version of node.js supports native Chrome debugging: https://github.com/nodejs/node/pull/6792. If J2V8 adopts this version of node.js, will I be able to simply attach the Chrome debugger directly to the JVM? 回答1: If the question is still relevant - I have created j2v8-debugger

Invoking some callback function twice leads to Segmentation fault: Nan

六眼飞鱼酱① 提交于 2019-12-11 03:35:16
问题 I am writing C++ addon using nbind - GitHub link for most thing and Nan - GitHub link for calling callbacks asynchronous. When I invoke callback only once, it works perfect. But When I invoke callback twice it gives Segmentation fault (core dumped) . Couldn't find error using gdb . Here is JS and C++ codes(compiling using node-gyp configure build ): //main.js code var nbind = require('nbind'); var lib = nbind.init().lib; lib.HeaderExample.callJS(function(a) { console.log("result" + a); });

Linking To V8 Snapshot

若如初见. 提交于 2019-12-11 02:58:39
问题 I'm trying to link to a V8 library (v8_base.lib) that I've compiled in Visual Studio 2008 with the /MDd option. When I link to it from another library I get errors like: Error 4 error LNK2001: unresolved external symbol "private: static int const v8::internal::Snapshot::size_" (?size_@Snapshot@internal@v8@@0HB) v8_base.lib myapp How can I resolve these issues? (List of all errors) Error 1 error LNK2019: unresolved external symbol "public: static int __cdecl v8::internal::NativesCollection<0>:

if some function is not optimized does it mean that all functions where it is declared are not optimized either?

若如初见. 提交于 2019-12-11 02:34:53
问题 Recently I encountered this article optimization killers about the V8 engine's optimization of JavaScript programs. But the article is not completely clear to me, so I would like to ask a couple of question about this stuff. The article states: Code compiled by the optimizing compiler can easily be, say, 100x faster than the code generated by the generic compiler... It is important to note that patterns that cause optimization bailouts affect the entire containing function. Does this mean

Why the prototype can be retrieved but the __proto__ is undefined in JavaScript?

*爱你&永不变心* 提交于 2019-12-11 02:18:24
问题 Now I am learning JavaScript prototype and __proto__ , and find several useful links __proto__ VS. prototype in JavaScript How does __proto__ differ from constructor.prototype? I can get the value of __proto__ of object f in the following codes under Chrome. var Foo = function() {} var f = new Foo(); f.__proto__ > Foo {} However, after setting the Foo.prototype.__proto__ to null , the value of __proto__ is undefined . var Foo = function() {} Foo.prototype = {name: 'cat', age: 10}; Foo

How do I prevent malicious javascript in V8 (with Python)

我的梦境 提交于 2019-12-11 01:17:45
问题 I'm using PyV8 to run untrusted javascript. How can I detect and kill javascript that has inifinite, or long running loops in it? I'd like to tell v8 to run javascript and fail with a timeout if it's not finished in 0.1 of a second. 回答1: if it's python, you can use Interrupting cow: from interruptingcow import timeout try: with timeout(5, exception=RuntimeError): # perform a potentially very slow operation pass except RuntimeError: print "didn't finish within 5 seconds" https://bitbucket.org

How to correctly use Context::Scope ?

99封情书 提交于 2019-12-11 00:55:48
问题 How to correctly use Context::Scope ? Do i allocate it while within a method/function scope while actually executing something or can i have a global copy of it next to the Context object ? The documentation isn't very clear on that. I want to make a global Application class and keep all the persistent stuff there not sure if i can put context scope there. 回答1: Context::Scope has to be allocated on the call stack outside of your call chain. What you want to do is use a Persistent<Context> to

Does V8 cache compiled regular expressions automatically?

☆樱花仙子☆ 提交于 2019-12-11 00:01:25
问题 So I know that in Javascript instantiating a regex causes it to be compiled automatically and if that regex is stored in a variable it will be reused without recompiling. Example: var re = /[Ff]oo|[Bb]ar/; "Foo".match(re); // ["Foo"] "Baz".match(re); // null However, are duplicated regular expressions recompiled or does V8 (Chrome/Node.js) intelligently re-use them (like PHP does with preg_* functions)? function isFooBar(str) { return str.match(/[Ff]oo|[Bb]ar/); } isFooBar("Foo"); // ["Foo"]

Will new Date().toJSON() always be unique in Javascript?

Deadly 提交于 2019-12-10 22:17:10
问题 The PouchDB Manual suggests using Date().toJSON() to generate a new id for each document. Do all javascript runtimes guarantee that Date().toJSON() will always be unique? 回答1: The dates only have microsecond precision, so there's no guarantee they will be unique. The snippet below will give you a number of duplicates in all but the slowest runtime environments: for (let i = 0; i < 10; i++) { console.log(new Date().toJSON()) } 回答2: In case of distributed system, We can also use this eventid

why it possible to use destructuring assignment in React Native?

故事扮演 提交于 2019-12-10 19:25:57
问题 In the example of react native tutorial, I find syntax which is defined in ECMAScript 2015 (ES6) standard called Destructuring assignment. But as I know, iojs and nodejs do not support this syntax. How can I use it in React Native? 回答1: You are right nodejs and iojs do not support ES6 syntax. But react native: As of version 0.5.0, React Native ships with the Babel JavaScript compiler. Read more here That means that there is another transpiler (Babel) at work in the React packager. It converts