mirror of
https://github.com/arnaucube/circom.git
synced 2026-02-06 18:56:40 +01:00
log buildC
This commit is contained in:
12
src/build.js
12
src/build.js
@@ -37,15 +37,22 @@ function build(ctx) {
|
|||||||
ctx.addConstant(ctx.F.zero);
|
ctx.addConstant(ctx.F.zero);
|
||||||
ctx.addConstant(ctx.F.one);
|
ctx.addConstant(ctx.F.one);
|
||||||
|
|
||||||
|
if (ctx.verbose) console.log("buildHeader...");
|
||||||
buildHeader(ctx);
|
buildHeader(ctx);
|
||||||
|
if (ctx.verbose) console.log("buildEntryTables...");
|
||||||
buildEntryTables(ctx);
|
buildEntryTables(ctx);
|
||||||
ctx.globalNames = ctx.uniqueNames;
|
ctx.globalNames = ctx.uniqueNames;
|
||||||
|
|
||||||
|
if (ctx.verbose) console.log("buildCode...");
|
||||||
buildCode(ctx);
|
buildCode(ctx);
|
||||||
|
|
||||||
|
if (ctx.verbose) console.log("buildComponentsArray...");
|
||||||
buildComponentsArray(ctx);
|
buildComponentsArray(ctx);
|
||||||
|
|
||||||
|
if (ctx.verbose) console.log("buildMapIsInput...");
|
||||||
buildMapIsInput(ctx);
|
buildMapIsInput(ctx);
|
||||||
|
|
||||||
|
if (ctx.verbose) console.log("buildWit2Sig...");
|
||||||
buildWit2Sig(ctx);
|
buildWit2Sig(ctx);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,6 +63,7 @@ function buildEntryTables(ctx) {
|
|||||||
const codes_componentEntries = [];
|
const codes_componentEntries = [];
|
||||||
const definedHashMaps = {};
|
const definedHashMaps = {};
|
||||||
for (let i=0; i<ctx.components.length; i++) {
|
for (let i=0; i<ctx.components.length; i++) {
|
||||||
|
if (ctx.verbose && (i%1000 ==0)) console.log(`buildEntryTables component: ${i}/${ctx.components.length}`);
|
||||||
const {htName, htMap} = addHashTable(i);
|
const {htName, htMap} = addHashTable(i);
|
||||||
|
|
||||||
let code = "";
|
let code = "";
|
||||||
@@ -131,6 +139,7 @@ function buildCode(ctx) {
|
|||||||
|
|
||||||
const fnComponents = [];
|
const fnComponents = [];
|
||||||
for (let i=0; i<ctx.components.length; i++) {
|
for (let i=0; i<ctx.components.length; i++) {
|
||||||
|
if (ctx.verbose && (i%1000 ==0)) console.log(`buildCode component: ${i}/${ctx.components.length}`);
|
||||||
const {h, instanceDef} = hashComponentCall(ctx, i);
|
const {h, instanceDef} = hashComponentCall(ctx, i);
|
||||||
const fName = ctx.components[i].template+"_"+h;
|
const fName = ctx.components[i].template+"_"+h;
|
||||||
if (!fDefined[fName]) {
|
if (!fDefined[fName]) {
|
||||||
@@ -180,6 +189,7 @@ function buildCode(ctx) {
|
|||||||
|
|
||||||
function buildComponentsArray(ctx) {
|
function buildComponentsArray(ctx) {
|
||||||
for (let i=0; i< ctx.components.length; i++) {
|
for (let i=0; i< ctx.components.length; i++) {
|
||||||
|
if (ctx.verbose && (i%10000 ==0)) console.log(`buildComponentsArray component: ${i}/${ctx.components.length}`);
|
||||||
let newThread;
|
let newThread;
|
||||||
if (ctx.newThreadTemplates) {
|
if (ctx.newThreadTemplates) {
|
||||||
if (ctx.newThreadTemplates.test(ctx.components[i].template)) {
|
if (ctx.newThreadTemplates.test(ctx.components[i].template)) {
|
||||||
@@ -217,6 +227,7 @@ function buildMapIsInput(ctx) {
|
|||||||
let map = [];
|
let map = [];
|
||||||
let acc = 0;
|
let acc = 0;
|
||||||
for (i=0; i<ctx.signals.length; i++) {
|
for (i=0; i<ctx.signals.length; i++) {
|
||||||
|
if (ctx.verbose && (i%100000 ==0)) console.log(`buildMapIsInput signal: ${i}/${ctx.signals.length}`);
|
||||||
if (ctx.signals[i].o & ctx.IN) {
|
if (ctx.signals[i].o & ctx.IN) {
|
||||||
acc = acc | (1 << (i%32) );
|
acc = acc | (1 << (i%32) );
|
||||||
}
|
}
|
||||||
@@ -243,6 +254,7 @@ function buildWit2Sig(ctx) {
|
|||||||
ctx.totals[ctx.stINTERNAL];
|
ctx.totals[ctx.stINTERNAL];
|
||||||
const arr = Array(NVars);
|
const arr = Array(NVars);
|
||||||
for (let i=0; i<ctx.signals.length; i++) {
|
for (let i=0; i<ctx.signals.length; i++) {
|
||||||
|
if (ctx.verbose && (i%100000 ==0)) console.log(`buildWit2Sig signal: ${i}/${ctx.signals.length}`);
|
||||||
const outIdx = ctx.signals[i].id;
|
const outIdx = ctx.signals[i].id;
|
||||||
if (ctx.signals[i].e>=0) continue; // If has an alias, continue..
|
if (ctx.signals[i].e>=0) continue; // If has an alias, continue..
|
||||||
assert(typeof outIdx != "undefined", `Signal ${i} does not have index`);
|
assert(typeof outIdx != "undefined", `Signal ${i} does not have index`);
|
||||||
|
|||||||
@@ -119,6 +119,16 @@ async function compile(srcFile, options) {
|
|||||||
throw(ctx.error);
|
throw(ctx.error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options.r1csFileName) {
|
||||||
|
measures.generateR1cs = -performance.now();
|
||||||
|
await buildR1cs(ctx, options.r1csFileName);
|
||||||
|
measures.generateR1cs += performance.now();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ctx.error) throw(ctx.error);
|
||||||
|
|
||||||
|
delete ctx.constraints; // Liberate memory.
|
||||||
|
|
||||||
if (options.cSourceWriteStream) {
|
if (options.cSourceWriteStream) {
|
||||||
if (ctx.verbose) console.log("Generating c...");
|
if (ctx.verbose) console.log("Generating c...");
|
||||||
measures.generateC = -performance.now();
|
measures.generateC = -performance.now();
|
||||||
@@ -131,6 +141,8 @@ async function compile(srcFile, options) {
|
|||||||
// await new Promise(fulfill => options.cSourceWriteStream.on("finish", fulfill));
|
// await new Promise(fulfill => options.cSourceWriteStream.on("finish", fulfill));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ctx.error) throw(ctx.error);
|
||||||
|
|
||||||
if ((options.wasmWriteStream)||(options.watWriteStream)) {
|
if ((options.wasmWriteStream)||(options.watWriteStream)) {
|
||||||
if (ctx.verbose) console.log("Generating wasm...");
|
if (ctx.verbose) console.log("Generating wasm...");
|
||||||
measures.generateWasm = -performance.now();
|
measures.generateWasm = -performance.now();
|
||||||
@@ -152,12 +164,6 @@ async function compile(srcFile, options) {
|
|||||||
// const mainCode = gen(ctx,ast);
|
// const mainCode = gen(ctx,ast);
|
||||||
if (ctx.error) throw(ctx.error);
|
if (ctx.error) throw(ctx.error);
|
||||||
|
|
||||||
if (options.r1csFileName) {
|
|
||||||
measures.generateR1cs = -performance.now();
|
|
||||||
await buildR1cs(ctx, options.r1csFileName);
|
|
||||||
measures.generateR1cs += performance.now();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options.symWriteStream) {
|
if (options.symWriteStream) {
|
||||||
measures.generateSyms = -performance.now();
|
measures.generateSyms = -performance.now();
|
||||||
const rdStream = buildSyms(ctx);
|
const rdStream = buildSyms(ctx);
|
||||||
|
|||||||
Reference in New Issue
Block a user