il2cpp
所属分类:Unity3D
开发工具:C/C++
文件大小:2220KB
下载次数:1
上传日期:2021-03-21 21:13:15
上 传 者:
710869
说明: Unity3D 想必大家都不陌生,独立游戏制作者们很多人都在用它,甚至一些大公司也用在很商业的游戏制作上。Unity3D最大的一个特点是一次制作,多平台部署,而 这一核心功能是靠Mono实现的。可以说Mono是Unity3D核心的核心,是Unity3D跨平台的根本。但是在2014年年中的时 候,Unity3D官方博客上却发了一篇“The future of scripting in unity”的文章,引出了IL2CPP的概念,感觉有取代Mono之势。那什么是IL2CPP,它能为Unity3D和作为使用Unity3D的我们带来哪些好处和改变?这就是本文尝试说明的。
(Unity3d must be familiar to everyone. Many independent game makers are using it, and even some big companies are using it for commercial game production. One of the biggest features of unity3d is one-time production and multi platform deployment, and this core function is realized by mono. It can be said that mono is the core of unity3d core and the foundation of unity3d cross platform. However, in the middle of 2014, an article "the future of scripting in unity" was posted on unity3d's official blog, which introduced the concept of il2cpp, and felt that it would replace mono. What is il2cpp? What benefits and changes can il2cpp bring to unity3d and us who use unity3d? This is what this paper tries to explain.)
文件列表:
il2cpp\build\il2cpp.exe (15360, 2016-07-27)
il2cpp\build\il2cpp.exe.mdb (2941, 2016-07-27)
il2cpp\build\Mono.Cecil.dll (289792, 2016-07-27)
il2cpp\build\Mono.Cecil.Mdb.dll (43520, 2016-07-27)
il2cpp\build\Mono.Cecil.Pdb.dll (79360, 2016-07-27)
il2cpp\build\Mono.Cecil.Rocks.dll (26624, 2016-07-27)
il2cpp\build\TinyProfiler.dll (17920, 2016-07-27)
il2cpp\build\TinyProfiler.dll.mdb (2809, 2016-07-27)
il2cpp\build\Unity.Cecil.Visitor.dll (14848, 2016-07-27)
il2cpp\build\Unity.Cecil.Visitor.dll.mdb (5314, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Building.dll (122368, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Building.dll.mdb (43305, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Common.dll (46592, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Common.dll.mdb (18572, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Common35.dll (40448, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Common35.dll.mdb (15284, 2016-07-27)
il2cpp\build\Unity.IL2CPP.CompilerServices.dll (4096, 2016-07-27)
il2cpp\build\Unity.IL2CPP.CompilerServices.dll.mdb (440, 2016-07-27)
il2cpp\build\Unity.IL2CPP.dll (568832, 2016-07-27)
il2cpp\build\Unity.IL2CPP.dll.mdb (230542, 2016-07-27)
il2cpp\build\Unity.IL2CPP.IoC.dll (6656, 2016-07-27)
il2cpp\build\Unity.IL2CPP.IoC.dll.mdb (1604, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Portability.dll (17920, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Portability.dll.mdb (9701, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Running.dll (8704, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Running.dll.mdb (1702, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Shell.dll (9216, 2016-07-27)
il2cpp\build\Unity.IL2CPP.Shell.dll.mdb (1956, 2016-07-27)
il2cpp\build\Unity.Options.dll (32768, 2016-07-27)
il2cpp\build\Unity.Options.dll.mdb (10702, 2016-07-27)
il2cpp\external\boehmgc\allchblk.c (33799, 2016-07-27)
il2cpp\external\boehmgc\alloc.c (46745, 2016-07-26)
il2cpp\external\boehmgc\backgraph.c (17353, 2016-07-26)
il2cpp\external\boehmgc\blacklst.c (10269, 2016-07-26)
il2cpp\external\boehmgc\checksums.c (6846, 2016-07-26)
il2cpp\external\boehmgc\cord\cordbscs.c (29019, 2016-07-26)
il2cpp\external\boehmgc\cord\cordprnt.c (14013, 2016-07-26)
il2cpp\external\boehmgc\cord\cordxtra.c (18141, 2016-07-26)
il2cpp\external\boehmgc\cord\tests\cordtest.c (8693, 2016-07-26)
il2cpp\external\boehmgc\cord\tests\de.c (17631, 2016-07-26)
... ...
# Boehm-Demers-Weiser Garbage Collector
This is version 7.4.0 of a conservative garbage collector for C and C++.
You might find a more recent version
[here](http://www.hpl.hp.com/personal/Hans_Boehm/gc).
## Overview
This is intended to be a general purpose, garbage collecting storage
allocator. The algorithms used are described in:
* Boehm, H., and M. Weiser, "Garbage Collection in an Uncooperative
Environment", Software Practice & Experience, September 1***8, pp. 807-820.
* Boehm, H., A. Demers, and S. Shenker, "Mostly Parallel Garbage Collection",
Proceedings of the ACM SIGPLAN '91 Conference on Programming Language Design
and Implementation, SIGPLAN Notices 26, 6 (June 1991), pp. 157-1***.
* Boehm, H., "Space Efficient Conservative Garbage Collection", Proceedings
of the ACM SIGPLAN '91 Conference on Programming Language Design and
Implementation, SIGPLAN Notices 28, 6 (June 1993), pp. 197-206.
* Boehm H., "Reducing Garbage Collector Cache Misses", Proceedings of the
2000 International Symposium on Memory Management.
Possible interactions between the collector and optimizing compilers are
discussed in
* Boehm, H., and D. Chase, "A Proposal for GC-safe C Compilation",
The Journal of C Language Translation 4, 2 (December 1992).
and
* Boehm H., "Simple GC-safe Compilation", Proceedings of the ACM SIGPLAN '96
Conference on Programming Language Design and Implementation.
(Some of these are also available from
[here](http://www.hpl.hp.com/personal/Hans_Boehm/papers/), among other places.)
Unlike the collector described in the second reference, this collector
operates either with the mutator stopped during the entire collection
(default) or incrementally during allocations. (The latter is supported
on fewer machines.) On the most common platforms, it can be built
with or without thread support. On a few platforms, it can take advantage
of a multiprocessor to speed up garbage collection.
Many of the ideas underlying the collector have previously been explored
by others. Notably, some of the run-time systems developed at Xerox PARC
in the early 1***0s conservatively scanned thread stacks to locate possible
pointers (cf. Paul Rovner, "On Adding Garbage Collection and Runtime Types
to a Strongly-Typed Statically Checked, Concurrent Language" Xerox PARC
CSL 84-7). Doug McIlroy wrote a simpler fully conservative collector that
was part of version 8 UNIX (tm), but appears to not have received
widespread use.
Rudimentary tools for use of the collector as a leak detector are included
([link](http://www.hpl.hp.com/personal/Hans_Boehm/gc/leak.html)),
as is a fairly sophisticated string package "cord" that makes use of the
collector. (See doc/README.cords and H.-J. Boehm, R. Atkinson, and M. Plass,
"Ropes: An Alternative to Strings", Software Practice and Experience 25, 12
(December 1995), pp. 1315-1330. This is very similar to the "rope" package
in Xerox Cedar, or the "rope" package in the SGI STL or the g++ distribution.)
Further collector documentation can be found
[here](http://www.hpl.hp.com/personal/Hans_Boehm/gc).
## General Description
This is a garbage collecting storage allocator that is intended to be
used as a plug-in replacement for C's malloc.
Since the collector does not require pointers to be tagged, it does not
attempt to ensure that all inaccessible storage is reclaimed. However,
in our experience, it is typically more successful at reclaiming unused
memory than most C programs using explicit deallocation. Unlike manually
introduced leaks, the amount of unreclaimed memory typically stays
bounded.
In the following, an "object" is defined to be a region of memory allocated
by the routines described below.
Any objects not intended to be collected must be pointed to either
from other such accessible objects, or from the registers,
stack, data, or statically allocated bss segments. Pointers from
the stack or registers may point to anywhere inside an object.
The same is true for heap pointers if the collector is compiled with
`ALL_INTERIOR_POINTERS` defined, or `GC_all_interior_pointers` is otherwise
set, as is now the default.
Compiling without `ALL_INTERIOR_POINTERS` may reduce accidental retention
of garbage objects, by requiring pointers from the heap to the beginning
of an object. But this no longer appears to be a significant
issue for most programs occupying a small fraction of the possible
address space.
There are a number of routines which modify the pointer recognition
algorithm. `GC_register_displacement` allows certain interior pointers
to be recognized even if `ALL_INTERIOR_POINTERS` is nor defined.
`GC_malloc_ignore_off_page` allows some pointers into the middle of
large objects to be disregarded, greatly reducing the probability of
accidental retention of large objects. For most purposes it seems
best to compile with `ALL_INTERIOR_POINTERS` and to use
`GC_malloc_ignore_off_page` if you get collector warnings from
allocations of very large objects. See doc/debugging.html for details.
_WARNING_: pointers inside memory allocated by the standard `malloc` are not
seen by the garbage collector. Thus objects pointed to only from such a
region may be prematurely deallocated. It is thus suggested that the
standard `malloc` be used only for memory regions, such as I/O buffers, that
are guaranteed not to contain pointers to garbage collectible memory.
Pointers in C language automatic, static, or register variables,
are correctly recognized. (Note that `GC_malloc_uncollectable` has
semantics similar to standard malloc, but allocates objects that are
traced by the collector.)
_WARNING_: the collector does not always know how to find pointers in data
areas that are associated with dynamic libraries. This is easy to
remedy IF you know how to find those data areas on your operating
system (see `GC_add_roots`). Code for doing this under SunOS, IRIX
5.X and 6.X, HP/UX, Alpha OSF/1, Linux, and win32 is included and used
by default. (See doc/README.win32 for Win32 details.) On other systems
pointers from dynamic library data areas may not be considered by the
collector. If you're writing a program that depends on the collector
scanning dynamic library data areas, it may be a good idea to include
at least one call to `GC_is_visible` to ensure that those areas are
visible to the collector.
Note that the garbage collector does not need to be informed of shared
read-only data. However if the shared library mechanism can introduce
discontiguous data areas that may contain pointers, then the collector does
need to be informed.
Signal processing for most signals may be deferred during collection,
and during uninterruptible parts of the allocation process.
Like standard ANSI C mallocs, by default it is unsafe to invoke
malloc (and other GC routines) from a signal handler while another
malloc call may be in progress.
The allocator/collector can also be configured for thread-safe operation.
(Full signal safety can also be achieved, but only at the cost of two system
calls per malloc, which is usually unacceptable.)
_WARNING_: the collector does not guarantee to scan thread-local storage
(e.g. of the kind accessed with `pthread_getspecific`). The collector
does scan thread stacks, though, so generally the best solution is to
ensure that any pointers stored in thread-local storage are also
stored on the thread's stack for the duration of their lifetime.
(This is arguably a longstanding bug, but it hasn't been fixed yet.)
## Installation and Portability
As distributed, the collector operates silently
In the event of problems, this can usually be changed by defining the
`GC_PRINT_STATS` or `GC_PRINT_VERBOSE_STATS` environment variables. This
will result in a few lines of descriptive output for each collection.
(The given statistics exhibit a few peculiarities.
Things don't appear to add up for a variety of reasons, most notably
fragmentation losses. These are probably much more significant for the
contrived program "test.c" than for your application.)
On most Unix-like platforms, the collector can be built either using a
GNU autoconf-based build infrastructure (type `configure; make` in the
simplest case), or with a classic makefile by itself (type
`make -f Makefile.direct`). Here we focus on the latter option.
On other platforms, typically only the latter option is available, though
with a different supplied Makefile.)
For the Makefile.direct-based process, typing `make test` instead of `make`
will automatically build the collector and then run `setjmp_test` and `gctest`.
`Setjmp_test` will give you information about configuring the collector, which is
useful primarily if you have a machine that's not already supported. Gctest is
a somewhat superficial test of collector functionality. Failure is indicated
by a core dump or a message to the effect that the collector is broken. Gctest
takes about a second to two to run on reasonable 2007 vintage desktops. It may
use up to about 30MB of memory. (The multi-threaded version will use more.
***-bit versions may use more.) `make test` will also, as its last step, attempt
to build and test the "cord" string library.)
Makefile.direct will generate a library gc.a which you should link against.
Typing "make cords" will add the cord library to gc.a.
The GNU style build process understands the usual targets. `make check`
runs a number of tests. `make install` installs at least libgc, and libcord.
Try `./configure --help` to see the configuration options. It is currently
not possible to exercise all combinations of build options this way.
It is suggested that if you need to replace a piece of the collector
(e.g. GC_mark_rts.c) you simply list your version ahead of gc.a on the
ld command line, rather than replacing the one in gc.a. (This will
generate numerous warnings under some versions of AIX, but it still
works.)
All include files that need to be used by clients will be put in the
include subdirectory. (Normally this is just gc.h. `make cords` adds
"cord.h" and "ec.h".)
The collector currently is designed to run essentially unmodified on
machines that use a flat 32-bit or ***-bit address space.
That includes the vast majority of Workstations and X86 (X >= 3) PCs.
(The list here was deleted because it was getting too long and constantly
out of date.)
In a few cases (Amiga, OS/2, Win32, MacOS) a separate makefile
or equivalent is supplied. Many of these have separate README.system
files.
Dynamic libraries are completely supported only under SunOS/Solaris,
(and even that support is not functional on the last Sun 3 release),
Linux, FreeBSD, NetBSD, IRIX 5&6, HP/UX, Win32 (not Win32S) and OSF/1
on DEC AXP machines plus perhaps a few others listed near the top
of dyn_load.c. On other machines we recommend that you do one of
the following:
1) Add dynamic library support (and send us the code).
2) Use static versions of the libraries.
3) Arrange for dynamic libraries to use the standard malloc.
This is still dangerous if the library stores a pointer to a
garbage collected object. But nearly all standard interfaces
prohibit this, because they deal correctly with pointers
to stack allocated objects. (Strtok is an exception. Don't
use it.)
In all cases we assume that pointer alignment is consistent with that
enforced by the standard C compilers. If you use a nonstandard compiler
you may have to adjust the alignment parameters defined in gc_priv.h.
Note that this may also be an issue with packed records/structs, if those
enforce less alignment for pointers.
A port to a machine that is not byte addressed, or does not use 32 bit
or *** bit addresses will require a major effort. A port to plain MSDOS
or win16 is hard.
For machines not already mentioned, or for nonstandard compilers,
some porting suggestions are provided in doc/porting.html.
## The C Interface to the Allocator
The following routines are intended to be directly called by the user.
Note that usually only `GC_malloc` is necessary. `GC_clear_roots` and
`GC_add_roots` calls may be required if the collector has to trace
from nonstandard places (e.g. from dynamic library data areas on a
machine on which the collector doesn't already understand them.) On
some machines, it may be desirable to set `GC_stacktop` to a good
approximation of the stack base. (This enhances code portability on
HP PA machines, since there is no good way for the collector to
compute this value.) Client code may include "gc.h", which defines
all of the following, plus many others.
1) `GC_malloc(nbytes)`
- Allocate an object of size nbytes. Unlike malloc, the object is
cleared before being returned to the user. `GC_malloc` will
invoke the garbage collector when it determines this to be appropriate.
GC_malloc may return 0 if it is unable to acquire sufficient
space from the operating system. This is the most probable
consequence of running out of space. Other possible consequences
are that a function call will fail due to lack of stack space,
or that the collector will fail in other ways because it cannot
maintain its internal data structures, or that a crucial system
process will fail and take down the machine. Most of these
possibilities are independent of the malloc implementation.
2) `GC_malloc_atomic(nbytes)`
- Allocate an object of size nbytes that is guaranteed not to contain any
pointers. The returned object is not guaranteed to be cleared.
(Can always be replaced by `GC_malloc`, but results in faster collection
times. The collector will probably run faster if large character
arrays, etc. are allocated with `GC_malloc_atomic` than if they are
statically allocated.)
3) `GC_realloc(object, new_size)`
- Change the size of object to be `new_size`. Returns a pointer to the
new object, which may, or may not, be the same as the pointer to
the old object. The new object is taken to be atomic if and only if the
old one was. If the new object is composite and larger than the original
object,then the newly added bytes are cleared (we hope). This is very
likely to allocate a new object, unless `MERGE_SIZES` is defined in
gc_priv.h. Even then, it is likely to recycle the old object only if the
object is grown in small additive increments (which, we claim, is
generally bad coding practice.)
4) `GC_free(object)`
- Explicitly deallocate an object returned by `GC_malloc` or
`GC_malloc_atomic`. Not necessary, but can be used to minimize
collections if performance is critical. Probably a performance
loss for very small objects (<= 8 bytes).
5) `GC_expand_hp(bytes)`
- Explicitly increase the heap size. (This is normally done automatically
if a garbage collection failed to `GC_reclaim` enough memory. Explicit
calls to `GC_expand_hp` may prevent unnecessarily frequent collections at
program startup.)
6) `GC_malloc_ignore_off_page(bytes)`
- Identical to `GC_malloc`, but the client promises to keep a pointer to
the somewhere within the first 256 bytes of the object while it is
live. (This pointer should normally be declared volatile to prevent
interference from compiler optimizations.) This is the recommended
way to allocate anything that is likely to be larger than 100 Kbytes
or so. (`GC_malloc` may result in failure to reclaim such objects.)
7) `GC_set_warn_proc(proc)`
- Can be used to redirect warnings from the collector. Such warnings
should be rare, and should not be ignored during code development.
8) `GC_enable_incremental()`
- Enables generational and incremental collection. Useful for large
heaps on machines that provide access to page dirty information.
Some dirty bit implementations may interfere with debugging
(by catching address faults) and place restrictions on heap arguments
to system calls (since write faults inside a system call may not be
handled well).
9) Several routines to allow for registration of finalization code.
User supplied finalization code may be invoked when an object becomes
unreachable. To call `(*f)(obj, x)` when obj becomes inaccessible, use
`GC_register_finalizer(obj, f, x, 0, 0);`
For more sophisticated uses, and for finalization ordering issues,
see gc.h.
The global variable `GC_free_space_divisor` may be adjusted up from it
default value of 3 to use less space and more collection time, or down for
the opposite effect. Setting it to 1 will almost disable collections
and cause all allocations to simply grow the heap.
The variable `GC_non_gc_bytes`, which is normally 0, may be changed to reflect
the amount of memory allocated by the above routines that should not be
considered as a candidate for collection. Careless use may, of course, result
in excessive memory consumption.
Some additional tuning is possible through the parameters defined
near the top of gc_priv.h.
If only `GC_malloc` is intended to be used, it might be appropriate to define:
#define malloc(n) GC_malloc(n)
#define calloc(m,n) GC_malloc((m)*(n))
For small pieces of VERY allocation intensive code, gc_inl.h includes
some allocation macros that may be used in place of `GC_malloc` and
friends.
All externally visible names in the garbage collector start with `GC_`.
To avoid name conflicts, client code should avoid this prefix, except when
accessing garbage collector routines or variables.
There are provisions for allocation with explicit type information.
This is rarely necessary. Details can be found in gc_typed.h.
## The C++ Interface to the Allocator
The Ellis-Hull C++ interface to the collector is included in
the collector distribution. If you intend to use this, type
`make c++` after the initial build of the collector is complete.
See gc_cpp.h for the definition of the interface. This interface
tries to approximate the Ellis-Detlefs C++ garbage collection
proposal without compiler changes.
Very often it will also be necessary to use gc_allocator.h and the
allocator declared there to construct STL data structures. Otherwise
subobjects of STL data structures will be allocated using a system
allocator, and objects they refer to may be prematurely collected.
## Use as Leak Detector
The collector may be used to track down leaks in C programs that are
intended to run with malloc/free (e.g. code with extreme real-time or
portability constraints). To do so define `FIND_LEAK` in Makefile.
This will cause the collector to invoke the `report_leak`
routine defined near the top of reclaim.c whenever an inaccessible
object is found that has not been explicitly freed. Such objects will
also be automatically reclaimed.
If all objects are allocated with `GC_DEBUG_MALLOC` (see next section), then
the default version of report_leak will report at least the source file and
line number at which the leaked object was allocated. This may sometimes be
sufficient. (On a few machines, it will also report a cryptic stack trace.
If this is not symbolic, it can sometimes be called into a symbolic stack
trace by invoking program "foo" with "tools/callprocs.sh foo". It is a short
shell script that invokes adb to expand program counter values to symbolic
addresses. It was largely supplied by Scott Schwartz.)
Note that the debugging facilities described in the next section can
sometimes be slightly LESS effective in le ... ...
近期下载者:
相关文件:
收藏者: