SlideShare a Scribd company logo
Extending OpenJDK To
Support Hybrid STM/HTM
Keith Chapman
Purdue U
Tony Hosking
ANU/Data61, Purdue U
Eliot Moss
UMass
Transactions are Good
They deal with concurrency
• Atomic transactions avoid problems with locks
• Deadlock, wrong lock, priority inversion, etc.
Transactions are Good
They deal with concurrency
• Atomic transactions avoid problems with locks
• Deadlock, wrong lock, priority inversion, etc.
They handle recovery
• Retry in case of conflict
• Cleanup in face of exceptions/errors
Transactions are Good
They deal with concurrency
• Atomic transactions avoid problems with locks
• Deadlock, wrong lock, priority inversion, etc.
They handle recovery
• Retry in case of conflict
• Cleanup in face of exceptions/errors
More practical for ordinary programmers than locks for robust concurrent systems
Semantics of Transactions
They offer A,C,I of database ACID properties:
• Atomicity: all or nothing
• Consistency: single global order
• Isolation: intermediate states invisible
Semantics of Transactions
They offer A,C,I of database ACID properties:
• Atomicity: all or nothing
• Consistency: single global order
• Isolation: intermediate states invisible
In sum, serializability, in face of concurrent execution and transaction failures
Semantics of Transactions
They offer A,C,I of database ACID properties:
• Atomicity: all or nothing
• Consistency: single global order
• Isolation: intermediate states invisible
In sum, serializability, in face of concurrent execution and transaction failures
Can be provided by Transactional Memory
• Hardware, software, or hybrid
XJ: Transactional Java
XJ Language
• Dialect of Java
• Supports flat and closed/open/boosted nested transactions
XJ: Transactional Java
XJ Language
• Dialect of Java
• Supports flat and closed/open/boosted nested transactions
XJ framework supports hybrid transactions
• HTM support via Intel TSX
Current XJ System Architecture
Current XJ System Architecture
XJ source code
Current XJ System Architecture
XJ source code XJ Compiler
Current XJ System Architecture
XJ source code XJ Compiler
compile
Current XJ System Architecture
XJ source code XJ Compiler
standard Java
bytecode
compile
Current XJ System Architecture
XJ source code XJ Compiler
standard Java
bytecode XJ Rewriter
compile
Current XJ System Architecture
XJ source code XJ Compiler
standard Java
bytecode XJ Rewriter
compile load
Current XJ System Architecture
XJ source code XJ Compiler
standard Java
bytecode XJ Rewriter
bytecode
+ run-time calls
compile load
Current XJ System Architecture
XJ source code
XJ run-time
library
XJ Compiler
standard Java
bytecode XJ Rewriter
bytecode
+ run-time calls
compile load
Current XJ System Architecture
XJ source code
XJ run-time
library
XJ Compiler
standard Java
bytecode XJ Rewriter
bytecode
+ run-time calls
HTM-enabled
JVM
compile load
Current XJ System Architecture
XJ source code
XJ run-time
library
XJ Compiler
standard Java
bytecode XJ Rewriter
bytecode
+ run-time calls
HTM-enabled
JVM
compile load run
Current XJ System Architecture
HTM 5-10 times faster than STM
XJ source code
XJ run-time
library
XJ Compiler
standard Java
bytecode XJ Rewriter
bytecode
+ run-time calls
HTM-enabled
JVM
compile load run
Drawbacks of Outside-VM Approach
Requires bytecode rewriting for transaction mechanisms & metadata
• Extra level of indirection when accessing object lock/version
Drawbacks of Outside-VM Approach
Requires bytecode rewriting for transaction mechanisms & metadata
• Extra level of indirection when accessing object lock/version
Interpreter and compiler challenges
• Jump through hoops to get compiled code to work under HTM
Drawbacks of Outside-VM Approach
Requires bytecode rewriting for transaction mechanisms & metadata
• Extra level of indirection when accessing object lock/version
Interpreter and compiler challenges
• Jump through hoops to get compiled code to work under HTM
Less opportunity for optimization
Proposed Extensions to OpenJDK
1. Locking protocol
2. Compiler enhancements for TSX
3. Optimizations
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
hash code age 0 01
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock thin lock
inflate lock
recursive lock
lock / unlock
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 00
pointer to heavyweight monitor 10
(heavyweight locked object)
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(heavyweight hashed/locked object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock thin lock
inflate lock
recursive lock
lock / unlock
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock thin lock
inflate lock
recursive lock
lock / unlock
txnread
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock thin lock
inflate lock
recursive lock
lock / unlock
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write
thin lock
inflate lock
recursive lock
lock / unlock
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write txn commit
thin lock
inflate lock
recursive lock
lock / unlock
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write txn commit
thin lock
inflate lock
recursive lock
lock / unlock txn read/write
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write txn commit
thin lock
inflate lock
recursive lock
lock / unlock
lock / hash
lock / hash
txn read/write
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write txn commit
thin lock
inflate lock
recursive lock
lock / unlock
lock / hash
unlock (unhashed)
lock / hash
unlock (unhashed)
txn read/write
txnread
txnwrite
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
allocate object
0 epoch age 1 01
thread ID epoch age 1 01
Txn ID epoch age 1 000
version epoch age 1 001
hash code age 0 01
pointer to heavyweight monitor 100
(unlocked and unbiased but biasable object) (unlocked non-biasable object)
(biased object, locked or unlocked) (lightweight locked object)
(transactionally write locked object) (heavyweight hashed/locked object)
(transactionally read object)
if currently unlocked
if currently locked
revoke biasrebiasinitial lock
txn write txn commit
thin lock
inflate lock
recursive lock
lock / unlock
lock / hash
unlock (unhashed)
lock / hash
unlock (unhashed)
txn read/write
txnread
txnwrite
unlock(non-txnal)
txnread/write
If biased locking is disabled for the classIf biased locking is enabled for the class
pointer to lock record 000
Locking Protocol (continued)
What about statics?
• Distinct field to hold lock/version for statics
• Can extend to have distinct locks for disjoint subsets of statics
Locking Protocol (continued)
What about statics?
• Distinct field to hold lock/version for statics
• Can extend to have distinct locks for disjoint subsets of statics
How about arrays?
• Use arraylets (add a lock field for each arraylet)
Compiler Challenges
HTM does not work under the interpreter
• Will fail because of buffer overflow
Compiler Challenges
HTM does not work under the interpreter
• Will fail because of buffer overflow
HTM does not work under compilation either :-(
Compiler Challenges
HTM does not work under the interpreter
• Will fail because of buffer overflow
HTM does not work under compilation either :-(
• Txn-illegal instructions in HotSpot’s dynamic code patching stubs
Compiler Challenges
HTM does not work under the interpreter
• Will fail because of buffer overflow
HTM does not work under compilation either :-(
• Txn-illegal instructions in HotSpot’s dynamic code patching stubs
• “Short-term memory loss” (so stubs can’t be updated)
Compiler Challenges (continued)
TSX classifies certain instructions as illegal inside of a transaction
• e.g., FXRSTOR and FXSAVE
• Extensively used in HotSpot’s dynamic code patching stubs
• These never work inside a hardware transaction
TSX
XBEGIN — Begin a transaction
XEND — End a transaction
XABORT — Abort a transaction explicitly
• Takes an 8-bit value as argument
• Returned to the user in bits 31:24 of EAX
Addressing Compiler Challenges
Using HTM failure codes
• “Return” 8 bits of information, via the EAX register
• Simple if less than 256 guards
• Can use a multi-step encoding technique to handle more guards
Addressing Compiler Challenges
Using HTM failure codes
• “Return” 8 bits of information, via the EAX register
• Simple if less than 256 guards
• Can use a multi-step encoding technique to handle more guards
Maintain correlated STM and HTM code versions
More Integrated Optimizations
• Additional data-flow based optimization for STM/HTM methods
• Elide redundant locks
• Hoist certain locks
Future TM Hardware Suggestions
Return additional full-word error code
Future TM Hardware Suggestions
Return additional full-word error code
Some kind of extra-transactional writes
Questions?

More Related Content

PDF
Java synchronizers
DOCX
Java 5 concurrency
PPTX
Low-level concurrency (reinvent vehicle)
PDF
Locks (Concurrency)
PDF
Lect04
PDF
Java Concurrency Gotchas
PDF
A Runtime Monitoring Framework for Event Streams with Non-Primitive Arguments
PPTX
Advanced Hibernate V2
Java synchronizers
Java 5 concurrency
Low-level concurrency (reinvent vehicle)
Locks (Concurrency)
Lect04
Java Concurrency Gotchas
A Runtime Monitoring Framework for Event Streams with Non-Primitive Arguments
Advanced Hibernate V2

Similar to Extending OpenJDK To Support Hybrid STM/HTM (20)

PDF
Hybrid STM/HTM for Nested Transactions on OpenJDK
PPT
Core Java interview questions-ppt
PDF
Transactional Memory
PPT
Hs java open_party
PDF
Java & low latency applications
PDF
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
PPT
JVM performance options. How it works
PDF
Geek out 2014-lagergren-final
PDF
OpenDS_Jazoon2010
KEY
Modern Java Concurrency (OSCON 2012)
PPTX
Transactional Memory
PPT
Optimizing your java applications for multi core hardware
PDF
Unsafe Java
PDF
Java Memory Model
PDF
jvm/java - towards lock-free concurrency
PDF
Racing To Win: Using Race Conditions to Build Correct and Concurrent Software
PDF
HotSpot Synchronization, A Peek Under the Hood [JavaOne 2015 CON7570]
PDF
Java Concurrency in Practice
PPTX
PDF
JavaOne 2013: Memory Efficient Java
Hybrid STM/HTM for Nested Transactions on OpenJDK
Core Java interview questions-ppt
Transactional Memory
Hs java open_party
Java & low latency applications
Java Concurrency, A(nother) Peek Under the Hood [Code One 2019]
JVM performance options. How it works
Geek out 2014-lagergren-final
OpenDS_Jazoon2010
Modern Java Concurrency (OSCON 2012)
Transactional Memory
Optimizing your java applications for multi core hardware
Unsafe Java
Java Memory Model
jvm/java - towards lock-free concurrency
Racing To Win: Using Race Conditions to Build Correct and Concurrent Software
HotSpot Synchronization, A Peek Under the Hood [JavaOne 2015 CON7570]
Java Concurrency in Practice
JavaOne 2013: Memory Efficient Java
Ad

Recently uploaded (20)

PPTX
L1 - Introduction to python Backend.pptx
PDF
Digital Strategies for Manufacturing Companies
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Adobe Illustrator 28.6 Crack My Vision of Vector Design
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PDF
System and Network Administration Chapter 2
PPTX
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
How to Choose the Right IT Partner for Your Business in Malaysia
PPTX
assetexplorer- product-overview - presentation
PPTX
history of c programming in notes for students .pptx
PDF
top salesforce developer skills in 2025.pdf
PPT
Introduction Database Management System for Course Database
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
PDF
Softaken Excel to vCard Converter Software.pdf
PPTX
VVF-Customer-Presentation2025-Ver1.9.pptx
L1 - Introduction to python Backend.pptx
Digital Strategies for Manufacturing Companies
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Adobe Illustrator 28.6 Crack My Vision of Vector Design
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
System and Network Administration Chapter 2
Lecture 3: Operating Systems Introduction to Computer Hardware Systems
Which alternative to Crystal Reports is best for small or large businesses.pdf
Wondershare Filmora 15 Crack With Activation Key [2025
Odoo Companies in India – Driving Business Transformation.pdf
How to Choose the Right IT Partner for Your Business in Malaysia
assetexplorer- product-overview - presentation
history of c programming in notes for students .pptx
top salesforce developer skills in 2025.pdf
Introduction Database Management System for Course Database
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Agentic AI : A Practical Guide. Undersating, Implementing and Scaling Autono...
Softaken Excel to vCard Converter Software.pdf
VVF-Customer-Presentation2025-Ver1.9.pptx
Ad

Extending OpenJDK To Support Hybrid STM/HTM

  • 1. Extending OpenJDK To Support Hybrid STM/HTM Keith Chapman Purdue U Tony Hosking ANU/Data61, Purdue U Eliot Moss UMass
  • 2. Transactions are Good They deal with concurrency • Atomic transactions avoid problems with locks • Deadlock, wrong lock, priority inversion, etc.
  • 3. Transactions are Good They deal with concurrency • Atomic transactions avoid problems with locks • Deadlock, wrong lock, priority inversion, etc. They handle recovery • Retry in case of conflict • Cleanup in face of exceptions/errors
  • 4. Transactions are Good They deal with concurrency • Atomic transactions avoid problems with locks • Deadlock, wrong lock, priority inversion, etc. They handle recovery • Retry in case of conflict • Cleanup in face of exceptions/errors More practical for ordinary programmers than locks for robust concurrent systems
  • 5. Semantics of Transactions They offer A,C,I of database ACID properties: • Atomicity: all or nothing • Consistency: single global order • Isolation: intermediate states invisible
  • 6. Semantics of Transactions They offer A,C,I of database ACID properties: • Atomicity: all or nothing • Consistency: single global order • Isolation: intermediate states invisible In sum, serializability, in face of concurrent execution and transaction failures
  • 7. Semantics of Transactions They offer A,C,I of database ACID properties: • Atomicity: all or nothing • Consistency: single global order • Isolation: intermediate states invisible In sum, serializability, in face of concurrent execution and transaction failures Can be provided by Transactional Memory • Hardware, software, or hybrid
  • 8. XJ: Transactional Java XJ Language • Dialect of Java • Supports flat and closed/open/boosted nested transactions
  • 9. XJ: Transactional Java XJ Language • Dialect of Java • Supports flat and closed/open/boosted nested transactions XJ framework supports hybrid transactions • HTM support via Intel TSX
  • 10. Current XJ System Architecture
  • 11. Current XJ System Architecture XJ source code
  • 12. Current XJ System Architecture XJ source code XJ Compiler
  • 13. Current XJ System Architecture XJ source code XJ Compiler compile
  • 14. Current XJ System Architecture XJ source code XJ Compiler standard Java bytecode compile
  • 15. Current XJ System Architecture XJ source code XJ Compiler standard Java bytecode XJ Rewriter compile
  • 16. Current XJ System Architecture XJ source code XJ Compiler standard Java bytecode XJ Rewriter compile load
  • 17. Current XJ System Architecture XJ source code XJ Compiler standard Java bytecode XJ Rewriter bytecode + run-time calls compile load
  • 18. Current XJ System Architecture XJ source code XJ run-time library XJ Compiler standard Java bytecode XJ Rewriter bytecode + run-time calls compile load
  • 19. Current XJ System Architecture XJ source code XJ run-time library XJ Compiler standard Java bytecode XJ Rewriter bytecode + run-time calls HTM-enabled JVM compile load
  • 20. Current XJ System Architecture XJ source code XJ run-time library XJ Compiler standard Java bytecode XJ Rewriter bytecode + run-time calls HTM-enabled JVM compile load run
  • 21. Current XJ System Architecture HTM 5-10 times faster than STM XJ source code XJ run-time library XJ Compiler standard Java bytecode XJ Rewriter bytecode + run-time calls HTM-enabled JVM compile load run
  • 22. Drawbacks of Outside-VM Approach Requires bytecode rewriting for transaction mechanisms & metadata • Extra level of indirection when accessing object lock/version
  • 23. Drawbacks of Outside-VM Approach Requires bytecode rewriting for transaction mechanisms & metadata • Extra level of indirection when accessing object lock/version Interpreter and compiler challenges • Jump through hoops to get compiled code to work under HTM
  • 24. Drawbacks of Outside-VM Approach Requires bytecode rewriting for transaction mechanisms & metadata • Extra level of indirection when accessing object lock/version Interpreter and compiler challenges • Jump through hoops to get compiled code to work under HTM Less opportunity for optimization
  • 25. Proposed Extensions to OpenJDK 1. Locking protocol 2. Compiler enhancements for TSX 3. Optimizations
  • 26. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 hash code age 0 01 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) if currently unlocked if currently locked revoke biasrebiasinitial lock thin lock inflate lock recursive lock lock / unlock If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 00 pointer to heavyweight monitor 10 (heavyweight locked object)
  • 27. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (heavyweight hashed/locked object) if currently unlocked if currently locked revoke biasrebiasinitial lock thin lock inflate lock recursive lock lock / unlock If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 28. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock thin lock inflate lock recursive lock lock / unlock txnread If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 29. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock thin lock inflate lock recursive lock lock / unlock txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 30. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write thin lock inflate lock recursive lock lock / unlock txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 31. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write txn commit thin lock inflate lock recursive lock lock / unlock txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 32. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write txn commit thin lock inflate lock recursive lock lock / unlock txn read/write txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 33. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write txn commit thin lock inflate lock recursive lock lock / unlock lock / hash lock / hash txn read/write txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 34. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write txn commit thin lock inflate lock recursive lock lock / unlock lock / hash unlock (unhashed) lock / hash unlock (unhashed) txn read/write txnread txnwrite If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 35. allocate object 0 epoch age 1 01 thread ID epoch age 1 01 Txn ID epoch age 1 000 version epoch age 1 001 hash code age 0 01 pointer to heavyweight monitor 100 (unlocked and unbiased but biasable object) (unlocked non-biasable object) (biased object, locked or unlocked) (lightweight locked object) (transactionally write locked object) (heavyweight hashed/locked object) (transactionally read object) if currently unlocked if currently locked revoke biasrebiasinitial lock txn write txn commit thin lock inflate lock recursive lock lock / unlock lock / hash unlock (unhashed) lock / hash unlock (unhashed) txn read/write txnread txnwrite unlock(non-txnal) txnread/write If biased locking is disabled for the classIf biased locking is enabled for the class pointer to lock record 000
  • 36. Locking Protocol (continued) What about statics? • Distinct field to hold lock/version for statics • Can extend to have distinct locks for disjoint subsets of statics
  • 37. Locking Protocol (continued) What about statics? • Distinct field to hold lock/version for statics • Can extend to have distinct locks for disjoint subsets of statics How about arrays? • Use arraylets (add a lock field for each arraylet)
  • 38. Compiler Challenges HTM does not work under the interpreter • Will fail because of buffer overflow
  • 39. Compiler Challenges HTM does not work under the interpreter • Will fail because of buffer overflow HTM does not work under compilation either :-(
  • 40. Compiler Challenges HTM does not work under the interpreter • Will fail because of buffer overflow HTM does not work under compilation either :-( • Txn-illegal instructions in HotSpot’s dynamic code patching stubs
  • 41. Compiler Challenges HTM does not work under the interpreter • Will fail because of buffer overflow HTM does not work under compilation either :-( • Txn-illegal instructions in HotSpot’s dynamic code patching stubs • “Short-term memory loss” (so stubs can’t be updated)
  • 42. Compiler Challenges (continued) TSX classifies certain instructions as illegal inside of a transaction • e.g., FXRSTOR and FXSAVE • Extensively used in HotSpot’s dynamic code patching stubs • These never work inside a hardware transaction
  • 43. TSX XBEGIN — Begin a transaction XEND — End a transaction XABORT — Abort a transaction explicitly • Takes an 8-bit value as argument • Returned to the user in bits 31:24 of EAX
  • 44. Addressing Compiler Challenges Using HTM failure codes • “Return” 8 bits of information, via the EAX register • Simple if less than 256 guards • Can use a multi-step encoding technique to handle more guards
  • 45. Addressing Compiler Challenges Using HTM failure codes • “Return” 8 bits of information, via the EAX register • Simple if less than 256 guards • Can use a multi-step encoding technique to handle more guards Maintain correlated STM and HTM code versions
  • 46. More Integrated Optimizations • Additional data-flow based optimization for STM/HTM methods • Elide redundant locks • Hoist certain locks
  • 47. Future TM Hardware Suggestions Return additional full-word error code
  • 48. Future TM Hardware Suggestions Return additional full-word error code Some kind of extra-transactional writes