Skip to content

Commit

Permalink
add GC_get_prof_stats as OMC API, ticket:4889
Browse files Browse the repository at this point in the history
Belonging to [master]:
  - OpenModelica/OMCompiler#2381
  • Loading branch information
adrpo authored and OpenModelica-Hudson committed Apr 18, 2018
1 parent ae5e0b1 commit de3a487
Show file tree
Hide file tree
Showing 3 changed files with 92 additions and 1 deletion.
22 changes: 22 additions & 0 deletions Compiler/FrontEnd/ModelicaBuiltin.mo
Expand Up @@ -3889,6 +3889,28 @@ annotation(
</html>"));
end GC_set_max_heap_size;

record GC_PROFSTATS
Integer heapsize_full;
Integer free_bytes_full;
Integer unmapped_bytes;
Integer bytes_allocd_since_gc;
Integer allocd_bytes_before_gc;
Integer non_gc_bytes;
Integer gc_no;
Integer markers_m1;
Integer bytes_reclaimed_since_gc;
Integer reclaimed_bytes_before_gc;
end GC_PROFSTATS;

function GC_get_prof_stats
output GC_PROFSTATS gcStats;
external "builtin";
annotation(
Documentation(info="<html>
<p>Returns a record with the GC statistics.</p>
</html>"));
end GC_get_prof_stats;

function checkInterfaceOfPackages
input TypeName cl;
input String dependencyMatrix[:,:];
Expand Down
32 changes: 32 additions & 0 deletions Compiler/NFFrontEnd/NFModelicaBuiltin.mo
Expand Up @@ -3955,6 +3955,38 @@ annotation(
</html>"));
end GC_expand_hp;

function GC_set_max_heap_size
input Integer size;
output Boolean success;
external "builtin";
annotation(
Documentation(info="<html>
<p>Forces the GC to limit the maximum heap size.</p>
</html>"));
end GC_set_max_heap_size;

record GC_PROFSTATS
Integer heapsize_full;
Integer free_bytes_full;
Integer unmapped_bytes;
Integer bytes_allocd_since_gc;
Integer allocd_bytes_before_gc;
Integer non_gc_bytes;
Integer gc_no;
Integer markers_m1;
Integer bytes_reclaimed_since_gc;
Integer reclaimed_bytes_before_gc;
end GC_PROFSTATS;

function GC_get_prof_stats
output GC_PROFSTATS gcStats;
external "builtin";
annotation(
Documentation(info="<html>
<p>Returns a record with the GC statistics.</p>
</html>"));
end GC_get_prof_stats;

function checkInterfaceOfPackages
input TypeName cl;
input String dependencyMatrix[:,:];
Expand Down
39 changes: 38 additions & 1 deletion Compiler/Script/CevalScript.mo
Expand Up @@ -549,7 +549,7 @@ algorithm
Absyn.Exp aexp;
DAE.DAElist dae;
array<list<Integer>> m,mt;
Values.Value ret_val,simValue,value,v,cvar,cvar2,v1,v2,v3;
Values.Value ret_val,simValue,value,v,cvar,cvar2,v1,v2,v3,gcStatRec;
Absyn.ComponentRef cr,cr_1;
Integer size,resI,i,i1,i2,i3,n,curveStyle,numberOfIntervals, status;
list<Integer> is;
Expand Down Expand Up @@ -589,6 +589,7 @@ algorithm
list<list<Values.Value>> valsLst;
Boolean new_inst;
SymbolTable interactiveSymbolTable, interactiveSymbolTable2;
GC.ProfStats gcStats;

case (cache,_,"parseString",{Values.STRING(str1),Values.STRING(str2)},_)
equation
Expand Down Expand Up @@ -676,6 +677,42 @@ algorithm
GC.setMaxHeapSize(i);
then (cache,Values.BOOL(true));

case (cache,_,"GC_get_prof_stats",{},_)
equation
gcStats = GC.getProfStats();
gcStatRec = match gcStats
case GC.PROFSTATS() then
Values.RECORD(Absyn.IDENT("GC_PROFSTATS"),
{
Values.INTEGER(gcStats.heapsize_full),
Values.INTEGER(gcStats.free_bytes_full),
Values.INTEGER(gcStats.unmapped_bytes),
Values.INTEGER(gcStats.bytes_allocd_since_gc),
Values.INTEGER(gcStats.allocd_bytes_before_gc),
Values.INTEGER(gcStats.bytes_allocd_since_gc+gcStats.allocd_bytes_before_gc),
Values.INTEGER(gcStats.non_gc_bytes),
Values.INTEGER(gcStats.gc_no),
Values.INTEGER(gcStats.markers_m1),
Values.INTEGER(gcStats.bytes_reclaimed_since_gc),
Values.INTEGER(gcStats.reclaimed_bytes_before_gc)
},
{
"heapsize_full",
"free_bytes_full",
"unmapped_bytes: ",
"bytes_allocd_since_gc",
"allocd_bytes_before_gc",
"total_allocd_bytes",
"non_gc_bytes",
"gc_no",
"markers_m1",
"bytes_reclaimed_since_gc",
"reclaimed_bytes_before_gc"
},
-1);
end match;
then (cache, gcStatRec);

case (cache,_,"clear",{},_)
algorithm
SymbolTable.reset();
Expand Down

0 comments on commit de3a487

Please sign in to comment.