Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
asmdex
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
9
Issues
9
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Container Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
asm
asmdex
Commits
a328bf64
Commit
a328bf64
authored
Oct 28, 2012
by
pcregut
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check that indices are correct before writing them out.
parent
b34efe51
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
42 additions
and
2 deletions
+42
-2
src/org/ow2/asmdex/instruction/Instruction.java
src/org/ow2/asmdex/instruction/Instruction.java
+19
-1
src/org/ow2/asmdex/instruction/InstructionFormat11N.java
src/org/ow2/asmdex/instruction/InstructionFormat11N.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat11X.java
src/org/ow2/asmdex/instruction/InstructionFormat11X.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat12X.java
src/org/ow2/asmdex/instruction/InstructionFormat12X.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat21C.java
src/org/ow2/asmdex/instruction/InstructionFormat21C.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat21H.java
src/org/ow2/asmdex/instruction/InstructionFormat21H.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat21S.java
src/org/ow2/asmdex/instruction/InstructionFormat21S.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat21T.java
src/org/ow2/asmdex/instruction/InstructionFormat21T.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat22B.java
src/org/ow2/asmdex/instruction/InstructionFormat22B.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat22C.java
src/org/ow2/asmdex/instruction/InstructionFormat22C.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat22S.java
src/org/ow2/asmdex/instruction/InstructionFormat22S.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat22T.java
src/org/ow2/asmdex/instruction/InstructionFormat22T.java
+2
-0
src/org/ow2/asmdex/instruction/InstructionFormat22X.java
src/org/ow2/asmdex/instruction/InstructionFormat22X.java
+2
-0
src/org/ow2/asmdex/instruction/InstructionFormat23X.java
src/org/ow2/asmdex/instruction/InstructionFormat23X.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat31C.java
src/org/ow2/asmdex/instruction/InstructionFormat31C.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat31I.java
src/org/ow2/asmdex/instruction/InstructionFormat31I.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat31T.java
src/org/ow2/asmdex/instruction/InstructionFormat31T.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat32X.java
src/org/ow2/asmdex/instruction/InstructionFormat32X.java
+1
-0
src/org/ow2/asmdex/instruction/InstructionFormat35C.java
src/org/ow2/asmdex/instruction/InstructionFormat35C.java
+3
-1
src/org/ow2/asmdex/instruction/InstructionFormat51L.java
src/org/ow2/asmdex/instruction/InstructionFormat51L.java
+1
-0
No files found.
src/org/ow2/asmdex/instruction/Instruction.java
View file @
a328bf64
...
@@ -151,6 +151,23 @@ public abstract class Instruction {
...
@@ -151,6 +151,23 @@ public abstract class Instruction {
}
}
}
}
/**
* Tests if the given number can be held in 8 bits, throw an IllegalArgumentException otherwise.
*/
public
static
void
test8BitsLimit
(
int
number
)
{
if
((
number
&
0xffffff00
)
!=
0
)
{
throw
new
IllegalArgumentException
(
"The number "
+
number
+
" can't be held in 8 bits !"
);
}
}
/**
* Tests if the given number can be held in 16 bits, throw an IllegalArgumentException otherwise.
*/
public
static
void
test16BitsLimit
(
int
number
)
{
if
((
number
&
0xffff0000
)
!=
0
)
{
throw
new
IllegalArgumentException
(
"The number "
+
number
+
" can't be held in 16 bits !"
);
}
}
/**
/**
* Tests if the given numbers can be held in 4 bits, throw an IllegalArgumentException otherwise.
* Tests if the given numbers can be held in 4 bits, throw an IllegalArgumentException otherwise.
*/
*/
...
@@ -190,4 +207,5 @@ public abstract class Instruction {
...
@@ -190,4 +207,5 @@ public abstract class Instruction {
public
static
byte
getInstructionSizeInByte
(
int
opcode
)
{
public
static
byte
getInstructionSizeInByte
(
int
opcode
)
{
return
instructionSizeInBytes
[
opcode
];
return
instructionSizeInBytes
[
opcode
];
}
}
}
}
src/org/ow2/asmdex/instruction/InstructionFormat11N.java
View file @
a328bf64
...
@@ -98,6 +98,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
...
@@ -98,6 +98,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test4BitsLimit
(
registerA
);
int
firstShort
=
((
literalB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
int
firstShort
=
((
literalB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
out
.
putShort
(
firstShort
);
out
.
putShort
(
firstShort
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat11X.java
View file @
a328bf64
...
@@ -105,6 +105,7 @@ public class InstructionFormat11X extends Instruction implements IOneRegisterIns
...
@@ -105,6 +105,7 @@ public class InstructionFormat11X extends Instruction implements IOneRegisterIns
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat12X.java
View file @
a328bf64
...
@@ -139,6 +139,7 @@ public class InstructionFormat12X extends Instruction implements ITwoRegistersIn
...
@@ -139,6 +139,7 @@ public class InstructionFormat12X extends Instruction implements ITwoRegistersIn
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test4BitsLimit
(
registerA
|
registerB
);
int
firstShort
=
((
registerB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
int
firstShort
=
((
registerB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
out
.
putShort
(
firstShort
);
out
.
putShort
(
firstShort
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat21C.java
View file @
a328bf64
...
@@ -162,6 +162,7 @@ implements IOneRegisterInstruction, IIndexInstruction {
...
@@ -162,6 +162,7 @@ implements IOneRegisterInstruction, IIndexInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
// The format is AA|op BBBB.
// The format is AA|op BBBB.
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
// The index may be a Type, or a String index.
// The index may be a Type, or a String index.
...
...
src/org/ow2/asmdex/instruction/InstructionFormat21H.java
View file @
a328bf64
...
@@ -138,6 +138,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
...
@@ -138,6 +138,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(
literalB
&
0xffff
);
out
.
putShort
(
literalB
&
0xffff
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat21S.java
View file @
a328bf64
...
@@ -133,6 +133,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
...
@@ -133,6 +133,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(
literalB
&
0xffff
);
out
.
putShort
(
literalB
&
0xffff
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat21T.java
View file @
a328bf64
...
@@ -162,6 +162,7 @@ implements IOneRegisterInstruction, IOffsetInstruction {
...
@@ -162,6 +162,7 @@ implements IOneRegisterInstruction, IOffsetInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
// The format is AA|op BBBB.
// The format is AA|op BBBB.
int
firstShort
=
((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
;
int
firstShort
=
((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
;
int
secondShort
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
int
secondShort
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
...
...
src/org/ow2/asmdex/instruction/InstructionFormat22B.java
View file @
a328bf64
...
@@ -158,6 +158,7 @@ implements ITwoRegistersInstruction, ILiteralInstruction {
...
@@ -158,6 +158,7 @@ implements ITwoRegistersInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
|
registerB
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
literalC
&
0xff
)
<<
8
)
+
(
registerB
&
0xff
));
out
.
putShort
(((
literalC
&
0xff
)
<<
8
)
+
(
registerB
&
0xff
));
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat22C.java
View file @
a328bf64
...
@@ -189,6 +189,7 @@ implements ITwoRegistersInstruction, IIndexInstruction {
...
@@ -189,6 +189,7 @@ implements ITwoRegistersInstruction, IIndexInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
// The format is B|A|op CCCC.
// The format is B|A|op CCCC.
test8BitsLimit
(
registerA
|
registerB
);
out
.
putShort
((((
registerA
&
0xf
)
<<
8
)
+
((
registerB
&
0xf
)
<<
12
))
+
opcodeByte
);
out
.
putShort
((((
registerA
&
0xf
)
<<
8
)
+
((
registerB
&
0xf
)
<<
12
))
+
opcodeByte
);
// The index may be a Type, or a Field index.
// The index may be a Type, or a Field index.
int
index
;
int
index
;
...
...
src/org/ow2/asmdex/instruction/InstructionFormat22S.java
View file @
a328bf64
...
@@ -147,6 +147,7 @@ implements ITwoRegistersInstruction, ILiteralInstruction {
...
@@ -147,6 +147,7 @@ implements ITwoRegistersInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test4BitsLimit
(
registerA
|
registerB
);
out
.
putShort
((((
registerA
&
0xf
)
<<
8
)
+
((
registerB
&
0xf
)
<<
12
))
+
opcodeByte
);
out
.
putShort
((((
registerA
&
0xf
)
<<
8
)
+
((
registerB
&
0xf
)
<<
12
))
+
opcodeByte
);
out
.
putShort
(
literalC
&
0xffff
);
out
.
putShort
(
literalC
&
0xffff
);
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat22T.java
View file @
a328bf64
...
@@ -183,6 +183,8 @@ implements ITwoRegistersInstruction, IOffsetInstruction {
...
@@ -183,6 +183,8 @@ implements ITwoRegistersInstruction, IOffsetInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test4BitsLimit
(
registerA
|
registerB
);
// The format is B|A|op CCCC.
// The format is B|A|op CCCC.
int
firstShort
=
((
registerB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
int
firstShort
=
((
registerB
&
0xf
)
<<
12
)
+
((
registerA
&
0xf
)
<<
8
)
+
opcodeByte
;
int
secondShort
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
int
secondShort
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
...
...
src/org/ow2/asmdex/instruction/InstructionFormat22X.java
View file @
a328bf64
...
@@ -134,6 +134,8 @@ implements ITwoRegistersInstruction {
...
@@ -134,6 +134,8 @@ implements ITwoRegistersInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
test16BitsLimit
(
registerB
);
int
firstShort
=
((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
;
int
firstShort
=
((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
;
out
.
putShort
(
firstShort
);
out
.
putShort
(
firstShort
);
out
.
putShort
(
registerB
&
0xffff
);
out
.
putShort
(
registerB
&
0xffff
);
...
...
src/org/ow2/asmdex/instruction/InstructionFormat23X.java
View file @
a328bf64
...
@@ -197,6 +197,7 @@ implements IThreeRegistersInstruction {
...
@@ -197,6 +197,7 @@ implements IThreeRegistersInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
|
registerB
|
registerC
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerC
&
0xff
)
<<
8
)
+
(
registerB
&
0xff
));
out
.
putShort
(((
registerC
&
0xff
)
<<
8
)
+
(
registerB
&
0xff
));
}
}
...
...
src/org/ow2/asmdex/instruction/InstructionFormat31C.java
View file @
a328bf64
...
@@ -132,6 +132,7 @@ implements IOneRegisterInstruction, IIndexInstruction {
...
@@ -132,6 +132,7 @@ implements IOneRegisterInstruction, IIndexInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
// The format is AA|op BBBBlo BBBBhi.
// The format is AA|op BBBBlo BBBBhi.
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
int
index
=
constantPool
.
getStringIndex
(
string
);
int
index
=
constantPool
.
getStringIndex
(
string
);
...
...
src/org/ow2/asmdex/instruction/InstructionFormat31I.java
View file @
a328bf64
...
@@ -134,6 +134,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
...
@@ -134,6 +134,7 @@ implements IOneRegisterInstruction, ILiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(
literalB
&
0xffff
);
out
.
putShort
(
literalB
&
0xffff
);
out
.
putShort
((
literalB
>>
16
)
&
0xffff
);
out
.
putShort
((
literalB
>>
16
)
&
0xffff
);
...
...
src/org/ow2/asmdex/instruction/InstructionFormat31T.java
View file @
a328bf64
...
@@ -168,6 +168,7 @@ implements IOneRegisterInstruction, IOffsetInstruction {
...
@@ -168,6 +168,7 @@ implements IOneRegisterInstruction, IOffsetInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
// The format is AA|op BBBBlo BBBBhi.
// The format is AA|op BBBBlo BBBBhi.
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
int
branchOffset
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
int
branchOffset
=
(
label
.
getOffset
()
-
instructionOffset
)
/
2
;
// / 2 because offsets are word-based.
out
.
putShort
(
branchOffset
&
0xffff
);
out
.
putShort
(
branchOffset
&
0xffff
);
...
...
src/org/ow2/asmdex/instruction/InstructionFormat32X.java
View file @
a328bf64
...
@@ -136,6 +136,7 @@ implements ITwoRegistersInstruction {
...
@@ -136,6 +136,7 @@ implements ITwoRegistersInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test16BitsLimit
(
registerA
|
registerB
);
out
.
putShort
(
opcodeByte
);
out
.
putShort
(
opcodeByte
);
out
.
putShort
(
registerA
&
0xffff
);
out
.
putShort
(
registerA
&
0xffff
);
out
.
putShort
(
registerB
&
0xffff
);
out
.
putShort
(
registerB
&
0xffff
);
...
...
src/org/ow2/asmdex/instruction/InstructionFormat35C.java
View file @
a328bf64
...
@@ -200,7 +200,9 @@ implements IRegisterArrayInstruction, IIndexInstruction {
...
@@ -200,7 +200,9 @@ implements IRegisterArrayInstruction, IIndexInstruction {
try
{
throw
new
Exception
(
"Abnormal arguments number : "
+
nbRegisters
);
}
try
{
throw
new
Exception
(
"Abnormal arguments number : "
+
nbRegisters
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
}
int
mask
=
0
;
for
(
int
i
=
0
;
i
<
nbRegisters
;
i
++)
mask
|=
registers
[
i
];
test4BitsLimit
(
mask
);
out
.
putShort
(
firstShort
);
out
.
putShort
(
firstShort
);
if
(
opcodeByte
==
0x24
)
{
if
(
opcodeByte
==
0x24
)
{
out
.
putShort
(
constantPool
.
getTypeIndex
(
type
));
out
.
putShort
(
constantPool
.
getTypeIndex
(
type
));
...
...
src/org/ow2/asmdex/instruction/InstructionFormat51L.java
View file @
a328bf64
...
@@ -141,6 +141,7 @@ implements IOneRegisterInstruction, ILongLiteralInstruction {
...
@@ -141,6 +141,7 @@ implements IOneRegisterInstruction, ILongLiteralInstruction {
@Override
@Override
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
public
void
write
(
ByteVector
out
,
ConstantPool
constantPool
)
{
test8BitsLimit
(
registerA
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putShort
(((
registerA
&
0xff
)
<<
8
)
+
opcodeByte
);
out
.
putByte
((
byte
)
literalB
);
out
.
putByte
((
byte
)
literalB
);
out
.
putByte
((
byte
)(
literalB
>>
8
));
out
.
putByte
((
byte
)(
literalB
>>
8
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment