JP5466601B2 - コード生成方法、システム及びプログラム - Google Patents
コード生成方法、システム及びプログラム Download PDFInfo
- Publication number
- JP5466601B2 JP5466601B2 JP2010194224A JP2010194224A JP5466601B2 JP 5466601 B2 JP5466601 B2 JP 5466601B2 JP 2010194224 A JP2010194224 A JP 2010194224A JP 2010194224 A JP2010194224 A JP 2010194224A JP 5466601 B2 JP5466601 B2 JP 5466601B2
- Authority
- JP
- Japan
- Prior art keywords
- code
- argument
- specialized
- java
- call site
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Expired - Fee Related
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
- G06F8/4441—Reducing the execution time required by the program code
- G06F8/4443—Inlining
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45516—Runtime code conversion or optimisation
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Description
Obj f(Obj a, Obj b, Obj c) {
load a
load b
invoke add(Obj,Obj)
load c
invoke sub(Obj,Obj) ..
invoke print(Obj) …
これは、わかりやすさのために擬似ソースコードで示す(以降同様)ことにすると以下のようになる。
Obj f(Obj a, Obj b, Obj c) {
print(sub(add(a,b), c)) …
Obj add(Obj x, Obj y) {
if (x instanceof Int
&& y instanceof Int) {
return new Int(
x.getInt() + y.getInt());
} else if (x instanceof Dbl ..) {
..
} else if (..) {
...
Obj sub(Obj x, Obj y) {
if (x instanceof Int
&& y instanceof Int) {
new Int(
x.getInt() - y.getInt());
} else if (x instanceof Dbl ..) {
..
} else if (..) {
...
すなわち、みなしマルチメソッド(deemed multimethods)とは、メソッド本体が以下のいずれかの条件によくあてはまるコードを含むメソッドのことである。
(a) 仮引数のオブジェクトに対してinstanceof や checkcast による実行時型検査の結果に基づいて分岐する。
(b) 仮引数のオブジェクトに対して invokevirtual や invokeinterface により、型ごとに結果が変わらない(ことの多い)メソッド呼び出しを行い、その結果に基づいて分岐する
(c) 仮引数のオブジェクトを他のみなしマルチメソッドの実引数として渡す。
実引数の型の組の出現に偏りがあらわれていれば、高頻度の型の組について、メソッドを特化し、メソッドと型の組をキーとしてキャッシュしておく。
高頻度の型の組のいくつかについて、実行時検査をして特化されたメソッドを呼び出すように、呼び出し元のコードを最適化する。
特化されたメソッドが十分小さいときにはインライン化する。
(a) 仮引数のオブジェクトに対してinstanceof や checkcast による実行時型検査の結果に基づいて分岐する。
(b) 仮引数のオブジェクトに対して invokevirtual や invokeinterface により、型ごとに結果が変わらない(ことの多い)メソッド呼び出しを行い、その結果に基づいて分岐する
(c) 仮引数のオブジェクトを他のみなしマルチメソッドの実引数として渡す。
みなしマルチメソッドの判定処理については、図4のフローチャートを参照して、後で説明する。
dup2
instanceof Int
ifeq NOT_X_Int
instanceof Int
ifeq GENERAL_CALL
invoke add_Int_Int(Int,Int)
jmp END_PIC
NOT_X_Int:
pop
GENERAL_CALL:
invoke add(Obj,Obj)
END_PIC:
dup2
instanceof Int
ifeq NOT_X_Int
instanceof Int
ifeq GENERAL_CALL
invoke add_Int_Int(Int,Int)
jmp END_PIC
NOT_X_Int:
dup_x1
instanceof Str
ifeq NOT_X_Str
instanceof Int
ifeq GENERAL_CALL
invoke add_Int_Str(Int,Str)
jmp END_PIC
NOT_X_Str:
pop
GENERAL_CALL:
invoke add(Obj,Obj)
END_PIC:
Obj add(Obj x, Obj y) {
if (x instanceof Int
&& y instanceof Int) {
return new Int(
x.getInt() + y.getInt());
} else if (x instanceof Dbl ..) {
..
} else if (..) {
…
Int add_Int_Int(Int x, Int y) {
return new Int(x.val + y.val); }
これは、上記みなしマルチメソッドのコードにおいて、(x instanceof Int && y instanceof Int)という条件をみたす箇所だけを抜き出したコードであることが見て取れよう。
106 主記憶
108 ハードディスク・ドライブ
202 オペレーティング・システム
206 バイトコード生成器
208 コード変換器
402 オペレーティング・システム
406 バイトコード生成器
412 ソースコード
702 プロファイリング・テーブル
704 バイトコード
806 マルチパラメータPIC
Claims (14)
- コンピュータの処理に基づき、メソッドをインラインする機能をもつコード生成方法であって、
前記コンピュータの処理により、メソッドを含むコードを走査するステップと、
前記コンピュータの処理により、メソッドが、そのままインライン化するには大きすぎると判断した場合に、引数の実行時型に基づく分岐を含むかどうか判断するステップと、
前記メソッドが、引数の実行時型に基づく分岐を含むなら、前記コンピュータの処理により、前記メソッドのコールサイトにおける実際の引数の実行時型をプロファイルするステップと、
前記コンピュータの処理により、前記プロファイルに基づき、複数引数に基づく多相インライン・キャッシュ(PIC)コードを生成しつつ、前記PICコードから呼び出されうる、引数の実行時型の頻出する組み合わせに特化したメソッドを、生成するステップと、
前記コンピュータの処理により、前記特化したメソッドの本体のサイズの大きさが許容範囲であるなら、前記特化したメソッドの本体を、前記コールサイトにインラインするステップを含む、
方法。 - 前記プロファイルするステップが、メソッド・プロローグ計装、またはコールサイト計装のプロファイル結果からの型推論によって行われる、請求項1に記載の方法。
- 前記方法が、Java(R) VMのバイトコードを変換するJITコンパイラ上で実装された方法である、請求項1に記載の方法。
- 前記バイトコードが、Java(R) VMのバイトコードを生成する機能をもつ動的スクリプト言語処理系によって生成されたものである、請求項3に記載の方法。
- コンピュータの処理に基づき、メソッドをインラインする機能をもつコード生成プログラムであって、
前記コンピュータに、
メソッドを含むコードを走査するステップと、
メソッドが、そのままインライン化するには大きすぎると判断した場合に、引数の実行時型に基づく分岐を含むかどうか判断するステップと、
前記メソッドが、引数の実行時型に基づく分岐を含むなら、前記メソッドのコールサイトにおける実際の引数の実行時型をプロファイルするステップと、
前記プロファイルに基づき、複数引数に基づく多相インライン・キャッシュ(PIC)コードを生成しつつ、前記PICコードから呼び出されうる、引数の実行時型の頻出する組み合わせに特化したメソッドを、生成するステップと、
前記特化したメソッドの本体のサイズの大きさが許容範囲であるなら、前記特化したメソッドの本体を、前記コールサイトにインラインするステップを実行させる、
プログラム。 - 前記プロファイルするステップが、メソッド・プロローグ計装、またはコールサイト計装のプロファイル結果からの型推論によって行われる、請求項5に記載のプログラム。
- 前記プログラムが、Java(R) VMのバイトコードを変換するJITコンパイラの機能をもつ、請求項5に記載のプログラム。
- 前記バイトコードが、Java(R) VMのバイトコードを生成する機能をもつ動的スクリプト言語処理系によって生成されたものである、請求項7に記載のプログラム。
- 前記動的スクリプト言語処理系が、P8、Quercus、JRuby、Jython、及びGroovyから選ばれたものである、請求項8に記載のプログラム。
- コンピュータの処理に基づき、メソッドをインラインする機能をもつコード生成システムであって、
記憶手段と、
前記記憶手段に記憶された、メソッドを含むコードを走査する手段と、
メソッドが、そのままインライン化するには大きすぎると判断した場合に、引数の実行時型に基づく分岐を含むかどうか判断する手段と、
前記メソッドが、引数の実行時型に基づく分岐を含むなら、前記メソッドのコールサイトにおける実際の引数の実行時型をプロファイルする手段と、
前記プロファイルに基づき、複数引数に基づく多相インライン・キャッシュ(PIC)コードを生成しつつ、前記PICコードから呼び出されうる、引数の実行時型の頻出する組み合わせに特化したメソッドを、生成する手段と、
前記特化したメソッドの本体のサイズの大きさが許容範囲であるなら、前記特化したメソッドの本体を、前記コールサイトにインラインする手段を有する、
コード生成システム。 - 前記プロファイルする手段が、メソッド・プロローグ計装、またはコールサイト計装のプロファイル結果からの型推論を用いる、請求項10に記載のシステム。
- 前記コードが、Java(R) VMのバイトコードである、請求項10に記載のシステム。
- 前記インラインする手段によるインラインの後、前記バイトコードをJITコンパイルする手段をさらに有する、請求項12に記載のシステム。
- 前記コードが、Java(R) VMのバイトコードを生成する機能をもつ動的スクリプト言語処理系上のコードである、請求項12に記載のシステム。
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010194224A JP5466601B2 (ja) | 2010-08-31 | 2010-08-31 | コード生成方法、システム及びプログラム |
US13/221,171 US9235394B2 (en) | 2010-08-31 | 2011-08-30 | Method and system for code generation and inlining |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
JP2010194224A JP5466601B2 (ja) | 2010-08-31 | 2010-08-31 | コード生成方法、システム及びプログラム |
Publications (2)
Publication Number | Publication Date |
---|---|
JP2012053566A JP2012053566A (ja) | 2012-03-15 |
JP5466601B2 true JP5466601B2 (ja) | 2014-04-09 |
Family
ID=45698877
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
JP2010194224A Expired - Fee Related JP5466601B2 (ja) | 2010-08-31 | 2010-08-31 | コード生成方法、システム及びプログラム |
Country Status (2)
Country | Link |
---|---|
US (1) | US9235394B2 (ja) |
JP (1) | JP5466601B2 (ja) |
Families Citing this family (18)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
WO2007076629A1 (en) * | 2005-12-30 | 2007-07-12 | Intel Corporation | Type checking for object-oriented programming languages |
FR2961922B1 (fr) | 2010-06-29 | 2013-12-13 | Flexycore | Procede de compilation selective, dispositif et produit programme d'ordinateur correspondant. |
US20140047423A1 (en) | 2012-08-09 | 2014-02-13 | Filip J. Pizlo | Runtime State Based Code Re-Optimization |
US9552195B2 (en) * | 2013-03-08 | 2017-01-24 | Facebook, Inc. | Enlarging control regions to optimize script code compilation |
US9256398B2 (en) * | 2013-03-15 | 2016-02-09 | Fujitsu Limited | Device and method of increasing dynamically-typed software efficiency |
US9195441B2 (en) * | 2013-07-30 | 2015-11-24 | Facebook, Inc. | Systems and methods for incremental compilation at runtime using relaxed guards |
US9304748B2 (en) * | 2013-08-07 | 2016-04-05 | Qualcomm Incorporated | Method for controlling inlining in a code generator |
US9251071B2 (en) | 2013-08-30 | 2016-02-02 | Apple Inc. | Concurrent inline cache optimization in accessing dynamically typed objects |
GB2525435A (en) * | 2014-04-25 | 2015-10-28 | Ibm | Augmenting profile data with information gathered from a JIT complier |
US10025571B1 (en) | 2014-07-17 | 2018-07-17 | Google Llc | Optimized execution of dynamic languages |
US9244665B1 (en) * | 2014-07-17 | 2016-01-26 | Google Inc. | Optimized execution of dynamic languages |
US9594662B2 (en) * | 2014-08-27 | 2017-03-14 | Ca, Inc. | Automated instrumentation of applications |
US10120661B2 (en) * | 2015-07-16 | 2018-11-06 | Sugarcrm Inc. | Multi-flavored software execution from a singular code base |
US9569206B1 (en) | 2015-09-29 | 2017-02-14 | International Business Machines Corporation | Creating optimized shortcuts |
JP6863112B2 (ja) * | 2017-06-15 | 2021-04-21 | 富士通株式会社 | 情報処理装置、コンパイラ方法、およびコンパイラプログラム |
US11360976B2 (en) | 2017-08-31 | 2022-06-14 | Oracle International Corporation | Deployment of javascript and typescript stored procedures and user-defined functions into database management systems |
US10416967B2 (en) | 2017-10-13 | 2019-09-17 | Internationa Business Machines Corporation | Method of optimizing vargs in object-oriented programming languages |
US10684873B2 (en) * | 2018-06-12 | 2020-06-16 | Oracle International Corporation | Efficient data decoding using runtime specialization |
Family Cites Families (12)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5995754A (en) * | 1997-10-06 | 1999-11-30 | Sun Microsystems, Inc. | Method and apparatus for dynamically optimizing byte-coded programs |
JP2000207212A (ja) * | 1999-01-11 | 2000-07-28 | Hitachi Ltd | メソッド呼出し最適化方法,クラス推定方法,メソッド呼出し最適化装置及び記憶媒体 |
US6442752B1 (en) * | 1999-08-26 | 2002-08-27 | Unisys Corporation | Method, apparatus, and computer program product for replacing a dynamic link library (dll) of a first computing environment with a dll of a second computing environment that can be invoked from the first computing environment in a transparent manner |
US6810519B1 (en) * | 2000-09-29 | 2004-10-26 | International Business Machines Corporation | Achieving tight binding for dynamically loaded software modules via intermodule copying |
US6957423B1 (en) * | 2001-05-15 | 2005-10-18 | Xilinx, Inc. | Method of inlining a VHDL function call into Verilog |
US7171650B2 (en) * | 2002-08-23 | 2007-01-30 | Sbc Properties, L.P. | System and method for integrating resources in a network |
JP2005346407A (ja) * | 2004-06-03 | 2005-12-15 | Hitachi Ltd | 動的コンパイルにおけるインライン展開実施方法 |
JP4712512B2 (ja) | 2005-10-14 | 2011-06-29 | 富士通株式会社 | プログラム変換プログラム、プログラム変換装置、プログラム変換方法 |
US7461205B2 (en) * | 2006-06-01 | 2008-12-02 | International Business Machines Corporation | Performing useful computations while waiting for a line in a system with a software implemented cache |
US7493610B1 (en) * | 2008-03-27 | 2009-02-17 | International Business Machines Corporation | Versioning optimization for dynamically-typed languages |
US8627303B2 (en) * | 2009-11-30 | 2014-01-07 | International Business Machines Corporation | Memory optimization of virtual machine code by partitioning extraneous information |
JP5496849B2 (ja) * | 2010-10-15 | 2014-05-21 | インターナショナル・ビジネス・マシーンズ・コーポレーション | プロファイル計装方法、プログラム及びコンパイラ |
-
2010
- 2010-08-31 JP JP2010194224A patent/JP5466601B2/ja not_active Expired - Fee Related
-
2011
- 2011-08-30 US US13/221,171 patent/US9235394B2/en not_active Expired - Fee Related
Also Published As
Publication number | Publication date |
---|---|
US20120054725A1 (en) | 2012-03-01 |
US9235394B2 (en) | 2016-01-12 |
JP2012053566A (ja) | 2012-03-15 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
JP5466601B2 (ja) | コード生成方法、システム及びプログラム | |
Würthinger et al. | Self-optimizing AST interpreters | |
JP5518085B2 (ja) | ランタイムにおいて生成したコードのキャッシュへの格納 | |
JP5818695B2 (ja) | コード変換方法、プログラム及びシステム | |
EP0778521B1 (en) | System and method for runtime optimization of private variable function calls in a secure interpreter | |
US8806432B2 (en) | Method, system, and program for executing program | |
US20050060695A1 (en) | Lazy compilation of template-generated classes in dynamic compilation execution environments | |
JP4806060B2 (ja) | コンパイラ・プログラム、コンパイル方法及びコンピュータ・システム | |
JP5496849B2 (ja) | プロファイル計装方法、プログラム及びコンパイラ | |
Ortin et al. | A hybrid class-and prototype-based object model to support language-neutral structural intercession | |
KR20160003485A (ko) | 원격 함수 호출을 위한 자동 코드 생성 | |
Stepanian et al. | Inlining java native calls at runtime | |
Garcia et al. | Design and implementation of an efficient hybrid dynamic and static typing language | |
Fourtounis et al. | Deep static modeling of invokedynamic | |
Chang et al. | Efficient just-in-time execution of dynamically typed languages via code specialization using precise runtime type inference | |
Stadler et al. | Lazy continuations for Java virtual machines | |
JP5950288B2 (ja) | プログラミング言語の処理系を実現する装置及び方法 | |
Hu et al. | A static timing analysis environment using Java architecture for safety critical real-time systems | |
Mohan | Comparative Analysis Of JavaScript And WebAssembly In The Browser Environment | |
KR101024707B1 (ko) | 바이트코드-투-씨 어헤드-오브-타임 컴파일러를 위한 해석기 호출 방법 | |
Puder et al. | Towards an XML-based bytecode level transformation framework | |
Tauber et al. | Memory-Efficient tail calls in the JVM with imperative functional objects | |
Plumbridge et al. | Translating Java for resource constrained embedded systems | |
Bernstein et al. | Dr Wenowdis: Specializing dynamic language C extensions using type information | |
Melançon et al. | An Executable Semantics for Faster Development of Optimizing Python Compilers |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
A621 | Written request for application examination |
Free format text: JAPANESE INTERMEDIATE CODE: A621 Effective date: 20130501 |
|
A131 | Notification of reasons for refusal |
Free format text: JAPANESE INTERMEDIATE CODE: A131 Effective date: 20130917 |
|
A521 | Request for written amendment filed |
Free format text: JAPANESE INTERMEDIATE CODE: A523 Effective date: 20131216 |
|
TRDD | Decision of grant or rejection written | ||
A01 | Written decision to grant a patent or to grant a registration (utility model) |
Free format text: JAPANESE INTERMEDIATE CODE: A01 Effective date: 20140107 |
|
A61 | First payment of annual fees (during grant procedure) |
Free format text: JAPANESE INTERMEDIATE CODE: A61 Effective date: 20140124 |
|
R150 | Certificate of patent or registration of utility model |
Ref document number: 5466601 Country of ref document: JP Free format text: JAPANESE INTERMEDIATE CODE: R150 Free format text: JAPANESE INTERMEDIATE CODE: R150 |
|
LAPS | Cancellation because of no payment of annual fees |