send2vinnie / mclinker

Automatically exported from code.google.com/p/mclinker
Other
0 stars 0 forks source link

Refactor MemoryArea and MemoryAreaFactory #65

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This work will be done in LionHead branch.

Original responsibility of MemoryAreaFactory:
1. One file may be opened many times during linking. Linkers should reuse the 
opened file descriptor and information to reduce I/O. MemoryAreaFactory reuses 
the opened file descriptors to eliminate the redundancy.

Original responsibility of MemoryArea:
Essential responsibility
1. creates Space
2. remembers Space
3. decide WHEN to use ::mmap or ::malloc
4. decide WHEN to synchronize file and memory.
5. synchronize file and memory
6. describe whether we opened the file successfully or not.

Incidental responsibility
1. open file descriptor
2. close file descriptor
3. execute ::mmap and ::malloc
4. increase the size of output file.

In the future, we will separate those responsibilities as following:

MemoryAreaFactory
1. Provides the interface and hide all details
  1. open file descriptor
  2. use opened file descriptor
  3. use given void* memory
  - For the orthogonality, we should reuse C's oflags and mode_t.
    i. MemoryAreaFactory should not dependent on any kinds of input or output file.

2. Make the memory buffer, and use it to Space.
3. Confirm the same file descriptor will not be opened twice.
  - records file descriptor
  - change the size of file (writable file only)
4. Allocate the memory
  - creates Space
5. synchronize file and memory

The responsibility of MemoryArea
1. remember Space
2. decides WHAT KIND of Space to be created
3. decides WHEN to create Space
4. decides WHEN to synchronize file and memory

Original issue reported on code.google.com by LubaTang on 13 Jun 2012 at 4:08

GoogleCodeExporter commented 9 years ago
In the new MemoryAreaFactory, feature
1. Provides the interface and hide all details
  2. use opened file descriptor
will be removed.

Because we can not know whether the file descriptor is writable or not, there 
is no way to make a correct Space.

Original comment by LubaTang on 13 Jun 2012 at 7:38

GoogleCodeExporter commented 9 years ago
I merge master and LionHead. I think it's time to verify all regression tests 
and release a new version.

Original comment by LubaTang on 23 Jun 2012 at 7:54