windows garbagecollector, fix gcc -O2

This commit is contained in:
Mister Hat 2021-07-18 12:16:31 -05:00
parent 7930426393
commit ea97265d0a
12 changed files with 5596 additions and 5 deletions

View File

@ -3,10 +3,11 @@ java -jar ./JCGO/jcgo.jar mudclient -src ./mudclient204-headless \
patch -p0 -i sdl.diff
x86_64-w64-mingw32-gcc -g -I ./JCGO/include -I ./JCGO/native \
-I ./JCGO/include/boehmgc -I ./SDL2-2.0.14/x86_64-w64-mingw32/include \
-DJCGO_NOGC -DJCGO_USEGCJ -DJCGO_FPFAST -DJCGO_FASTMATH -DJCGO_INET \
x86_64-w64-mingw32-gcc -O2 -I ./JCGO/include -I ./JCGO/native \
-I ./JCGO/include/tinygc -I ./SDL2-2.0.14/x86_64-w64-mingw32/include \
-fno-strict-aliasing \
-DGC_THREADS -DJCGO_USEGCJ -DJCGO_FPFAST -DJCGO_FASTMATH -DJCGO_INET \
-DJCGO_INTFIT -DJCGO_THREADS -D_IEEEFP_H -DJCGO_WIN32 \
-o mudclient.exe jcgo_Out/Main.c -lm \
-L ./SDL2-2.0.14/x86_64-w64-mingw32/lib -lSDL2 -lwsock32 \
./JCGO/libs/amd64/mingw64/libgcmt.a -no-pie
./tinygc-tinygc-2_6/tinygcmt.o -no-pie

View File

@ -5,7 +5,8 @@ patch -p0 -i sdl.diff
#-DJCGO_PARALLEL
#-DJCGO_NOGJ
gcc -g -I ./JCGO/include -I ./JCGO/native -I ./JCGO/include/boehmgc \
gcc -O2 -I ./JCGO/include -I ./JCGO/native -I ./JCGO/include/boehmgc \
-fno-strict-aliasing \
-DJCGO_USEGCJ -DJCGO_FPFAST -DJCGO_FASTMATH -DJCGO_INET \
-DJCGO_INTFIT -DJCGO_THREADS -DJCGO_UNIX -D_IEEEFP_H -DJCGO_UNIFSYS \
-o mudclient jcgo_Out/Main.c -lm -lpthread -lSDL2 \

40
tinygc-tinygc-2_6/ChangeLog Executable file
View File

@ -0,0 +1,40 @@
[2.6 release]
2010-12-04 Ivan Maidanski <ivmai@mail.ru>
* htdocs/index.html: Update (according to the changes in README).
* README.txt: Update "Tuning macros" section (add GC_THREADS
macro description); update "Files list" section (for gc_mark.h).
* gc.h (GC_TINYGC_VER): Update the value.
* gc.h (GC_NO_THREAD_REDIRECTS, GC_allow_register_threads,
GC_register_my_thread, GC_unregister_my_thread): Declare only if
GC_THREADS.
* gc_mark.h (GC_start_callback_proc, GC_set_start_callback,
GC_get_start_callback): New API prototype.
* tinygc.c (GC_start_call_back): New static global variable.
* tinygc.c (GC_collect_unreachable): Call GC_start_call_back if
non-zero.
* tinygc.c (GC_set_start_callback, GC_get_start_callback): New API
function.
[2.5 release]
2009-12-20 Ivan Maidanski <ivmai@mail.ru>
* htdocs/index.html: New file (also put to sftp:web.sf.net/htdocs).
2009-12-20 Ivan Maidanski <ivmai@mail.ru>
* ChangeLog: New file.
* GNU_GPL.txt: New file (GNU GPLv2 license).
* tinygc.c: Set version to 2.5.
* README.txt: Ditto.
* gc.h (GC_TINYGC_VER): Ditto.
* gc_gcj.h: Initial SVN import.
* gc_mark.h: Ditto.
* javaxfc.h: Ditto.
* README.txt: Update.
Local Variables:
version-control: never
End:

340
tinygc-tinygc-2_6/GNU_GPL.txt Executable file
View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) 19yy <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

298
tinygc-tinygc-2_6/README.txt Executable file
View File

@ -0,0 +1,298 @@
TinyGC v2.6 (Tiny Garbage Collector)
------------------------------------
Copyright (C) 2006-2010 Ivan Maidanski <ivmai@mail.ru>
All rights reserved.
Project home page
-----------------
http://tinygc.sourceforge.net
Preface
-------
TinyGC is an independent implementation of the API of the well-known
Boehm-Demers-Weiser Conservative GC ("BDWGC" or "BoehmGC" for short).
TinyGC has been initially developed as a part of the JCGO project to be
used as a BoehmGC replacement. At present, TinyGC is a standalone
project.
Disclaimer/License
------------------
This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This software is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License (GPL) for more details.
You should have received a copy of the GNU General Public License
along with this software. If not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301 USA.
Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
Target environments
-------------------
TinyGC is designed to be used primary in projects requiring Java-like
memory garbage collection functionality for:
- memory constrained environments;
- 8/16-bit systems;
- BoehmGC temporal replacement (for application debugging, testing and
benchmarking purposes);
- targets where BoehmGC is still not ported to.
TinyGC is NOT designed for speed.
Design principles
-----------------
The major principles are:
- source and binary compatibility with BoehmGC;
- implements only the minimal subset of the BoehmGC API (v7.2)
sufficient for the Java/GCJ-like functionality;
- highly portable (contains no assembler, no machine/OS-specific code
portions) and tunable;
- supports 16/32/64-bit architectures ("flat" data models only);
- compact code and small initial internal data size;
- simple collection World-stopped Mark-and-Sweep algorithm
implementation;
- malloc-based allocation (i.e. every object is allocated using
malloc());
- objects finalization and memory recycling (reclaiming to the
underlaying malloc implementation) is done lazily (between
collections).
Advantages and drawbacks
------------------------
The major TinyGC advantages over BoehmGC are:
- small code size (it could be as small as 3800 bytes);
- 16-bit architectures are supported;
- small initial internal data size;
- less source code (to verify);
- minimal set of the underlaying clib/pthread/Win32 functions used.
The drawbacks of TinyGC are:
- lower allocation speed and larger world-stopped collection delays
(typically);
- only a small subset of the BoehmGC API is implemented;
- no support for C++;
- no support for architectures with a separate registers stack (like
IA-64);
- no find-leak and pointer back-trace modes;
- no automatic registration of static data roots, stack bottom and
threads;
- no "advanced" allocation and collection technologies (no
blacklisting, memory unmapping, thread-local allocation, parallel
marking, generation and incremental collections);
- relies on the underlaying malloc/free() implementation (which may be
broken for large heaps, like, e.g., in some versions of msvcrt);
- "all-interior-pointers" mode is limited by the offset of 256
(1 << GC_LOG2_OFFIGNORE) bytes (this also means that disappearing links
must not be placed at this or higher offsets of an allocated object);
- only the length-based descriptor for the GCJ-style allocation is
supported;
- only Java-like "no-order" finalization policy is implemented.
Notes
-----
Release notes:
- no binary distribution is offered on the official site;
- no make file (or other building script) is provided.
Implementation notes:
- the same environment variables are recognized as in BoehmGC;
- the finalization and disappearing links implementations are generally
the same as in BoehmGC;
- full TinyGC implementation resides in a single file (all the internal
symbols are not visible outside);
- both pthreads and Win32 threads are supported;
- no thread-safety of the underlaying malloc/free is required;
- the stack direction is detected at TinyGC initialization;
- no warnings are printed;
- the thread "suspend" handler does not use pthread synchronization
primitives (yielding and sleeping are used instead for better
portability);
- CPU state is saved by setjmp();
- there is no object "header" (i.e. the original object size is passed
to the underlaying malloc()).
Usage notes:
- all pointers must be word-aligned;
- it is assumed that the compiler performs only GC-safe pointer
transformations;
- static data roots must be manually registered;
- application threads must be manually registered and unregistered;
- it would be good to use GC_call_with_gc_active() to record the
correct main stack base (after GC_INIT()).
Tuning macros
-------------
Useful macros for tuning (same as in BoehmGC):
- GC_DLL - compile to produce a DLL (gc.dll);
- ALL_INTERIOR_POINTERS - turn on "all-interior-pointers" mode by
default;
- GC_GCJ_SUPPORT - compile with GCJ-style allocation support;
- GC_THREADS - compile with thread support (pthread-based by default);
- GC_WIN32_THREADS - compile with Win32-based thread support;
- JAVA_FINALIZATION_NOT_NEEDED - exclude GC_finalize_all() from the
API;
- DONT_ADD_BYTE_AT_END - do not pad objects even if
"all-interior-pointers" mode is on;
- FINALIZE_ON_DEMAND - causes finalizers to be run only in response to
explicit GC_invoke_finalizers() calls by default (unless overridden at
run-time);
- GC_IGNORE_GCJ_INFO - disable GCJ-style type information (useful for
debugging);
- GC_DONT_EXPAND - do not implicitly expand the heap by default (unless
overridden at run-time);
- GC_INITIAL_HEAP_SIZE=<value> - set the desired default initial heap
size (in bytes);
- GC_FREE_SPACE_DIVISOR=<value> - the default trade-off between garbage
collection and heap growth;
- GC_MAX_RETRIES=<value> - the default maximum number of garbage
collections attempted before reporting out of memory after a heap
expansion failure.
Major TinyGC-specific macros:
- GC_PRINT_MSGS - compile with statistic and error printing
capabilities;
- GC_GETENV_SKIP - do not recognize any environment variable (for
smaller code size or for WinCE targets);
- GC_WIN32_WCE - compile for WinCE (use thread Id instead of thread
handle, and retry on SuspendThread() failures);
- GC_NO_INACTIVE, GC_MISC_EXCLUDE - exclude the corresponding parts of
the TinyGC API (for smaller code size);
- GC_NO_GCBASE, GC_NO_FNLZ, GC_NO_DLINKS, GC_NO_REGISTER_DLINK -
exclude the support (i.e. expose dummy support) for the corresponding
TinyGC capabilities (for smaller code size);
- GC_USE_WIN32_SYSTEMTIME - use Win32 GetSystemTime() API call instead
of ftime() or gettimeofday() ones (useful for WinCE);
- GC_USE_GETTIMEOFDAY - use Unix gettimeofday() API call instead of
ftime() one;
- GC_OMIT_REGISTER_KEYWORD - ignore C "register" keyword;
- CONST=/**/ - ignore C "const" keyword;
- INLINE=/**/ - ignore C "__inline" keyword;
- GC_FASTCALL=/**/ - ignore C x86-specific "__fastcall" keyword;
- GC_CLIBDECL=/**/ - ignore C x86-specific "__cdecl" keyword;
- GC_DATASTATIC=/**/ - do not use C static storage class for global
data;
- GC_STATIC=/**/ - do not use C static linkage for GC internal
functions;
- GC_DATASTARTSYM=<id> - specify the external symbol which is the first
one in the program data section;
- GC_DATAENDSYM=<id> - specify the external symbol which is the last
one in the program data section;
- GC_DATASTARTSYM2=<id> - specify the external symbol which is the
first one in the program ".bss" section;
- GC_DATAENDSYM2=<id> - specify the external symbol which is the last
one in the program ".bss" section;
- GC_STACKBOTTOMVAR=<id> - specify the external symbol pointing to the
program main thread stack bottom (or top if GC_STACKLEN is 0);
- GC_STACKLENVAR=<id> - specify the external symbol pointing to the
program main thread stack size;
- GC_SIG_SUSPEND=<sig_id> - use specific signal to suspend Posix
threads;
- GC_WIN32_CONTEXT_SP_NAME=<sp_id> - use specific stack pointer
register name (defined in Win32 "winnt.h");
- GC_LOG2_OFFIGNORE=<value> - explicitly specify the number of address
lowest bits ignored for object address hash computations.
Useful macros for client application tuning (same as in BoehmGC):
- GC_DONT_EXPAND - do not implicitly expand the heap (unless overridden
at run-time);
- GC_DLL - use TinyGC residing in a DLL;
- GC_THREADS - declare the prototypes for the collector multi-threading
support;
- GC_CALL=<calling_conv> - explicitly specify calling convention for
the GC API functions;
- GC_CALLBACK=<calling_conv> - explicitly specify an alternate calling
convention for the GC API user callbacks;
- GC_INITIAL_HEAP_SIZE=<value> - set the desired initial heap size (in
bytes);
- GC_MAXIMUM_HEAP_SIZE=<value> - set the desired maximum heap size (in
bytes);
- GC_FREE_SPACE_DIVISOR=<value> - set the desired trade-off between
garbage collection and heap growth;
- GC_MAX_RETRIES=<value> - set the desired maximum number of garbage
collections attempted before reporting out of memory after a heap
expansion failure.
Note 1: if GC_NO_DLINKS is used without GC_NO_REGISTER_DLINK then all
the disappearing links are treated as normal pointers.
Note 2: for Unix use the command-line options:
-DGC_FASTCALL= -DGC_CLIBDECL=
Note 3: for Solaris SunOS "cc" use the command-line options:
-DGC_FASTCALL= -DGC_CLIBDECL= -DINLINE=inline
-erroff=E_WHITE_SPACE_IN_DIRECTIVE
Environment variables
---------------------
Environment variables recognized (if supported, same as in BoehmGC):
GC_DONT_GC - turn off garbage collection;
GC_PRINT_STATS - turn on statistic printing on every garbage collection
(if supported);
GC_ALL_INTERIOR_POINTERS - turn on "all-interior-pointers" collector
mode;
GC_IGNORE_GCJ_INFO - ignore the GCJ-style type descriptors (if
supported);
GC_INITIAL_HEAP_SIZE=<value> - set the initial heap size (in bytes);
GC_MAXIMUM_HEAP_SIZE=<value> - set the maximum heap size (in bytes);
GC_FREE_SPACE_DIVISOR=<value> - change the default trade-off between
garbage collection and heap growth.
Note: the values assigned to the specified environment variables
override the similar default (or the preset at the compilation time)
values.
Files list
----------
The TinyGC distribution consists of:
- ChangeLog - the standard changes log file;
- GNU_GPL.txt - the GNU GPLv2 license;
- README.txt - this file;
- gc.h - the main include file (the subset of that in BoehmGC);
- gc_gcj.h - GCJ-style allocation API (the subset of that in BoehmGC);
- gc_mark.h - contains only the constants for the GCJ-style
length-based descriptors and the collections notifier prototypes;
- javaxfc.h - same as in BoehmGC;
- tinygc.c - the TinyGC implementation itself.
User's feedback
---------------
Any questions, suggestions, bug reports and patches are welcomed at
the TinyGC site tracker (hosted at SourceForge.net).
--- [ End of File ] ---

325
tinygc-tinygc-2_6/gc.h Executable file
View File

@ -0,0 +1,325 @@
/*
* @(#) gc.h -- TinyGC (Tiny Garbage Collector) header.
* Copyright (C) 2006-2010 Ivan Maidanski <ivmai@mail.ru> All rights reserved.
**
* Version: 2.6
* See also files: tinygc.c, gc_gcj.h, gc_mark.h, javaxfc.h
* Required: any ANSI C compiler (assume GC-safe compilation).
*/
/*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
**
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License (GPL) for more details.
**
* Linking this library statically or dynamically with other modules is
* making a combined work based on this library. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
**
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on this library. If you modify this library, you may extend
* this exception to your version of the library, but you are not
* obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef GC_H
#define GC_H
#define GC_TINYGC_VER 260 /* TinyGC v2.6 */
/* TinyGC API is a subset of Boehm-Demers-Weiser Conservative GC API v7.2 */
/*
* Control macros: GC_DLL, GC_DONT_EXPAND, GC_STACKBASE_WITH_REGBASE,
* GC_THREADS.
* Macros for tuning: CONST, GC_API, GC_CALL, GC_CALLBACK, GC_DATASTART,
* GC_DATASTART2, GC_DATASTARTSYM, GC_DATASTARTSYM2, GC_DATAEND, GC_DATAEND2,
* GC_DATAENDSYM, GC_DATAENDSYM2, GC_FREE_SPACE_DIVISOR, GC_INITIAL_HEAP_SIZE,
* GC_MAXIMUM_HEAP_SIZE, GC_MAX_RETRIES, GC_NEAR, GC_SIGNEDWORD.
*/
#ifndef _STDDEF_H
#include <stddef.h>
/* typedef size_t; */
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef CONST
#define CONST const
#endif
#ifndef GC_API
#ifdef GC_DLL
#define GC_API __declspec(dllimport)
#else
#define GC_API extern
#endif
#endif
#ifndef GC_CALL
#define GC_CALL /* empty */
#endif
#ifndef GC_CALLBACK
#define GC_CALLBACK GC_CALL
#endif
#ifndef GC_NEAR
/* TinyGC-specific */
#define GC_NEAR /* empty */
#endif
#ifndef GC_SIGNEDWORD
/* TinyGC-specific */
#ifdef _WIN64
#define GC_SIGNEDWORD __int64
#else
#ifdef _LLP64
#define GC_SIGNEDWORD long long
#else
#ifdef _LP64
#define GC_SIGNEDWORD long
#endif
#endif
#endif
#endif
#ifndef GC_STACKBASE_WITH_REGBASE
/* TinyGC-specific */
#ifdef _M_IA64
#define GC_STACKBASE_WITH_REGBASE 1
#else
#ifdef __ia64__
#define GC_STACKBASE_WITH_REGBASE 1
#endif
#endif
#endif
#ifdef GC_SIGNEDWORD
typedef unsigned GC_SIGNEDWORD GC_word;
/* sizeof(GC_word) == sizeof(void GC_NEAR *) */
#else
typedef unsigned GC_word;
#endif
#define GC_MALLOC(size) GC_malloc(size)
#define GC_MALLOC_ATOMIC(size) GC_malloc_atomic(size)
#define GC_NEW(t) ((t GC_NEAR *)GC_MALLOC(sizeof(t)))
#define GC_NEW_ATOMIC(t) ((t GC_NEAR *)GC_MALLOC_ATOMIC(sizeof(t)))
#define GC_GENERAL_REGISTER_DISAPPEARING_LINK(link, obj) GC_general_register_disappearing_link(link, obj)
#define GC_REGISTER_FINALIZER_NO_ORDER(obj, fn, client_data, ofn, odata) GC_register_finalizer_no_order(obj, fn, client_data, ofn, odata)
typedef void (GC_CALLBACK *GC_finalizer_notifier_proc)(void);
typedef int (GC_CALLBACK *GC_stop_func)(void);
typedef void (GC_CALLBACK *GC_finalization_proc)(void GC_NEAR *,
void GC_NEAR *);
typedef void (GC_CALLBACK *GC_warn_proc)(char GC_NEAR *, GC_word);
typedef void GC_NEAR *(GC_CALLBACK *GC_fn_type)(void GC_NEAR *);
GC_API GC_word GC_CALL GC_get_gc_no(void);
GC_API void GC_CALL GC_set_all_interior_pointers(int);
GC_API void GC_CALL GC_set_finalize_on_demand(int);
GC_API void GC_CALL GC_set_java_finalization(int);
GC_API void GC_CALL GC_set_dont_expand(int);
GC_API void GC_CALL GC_set_no_dls(int);
GC_API void GC_CALL GC_set_dont_precollect(int);
GC_API void GC_CALL GC_set_free_space_divisor(GC_word);
GC_API void GC_CALL GC_set_max_retries(GC_word);
GC_API void GC_CALL GC_set_finalizer_notifier(GC_finalizer_notifier_proc);
GC_API GC_finalizer_notifier_proc GC_CALL GC_get_finalizer_notifier(void);
GC_API void GC_CALL GC_init(void);
GC_API void GC_NEAR *GC_CALL GC_malloc(size_t);
GC_API void GC_NEAR *GC_CALL GC_malloc_atomic(size_t);
GC_API void GC_NEAR *GC_CALL GC_base(void GC_NEAR *);
GC_API int GC_CALL GC_expand_hp(size_t);
GC_API void GC_CALL GC_set_max_heap_size(GC_word);
GC_API void GC_CALL GC_exclude_static_roots(void GC_NEAR *, void GC_NEAR *);
GC_API void GC_CALL GC_clear_roots(void);
GC_API void GC_CALL GC_add_roots(void GC_NEAR *, void GC_NEAR *);
GC_API void GC_CALL GC_remove_roots(void GC_NEAR *, void GC_NEAR *);
GC_API void GC_CALL GC_gcollect(void);
GC_API void GC_CALL GC_gcollect_and_unmap(void);
GC_API int GC_CALL GC_try_to_collect(GC_stop_func);
GC_API void GC_CALL GC_set_stop_func(GC_stop_func);
GC_API GC_stop_func GC_CALL GC_get_stop_func(void);
GC_API size_t GC_CALL GC_get_heap_size(void);
GC_API size_t GC_CALL GC_get_free_bytes(void);
GC_API size_t GC_CALL GC_get_bytes_since_gc(void);
GC_API size_t GC_CALL GC_get_total_bytes(void);
GC_API void GC_CALL GC_disable(void);
GC_API void GC_CALL GC_enable(void);
GC_API void GC_CALL GC_enable_incremental(void);
GC_API void GC_CALL GC_register_finalizer_no_order(void GC_NEAR *,
GC_finalization_proc, void GC_NEAR *, GC_finalization_proc GC_NEAR *,
void GC_NEAR *GC_NEAR *);
#define GC_NO_MEMORY 2
GC_API int GC_CALL GC_general_register_disappearing_link(
void GC_NEAR *GC_NEAR *, void GC_NEAR *);
GC_API int GC_CALL GC_unregister_disappearing_link(void GC_NEAR *GC_NEAR *);
GC_API int GC_CALL GC_should_invoke_finalizers(void);
GC_API int GC_CALL GC_invoke_finalizers(void);
GC_API void GC_CALL GC_set_warn_proc(GC_warn_proc);
GC_API GC_warn_proc GC_CALL GC_get_warn_proc(void);
GC_API void GC_CALLBACK GC_ignore_warn_proc(char GC_NEAR *, GC_word);
GC_API void GC_NEAR *GC_CALL GC_call_with_alloc_lock(GC_fn_type,
void GC_NEAR *);
#define GC_SUCCESS 0
#define GC_DUPLICATE 1
#define GC_UNIMPLEMENTED 3
struct GC_stack_base
{
void GC_NEAR *mem_base;
#ifdef GC_STACKBASE_WITH_REGBASE
void GC_NEAR *reg_base; /* not used by TinyGC */
#endif
};
typedef void GC_NEAR *(GC_CALLBACK *GC_stack_base_func)(
struct GC_stack_base GC_NEAR *, void GC_NEAR *);
GC_API void GC_NEAR *GC_CALL GC_call_with_stack_base(GC_stack_base_func,
void GC_NEAR *);
GC_API int GC_CALL GC_get_stack_base(struct GC_stack_base GC_NEAR *);
GC_API void GC_NEAR *GC_CALL GC_do_blocking(GC_fn_type, void GC_NEAR *);
GC_API void GC_NEAR *GC_CALL GC_call_with_gc_active(GC_fn_type,
void GC_NEAR *);
#ifdef GC_THREADS
#ifndef GC_NO_THREAD_REDIRECTS
/* No "implicit thread registration" mode */
#define GC_NO_THREAD_REDIRECTS
#endif
GC_API void GC_CALL GC_allow_register_threads(void);
GC_API int GC_CALL GC_register_my_thread(
CONST struct GC_stack_base GC_NEAR *);
GC_API int GC_CALL GC_unregister_my_thread(void);
#endif
GC_API void GC_CALL GC_set_force_unmap_on_gcollect(int);
#ifdef GC_DATASTARTSYM
extern char GC_DATASTARTSYM;
#ifndef GC_DATASTART
#define GC_DATASTART ((void GC_NEAR *)&GC_DATASTARTSYM)
#endif
#endif
#ifdef GC_DATAENDSYM
extern char GC_DATAENDSYM;
#ifndef GC_DATAEND
#define GC_DATAEND ((void GC_NEAR *)&GC_DATAENDSYM)
#endif
#endif
#ifdef GC_DATASTARTSYM2
extern char GC_DATASTARTSYM2;
#ifndef GC_DATASTART2
#define GC_DATASTART2 ((void GC_NEAR *)&GC_DATASTARTSYM2)
#endif
#endif
#ifdef GC_DATAENDSYM2
extern char GC_DATAENDSYM2;
#ifndef GC_DATAEND2
#define GC_DATAEND2 ((void GC_NEAR *)&GC_DATAENDSYM2)
#endif
#endif
#ifdef GC_DATASTART
#ifndef GC_DATAEND
#define GC_DATAEND GC_DATASTART
#endif
#ifdef GC_DATASTART2
#ifndef GC_DATAEND2
#define GC_DATAEND2 GC_DATASTART2
#endif
#define GC_INIT_CONF_ROOTS (GC_add_roots(GC_DATASTART, GC_DATAEND), GC_add_roots(GC_DATASTART2, GC_DATAEND2))
#else
#define GC_INIT_CONF_ROOTS GC_add_roots(GC_DATASTART, GC_DATAEND)
#endif
#else
#define GC_INIT_CONF_ROOTS /* empty */
#endif
#ifdef GC_DONT_EXPAND
#define GC_INIT_CONF_DONT_EXPAND GC_set_dont_expand(1)
#else
#define GC_INIT_CONF_DONT_EXPAND /* empty */
#endif
#ifdef GC_MAX_RETRIES
#define GC_INIT_CONF_MAX_RETRIES GC_set_max_retries(GC_MAX_RETRIES)
#else
#define GC_INIT_CONF_MAX_RETRIES /* empty */
#endif
#ifdef GC_FREE_SPACE_DIVISOR
#define GC_INIT_CONF_FREE_SPACE_DIVISOR GC_set_free_space_divisor(GC_FREE_SPACE_DIVISOR)
#else
#define GC_INIT_CONF_FREE_SPACE_DIVISOR /* empty */
#endif
#ifdef GC_MAXIMUM_HEAP_SIZE
#define GC_INIT_CONF_MAXIMUM_HEAP_SIZE GC_set_max_heap_size(GC_MAXIMUM_HEAP_SIZE)
#else
#define GC_INIT_CONF_MAXIMUM_HEAP_SIZE /* empty */
#endif
#ifdef GC_INITIAL_HEAP_SIZE
#define GC_INIT_CONF_INITIAL_HEAP_SIZE { size_t GC_heap_size; (void)((GC_heap_size = GC_get_heap_size()) < (size_t)(GC_INITIAL_HEAP_SIZE) ? GC_expand_hp((size_t)(GC_INITIAL_HEAP_SIZE) - GC_heap_size) : 0); }
#else
#define GC_INIT_CONF_INITIAL_HEAP_SIZE /* empty */
#endif
#define GC_INIT() { GC_INIT_CONF_DONT_EXPAND; GC_INIT_CONF_MAX_RETRIES; GC_INIT_CONF_FREE_SPACE_DIVISOR; GC_INIT_CONF_MAXIMUM_HEAP_SIZE; GC_init(); GC_INIT_CONF_ROOTS; GC_INIT_CONF_INITIAL_HEAP_SIZE; }
#ifdef __cplusplus
}
#endif
#endif

66
tinygc-tinygc-2_6/gc_gcj.h Executable file
View File

@ -0,0 +1,66 @@
/*
* @(#) gc_gcj.h -- TinyGC additional header (GCJ-style API).
* Copyright (C) 2006-2009 Ivan Maidanski <ivmai@mail.ru> All rights reserved.
**
* See also files: tinygc.c, gc.h, gc_mark.h, javaxfc.h
*/
/*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
**
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License (GPL) for more details.
**
* Linking this library statically or dynamically with other modules is
* making a combined work based on this library. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
**
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on this library. If you modify this library, you may extend
* this exception to your version of the library, but you are not
* obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef GC_GCJ_H
#define GC_GCJ_H
/* TinyGC API is a subset of Boehm-Demers-Weiser Conservative GC API */
#ifndef GC_H
#include "gc.h"
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#ifndef GC_NEAR
/* TinyGC-specific */
#define GC_NEAR /* empty */
#endif
#define GC_GCJ_MALLOC(size, vtable) GC_gcj_malloc(size, vtable)
GC_API void GC_CALL GC_init_gcj_malloc(int, void * /* GC_mark_proc */);
GC_API void GC_NEAR *GC_CALL GC_gcj_malloc(size_t, void GC_NEAR *);
#ifdef __cplusplus
}
#endif
#endif

64
tinygc-tinygc-2_6/gc_mark.h Executable file
View File

@ -0,0 +1,64 @@
/*
* @(#) gc_mark.h -- TinyGC additional header (explicit GC marker control).
* Copyright (C) 2006-2010 Ivan Maidanski <ivmai@mail.ru> All rights reserved.
**
* See also files: tinygc.c, gc.h, gc_gcj.h, javaxfc.h
*/
/*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
**
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License (GPL) for more details.
**
* Linking this library statically or dynamically with other modules is
* making a combined work based on this library. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
**
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on this library. If you modify this library, you may extend
* this exception to your version of the library, but you are not
* obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
#ifndef GC_MARK_H
#define GC_MARK_H
/* TinyGC API is a subset of Boehm-Demers-Weiser Conservative GC API */
#ifndef GC_H
#include "gc.h"
#endif
#ifdef __cplusplus
extern "C"
{
#endif
#define GC_DS_TAG_BITS 2
#define GC_DS_TAGS ((1 << GC_DS_TAG_BITS) - 1)
#define GC_DS_LENGTH 0
typedef void (GC_CALLBACK *GC_start_callback_proc)(void);
GC_API void GC_CALL GC_set_start_callback(GC_start_callback_proc);
GC_API GC_start_callback_proc GC_CALL GC_get_start_callback(void);
#ifdef __cplusplus
}
#endif
#endif

View File

@ -0,0 +1,473 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML lang=en-us>
<HEAD>
<META http-equiv="content-type" content="text/html; charset=iso-8859-1">
<META http-equiv="content-language" content="en-us">
<meta name="google-site-verification" content="euF_Ds6ls67K5HQAK1QLmLN-9T0UpvF2SdDOK_qBUIs" />
<TITLE>TinyGC - Tiny Garbage Collector</TITLE>
<LINK rev=made href="mailto:ivmai@mail.ru">
<META name="author" content="Ivan Maidanski">
<STYLE type="text/css"><!--
HTML {
font-size: 100%;
}
BODY {
margin: 0.8em;
font-family: helvetica, sans-serif;
color: black;
background: #eff;
}
H1 {
clear: both;
margin-top: 0.8em;
text-align: center;
word-spacing: 0.3em;
font-weight: bold;
text-decoration: underline;
}
H3 {
clear: both;
text-align: left;
margin-left: 0.3em;
margin-bottom: 0.1em;
}
P {
text-align: justify;
text-indent: 1.3em;
margin-top: 0.2em;
margin-bottom: 0;
}
OL, UL {
text-align: left;
text-indent: 1.1em;
margin: 0;
list-style-position: inside;
padding: 0;
}
ACRONYM {
font-weight: bolder;
white-space: nowrap;
}
CODE {
font-family: monospace;
font-size: 130%;
}
PRE {
padding: 0;
margin: 0 0 0.7em 1.3em;
}
A:link { color: blue; }
A:visited { color: purple; }
A:hover { color: red; }
A:active { color: green; }
A {
white-space: nowrap;
}
A.external { }
A.mailto {
color: teal;
font-style: oblique;
}
DIV {
min-width: 35em;
margin-top: 1em;
}
DIV.subsection {
margin-bottom: 0.9em;
}
DIV.download {
margin-bottom: 0.9em;
border-top: 1pt dashed blue;
}
DIV.license {
border-top: thin solid blue;
text-align: center;
font-size: 110%;
font-family: monospace;
}
DIV.page-footer {
border-top: thin solid blue;
margin-top: 1.2em;
text-align: center;
}
.copyright {
text-align: right;
white-space: nowrap;
font-size: x-small;
font-weight: lighter;
}
--></STYLE>
</HEAD>
<BODY>
<A href="http://sourceforge.net/projects/tinygc/">
<IMG src="http://sflogo.sourceforge.net/sflogo.php?group_id=294566&type=14"
alt="get TinyGC at SourceForge.net" width=150 height=40 border=0></A>
<H1 align=center>TinyGC</H1>
<DIV class=subsection>
<H3>Preface</H3>
<P>TinyGC is an independent implementation of the API of the well-known
Boehm-Demers-Weiser Conservative GC ("BDWGC" or "BoehmGC" for short).
<P>TinyGC has been initially developed as a part of the JCGO project to be
used as a BoehmGC replacement. At present, TinyGC is a standalone project.
</DIV>
<DIV class=download>
<H3>Download</H3>
<P>To get the latest <ACRONYM>TinyGC</ACRONYM> stable release source code,
please visit
<A href="http://sourceforge.net/projects/tinygc/files/">"Browse files for
TinyGC"</A>.
</DIV>
<DIV class=subsection>
<H3>Target environments</H3>
<P><ACRONYM>TinyGC</ACRONYM> is designed to be used primary in projects
requiring Java-like memory garbage collection functionality for:
<UL>
<LI>memory constrained environments;
<LI>8/16-bit systems;
<LI>BoehmGC temporal replacement (for application debugging, testing and
benchmarking purposes);
<LI>targets where <ACRONYM>BoehmGC</ACRONYM> is still not ported to.
</UL>
<P><ACRONYM>TinyGC</ACRONYM> is NOT designed for speed.
</DIV>
<DIV class=subsection>
<H3>Design principles</H3>
<P>The major principles are:
<UL>
<LI>source and binary compatibility with <ACRONYM>BoehmGC</ACRONYM>;
<LI>implements only the minimal subset of the <ACRONYM>BoehmGC</ACRONYM>
<ACRONYM>API</ACRONYM> (v7.2) sufficient for the
Java/<ACRONYM>GCJ</ACRONYM>-like functionality;
<LI>highly portable (contains no assembler, no
machine/<ACRONYM>OS</ACRONYM>-specific code portions) and tunable;
<LI>supports 16/32/64-bit architectures ("flat" data models only);
<LI>compact code and small initial internal data size;
<LI>simple collection World-stopped Mark-and-Sweep algorithm implementation;
<LI>malloc-based allocation (i.e. every object is allocated using
<CODE>malloc()</CODE>);
<LI>objects finalization and memory recycling (reclaiming to the underlaying
malloc implementation) is done lazily (between collections).
</UL></DIV>
<DIV class=subsection>
<H3>Advantages and drawbacks</H3>
<P>The major <ACRONYM>TinyGC</ACRONYM> advantages over
<ACRONYM>BoehmGC</ACRONYM> are:
<UL>
<LI>small code size (it could be as small as 3800 bytes);
<LI>16-bit architectures are supported;
<LI>small initial internal data size;
<LI>less source code (to verify);
<LI>minimal set of the underlaying
<ACRONYM>clib</ACRONYM>/<ACRONYM>pthread</ACRONYM>/<ACRONYM>Win32</ACRONYM>
functions used.
</UL>
<P>The drawbacks of <ACRONYM>TinyGC</ACRONYM> are:
<UL>
<LI>lower allocation speed and larger world-stopped collection delays
(typically);
<LI>only a small subset of the <ACRONYM>BoehmGC</ACRONYM>
<ACRONYM>API</ACRONYM> is implemented;
<LI>no support for <ACRONYM>C++</ACRONYM>;
<LI>no support for architectures with a separate registers stack (like
<ACRONYM>IA-64</ACRONYM>);
<LI>no find-leak and pointer back-trace modes;
<LI>no automatic registration of static data roots, stack bottom and threads;
<LI>no "advanced" allocation and collection technologies (no blacklisting,
memory unmapping, thread-local allocation, parallel marking, generation and
incremental collections);
<LI>relies on the underlaying malloc/free() implementation (which may be
broken for large heaps, like, e.g., in some versions of msvcrt);
<LI>"all-interior-pointers" mode is limited by the offset of 256
<CODE>(1 &lt;&lt; GC_LOG2_OFFIGNORE)</CODE> bytes (this also means that
disappearing links must not be placed at this or higher offsets of an
allocated object);
<LI>only the length-based descriptor for the <ACRONYM>GCJ</ACRONYM>-style
allocation is supported;
<LI>only Java-like "no-order" finalization policy is implemented.
</UL></DIV>
<DIV class=subsection>
<H3>Notes</H3>
<P>Release notes:
<UL>
<LI>no binary distribution is offered on the official site;
<LI>no make file (or other building script) is provided.
</UL>
<P>Implementation notes:
<UL>
<LI>the same environment variables are recognized as in
<ACRONYM>BoehmGC</ACRONYM>;
<LI>the finalization and disappearing links implementations are generally the
same as in <ACRONYM>BoehmGC</ACRONYM>;
<LI>full <ACRONYM>TinyGC</ACRONYM> implementation resides in a single file
(all the internal symbols are not visible outside);
<LI>both <ACRONYM>pthreads</ACRONYM> and <ACRONYM>Win32</ACRONYM> threads are
supported;
<LI>no thread-safety of the underlaying malloc/free is required;
<LI>the stack direction is detected at <ACRONYM>TinyGC</ACRONYM>
initialization;
<LI>no warnings are printed;
<LI>the thread "suspend" handler does not use <ACRONYM>pthread</ACRONYM>
synchronization primitives (yielding and sleeping are used instead for better
portability);
<LI><ACRONYM>CPU</ACRONYM> state is saved by <CODE>setjmp()</CODE>;
<LI>there is no object "header" (i.e. the original object size is passed to
the underlaying <CODE>malloc()</CODE>).
</UL>
<P>Usage notes:
<UL>
<LI>all pointers must be word-aligned;
<LI>it is assumed that the compiler performs only <ACRONYM>GC</ACRONYM>-safe
pointer transformations;
<LI>static data roots must be manually registered;
<LI>application threads must be manually registered and unregistered;
<LI>it would be good to use <CODE>GC_call_with_gc_active()</CODE> to record
the correct main stack base (after <CODE>GC_INIT()</CODE>).
</UL></DIV>
<DIV class=subsection>
<H3>Tuning macros</H3>
<P>Useful macros for tuning (same as in <ACRONYM>BoehmGC</ACRONYM>):
<UL>
<LI>GC_DLL - compile to produce a <ACRONYM>DLL</ACRONYM> (gc.dll);
<LI>ALL_INTERIOR_POINTERS - turn on "all-interior-pointers" mode by default;
<LI>GC_GCJ_SUPPORT - compile with <ACRONYM>GCJ</ACRONYM>-style allocation
support;
<LI>GC_THREADS - compile with thread support (<ACRONYM>pthread</ACRONYM>-based
by default);
<LI>GC_WIN32_THREADS - compile with <ACRONYM>Win32</ACRONYM>-based thread
support;
<LI>JAVA_FINALIZATION_NOT_NEEDED - exclude <CODE>GC_finalize_all()</CODE> from
the <ACRONYM>API</ACRONYM>;
<LI>DONT_ADD_BYTE_AT_END - do not pad objects even if "all-interior-pointers"
mode is on;
<LI>FINALIZE_ON_DEMAND - causes finalizers to be run only in response to
explicit <CODE>GC_invoke_finalizers()</CODE> calls by default (unless
overridden at run-time);
<LI>GC_IGNORE_GCJ_INFO - disable <ACRONYM>GCJ</ACRONYM>-style type information
(useful for debugging);
<LI>GC_DONT_EXPAND - do not implicitly expand the heap by default (unless
overridden at run-time);
<LI>GC_INITIAL_HEAP_SIZE=&lt;value> - set the desired default initial heap
size (in bytes);
<LI>GC_FREE_SPACE_DIVISOR=&lt;value> - the default trade-off between garbage
collection and heap growth;
<LI>GC_MAX_RETRIES=&lt;value> - the default maximum number of garbage
collections attempted before reporting out of memory after a heap expansion
failure.
</UL>
<P>Major <ACRONYM>TinyGC</ACRONYM>-specific macros:
<UL>
<LI>GC_PRINT_MSGS - compile with statistic and error printing capabilities;
<LI>GC_GETENV_SKIP - do not recognize any environment variable (for smaller
code size or for <ACRONYM>WinCE</ACRONYM> targets);
<LI>GC_WIN32_WCE - compile for <ACRONYM>WinCE</ACRONYM> (use thread Id instead
of thread handle, and retry on <CODE>SuspendThread()</CODE> failures);
<LI>GC_NO_INACTIVE, GC_MISC_EXCLUDE - exclude the corresponding parts of the
<ACRONYM>TinyGC</ACRONYM> <ACRONYM>API</ACRONYM> (for smaller code size);
<LI>GC_NO_GCBASE, GC_NO_FNLZ, GC_NO_DLINKS, GC_NO_REGISTER_DLINK - exclude the
support (i.e. expose dummy support) for the corresponding
<ACRONYM>TinyGC</ACRONYM> capabilities (for smaller code size);
<LI>GC_USE_WIN32_SYSTEMTIME - use <ACRONYM>Win32</ACRONYM>
<CODE>GetSystemTime()</CODE> <ACRONYM>API</ACRONYM> call instead of
<CODE>ftime()</CODE> or <CODE>gettimeofday()</CODE> ones (useful for
<ACRONYM>WinCE</ACRONYM>);
<LI>GC_USE_GETTIMEOFDAY - use Unix <CODE>gettimeofday()</CODE>
<ACRONYM>API</ACRONYM> call instead of <CODE>ftime()</CODE> one;
<LI>GC_OMIT_REGISTER_KEYWORD - ignore <ACRONYM>C</ACRONYM> "register" keyword;
<LI>CONST=/**/ - ignore <ACRONYM>C</ACRONYM> "const" keyword;
<LI>INLINE=/**/ - ignore <ACRONYM>C</ACRONYM> "__inline" keyword;
<LI>GC_FASTCALL=/**/ - ignore <ACRONYM>C</ACRONYM>
<ACRONYM>x86</ACRONYM>-specific "__fastcall" keyword;
<LI>GC_CLIBDECL=/**/ - ignore <ACRONYM>C</ACRONYM>
<ACRONYM>x86</ACRONYM>-specific "__cdecl" keyword;
<LI>GC_DATASTATIC=/**/ - do not use <ACRONYM>C</ACRONYM> static storage class
for global data;
<LI>GC_STATIC=/**/ - do not use <ACRONYM>C</ACRONYM> static linkage for
<ACRONYM>GC</ACRONYM> internal functions;
<LI>GC_DATASTARTSYM=&lt;id> - specify the external symbol which is the first
one in the program data section;
<LI>GC_DATAENDSYM=&lt;id> - specify the external symbol which is the last one
in the program data section;
<LI>GC_DATASTARTSYM2=&lt;id> - specify the external symbol which is the first
one in the program ".bss" section;
<LI>GC_DATAENDSYM2=&lt;id> - specify the external symbol which is the last one
in the program ".bss" section;
<LI>GC_STACKBOTTOMVAR=&lt;id> - specify the external symbol pointing to the
program main thread stack bottom (or top if GC_STACKLEN is 0);
<LI>GC_STACKLENVAR=&lt;id> - specify the external symbol pointing to the
program main thread stack size;
<LI>GC_SIG_SUSPEND=&lt;sig_id> - use specific signal to suspend Posix threads;
<LI>GC_WIN32_CONTEXT_SP_NAME=&lt;sp_id> - use specific stack pointer register
name (defined in <ACRONYM>Win32</ACRONYM> "winnt.h");
<LI>GC_LOG2_OFFIGNORE=&lt;value> - explicitly specify the number of address
lowest bits ignored for object address hash computations.
</UL>
<P>Useful macros for client application tuning (same as in
<ACRONYM>BoehmGC</ACRONYM>):
<UL>
<LI>GC_DONT_EXPAND - do not implicitly expand the heap (unless overridden at
run-time);
<LI>GC_DLL - use <ACRONYM>TinyGC</ACRONYM> residing in a
<ACRONYM>DLL</ACRONYM>;
<LI>GC_THREADS - declare the prototypes for the collector multi-threading
support;
<LI>GC_CALL=&lt;calling_conv> - explicitly specify calling convention for the
<ACRONYM>GC</ACRONYM> <ACRONYM>API</ACRONYM> functions;
<LI>GC_CALLBACK=&lt;calling_conv> - explicitly specify an alternate calling
convention for the <ACRONYM>GC</ACRONYM> <ACRONYM>API</ACRONYM> user
callbacks;
<LI>GC_INITIAL_HEAP_SIZE=&lt;value> - set the desired initial heap size (in
bytes);
<LI>GC_MAXIMUM_HEAP_SIZE=&lt;value> - set the desired maximum heap size (in
bytes);
<LI>GC_FREE_SPACE_DIVISOR=&lt;value> - set the desired trade-off between
garbage collection and heap growth;
<LI>GC_MAX_RETRIES=&lt;value> - set the desired maximum number of garbage
collections attempted before reporting out of memory after a heap expansion
failure.
</UL>
<P>Note 1: if GC_NO_DLINKS is used without GC_NO_REGISTER_DLINK then all the
disappearing links are treated as normal pointers.
<P>Note 2: for Unix use the command-line options:
<PRE><CODE>
-DGC_FASTCALL= -DGC_CLIBDECL=
</CODE></PRE>
<P>Note 3: for Solaris <ACRONYM>SunOS</ACRONYM> "cc" use the command-line
options:
<PRE><CODE>
-DGC_FASTCALL= -DGC_CLIBDECL= -DINLINE=inline -erroff=E_WHITE_SPACE_IN_DIRECTIVE
</CODE></PRE></DIV>
<DIV class=subsection>
<H3>Environment variables</H3>
<P>Environment variables recognized (if supported, same as in
<ACRONYM>BoehmGC</ACRONYM>):
<UL>
<LI>GC_DONT_GC - turn off garbage collection;
<LI>GC_PRINT_STATS - turn on statistic printing on every garbage collection
(if supported);
<LI>GC_ALL_INTERIOR_POINTERS - turn on "all-interior-pointers" collector mode;
<LI>GC_IGNORE_GCJ_INFO - ignore the <ACRONYM>GCJ</ACRONYM>-style type
descriptors (if supported);
<LI>GC_INITIAL_HEAP_SIZE=&lt;value> - set the initial heap size (in bytes);
<LI>GC_MAXIMUM_HEAP_SIZE=&lt;value> - set the maximum heap size (in bytes);
<LI>GC_FREE_SPACE_DIVISOR=&lt;value> - change the default trade-off between
garbage collection and heap growth.
</UL>
<P>Note: the values assigned to the specified environment variables override
the similar default (or the preset at the compilation time) values.
</DIV>
<DIV class=subsection>
<H3>Files list</H3>
<P>The <ACRONYM>TinyGC</ACRONYM> distribution consists of:
<UL>
<LI>ChangeLog - the standard changes log file;
<LI>GNU_GPL.txt - the <ACRONYM>GNU</ACRONYM> <ACRONYM>GPLv2</ACRONYM> license;
<LI>README.txt - this file;
<LI>gc.h - the main include file (the subset of that in
<ACRONYM>BoehmGC</ACRONYM>);
<LI>gc_gcj.h - <ACRONYM>GCJ</ACRONYM>-style allocation <ACRONYM>API</ACRONYM>
(the subset of that in <ACRONYM>BoehmGC</ACRONYM>);
<LI>gc_mark.h - contains only the constants for the
<ACRONYM>GCJ</ACRONYM>-style length-based descriptors and the collections
notifier prototypes;
<LI>javaxfc.h - same as in <ACRONYM>BoehmGC</ACRONYM>;
<LI>tinygc.c - the <ACRONYM>TinyGC</ACRONYM> implementation itself.
</UL></DIV>
<DIV class=subsection>
<H3>User's feedback</H3>
<P>Any questions, suggestions, bug reports and patches are welcomed at the
<ACRONYM>TinyGC</ACRONYM>
<A href="http://sourceforge.net/projects/tinygc/develop/">site tracker</A>
(hosted at SourceForge.net).
</DIV>
<DIV class=subsection>
<H3>External resources</H3>
<P>Links to the 3rd-party projects:
<UL>
<LI><A class=external target="_blank" href="http://www.hpl.hp.com/personal/Hans_Boehm/gc/">BoehmGC</A>
(A garbage collector for C and C++)
<LI><A class=external target="_blank" href="http://gcc.gnu.org/java/">GNU GCJ</A>
(a portable optimizing ahead-of-time compiler for Java)
</UL>
<P>For more links, please visit
"<A href="http://www.ivmaisoft.com/jcgo/links.htm">Java and C/C++ developer web resources</A>"
hosted on the <ACRONYM>JCGO</ACRONYM> project (a
<A href="http://www.ivmaisoft.com/jcgo/">java2c/java2exe</A> solution) site.
</DIV>
<DIV class=license>
<H3>License</H3>
<P>This is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
<P>This software is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License (GPL) for more details.
<P>You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
<P>Linking this library statically or dynamically with other modules is
making a combined work based on this library. Thus, the terms and
conditions of the GNU General Public License cover the whole
combination.
<P>As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent
modules, and to copy and distribute the resulting executable under
terms of your choice, provided that you also meet, for each linked
independent module, the terms and conditions of the license of that
module. An independent module is a module which is not derived from
or based on this library. If you modify this library, you may extend
this exception to your version of the library, but you are not
obligated to do so. If you do not wish to do so, delete this
exception statement from your version.
</DIV>
<DIV class=page-footer>
<P class=copyright>&copy; 2006-2010
<A class=mailto href="mailto:ivmai@mail.ru">Ivan Maidanski</A>
</DIV>
<a href="http://www3.clustrmaps.com/counter/maps.php?url=http://tinygc.sourceforge.net" id="clustrMapsLink"><img src="http://www3.clustrmaps.com/counter/index2.php?url=http://tinygc.sourceforge.net" style="border:0px;" alt="Locations of visitors to this page" title="Locations of visitors to this page" id="clustrMapsImg" onerror="this.onerror=null; this.src='http://www2.clustrmaps.com/images/clustrmaps-back-soon.jpg'; document.getElementById('clustrMapsLink').href='http://www2.clustrmaps.com';" />
</a>
</BODY></HTML>

52
tinygc-tinygc-2_6/javaxfc.h Executable file
View File

@ -0,0 +1,52 @@
/*
* @(#) javaxfc.h -- TinyGC additional header (explicit finalization).
* Copyright (C) 2006-2009 Ivan Maidanski <ivmai@mail.ru> All rights reserved.
**
* See also files: tinygc.c, gc.h, gc_gcj.h, gc_mark.h
*/
/*
* This is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
**
* This software is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License (GPL) for more details.
**
* Linking this library statically or dynamically with other modules is
* making a combined work based on this library. Thus, the terms and
* conditions of the GNU General Public License cover the whole
* combination.
**
* As a special exception, the copyright holders of this library give you
* permission to link this library with independent modules to produce an
* executable, regardless of the license terms of these independent
* modules, and to copy and distribute the resulting executable under
* terms of your choice, provided that you also meet, for each linked
* independent module, the terms and conditions of the license of that
* module. An independent module is a module which is not derived from
* or based on this library. If you modify this library, you may extend
* this exception to your version of the library, but you are not
* obligated to do so. If you do not wish to do so, delete this
* exception statement from your version.
*/
/* TinyGC API is a subset of Boehm-Demers-Weiser Conservative GC API */
#ifndef GC_H
#include "gc.h"
#endif
#ifdef __cplusplus
extern "C"
{
#endif
GC_API void GC_CALL GC_finalize_all(void);
#ifdef __cplusplus
}
#endif

3931
tinygc-tinygc-2_6/tinygc.c Executable file

File diff suppressed because it is too large Load Diff

Binary file not shown.