Comments (5)
I'll take a look at this.
from ziria.
To help you see what is going on, arrays are allocated at the moment in two ways: (a) if they are very big OR their size is unknown at code-generation time (i.e. we are generating the code for the body of a length-polymorphic function) then they go through the wpl_alloca() path. This emulates a big stack for every function, which is finally popped all the way up (since Ziria can only return by-value, and never assign pointers -- with the caveat being that other weird bug you discovered a couple of days ago @siddhanathan :-)). However, what is happening here is that the wpl_alloca happens to be /inside/ a very large loop so before even getting the chance to deallocate memory, we run out of it. (b) if arrays are small and statically known then they are just declared locally in the current scope (but, again, we should be very careful that we don't just return their addresses when they go out of scope) . All this logic exists in CgTypes.hs which provides a lot of functionality for such things. I am not entirely sure actually that the fix is straightforward: I can think of several things: (1) execute the loop body using "inAllocFrame" which will ensure that we push/pop in every iteration -- this may be the simplest thing but introduces a slight perf penaly; i'd give this a try first. (2) Somehow hoist big allocations out of loops (seems harder as we have to inspect deeply all blocks of code, find declarations etc.).
from ziria.
(The actual test file is struct3.wpl, not struct03.wpl I think)
from ziria.
There is at least one naive fix, and that is to abuse DeclPkg
by doing the assignment during the declaration itself. So instead of DeclPkg ig [stmt]
we could have DeclPkg ig []
and do wpl_alloca
inside ig
itself.
from ziria.
Eh.... I didn't mean to link those commits here.
@dimitriv would https://github.com/siddhanathan/Ziria/commit/cd3a61d57b963fc8af15f0e86f62b27c09e103ec work? It essentially does the wpl_alloca at the declaration scope, ensuring that the wpl_alloca doesn't happen inside a loop. I know all tests pass. I tried other variations including pushing/popping on every iteration, and they either have bad performance or cause tests to fail.
from ziria.
Related Issues (20)
- Memory allocation bug HOT 1
- Negating complex16 should either be banned or implementing
- noloc location information in bound checks HOT 6
- Ziria produces code with too much nesting that fails C compilation
- Add support for unsigned ints HOT 1
- Identifiers with ' (single quotes) parse but generate illegal C HOT 2
- Static analyzer fails with a weird error
- Issues in /doc/UserGuide/language
- Error message when writing (incorrectly) "var x : int = y". HOT 6
- Long arrays in structs take lot of time to compile in Ziria/VS
- Smarter array initialization is neede
- Incorrect variable naming
- Backend test fail with --no-fold HOT 8
- blink_copy undefined behavior HOT 3
- LUT generation bug HOT 8
- LUT generation HOT 1
- Inlining bug HOT 3
- Bug when taking large arrays from input
- Indexing multi-dimensional arrays
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ziria.