public abstract class InstanceOfSnippetsTemplates extends SnippetTemplate.AbstractTemplates
InstanceOfNode
s with snippets. The majority of the complexity
in such a lowering derives from the fact that InstanceOfNode
is a floating node. A
snippet used to lower an InstanceOfNode
will almost always incorporate control flow and
replacing a floating node with control flow is not trivial.
The mechanism implemented in this class ensures that the graph for an instanceof snippet is
instantiated once per InstanceOfNode
being lowered. The result produced is then re-used
by all usages of the node. Additionally, if there is a single usage that is an IfNode
,
the control flow in the snippet is connected directly to the true and false successors of the
IfNode
. This avoids materializing the instanceof test as a boolean which is then retested
by the IfNode
.
Modifier and Type | Class and Description |
---|---|
static class |
InstanceOfSnippetsTemplates.InstanceOfUsageReplacer
Replaces a usage of an
InstanceOfNode or InstanceOfDynamicNode . |
static class |
InstanceOfSnippetsTemplates.Instantiation
The result of instantiating an instanceof snippet.
|
static class |
InstanceOfSnippetsTemplates.MaterializationUsageReplacer
Replaces the usage of an
InstanceOfNode or InstanceOfDynamicNode that does
materializes the result of the type test. |
static class |
InstanceOfSnippetsTemplates.NonMaterializationUsageReplacer
Replaces the usage of an
InstanceOfNode or InstanceOfDynamicNode that does
not materialize the result of the type test. |
providers, snippetReflection, target, UseSnippetTemplateCache
Constructor and Description |
---|
InstanceOfSnippetsTemplates(Providers providers,
SnippetReflectionProvider snippetReflection,
TargetDescription target) |
Modifier and Type | Method and Description |
---|---|
protected InstanceOfSnippetsTemplates.InstanceOfUsageReplacer |
createReplacer(FloatingNode instanceOf,
InstanceOfSnippetsTemplates.Instantiation instantiation,
Node usage,
StructuredGraph graph)
Gets the specific replacer object used to replace the usage of an instanceof node with the
result of an instantiated instanceof snippet.
|
void |
lower(FloatingNode instanceOf,
LoweringTool tool) |
protected abstract SnippetTemplate.Arguments |
makeArguments(InstanceOfSnippetsTemplates.InstanceOfUsageReplacer replacer,
LoweringTool tool)
Gets the arguments used to retrieve and instantiate an instanceof snippet template.
|
findMethod, snippet, template
public InstanceOfSnippetsTemplates(Providers providers, SnippetReflectionProvider snippetReflection, TargetDescription target)
protected abstract SnippetTemplate.Arguments makeArguments(InstanceOfSnippetsTemplates.InstanceOfUsageReplacer replacer, LoweringTool tool)
public void lower(FloatingNode instanceOf, LoweringTool tool)
protected InstanceOfSnippetsTemplates.InstanceOfUsageReplacer createReplacer(FloatingNode instanceOf, InstanceOfSnippetsTemplates.Instantiation instantiation, Node usage, StructuredGraph graph)