-
-
Notifications
You must be signed in to change notification settings - Fork 925
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Truffle] CallDispatchHeadNode and DoesRespondDispatchHeadNode.
- 9.4.12.0
- 9.4.11.0
- 9.4.10.0
- 9.4.9.0
- 9.4.8.0
- 9.4.7.0
- 9.4.6.0
- 9.4.5.0
- 9.4.4.0
- 9.4.3.0
- 9.4.2.0
- 9.4.1.0
- 9.4.0.0
- 9.3.15.0
- 9.3.14.0
- 9.3.13.0
- 9.3.12.0
- 9.3.11.0
- 9.3.10.0
- 9.3.9.0
- 9.3.8.0
- 9.3.7.0
- 9.3.6.0
- 9.3.5.0
- 9.3.4.0
- 9.3.3.0
- 9.3.2.0
- 9.3.1.0
- 9.3.0.0
- 9.2.21.0
- 9.2.20.1
- 9.2.20.0
- 9.2.19.0
- 9.2.18.0
- 9.2.17.0
- 9.2.16.0
- 9.2.15.0
- 9.2.14.0
- 9.2.13.0
- 9.2.12.0
- 9.2.11.1
- 9.2.11.0
- 9.2.10.0
- 9.2.9.0
- 9.2.8.0
- 9.2.7.0
- 9.2.6.0
- 9.2.5.0
- 9.2.4.1
- 9.2.4.0
- 9.2.3.0
- 9.2.2.0
- 9.2.1.0
- 9.2.0.0
- 9.1.17.0
- 9.1.16.0
- 9.1.15.0
- 9.1.14.0
- 9.1.13.0
- 9.1.12.0
- 9.1.11.0
- 9.1.10.0
- 9.1.9.0
- 9.1.8.0
- 9.1.7.0
- 9.1.6.0
- 9.1.5.0
- 9.1.4.0
- 9.1.3.0
- 9.1.2.0
- 9.1.1.0
- 9.1.0.0
- 9.0.5.0
- 9.0.4.0
- 9.0.3.0
- 9.0.1.0
- 9.0.0.0
- 9.0.0.0.rc2
- 9.0.0.0.rc1
- 9.0.0.0.pre2
- 9.0.0.0.pre1
1 parent
f2b1582
commit fb4b3b8
Showing
31 changed files
with
261 additions
and
264 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
103 changes: 103 additions & 0 deletions
103
core/src/main/java/org/jruby/truffle/nodes/dispatch/CallDispatchHeadNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
/* | ||
* Copyright (c) 2014, 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: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes.dispatch; | ||
|
||
import com.oracle.truffle.api.CompilerDirectives; | ||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import org.jruby.truffle.runtime.LexicalScope; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
import org.jruby.truffle.runtime.control.RaiseException; | ||
import org.jruby.truffle.runtime.core.RubyProc; | ||
|
||
public class CallDispatchHeadNode extends DispatchHeadNode { | ||
|
||
public CallDispatchHeadNode(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior, LexicalScope lexicalScope) { | ||
super(context, ignoreVisibility, indirect, missingBehavior, lexicalScope, DispatchAction.CALL_METHOD); | ||
} | ||
|
||
public Object call( | ||
VirtualFrame frame, | ||
Object receiverObject, | ||
Object methodName, | ||
RubyProc blockObject, | ||
Object... argumentsObjects) { | ||
return dispatch( | ||
frame, | ||
receiverObject, | ||
methodName, | ||
blockObject, | ||
argumentsObjects); | ||
} | ||
|
||
public double callFloat( | ||
VirtualFrame frame, | ||
Object receiverObject, | ||
Object methodName, | ||
RubyProc blockObject, | ||
Object... argumentsObjects) throws UseMethodMissingException { | ||
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects); | ||
|
||
if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) { | ||
throw new UseMethodMissingException(); | ||
} | ||
|
||
if (value instanceof Double) { | ||
return (double) value; | ||
} | ||
|
||
CompilerDirectives.transferToInterpreter(); | ||
|
||
final String message = String.format("%s (%s#%s gives %s)", | ||
context.getCoreLibrary().getFloatClass().getName(), | ||
context.getCoreLibrary().getLogicalClass(receiverObject).getName(), | ||
methodName, | ||
context.getCoreLibrary().getLogicalClass(value).getName()); | ||
|
||
throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo( | ||
context.getCoreLibrary().getLogicalClass(receiverObject).getName(), | ||
message, | ||
this)); | ||
} | ||
|
||
public long callLongFixnum( | ||
VirtualFrame frame, | ||
Object receiverObject, | ||
Object methodName, | ||
RubyProc blockObject, | ||
Object... argumentsObjects) throws UseMethodMissingException { | ||
final Object value = call(frame, receiverObject, methodName, blockObject, argumentsObjects); | ||
|
||
if (missingBehavior == MissingBehavior.RETURN_MISSING && value == DispatchNode.MISSING) { | ||
throw new UseMethodMissingException(); | ||
} | ||
|
||
if (value instanceof Integer) { | ||
return (int) value; | ||
} | ||
|
||
if (value instanceof Long) { | ||
return (long) value; | ||
} | ||
|
||
CompilerDirectives.transferToInterpreter(); | ||
|
||
final String message = String.format("%s (%s#%s gives %s)", | ||
context.getCoreLibrary().getFloatClass().getName(), | ||
context.getCoreLibrary().getLogicalClass(receiverObject).getName(), | ||
methodName, | ||
context.getCoreLibrary().getLogicalClass(value).getName()); | ||
|
||
throw new RaiseException(context.getCoreLibrary().typeErrorCantConvertTo( | ||
context.getCoreLibrary().getLogicalClass(receiverObject).getName(), | ||
message, | ||
this)); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
core/src/main/java/org/jruby/truffle/nodes/dispatch/DoesRespondDispatchHeadNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (c) 2014, 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: | ||
* | ||
* Eclipse Public License version 1.0 | ||
* GNU General Public License version 2 | ||
* GNU Lesser General Public License version 2.1 | ||
*/ | ||
package org.jruby.truffle.nodes.dispatch; | ||
|
||
import com.oracle.truffle.api.frame.VirtualFrame; | ||
import org.jruby.truffle.runtime.LexicalScope; | ||
import org.jruby.truffle.runtime.RubyContext; | ||
|
||
public class DoesRespondDispatchHeadNode extends DispatchHeadNode { | ||
|
||
public DoesRespondDispatchHeadNode(RubyContext context, boolean ignoreVisibility, boolean indirect, MissingBehavior missingBehavior, LexicalScope lexicalScope) { | ||
super(context, ignoreVisibility, indirect, missingBehavior, lexicalScope, DispatchAction.RESPOND_TO_METHOD); | ||
} | ||
|
||
/** | ||
* Check if a specific method is defined on the receiver object. | ||
* This check is "static" and should only be used in a few VM operations. | ||
* In many cases, a dynamic call to Ruby's respond_to? should be used instead. | ||
* Similar to MRI rb_check_funcall(). | ||
*/ | ||
public boolean doesRespondTo( | ||
VirtualFrame frame, | ||
Object methodName, | ||
Object receiverObject) { | ||
// It's ok to cast here as we control what RESPOND_TO_METHOD returns | ||
return (boolean) dispatch( | ||
frame, | ||
receiverObject, | ||
methodName, | ||
null, | ||
null); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 0 additions & 29 deletions
29
core/src/main/java/org/jruby/truffle/runtime/util/TypeConversionUtils.java
This file was deleted.
Oops, something went wrong.
fb4b3b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@eregon @nirvdrum there's now a couple of subclasses of
DispatchHeadNode
,CallDispatchHeadNode
andDoesRespondDispatchHeadNode
- create these usingDispatchHeadNodeFactory
.CallDispatchHeadNode
has methods on it that return a particular type and will raiseTypeError
if it doesn't get it. I wrote those forMath
which passes all the specs so they hopefully do the right thing in most cases. This will help us to get rid of all the random casts we often have after calls to dispatch.fb4b3b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, is it on purpose that not all nodes use the factory yet?
fb4b3b8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No - I'll make the constructor of
DispatchHeadNode
package protected and then we will be able to update them.