Coder Social home page Coder Social logo

Comments (4)

pavelkryukov avatar pavelkryukov commented on June 16, 2024

there is absolutely no guarantee, that they won't throw

Could you please prove your statement?
Up to my knowledge, correct input is guaranteed by our unit tests suite.

Why are we using it?

This method is a GPROF bottleneck, so we remove exception handling code to optimize more aggressively.

from mipt-mips.

graudtv avatar graudtv commented on June 16, 2024

This will fail to compile:

        auto is_in_RF( const Instr& instr, size_t src_index) const noexcept
        {
            static_assert(noexcept(instr.get_src( src_index)), "instr.get_src( src_index) may throw");
            const auto reg_num = instr.get_src( src_index);
            return get_entry( reg_num).current_stage.is_in_RF();
        }

And this too

    void RegisterStage::inc() noexcept
    {
        static_assert(noexcept(value + 1_lt), "Latency::operator +() is not noexcept too");
        value = value + 1_lt;
    }

So we are relying on some implicit thoughts about operations behaviour

from mipt-mips.

pavelkryukov avatar pavelkryukov commented on June 16, 2024

I don't get it. Why should we add these static assertions?

We are relying on some implicit thoughts about operations behaviour

These thoughts are explicit, since they are defined in unit tests.
Please correct me if I'm wrong.

I suspect you are trying to sell me "defensive programming" paradigm, where each function or procedure assumes the inputs may be incorrect.
MIPT-V does not use it. Instead, we prove there are no chances to generate these incorrect inputs.

from mipt-mips.

graudtv avatar graudtv commented on June 16, 2024

Ok, I understood, thanks for answer

from mipt-mips.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.