Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion docs/user/Embedding-Permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ The Java backend's state is disconnected from the actual OS state:
- **File access checks:** `os.access()` and functionality based on the `faccessat` POSIX function do not support:
- Effective IDs
- `follow_symlinks=False` unless the mode is only `F_OK`
- **select.select:** Temporarily sets file descriptors to non-blocking mode which could affect other threads.
- **select.poll:** Temporarily sets file descriptors to non-blocking mode which could affect other threads. Only supports `POLLIN` and `POLLOUT` events. EOF is reported as `POLLIN`/`POLLOUT`.

## Context Security Configuration

When embedding GraalPy using the Polyglot API, you can configure security and access permissions through the `Context.Builder` class.
When embedding GraalPy using the Polyglot API, you can configure security and access permissions through the `Context.Builder` class.
These settings control what system resources and host functionality your embedded Python code can access.

This table shows the common security methods:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -868,13 +868,13 @@ abstract Object execute(Node inliningTarget, Object compiledRegex, Object compil
@Specialization(guards = "groupCount == 1")
static Object count1(Node inliningTarget, Object compiledRegex, Object compiledRegexMustAdvance, TruffleString input, int pos, int endpos, boolean binary, int groupCount,
@Cached @Exclusive FindAllInnerNode3 innerNode) {
return innerNode.execute(inliningTarget, compiledRegex, compiledRegexMustAdvance, input, pos, endpos, binary, groupCount, false);
return innerNode.execute(inliningTarget, compiledRegex, compiledRegexMustAdvance, input, pos, endpos, binary, 1, false);
}

@Specialization(guards = "groupCount == 2")
static Object count2(Node inliningTarget, Object compiledRegex, Object compiledRegexMustAdvance, TruffleString input, int pos, int endpos, boolean binary, int groupCount,
@Cached @Exclusive FindAllInnerNode3 innerNode) {
return innerNode.execute(inliningTarget, compiledRegex, compiledRegexMustAdvance, input, pos, endpos, binary, groupCount, false);
return innerNode.execute(inliningTarget, compiledRegex, compiledRegexMustAdvance, input, pos, endpos, binary, 2, false);
}

@Specialization(guards = "groupCount > 2")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,9 @@ private PythonOptions() {
@EngineOption @Option(category = OptionCategory.EXPERT, usageSyntax = "<limit>", help = "") //
public static final OptionKey<Integer> NodeRecursionLimit = new OptionKey<>(1);

@EngineOption @Option(category = OptionCategory.EXPERT, usageSyntax = "<count>", help = "") //
public static final OptionKey<Integer> MaxTypeInvalidationCount = new OptionKey<>(3);

@Option(category = OptionCategory.EXPERT, usageSyntax = "true|false", help = "Force to automatically import site.py module.", stability = OptionStability.STABLE) //
public static final OptionKey<Boolean> ForceImportSite = new OptionKey<>(false);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@
import java.util.HashMap;
import java.util.Map;

import com.oracle.graal.python.PythonLanguage;
import com.oracle.graal.python.builtins.objects.type.PythonAbstractClass;
import com.oracle.graal.python.runtime.PythonOptions;
import com.oracle.graal.python.util.PythonUtils;
import com.oracle.truffle.api.Assumption;
import com.oracle.truffle.api.CompilerAsserts;
Expand All @@ -53,7 +55,6 @@
import com.oracle.truffle.api.Truffle;
import com.oracle.truffle.api.dsl.NonIdempotent;
import com.oracle.truffle.api.strings.TruffleString;
import com.oracle.truffle.api.utilities.CyclicAssumption;
import com.oracle.truffle.api.utilities.TruffleWeakReference;

public final class MroSequenceStorage extends ArrayBasedSequenceStorage {
Expand All @@ -62,7 +63,8 @@ public final class MroSequenceStorage extends ArrayBasedSequenceStorage {
/**
* This assumption will be invalidated whenever the mro changes.
*/
private final CyclicAssumption lookupStableAssumption;
private Assumption lookupStableAssumption;
private int lookupStableAssumptionInvalidations;

/**
* These assumptions will be invalidated whenever the value of the given slot changes. All
Expand Down Expand Up @@ -123,7 +125,7 @@ public MroSequenceStorage(TruffleString className, PythonAbstractClass[] element
this.values = elements;
this.capacity = elements.length;
this.length = elements.length;
this.lookupStableAssumption = new CyclicAssumption(className.toJavaStringUncached());
this.lookupStableAssumption = createLookupStableAssumption();
this.attributesInMROFinalAssumptions = new HashMap<>();
}

Expand All @@ -133,7 +135,7 @@ public MroSequenceStorage(TruffleString className, int capacity) {
this.values = new PythonAbstractClass[capacity];
this.capacity = capacity;
this.length = 0;
this.lookupStableAssumption = new CyclicAssumption(className.toJavaStringUncached());
this.lookupStableAssumption = createLookupStableAssumption();
this.attributesInMROFinalAssumptions = new HashMap<>();
}

Expand Down Expand Up @@ -186,7 +188,7 @@ public StorageType getElementType() {
}

public Assumption getLookupStableAssumption() {
return lookupStableAssumption.getAssumption();
return lookupStableAssumption;
}

public FinalAttributeAssumptionPair getFinalAttributeAssumption(TruffleString name) {
Expand Down Expand Up @@ -221,7 +223,19 @@ public void lookupChanged() {
assumptionPair.invalidate();
}
}
lookupStableAssumption.invalidate();
if (lookupStableAssumption != Assumption.NEVER_VALID) {
lookupStableAssumption.invalidate();
if (lookupStableAssumptionInvalidations < PythonLanguage.get(null).getEngineOption(PythonOptions.MaxTypeInvalidationCount)) {
lookupStableAssumption = createLookupStableAssumption();
lookupStableAssumptionInvalidations++;
} else {
lookupStableAssumption = Assumption.NEVER_VALID;
}
}
}

private Assumption createLookupStableAssumption() {
return Truffle.getRuntime().createAssumption(className.toJavaStringUncached());
}

public NativeSequenceStorage getNativeMirror() {
Expand Down
Loading