Actions
Bug #5690
closedSupport of L_SHIFT and L_ROTATE for 64-bit operands
Start date:
03/05/2015
Due date:
% Done:
100%
Estimated time:
Detected in build:
2.1.5-beta-150305
Platform:
Published in build:
150324
Description
This description of operation results in illegal argument exception.
operand2 = rm<63> | (rm<62..0> << imm6); /*LSL*/
or
operand2 = rm<63> | (rm<62..0> <<< imm6); /*LSR*/
Result of test generation:
java.lang.IllegalArgumentException: The L_ROTATE operation cannot be performed for Type.INT(63) and Type.INT(63) operands. at ru.ispras.microtesk.model.api.data.DataEngine.checkOperationSupported(Unknown Source) at ru.ispras.microtesk.model.api.data.DataEngine.execute(Unknown Source) at ru.ispras.microtesk.model.armv8.op.adds.action(Unknown Source) at ru.ispras.microtesk.model.api.instruction.InstructionCall.execute(Unknown Source) at ru.ispras.microtesk.test.template.ConcreteCall.execute(Unknown Source) at ru.ispras.microtesk.test.Executor.executeCall(Unknown Source) at ru.ispras.microtesk.test.Executor.executeSequence(Unknown Source) at ru.ispras.microtesk.test.Executor.executeSequence(Unknown Source) at ru.ispras.microtesk.test.TestEngine$TemplateProcessor.processSequences(Unknown Source) at ru.ispras.microtesk.test.TestEngine$TemplateProcessor.processMainSection(Unknown Source) at ru.ispras.microtesk.test.TestEngine$TemplateProcessor.process(Unknown Source) at ru.ispras.microtesk.test.TestEngine$TemplateProcessor.access$100(Unknown Source) at ru.ispras.microtesk.test.TestEngine.process(Unknown Source) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) at org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(JavaMethod.java:455) at org.jruby.javasupport.JavaMethod.invokeDirect(JavaMethod.java:316) at org.jruby.java.invokers.InstanceMethodInvoker.call(InstanceMethodInvoker.java:61) at org.jruby.runtime.callsite.CachingCallSite.cacheAndCall(CachingCallSite.java:326) at org.jruby.runtime.callsite.CachingCallSite.call(CachingCallSite.java:170) at org.jruby.ast.CallOneArgNode.interpret(CallOneArgNode.java:57) at org.jruby.ast.NewlineNode.interpret(NewlineNode.java:105) at org.jruby.ast.BlockNode.interpret(BlockNode.java:71) at org.jruby.evaluator.ASTInterpreter.INTERPRET_METHOD(ASTInterpreter.java:75) at org.jruby.internal.runtime.methods.InterpretedMethod.call(InterpretedMethod.java:182) at org.jruby.internal.runtime.methods.DefaultMethod.call(DefaultMethod.java:188) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:149) at C_3a_.work.microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305.lib.ruby.microtesk.chained_2_rescue_1$RUBY$SYNTHETICmain(C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:48) at C_3a_.work.microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305.lib.ruby.microtesk.block_0$RUBY$main(C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:44) at C_3a_$work$microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305$lib$ruby$microtesk$block_0$RUBY$main.call(C_3a_$work$microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305$lib$ruby$microtesk$block_0$RUBY$main) at org.jruby.runtime.CompiledBlock19.yield(CompiledBlock19.java:139) at org.jruby.runtime.Block.yield(Block.java:130) at org.jruby.RubyHash$13.visit(RubyHash.java:1270) at org.jruby.RubyHash.visitAll(RubyHash.java:627) at org.jruby.RubyHash.iteratorVisitAll(RubyHash.java:1221) at org.jruby.RubyHash.each_pairCommon(RubyHash.java:1266) at org.jruby.RubyHash.each19(RubyHash.java:1257) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:224) at C_3a_.work.microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305.lib.ruby.microtesk.method__1$RUBY$main(C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:43) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at java.lang.invoke.MethodHandle.invokeWithArguments(Unknown Source) at org.jruby.runtime.invokedynamic.InvocationLinker.invocationFallback(InvocationLinker.java:132) at C_3a_.work.microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305.lib.ruby.microtesk.__file__(C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:111) at C_3a_.work.microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305.lib.ruby.microtesk.load(C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb) at org.jruby.Ruby.runScript(Ruby.java:815) at org.jruby.Ruby.runScript(Ruby.java:808) at org.jruby.Ruby.runNormally(Ruby.java:679) at org.jruby.Ruby.runFromMain(Ruby.java:528) at org.jruby.Main.doRunFromMain(Main.java:390) at org.jruby.Main.internalRun(Main.java:279) at org.jruby.Main.run(Main.java:221) at org.jruby.Main.main(Main.java:201) null:-1:in `checkOperationSupported': java.lang.IllegalArgumentException: The L_ROTATE operation cannot be performed for Type.INT(63) and Type.INT(63) operands. from null:-1:in `execute' from null:-1:in `action' from null:-1:in `execute' from null:-1:in `execute' from null:-1:in `executeCall' from null:-1:in `executeSequence' from null:-1:in `executeSequence' from null:-1:in `processSequences' from null:-1:in `processMainSection' from null:-1:in `process' from null:-1:in `access$100' from null:-1:in `process' from null:-2:in `invoke0' from null:-1:in `invoke' from null:-1:in `invoke' from null:-1:in `invoke' from JavaMethod.java:455:in `invokeDirectWithExceptionHandling' from JavaMethod.java:316:in `invokeDirect' from InstanceMethodInvoker.java:61:in `call' from CachingCallSite.java:326:in `cacheAndCall' from CachingCallSite.java:170:in `call' from CallOneArgNode.java:57:in `interpret' from NewlineNode.java:105:in `interpret' from BlockNode.java:71:in `interpret' from ASTInterpreter.java:75:in `INTERPRET_METHOD' from InterpretedMethod.java:182:in `call' from DefaultMethod.java:188:in `call' from null:-1:in `invokeWithArguments' from InvocationLinker.java:149:in `invocationFallback' from C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:48:in `chained_2_rescue_1$RUBY$SYNTHETICmain' from C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:44:in `block_0$RUBY$main' from C_3a_$work$microtesk_minus_2_dot_1_dot_5_minus_beta_minus_150305$lib$ruby$microtesk$block_0$RUBY$main:-1:in `call' from CompiledBlock19.java:139:in `yield' from Block.java:130:in `yield' from RubyHash.java:1270:in `visit' from RubyHash.java:627:in `visitAll' from RubyHash.java:1221:in `iteratorVisitAll' from RubyHash.java:1266:in `each_pairCommon' from RubyHash.java:1257:in `each19' from null:-1:in `invokeWithArguments' from null:-1:in `invokeWithArguments' from null:-1:in `invokeWithArguments' from InvocationLinker.java:224:in `invocationFallback' from C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:43:in `method__1$RUBY$main' from null:-1:in `invokeWithArguments' from null:-1:in `invokeWithArguments' from null:-1:in `invokeWithArguments' from null:-1:in `invokeWithArguments' from InvocationLinker.java:132:in `invocationFallback' from C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:111:in `__file__' from C:\work\microtesk-2.1.5-beta-150305/lib/ruby/microtesk.rb:-1:in `load' from Ruby.java:815:in `runScript' from Ruby.java:808:in `runScript' from Ruby.java:679:in `runNormally' from Ruby.java:528:in `runFromMain' from Main.java:390:in `doRunFromMain' from Main.java:279:in `internalRun' from Main.java:221:in `run' from Main.java:201:in `main'
Updated by Andrei Tatarnikov over 9 years ago
Дело в том, что сдвиги реализованы так, что величина смещения указывается как int (32 бита). Если второй операнд больше 32 бит, то возможнен некорректный результат. Поэтому API ругается. Нужно подумать, как это грамотно реализовать.
Более простой пример:
public class DataEngineTestCase {
@Test
public void test() {
final Type SHORT = Type.CARD(33);
DataEngine.execute(
EOperatorID.L_ROTATE,
new Data(BitVector.valueOf(1, SHORT.getBitSize()), SHORT),
new Data(BitVector.valueOf(2, SHORT.getBitSize()), SHORT)
);
}
}
Updated by Mikhail Chupilko over 9 years ago
Вспомогательная информация:
op adds (rd: REG, rn: REG, rm: REG, imm6: card(6), shift: card(2))
mode REG (i : INDEX) = GPR[i]
reg GPR [32, DWORD]
type DWORD = int(64)
Updated by Andrei Tatarnikov over 9 years ago
it is relatively easy to fix. Changes in Fortress are needed. The changes imply using BiegInteger instead of int to calculate the offset. For example:
public static BitVector shl(BitVector v, BigInteger to) {
checkNotNull(v);
checkNotNull(to);
final BigInteger bitSize = BigInteger.valueOf(v.getBitSize());
final BigInteger bitDistance = to.mod(bitSize).abs();
if (bitDistance.equals(BigInteger.ZERO)) {
return v;
}
final int distance = bitDistance.intValue();
final BitVector result = BitVector.newEmpty(v.getBitSize());
if (to.compareTo(BigInteger.ZERO) > 0) {
BitVectorAlgorithm.copy(v, 0, result, distance, result.getBitSize() - distance);
} else {
BitVectorAlgorithm.copy(v, 0, result, result.getBitSize() - distance, distance);
}
return result;
}
Updated by Alexander Kamkin over 9 years ago
- Subject changed from [model] Support of L_SHIFT and L_ROTATE for 64-bit operands to Support of L_SHIFT and L_ROTATE for 64-bit operands
- Category set to ISA Simulator
Updated by Andrei Tatarnikov over 9 years ago
- Status changed from New to Resolved
- % Done changed from 0 to 100
Fixed in r3320. A unit test has been added.
Updated by Mikhail Chupilko over 9 years ago
- Status changed from Resolved to Verified
It also works in my examples.
Updated by Alexander Kamkin over 9 years ago
- Category changed from ISA Simulator to 90
Updated by Andrei Tatarnikov over 9 years ago
- Status changed from Verified to Closed
- Published in build set to 150324
Actions