1 / 17

A Non Readable H eap (and why you might want one )

A Non Readable H eap (and why you might want one ) Laurence Hellyer Computing Laboratory, University of Kent, UK. A Non Readable Heap. ?. ?. ?. ?. ?. Primitive Write Barriers. HEAP’. HEAP’. HEAP. HEAP. Object Foo ’ { Int Bar; }. Object Foo ’ { Int Bar = 1; }.

zulema
Download Presentation

A Non Readable H eap (and why you might want one )

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A Non Readable Heap (and why you might want one) Laurence HellyerComputing Laboratory,University of Kent, UK

  2. A Non Readable Heap ? ? ? ? ?

  3. L.Hellyer@kent.ac.uk MM-NET 2009 Presentation Primitive Write Barriers HEAP’ HEAP’ HEAP HEAP Object Foo’ { Int Bar; } Object Foo’ { Int Bar = 1; } Object Foo { Int Bar; } Object Foo { Int Bar = 1; } Primitive Write Barrier Foo.Bar = 1;

  4. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Write Protected Heap • Catch all non-conforming writes • Fatal exception as soon as the write is made • Timely stack trace allows quick pinpointing of non-confirming code • Almost a pure Java approach • Doesn’t rely on external tool

  5. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Non Readable Heap • Why? • Last remaining class of barriers to implement in JikesRVM is primitive read barriers • A non readable heap ensures that all heap accesses must go via an appropriate barrier • Other benefits? • Catch errors in JNI code that cause direct access to the heap

  6. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Thank you Questions? www.cs.kent.ac.uk/~lh243

  7. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Debugging Framework: A Write Protected Heap HEAP HEAP Object Foo { Field Bar; } Object Foo { Field Bar = X; } Write Barrier Foo.Bar = X;

  8. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Debugging Framework: A Write Protected Heap HEAP HEAP Object Foo { Field Bar; } Object Foo { Field Bar = X; } Write Barrier

  9. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WBFoo

  10. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WBFoo

  11. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WFoo

  12. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation HEAP HEAP ALIASED HEAP MMAP’d Alias Object Foo { Field Bar; } Object Foo { Field Bar; } Object Foo { Field Bar; } • Alias address mapping is writable • Virtual alias only occupies address space • Backed by same physical pages • Aliased heap is only known to WB Pages reserved for heap as normal – but marked read only. All reads occur on write-protected heap. A virtual alias of the heap is created in address space.

  13. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation ALIASED HEAP ALIASED HEAP Object Foo { Field Bar; } Object Foo { Field Bar = X; } HEAP HEAP MMAP’d Alias Object Foo { Field Bar = X; } Object Foo { Field Bar; } Write Barrier Foo.Bar = X;

  14. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation HEAP HEAP MMAP’d Alias Object Foo { Field Bar; } Object Foo { Field Bar = X; } ALIASED HEAP Object Foo { Field Bar = X; } Write Barrier

  15. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation 32 bit Address Limitation Thread local HEAP HEAP Object Foo { Field Bar; } Object Foo { Field Bar = X; } MMAP’d Alias ALIASED HEAP Object Foo { Field Bar = X; } • To avoid exhausting virtual address space, only mmap the page of the field we are writing • And the next page in case it’s an unaligned double • Each thread has its own aliased window • Many threads can have own mapping to same underlying physical page

  16. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Performance and Testing • Useful benchmarks to ensure correct barrier usage: • DaCapo Chart: • No debugging framework: 10 seconds • Debugging framework: 552 seconds • DaCapoHsqldb • No debugging framework: 6 seconds • Debugging framework: 625 seconds • JVM98 _200_check: • No debugging framework: 0.1 second • Debugging framework: 2 seconds • (Total invocation time goes from 1  10 seconds)

  17. L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Current and Future Uses • Successfully used to implement primitive write barriers in JikesRVM Baseline and Opt compilers • Will be made available shortly for other researchers • A potential future use – debugging primitive read barriers • Heap could be read and write protected • Aliased address range of heap would allow conforming code to read heap • Non-conforming code would SIGSEGV and produce stack trace

More Related