decoration decoration
Stories

GROKLAW
When you want to know more...
decoration
For layout only
Home
Archives
Site Map
Search
About Groklaw
Awards
Legal Research
Timelines
ApplevSamsung
ApplevSamsung p.2
ArchiveExplorer
Autozone
Bilski
Cases
Cast: Lawyers
Comes v. MS
Contracts/Documents
Courts
DRM
Gordon v MS
GPL
Grokdoc
HTML How To
IPI v RH
IV v. Google
Legal Docs
Lodsys
MS Litigations
MSvB&N
News Picks
Novell v. MS
Novell-MS Deal
ODF/OOXML
OOXML Appeals
OraclevGoogle
Patents
ProjectMonterey
Psystar
Quote Database
Red Hat v SCO
Salus Book
SCEA v Hotz
SCO Appeals
SCO Bankruptcy
SCO Financials
SCO Overview
SCO v IBM
SCO v Novell
SCO:Soup2Nuts
SCOsource
Sean Daly
Software Patents
Switch to Linux
Transcripts
Unix Books

Gear

Groklaw Gear

Click here to send an email to the editor of this weblog.


You won't find me on Facebook


Donate

Donate Paypal


No Legal Advice

The information on Groklaw is not intended to constitute legal advice. While Mark is a lawyer and he has asked other lawyers and law students to contribute articles, all of these articles are offered to help educate, not to provide specific legal advice. They are not your lawyers.

Here's Groklaw's comments policy.


What's New

STORIES
No new stories

COMMENTS last 48 hrs
No new comments


Sponsors

Hosting:
hosted by ibiblio

On servers donated to ibiblio by AMD.

Webmaster
The Simulator class | 400 comments | Create New Account
Comments belong to whoever posts them. Please notify us of inappropriate comments.
The Simulator class
Authored by: Anonymous on Saturday, May 12 2012 @ 10:10 AM EDT
Why would Dalvik contain a Simulator class, if not for the express purpose of infringing Sun's stupid '520 patent, I hear the audience wondering?

Simple! Java bytecodes are for a stack-based VM, and Dalvik uses a different register-based bytecodes system. So the dex compiler has to figure out what the effects of a group of Java bytecodes are, so it can turn them into Dalvik's register-based bytecode.

To do this, it has to _simulate_ what those bytecodes do (a combination of manipulating the Java stack, and causing other side effects like reading/writing memory) and as the simulation discovers side effects, it emits its own bytecodes that have the same side effects.

Ironically, dex uses simulation for translating almost all of the bytecodes, EXCEPT for the specific bytecodes used for this clinit array initialization that the '520 patented optimization is about. Dex can also optimize those bytecodes, but it uses a different--and much simpler--mechanism for doing it, which avoids the '520 claims.

...So why do they need a Simulator class at all? Good question. Actually, they could have used pattern matching for everything, and programmed in all of the patterns actually used by Java compilers. But it would have been a lot of patterns, it would have been complex and still brittle. Bytecode optimisers or obfuscator tools might re-arrange bytecodes into unrecognised patterns. Programmers might assemble unusual bytecode patterns by hand. Future Java compilers might emit new and unrecognised patterns. Any of these would have caused Dex to be unable to convert the program, which would be bad. No, simulation with the Simulator class is a better approach for the general translation of tbe bytecodes, because it can handle any Java bytecodes that a Java VM would accept.

But for optimising the specific feature of array initializers, pattern matching was a great choice, because:

(1) its simple, and there's only one pattern that all of the known compilers use for this, and:

(2) its only an optimization. If it misses one because somebody emitted a different pattern of bytecodes, the translated program will still work--it will just be a little bit bigger and slower.

Dex either detects the pattern and optimizes an array initialization, or it DOESN'T detect the pattern, and DOESN'T apply the optimisation, and instead it simulates and translates the individual bytecodes.

The '520 patent covers doing BOTH things at the same time: simulating the bytecodes and using the info collected during that simulation to do the optimisation. Dalvik never does both together, it either does one or the other.

[ Reply to This | Parent | # ]

Groklaw © Copyright 2003-2013 Pamela Jones.
All trademarks and copyrights on this page are owned by their respective owners.
Comments are owned by the individual posters.

PJ's articles are licensed under a Creative Commons License. ( Details )