Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

foamAudit #29

Open
pbroadbery opened this issue Jul 27, 2013 · 4 comments
Open

foamAudit #29

pbroadbery opened this issue Jul 27, 2013 · 4 comments

Comments

@pbroadbery
Copy link
Member

The compiler -Waudit option does a small amount of checking on foam being emitted by the compiler. It should be on by default in all builds, assuming compile time isn't an issue.

There's a couple of steps to get it working:

  1. If it fails, the compile should fail. Otherwise, what's the point?
  2. Fix current issues
  3. Fix false positives, eg returning a record
@pippijn
Copy link
Collaborator

pippijn commented Jul 27, 2013

In my builds, -Waudit is always on, and I agree. Also, I think foamAudit takes such little time that compile time will never be an issue. I don't notice a difference.

@pbroadbery
Copy link
Member Author

OK, this is 80% done, but there's a bit of a type shaped hole at the moment.

To explain, the FOAM generated by the compiler does not conform to the type rules in foam.c (they can be enabled optionally, but you'll get errors).

Most of the time, we're fine, as almost all real types are represented as FOAM_Word, it's only when FOAM_Rec or FOAM_Clos comes into the picture we get into trouble. Consider a domain List(Record(x:T)); at the moment, Record(x: T) is represented as type FOAM_Rec, while all the exports of List will assume that the type is FOAM_Word. So any function on the List(Record()) type will fail the type rules.

I suspect that the fix is to treat maps and records specially when deciding what interface type they have;
Maps should always be implemented as (FOAM_Word,...) --> (FOAM_Word, ...), and values cast to implementation types in the caller.
Records should always use FOAM_Word as content for similar reasons.

Unfortunately adding this will confuse the inliner, as the additional casts might not be removed, and it will need fixing. Similarly of_retype will also need some attention (it is mostly about casting)

@pippijn
Copy link
Collaborator

pippijn commented Aug 25, 2013

Perhaps making the audit a post-condition for FOAM construction and setter functions would be a good idea. That way, bugs in genfoam or optimiser can be caught right where they happen. Also, it would mean that every FOAM value constructed by these functions is always valid.

@pbroadbery
Copy link
Member Author

In principle, yes. There's a few places where we create variables with
negative indices, and similar not-quite-compliant stuff though.

The other problem is that local/lex checking would need to be disabled, or
some kind of scope added to the check.

Peter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants