Skip to content
Draft
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
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ObjectFlags.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface ObjectFlags {
int FALSE_F = registry.newFlag(RubyBasicObject.class);
int NIL_F = registry.newFlag(RubyBasicObject.class);
int FROZEN_F = registry.newFlag(RubyBasicObject.class);
int SHAREABLE_F = registry.newFlag(RubyBasicObject.class);

int CACHEPROXY_F = registry.newFlag(RubyModule.class);
int NEEDSIMPL_F = registry.newFlag(RubyModule.class);
Expand All @@ -21,9 +22,9 @@ public interface ObjectFlags {
int TEMPORARY_NAME = registry.newFlag(RubyModule.class);

// order is important here; CR_7BIT_f needs to be 16 and CR_VALID_F needs to be 32 to match values in Prism parser
int FSTRING = registry.newFlag(RubyString.class);
int CR_7BIT_F = registry.newFlag(RubyString.class);
int CR_VALID_F = registry.newFlag(RubyString.class);
int FSTRING = registry.newFlag(RubyString.class);
int CHILLED_LITERAL_F = registry.newFlag(RubyString.class);
int CHILLED_SYMBOL_TO_S_F = registry.newFlag(RubyString.class);

Expand Down
11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import org.jruby.exceptions.LocalJumpError;
import org.jruby.exceptions.SystemExit;
import org.jruby.ext.jruby.JRubyUtilLibrary;
import org.jruby.ext.ractor.Ractor;
import org.jruby.ext.thread.ConditionVariable;
import org.jruby.ext.thread.Mutex;
import org.jruby.ext.thread.Queue;
Expand Down Expand Up @@ -584,14 +585,16 @@ private void initBootLibraries(ThreadContext context) {
// init Ruby-based kernel
initRubyKernel();

if (this.config.isRactorEnabled()) loadService(context).load("jruby/kernel/ractor.rb", false);

// Define blank modules for feature detection in preludes
if (!this.config.isDisableGems()) {
if (this.config.isGemsEnabled()) {
Define.defineModule(context, "Gem");
if (!this.config.isDisableErrorHighlight()) {
if (this.config.isErrorHighlightEnabled()) {
warnings.warn("ErrorHighlight does not currently support JRuby and will not be loaded");
}
if (!this.config.isDisableDidYouMean()) Define.defineModule(context, "DidYouMean");
if (!this.config.isDisableSyntaxSuggest()) Define.defineModule(context, "SyntaxSuggest");
if (this.config.isDidYouMeanEnabled()) Define.defineModule(context, "DidYouMean");
if (this.config.isSyntaxSuggestEnabled()) Define.defineModule(context, "SyntaxSuggest");
}

// Provide some legacy libraries
Expand Down
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Original file line number Diff line number Diff line change
Expand Up @@ -3113,6 +3113,10 @@ private void readObject(ObjectInputStream ois) throws IOException, ClassNotFound
metaClass.getVariableTableManager().deserializeVariables(this, ois);
}

public boolean isShareable() {
return getFlag(ObjectFlags.SHAREABLE_F);
}

/**
* Retrieve the call sites for this class.
*
Expand Down
128 changes: 98 additions & 30 deletions core/src/main/java/org/jruby/RubyInstanceConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ public void tryProcessArgumentsWithRubyopts() {
}

public void processArgumentsWithRubyopts() {
if (disableRUBYOPT) return;
if (!enableRUBYOPT) return;

// environment defaults to System.getenv normally
Object rubyoptObj = environment.get("RUBYOPT");
Expand Down Expand Up @@ -1203,67 +1203,89 @@ public void setHasShebangLine(boolean hasShebangLine) {
this.hasShebangLine = hasShebangLine;
}

public void setAllFeaturesEnabled(boolean ea) {
// disable all features
for (ArgumentProcessor.Feature feature: ArgumentProcessor.Feature.values()) {
if (feature == ArgumentProcessor.Feature.ALL) continue; // skip self
feature.enabler.accept(this, ea);
}
}

/**
* @see Options#CLI_RUBYGEMS_ENABLE
*/
public boolean isDisableGems() {
return disableGems;
public boolean isGemsEnabled() {
return enableGems;
}

/**
* @see Options#CLI_RUBYGEMS_ENABLE
*/
public void setGemsEnabled(boolean eg) {
this.enableGems = eg;
}

/**
* @see Options#CLI_DID_YOU_MEAN_ENABLE
*/
public boolean isDisableDidYouMean() {
return disableDidYouMean;
public boolean isDidYouMeanEnabled() {
return enableDidYouMean;
}

/**
* @see Options#CLI_DID_YOU_MEAN_ENABLE
*/
public void setDidYouMeanEnabled(boolean edym) {
this.enableDidYouMean = edym;
}

/**
* @see Options#CLI_ERROR_HIGHLIGHT_ENABLE
*/
public boolean isDisableErrorHighlight() {
return disableErrorHighlight;
public boolean isErrorHighlightEnabled() {
return enableErrorHighlight;
}

/**
* @see Options#CLI_SYNTAX_SUGGEST_ENABLE
* @see Options#CLI_ERROR_HIGHLIGHT_ENABLE
*/
public boolean isDisableSyntaxSuggest() {
return disableSyntaxSuggest;
public void setErrorHighlightEnabled(boolean eeh) {
this.enableErrorHighlight = eeh;
}

/**
* @see Options#CLI_RUBYOPT_ENABLE
* @see Options#CLI_SYNTAX_SUGGEST_ENABLE
*/
public void setDisableRUBYOPT(boolean dr) {
this.disableRUBYOPT = dr;
public boolean isSyntaxSuggestEnabled() {
return enableSyntaxSuggest;
}

/**
* @see Options#CLI_RUBYGEMS_ENABLE
* @see Options#CLI_SYNTAX_SUGGEST_ENABLE
*/
public void setDisableGems(boolean dg) {
this.disableGems = dg;
public void setSyntaxSuggestEnabled(boolean ess) {
this.enableSyntaxSuggest = ess;
}

/**
* @see Options#CLI_DID_YOU_MEAN_ENABLE
* @see Options#CLI_RUBYOPT_ENABLE
*/
public void setDisableDidYouMean(boolean ddym) {
this.disableDidYouMean = ddym;
public void setRUBYOPTEnabled(boolean er) {
this.enableRUBYOPT = er;
}

/**
* @see Options#CLI_ERROR_HIGHLIGHT_ENABLE
* @see Options#CLI_RACTOR_ENABLE
*/
public void setDisableErrorHighlight(boolean eh) {
this.disableErrorHighlight = eh;
public boolean isRactorEnabled() {
return enableRactor;
}

/**
* @see Options#CLI_SYNTAX_SUGGEST_ENABLE
* @see Options#CLI_RACTOR_ENABLE
*/
public void setDisableSyntaxSuggest(boolean ss) {
this.disableSyntaxSuggest = ss;
public void setRactorEnabled(boolean er) {
this.enableRactor = er;
}

/**
Expand Down Expand Up @@ -1592,11 +1614,12 @@ public ClassLoader getCurrentThreadClassLoader() {
private String inPlaceBackupExtension = Options.CLI_BACKUP_EXTENSION.load();
private boolean parserDebug = false;
private boolean hardExit = false;
private boolean disableGems = !Options.CLI_RUBYGEMS_ENABLE.load();
private boolean disableDidYouMean = !Options.CLI_DID_YOU_MEAN_ENABLE.load();
private boolean disableErrorHighlight = !Options.CLI_ERROR_HIGHLIGHT_ENABLE.load();
private boolean disableSyntaxSuggest = !Options.CLI_SYNTAX_SUGGEST_ENABLE.load();
private boolean disableRUBYOPT = !Options.CLI_RUBYOPT_ENABLE.load();
private boolean enableGems = Options.CLI_RUBYGEMS_ENABLE.load();
private boolean enableDidYouMean = Options.CLI_DID_YOU_MEAN_ENABLE.load();
private boolean enableErrorHighlight = Options.CLI_ERROR_HIGHLIGHT_ENABLE.load();
private boolean enableSyntaxSuggest = Options.CLI_SYNTAX_SUGGEST_ENABLE.load();
private boolean enableRUBYOPT = Options.CLI_RUBYOPT_ENABLE.load();
private boolean enableRactor = Options.CLI_RACTOR_ENABLE.load();
private boolean updateNativeENVEnabled = true;
private boolean kernelGsubDefined;
private boolean hasScriptArgv = false;
Expand Down Expand Up @@ -2044,4 +2067,49 @@ public void setGlobalRequireLock(boolean globalRequireLock) {

@Deprecated(since = "9.4.3.0")
public static final boolean FASTOPS_COMPILE_ENABLED = Options.COMPILE_FASTOPS.load();

@Deprecated
public boolean isDisableGems() {
return !enableGems;
}

@Deprecated(since = "10.0.3.0")
public void setDisableGems(boolean dg) {
this.enableGems = !dg;
}

@Deprecated(since = "10.0.3.0")
public boolean isDisableDidYouMean() {
return !enableDidYouMean;
}

@Deprecated(since = "10.0.3.0")
public void setDisableDidYouMean(boolean ddym) {
this.enableDidYouMean = !ddym;
}

@Deprecated(since = "10.0.3.0")
public boolean isDisableErrorHighlight() {
return !enableErrorHighlight;
}

@Deprecated(since = "10.0.3.0")
public void setDisableErrorHighlight(boolean deh) {
this.enableErrorHighlight = !deh;
}

@Deprecated(since = "10.0.3.0")
public boolean isDisableSyntaxSuggest() {
return !enableSyntaxSuggest;
}

@Deprecated(since = "10.0.3.0")
public void setDisableSyntaxSuggest(boolean dss) {
this.enableSyntaxSuggest = !dss;
}

@Deprecated(since = "10.0.3.0")
public void setDisableRUBYOPT(boolean dr) {
this.enableRUBYOPT = !dr;
}
}
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/RubyModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,8 @@ protected RubyModule(Ruby runtime, RubyClass metaClass, boolean objectSpace) {

// set up an invalidator for use in new optimization strategies
methodInvalidator = OptoFactory.newMethodInvalidator(this);

setFlag(ObjectFlags.SHAREABLE_F, true);
}

/** used by MODULE_ALLOCATOR and RubyClass constructors
Expand Down
9 changes: 8 additions & 1 deletion core/src/main/java/org/jruby/RubyStruct.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;

import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
Expand Down Expand Up @@ -803,8 +804,14 @@ public RubyFixnum size() {
}

public IRubyObject eachInternal(ThreadContext context, Block block) {
visitValues(context, block);

return this;
}

public IRubyObject visitValues(ThreadContext context, BiFunction<ThreadContext, IRubyObject, IRubyObject> visitor) {
for (int i = 0; i < values.length; i++) {
block.yield(context, values[i]);
visitor.apply(context, values[i]);
}

return this;
Expand Down
5 changes: 5 additions & 0 deletions core/src/main/java/org/jruby/api/Error.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import org.jruby.exceptions.IOError;
import org.jruby.exceptions.NotImplementedError;
import org.jruby.exceptions.RaiseException;
import org.jruby.exceptions.RuntimeError;
import org.jruby.exceptions.TypeError;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
Expand Down Expand Up @@ -276,4 +277,8 @@ private static IRubyObject typeFor(Ruby runtime, IRubyObject object) {
public static EOFError eofError(ThreadContext context, String message) {
return (EOFError) context.runtime.newEOFError(message);
}

public static RaiseException ractorError(ThreadContext context, String s) {
return RuntimeError.from(context.runtime, s);
}
}
Loading
Loading