次のトピックでは、ディレクティブの動作と相互作用について確認します。
デフォルト・ディレクティブは、すべての可能なディレクティブ・オプションのデフォルト値が含まれるコンパイラ・ディレクティブです。これはディレクティブ・スタックの最下部にあり、コンパイルに送信される各メソッドに一致します。
新規ディレクティブを設計する際、新規ディレクティブがデフォルト・ディレクティブとどのように異なるかを指定します。デフォルト・ディレクティブは、設計上の判断を導くためのテンプレートになります。
デフォルト・ディレクティブのディレクティブ・オプション値
Directive: (default) matching: *.* c1 directives: inline: - Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000 c2 directives: inline: - Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000
新規ディレクティブのディレクティブ・オプション値
新規ディレクティブは、それらがデフォルト・ディレクティブとどのように異なるかを指定する必要があります。ディレクティブ・オプションが言及されていない場合、そのオプションはデフォルト・ディレクティブの値を保持します。
[ { match: ["*Concurrent.*"], c2: { MaxNodeLimit: 1000, }, Exclude:true, }, ]このディレクティブをディレクティブ・スタックに追加すると、デフォルト・ディレクティブはスタック内の最下位のディレクティブになります。この処理の詳細は、ディレクティブ・スタック内のディレクティブの順序を参照してください。最終的なディレクティブ・スタックの出力には、例の中で指定したディレクティブ・オプションのみがデフォルト・ディレクティブにある値と異なっていることが示されます。
Directive: matching: *Concurrent.* c1 directives: inline: - Enable:true Exclude:true BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000 c2 directives: inline: - Enable:true Exclude:true BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:1000 Directive: (default) matching: *.* c1 directives: inline: - Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000 c2 directives: inline: - Enable:true Exclude:false BreakAtExecute:false BreakAtCompile:false Log:false PrintAssembly:false PrintInlining:false PrintNMethods:false BackgroundCompilation:true ReplayInline:false DumpReplay:false DumpInline:false CompilerDirectivesIgnoreCompileCommands:false DisableIntrinsic: BlockLayoutByFrequency:true PrintOptoAssembly:false PrintIntrinsics:false TraceOptoPipelining:false TraceOptoOutput:false TraceSpilling:false Vectorize:false VectorizeDebug:0 CloneMapDebug:false IGVPrintLevel:0 MaxNodeLimit:80000
ディレクティブは、メソッド照合プロセスに基づいてコードに適用されます。コンパイルのために送信された各メソッドは、ディレクティブ・スタック内のディレクティブと照合されます。
メソッドとディレクティブ・スタックの照合を行うプロセスはCompilerBrokerによって実行されます。
メソッド照合プロセス
メソッドがコンパイルのために送信されると、その完全修飾名がディレクティブ・スタックの一致基準と比較されます。スタック内の最初の一致ディレクティブがメソッドに適用されます。スタック内の残りのディレクティブは無視されます。それ以外の一致が見つからない場合、デフォルト・ディレクティブが適用されます。
このプロセスは、コンパイルにおいてすべてのメソッドに対して繰り返されます。したがって、コンパイルでは複数のディレクティブが適用される場合があります。ただし、メソッド当たり1つのディレクティブのみが適用されます。スタック内のすべてのディレクティブは潜在的に適用可能であるため、アクティブであるとみなされます。アクティブなディレクティブと適用されたディレクティブの主な違いは次のとおりです。
ディレクティブがディレクティブ・スタックに存在する場合、そのディレクティブはアクティブです。
ディレクティブがコードに影響を及ぼしている場合、そのディレクティブは適用されています。
例2-1 一致が見つかった場合
public int exampleMethod(int x){ return x; }メソッド照合基準に基づいて、次の例のディレクティブ・スタックから
Directive 2
が適用されます。Directive 2: matching: *.*example* Directive 1: matching: *.*exampleMethod* Directive 0: (default) matching: *.*
例2-2 一致が見つからない場合
public int otherMethod(int y){ return y; }次の例のディレクティブ・スタックのメソッド照合基準に基づいて、
Directive 0
(デフォルト・ディレクティブ)が適用されます。Directive 2: matching: *.*example* Directive 1: matching: *.*exampleMethod* Directive 0: (default) matching: *.*
その他のガイドライン
ディレクティブのメソッド照合基準を慎重に記述します。指定されたメソッドに適用されるディレクティブを検証するフィードバック・メカニズムはありません。かわりに、JMXなどのプロファイラを使用して、適用されたディレクティブの累積的な影響を測定できます。
CompilerBrokerは、不正なコード(対応していないプラットフォームのハードウェアに命令を強制するなど)を作成するディレクティブ・オプションを無視します。警告メッセージが表示されます。
ディレクティブ・オプションには、一般的なコマンドライン・フラグと同じ制限があります。たとえば、インライン・コードに対する命令が処理されるのは、中間表現(IR)が大きくなりすぎない場合にかぎられます。
コンパイラ・コントロール・ディレクティブとともに、CompileCommandおよびコマンドライン・フラグを使用できます。
コンパイラ・コントロール
CompileCommand
コマンドライン・フラグ
デフォルト値
例2-3 コンパイラ・コントロールとCompileCommandの併用
コンパイラ・コントロール:
Exclude: true
BreakAtExecute: false
CompileCommand:
BreakAtExecute: true
BreakAtCompile: true
デフォルト値:
Exclude: false
BreakAtExecute: false
BreakAtCompile: false
Log: false
Exclude: true
BreakAtExecute: false
BreakAtCompile: true
Log: false