Skip to content
/ papers Public

Papers & proposals, for C++ programming language, Microsoft Windows OS, and other

Notifications You must be signed in to change notification settings

tringi/papers

Repository files navigation

Windows OS improvement recipes

  • DWM: ClearType on composited/translucent surfaces
    Defer text rendering to be done by DWM at composition time.
    DwmSetDeferredText (HWND, LONG_PTR, RECT, HFONT, ..., LPCWSTR text, int cch);

  • Win32 API: Support (w)string_view in place of LPCWSTR
    Tagged pointer to wstring_view in place of LPCWSTR parameter, unwrapped internally directly into UNICODE_STRING that NT APIs consume.

  • Start Menu: Uninstall command for Win32
    Introduce extended IShellLink2 to embed uninstaller path or uninstall registry key into .lnk file so that Start Menu can directly run it, and bring consistency with Store/Moden apps

  • Add current thread's NUMA node number to TEB to improve performance of fast allocators and caches.
    Updated on context switch. It will reduce to a single mov the following routine, which contains extra syscall and an expensive loop inside GetNumaProcessorNodeEx:

    USHORT GetCurrentProcessorNumaNode () {
        USHORT numa;
        PROCESSOR_NUMBER processor;
        GetCurrentProcessorNumberEx (&processor);
        GetNumaProcessorNodeEx (&processor, &numa);
        return numa;
    }
  • SetThreadExecutionState (..., ES_DISPLAY_REQUIRED) should apply only to thread's Desktop.
    This will prevent browser playing a video on a locked computer (e.g. user is listening to music) from keeping the screens on, when there's nothing of value being displayed.

  • DeleteMultipleFiles API to request deletion of more than single file with one syscall to improve deletion performance of large directories.

C++ papers & proposals

  • C++ Destructive Move - quick and dirty proposal draft

    struct A {
        ~A (A & a) noexcept { ... }
        ~A () noexcept -> A { return A{ ... }; }
    };
  • Fast x86-64 calling convention for C++ Work In Progress
    Fully utilize registers, pack smaller structures, spill larger structures. Keep current ABI when interfacing the OS.
    Calling convention for modern era.

  • Fix regular comparison operators for intrinsic types of distinct signedness
    ...now that chained comparisons are getting fixed.

    bool operator < (signed int a, unsigned int b) noexcept {
        if (a < 0)
            return true;
        if (b > INT_MAX)
            return true;
    
        return unsigned (a) < b;
    }

C++ Syntactic sugar

  • Function-return-statement (akin to function-try-block)
    In function definition, where function body would normally begin, or where try statement could appear, an immediate return can now appear too.

    int fma (int a, int b, int c)
        return a * b + c;
  • const and volatile implies auto
    While it might appear ambiguous, as a and b can be existing types, those being immediatelly followed by = disambiguates the parse.

    const a = 1; // same as: const auto a = 1;
    volatile b = 2.0; // same as: volatile auto b = 2.0
  • Named break/continue
    New control transfer statements are introduced, break for; and break switch; that can be used to transfer control out of nearest for or switch statements from within nested constructions.

    for (...) {
        switch (...) {
            case X:
                break for;
            case Y:
                for (...) {
                    if (...)
                        break switch;
                }
        }
    }
  • goto case/default
    Within a switch statement, a goto case X; or goto default; can be used to transfer control to appropriate case or default label belonging to that switch.

    switch (x) {
        case 0:
            func0 ();
            goto case 2;
        case 1:
            func1 ();
            goto default;
        case 2:
            func2 ();
            break;
        default:
            func_default ();
    }

    Undecided: Should goto case/default to a missing case label be treated as error or evaluated? If evaluated, should non-static data, e.g. goto case a * 2 + 1; be allowed?

Superseded ideas

  • Argument dependent lookup for scoped enumerations
    Superseded by Using-enum-declaration
    If an argument cannot be found, relevant enum scope is searched too, enabling one to write:

    enum class color {
        red,
        green,
        blue,
    };
    int function (color c);
    
    // ...
    
    function (red); // color::red
    
    color green = blue; // color::blue
    function (green); // local variables still have priority

x86 ISA Extensions proposals

  • LOCK BSFR BSF (Bit Scan Forward) and Reset.
    The same operation as BSF with addition of clearing the found set bit. Viola, lock-free bitmap allocator with a single instruction. BSRR optional.
    It seems like a sensible addition to complete the BTS, BTR, BTC set.

  • vpccintersectps rax, ymm0, ymm1
    Would set RAX to distance (squared?) of envelopes of two circles. Each YMM register would contain X,Y,Z and Radius. If RAX <= 0 then circles intersect, otherwise RAX is their distance (squared?).

About

Papers & proposals, for C++ programming language, Microsoft Windows OS, and other

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published