如何获取JavaScript变量的内存地址? [英] How can I get the memory address of a JavaScript variable?
问题描述
是否可以找到JavaScript变量的内存地址? JavaScript代码是普通应用程序的一部分(嵌入),其中JavaScript用作C ++的前端,不能在浏览器上运行。使用的JavaScript实现是SpiderMonkey。
Is it possible to find the memory address of a JavaScript variable? The JavaScript code is part of (embedded into) a normal application where JavaScript is used as a front end to C++ and does not run on the browser. The JavaScript implementation used is SpiderMonkey.
推荐答案
如果可能的话,它将非常依赖于javascript引擎。更现代的javascript引擎使用及时编译器编译他们的代码并且弄乱他们的内部变量会对性能有害,或者对稳定性不利。
If it would be possible at all, it would be very dependent on the javascript engine. The more modern javascript engine compile their code using a just in time compiler and messing with their internal variables would be either bad for performance, or bad for stability.
如果引擎允许它,为什么不为一些本机代码创建一个函数调用接口来交换变量的值?
If the engine allows it, why not make a function call interface to some native code to exchange the variable's values?
这篇关于如何获取JavaScript变量的内存地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!