Skip to content

Commit

Permalink
Merge branch 'master' into compile_more
Browse files Browse the repository at this point in the history
  • Loading branch information
enebo committed Dec 16, 2016
2 parents 70d4921 + e926a44 commit 31f0082
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 60 deletions.
33 changes: 33 additions & 0 deletions core/src/main/java/org/jruby/ObjectFlags.java
@@ -0,0 +1,33 @@
package org.jruby;

import org.jruby.ext.stringio.StringIO;

/**
* Flags used by RubyBasicObject descendants.
*/
public interface ObjectFlags {
FlagRegistry registry = new FlagRegistry();

// These flags must be registered from top of hierarchy down to maintain order.
// TODO: Replace these during the build with their calculated values.
int FALSE_F = registry.newFlag(RubyBasicObject.class);
int NIL_F = registry.newFlag(RubyBasicObject.class);
int FROZEN_F = registry.newFlag(RubyBasicObject.class);
int TAINTED_F = registry.newFlag(RubyBasicObject.class);

int CACHEPROXY_F = registry.newFlag(RubyModule.class);
int NEEDSIMPL_F = registry.newFlag(RubyModule.class);
int REFINED_MODULE_F = registry.newFlag(RubyModule.class);
int IS_OVERLAID_F = registry.newFlag(RubyModule.class);

int CR_7BIT_F = registry.newFlag(RubyString.class);
int CR_VALID_F = registry.newFlag(RubyString.class);

int STRIO_READABLE = registry.newFlag(StringIO.class);
int STRIO_WRITABLE = registry.newFlag(StringIO.class);

int MATCH_BUSY = registry.newFlag(RubyMatchData.class);

int COMPARE_BY_IDENTITY_F = registry.newFlag(RubyHash.class);
int PROCDEFAULT_HASH_F = registry.newFlag(RubyHash.class);
}
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/RubyBasicObject.java
Expand Up @@ -30,7 +30,6 @@
import org.jcodings.Encoding;
import org.jcodings.specific.UTF8Encoding;
import org.jruby.ir.interpreter.Interpreter;
import org.jruby.runtime.Constants;
import org.jruby.runtime.JavaSites;
import org.jruby.runtime.JavaSites.BasicObjectSites;
import org.jruby.runtime.ivars.VariableAccessor;
Expand Down Expand Up @@ -143,7 +142,7 @@ public class RubyBasicObject implements Cloneable, IRubyObject, Serializable, Co
public static final String ERR_INSECURE_SET_INST_VAR = "Insecure: can't modify instance variable";

public static final int ALL_F = -1;
public static final int FALSE_F = Constants.FALSE_F;
public static final int FALSE_F = ObjectFlags.FALSE_F;
/**
* This flag is a bit funny. It's used to denote that this value
* is nil. It's a bit counterintuitive for a Java programmer to
Expand All @@ -154,9 +153,9 @@ public class RubyBasicObject implements Cloneable, IRubyObject, Serializable, Co
* final. It turns out using a flag for this actually gives us
* better performance than having a polymorphic {@link #isNil()} method.
*/
public static final int NIL_F = Constants.NIL_F;
public static final int FROZEN_F = Constants.FROZEN_F;
public static final int TAINTED_F = Constants.TAINTED_F;
public static final int NIL_F = ObjectFlags.NIL_F;
public static final int FROZEN_F = ObjectFlags.FROZEN_F;
public static final int TAINTED_F = ObjectFlags.TAINTED_F;

/**
* A value that is used as a null sentinel in among other places
Expand Down
11 changes: 2 additions & 9 deletions core/src/main/java/org/jruby/RubyHash.java
Expand Up @@ -44,20 +44,13 @@
import org.jruby.common.IRubyWarnings.ID;
import org.jruby.exceptions.RaiseException;
import org.jruby.javasupport.JavaUtil;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
import org.jruby.runtime.Binding;
import org.jruby.runtime.Block;
import org.jruby.runtime.BlockBody;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.Constants;
import org.jruby.runtime.Frame;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.JavaSites.HashSites;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.Signature;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.marshal.MarshalStream;
import org.jruby.runtime.marshal.UnmarshalStream;
Expand Down Expand Up @@ -118,7 +111,7 @@
public class RubyHash extends RubyObject implements Map {
public static final int DEFAULT_INSPECT_STR_SIZE = 20;

public static final int COMPARE_BY_IDENTITY_F = Constants.COMPARE_BY_IDENTITY_F;
public static final int COMPARE_BY_IDENTITY_F = ObjectFlags.COMPARE_BY_IDENTITY_F;

public static RubyClass createHashClass(Ruby runtime) {
RubyClass hashc = runtime.defineClass("Hash", runtime.getObject(), HASH_ALLOCATOR);
Expand Down Expand Up @@ -231,7 +224,7 @@ public static final RubyHash newHash(Ruby runtime, Map valueMap, IRubyObject def
protected int size = 0;
private int threshold;

private static final int PROCDEFAULT_HASH_F = Constants.PROCDEFAULT_HASH_F;
private static final int PROCDEFAULT_HASH_F = ObjectFlags.PROCDEFAULT_HASH_F;

private IRubyObject ifNone;

Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/org/jruby/RubyMatchData.java
Expand Up @@ -46,7 +46,6 @@
import org.jruby.anno.JRubyClass;
import org.jruby.runtime.Block;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.Constants;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.Visibility;
Expand Down Expand Up @@ -276,7 +275,7 @@ private void updateCharOffset() {
charOffsetUpdated = true;
}

private static final int MATCH_BUSY = Constants.MATCH_BUSY;
private static final int MATCH_BUSY = ObjectFlags.MATCH_BUSY;

// rb_match_busy
public final void use() {
Expand Down
9 changes: 4 additions & 5 deletions core/src/main/java/org/jruby/RubyModule.java
Expand Up @@ -93,7 +93,6 @@
import org.jruby.runtime.Block;
import org.jruby.runtime.CallSite;
import org.jruby.runtime.ClassIndex;
import org.jruby.runtime.Constants;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.IRBlockBody;
import org.jruby.runtime.MethodFactory;
Expand Down Expand Up @@ -134,10 +133,10 @@ public class RubyModule extends RubyObject {
private static final Logger LOG = LoggerFactory.getLogger(RubyModule.class);
// static { LOG.setDebugEnable(true); } // enable DEBUG output

public static final int CACHEPROXY_F = Constants.CACHEPROXY_F;
public static final int NEEDSIMPL_F = Constants.NEEDSIMPL_F;
public static final int REFINED_MODULE_F = Constants.REFINED_MODULE_F;
public static final int IS_OVERLAID_F = Constants.IS_OVERLAID_F;
public static final int CACHEPROXY_F = ObjectFlags.CACHEPROXY_F;
public static final int NEEDSIMPL_F = ObjectFlags.NEEDSIMPL_F;
public static final int REFINED_MODULE_F = ObjectFlags.REFINED_MODULE_F;
public static final int IS_OVERLAID_F = ObjectFlags.IS_OVERLAID_F;

public static final ObjectAllocator MODULE_ALLOCATOR = new ObjectAllocator() {
@Override
Expand Down
7 changes: 3 additions & 4 deletions core/src/main/java/org/jruby/ext/stringio/StringIO.java
Expand Up @@ -32,7 +32,7 @@

import org.jcodings.Encoding;
import org.jcodings.specific.ASCIIEncoding;
import org.jruby.FlagRegistry;
import org.jruby.ObjectFlags;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyClass;
Expand All @@ -49,7 +49,6 @@
import org.jruby.ast.util.ArgsUtil;
import org.jruby.java.addons.IOJavaAddons;
import org.jruby.runtime.Block;
import org.jruby.runtime.Constants;
import org.jruby.runtime.ObjectAllocator;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
Expand Down Expand Up @@ -81,8 +80,8 @@ static class StringIOData {
}
StringIOData ptr;

private static final int STRIO_READABLE = Constants.STRIO_READABLE;
private static final int STRIO_WRITABLE = Constants.STRIO_WRITABLE;
private static final int STRIO_READABLE = ObjectFlags.STRIO_READABLE;
private static final int STRIO_WRITABLE = ObjectFlags.STRIO_WRITABLE;
private static final int STRIO_READWRITE = (STRIO_READABLE | STRIO_WRITABLE);

private static ObjectAllocator STRINGIO_ALLOCATOR = new ObjectAllocator() {
Expand Down
8 changes: 3 additions & 5 deletions core/src/main/java/org/jruby/util/StringSupport.java
Expand Up @@ -35,15 +35,13 @@
import org.jcodings.specific.UTF8Encoding;
import org.jcodings.util.IntHash;
import org.joni.Matcher;
import org.jruby.FlagRegistry;
import org.jruby.ObjectFlags;
import org.jruby.Ruby;
import org.jruby.RubyArray;
import org.jruby.RubyEncoding;
import org.jruby.RubyIO;
import org.jruby.RubyObject;
import org.jruby.RubyString;
import org.jruby.runtime.Block;
import org.jruby.runtime.Constants;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.collections.IntHashMap;
Expand All @@ -56,8 +54,8 @@
import java.util.List;

public final class StringSupport {
public static final int CR_7BIT_F = Constants.CR_7BIT_F;
public static final int CR_VALID_F = Constants.CR_VALID_F;
public static final int CR_7BIT_F = ObjectFlags.CR_7BIT_F;
public static final int CR_VALID_F = ObjectFlags.CR_VALID_F;
public static final int CR_UNKNOWN = 0;

// We hardcode these so they can be used in a switch below. The assert verifies they match FlagRegistry's value.
Expand Down
30 changes: 0 additions & 30 deletions core/src/main/resources/org/jruby/runtime/Constants.java
Expand Up @@ -81,36 +81,6 @@ public final class Constants {
* The JIT threshold to the specified method invocation count.
*/
public static final int JIT_THRESHOLD = 50;

private static final FlagRegistry registry = new FlagRegistry();

// These flags must be registered from top of hierarchy down to maintain order.
// TODO: Replace these during the build with their calculated values.
public static final int FALSE_F = registry.newFlag(RubyBasicObject.class);
public static final int NIL_F = registry.newFlag(RubyBasicObject.class);
public static final int FROZEN_F = registry.newFlag(RubyBasicObject.class);
public static final int TAINTED_F = registry.newFlag(RubyBasicObject.class);

public static final int CACHEPROXY_F = registry.newFlag(RubyModule.class);
public static final int NEEDSIMPL_F = registry.newFlag(RubyModule.class);
public static final int REFINED_MODULE_F = registry.newFlag(RubyModule.class);
public static final int IS_OVERLAID_F = registry.newFlag(RubyModule.class);

public static final int CR_7BIT_F = registry.newFlag(RubyString.class);
public static final int CR_VALID_F = registry.newFlag(RubyString.class);

public static final int STRIO_READABLE = registry.newFlag(StringIO.class);
public static final int STRIO_WRITABLE = registry.newFlag(StringIO.class);

public static final int MATCH_BUSY = registry.newFlag(RubyMatchData.class);

public static final int COMPARE_BY_IDENTITY_F = registry.newFlag(RubyHash.class);
public static final int PROCDEFAULT_HASH_F = registry.newFlag(RubyHash.class);

private static final boolean DEBUG = false;
static {
if (DEBUG) registry.printFlags();
}

private static String jruby_revision = "@jruby.revision@";

Expand Down

0 comments on commit 31f0082

Please sign in to comment.