Show
Ignore:
Timestamp:
07/04/08 02:15:06 (5 months ago)
Author:
ruoso
Message:

[smop] yet more work on the p6opaque implementation... Some nasty bug is causing a deadlock (yes... I know the reasons for locks to exist is to cause dead-locks, but that is what I got so far)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • v6/smop/src/p6opaque.sm0p

    r21201 r21202  
    113113 
    114114      if (invocant == SMOP__p6opaque__RI) { 
    115         fprintf(stderr, "[SMOP p6opaque] TODO: p6opaque RI's meta undefined yet\n"); 
    116115        ret = SMOP__NATIVE__bool_false; 
    117116      } else if (SMOP_RI(invocant) != (SMOP__ResponderInterface*)SMOP__p6opaque__RI) { 
     
    119118        ret = SMOP__NATIVE__bool_false; 
    120119      } else { 
    121         if (set) 
     120 
     121        if (set) { 
    122122          smop_lowlevel_wrlock(invocant); 
    123         else 
     123        } else { 
    124124          smop_lowlevel_rdlock(invocant); 
     125        } 
    125126 
    126127        if (((SMOP__p6opaque_struct*)invocant)->metadata) { 
    127128          // we have our own metadata. 
    128           SMOP__Object* old = ((SMOP__p6opaque_struct*)invocant)->metadata->how; 
    129           ret = old; 
     129          SMOP__Object* old = NULL; 
    130130          if (set) { 
     131            old = ((SMOP__p6opaque_struct*)invocant)->metadata->how; 
    131132            ((SMOP__p6opaque_struct*)invocant)->metadata->how = set; 
    132             ret = set; 
    133133          } 
     134          ret = ((SMOP__p6opaque_struct*)invocant)->metadata->how; 
    134135          smop_lowlevel_unlock(invocant); 
     136 
    135137          if (old) SMOP_RELEASE(interpreter, old); 
     138          SMOP_REFERENCE(interpreter, ret); 
    136139 
    137140        } else if (((SMOP__p6opaque_struct*)invocant)->instanceof) { 
     
    143146          if (set) { 
    144147            fprintf(stderr, "[SMOP p6opaque] Can't set how on a instance\n"); 
    145             SMOP_RELEASE(interpreter,set); 
    146148          } else { 
    147149 
     
    173175          ret = SMOP_REFERENCE(interpreter, set); 
    174176        } else { 
     177          smop_lowlevel_unlock(invocant); 
    175178          fprintf(stderr,"[SMOP p6opaque] TODO: invalid .^!how call\n"); 
     179          ret = SMOP__NATIVE__bool_false; 
    176180        } 
    177181      } 
     
    183187      ret = SMOP__NATIVE__bool_false; 
    184188    } 
     189 
     190  } else if (identifier == SMOP__ID__REPR_DESTROY) { 
     191 
     192    if (SMOP_RI(capture) == (SMOP__ResponderInterface*)SMOP__NATIVE__capture) { 
     193      SMOP__Object* invocant = SMOP__NATIVE__capture_invocant(interpreter,capture); 
     194 
     195      if (invocant == SMOP__p6opaque__RI) { 
     196        ret = SMOP__NATIVE__bool_false; 
     197      } else if (SMOP_RI(invocant) != (SMOP__ResponderInterface*)SMOP__p6opaque__RI) { 
     198        fprintf(stderr, "[SMOP p6opaque] call to repr method with non p6opaque invocant\n"); 
     199        ret = SMOP__NATIVE__bool_false; 
     200      } else { 
     201        smop_lowlevel_wrlock(invocant); 
     202        SMOP__p6opaque_LOWL_metadata* m = ((SMOP__p6opaque_struct*)invocant)->metadata; 
     203        ((SMOP__p6opaque_struct*)invocant)->metadata = NULL; 
     204        smop_lowlevel_unlock(invocant); 
     205        SMOP_RELEASE(interpreter,m->how); 
     206        free(m); 
     207      } 
     208 
     209      SMOP_RELEASE(interpreter,invocant); 
     210    } else { 
     211      fprintf(stderr, "[SMOP p6opaque] TODO: non-native captures\n"); 
     212    } 
     213  } else if (identifier == SMOP__ID__DESTROYALL) { 
     214 
     215    ret = SMOP__NATIVE__bool_true; 
     216    SMOP__Object* frame; 
     217    SMOP__Object* continuation = SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
     218                                               SMOP__ID__continuation,  
     219                                               SMOP_REFERENCE(interpreter,interpreter)); 
     220 
     221    if (SMOP_RI(capture) == (SMOP__ResponderInterface*)SMOP__p6opaque__RI) { 
     222      SMOP__Object* invocant = capture; 
     223      $frame = q:sm0p { 
     224        $capture; 
     225        $identifier; 
     226        $invocant; 
     227        $invocant.SMOP__ID__REPR_how(); 
     228        SMOP__SLIME__CurrentFrame.copy(1); 
     229        SMOP__SLIME__CurrentFrame.move_responder(2,2); 
     230        SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(2,(4,5,6),(),1)); 
     231        SMOP__NATIVE__bool_true.SMOP__ID__dispatch(); 
     232        $invocant.SMOP__ID__REPR_DESTROY(); 
     233        $interpreter.goto(|$continuation); 
     234      }; 
     235    } else { 
     236      $frame = q:sm0p { 
     237        $capture; 
     238        $identifier; 
     239        $capture.SMOP__ID__invocant(); 
     240        $capture.SMOP__ID__invocant(); 
     241        SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(1,(),(),1)); 
     242        SMOP__p6opaque__RI.SMOP__ID__REPR_how(); 
     243        SMOP__SLIME__CurrentFrame.copy(1); 
     244        SMOP__SLIME__CurrentFrame.move_responder(2,2); 
     245        SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(2,(6,7,8),(),1)); 
     246        SMOP__NATIVE__bool_true.SMOP__ID__dispatch(); 
     247        $capture.SMOP__ID__invocant(); 
     248        SMOP__SLIME__CurrentFrame.move_responder(1,3); 
     249        $capture.SMOP__ID__invocant(); 
     250        SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(1,(),(),1)); 
     251        SMOP__p6opaque__RI.SMOP__ID__REPR_DESTROY(); 
     252        $interpreter.goto(|$continuation); 
     253      }; 
     254    } 
     255 
     256    SMOP_DISPATCH(interpreter, SMOP_RI(interpreter), 
     257                  SMOP__ID__goto, 
     258                  frame); 
     259 
    185260  } else { 
    186261    // as we want to support different captures, we'll start to use a 
     
    196271      $identifier; 
    197272      $capture.SMOP__ID__invocant(); 
    198       SMOP__SLIME__CurrentFrame.copy(1); 
     273      $capture.SMOP__ID__invocant(); 
    199274      SMOP__SLIME__CurrentFrame.move_capturize(SMOP__SLIME__Capturize.new(1,(),(),1)); 
    200275      SMOP__p6opaque__RI.SMOP__ID__REPR_how();