Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] [GR-32682] Bytecode DSL. #6697

Closed
wants to merge 493 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
493 commits
Select commit Hold shift + click to select a range
b49dac6
Simplify emitLeaves by specializing it for return and branch.
chumer Mar 1, 2024
8f04f11
Add prepareForInstrumentation method in RootNode.
chumer Mar 8, 2024
1824242
Implement dead code elimination.
chumer Mar 8, 2024
9930089
Implement implicit custom operation tag instruementation.
chumer Mar 8, 2024
4410e62
only emit endTag call for emitXYZOperation when it has implicit tags
DSouzaM Mar 8, 2024
92d5693
Add advanced try catch test.
chumer Mar 12, 2024
52d47d8
Fix epilog emission without an operand value must not happen; Add add…
chumer Mar 12, 2024
f84298b
Refactor exception handlers.
chumer Mar 13, 2024
d271a82
Implement exception profiles.
chumer Mar 13, 2024
9b919f7
Remove public readBciFromFrame API, clarify storeBciInFrame docs
DSouzaM Mar 14, 2024
4955961
Add BytecodeRootNode#getStartLocation API
DSouzaM Mar 14, 2024
5c7c033
Initial version of tag instrumentation exception handlers.
chumer Mar 18, 2024
a18ed20
Rename initiallyReachable to handlerReachable. Remove invalid assertion.
chumer Mar 18, 2024
523d84b
forward local frame to exception intercept methods when continuations…
DSouzaM Mar 18, 2024
ae28d62
Do not patch dead branch instructions
DSouzaM Mar 19, 2024
920dbb1
Fix materialized local reads
DSouzaM Mar 19, 2024
a5a0399
Fix node-to-bci computation with boxing elimination
DSouzaM Mar 21, 2024
9376072
More tag handler tests and refactoring.
chumer Mar 18, 2024
89becdd
Return null instead of trapping all method fall-through. Implement ep…
chumer Mar 21, 2024
c5d0307
Pass a valid child bci to afterChild for short circuit ops
DSouzaM Mar 21, 2024
8f68d17
Add BytecodeRootNode#setLocal
DSouzaM Mar 22, 2024
d6b95ad
Fix typo on isBytecodeUpdatable
DSouzaM Mar 25, 2024
4c2ee41
Rename Builder's BytecodeLocation to UnresolvedBranchTarget to disamb…
DSouzaM Mar 25, 2024
74fcdb9
Reimplement source info encoding similar to exception handling; Impro…
chumer Mar 26, 2024
2f9d16b
Make continuations (almost) work with BytecodeLocations
DSouzaM Mar 27, 2024
d200bc1
Optimization: don't allocate ContinuationLocations when reparsing
DSouzaM Apr 1, 2024
d6f3edc
Implement ContinuationLocation#getBytecodeLocation + toString methods…
DSouzaM Apr 1, 2024
160abd2
Fix OSR: forward target to caller instead of overwriting return value…
DSouzaM Apr 3, 2024
835d790
Fix continuations: eagerly patch continuation roots on bytecode rewri…
DSouzaM Apr 4, 2024
8865766
Fix sl out of bounds argument access handling.
chumer Mar 26, 2024
9cb4782
Add support for accessing the instrumenting call node in frames.
chumer Apr 4, 2024
90027d5
Use instrumenting call node in the debugger instead of the regular ca…
chumer Apr 4, 2024
78903c6
Support non-wrapped instrumentable nodes when finding parent instrume…
chumer Apr 4, 2024
65c5b93
Add basic implementation to support customizing the tag tree node lib…
chumer Apr 4, 2024
031726b
Run and fix more tests for the bytecode interpreter in SL.
chumer Apr 4, 2024
560a3ee
Make introspection classes top-level classes in the bytecode package.
chumer Apr 4, 2024
58cc801
Move Argument class inside Instruction class.
chumer Apr 4, 2024
9c910e4
Refactor instruction instrumentation; Cleanup API methods. (breaking)
chumer Apr 5, 2024
8ceb6e5
Add Instruction#isInstrumentation method
DSouzaM Apr 5, 2024
65e7db1
Rewrite compilation tests to explicitly request compilation
DSouzaM Apr 11, 2024
e17fd24
Improve continuations: move cached transition into transitionState; s…
DSouzaM Apr 11, 2024
d1dc326
mark unmodified OperationData fields as final; rename handlerReachabl…
DSouzaM Apr 12, 2024
f97ba26
Simplify doEmitFinallyHandler for BRANCH_BACKWARD
DSouzaM Apr 12, 2024
1bec42f
Simplify FinallyTry reachability update
DSouzaM Apr 12, 2024
2f783b8
Fix FinallyTry: do not guard the handler bytecode inlined for early e…
DSouzaM Apr 15, 2024
2bcf567
Avoid allocating exception table entries with empty bci ranges
DSouzaM Apr 16, 2024
81ed84d
Add FinallyTryCatch operation
DSouzaM Apr 16, 2024
6a27b4c
Remove instruction index APIs
DSouzaM Apr 17, 2024
d1f5658
Implement/proxy RootNode methods on ContinuationRootNode
DSouzaM Apr 17, 2024
ce51f3e
Use int[] instead of List<Integer> in finally-try builder data; docum…
DSouzaM Apr 18, 2024
9db5e8c
Only add proxy methods to ContinuationRootNode for methods overridden…
DSouzaM Apr 18, 2024
d0b9d3c
Remove FinallyTryNoExcept
DSouzaM Apr 18, 2024
f7bf7da
Fix source reparsing: reused cached nodes get adopted; continuation l…
DSouzaM Apr 19, 2024
cc6a9cc
Define separate BytecodeNode#getBytecodeIndex method to directly read…
DSouzaM Apr 19, 2024
7f2d4b2
When quickening/BE is enabled, cloneUninitialized should unquicken in…
DSouzaM Apr 22, 2024
76f748b
Explicitly adopt cached nodes when they get reused during reparse
DSouzaM Apr 22, 2024
725d0b9
Ensure intercept methods are only called once when interpreter has ex…
DSouzaM Apr 30, 2024
941c58c
Remove bytecode introspection class; Refactor SourceInformation and E…
chumer Apr 7, 2024
4ecf216
Implement local scoping feature; Improve simple language test coverag…
chumer May 6, 2024
ff1bccf
Basic constant operand support
DSouzaM May 7, 2024
a256a1f
Constant operands: Support uncached & serialization, test BE, require…
DSouzaM May 7, 2024
9fba5c5
Constant operands: test instruction constant introspection; improve E…
DSouzaM May 8, 2024
2f82bd5
Constant operands: support prolog constants; add javadoc
DSouzaM May 8, 2024
acb3c9f
Constant operands: rename builder arguments to avoid naming collisions
DSouzaM May 8, 2024
9783fb8
Move builtins to BytecodeDSLBuiltins and put documentation directly i…
DSouzaM May 9, 2024
92b9506
Implement tag instrumentation notifications for yielding and resuming.
chumer May 7, 2024
127b140
Allow reading default values; Improve local scope testing.
chumer May 7, 2024
7d3779a
Fix on stack transitions for tag instrumentation.
chumer May 10, 2024
be2099b
Exclude constant operands from BE quickenings; remove unused TRAP ins…
DSouzaM May 13, 2024
3d43552
Allocate constant operands before instrumentation check so constant p…
DSouzaM May 13, 2024
8bf96c1
Constant operands: rename operandName->name and properly set it; add …
DSouzaM May 13, 2024
cbca6a9
Ensure materialized local frame is used when resumed nodes trigger OSR
DSouzaM May 14, 2024
2aa2ccd
Fix boxing elimination for local accesses with LocalSetter and LocalS…
chumer May 14, 2024
a4586eb
Remove error tests pertaining to LocalSetter/LocalSetterRange
DSouzaM May 14, 2024
9c2ffa7
Minor fixes: suppress dump exceptions in generated code instead of pu…
DSouzaM May 14, 2024
e4c2f8c
Fix TypeMirror identity is not reliable on javac.
chumer May 15, 2024
585a5db
Disable parity checks for eager probes.
chumer May 15, 2024
a42da67
Cleanups.
chumer May 15, 2024
681d744
Add SourceInformationTree
DSouzaM May 15, 2024
7f5ab20
Add ConstantOperand tests for fallback and LocalSetters
DSouzaM May 16, 2024
3f6fe07
Introduce DynamicOperandModel (non-functional change)
DSouzaM May 17, 2024
6eb377e
Infer dynamic operand names for custom operations from specialization…
DSouzaM May 17, 2024
d25214a
Include return type in operation signature; fix operand naming bug
DSouzaM May 24, 2024
1ed424a
Support branching out of a finally handler when sp matches; rename an…
DSouzaM May 28, 2024
78eee13
Bugfix: return does not produce a value.
DSouzaM May 28, 2024
4467993
Add branch.unaligned to allow users to branch to locations with lower…
DSouzaM May 29, 2024
0b4bc64
Update compiler test to use new LocalSetter APIs
DSouzaM May 29, 2024
4f4cfcc
Fix TryCatch: handler table entry should have precedence over outer f…
DSouzaM May 31, 2024
8a0ff4a
fix LocalVariable dump with global scopes; store frame index instead …
DSouzaM Jun 3, 2024
4965326
Only use safe operations in validateBytecodes and instruction argumen…
DSouzaM Jun 3, 2024
02bccd1
Optimization: emit regular branch when branch.unaligned is unnecessary
DSouzaM Jun 3, 2024
ebcc41c
Bugfix: epilog.return should run before implicit return
DSouzaM Jun 5, 2024
2765071
Validate that endTag receives same tags as beginTag, when possible
DSouzaM Jun 5, 2024
b32b66f
Clean up/consolidate beforeEmitReturn/beforeEmitBranch code; add test…
DSouzaM Jun 7, 2024
1592b7e
Add builtin tutorial for the Bytecode DSL.
chumer Jun 10, 2024
d9a55fe
Refactor AbstractBytecodeException.
chumer Jun 10, 2024
4f56822
Fix lint warnings, minor builtin tutorial rewording, small typo on Ab…
DSouzaM Jun 10, 2024
ff9b646
Add additional tests to explain the builtin usage.
chumer Jun 11, 2024
c54dcc3
Fix node location used for BasicInterpreter exceptions
DSouzaM Jun 11, 2024
5f72736
Major change: specify finally handlers using closures
DSouzaM Jun 14, 2024
947a4dc
Refactor serialization to support closure-based finally handlers
DSouzaM Jun 20, 2024
e4b7dd2
Remove branch.unaligned
DSouzaM Jun 20, 2024
529718b
Properly support serialization of nested root nodes across finally ha…
DSouzaM Jun 21, 2024
e6e28f3
Properly serialize fields of root nodes declared in finally handlers
DSouzaM Jun 24, 2024
2407b67
Fix: don't allocate builtNodes space on reparse.
DSouzaM Jun 24, 2024
52ab584
Source sections: emit proper bci range for SourceSections enclosing R…
DSouzaM Jun 25, 2024
dd93bc8
Source sections: permit arbitrary number of sections in getSourceLoca…
DSouzaM Jun 25, 2024
7a538c0
SL: fix bytecode exception failures; fix compilation warnings
DSouzaM Jun 25, 2024
5557daa
Bytecode validation: improve error messages; validate source info & e…
DSouzaM Jun 25, 2024
e883a16
FinallTry: remove exception argument (pass exceptions on the stack, F…
DSouzaM Jun 26, 2024
ff06d91
Exception table: remove exception local, replace with handler kind
DSouzaM Jun 27, 2024
3c81f82
Serialization: improve type-safety by using special local & label ser…
DSouzaM Jun 27, 2024
e2e1d21
Serialization: use special SerializationRootNode
DSouzaM Jun 27, 2024
681bff7
Always allocate continuations and invoke finally parsers regardless o…
DSouzaM Jul 2, 2024
a0a954f
Tags: fix stack walk for yield resumes; add another FinallyTry test
DSouzaM Jul 2, 2024
e10b17d
Reachability: add another test for finally handler reachability propa…
DSouzaM Jul 3, 2024
f2b9858
Exception handlers: walk handler table to patch entries instead of re…
DSouzaM Jul 3, 2024
d6ecbc4
Exception handlers: optimize extra handler patching by tracking range…
DSouzaM Jul 3, 2024
4c7c62c
Exception handlers: combine contiguous ranges, don't skip return/bran…
DSouzaM Jul 3, 2024
82625d0
Update compiler SL tests; add compiler test with multiple returns at …
DSouzaM Jul 4, 2024
88c7ee1
Operation stack: bottom-up stack walk without allocation using forwar…
DSouzaM Jul 4, 2024
c622dc1
Introduce LoadException operation (to replace BytecodeLocal used in T…
DSouzaM Jul 4, 2024
8954cc8
Remove BytecodeLocal argument from TryCatch/FinallyTryCatch operations
DSouzaM Jul 5, 2024
842f199
Fix: deserialization should not read data inside an assertion that ca…
DSouzaM Jul 5, 2024
916e599
Unwind/rewind: properly open/close exception handlers for tags
DSouzaM Jul 8, 2024
70ff29b
Compiler tests: remove todo comment and update tests to new TryCatch API
DSouzaM Jul 8, 2024
1f50f90
Tags: fix exception handler emission
DSouzaM Jul 9, 2024
8c77aca
API: use 'BytecodeIndex' for public APIs; document TagTree
DSouzaM Jul 9, 2024
11900f6
Update 'since' tag on javadoc to 24.2
DSouzaM Jul 9, 2024
aef6d3d
BytecodeNode: add/update javadoc and change bci->bytecodeIndex for pu…
DSouzaM Jul 9, 2024
8af6d9c
Support Truffle stack trace lookup in bytecode interpreter; Remove Ab…
chumer Jul 8, 2024
8ce1a50
Fix load local materialized NPE.
chumer Jul 8, 2024
3310450
Use @Proxyable(allowUncached=true) instead of @GenerateUncached to av…
chumer Jul 9, 2024
82f0ced
Source sections: encode start and end bci as ints, beginBci -> startBci
DSouzaM Jul 9, 2024
228808d
Fix unwind/rewind to work with nested roots; add nested root tag test…
DSouzaM Jul 10, 2024
ff008d6
Source sections: unwind and rewind during early exits
DSouzaM Jul 10, 2024
4df2b50
Implement SL builtins using bytecode root nodes if the bytecode inter…
chumer Jul 11, 2024
f44ef5d
Source sections: remove location lookups for (startBci, endBci); add …
DSouzaM Jul 11, 2024
bc32271
SourceInformationTree: fix to work with multiple 'roots' of tree (com…
DSouzaM Jul 11, 2024
8ffa185
Make continuation result forward interop messages to the result.
chumer Jul 12, 2024
d4de0a2
SourceInformationTree: update documentation
DSouzaM Jul 12, 2024
0d00fc8
Refactor bind expressions for Bytecode DSL (breaking) and implement @…
chumer Jul 12, 2024
76ce3cf
Migrate 'this' bound variables to '$node'.
chumer Jul 12, 2024
c819fdd
Fix dangling operations are not validated.
chumer Jul 12, 2024
24d6567
Migrate exception tests to assertThrows.
chumer Jul 12, 2024
7dbdb34
Refactor builder error handling. Add prefix and current operation sta…
chumer Jul 12, 2024
ad90155
Minor improvements: move handle table patching to its own method, fix…
DSouzaM Jul 12, 2024
12e102f
Source sections: support unavailable sections
DSouzaM Jul 16, 2024
78a626d
Fix SLDebugTest.
chumer Jul 16, 2024
ec7f3df
Local scopes: implement unwind/rewind for correct liveness computations
DSouzaM Jul 16, 2024
8c0e15f
Bug fix: properly reset locals table in beginRoot
DSouzaM Jul 17, 2024
0d76a67
Bug fixes: encode unique local index in locals table (table position …
DSouzaM Jul 17, 2024
f6abda6
Rewind: walk the stack bottom-up so LocalVariables have same order wh…
DSouzaM Jul 17, 2024
6e0b3fd
Bug fix: clear locals on branch out; exclude defining Block from bran…
DSouzaM Jul 17, 2024
81e3d97
Improve handling of type system references in the operation DSL.
chumer Jul 17, 2024
7befda8
Refactor default bytecode scope implementation; Reuse default bytecod…
chumer Jul 17, 2024
7f13e5f
Add tests for regular type systems with the bytecode DSL.
chumer Jul 17, 2024
80d801e
Add some boxing elimination tests (ignored for now).
chumer Jul 18, 2024
b89cfbc
Fix operation parser type system comparison should only be performed …
chumer Jul 18, 2024
70a5aa6
Implement merging of local table entries.
chumer Jul 18, 2024
32ef408
Locals table: merge entries during rewind
DSouzaM Jul 18, 2024
5e0fd54
Cleanup: add/fix javadoc, remove resolved TODOs, fix compiler warnings
DSouzaM Jul 18, 2024
a55b5a5
Test automatic tagging of OperationProxy and improve error location
DSouzaM Jul 18, 2024
ae1b97a
SimpleLanguage: remove 'Bytecode' from parser/lexer definitions, dele…
DSouzaM Jul 18, 2024
8df6f54
Cleanup: add tests for getSourceLocation(FrameInstance); misc javadoc…
DSouzaM Jul 18, 2024
fd413a7
Bug fixes: user code can override RootNode methods with wider visibil…
DSouzaM Jul 19, 2024
01d0876
Bug: load.local.mat should handle null tags array; also test local un…
DSouzaM Jul 22, 2024
3e7b0c1
Constant operands: use correct offset for constant operands in uncached
DSouzaM Jul 23, 2024
2662ce7
Validation: use appropriate root node for locals, fix local offset up…
DSouzaM Jul 24, 2024
7a941c4
Instruction encoding overhaul: store bytecode in byte array; support …
DSouzaM Jul 25, 2024
9d6aca0
Implement boxing elimination for implicit casts.
chumer Jul 25, 2024
d0b445a
Fix specializations with the same name could trigger invalid boxing e…
chumer Jul 26, 2024
9cc8fc4
Fix invalid instruction reads for debug tracing.
chumer Jul 26, 2024
4d578e6
Use ByteArraySupport to access byte arrays instead of hand-written By…
DSouzaM Jul 25, 2024
3ae7d2d
Use ByteArraySupport#readUnalignedInt to read int immediates; explici…
DSouzaM Jul 26, 2024
0479d9f
Eliminate overhead for engine.TraceTransferToInterpreter on HotSpot.
chumer Jul 28, 2024
6105cad
Implement accessors for native byte array accessors to avoid public e…
chumer Jul 28, 2024
1b32be0
Fix materialized accesses can only be validated if the bci is always …
chumer Jul 28, 2024
78391b7
Implement splitting bytecode dispatches that exceed 8000 bytecodes.
chumer Jul 30, 2024
8341baf
Fix: only generate validateGetCachedLocalKindInternal with local scoping
DSouzaM Jul 29, 2024
2dc07a0
Bytecode encoding: encode constants with ints; add BytecodeEncodingEx…
DSouzaM Jul 30, 2024
aeb542c
Simplify exception handling and move more bytecodes into methods.
chumer Jul 30, 2024
270c9bf
ByteArraySupport: add unaligned reads for short/long, fix bugs, add t…
DSouzaM Jul 30, 2024
fff5ab8
Minor: asNodeProfile to asCachedNode, asTagNode returns TagTreeNode, …
DSouzaM Jul 30, 2024
c3e769f
Automatically generate reflective helper methods for GenerateBytecode…
DSouzaM Jul 31, 2024
053fcaa
Simplify notifyTransferToInterpreter further.
chumer Aug 1, 2024
4edd759
Refactor all constants must be non-null. Introduce emitLoadNull opera…
chumer Aug 1, 2024
e379563
Documentation: update introduction and add sample code to demonstrate…
DSouzaM Aug 1, 2024
3ba7f04
Documentation: migrate GettingStarted.md to GettingStarted.java; remo…
DSouzaM Aug 1, 2024
499dcf5
Fix make LoopCounter escape analyze again.
chumer Aug 2, 2024
cc6093c
Documentation: start rewriting + restructuring User Guide
DSouzaM Aug 2, 2024
3f020bc
Hide unsafe accesses through accessor pattern to avoid too easy acces…
chumer Aug 5, 2024
3769136
Remove unused checked frame extensions.
chumer Aug 5, 2024
071d6bb
Fix invalid constants in tests.
chumer Aug 5, 2024
49b7c5a
Add special null instruction to serialization to avoid null check err…
chumer Aug 5, 2024
fc8d65f
Hide BytecodeEncodingException constructor; use Unsafe for branch pro…
DSouzaM Aug 6, 2024
8c7d8bc
Documentation: write rest of the User Guide
DSouzaM Aug 7, 2024
7ebc23d
Bug: don't quicken Conditional operands if they have early returns
DSouzaM Aug 8, 2024
1e32be7
Bug: permit -1 for child bcis of merge.conditional$generic
DSouzaM Aug 8, 2024
5aa54e5
Documentation: polish serialization tutorial and include constant ope…
DSouzaM Aug 8, 2024
d0aad32
Remove no longer needed tag instrumentation code.
chumer Aug 5, 2024
07bdf37
Fix invalid uncheckedCast intrinsic.
chumer Aug 9, 2024
027b019
Continuations: polish API and write tutorial
DSouzaM Aug 9, 2024
4db6e27
Polish docs, rename findSourceLocation -> getSourceLocation
DSouzaM Aug 12, 2024
90b10ca
Remove outdated TODO.
chumer Aug 12, 2024
ee5c9ae
Cleanup and test RootNode.findInstrumentableNode.
chumer Aug 12, 2024
f32dfd1
Remove Tracing feature. Needs to wait for v2. (GR-57220)
chumer Aug 12, 2024
88494ea
Docs: include reference to BuiltinTutorial.java
DSouzaM Aug 12, 2024
a4a19c9
Add issue to disabled test (GR-57221).
chumer Aug 12, 2024
b631b78
Fix checkstyle warnings.
chumer Aug 12, 2024
1dffce1
Add missing package.info.java
chumer Aug 12, 2024
7f2e60d
Fix spotbugs warnings.
chumer Aug 12, 2024
1c00af6
Fix javadoc.
chumer Aug 12, 2024
a6d3186
Fix javac warning.
chumer Aug 12, 2024
3ad5dda
Remove unused Frame.copyObject and Frame.copyPrimitive.
chumer Aug 12, 2024
a765c6b
More javadoc and TruffleBoundary to AbstractTruffleException.
chumer Aug 12, 2024
8b26cc7
Protect more base classes using tokens.
chumer Aug 12, 2024
45e0b61
Remove AbstractBytecodeException.
chumer Aug 12, 2024
0d3eef2
Added changelog entries for Truffle API changes.
chumer Aug 12, 2024
7464cdc
Improve documentation and validation of BytecodeNode. Fix compile err…
chumer Aug 13, 2024
7c72d3a
Fix super constructor call in ManualBytecodeInterpreter.AccessToken
DSouzaM Aug 13, 2024
8dd994e
Fix unreachable continuation locations should not produce invalid byt…
chumer Aug 13, 2024
fb90c4c
One more fix for unreachable continuation locations.
chumer Aug 13, 2024
a9dd637
Cleanup constant names.
chumer Aug 13, 2024
c753d2e
Refactor factories to element subclasses in bytecode dsl factory.
chumer Aug 13, 2024
ac78c32
Refactor bytecode dsl root node element.
chumer Aug 13, 2024
2ca9503
Fix builder generation.
chumer Aug 14, 2024
d6ddfc9
Minor improvments; Docs.
chumer Aug 14, 2024
00a15c4
Fix accidentally using safe frame accessors instead of unsafe.
chumer Aug 14, 2024
f4e8d74
Avoid materialization of sources during stack walking.
chumer Aug 14, 2024
ece9788
Revert "Simplify notifyTransferToInterpreter further."
chumer Aug 14, 2024
244206d
Fix invalid intrinsics.
chumer Aug 14, 2024
1fc3973
Cleanup leftover code.
chumer Aug 14, 2024
e720387
Fix also update bytecode root node clones when updating bytecodes. Im…
chumer Aug 14, 2024
4f0bc54
Fix invalid bytecode node adoption.
chumer Aug 15, 2024
b7c2efc
Cleanups.
chumer Aug 15, 2024
425c3c7
Fix overload handling of splitting methods.
chumer Aug 15, 2024
d837f5a
Remove unnecessary testing code.
chumer Aug 15, 2024
31eaa85
Fix split updating.
chumer Aug 15, 2024
80fb0e7
Improve and cleanup javadoc; Use retention policy SOURCE instead of R…
chumer Aug 15, 2024
5f7ff6e
Improve coverage for BytecodeNode methods
DSouzaM Aug 15, 2024
3e0de0a
Add introspection invariant tests.
chumer Aug 16, 2024
b72a9cc
Fix truffle project config.
chumer Aug 16, 2024
a9df309
Fixes: short/int byte read helpers should use short/int; assert shoul…
DSouzaM Aug 16, 2024
b52785d
Actually generate LocalIndex introspection type; improve coverage of …
DSouzaM Aug 16, 2024
65f99e9
LocalSetterRange: add missing setter methods
DSouzaM Aug 16, 2024
390d6ff
Fix SL instrument redo test.
chumer Aug 16, 2024
cd8a868
Cleanup: remove dead code, simplify some code, undo random file changes
DSouzaM Aug 16, 2024
ec46e54
Updated changelog, removed reference to GraalPy implementation for now
DSouzaM Aug 16, 2024
d165e96
Fixes: re-add EarlyReturn op for compiler tests, don't intrinsify rem…
DSouzaM Aug 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleanup constant names.
  • Loading branch information
chumer committed Aug 13, 2024
commit a9dd637d81f5c73377b3978849df289f7d0f9d7a
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@

public class BytecodeDSLNodeFactory implements ElementHelpers {

public static final String USER_LOCALS_START_IDX = "USER_LOCALS_START_IDX";
public static final String BCI_IDX = "BCI_IDX";
public static final String COROUTINE_FRAME_IDX = "COROUTINE_FRAME_IDX";
public static final String EPILOG_EXCEPTION_IDX = "EPILOG_EXCEPTION_IDX";
public static final String USER_LOCALS_START_INDEX = "USER_LOCALS_START_INDEX";
public static final String BCI_INDEX = "BCI_INDEX";
public static final String COROUTINE_FRAME_INDEX = "COROUTINE_FRAME_INDEX";
public static final String EPILOG_EXCEPTION_INDEX = "EPILOG_EXCEPTION_INDEX";
public static final String EMPTY_INT_ARRAY = "EMPTY_INT_ARRAY";

// Bytecode version encoding: [tags][instrumentations][source bit]
Expand Down Expand Up @@ -517,7 +517,7 @@ private Element createFindBytecodeIndex() {
b.startStaticCall(types.BytecodeNode, "get").string("node").end().instanceOf(abstractBytecodeNode.asType()).string(" : ").doubleQuote("invalid bytecode node passed");
b.end();
b.startReturn();
b.startCall("frame.getInt").string("BCI_IDX").end();
b.startCall("frame.getInt").string("BCI_INDEX").end();
b.end();
} else {
b.declaration(abstractBytecodeNode.asType(), "bytecode", "null");
Expand Down Expand Up @@ -756,18 +756,18 @@ private List<CodeVariableElement> createFrameLayoutConstants() {
int reserved = 0;

if (model.needsBciSlot()) {
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, BCI_IDX, reserved++ + ""));
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, BCI_INDEX, reserved++ + ""));
}

if (model.enableYield) {
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, COROUTINE_FRAME_IDX, reserved++ + ""));
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, COROUTINE_FRAME_INDEX, reserved++ + ""));
}

if (model.epilogExceptional != null) {
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, EPILOG_EXCEPTION_IDX, reserved++ + ""));
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, EPILOG_EXCEPTION_INDEX, reserved++ + ""));
}

result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, USER_LOCALS_START_IDX, reserved + ""));
result.add(createInitializedVariable(Set.of(PRIVATE, STATIC, FINAL), int.class, USER_LOCALS_START_INDEX, reserved + ""));

return result;
}
Expand Down Expand Up @@ -2471,7 +2471,7 @@ private CodeTypeElement create() {
private CodeExecutableElement createGetLocalOffset() {
CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.BytecodeLocal, "getLocalOffset");
CodeTreeBuilder b = ex.createBuilder();
b.startReturn().string("frameIndex - USER_LOCALS_START_IDX").end();
b.startReturn().string("frameIndex - USER_LOCALS_START_INDEX").end();
return ex;
}
}
Expand Down Expand Up @@ -3749,7 +3749,7 @@ private CodeExecutableElement createCreateLocalAllParameters() {
TypeMirror scopeType = scopeDataType.asType();
b.declaration(scopeType, "scope", "getCurrentScope()");
b.declaration(type(short.class), "localIndex", "allocateBytecodeLocal() /* unique global index */");
b.declaration(type(short.class), "frameIndex", safeCastShort("USER_LOCALS_START_IDX + scope.frameOffset + scope.numLocals") + " /* location in frame */");
b.declaration(type(short.class), "frameIndex", safeCastShort("USER_LOCALS_START_INDEX + scope.frameOffset + scope.numLocals") + " /* location in frame */");
b.declaration(type(int.class), "tableIndex", "doEmitLocal(localIndex, frameIndex, name, info) /* index in global table */");
b.statement("scope.registerLocal(tableIndex)");
} else {
Expand Down Expand Up @@ -5268,9 +5268,9 @@ private void buildFrameSize(CodeTreeBuilder b) {

private String maxLocals() {
if (model.enableLocalScoping) {
return "maxLocals + USER_LOCALS_START_IDX";
return "maxLocals + USER_LOCALS_START_INDEX";
} else {
return "numLocals + USER_LOCALS_START_IDX";
return "numLocals + USER_LOCALS_START_INDEX";
}
}

Expand Down Expand Up @@ -6528,7 +6528,7 @@ private CodeExecutableElement createDoEmitLocalConstantIndices() {
b.declaration(type(int.class), "tableIndex", "allocateLocalsTableEntry()");

if (model.enableLocalScoping) {
b.statement("assert frameIndex - USER_LOCALS_START_IDX >= 0");
b.statement("assert frameIndex - USER_LOCALS_START_INDEX >= 0");
b.statement("locals[tableIndex + LOCALS_OFFSET_START_BCI] = bci");
b.lineComment("will be patched later at the end of the block");
b.statement("locals[tableIndex + LOCALS_OFFSET_END_BCI] = -1");
Expand Down Expand Up @@ -7470,7 +7470,7 @@ private CodeExecutableElement createAllocateBytecodeLocal() {
if (model.enableLocalScoping) {
b.string("(short) numLocals++");
} else {
b.string("(short) (USER_LOCALS_START_IDX + numLocals++)");
b.string("(short) (USER_LOCALS_START_INDEX + numLocals++)");
}
b.doubleQuote("Number of locals");
b.end(2);
Expand Down Expand Up @@ -8321,7 +8321,7 @@ private CodeExecutableElement createGetLocalOffset() {
CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.LocalVariable, "getLocalOffset");
CodeTreeBuilder b = ex.createBuilder();
if (model.enableLocalScoping) {
b.statement("return bytecode.locals[baseIndex + LOCALS_OFFSET_FRAME_INDEX] - USER_LOCALS_START_IDX");
b.statement("return bytecode.locals[baseIndex + LOCALS_OFFSET_FRAME_INDEX] - USER_LOCALS_START_INDEX");
} else {
b.statement("return baseIndex / LOCALS_LENGTH");
}
Expand All @@ -8341,7 +8341,7 @@ private CodeExecutableElement createGetTypeProfile() {
b.statement("return FrameSlotKind.fromTag(localTags[getLocalIndex()])");
} else {
b.startIf().string("bytecode instanceof CachedBytecodeNode").end().startBlock();
b.statement("return bytecode.getRoot().getFrameDescriptor().getSlotKind(getLocalOffset() + USER_LOCALS_START_IDX)");
b.statement("return bytecode.getRoot().getFrameDescriptor().getSlotKind(getLocalOffset() + USER_LOCALS_START_INDEX)");
b.end().startElseBlock();
b.returnNull();
b.end();
Expand Down Expand Up @@ -8759,7 +8759,7 @@ private CodeExecutableElement createAsLocalOffset() {
b.declaration(type(byte[].class), "bc", "this.bytecode.bytecodes");
b.startReturn();
assert ImmediateKind.LOCAL_OFFSET.width == ImmediateWidth.SHORT;
b.string(readShortSafe("bc", "bci")).string(" - USER_LOCALS_START_IDX");
b.string(readShortSafe("bc", "bci")).string(" - USER_LOCALS_START_INDEX");
b.end();
return ex;
}
Expand Down Expand Up @@ -9321,7 +9321,7 @@ private CodeExecutableElement createGetLocalValue(TypeMirror specializedType) {
buildVerifyLocalsIndex(b);
buildVerifyFrameDescriptor(b);

b.declaration(type(int.class), "frameIndex", "USER_LOCALS_START_IDX + localOffset");
b.declaration(type(int.class), "frameIndex", "USER_LOCALS_START_INDEX + localOffset");
if (model.usesBoxingElimination()) {
if (generic) {
b.startTryBlock();
Expand Down Expand Up @@ -9400,7 +9400,7 @@ private CodeExecutableElement createSetLocalValue(TypeMirror specializedType) {
b.statement("assert validateBytecodeIndex(bci)");
buildVerifyLocalsIndex(b);
buildVerifyFrameDescriptor(b);
b.declaration(type(int.class), "frameIndex", "USER_LOCALS_START_IDX + localOffset");
b.declaration(type(int.class), "frameIndex", "USER_LOCALS_START_INDEX + localOffset");
if (model.usesBoxingElimination()) {
b.startStatement().startCall("setLocalValue" + suffix + "Impl");
b.string("frame").string("frameIndex").string("value");
Expand Down Expand Up @@ -9570,7 +9570,7 @@ private CodeExecutableElement createValidateGetCachedLocalKindInternal() {
CodeTreeBuilder b = ex.createBuilder();
if (model.enableLocalScoping && model.storeBciInFrame) {
b.startDeclaration(type(int.class), "bci");
startGetFrame(b, "frame", type(int.class), false).string("BCI_IDX").end();
startGetFrame(b, "frame", type(int.class), false).string("BCI_INDEX").end();
b.end();
b.startIf().string("locals[localIndexToTableIndex(bci, localIndex) + LOCALS_OFFSET_FRAME_INDEX] != frameIndex").end().startBlock();
b.tree(GeneratorUtils.createShouldNotReachHere("Inconsistent indices"));
Expand Down Expand Up @@ -9839,7 +9839,7 @@ private CodeExecutableElement createValidateBytecodes() {
if (!rootNodeAvailable) {
rootNodeAvailable = tryEmitRootNodeForLocalInstruction(b, group);
}
b.startIf().string(localName).string(" < USER_LOCALS_START_IDX");
b.startIf().string(localName).string(" < USER_LOCALS_START_INDEX");
if (rootNodeAvailable) {
b.string(" || ").string(localName).string(" >= root.maxLocals");
}
Expand Down Expand Up @@ -10978,11 +10978,11 @@ private CodeExecutableElement createFindBytecodeIndex1() {
if (model.enableYield) {
/**
* If the frame is from a continuation, the bci will be in the locals frame,
* which is stored in slot COROUTINE_FRAME_IDX.
* which is stored in slot COROUTINE_FRAME_INDEX.
*/
b.declaration(types.Frame, "frame", getFrame);
b.startDeclaration(types.Frame, "coroutineFrame");
b.cast(types.Frame).startCall("frame.getObject").string(COROUTINE_FRAME_IDX).end();
b.cast(types.Frame).startCall("frame.getObject").string(COROUTINE_FRAME_INDEX).end();
b.end();

b.startIf().string("coroutineFrame != null").end().startBlock();
Expand All @@ -10991,12 +10991,12 @@ private CodeExecutableElement createFindBytecodeIndex1() {

b.startReturn();
b.startCall("frame", "getInt");
b.string(BCI_IDX);
b.string(BCI_INDEX);
b.end(2);
} else {
b.startReturn();
b.startCall(getFrame, "getInt");
b.string(BCI_IDX);
b.string(BCI_INDEX);
b.end(2);
}
} else {
Expand All @@ -11018,7 +11018,7 @@ private CodeExecutableElement createFindBytecodeIndex2() {
}

if (useFrameForBytecodeIndex()) {
b.startReturn().string("frame.getInt(" + BCI_IDX + ")").end();
b.startReturn().string("frame.getInt(" + BCI_INDEX + ")").end();
} else {
b.startReturn().string("-1").end();
}
Expand All @@ -11030,7 +11030,7 @@ private CodeExecutableElement createGetBytecodeIndex() {
CodeExecutableElement ex = GeneratorUtils.overrideImplement(types.BytecodeNode, "getBytecodeIndex");
ex.renameArguments("frame");
CodeTreeBuilder b = ex.createBuilder();
b.startReturn().string("frame.getInt(" + BCI_IDX + ")").end();
b.startReturn().string("frame.getInt(" + BCI_INDEX + ")").end();
return ex;
}

Expand Down Expand Up @@ -11606,7 +11606,7 @@ private List<CodeExecutableElement> createContinueAt() {
if (model.needsBciSlot() && !model.storeBciInFrame && !tier.isUncached()) {
// If a bci slot is allocated but not used for non-uncached interpreters, set it to
// an invalid value just in case it gets read during a stack walk.
b.statement("FRAMES.setInt(" + localFrame() + ", " + BCI_IDX + ", -1)");
b.statement("FRAMES.setInt(" + localFrame() + ", " + BCI_INDEX + ", -1)");
}

b.string("loop: ").startWhile().string("true").end().startBlock();
Expand Down Expand Up @@ -14336,7 +14336,7 @@ private void buildCallExecute(CodeTreeBuilder b, InstructionModel instr, String
*/
private void storeBciInFrameIfNecessary(CodeTreeBuilder b) {
if (tier.isUncached() || model.storeBciInFrame) {
b.statement("FRAMES.setInt(" + localFrame() + ", " + BCI_IDX + ", bci)");
b.statement("FRAMES.setInt(" + localFrame() + ", " + BCI_INDEX + ", bci)");
}
}

Expand Down Expand Up @@ -14493,7 +14493,7 @@ private CodeExecutableElement createExecute() {

b.lineComment("Copy any existing stack values (from numLocals to sp - 1) to the current frame, which will be used for stack accesses.");
b.statement(copyFrameTo("parentFrame", "root.maxLocals", "frame", "root.maxLocals", "sp - 1"));
b.statement(setFrameObject(COROUTINE_FRAME_IDX, "parentFrame"));
b.statement(setFrameObject(COROUTINE_FRAME_INDEX, "parentFrame"));
b.statement(setFrameObject("root.maxLocals + sp - 1", "inputValue"));
b.declaration(types.BytecodeLocation, "bytecodeLocation", "location");
b.statement("int startState = ((sp + root.maxLocals) << 16) | (bytecodeLocation.getBytecodeIndex() & 0xFFFF)");
Expand Down Expand Up @@ -14529,7 +14529,7 @@ private CodeExecutableElement createFindFrame() {
CodeTreeBuilder b = ex.createBuilder();
b.startReturn();
b.cast(types.Frame);
startGetFrame(b, "frame", type(Object.class), false).string(COROUTINE_FRAME_IDX).end();
startGetFrame(b, "frame", type(Object.class), false).string(COROUTINE_FRAME_INDEX).end();
b.end();
return ex;
}
Expand Down