@Override
  public Object executeDispatch(
      VirtualFrame frame,
      Object receiverObject,
      Object methodName,
      DynamicObject blockObject,
      Object[] argumentsObjects) {
    if (!guard(methodName, receiverObject)) {
      return next.executeDispatch(frame, receiverObject, methodName, blockObject, argumentsObjects);
    }

    // Check the class has not been modified

    try {
      unmodifiedAssumption.check();
    } catch (InvalidAssumptionException e) {
      return resetAndDispatch(
          frame, receiverObject, methodName, blockObject, argumentsObjects, "class modified");
    }

    switch (getDispatchAction()) {
      case CALL_METHOD:
        return MISSING;

      case RESPOND_TO_METHOD:
        return false;

      default:
        throw new UnsupportedOperationException();
    }
  }
Ejemplo n.º 2
0
 private void poll(Node currentNode, boolean fromBlockingCall) {
   try {
     assumption.check();
   } catch (InvalidAssumptionException e) {
     assumptionInvalidated(currentNode, fromBlockingCall);
   }
 }
  @Override
  public Object executeDispatch(
      VirtualFrame frame,
      Object receiverObject,
      Object methodName,
      DynamicObject blockObject,
      Object[] argumentsObjects) {
    try {
      unmodifiedAssumption.check();
    } catch (InvalidAssumptionException e) {
      return resetAndDispatch(
          frame, receiverObject, methodName, blockObject, argumentsObjects, "class modified");
    }

    if (!guard(methodName, receiverObject)) {
      return next.executeDispatch(frame, receiverObject, methodName, blockObject, argumentsObjects);
    }

    switch (getDispatchAction()) {
      case CALL_METHOD:
        return call(callNode, frame, method, expectedReceiver, blockObject, argumentsObjects);

      case RESPOND_TO_METHOD:
        return true;

      default:
        throw new UnsupportedOperationException();
    }
  }
  @Override
  public Object executeDispatch(
      VirtualFrame frame,
      Object receiverObject,
      Object methodName,
      Object blockObject,
      Object argumentsObjects) {
    if (!guardName(methodName) || !(receiverObject instanceof RubySymbol)) {
      return next.executeDispatch(frame, receiverObject, methodName, blockObject, argumentsObjects);
    }

    // Check the class has not been modified

    try {
      unmodifiedAssumption.check();
    } catch (InvalidAssumptionException e) {
      return resetAndDispatch(
          frame,
          receiverObject,
          methodName,
          (RubyProc) blockObject,
          argumentsObjects,
          "class modified");
    }

    switch (getDispatchAction()) {
      case CALL_METHOD:
        {
          if (isIndirect()) {
            return indirectCallNode.call(
                frame,
                method.getCallTarget(),
                RubyArguments.pack(
                    method,
                    method.getDeclarationFrame(),
                    receiverObject,
                    (RubyProc) blockObject,
                    (Object[]) argumentsObjects));
          } else {
            return callNode.call(
                frame,
                RubyArguments.pack(
                    method,
                    method.getDeclarationFrame(),
                    receiverObject,
                    (RubyProc) blockObject,
                    (Object[]) argumentsObjects));
          }
        }

      case RESPOND_TO_METHOD:
        return true;

      case READ_CONSTANT:
        return value;

      default:
        throw new UnsupportedOperationException();
    }
  }
Ejemplo n.º 5
0
 @Override
 public void leave(Node astNode, VirtualFrame frame, Object result) {
   try {
     inactiveAssumption.check();
   } catch (InvalidAssumptionException e) {
     final ActiveLeaveDebugProbe activeNode = createActive();
     replace(activeNode);
     activeNode.leave(astNode, frame, result);
   }
 }
Ejemplo n.º 6
0
  @Override
  public void enter(Node node, VirtualFrame frame) {
    try {
      traceAssumption.check();
    } catch (InvalidAssumptionException e) {

      traceAssumption = context.getTraceManager().getTraceAssumption();
      traceFunc = context.getTraceManager().getTraceFunc();

      if (traceFunc != null) {
        callNode = insert(Truffle.getRuntime().createDirectCallNode(traceFunc.getCallTarget()));
      } else {
        callNode = null;
      }
    }

    if (traceFunc != null) {
      if (!context.getTraceManager().isInTraceFunc()) {
        context.getTraceManager().setInTraceFunc(true);

        final Object[] args =
            new Object[] {
              event,
              file,
              line,
              NilPlaceholder.INSTANCE,
              new RubyBinding(
                  context.getCoreLibrary().getBindingClass(),
                  RubyArguments.getSelf(frame.getArguments()),
                  frame.materialize()),
              NilPlaceholder.INSTANCE
            };

        try {
          callNode.call(
              frame,
              RubyArguments.pack(
                  traceFunc,
                  traceFunc.getDeclarationFrame(),
                  traceFunc.getSelfCapturedInScope(),
                  traceFunc.getBlockCapturedInScope(),
                  args));
        } finally {
          context.getTraceManager().setInTraceFunc(false);
        }
      }
    }
  }
  @Specialization(guards = "guardName")
  public Object dispatch(
      VirtualFrame frame,
      RubyNilClass methodReceiverObject,
      LexicalScope lexicalScope,
      RubySymbol receiverObject,
      Object methodName,
      Object blockObject,
      Object argumentsObjects,
      Dispatch.DispatchAction dispatchAction) {
    CompilerAsserts.compilationConstant(dispatchAction);

    // Check the class has not been modified

    try {
      unmodifiedAssumption.check();
    } catch (InvalidAssumptionException e) {
      return resetAndDispatch(
          frame,
          methodReceiverObject,
          lexicalScope,
          receiverObject,
          methodName,
          CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
          argumentsObjects,
          dispatchAction,
          "class modified");
    }

    if (dispatchAction == Dispatch.DispatchAction.CALL_METHOD) {
      return callNode.call(
          frame,
          RubyArguments.pack(
              method,
              method.getDeclarationFrame(),
              receiverObject,
              CompilerDirectives.unsafeCast(blockObject, RubyProc.class, true, false),
              CompilerDirectives.unsafeCast(argumentsObjects, Object[].class, true)));
    } else if (dispatchAction == Dispatch.DispatchAction.RESPOND_TO_METHOD) {
      return true;
    } else if (dispatchAction == Dispatch.DispatchAction.READ_CONSTANT) {
      return value;
    } else {
      throw new UnsupportedOperationException();
    }
  }