JavaScript的透明对象代理
Transparent Object Proxies for JavaScript
摘要:
代理是对象适应的瑞士军刀。它们引入了一定程度的间接性来拦截目标对象上的选择操作,并将它们作为方法调用转移到处理程序。代理有许多用途,如实现访问控制,强制执行合同,虚拟化资源。代理API设计中的一个重要问题是代理对象是否应该继承其目标的标识。显然,代理应该有自己的身份安全相关的应用程序,而其他应用程序,特别是合同系统,需要透明的代理,比较等于他们的目标对象。我们研究了代理的各种用例中的透明性问题,讨论了获得透明性的不同方法,并提出了两种需要在JavaScript引擎中进行适度修改并且程序员无法绕过的设计。我们在SpiderMonkey JavaScript解释器和字节码编译器中实现了我们的设计。我们的评估表明,这些修改对JavaScript引擎的基准性能没有统计上的显著影响。此外,我们证明,合同系统的包装需要透明的代理,以避免干扰程序执行在现实的设置。
英文摘要:
Proxies are the swiss army knives of object adaptation. They introduce a level of indirection to intercept select operations on a target object and divert them as method calls to a handler. Proxies have many uses like implementing access control, enforcing contracts, virtualizing resources. One important question in the design of a proxy API is whether a proxy object should inherit the identity of its target. Apparently proxies should have their own identity for security-related applications whereas other applications, in particular contract systems, require transparent proxies that compare equal to their target objects. We examine the issue with transparency in various use cases for proxies, discuss different approaches to obtain transparency, and propose two designs that require modest modifications in the JavaScript engine and cannot be bypassed by the programmer. We implement our designs in the SpiderMonkey JavaScript interpreter and bytecode compiler. Our evaluation shows that these modifications of have no statistically significant impact on the benchmark performance of the JavaScript engine. Furthermore, we demonstrate that contract systems based on wrappers require transparent proxies to avoid interference with program execution in realistic settings.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。