170 likes | 319 Views
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; }.
E N D
A Non Readable Heap (and why you might want one) Laurence HellyerComputing Laboratory,University of Kent, UK
A Non Readable Heap ? ? ? ? ?
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;
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
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
L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Thank you Questions? www.cs.kent.ac.uk/~lh243
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;
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
L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WBFoo
L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WBFoo
L.Hellyer@kent.ac.uk ISSM WACI 2009 Presentation Implementation Challenges • Multiple threads • Primitive WB’s • Performance T1 WBFoo T2 WFoo
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.
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;
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
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
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)
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