# US 2004/0073894 A1 · Optimization of n-base typed arithmetic expressions

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2004/0073894 A1
- Document ID: US20040073894A1
- Status: Published application
- Kind: A1
- Application number: 10/686,513
- Filed: 2003-10-14
- Published: 2004-04-15
- Earliest claimed: 1999-11-12
- Assignees: Sun Microsystems, Inc., a Delaware Corporation
- Inventors: Zhigun Chen; Judith E. Schwabe
- Web page: https://patentgrep.com/patent/US20040073894A1

## CPC

- G06F 8/4434: {Reducing the memory space required by the program code}
- G06F 8/52: Binary to binary
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)

## Abstract

A method for arithmetic expression optimization includes receiving a first instruction defined for a first processor having a first base, the first instruction including an operator and at least one operand, converting the first instruction to a second instruction optimized for a second processor having a second base when all operands do not carry potential overflow or when the operator is insensitive to overflow, the second base being smaller than the first base, and converting to a wider base a third instruction that is the source of the overflow when the at least one operand the potential for overflow and when the operator is sensitive to overflow. An apparatus for arithmetic expression optimization includes at least one memory having program instructions and at least one processor configured to use the program instructions to receive a first instruction defined for a first processor having a first base, convert the first instruction to a second instruction optimized for a second processor having a second base when every one of the at least one operand does not carry potential overflow or when the operator is insensitive to overflow, the second base being smaller than the first base, and convert to a wider base a third instruction that is the source of the overflow when the at least one operand the potential for overflow and when the operator is sensitive to overflow.

## Claims

### Claim 1

A method for arithmetic expression optimization, comprising:
receiving a first instruction defined for a first processor having a first base, said instruction including an operator and at least one operand;
converting said first instruction to a second instruction optimized for a second processor having a second base when said at least one operand does not carry potential overflow beyond said second base or when said operator is insensitive to overflow, said second base smaller than said first base; and
converting to a wider base a third instruction that is the source of potential overflow associated with said at least one operand when said at least one operand carries the potential for overflow beyond said second base and when said operator is sensitive to overflow, said third instruction having been previously optimized, said wider base larger than said second base and smaller or equal to said first base.

### Claim 2 (depends on 1)

The method of claim 1 wherein said converting to a wider base further comprises discarding previous conversion results of said third instruction before said converting to a wider base.

### Claim 3 (depends on 1)

The method of claim 1, further comprising rejecting an expression that cannot be optimized to a smaller base on said second processor.

### Claim 4 (depends on 1)

The method of claim 1 wherein said converting to a wider base further comprises rejecting said first instruction when said wider-base is not supported by said second processor.

### Claim 5 (depends on 1)

The method of claim 1 wherein said first instruction is arithmetic.

### Claim 6 (depends on 1)

The method of claim 1 wherein said first instruction comprises a non-arithmetic, type-sensitive instruction.

### Claim 7 (depends on 5)

The method of claim 5, further comprising, after said converting said first instruction, returning to receiving said first instruction until all instructions defined for said first processor are converted.

### Claim 8 (depends on 7)

The method of claim 7, further comprising linking each instruction to successor instructions in all control paths.

### Claim 9 (depends on 8)

The method of claim 8 wherein said converting said first instruction further comprises:
linking each result of an instruction to all instructions that consume said result;
if said converting includes creating a value, linking said value to the instruction that produced said value; and
if said value carries a potential for overflow, linking said value to the instruction that originally caused said overflow.

### Claim 10 (depends on 1)

The method of claim 1 wherein
said first processor comprises a Java™ Virtual Machine; and
said second processor comprises a Java Card™ Virtual Machine.

### Claim 11 (depends on 1)

The method of claim 1 wherein
said first base is used by said first processor for performing arithmetic operations on at least one data type, said at least one data type having a size less than the size of said first base; and
said second base is used by said second processor for performing arithmetic operations on said at least one data type, said second base having a size equal to the size of said at least one data type.

### Claim 12 (depends on 1)

The method of claim 1 wherein
said first processor comprises a 32-bit processor; and
said second processor comprises a resource-constrained 16-bit processor.

### Claim 13 (depends on 9)

The method of claim 9 wherein
said first base is used by said first processor for performing arithmetic operations on at least one data type, said at least one data type having a size less than the size of said first base; and
said second base is used by said second processor for performing arithmetic operations on said at least one data type, said second base having a size greater than the size of said at least one data type.

### Claim 14 (depends on 13)

The method of claim 13 wherein
said first processor comprises a 32-bit processor; and
said second processor comprises a resource-constrained 16-bit processor.

### Claim 15

A program storage device readable by a machine, embodying a program of instructions executable by the machine to perform arithmetic expression optimization comprising:
receiving a first instruction defined for a first processor having a first base, said first instruction including an operator and at least one operand;
converting said first instruction to a second instruction optimized for a second processor having a second base when said at least one operand does not carry potential overflow beyond said second base or when said operator is insensitive to overflow, said second base smaller than said first base; and
converting to a wider base a third instruction that is the source of potential overflow associated with said at least one operand when said at least one operand carries the potential for overflow beyond said second base and when said operator is sensitive to overflow, said third instruction having been previously optimized, said wider base larger than said second base and smaller or equal to said first base.

### Claim 16 (depends on 15)

The program storage device of claim 15 wherein said converting to a wider base further comprises discarding previous conversion results of said third instruction before said converting to a wider base.

### Claim 17 (depends on 15)

The program storage device of claim 15, further comprising rejecting an expression that cannot be optimized to a smaller base on said second processor.

### Claim 18 (depends on 15)

The program storage device of claim 15 wherein said converting to a wider base further comprises rejecting said first instruction when said wider base is not supported by said second processor.

### Claim 19 (depends on 15)

The program storage device of claim 15 wherein said first instruction is arithmetic.

### Claim 20 (depends on 15)

The program storage device of claim 15 wherein said first instruction comprises a non-arithmetic, type-sensitive instruction.

### Claim 21 (depends on 19)

The program storage device of claim 19, further comprising, after said converting said first instruction, returning to receiving said first instruction until all instructions defined for said first processor are converted.

### Claim 22 (depends on 21)

The program storage device of claim 21, further comprising linking each instruction to successor instructions in all control paths.

### Claim 23 (depends on 22)

The program storage device of claim 22 wherein said converting said first instruction further comprises:
linking each result of an instruction to all instructions that consume said result;
if said converting includes creating a value, linking said value to the instruction that produced said value; and
if said value carries a potential for overflow, linking said value to the instruction that originally caused said overflow.

### Claim 24 (depends on 15)

The program storage device of claim 15 wherein
said first processor comprises a Java™ Virtual Machine; and
said second processor comprises a Java Card™ Virtual Machine.

### Claim 25 (depends on 15)

The program storage device of claim 15 wherein
said first base is used by said first processor for performing arithmetic operations on at least one data type, said at least one data type having a size less than the size of said first base; and
said second base is used by said second processor for performing arithmetic operations on said at least one data type, said second base having a size equal to the size of said at least one data type.

### Claim 26 (depends on 15)

The program storage device of claim 15 wherein
said first processor comprises a 32-bit processor; and
said second processor comprises a resource-constrained 16-bit processor.

### Claim 27 (depends on 23)

The program storage device of claim 23 wherein
said first base is used by said first processor for performing arithmetic operations on at least one data type, said at least one data type having a size less than the size of said first base; and
said second base is used by said second processor for performing arithmetic operations on said at least one data type, said second base having a size greater than the size of said at least one data type.

### Claim 28

An apparatus for arithmetic expression optimization, comprising:
at least one memory having program instructions; and
at least one processor configured to use the program instructions to:
receive a first instruction defined for a first processor having a first base, said first instruction including an operator and at least one operand;
convert said first instruction to a second instruction optimized for a second processor having a second base when said at least one operand does not carry potential overflow beyond said second base or when said operator is insensitive to overflow, said second base smaller than said first base; and
convert to a wider base a third instruction that is the source of potential overflow associated with said at least one operand when said at least one operand carries the potential for overflow beyond said second base and when said operator is sensitive to overflow, said third instruction having been previously optimized, said wider base larger than said second base and smaller or equal to said first base.

### Claim 29 (depends on 28)

The apparatus of claim 28 wherein said at least one processor is further configured to use the program instructions to discard previous conversion results of said third instruction before converting to a wider base.

### Claim 30

An apparatus for arithmetic expression optimization, comprising:
means for receiving a first instruction defined for a first processor having a first base, said first instruction including an operator and at least one operand;
means for converting said first instruction to a second instruction optimized for a second processor having a second base when said at least one operand does not carry potential overflow beyond said second base or when said operator is insensitive to overflow, said second base smaller than said first base; and
means for converting to a wider base a third instruction that is the source of potential overflow associated with said at least one operand when said at least one operand carries the potential for overflow beyond said second base and when said operator is sensitive to overflow, said third instruction having been previously optimized, said wider base larger than said second base and smaller or equal to said first base.

### Claim 31 (depends on 30)

The apparatus of claim 30 wherein said means for converting to a wider base further comprises a means for discarding previous conversion results of said third instruction before said converting to a wider base.

### Claim 32 (depends on 30)

The apparatus of claim 30, further comprising a means for linking each instruction to successor instructions in all control paths.

### Claim 33

A method of using an application software program including arithmetic expression optimization of at least one instruction targeted to a processor having a first base, the method comprising:
receiving the software program on a processor; and
executing the sequence of instructions on the processor.

### Claim 34 (depends on 33)

The method of claim 33, further including storing the at least one instruction on a resource-constrained device.

### Claim 35

A smart card having a microcontroller embedded therein, the smart card comprising:
a virtual machine being executed by a microcontroller, the virtual machine executing a software application comprising of a plurality of previously optimized instructions, the virtual machine comprising means for receiving optimized instructions, the optimized instructions being previously optimized for execution on a resource-constrained device, means for executing said instructions.
