发明名称 Binding-based characterization of closures in software programs
摘要 The disclosed embodiments provide a system that facilitates the compilation and execution of a software program. During operation, the system obtains a closure from source code for the software program. Next, the system characterizes a type of the closure based on a mutability of one or more variables captured by the closure. Finally, the system encodes the type into a compiled form of the closure to facilitate subsequent execution of the closure in a multithreaded environment.
申请公布号 US9465627(B2) 申请公布日期 2016.10.11
申请号 US201113028111 申请日期 2011.02.15
申请人 ORACLE INTERNATIONAL CORPORATION 发明人 Goetz Brian;Buckley Alexander R.
分类号 G06F9/45;G06F9/44 主分类号 G06F9/45
代理机构 Park, Vaughan, Fleming & Dowler LLP 代理人 Park, Vaughan, Fleming & Dowler LLP ;Suen Chia-Hsin
主权项 1. A method, comprising: detecting, by computer, a closure from source code for a software program; characterizing a type of the closure based on: whether the closure captures any variables; andif the closure captures one or more variables, a mutability of the one or more variables captured by the closure; based on the characterization of the type, selecting, from a plurality of markers, a marker to encode the type into a compiled form of the closure, wherein the marker is one of an interface that corresponds to the type, a class that corresponds to the type, and a trait that corresponds to the type; and while executing a compiled form of the source code in a multithreaded environment, preventing an unsafe concurrent execution of the compiled form of the closure when the selected marker indicates that the closure captures at least one mutable variable; wherein the closure is characterized as a first type if the closure does not capture any variables; wherein the closure is characterized as a second type if the closure captures only immutable variables, wherein the first type and the second type permit safe concurrent execution of the closure in the multithreaded environment; and wherein the closure is characterized as a third type if the closure captures one or more mutable variables.
地址 Redwood Shores CA US
您可能感兴趣的专利