Changeset 7100384 in OpenModelica


Ignore:
Timestamp:
2016-04-04T08:50:36+02:00 (8 years ago)
Author:
hudson <openmodelica@…>
Branches:
Added-citation-metadata, maintenance/v1.14, maintenance/v1.15, maintenance/v1.16, maintenance/v1.17, maintenance/v1.18, maintenance/v1.19, maintenance/v1.20, maintenance/v1.21, maintenance/v1.22, maintenance/v1.23, master, omlib-staging
Children:
0aff3d1
Parents:
f49dbc4
git-author:
Martin Sjölund <martin.sjolund@…> (04/04/16 08:50:36)
git-committer:
hudson <openmodelica@…> (04/04/16 08:50:36)
Message:

Workaround for bugs with hash tables

Location:
Compiler
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Compiler/FrontEnd/Inline.mo

    rf49dbc4 r7100384  
    692692    case (e,fns,source)
    693693      equation
    694         (e_1,_) = Expression.Expression.traverseExpBottomUp(e,function forceInlineCall(fns=fns),{});
     694        (e_1,_) = Expression.traverseExpBottomUp(e,function forceInlineCall(fns=fns),{});
    695695        false = referenceEq(e, e_1);
    696696        source = DAEUtil.addSymbolicTransformation(source,DAE.OP_INLINE(DAE.PARTIAL_EQUATION(e),DAE.PARTIAL_EQUATION(e_1)));
     
    822822          // MSL 3.2.1 need GenerateEvents to disable this
    823823          newExp = Expression.addNoEventToRelationsAndConds(newExp);
    824           (newExp,(_,_,true)) = Expression.Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
     824          (newExp,(_,_,true)) = Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
    825825          // for inlinecalls in functions
    826           (newExp1,assrtLst) = Expression.Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrtLst);
     826          (newExp1,assrtLst) = Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrtLst);
    827827        else // normal Modelica
    828828          // get inputs, body and output
     
    843843            generateEvents = hasGenerateEventsAnnotation(comment);
    844844            newExp = if not generateEvents then Expression.addNoEventToRelationsAndConds(newExp) else newExp;
    845             (newExp,(_,_,true)) = Expression.Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
     845            (newExp,(_,_,true)) = Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
    846846            // for inlinecalls in functions
    847             (newExp1,assrtLst) = Expression.Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrtLst);
     847            (newExp1,assrtLst) = Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrtLst);
    848848          else // assert detected
    849849            true = listLength(assrtStmts) == 1;
     
    860860            generateEvents = hasGenerateEventsAnnotation(comment);
    861861            newExp = if not generateEvents then Expression.addNoEventToRelationsAndConds(newExp) else newExp;
    862             (newExp,(_,_,true)) = Expression.Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
     862            (newExp,(_,_,true)) = Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
    863863            assrt = inlineAssert(assrt,fns,argmap,checkcr);
    864864            // for inlinecalls in functions
    865             (newExp1,assrtLst) = Expression.Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrt::assrtLst);
     865            (newExp1,assrtLst) = Expression.traverseExpBottomUp(newExp,function inlineCall(fns=fns),assrt::assrtLst);
    866866          end if;
    867867        end if;
     
    887887algorithm
    888888  DAE.STMT_ASSERT(cond=cond, msg=msg, level=level, source=source) := assrtIn;
    889   (cond,_,_,_) := inlineExp(cond,fns,source);
    890   (cond,(_,_,true)) := Expression.Expression.traverseExpBottomUp(cond,replaceArgs,(argmap,checkcr,true));
     889  (cond,(_,_,true)) := Expression.traverseExpBottomUp(cond,replaceArgs,(argmap,checkcr,true));
    891890  //print("ASSERT inlined: "+ExpressionDump.printExpStr(cond)+"\n");
    892   (msg,_,_,_) := inlineExp(msg,fns,source);
    893   (msg,(_,_,true)) := Expression.Expression.traverseExpBottomUp(msg,replaceArgs,(argmap,checkcr,true));
     891  (msg,(_,_,true)) := Expression.traverseExpBottomUp(msg,replaceArgs,(argmap,checkcr,true));
     892  // These clear checkcr/repl and need to be performed last
     893  // (cond,_,_,_) := inlineExp(cond,fns,source);
     894  // (msg,_,_,_) := inlineExp(msg,fns,source);
    894895  assrtOut := DAE.STMT_ASSERT(cond, msg, level, source);
    895896end inlineAssert;
     
    966967        generateEvents = hasGenerateEventsAnnotation(comment);
    967968        newExp = if not generateEvents then Expression.addNoEventToRelationsAndConds(newExp) else newExp;
    968         (newExp,(_,_,true)) = Expression.Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
     969        (newExp,(_,_,true)) = Expression.traverseExpBottomUp(newExp,replaceArgs,(argmap,checkcr,true));
    969970        // for inlinecalls in functions
    970971        (newExp1,assrtLst) = Expression.traverseExpBottomUp(newExp,function forceInlineCall(fns=fns),assrtLst);
     
    16001601    case DAE.PARTIAL_EQUATION(e)
    16011602      equation
    1602         (e_1,_) = Expression.Expression.traverseExpBottomUp(e,fn,{});
     1603        (e_1,_) = Expression.traverseExpBottomUp(e,fn,{});
    16031604        changed = not referenceEq(e, e_1);
    16041605        eq2 = DAE.PARTIAL_EQUATION(e_1);
     
    16081609    case DAE.RESIDUAL_EXP(e)
    16091610      equation
    1610         (e_1,_) = Expression.Expression.traverseExpBottomUp(e,fn,{});
     1611        (e_1,_) = Expression.traverseExpBottomUp(e,fn,{});
    16111612        changed = not referenceEq(e, e_1);
    16121613        eq2 = DAE.RESIDUAL_EXP(e_1);
     
    16161617    case DAE.EQUALITY_EXPS(e1,e2)
    16171618      equation
    1618         (e1_1,_) = Expression.Expression.traverseExpBottomUp(e1,fn,{});
    1619         (e2_1,_) = Expression.Expression.traverseExpBottomUp(e2,fn,{});
     1619        (e1_1,_) = Expression.traverseExpBottomUp(e1,fn,{});
     1620        (e2_1,_) = Expression.traverseExpBottomUp(e2,fn,{});
    16201621        changed = not (referenceEq(e1, e1_1) and referenceEq(e2, e2_1));
    16211622        eq2 = DAE.EQUALITY_EXPS(e1_1,e2_1);
  • Compiler/Util/BaseHashTable.mo

    rcd37dee6 r7100384  
    649649  Key key;
    650650  array<Option<HashEntry>> vae;
     651  constant Boolean workaroundForBug=true "TODO: Make it impossible to update a value by not updating n (fully mutable HT instead of this hybrid)";
     652  constant Boolean debug=false;
    651653algorithm
    652654  (hv, (vs, ve, vae), bs, ft as (hashFunc,_,_,_)) := ht;
     
    655657      case SOME((key,_))
    656658        algorithm
    657           hash_idx := hashFunc(key, bs) + 1;
    658           arrayUpdate(hv, hash_idx, {});
     659          if not workaroundForBug then
     660            hash_idx := hashFunc(key, bs) + 1;
     661            arrayUpdate(hv, hash_idx, {});
     662          end if;
    659663          arrayUpdate(vae, i, NONE());
    660664        then ();
    661665      else
    662666        algorithm
    663           return;
     667          if not workaroundForBug then return; end if;
    664668        then ();
    665669    end match;
    666670  end for;
     671  if debug then
     672    for i in vae loop
     673      if isSome(i) then
     674        print("vae not empty\n");
     675        break;
     676      end if;
     677    end for;
     678  end if;
     679  if workaroundForBug then
     680    for i in 1:arrayLength(hv) loop
     681      if not listEmpty(arrayGet(hv,i)) then
     682        if debug then print("hv not empty\n"); end if;
     683        arrayUpdate(hv,i,{});
     684      end if;
     685    end for;
     686  end if;
    667687end clearAssumeNoDelete;
    668688
Note: See TracChangeset for help on using the changeset viewer.