Skip to content
This repository was archived by the owner on May 18, 2019. It is now read-only.

Commit de3a487

Browse files
adrpoOpenModelica-Hudson
authored andcommitted
add GC_get_prof_stats as OMC API, ticket:4889
Belonging to [master]: - #2381
1 parent ae5e0b1 commit de3a487

File tree

3 files changed

+92
-1
lines changed

3 files changed

+92
-1
lines changed

Compiler/FrontEnd/ModelicaBuiltin.mo

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3889,6 +3889,28 @@ annotation(
38893889
</html>"));
38903890
end GC_set_max_heap_size;
38913891

3892+
record GC_PROFSTATS
3893+
Integer heapsize_full;
3894+
Integer free_bytes_full;
3895+
Integer unmapped_bytes;
3896+
Integer bytes_allocd_since_gc;
3897+
Integer allocd_bytes_before_gc;
3898+
Integer non_gc_bytes;
3899+
Integer gc_no;
3900+
Integer markers_m1;
3901+
Integer bytes_reclaimed_since_gc;
3902+
Integer reclaimed_bytes_before_gc;
3903+
end GC_PROFSTATS;
3904+
3905+
function GC_get_prof_stats
3906+
output GC_PROFSTATS gcStats;
3907+
external "builtin";
3908+
annotation(
3909+
Documentation(info="<html>
3910+
<p>Returns a record with the GC statistics.</p>
3911+
</html>"));
3912+
end GC_get_prof_stats;
3913+
38923914
function checkInterfaceOfPackages
38933915
input TypeName cl;
38943916
input String dependencyMatrix[:,:];

Compiler/NFFrontEnd/NFModelicaBuiltin.mo

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3955,6 +3955,38 @@ annotation(
39553955
</html>"));
39563956
end GC_expand_hp;
39573957

3958+
function GC_set_max_heap_size
3959+
input Integer size;
3960+
output Boolean success;
3961+
external "builtin";
3962+
annotation(
3963+
Documentation(info="<html>
3964+
<p>Forces the GC to limit the maximum heap size.</p>
3965+
</html>"));
3966+
end GC_set_max_heap_size;
3967+
3968+
record GC_PROFSTATS
3969+
Integer heapsize_full;
3970+
Integer free_bytes_full;
3971+
Integer unmapped_bytes;
3972+
Integer bytes_allocd_since_gc;
3973+
Integer allocd_bytes_before_gc;
3974+
Integer non_gc_bytes;
3975+
Integer gc_no;
3976+
Integer markers_m1;
3977+
Integer bytes_reclaimed_since_gc;
3978+
Integer reclaimed_bytes_before_gc;
3979+
end GC_PROFSTATS;
3980+
3981+
function GC_get_prof_stats
3982+
output GC_PROFSTATS gcStats;
3983+
external "builtin";
3984+
annotation(
3985+
Documentation(info="<html>
3986+
<p>Returns a record with the GC statistics.</p>
3987+
</html>"));
3988+
end GC_get_prof_stats;
3989+
39583990
function checkInterfaceOfPackages
39593991
input TypeName cl;
39603992
input String dependencyMatrix[:,:];

Compiler/Script/CevalScript.mo

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ algorithm
549549
Absyn.Exp aexp;
550550
DAE.DAElist dae;
551551
array<list<Integer>> m,mt;
552-
Values.Value ret_val,simValue,value,v,cvar,cvar2,v1,v2,v3;
552+
Values.Value ret_val,simValue,value,v,cvar,cvar2,v1,v2,v3,gcStatRec;
553553
Absyn.ComponentRef cr,cr_1;
554554
Integer size,resI,i,i1,i2,i3,n,curveStyle,numberOfIntervals, status;
555555
list<Integer> is;
@@ -589,6 +589,7 @@ algorithm
589589
list<list<Values.Value>> valsLst;
590590
Boolean new_inst;
591591
SymbolTable interactiveSymbolTable, interactiveSymbolTable2;
592+
GC.ProfStats gcStats;
592593

593594
case (cache,_,"parseString",{Values.STRING(str1),Values.STRING(str2)},_)
594595
equation
@@ -676,6 +677,42 @@ algorithm
676677
GC.setMaxHeapSize(i);
677678
then (cache,Values.BOOL(true));
678679

680+
case (cache,_,"GC_get_prof_stats",{},_)
681+
equation
682+
gcStats = GC.getProfStats();
683+
gcStatRec = match gcStats
684+
case GC.PROFSTATS() then
685+
Values.RECORD(Absyn.IDENT("GC_PROFSTATS"),
686+
{
687+
Values.INTEGER(gcStats.heapsize_full),
688+
Values.INTEGER(gcStats.free_bytes_full),
689+
Values.INTEGER(gcStats.unmapped_bytes),
690+
Values.INTEGER(gcStats.bytes_allocd_since_gc),
691+
Values.INTEGER(gcStats.allocd_bytes_before_gc),
692+
Values.INTEGER(gcStats.bytes_allocd_since_gc+gcStats.allocd_bytes_before_gc),
693+
Values.INTEGER(gcStats.non_gc_bytes),
694+
Values.INTEGER(gcStats.gc_no),
695+
Values.INTEGER(gcStats.markers_m1),
696+
Values.INTEGER(gcStats.bytes_reclaimed_since_gc),
697+
Values.INTEGER(gcStats.reclaimed_bytes_before_gc)
698+
},
699+
{
700+
"heapsize_full",
701+
"free_bytes_full",
702+
"unmapped_bytes: ",
703+
"bytes_allocd_since_gc",
704+
"allocd_bytes_before_gc",
705+
"total_allocd_bytes",
706+
"non_gc_bytes",
707+
"gc_no",
708+
"markers_m1",
709+
"bytes_reclaimed_since_gc",
710+
"reclaimed_bytes_before_gc"
711+
},
712+
-1);
713+
end match;
714+
then (cache, gcStatRec);
715+
679716
case (cache,_,"clear",{},_)
680717
algorithm
681718
SymbolTable.reset();

0 commit comments

Comments
 (0)