Mercurial > hg > graal-jvmci-8
comparison graal/com.oracle.truffle.api/src/com/oracle/truffle/api/nodes/Node.java @ 19979:f792b4270cb1
Truffle: simplify inAtomicBlock assertion.
author | Christian Humer <christian.humer@oracle.com> |
---|---|
date | Fri, 20 Mar 2015 19:00:50 +0100 |
parents | cd59085cf0d8 |
children | 8dc73c226c63 |
comparison
equal
deleted
inserted
replaced
19978:4cd28f6e3485 | 19979:f792b4270cb1 |
---|---|
555 return ""; | 555 return ""; |
556 } | 556 } |
557 | 557 |
558 private static final Object GIL = new Object(); | 558 private static final Object GIL = new Object(); |
559 | 559 |
560 private static final ThreadLocal<Integer> IN_ATOMIC_BLOCK = new ThreadLocal<>(); | 560 private static final ThreadLocal<Integer> IN_ATOMIC_BLOCK = new ThreadLocal<Integer>() { |
561 @Override | |
562 protected Integer initialValue() { | |
563 return 0; | |
564 } | |
565 }; | |
561 | 566 |
562 private static boolean inAtomicBlock() { | 567 private static boolean inAtomicBlock() { |
563 Integer value = IN_ATOMIC_BLOCK.get(); | 568 return IN_ATOMIC_BLOCK.get() > 0; |
564 if (value == null) { | |
565 return false; | |
566 } | |
567 return value > 0; | |
568 } | 569 } |
569 | 570 |
570 private static boolean enterAtomic() { | 571 private static boolean enterAtomic() { |
571 Integer currentValue = IN_ATOMIC_BLOCK.get(); | 572 IN_ATOMIC_BLOCK.set(IN_ATOMIC_BLOCK.get() + 1); |
572 if (currentValue == null) { | |
573 currentValue = 0; | |
574 } | |
575 IN_ATOMIC_BLOCK.set(currentValue + 1); | |
576 return true; | 573 return true; |
577 } | 574 } |
578 | 575 |
579 private static boolean exitAtomic() { | 576 private static boolean exitAtomic() { |
580 IN_ATOMIC_BLOCK.set(IN_ATOMIC_BLOCK.get() - 1); | 577 IN_ATOMIC_BLOCK.set(IN_ATOMIC_BLOCK.get() - 1); |