Skip to content

Commit a58ab33

Browse files
committed
[GR-36894] Various DynamicObject improvements and cleanups
PullRequest: graal/22051
2 parents adf4cac + 8b2723e commit a58ab33

File tree

61 files changed

+1291
-2092
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1291
-2092
lines changed

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/truffle/test/HostInliningBytecodeInterpreterExampleTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
import jdk.vm.ci.meta.ResolvedJavaMethod;
5050

5151
/*
52-
* If you update the code here, please also update truffle/docs/HostOptimization.md.
52+
* If you update the code here, please also update truffle/docs/HostCompilation.md.
5353
*/
5454
public class HostInliningBytecodeInterpreterExampleTest extends TruffleCompilerImplTest {
5555

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/host/HostInliningPhase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ private static boolean isFastPathInvoke(CallTree call) {
907907

908908
/**
909909
* Returns <code>true</code> if a call tree should get inlined, otherwise <code>false</code>.
910-
* This method does not yet make determine wheter the call site is in budget. See
910+
* This method does not yet determine whether the call site is in budget. See
911911
* {@link #isInBudget(CallTree, int, int)} for that.
912912
*/
913913
private boolean shouldInline(InliningPhaseContext context, CallTree call) {
@@ -1013,7 +1013,7 @@ private boolean shouldInline(InliningPhaseContext context, CallTree call) {
10131013
* or non-direct virtual calls.
10141014
*/
10151015
if (call.subTreeFastPathInvokes >= context.maxSubtreeInvokes) {
1016-
call.reason = "call has too many fast-path invokes - too complex, please optimize, see truffle/docs/HostOptimization.md";
1016+
call.reason = "call has too many fast-path invokes - too complex, please optimize, see truffle/docs/HostCompilation.md";
10171017
return false;
10181018
}
10191019

truffle/docs/HostCompilation.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ This allows bytecode interpreter switches to be composed of multiple methods if
3838
Native image, during closed world analysis, computes all methods that are reachable for runtime compilation.
3939
Any potentially reachable method from `RootNode.execute(...)` is determined as runtime compilable.
4040
For native images, in addition to bytecode interpreter switches, all runtime compilable methods are optimized using Truffle host inlining.
41-
The maximum node cost of such an inlining pass can be configured with `-H:TruffleHostInliningBaseBudget=5000`.
41+
The maximum node cost of such an inlining pass can be configured with `-H:TruffleHostInliningBaseBudget=5000`.
4242
On HotSpot the set of runtime compilable methods is unknown.
4343
Therefore, we can only rely on regular Java method inlining for methods not annotated as bytecode interpreter switch on HotSpot.
4444

@@ -213,10 +213,10 @@ Additionally, to avoid the explosion of code size, host inlining has a built-in
213213
For example, the tracing may print the following:
214214

215215
```
216-
CUTOFF com.oracle.truffle.espresso.nodes.BytecodeNode.putPoolConstant(VirtualFrame, int, char, int) [inlined -1, explored 0, monomorphic false, deopt false, inInterpreter false, propDeopt false, graphSize 1132, subTreeCost 5136, invokes 1, subTreeInvokes 12, forced false, incomplete false, reason call has too many fast-path invokes - too complex, please optimize, see truffle/docs/HostOptimization.md
216+
CUTOFF com.oracle.truffle.espresso.nodes.BytecodeNode.putPoolConstant(VirtualFrame, int, char, int) [inlined -1, explored 0, monomorphic false, deopt false, inInterpreter false, propDeopt false, graphSize 1132, subTreeCost 5136, invokes 1, subTreeInvokes 12, forced false, incomplete false, reason call has too many fast-path invokes - too complex, please optimize, see truffle/docs/HostCompilation.md
217217
```
218218

219-
This indicates that there are too many fast-path invokes (by default 10) in the subtree, it also stops exploring after that number.
219+
This indicates that there are too many fast-path invokes (see limit in [HostInliningPhase](../../compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/host/HostInliningPhase.java)) in the subtree, it also stops exploring after that number.
220220
The `-Djdk.graal.TruffleHostInliningPrintExplored=true` flag may be provided to see the entire subtree for the decision.
221221
The following calls are considered fast-path invokes:
222222

@@ -262,8 +262,8 @@ abstract class AddNode extends Node {
262262
```
263263

264264
In this example, the specializations `doInt` and `doDouble` are very simple, but there is also the `doGeneric` specialization, which calls into a complex lookup chain.
265-
Assuming that the `LookupAndCallNode.execute` is a very complex method with more than ten fast-path subtree calls, we could not expect the execute method to get inlined.
266-
Host inlining currently does not support automatic component analysis; though it can be specified manually using the `@InliningCutoff` annotation:
265+
Assuming that the `LookupAndCallNode.execute` is a very complex method with many fast-path subtree calls (see limit in [HostInliningPhase](../../compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/truffle/host/HostInliningPhase.java)), we could not expect the execute method to get inlined.
266+
Host inlining currently does not support automatic component analysis; though a cutoff can be specified manually using the `@InliningCutoff` annotation:
267267

268268
```
269269
abstract class AddNode extends Node {

truffle/mx.truffle/mx_truffle.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ def slnative(args):
478478
vm_args, sl_args = mx.extract_VM_args(args, useDoubleDash=True, defaultAllVMArgs=False)
479479
target_dir = parsed_args.target_folder if parsed_args.target_folder else tempfile.mkdtemp()
480480
jdk = mx.get_jdk(tag='graalvm')
481-
image = _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, force_cp=False, hosted_assertions=False)
481+
image = _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, force_cp=False, hosted_assertions=False, log_host_inlining=mx.env_var_to_bool("SL_NATIVE_HOST_INLINING"))
482482
mx.log("Image build completed. Running {}".format(" ".join([image] + sl_args)))
483483
result = mx.run([image] + sl_args)
484484
return result
@@ -491,7 +491,7 @@ def _native_image(jdk):
491491
mx.abort("No native-image installed in GraalVM {}. Switch to an environment that has an installed native-image command.".format(jdk.home))
492492
return native_image_path
493493

494-
def _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, use_enterprise=True, force_cp=False, hosted_assertions=True):
494+
def _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, use_enterprise=True, force_cp=False, hosted_assertions=True, log_host_inlining=False):
495495
native_image_args = list(vm_args)
496496
native_image_path = _native_image(jdk)
497497
target_path = os.path.join(target_dir, mx.exe_suffix('sl'))
@@ -500,6 +500,16 @@ def _native_image_sl(jdk, vm_args, target_dir, use_optimized_runtime=True, use_e
500500
if hosted_assertions:
501501
native_image_args += ["-J-ea", "-J-esa"]
502502

503+
if log_host_inlining:
504+
native_image_args += [
505+
"-H:+UnlockExperimentalVMOptions",
506+
"-H:Log=HostInliningPhase,~CanonicalizerPhase,~GraphBuilderPhase",
507+
"-H:+TruffleHostInliningPrintExplored",
508+
"-H:MethodFilter=com.oracle.truffle.sl.*.*",
509+
"-H:-UnlockExperimentalVMOptions",
510+
"-Dgraal.LogFile=host-inlining.txt",
511+
]
512+
503513
# Even when Truffle is on the classpath, it is loaded as a named module due to
504514
# the ForceOnModulePath option in its native-image.properties
505515
# GR-58290: Fixed when ForceOnModulePath is removed

truffle/src/com.oracle.truffle.api.dsl/src/com/oracle/truffle/api/dsl/InlineSupport.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ private static String getEnclosingSimpleName(Class<?> c) {
169169

170170
/**
171171
* Marks a field to be accessed with unsafe. This annotation is useful to communicate fields
172-
* that must not e rewritten by code obfuscation tools like Proguard.
172+
* that must not be rewritten by code obfuscation tools like Proguard.
173173
*
174174
* @since 23.0
175175
*/
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,18 +38,18 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41-
package com.oracle.truffle.object.basic.test;
41+
package com.oracle.truffle.api.object.test;
4242

4343
import static org.junit.Assert.assertEquals;
4444
import static org.junit.Assert.assertSame;
4545
import static org.junit.Assert.assertTrue;
4646

47-
import org.junit.Ignore;
48-
import org.junit.Test;
49-
5047
import com.oracle.truffle.api.object.DynamicObject;
5148
import com.oracle.truffle.api.object.DynamicObjectLibrary;
5249
import com.oracle.truffle.api.object.Shape;
50+
import org.junit.Ignore;
51+
import org.junit.Test;
52+
5353
import com.oracle.truffle.api.test.AbstractLibraryTest;
5454

5555
public class CachedFallbackTest extends AbstractLibraryTest {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41-
package com.oracle.truffle.object.basic.test;
41+
package com.oracle.truffle.api.object.test;
4242

4343
import com.oracle.truffle.api.dsl.GenerateInline;
4444
import com.oracle.truffle.api.dsl.Specialization;
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41-
package com.oracle.truffle.object.basic.test;
41+
package com.oracle.truffle.api.object.test;
4242

4343
import com.oracle.truffle.api.dsl.GenerateInline;
4444
import com.oracle.truffle.api.dsl.Specialization;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,15 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41-
package com.oracle.truffle.object.basic.test;
41+
package com.oracle.truffle.api.object.test;
4242

4343
import java.util.Arrays;
4444
import java.util.List;
4545

46+
import com.oracle.truffle.api.object.DynamicObject;
47+
import com.oracle.truffle.api.object.DynamicObjectLibrary;
48+
import com.oracle.truffle.api.object.Property;
49+
import com.oracle.truffle.api.object.Shape;
4650
import org.hamcrest.CoreMatchers;
4751
import org.hamcrest.MatcherAssert;
4852
import org.junit.Assert;
@@ -51,10 +55,6 @@
5155
import org.junit.runners.Parameterized;
5256
import org.junit.runners.Parameterized.Parameters;
5357

54-
import com.oracle.truffle.api.object.DynamicObject;
55-
import com.oracle.truffle.api.object.DynamicObjectLibrary;
56-
import com.oracle.truffle.api.object.Property;
57-
import com.oracle.truffle.api.object.Shape;
5858
import com.oracle.truffle.api.test.AbstractParametrizedLibraryTest;
5959

6060
@SuppressWarnings("deprecation")
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,16 +38,15 @@
3838
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
3939
* SOFTWARE.
4040
*/
41-
package com.oracle.truffle.object.ext.test;
41+
package com.oracle.truffle.api.object.test;
4242

4343
import static org.junit.Assert.assertNotNull;
4444

4545
import java.lang.invoke.MethodHandles;
4646

47-
import org.junit.Test;
48-
4947
import com.oracle.truffle.api.object.DynamicObject;
5048
import com.oracle.truffle.api.object.Shape;
49+
import org.junit.Test;
5150

5251
public class CustomLayoutTest {
5352

0 commit comments

Comments
 (0)