From d715c111d8a465cd3b32aae68463756b9c1db183 Mon Sep 17 00:00:00 2001 From: "Brian S. O'Neill" Date: Sun, 16 Sep 2007 19:02:43 +0000 Subject: Ensure that non-destructive update doesn't invoke load trigger. --- .../carbonado/gen/MasterStorableGenerator.java | 30 ++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) (limited to 'src/main/java/com/amazon/carbonado') diff --git a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java index 18f0ea9..b9da366 100644 --- a/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java +++ b/src/main/java/com/amazon/carbonado/gen/MasterStorableGenerator.java @@ -536,6 +536,8 @@ public final class MasterStorableGenerator { Label failed = b.createLabel(); + Label tryLoadStart = null, tryLoadEnd = null; + if (mFeatures.contains(MasterFeature.UPDATE_FULL)) { // Storable saved = copy(); b.loadThis(); @@ -544,13 +546,29 @@ public final class MasterStorableGenerator { savedVar = b.createLocalVariable(null, mClassFile.getType()); b.storeLocal(savedVar); - // if (!saved.tryLoad()) { - // goto failed; + // support.locallyDisableLoadTrigger(); + // try { + // if (!saved.tryLoad()) { + // goto failed; + // } + // } finally { + // support.locallyEnableLoadTrigger(); // } + b.loadThis(); + b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); + b.invokeInterface(triggerSupportType, "locallyDisableLoadTrigger", null, null); + + tryLoadStart = b.createLabel().setLocation(); b.loadLocal(savedVar); b.invokeInterface(storableType, TRY_LOAD_METHOD_NAME, TypeDesc.BOOLEAN, null); + tryLoadEnd = b.createLabel().setLocation(); + b.loadThis(); + b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); + b.invokeInterface(triggerSupportType, "locallyEnableLoadTrigger", null, null); b.ifZeroComparisonBranch(failed, "=="); + // Exception handler generated at the end of method. + // if (version support enabled) { // if (!derived version) { // if (this.getVersionNumber() != saved.getVersionNumber()) { @@ -706,6 +724,14 @@ public final class MasterStorableGenerator { b.loadConstant(false); b.returnValue(TypeDesc.BOOLEAN); + if (tryLoadStart != null) { + b.exceptionHandler(tryLoadStart, tryLoadEnd, null); + b.loadThis(); + b.loadField(StorableGenerator.SUPPORT_FIELD_NAME, triggerSupportType); + b.invokeInterface(triggerSupportType, "locallyEnableLoadTrigger", null, null); + b.throwObject(); + } + addExitTransaction(b, UPDATE_OP, txnVar, tryStart); } -- cgit v1.2.3