Skip to content

Commit

Permalink
- YOU WILL NEED A NEW MMC-RML for this (>= revision 223)!
Browse files Browse the repository at this point in the history
  svn up OMDev on windows, svn up rml on Linux or wait for a build.
- moved setStackOverflowSignal to RML.
- various other fixes so the bootstrapped compiler works with MSVC.
- hashtable for DaE.Type -> DAE.ExpType (unfortunately doesn't work to use it in Types.elabType as is slower than the current solution)
- removed the above hashtable from the compilation as is not used.
- other small code edits (mostly comments).

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@10584 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adrpo committed Nov 25, 2011
1 parent a9d2ad3 commit 99ca479
Show file tree
Hide file tree
Showing 18 changed files with 189 additions and 157 deletions.
3 changes: 2 additions & 1 deletion Compiler/FrontEnd/Inst.mo
Expand Up @@ -436,7 +436,8 @@ algorithm
equation
// if we got a stack overflow remove the stack-overflow flag
// adrpo: NOTE THAT THE NEXT FUNCTION CALL MUST BE THE FIRST IN THIS CASE, otherwise the stack overflow will not be caught!
stackOverflow = System.setStackOverflowSignal(false);
stackOverflow = setStackOverflowSignal(false);

cname_str = Absyn.pathString(path) +& Util.if_(stackOverflow, ". The compiler got into Stack Overflow!", "");
Error.addMessage(Error.ERROR_FLATTENING, {cname_str});

Expand Down
9 changes: 9 additions & 0 deletions Compiler/FrontEnd/MetaModelicaBuiltin.mo
Expand Up @@ -858,3 +858,12 @@ end realSqrt;
function fail
external "builtin";
end fail;

function setStackOverflowSignal
"Sets the stack overflow signal to the given value and returns the old one"
input Boolean inSignal;
output Boolean outSignal;
annotation(__OpenModelica_Impure = true);
external "builtin";
end setStackOverflowSignal;

11 changes: 9 additions & 2 deletions Compiler/FrontEnd/Types.mo
Expand Up @@ -3538,7 +3538,7 @@ public
constant DAE.ExpType etNoRetCall = DAE.ET_NORETCALL();
constant DAE.ExpType etFuncRefVar = DAE.ET_FUNCTION_REFERENCE_VAR();
constant DAE.ExpType etMetaType = DAE.ET_METATYPE();
constant DAE.ExpType etOther = DAE.ET_OTHER();
constant DAE.ExpType etOther = DAE.ET_OTHER();

public function elabType
"@author: adrpo
Expand Down Expand Up @@ -3694,7 +3694,7 @@ algorithm
outEq := typesElabEquivalent(inType1, ty2);
end typeMemoryEntryEq;

protected function typesElabEquivalent
public function typesElabEquivalent
"This function checks if two types will result in the same elaborated type.
Used by elabType to check if a matching elaborated type already exists."
input DAE.Type inType1;
Expand Down Expand Up @@ -7230,5 +7230,12 @@ algorithm
case (DAE.ET_NORETCALL(), _) then ();
end match;
end verifyExpressionType2;

public function printExpTypeStr
input DAE.ExpType iet;
output String str;
algorithm
str := printTypeStr(expTypetoTypesType(iet));
end printExpTypeStr;

end Types;
3 changes: 2 additions & 1 deletion Compiler/Main/Main.mo
Expand Up @@ -267,7 +267,8 @@ algorithm
(true,str,isymb);
case (str,isymb)
equation
_=System.setStackOverflowSignal(false);
_ = setStackOverflowSignal(false);

Error.addMessage(Error.STACK_OVERFLOW,{str});
then
(true,"",isymb);
Expand Down
1 change: 0 additions & 1 deletion Compiler/Makefile.common
Expand Up @@ -158,7 +158,6 @@ HashTable5.mo \
HashTableCG.mo \
HashTableStringToPath.mo \
HashTableExpToIndex.mo \
HashTableExpType.mo \
IOStream.mo \
List.mo \
Util.mo \
Expand Down
13 changes: 10 additions & 3 deletions Compiler/Util/BaseHashTable.mo
Expand Up @@ -72,6 +72,7 @@ protected import Util;
public constant Integer lowBucketSize = 257;
public constant Integer avgBucketSize = 2053;
public constant Integer bigBucketSize = 4013;
public constant Integer biggerBucketSize = 25343;
public constant Integer hugeBucketSize = 536870879 "2^29 - 33 is prime :)";
public constant Integer defaultBucketSize = avgBucketSize;

Expand Down Expand Up @@ -143,7 +144,8 @@ algorithm
Value value;
FuncsTuple fntpl;
FuncHash hashFunc;
/* Adding when not existing previously */

// Adding when not existing previously
case ((v as (key,value)),(hashTable as (hashvec,varr,bsize,n,fntpl as (hashFunc,_,_,_))))
equation
failure((_) = get(key, hashTable));
Expand Down Expand Up @@ -326,6 +328,7 @@ algorithm
Key k;
FuncEq keyEqual;
FuncHash hashFunc;

case (key,(hashvec,varr,bsize,n,(hashFunc,keyEqual,_,_)))
equation
hashindx = hashFunc(key, bsize);
Expand All @@ -334,6 +337,7 @@ algorithm
(k, v) = valueArrayNth(varr, indx);
then
(v,indx);

end match;
end get1;

Expand All @@ -347,16 +351,19 @@ protected function get2
partial function FuncEq input Key key1; input Key key2; output Boolean b; end FuncEq;
replaceable type Key subtypeof Any;
algorithm
index :=
matchcontinue (key,keyIndices,keyEqual)
index := matchcontinue (key,keyIndices,keyEqual)
local
Key key2;
list<tuple<Key,Integer>> xs;

// search for the key, found the good one
case (key,((key2,index) :: _),keyEqual)
equation
true = keyEqual(key, key2);
then
index;

// search more
case (key,(_ :: xs),keyEqual)
equation
index = get2(key, xs, keyEqual);
Expand Down
99 changes: 0 additions & 99 deletions Compiler/Util/HashTableExpType.mo

This file was deleted.

125 changes: 125 additions & 0 deletions Compiler/Util/HashTableTypeToExpType.mo
@@ -0,0 +1,125 @@
/*
* This file is part of OpenModelica.
*
* Copyright (c) 1998-CurrentYear, Linköping University,
* Department of Computer and Information Science,
* SE-58183 Linköping, Sweden.
*
* All rights reserved.
*
* THIS PROGRAM IS PROVIDED UNDER THE TERMS OF GPL VERSION 3
* AND THIS OSMC PUBLIC LICENSE (OSMC-PL).
* ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
* ACCEPTANCE OF THE OSMC PUBLIC LICENSE.
*
* The OpenModelica software and the Open Source Modelica
* Consortium (OSMC) Public License (OSMC-PL) are obtained
* from Linköping University, either from the above address,
* from the URLs: http://www.ida.liu.se/projects/OpenModelica or
* http://www.openmodelica.org, and in the OpenModelica distribution.
* GNU version 3 is obtained from: http://www.gnu.org/copyleft/gpl.html.
*
* This program is distributed WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY SET FORTH
* IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS
* OF OSMC-PL.
*
* See the full OSMC Public License conditions for more details.
*
*/

encapsulated package HashTableTypeToExpType "
This file is an extension to OpenModelica.

file: HashTableTypeToExpType.mo
package: HashTableTypeToExpType
description: Type to ExpType

RCS: $Id: HashTableTypeToExpType.mo 8796 2011-05-03 19:43:08Z adrpo $
"

/* Below is the instance specific code. For each hashtable the user must define:
Key - The key used to uniquely define elements in a hashtable
Value - The data to associate with each key
hashFunc - A function that maps a key to a positive integer.
keyEqual - A comparison function between two keys, returns true if equal.
*/

/* HashTable instance specific code */

public import DAE;
public import BaseHashTable;
protected import Types;
protected import System;

public type Key = DAE.Type;
public type Value = DAE.ExpType;

public type HashTableCrefFunctionsType = tuple<FuncHashType,FuncTypeEqual,FuncTypeStr,FuncExpTypeStr>;
public type HashTable = tuple<
array<list<tuple<Key,Integer>>>,
tuple<Integer,Integer,array<Option<tuple<Key,Value>>>>,
Integer,
Integer,
HashTableCrefFunctionsType
>;

partial function FuncHashType
input Key ty;
input Integer mod;
output Integer res;
end FuncHashType;

partial function FuncTypeEqual
input Key ty1;
input Key ty2;
output Boolean res;
end FuncTypeEqual;

partial function FuncTypeStr
input Key ty;
output String res;
end FuncTypeStr;

partial function FuncExpTypeStr
input Value exp;
output String res;
end FuncExpTypeStr;

public function myHash
input DAE.Type inTy;
input Integer hashMod;
output Integer hash;
protected
String str;
DAE.TType tt;
DAE.Type t;
algorithm
//str := Types.printTypeStr(inTy);
//hash := System.stringHashDjb2Mod(str, hashMod);
//print("hash: " +& intString(hash) +& " for " +& str +& "\n");
(tt, _) := inTy;
t := (tt, NONE());
hash := valueHashMod(t, hashMod);
end myHash;

public function emptyHashTable
"Returns an empty HashTable.
Using the default bucketsize.."
output HashTable hashTable;
algorithm
hashTable := emptyHashTableSized(BaseHashTable.biggerBucketSize);
end emptyHashTable;

public function emptyHashTableSized
"Returns an empty HashTable.
Using the bucketsize size."
input Integer size;
output HashTable hashTable;
algorithm
hashTable := BaseHashTable.emptyHashTableWork(size,(myHash,Types.typesElabEquivalent,Types.printTypeStr,Types.printExpTypeStr));
end emptyHashTableSized;

end HashTableTypeToExpType;
8 changes: 0 additions & 8 deletions Compiler/Util/System.mo
Expand Up @@ -899,12 +899,4 @@ public function reopenStandardStream
external "C" success=SystemImpl__reopenStandardStream(_stream,filename) annotation(Library = {"omcruntime"});
end reopenStandardStream;

public function setStackOverflowSignal
"@author: adrpo
sets the stack overflow signal and returns the previous one"
input Boolean inStackOverflow;
output Boolean outStackOverflow;
external "C" outStackOverflow = SystemImpl__setStackOverflowSignal(inStackOverflow) annotation(Library = {"omcruntime"});
end setStackOverflowSignal;

end System;
14 changes: 0 additions & 14 deletions Compiler/runtime/System_rml.c
Expand Up @@ -2115,20 +2115,6 @@ RML_BEGIN_LABEL(System__reopenStandardStream)
}
RML_END_LABEL

RML_BEGIN_LABEL(System__setStackOverflowSignal)
{
char tmp = rml_stack_overflow;

rml_stack_overflow = (rmlA0==RML_FALSE)?0:1;

// fprintf(stderr, "-> System__setStackOverflowSignal rml_stack_overflow = %d! before was: %d\n", (int)rml_stack_overflow, (int)tmp); fflush(NULL);

rmlA0 = tmp?RML_TRUE:RML_FALSE;

RML_TAILCALLK(rmlSC);
}
RML_END_LABEL

RML_BEGIN_LABEL(System__getMakeCommand)
{
rmlA0 = mk_scon(DEFAULT_MAKE);
Expand Down
2 changes: 2 additions & 0 deletions Compiler/runtime/config.h
Expand Up @@ -52,7 +52,9 @@
#endif

#define LDFLAGS_SENDDATA " -static-libgcc -lsendData -lQtNetwork-mingw -lQtCore-mingw -lQtGui-mingw -luuid -lole32 -lws2_32"
#if !defined(_MSC_VER)
#define CONFIG_WITH_SENDDATA 1
#endif
#define CONFIG_EXE_EXT ".exe"
#define CONFIG_DLL_EXT ".dll"
#define CONFIG_OS "Windows_NT"
Expand Down

0 comments on commit 99ca479

Please sign in to comment.