Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. ·...
Transcript of Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. ·...
![Page 1: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/1.jpg)
Embedding GI inside the JVM Benoit Baudry
Kwaku Yeboah-Antwi
1
![Page 2: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/2.jpg)
Specialize to environment .. or not
2
![Page 3: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/3.jpg)
3
Open-ended evolution
![Page 4: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/4.jpg)
Continuously evolve
4
![Page 5: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/5.jpg)
In software
• Code specialization • API are large and generic
• exact usage (e.g., surface really needed) is known only at runtime
• Spontaneous diversification • Instantiation creates large quantities of clones
• diversification at instantiation can increase resilience
5
![Page 6: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/6.jpg)
Let’s do it in Java
• JVM hardly supports runtime modifications of the bytecode • E.g., add, delete or rename fields, methods
• No built-in support • to edit the bytecode
• to steer the search for new code
6
![Page 7: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/7.jpg)
Our Contribution
ECSELR • ECologically Inspired Software EvoLution @ Runtime • A patch in the JVM + evolutionnary capacities for Java programs
7
![Page 8: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/8.jpg)
![Page 9: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/9.jpg)
Initialization
Selection
Variation
Evaluation
Object A Object B
Object C Object D
Object B
Object C
Object B’
Object C’
EvoAgentgetAllObjects()
Action FN
EvoDaemonselectObjects()
Evo Strategy
EvoDaemonmutateObject()
Genetic Oper
EvoAgenttestObjects()
Action FN
Object B’ EvoDaemondiscardUnfit()
Fitness
EvoAgentredefObjects()
Action FNInstallation
Object C’
Object B’records of
The evo loop
![Page 10: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/10.jpg)
The and steps
• Analyze all live objects on the heap • Select a subset according to some function • random
• by size
• by frequency of usage
• Copy the bytecode of selected objects
10
SelectionInitialization
![Page 11: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/11.jpg)
The step • ECSELR embeds default evo operations
• Method Addition • Merge Methods • Method Deletion • Field Addition Operator • Transplantation Operator • Random Instruction Operator • Passthrough Operator Return
11
Variation
![Page 12: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/12.jpg)
The step
• Static check • ensure syntactic validity
• check consistency after evolution: ECSLER embeds checks about the well-formedness of bytecode operatinos
• Dynamic check • parallel execution of original and evolved
• fitness evaluation 12
Evaluation
![Page 13: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/13.jpg)
Static check
13
public int greaterThan(int intOne, intTwo) { if (intOne > intTwo) { return 0; } else { return 1; }}
greaterThan(10,20);
0: iload_11: iload_22: nop3: if_icmple 86: iconst_07: ireturn8: iconst_19: ireturn
Bytecode
✔
![Page 14: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/14.jpg)
Static check
14
public int greaterThan(int intOne, intTwo) { if (intOne > intTwo) { return 0; } else { return 1; }}
greaterThan(10,20);
0: iload_11: iload_22: if_icmple 75: iconst_06: ireturn7: iconst_18: ireturn
Bytecode
✗ ECSELR detects the mistake: it knows that if_icmple requires two operands
![Page 15: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/15.jpg)
Dynamic checks
• Run both versions in parallel • for a given period
• This requires our patched JVM
15
original mutated
inputs
out_o out_m
eval fitness
if ok if not ok
discard mutatedkeep mutated
![Page 16: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/16.jpg)
Diversification example
16
int hash(final Object key) { int h = key.hashCode(); h += ~(h << 9); h ^= h >>> 14; h += h << 4; h ^= h >>> 10; return h;}
![Page 17: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/17.jpg)
17
![Page 18: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/18.jpg)
public long hash() { long h = this.hashCode(); h = this.initCapacity * h; h += ~(h << 9); h ^= h >>> 14; h += h << 4; h ^= h >>> 10; return h; }
18
Diversification example
public long hash() { long h = this.hashCode(); h = this.initCapacity * h; h += ~(h << 9); h ^= h >>> 14; h += h << 4; h ^= h >>> 10;
return h + h; }
public long hash() { long h = this.hashCode(); h = this.initCapacity * h; h += ~(h << 9);
h ^= h >>> 14;
h += h << (4+6); h ^= h >>> 10;
h = h * 100; return h; }
public long hash() { long h = this.hashCode(); h = this.initCapacity * h; h += ~(h << 9);
h ^= h >>> 14;
h += h << (4+6); h ^= h >>> 10; return h; }
![Page 19: Embedding GI inside the JVMcrest.cs.ucl.ac.uk/cow/45/slides/cow45_Baudry.pdf · 2016. 1. 31. · Benoit Baudry Kwaku Yeboah-Antwi 1. Specialize to environment .. or not 2. 3 Open-ended](https://reader035.fdocuments.us/reader035/viewer/2022062307/5fc720730df50e2ea36cbd5d/html5/thumbnails/19.jpg)
Conclusion
• We now have a machine to evolve Java programs at runtime • Next step: use it for runtime GI
• https://bitbucket.org/Kwaku/agentd/src
19