a non readable h eap (and why you might want one )

17
A Non Readable Heap (and why you might want one) Laurence Hellyer Computing Laboratory, University of Kent, UK

Upload: zulema

Post on 24-Feb-2016

35 views

Category:

Documents


0 download

DESCRIPTION

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; }. - PowerPoint PPT Presentation

TRANSCRIPT

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

• A Non Readable Heap• (and why you might want one)

• Laurence HellyerComputing Laboratory,University of Kent, UK

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

A Non Readable Heap

Page 2

?? ?? ?

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

HEAP’

Object Foo’ {Int Bar;}

HEAP’

Object Foo’ {Int Bar = 1;}

[email protected] MM-NET 2009 Presentation

Primitive Write Barriers

HEAP

Object Foo {Int Bar;}

Foo.Bar = 1;

Primitive Write Barrier

HEAP

Object Foo {Int Bar = 1;}

Page 3

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

[email protected] 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

Page 4

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

[email protected] 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

Page 5

• Other benefits?

• Catch errors in JNI code that cause direct access to the heap

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

[email protected] ISSM WACI 2009 Presentation

Thank you

Questions?www.cs.kent.ac.uk/~lh243

Page 6

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

HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar = X;}

[email protected] ISSM WACI 2009 Presentation

Debugging Framework: A Write Protected Heap

Foo.Bar = X;

Write Barrier

Page 7

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

HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar = X;}

[email protected] ISSM WACI 2009 Presentation

Debugging Framework: A Write Protected Heap

Write Barrier

Page 8

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

[email protected] ISSM WACI 2009 Presentation

Implementation Challenges

• Multiple threads

• Primitive WB’s

• Performance

Page 9

T1

T2

WBFoo

WBFoo

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

WBFoo

[email protected] ISSM WACI 2009 Presentation

Implementation Challenges

• Multiple threads

• Primitive WB’s

• Performance

Page 10

T1

T2 WBFoo

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

[email protected] ISSM WACI 2009 Presentation

Implementation Challenges

• Multiple threads

• Primitive WB’s

• Performance

Page 11

T1

T2

WBFoo

WFoo

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

MMAP’d

Alias

HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar;}

[email protected] ISSM WACI 2009 Presentation

Implementation

ALIASED HEAP

Object Foo {Field Bar;}

1. Pages reserved for heap as normal – but marked read only.2. All reads occur on write-protected heap.3. A virtual alias of the heap is created in address space.

•Alias address mapping is writable•Virtual alias only occupies address space

•Backed by same physical pages•Aliased heap is only known to WB

Page 12

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

HEAP

Object Foo {Field Bar = X;}

MMAP’d

Alias ALIASED HEAPALIASED HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar;}

[email protected] ISSM WACI 2009 Presentation

Implementation

Foo.Bar = X;

Write Barrier

Page 13

Object Foo {Field Bar = X;}

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

MMAP’d

Alias

HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar = X;}

[email protected] ISSM WACI 2009 Presentation

Implementation

Write Barrier

ALIASED HEAP

Object Foo {Field Bar = X;}

Page 14

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

MMAP’d

Alias

HEAP

Object Foo {Field Bar;}

HEAP

Object Foo {Field Bar = X;}

[email protected] ISSM WACI 2009 Presentation

32 bit Address Limitation

ALIASED HEAP

Object Foo {Field Bar = X;}

Page 15

•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

Thread local

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

[email protected] ISSM WACI 2009 Presentation

Performance and Testing

Page 16

• Useful benchmarks to ensure correct barrier usage:

• DaCapo Chart:• No debugging framework: 10 seconds• Debugging framework: 552 seconds

• DaCapo Hsqldb• 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)

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

[email protected] ISSM WACI 2009 Presentation

Current and Future Uses

Page 17

• 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