Comment #1 on issue 1911 by [email protected]: Remove duplicate code from platform-*.cc files
http://code.google.com/p/v8/issues/detail?id=1911

Just a general remark here: IMHO the right way to fix the current platform mess is to move away from spreading platform-specific #ifdefs all over our code, and replace those by feature-specific #ifdefs, which are in turn #defined at a central place. This is a tried and tested way of handling platform dependencies, e.g. autotools is doing this for decades now. Our way (anybody remembering xmkmf?) doesn't really scale and is very hard to maintain. Try e.g. adding cygwin builds using -mno-cygwin or pure MinGW/MSYS build to our system, and your eyes will bleed from the resulting #ifdefs. ;-)

To make this more concrete, consider e.g. virtual memory: The right way to handle this is to use something along the lines of:

Address* GetMeLotsOfVirtualMemory(size_t how_much) {
#if HAVE_MMAP
  {use mmap() here }
#elif HAVE_VIRTUALALLOC
  { use VirtualAlloc here }
#elif ...
#endif
}

You can then #define these HAVE_FOO macros at a central place (this is what 'configure' would do for you in autotools), depending on platform #ifdefs. High readability, no code duplication, easy addition of the n-th BSD variant, etc. etc.

I don't propose to change this completely at once, I just wanted to give a hint where we should be striving for IMHO. We can do this incrementally per-feature.

--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to