1
0
mirror of https://gitlab.com/camelot/kickc.git synced 2024-08-02 09:29:35 +00:00

Restructured fragment tests to use less memory.

This commit is contained in:
jespergravgaard 2019-03-09 23:50:50 +01:00
parent 980fc0aeb5
commit 6bc35f6c34
18 changed files with 287128 additions and 8 deletions

View File

@ -57,6 +57,14 @@ public class AsmFragmentTemplateSynthesizer {
*/
private Map<String, AsmFragmentSynthesis> synthesisGraph;
/**
* Get information about the size of the synthesizer data structures
* @return String with size information
*/
public static String getSizes() {
return "graph: "+ SYNTHESIZER.synthesisGraph.size();
}
public static AsmFragmentInstance getFragmentInstance(AsmFragmentInstanceSpec instanceSpec, CompileLog log) {
String signature = instanceSpec.getSignature();
AsmFragmentTemplate fragmentTemplate = SYNTHESIZER.getFragmentTemplate(signature, log);
@ -367,6 +375,9 @@ public class AsmFragmentTemplateSynthesizer {
return synthesisGraph.get(signature);
}
/** Number of synthesis created
private long synthesisCount = 0;
/**
* Get (or create) the synthesis used to synthesize a fragment template.
* If the synthesis does not already exist in the synthesis graph it is created - along with any sub-synthesis recursively usable for creating it.

View File

@ -10,7 +10,6 @@ import org.junit.BeforeClass;
import org.junit.Test;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
import static junit.framework.TestCase.fail;
@ -41,15 +40,101 @@ public class TestFragments {
}
@Test
public void testAssignmentsBinaryBu() throws IOException {
testFragments("fragments-assignment-binary", assignmentsBinaryBu());
public void testAssignmentsBinaryVbuaa() throws IOException {
testAssignmentsBinary(new Value("vbuaa"));
}
@Test
public void testAssignmentsBinaryVbuxx() throws IOException {
testAssignmentsBinary(new Value("vbuxx"));
}
@Test
public void testAssignmentsBinaryVbuyy() throws IOException {
testAssignmentsBinary(new Value("vbuyy"));
}
@Test
public void testAssignmentsBinaryVbuz1() throws IOException {
testAssignmentsBinary(new Value("vbuz1"));
}
@Test
public void testAssignmentsBinaryDerefVbuz1() throws IOException {
testAssignmentsBinary(new Value("_deref_pbuz1"));
}
@Test
public void testAssignmentsBinaryDerefVbuc1() throws IOException {
testAssignmentsBinary(new Value("_deref_pbuc1"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuaa() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuaa"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuxx() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuxx"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuyy() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuyy"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuz1() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuz1"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuz2() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuz2"));
}
@Test
public void testAssignmentsBinaryPbuz1DerefidxVbuc1() throws IOException {
testAssignmentsBinary(new Value("pbuz1_derefidx_vbuc1"));
}
@Test
public void testAssignmentsBinaryPbuc1DerefidxVbuaa() throws IOException {
testAssignmentsBinary(new Value("pbuc1_derefidx_vbuaa"));
}
@Test
public void testAssignmentsBinaryPbuc1DerefidxVbuxx() throws IOException {
testAssignmentsBinary(new Value("pbuc1_derefidx_vbuxx"));
}
@Test
public void testAssignmentsBinaryPbuc1DerefidxVbuyy() throws IOException {
testAssignmentsBinary(new Value("pbuc1_derefidx_vbuyy"));
}
@Test
public void testAssignmentsBinaryPbuc1DerefidxVbuz1() throws IOException {
testAssignmentsBinary(new Value("pbuc1_derefidx_vbuz1"));
}
private void testAssignmentsBinary(Value lVal) throws IOException {
testFragments("fragments-assignment-binary-" + lVal.getSignature(), assignmentsBinaryBu(lVal));
}
private void testFragments(String fileName, Collection<String> signatures) throws IOException {
AsmFragmentTemplateSynthesizer.initialize("src/main/fragment/");
System.gc();
CompileLog log = new CompileLog();
int cnt = 0;
for(String signature : signatures) {
if(++cnt % 1000 == 0) System.out.println(""+cnt+"/"+signatures.size());
if(++cnt % 1000 == 0) {
System.gc();
Runtime rt = Runtime.getRuntime();
long usedMB = (rt.totalMemory() - rt.freeMemory()) / 1024 / 1024;
System.out.println(""+cnt+"/"+signatures.size() + " - "+AsmFragmentTemplateSynthesizer.getSizes()+" mem: "+usedMB );
}
List<AsmFragmentTemplate> templates =
new ArrayList<>(AsmFragmentTemplateSynthesizer.getFragmentTemplates(signature, log));
Collections.sort(templates, Comparator.comparing(AsmFragmentTemplate::getClobber));
@ -97,10 +182,8 @@ public class TestFragments {
return signatures;
}
private Collection<String> assignmentsBinaryBu() {
private Collection<String> assignmentsBinaryBu(Value lValue) {
ArrayList<String> signatures = new ArrayList<>();
Collection<Value> lVals = lValuesBu(new ArrayList<>());
for(Value lValue : lVals) {
Collection<Value> rVal1s = rValuesBu(lValue.getAllValues());
for(Value rVal1 : rVal1s) {
ArrayList<Value> used = new ArrayList<>();
@ -113,7 +196,6 @@ public class TestFragments {
}
}
}
}
return signatures;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff