javascript-engine

Are there ways to see the assembly code for the code generated by any of the JavaScript jits, especially V8's?

允我心安 提交于 2020-01-28 09:59:42
问题 The major JavaScript engines of web browsers and nodeJS have had just-in-time compilers for years. I was just watching a video on Compiler Explorer showing the assembly code output by many compilers for various CPUs. This reminded me that I've been curious about the code generated by the JS engines' jits. Do any of those engines have ways for us to see that low-level generated code? (If this is out of place on SO please feel free to migrate it to the correct SE site.) 回答1: For V8, there is a

How to convert type Object from engine.eval to type int

巧了我就是萌 提交于 2020-01-15 23:04:47
问题 My program takes a String input and calculates it using engine.eval() from ScriptEngine imports. How do I convert the evaluated value to type int? import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class Main { public static void main(String[] args) { String s = "206 + 4"; Object eval; ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine eng = mgr.getEngineByName("JavaScript"); try { eval = eng.eval(s); } catch

What is the complexity of retrieval/insertion in JavaScript associative arrays (dynamic object properties) in the major javascript engines?

六眼飞鱼酱① 提交于 2020-01-11 04:40:07
问题 Take the following code example: var myObject = {}; var i = 100; while (i--) { myObject["foo"+i] = new Foo(i); } console.log(myObject["foo42"].bar()); I have a few questions. What kind of data structure do the major engines (IE, Mozilla, Chrome, Safari) use for storing key-value pairs? I'd hope it's some kind Binary Search tree, but I think they may use linked lists (due to the fact iterating is done in insertion order). If they do use a search tree, is it self balancing? Because the above

JavaScript Context in HttpClient

北城以北 提交于 2020-01-07 02:22:07
问题 hi i need to Execute all the java Script on the page that i downloaded using HttpCleint Get method, which are the steps to perform the execution of the javascript containned on the page on the context of the page without loosing the connectio to the server. thx 回答1: Have a look at htmlunit don't know if you can pass your downloaded page but it can download the page it self. 来源: https://stackoverflow.com/questions/5597441/javascript-context-in-httpclient

How to detect from nodejs which JavaScript engine it is running on?

懵懂的女人 提交于 2019-12-23 10:14:24
问题 There are now several forks of nodejs and some of them support JavaScript engines other than Google's V8 engine. For my node code to see which JS engine it is running under, what is currently the best way? The engines I am aware of are: Google's V8 - The only engine supported by the official node.js and the iojs fork. One of the engines supported by JXcore . Mozilla's SpiderMonkey - One of the engines supported by JXcore . Microsoft's ChakraCore - The engine supported by Microsoft 's port of

Is there a port of the Rhino JavaScript engine for .NET

让人想犯罪 __ 提交于 2019-12-21 20:00:02
问题 I worked for a company that had both Java and .NET implementations of an application. The app allowed for end-user customization of processing and business rules using scripts. The Java version supported JavaScript using the Rhino engine. The .NET app required VBScript. I would like to do something similar using .NET, but I would prefer to use JavaScript. I have searched but I am having a hard time finding anything like Rhino that will work within the .NET runtime. Do any of you know of or

What is Javascript atomic execution unit for events?

拟墨画扇 提交于 2019-12-12 03:53:31
问题 The javascript engine is executing a function which in turn calls another function (sequentially) and this goes on for say 5s. Meanwhile, several events were triggered either by the user or programmatically. Can we take for granted that no event will be handled before the outermost function finishes? /* Example */ function outermost_function() { function inner_function () { function innermost_function () { return; } } } 回答1: Javascript is single threaded and events are queued in an event loop

“document” is not defined in <eval> java ScriptEngine

情到浓时终转凉″ 提交于 2019-12-12 02:55:34
问题 i'm trying to call document in java using scriptEngine here is my code ScriptEngineManager scriptEngineManager=new ScriptEngineManager(); ScriptEngine scriptEngine=scriptEngineManager.getEngineByName("nashorn"); scriptEngine.eval("function func(){" + "document.location.href=someUrl;" + "var text=document.getElementsByTagName('textarea')[0];"}" ); Invocable invocable= (Invocable) scriptEngine; ((Invocable) scriptEngine).invokeFunction("func"); it throws an exception javax.script

Is there a javaScript engine where I can run my code without being forced to use a browser?

微笑、不失礼 提交于 2019-12-08 16:57:03
问题 Is there any way to write and run a JavaScript code without having a need to run a browser and use its JavaScript engine? Thanks! 回答1: I am amazed no one has pointed this out yet. Windows includes a Javascript engine that can be used from the command line. All versions of Windows, since Windows 98, have included something called "The Windows Script Host". It's a windows-standard way to support script "engines". Since the first release, WSH supports JScript, Microsoft's version of Javascript.

JavaScript - Object definition available before code execution on Safari

孤街浪徒 提交于 2019-12-07 04:55:26
Objects and functions which I require only to execute once on a page load are wrapped inside an undefined check for the object. On Chrome on Windows/Linux which I usually use, the code works perfectly i.e. code only executes once. But on Safari on both iPad and MacBook, the undefined check doesn't work i.e. as per the browser, the object/function is already declared without even the code execution reaching there! I've simplified my code to only include an if loop that checks if the nested function is already declared. Since it should not have been declared the first time, I've included