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

Sync to internal development branch of October 2022 #34

Merged
merged 64 commits into from
Oct 3, 2022
Merged

Conversation

WheretIB
Copy link
Owner

@WheretIB WheretIB commented Oct 3, 2022

Language improvements and changes:

  • Fixed precision of double number literals Precision lost with double numbers #33
  • Default argument values defined in the prototype of a function are available after the body of a function is defined
  • Fixed closure of the variable defined inside 'if' condition
  • operator definitions in local blocks are no longer visible inside generic functions that are defined in outer scope/imported modules

Library improvements:

  • Fixed vector:sort for containers of pointers
  • Added strlen and strcpy to std.string module for work with null-terminated character arrays
  • Fixed issues with string class in std.string module
  • Added string ordering operators <, <=, >, >= to std.string module
  • Fixed return value of strcmp in std.string module on some platforms
  • Added is_derived_from function On branch jan-2021-wip missing NULLC::IsDerivedFromBase #29

Code generation improvements:

  • Fixed rare issue when 'phi' merge instruction had different values coming from empty basic blocks
  • Global alloca temporaries can be removed by load-store propagation even when they are in global scope

Runtime improvements:

  • Fixed GC skipping the last 4 byte object with pointers (possible on 32 bit targets) at the end of a memory block

API changes:

  • Removed support for NULLC_AUTOBINDING feature that allowed calling external C functions by automatically finding them in the current running binary (using dlsym/GetProcAddress).
    This feature was disabled by default before in CMake builds, but not in Makefile/VS builds.
    As a replacement, nullcSetMissingFunctionLookup can be used to setup a callback for missing functions and do the same thing manually.

Other changes:

  • Build time statistics tracking
  • Big improvements to build time of large multi-module nullc projects
  • Added support for additional import paths in nullcl -c/-x options
  • Made it easier to use translation to C++ in nullcl
  • Fixed missing math library link when nullcl -x is used nullcl -x fail on linux #28
  • Added C++ bindings for std.memory module translation to C++

Instead of swapping pointers in an array of pointers, content of the pointer was swapped instead
Timing functions are required by compiler time statistics, but without execution environment they will return 0
…scope can have its own lookup table

Restoring an old scope now just changes the scope pointer and records a lookup location to hide entities defined after that points.
'unrestricted' scope flag allows new scopes in generic instantiation to lookup variables without location filtering (location filter points to the beginning of the function/type definition and we will to lookup variables defined after that)
Shadowing arrays are no longer required.
Entities defined in type and namespace scope are visible through top-level scope instead of a nested scope (so functions of local types still require a clean-up like before)

Small behavior change, entities in scopes in top-level space behave like local scopes.
Top-level scope is removed without lookup table clean-up.
Generic instantiation overhead has been lowered to almost nothing.
…n is defined without default arguments

Default arguments cannot be changed/repeated
Class types will store a map of all their methods, now we can lookup only specific functions and traverse the base classes directly
Do not check type map for types that are never placed there
Load type name only for class types (other types will generate type name)
Clear array with a memset
…ed previously

Stopped invalidating the lookup map for assignment on function removal since they are not precise and wont create false lookup results
…haracter arrays

Fixed unsafe operations in low-level string functions
WheretIB and others added 23 commits January 25, 2021 11:59
'nullcSetMissingFunctionLookup' is provided as a replacement.
libdl is no longer required.
Also output total instruction count at the end of a test run.
Also add protections against null pointers.
@WheretIB WheretIB merged commit 8bbcdb0 into master Oct 3, 2022
@mingodad
Copy link
Contributor

mingodad commented Oct 3, 2022

I'm just building this branch to test it and I can see that there is still several warnings like:

NULLC/DenseMap.h:380:9: warning: ‘void* memset(void*, int, size_t)’ clearing an object of non-trivial type ‘struct DirectChainedMap<FunctionData*>::Node’; use assignment or value-initialization instead [-Wclass-memaccess]
  380 |   memset(data, 0, sizeof(Node) * bucketCount);
      |   ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
NULLC/DenseMap.h:331:9: note: ‘struct DirectChainedMap<FunctionData*>::Node’ declared here
  331 |  struct Node
      |         ^~~~

That on my fork I tried to fix then by wrapping memset see here https://github.com/mingodad/nullc/blob/a2db7962723040bdca581aabf9a92f1da652eacc/NULLC/stdafx.h#L38 :

#ifdef NO_MEMSET_WRAPPER
#define NULLC_no_warning_memset(dest, ch, sz) memset(dest, ch, sz)
#define NULLC_no_warning_memcpy(dest, src, sz) memcpy(dest, src, sz)
#else
inline void NULLC_no_warning_memset(void *dest, int ch, size_t sz) {memset(dest, ch, sz);}
inline void NULLC_no_warning_memcpy(void *dest, void *src, size_t sz) {memcpy(dest, src, sz);}
#endif

This way we have less compiler warnings to distract our attention.

@mingodad
Copy link
Contributor

mingodad commented Oct 3, 2022

Also this easy to fix problem #28 has not been fixed.

@WheretIB
Copy link
Owner Author

WheretIB commented Oct 3, 2022

Also this easy to fix problem #28 has not been fixed.

Maybe it's not that easy.
I added the link argument here https://github.com/WheretIB/nullc/pull/34/files#diff-bf6c304578d0e149c4a16a0412871c436f997dbdd0ee53038d2c9cc0c60a74e4R221-R223
I'll test translation build on Unix again later.

@WheretIB
Copy link
Owner Author

WheretIB commented Oct 3, 2022

I'm just building this branch to test it and I can see that there is still several warnings like:

I'll check your PR with a fix for this.

@mingodad
Copy link
Contributor

mingodad commented Oct 3, 2022

Looking through it and seeing NULLC::SafeSprintf(pos, 1024 - unsigned(pos - cmdLine), " -lstdc++ -lm"); I forgot to mention that somehow I managed to build this project without depending/linkding(dynamically) to libstc++ adding this functions here https://github.com/mingodad/nullc/blob/a2db7962723040bdca581aabf9a92f1da652eacc/NULLC/stdafx.cpp#L82 :

nullc-dad/bin$ ldd nullc_exec 
	linux-vdso.so.1 (0x00007ffd4cdca000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2733e81000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2733ae3000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f27336f2000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f273449b000)

nullc-dad/bin$ ldd nullcl 
	linux-vdso.so.1 (0x00007fff1d9fc000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fe995f7f000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fe995b8e000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fe996688000)

Original nullc:

nullc/bin$ ldd nullc_exec 
	linux-vdso.so.1 (0x00007ffc6c7a0000)
	libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5f46183000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5f45d76000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5f459d8000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5f457c0000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5f453cf000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f5f4679e000)

nullc/bin$ ldd nullcl 
	linux-vdso.so.1 (0x00007ffd441d6000)
	libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007fd9a4373000)
	libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fd9a3fd5000)
	libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fd9a3dbd000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fd9a39cc000)
	/lib64/ld-linux-x86-64.so.2 (0x00007fd9a4aed000)

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

Successfully merging this pull request may close these issues.

2 participants