Comments (4)
I am currently working on cleanup of Source
creation sequence. I am going to introduce Source.Builder
, draft is available at https://github.com/jtulach/truffle/tree/SourceBuilder
The builder will not use any caching - e.g. your point 2 will be satisfied.
I find the description of point 1 a little bit too vague (unless it means "set the URI for a Source") - hard to guess whether my work satisfies it.
from graal.
To give some more background, I replaced 1 and 2 with my own code because:
- I wanted
Source
to behave uniformly regardless of which origin it was loaded from, in terms of eager vs. lazy loading, caching, etc. - I wanted to support the following different kinds of source code origins specific to my language: URL, File, class path, standard library, REPL input, literal text
- I wanted to easily determine the origin of a piece of source code and query its origin-specific attributes (e.g. to perform permission checks and to resolve relative script includes in an origin-specific way), without having to reconstruct this information from a
Source
's answers togetURL
,getPath
,getName
, etc. (which is brittle). - I wanted to have my own implementations for loading code from an origin (e.g. to perform permission checks and to leverage non-blocking IO).
- I needed to have my own representation of source (origin) anyway, as leaking Truffle classes from my APIs wasn't an option.
To satisfy these requirements, I currently do the following: I do my own loading/caching, exclusively use Source.fromText
to create Source
objects, and keep origin-specific information about the source in an IdentityHashMap
for later lookup. This works reasonably well. However, I'd rather not have to use IdentityHashMap
, and complications arise when I need to process a Source
that wasn't created by my own code. (I'd like to support this in order to be a good Truffle citizen.)
The following enhancements to Source
could make it a more versatile abstraction and a better fit for my needs:
- Allow to attach opaque meta-information to a
Source
. - Allow to easily determine which kind of built-in origin (
fromURL
,fromFilename
,fromText
, etc.) it was loaded from and what the origin-specific attributes are.
I also considered proposing a first-class, user-extensible notion of source origin, but this might not work so well in a polyglot setting.
from graal.
After jtulach@872a1e9 the origin is taken uniformly, I'd say.
The additional meta-information is out of scope for the current "builder" change, but it is an interesting idea. Similar to: when a co-located source is about to be loaded (think of importScript('rel.js')
) shouldn't that request be handled by the one who created the source that contains the importScript
?
from graal.
Looks like a stale issue where most issues are already resolved. Please reopen if addition work is necessary.
from graal.
Related Issues (20)
- Main entry point class 'HelloWorld.java' neither found on... on M2 HOT 5
- [GR-52475] Error with native image for ktfmt - Resource not found: /org/jetbrains/kotlin/cli/jvm/compiler/KotlinCoreEnvironment$Companion.class HOT 1
- Is there anything missing when graalvm-11uses JVM parameters to run java code? HOT 3
- GraalVM crashes with "fatal error: Initial size of CodeCache is too small" HOT 2
- [GR-52473] Serialization of arrays is not supported in Native Image HOT 4
- Classes not getting initialized HOT 1
- Build a spring boot3 project with hibernate-search and lucene backend, throw a 'undefined reference' error HOT 1
- [GR-52560] Size regression from GraalVM CE 23.0 to GraalVM for JDK 21 (CE) for `byte[] for code metadata` HOT 2
- JSON Metadata Versioning, Backwards Compatibility, and Evolution
- [GR-52553] Defining new classes at runtime is not supported HOT 2
- [GR-52591] Warning: Error processing trace entry map(size=5, {(tracer,reflect),(function,getSystemResource),(caller_class,org.apache.logging.log4j.core.util.Loader),(result,true),(args,[null])}): java.lang.NullPointerException HOT 3
- Caused by: java.lang.IllegalArgumentException: Method "list" could not be invoked HOT 14
- [GR-52611] Add the ability to add comments to JSON configuration file entries HOT 6
- --module-path directory: Modules Not Added HOT 5
- [GR-52818] javax.xml.transform.TransformerFactory.newTemplates(Source) NullPointerException in Native Image HOT 15
- Error: java.util.concurrent.ExecutionException: com.oracle.graal.pointsto.constraints.UnsupportedFeatureException: type is not available in this platform: com.oracle.svm.hosted.NativeImageSystemClassLoader HOT 1
- Instructions for building native-image-agent HOT 2
- [GR-52698] Cannot run SSL debug logs with GraalVM native image HOT 4
- the size of graal compiled program HOT 1
- Could not initialize class org.graalvm.polyglot.Engine$ImplHolder HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from graal.