Re: Genetic Programming and Machine Language

Discussion in 'Java' started by softwarepearls_com, Nov 17, 2008.

  1. On Nov 17, 4:43 pm, "Ken T." <> wrote:
    > Over the weekend I started development of a platform to allow me to play
    > around with genetic programming a bit.  I decided on a machine language
    > representation of the developed code for various reasons, so I developed
    > my own little virtual machine that works very much like an old 6502
    > microprocessor.  
    >
    > This was all quite easy and works great, but it does negate some of the
    > performance gains associated with working directly with machine language
    > programs.  Ideally I would like to generate programs written in the
    > machine language of the native platform and run them there.  I know this
    > would be a great hassle, so I'm not even going to bother with that right
    > now.  
    >
    > There is another option that might work too.  I could generate java byte
    > code, using a subset of the available commands.  I was curious how
    > difficult it would be to execute a given string full of java byte code
    > and what the pitfalls of doing things this way might be.  Would I expect
    > to see a dramatic increase in speed over that which would be expected
    > using my virtual machine (it is mostly a big switch statement)?
    >
    > Thanks,
    >
    > --
    > Ken T.
    >
    >   For every complex problem, there is a solution that is simple, neat,
    >   and wrong.
    >         -- H. L. Mencken


    I predict a dramatic speed increase over your current approach if you
    generated JVM instruction sequences.

    The hard part here would be to generate sequences that don't crash the
    JVM. You'd have to include plenty of logic to ensure your sequences
    never violate any of the fairly long list of preconditions for legal
    code. But assuming you could get over the initial period of
    frustrating JVM crashes (remember: you don't get any pretty Java stack
    traces when the JVM blows), you'd be looking at a pretty powerful
    genetic programming engine.
    softwarepearls_com, Nov 17, 2008
    #1
    1. Advertising

  2. softwarepearls_com

    Lew Guest

    "Ken T." wrote:
    > > There is another option that might work too.  I could generate java [sic] byte
    > > code, using a subset of the available commands.  I was curious how
    > > difficult it would be to execute a given string full of java byte code
    > > and what the pitfalls of doing things this way might be.  Would I expect
    > > to see a dramatic increase in speed over that which would be expected
    > > using my virtual machine (it is mostly a big switch statement)?


    I suggest using a file to hold your source, and name the file with the
    extension ".java". Write your state machine in accordance with Java
    syntax. Then, as Joshua Cranmer predicted, I bet
    > it seems likely that the JIT optimizer will be able to
    > make the core interpreter quite fast,


    softwarepearls_com <> wrote:
    > I predict a dramatic speed increase over your current approach if you
    > generated JVM instruction sequences.


    I predict the easiest way is to do it via an actual Java program.

    > The hard part here would be to generate sequences that don't crash the
    > JVM. You'd have to include plenty of logic to ensure your sequences


    Correctly written Java won't crash the JVM; incorrectly written Java
    won't start the JVM.

    > never violate any of the fairly long list of preconditions for legal
    > code. But assuming you could get over the initial period of
    > frustrating JVM crashes (remember: you don't get any pretty Java stack
    > traces when the JVM blows), you'd be looking at a pretty powerful
    > genetic programming engine.


    Write the genetic algorithm in Java. Translate the algorithm, not the
    6502.

    --
    Lew
    Lew, Nov 17, 2008
    #2
    1. Advertising

  3. On Nov 17, 8:33 pm, Eric Sosman <> wrote:
    > softwarepearls_com wrote:
    > > On Nov 17, 4:43 pm, "Ken T." <> wrote:
    > >> Over the weekend I started development of a platform to allow me to play
    > >> around with genetic programming a bit.  I decided on a machine language
    > >> representation of the developed code for various reasons, so I developed
    > >> my own little virtual machine that works very much like an old 6502
    > >> microprocessor.  

    >
    > >> This was all quite easy and works great, but it does negate some of the
    > >> performance gains associated with working directly with machine language
    > >> programs.  Ideally I would like to generate programs written in the
    > >> machine language of the native platform and run them there.  I know this
    > >> would be a great hassle, so I'm not even going to bother with that right
    > >> now.  

    >
    > >> There is another option that might work too.  I could generate java byte
    > >> code, using a subset of the available commands.  I was curious how
    > >> difficult it would be to execute a given string full of java byte code
    > >> and what the pitfalls of doing things this way might be.  Would I expect
    > >> to see a dramatic increase in speed over that which would be expected
    > >> using my virtual machine (it is mostly a big switch statement)?

    >
    > > I predict a dramatic speed increase over your current approach if you
    > > generated JVM instruction sequences.

    >
    > > The hard part here would be to generate sequences that don't crash the
    > > JVM. You'd have to include plenty of logic to ensure your sequences
    > > never violate any of the fairly long list of preconditions for legal
    > > code. But assuming you could get over the initial period of
    > > frustrating JVM crashes (remember: you don't get any pretty Java stack
    > > traces when the JVM blows), you'd be looking at a pretty powerful
    > > genetic programming engine.

    >
    >      If he can crash the JVM by loading bad byte code, the JVM has
    > a bug.  Instead of an "initial period of frustrating JVM crashes"
    > I think he's more likely to see an "initial period where byte code
    > validation fails and ClassLoaders throw exceptions."
    >
    > --
    >


    In my eperience with Sun's latest Windows JVM, it is easy to submit a
    bytecode sequence that crashes the JVM.. and when you don't get an
    outright JVM crash, the validation exceptions are sadistically sparse
    on information helping the developer track down the cause. It's all
    just the cost of working at the bleeding edge ;-)
    softwarepearls_com, Nov 18, 2008
    #3
  4. softwarepearls_com

    Eric Sosman Guest

    softwarepearls_com wrote:
    > On Nov 17, 8:33 pm, Eric Sosman <> wrote:
    >> [...]
    >> If he can crash the JVM by loading bad byte code, the JVM has
    >> a bug. Instead of an "initial period of frustrating JVM crashes"
    >> I think he's more likely to see an "initial period where byte code
    >> validation fails and ClassLoaders throw exceptions."

    >
    > In my eperience with Sun's latest Windows JVM, it is easy to submit a
    > bytecode sequence that crashes the JVM..


    You'd do everyone a favor by reporting the bug to Sun.
    I'm sure they would take it *very* seriously, because if bad
    byte code can cause the JVM to go off the rails there's at
    least a chance that a security exploit is possible. Byte
    code validation is supposed to detect and reject malformed
    input without causing the JVM to do unpredictable or unwanted
    things; if it's failing in this there is something Very Badly
    Wrong. Please, please, please tell Sun, right away.

    If you can provide a reproducible test case, that will be
    even better.

    > and when you don't get an
    > outright JVM crash, the validation exceptions are sadistically sparse
    > on information helping the developer track down the cause. It's all
    > just the cost of working at the bleeding edge ;-)


    True, exceptions thrown for validation failures are not
    exactly overburdened with information. Still, a nice clean
    exception is a far cry from a JVM crash. Also, I found they
    gave me enough clues to enable me to fix my own byte code
    generation when it went awry, so the edge may be not quite
    so gore-spattered as you suggest.

    --
    Eric Sosman
    lid
    Eric Sosman, Nov 18, 2008
    #4
  5. On Nov 18, 2:26 pm, Eric Sosman <> wrote:
    > softwarepearls_com wrote:
    > > On Nov 17, 8:33 pm, Eric Sosman <> wrote:
    > >> [...]
    > >>      If he can crash the JVM by loading bad byte code, the JVM has
    > >> a bug.  Instead of an "initial period of frustrating JVM crashes"
    > >> I think he's more likely to see an "initial period where byte code
    > >> validation fails and ClassLoaders throw exceptions."

    >
    > > In my eperience with Sun's latest Windows JVM, it is easy to submit a
    > > bytecode sequence that crashes the JVM..

    >
    >      You'd do everyone a favor by reporting the bug to Sun.
    > I'm sure they would take it *very* seriously, because if bad
    > byte code can cause the JVM to go off the rails there's at
    > least a chance that a security exploit is possible.  Byte
    > code validation is supposed to detect and reject malformed
    > input without causing the JVM to do unpredictable or unwanted
    > things; if it's failing in this there is something Very Badly
    > Wrong.  Please, please, please tell Sun, right away.


    You know, I was a regular Bug Parade user/contributor many years ago,
    but as time went by, and I saw how Sun has a very odd approach to
    respecting the bug-fixing priorities set by parade users (at the
    explicit invitation of Sun), I concluded that I had been naive in
    thinking Sun would respect the contributors. The number of really high
    profile bugs which people were begging/shouting Sun to fix, that
    remained open and unfixed year after year after year, really disgusted
    me in the end.

    I think the slightly less naive view is that Sun fix the bugs they
    want to fix, according to their commercial (and shifting) priorities,
    and not ours (incl Bug Parade's).
    softwarepearls_com, Nov 18, 2008
    #5
  6. softwarepearls_com

    Lew Guest

    softwarepearls_com wrote:
    >>> In my eperience with Sun's latest Windows JVM, it is easy to submit a
    >>> bytecode sequence that crashes the JVM..


    Eric Sosman wrote:
    >> You'd do everyone a favor by reporting the bug to Sun.
    >> I'm sure they would take it *very* seriously, because if bad
    >> byte code can cause the JVM to go off the rails there's at
    >> least a chance that a security exploit is possible. Byte
    >> code validation is supposed to detect and reject malformed
    >> input without causing the JVM to do unpredictable or unwanted
    >> things; if it's failing in this there is something Very Badly
    >> Wrong. Please, please, please tell Sun, right away.


    softwarepearls_com wrote:
    > You know, I was a regular Bug Parade user/contributor many years ago,
    > but as time went by, and I saw how Sun has a very odd approach to
    > respecting the bug-fixing priorities set by parade users (at the
    > explicit invitation of Sun), I concluded that I had been naive in
    > thinking Sun would respect the contributors. The number of really high
    > profile bugs which people were begging/shouting Sun to fix, that
    > remained open and unfixed year after year after year, really disgusted
    > me in the end.


    If you could provide the newsgroup an example, that would add credibility.

    I, for one, am not convinced.

    --
    Lew
    Lew, Nov 19, 2008
    #6
  7. softwarepearls_com

    Lew Guest

    Lew wrote:
    >> If you could provide the newsgroup an example, that would add
    >> credibility.
    >>
    >> I, for one, am not convinced.


    Ken T. wrote:
    > Not to support his original claim, I don't know the facts, but an example
    > would be the lack of support for applets under 64 bit architectures. I
    > understand it will be fixed in the next release, but it took them forever
    > and was highly rated on the bug parade.


    Oh, dear, I should never use a modifier when dangling. So sorry.

    I mean an example of "a bytecode sequence that crashes the JVM."

    --
    Lew
    Lew, Nov 19, 2008
    #7
  8. softwarepearls_com

    Lew Guest

    Lew wrote:
    >> I, for one, am not convinced.


    Eric Sosman wrote:
    > After spending half of yesterday on the problem I succeeded
    > in constructing a malformed class file that crashed the JVM, and
    > have reported the bug. I wish softwarepearls_com, who had seen
    > the crash, had not chosen to drive on by without stopping.


    I am convinced.

    --
    Lew
    Lew, Nov 19, 2008
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ruben Hoste
    Replies:
    10
    Views:
    641
    Howard
    Sep 23, 2004
  2. ThanhVu Nguyen
    Replies:
    3
    Views:
    373
  3. Ruben Hoste
    Replies:
    10
    Views:
    695
    Howard
    Sep 23, 2004
  4. aum
    Replies:
    1
    Views:
    330
  5. John Ladasky
    Replies:
    5
    Views:
    854
    John Ladasky
    Aug 3, 2008
Loading...

Share This Page