harry xu may 2012 complex concurrent software precision
play

Harry Xu May 2012 Complex, concurrent software Precision (no false - PowerPoint PPT Presentation

Harry Xu May 2012 Complex, concurrent software Precision (no false positives) Find real bugs in real executions Need to modify JVM (e.g., object layout, GC, or ISA-level code) Need to demonstrate realism (usually performance) Otherwise use


  1. Harry Xu May 2012

  2. Complex, concurrent software Precision (no false positives) Find real bugs in real executions

  3. Need to modify JVM (e.g., object layout, GC, or ISA-level code) Need to demonstrate realism (usually performance)

  4. Otherwise use RoadRunner, BCEL, Pin, LLVM, …

  5. Keeping track of stuff as the program executes?  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC

  6. Keeping track of stuff as the program executes?  JVM written in Java?!  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC  Uninterruptible code

  7. Jikes RVM {  Guide  Research Archive  Research mailing list

  8. Jikes RVM {  Guide  Research Archive  Research mailing list

  9. Jikes RVM source code Boot image writer Dynamic compilers

  10. Jikes RVM source code Boot image Run with writer another JVM Dynamic compilers

  11. Jikes RVM source code Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  12. Build configurations: Base Base Jikes RVM source code Base Adaptive Full Adaptive Fast Adaptive Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  13. Build configurations: Base Base (prototype) Jikes RVM source code Base Adaptive (prototype-opt) Full Adaptive (development) Fast Adaptive (production) Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  14. Build configurations: Base Base Jikes RVM source code Testing Base Adaptive Full Adaptive Fast Adaptive Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  15. Build configurations: Base Base Faster builds Jikes RVM source code Base Adaptive Full Adaptive Fast Adaptive Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  16. Build configurations: Base Base Jikes RVM source code Base Adaptive Faster runs Full Adaptive Fast Adaptive Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  17. Build configurations: Base Base Jikes RVM source code Base Adaptive Full Adaptive Performance Fast Adaptive Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  18. Jikes RVM source code Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  19. Jikes RVM source code Edit with Eclipse (see Guide) Boot image Run with writer another JVM Dynamic compilers Boot image (native code + initial heap space)

  20. Keeping track of stuff as the program executes?  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC

  21. Baseline compiler Bytecode Native code

  22. Baseline compiler Bytecode Native code Each bytecode  several x86 instructions (BaselineCompilerImpl.java)

  23. Baseline compiler Bytecode Native code Each bytecode  several x86 instructions (BaselineCompilerImpl.java)

  24. Baseline compiler Bytecode Native code Profiling Adaptive optimization system

  25. Baseline compiler Bytecode Native code Profiling (Faster) native code Optimizing compiler Adaptive optimization system

  26. Baseline compiler Bytecode Native code Profiling (Faster) native code Optimizing compiler Adaptive optimization system

  27. Bytecode (Faster) native code Optimizing compiler

  28. Bytecode Resembles bytecode HIR (Faster) native code LIR Resembles typical compiler IR (3-address code) MIR Resembles assembly code

  29. Bytecode HIR (Faster) native code LIR Opt levels: 0, 1, 2 (Even faster) native code MIR

  30. Bytecode HIR ExpandRuntimeServices.java (Faster) Add instrumentation at native code reads, writes, allocation, LIR synchronization MIR

  31. Keeping track of stuff as the program executes?  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC

  32. header field0 field1 field2 Low address High address

  33. Object reference type info locking & field0 field1 field2 block GC

  34. Object reference type info locking & field0 field1 field2 block GC Object reference type info locking & Array elem0 elem1 block GC length

  35. Object reference type info locking & field0 field1 field2 block GC Steal bits

  36. Object reference type info locking & misc field0 field1 field2 block GC MiscHeader.java

  37. Object reference type info locking & counter field0 field1 field2 block GC

  38. Object reference type info locking & counter field0 field1 field2 block GC Compiles down to three Magic! x86 instructions

  39. Object reference type info locking & counter field0 field1 field2 block GC 2 Gotcha: can’t actually use LSB of leftmost word

  40. Object reference type info locking & counter field0 field1 field2 block GC 2 What’s the problem with this code?

  41. Object reference type info locking & counter field0 field1 field2 block GC 2

  42. Object reference type info locking & not used field0 field1 field2 block GC

  43. Object reference type info locking & not used field0 field1 field2 block GC Compiles down to three x86 instructions

  44. Object reference type info locking & misc field0 field1 field2 block GC

  45. Object reference type info locking & misc field0 field1 field2 block GC What if GC moves object? What if GC collects object?

  46. Keeping track of stuff as the program executes?  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC

  47. Object reference type info locking & field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f)

  48. Object reference type info locking & field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f)

  49. Object reference type info locking & field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f)

  50. Object reference type info locking & misc field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f) obj.misc = markAndPossiblyCopy(obj.f) worklist.push(obj.misc)

  51. Object reference type info locking & misc field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f) obj.misc = markAndPossiblyCopy(obj.f) worklist.push(obj.misc)

  52. Object reference type info locking & misc field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f) obj.misc = markAndPossiblyCopy(obj.f) TraceLocal.scanObject() worklist.push(obj.misc)

  53. Object reference type info locking & field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f)

  54. Object reference type info locking & field0 field1 field2 block GC // Initially worklist populated with roots while worklist has elements Object obj = worklist.pop() foreach reference field obj.f obj.f = markAndPossiblyCopy(obj.f) worklist.push(obj.f) TraceLocal.processNode()

  55. Keeping track of stuff as the program executes?  Change application behavior (add instrumentation)  Store per-object/per-field metadata  Piggyback on GC  Uninterruptible code

  56.  Normal application code can be interrupted  Allocation  GC  Synchronization & yield points  join a GC  Some VM code shouldn’t be interrupted  Heap etc. in inconsistent state  Most instrumentation can’t be interrupted  Reads & writes aren’t GC-safe points

  57. @Uninterruptible static void myMethod(Object o) { // No allocation or synchronization // No calls to interruptible methods }

  58. @Uninterruptible static void myMethod(Object o) { currentThread.deferGC = true; Metadata m = new Metadata(); currentThread.deferGC = false; setMiscHeader(o, offset, m); }

Recommend


More recommend