示例#1
0
  // TODO CS 20-Aug-15 this needs to go
  public static boolean verySlowIsFrozen(RubyContext context, Object object) {
    final RubyNode node =
        IsFrozenNodeGen.create(context, null, new LiteralNode(context, null, object));
    new Node() {
      @Child RubyNode child = node;
    }.adoptChildren();

    return (boolean) node.execute(null);
  }
示例#2
0
    @ExplodeLoop
    @Override
    public Object execute(VirtualFrame frame) {
      final Object[] store = PackedArrayStrategy.createStore();

      int size = 0;

      initializers:
      for (int n = 0; n < keyValues.length / 2; n++) {
        Object key = keyValues[n * 2].execute(frame);

        if (stringKeyProfile.profile(RubyGuards.isRubyString(key))) {
          if (isFrozenNode == null) {
            CompilerDirectives.transferToInterpreter();
            isFrozenNode = insert(IsFrozenNodeGen.create(getContext(), getSourceSection(), null));
          }

          if (!isFrozenNode.executeIsFrozen(key)) {
            key = freezeNode.call(frame, dupNode.call(frame, key, "dup", null), "freeze", null);
          }
        }

        final int hashed = hashNode.hash(frame, key);

        final Object value = keyValues[n * 2 + 1].execute(frame);

        for (int i = 0; i < n; i++) {
          if (i < size
              && hashed == PackedArrayStrategy.getHashed(store, i)
              && equalNode.callBoolean(
                  frame, key, "eql?", null, PackedArrayStrategy.getKey(store, i))) {
            PackedArrayStrategy.setKey(store, i, key);
            PackedArrayStrategy.setValue(store, i, value);
            continue initializers;
          }
        }

        PackedArrayStrategy.setHashedKeyValue(store, size, hashed, key, value);
        size++;
      }

      return HashNodes.createHash(getContext().getCoreLibrary().getHashClass(), store, size);
    }