Skip to content

Commit

Permalink
[Truffle] Shared Objects: add a couple explanations for the Shape re-…
Browse files Browse the repository at this point in the history
…check.
  • Loading branch information
eregon committed Nov 21, 2016
1 parent acad490 commit 1a8a43a
Showing 1 changed file with 6 additions and 0 deletions.
Expand Up @@ -60,6 +60,9 @@ public void writeExistingField(DynamicObject object, Object value,
if (shared) {
writeBarrierNode.executeWriteBarrier(value);
synchronized (object) {
// Re-check the shape under the monitor as another thread might have changed it
// by adding a field (fine) or upgrading an existing field to Object storage
// (need to use the new storage)
if (object.getShape() != cachedShape) {
CompilerDirectives.transferToInterpreter();
execute(object, value);
Expand Down Expand Up @@ -95,6 +98,9 @@ public void writeNewField(DynamicObject object, Object value,
if (shared) {
writeBarrierNode.executeWriteBarrier(value);
synchronized (object) {
// Re-check the shape under the monitor as another thread might have changed it
// by adding a field or upgrading an existing field to Object storage
// (we need to make sure to have the right shape to add the new field)
if (object.getShape() != oldShape) {
CompilerDirectives.transferToInterpreter();
execute(object, value);
Expand Down

0 comments on commit 1a8a43a

Please sign in to comment.