Skip to content

Commit

Permalink
[Truffle] Abstract hash to index.
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisseaton committed Jan 8, 2015
1 parent efe40f5 commit 33a84f2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 192 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. This
* Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. This
* code is released under a tri EPL/GPL/LGPL license. You can use it,
* redistribute it and/or modify it under the terms of the:
*
Expand All @@ -13,14 +13,15 @@
import com.oracle.truffle.api.frame.VirtualFrame;
import com.oracle.truffle.api.nodes.UnexpectedResultException;
import org.jruby.truffle.nodes.RubyNode;
import org.jruby.truffle.nodes.control.PassthroughNode;
import org.jruby.truffle.runtime.UndefinedPlaceholder;
import org.jruby.truffle.runtime.control.RaiseException;
import org.jruby.truffle.runtime.core.CoreLibrary;
import org.jruby.truffle.runtime.core.RubyBasicObject;
import org.jruby.truffle.runtime.core.RubyRange;

public class FixnumLowerNode extends PassthroughNode {
public class FixnumLowerNode extends RubyNode {

@Child private RubyNode child;

@CompilerDirectives.CompilationFinal private boolean hasSeenInteger = false;
@CompilerDirectives.CompilationFinal private boolean hasSeenLong = false;
Expand All @@ -32,7 +33,8 @@ public class FixnumLowerNode extends PassthroughNode {
@CompilerDirectives.CompilationFinal private boolean hasNeededToLowerLongFixnumRange = false;

public FixnumLowerNode(RubyNode child) {
super(child);
super(child.getContext(), child.getEncapsulatingSourceSection());
this.child = child;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public HashSearchResult search(VirtualFrame frame, RubyHash hash, Object key) {
}

final Entry[] entries = (Entry[]) hash.getStore();
final int index = (hashed & HashOperations.SIGN_BIT_MASK) % entries.length;
final int index = HashOperations.getIndex(hashed, entries.length);
Entry entry = entries[index];

Entry previousEntry = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,4 +212,8 @@ public static void verySlowSetKeyValues(RubyHash hash, List<KeyValue> keyValues)

hash.setSize(actualSize);
}

public static int getIndex(int hashed, int entriesLength) {
return (hashed & HashOperations.SIGN_BIT_MASK) % entriesLength;
}
}

0 comments on commit 33a84f2

Please sign in to comment.