Commit Graph

2904 Commits

Author SHA1 Message Date
nickysn
624b3204d8 + added and implemented MemAvail and MaxAvail for the tiny heap
git-svn-id: trunk@28664 -
2014-09-14 18:35:15 +00:00
nickysn
ad7111ad4d * SysTinyFreeMem: terminate with a runtime error if Addr is >= HeapPtr, since
InternalTinyFreeMem cannot handle that (which causes heap corruption), and it
  indicates a bug in the program anyway, because the area between HeapPtr and
  HeapEnd is free (so it indicates either a double free or freeing an invalid
  pointer).

git-svn-id: trunk@28658 -
2014-09-14 14:47:13 +00:00
nickysn
bb07318386 + added RegisterTinyHeapBlock_Simple_Prealigned procedure, which is the same as
RegisterTinyHeapBlock_Simple, but expects its address and size parameters to
  be already aligned on a TinyHeapAllocGranularity boundary

git-svn-id: trunk@28651 -
2014-09-13 15:35:46 +00:00
nickysn
c8e9d2cf6e + added a simplified version of RegisterTinyHeapBlock, for use when the tiny
heap is a single memory block

git-svn-id: trunk@28635 -
2014-09-09 12:45:47 +00:00
nickysn
72ba70f7ec * use HexStr instead of casting to PtrUInt for logging pointers, when
DEBUG_TINY_HEAP is defined, because HexStr produces nicer results for far
  pointers

git-svn-id: trunk@28633 -
2014-09-09 00:47:25 +00:00
nickysn
bf8a7f0784 * handle properly the case when RegisterTinyHeapBlock is called with a start
address equal or larger than HeapEnd

git-svn-id: trunk@28621 -
2014-09-08 17:45:09 +00:00
Károly Balogh
8d98f31afc two cases of use casts instead of anding with when extracting 16bit values
git-svn-id: trunk@28615 -
2014-09-07 23:38:33 +00:00
Károly Balogh
05e72f52c6 a slightly better generic implementation for SwapEndian() 32 bit and 64 bit ints
git-svn-id: trunk@28614 -
2014-09-07 23:19:57 +00:00
Károly Balogh
83cf14d5dd removed unnecessary masking in Swap() calls
git-svn-id: trunk@28613 -
2014-09-07 23:17:52 +00:00
nickysn
af1c5096d6 * tiny heap made TP7 compatible; the FreeList and HeapPtr variables made public
git-svn-id: trunk@28612 -
2014-09-07 19:41:53 +00:00
sergei
5279693919 * softfpu.pp: fixed two more porting bugs, and also added two typecasts to avoid unnecessary 64-bit operations.
git-svn-id: trunk@28609 -
2014-09-06 21:01:50 +00:00
nickysn
e4095588d6 * the type of FreeList changed to an untyped pointer (TP7 compatibility)
git-svn-id: trunk@28608 -
2014-09-06 18:52:43 +00:00
nickysn
a4d71348dd * TinyHeapBlocks renamed FreeList for TP7 compatibility reasons (and it'll be
moved to the interface part of the system unit as soon as the tiny heap's free
  list becomes TP7 compatible)

git-svn-id: trunk@28607 -
2014-09-06 14:56:04 +00:00
nickysn
9b41b10350 * implementation of tiny heap's GetMem changed, so that it doesn't use FreeMem
internally.

git-svn-id: trunk@28580 -
2014-09-01 23:37:00 +00:00
sergei
98332db7fe * Improved generic implementations of Bsf/Bsr. Existing ones were just ugly, BsfQword/BsrQWord producing total of 15 inline expansions 5 levels down and bloating into just a little less than a kilobyte of code (on MIPS). Now it is at most 3 expansions and 21 instructions (84 bytes), 16 and 32 bit routines are branchless.
git-svn-id: trunk@28575 -
2014-09-01 16:00:33 +00:00
Jonas Maebe
74e56c2674 * let GetDirIO() return its result in DefaultFileSystemCodePage, as its only
used internally and in combination with other strings in that code page

git-svn-id: trunk@28571 -
2014-08-31 21:28:01 +00:00
Jonas Maebe
88d969f3bd * ensure that sysutils.expandfilename() returns its result in
DefaultRTLFileSystemCodePage instead of in DefaultFileSystemCodePage
    (mantis #26627)

git-svn-id: trunk@28570 -
2014-08-31 21:27:57 +00:00
nickysn
cd0acd050e * store the tiny heap free block size in a TP7-compatible way (as a normalized
segment:offset pair, instead of a longint) in the i8086 far data memory models

git-svn-id: trunk@28532 -
2014-08-28 21:24:41 +00:00
nickysn
03a838556f * keep the tiny heap free blocks ordered by start address, instead of size.
Rationale: 1) TP7 compatibility, 2) easier debugging of heap corruption
  problems

git-svn-id: trunk@28518 -
2014-08-24 16:07:01 +00:00
sergei
6807812997 * Avoid promotion to 64 bits due to mixing signed and unsigned expressions.
git-svn-id: trunk@28510 -
2014-08-22 17:21:26 +00:00
nickysn
70850f0ce6 + tinyheap: check and generate runtime error 204 if an attempt is made to free a
memory block that is outside the heap

git-svn-id: trunk@28446 -
2014-08-18 16:44:34 +00:00
nickysn
9979aa702f + added the TP7-compatible pointer variables HeapOrg and HeapEnd, indicating,
respectively, the start and end of the tiny heap. Eventually they are also
  going to be used for catching attempts to free memory that is outside the
  heap.

git-svn-id: trunk@28437 -
2014-08-17 22:42:44 +00:00
nickysn
7986d0c2ca * simplify RegisterTinyHeapBlock by calling InternalTinyFreeMem directly,
instead of FreeMem. We already do the alignments correctly, so going through
  FreeMem is no longer necessary.

git-svn-id: trunk@28428 -
2014-08-16 22:51:06 +00:00
nickysn
2e0c40d33b * TinyHeapAllocGranularity changed to SizeOf(TTinyHeapBlock). This fixes a bug
where the free blocks may become fragmented, even though all the memory has
  been freed, following certain allocation patterns.

git-svn-id: trunk@28419 -
2014-08-15 22:13:23 +00:00
nickysn
902c25fafa + RegisterTinyHeapBlock: align the start address and size according to
TinyHeapAllocGranularity

git-svn-id: trunk@28418 -
2014-08-15 16:10:22 +00:00
nickysn
815bfe0dcf + tiny heap alloc granularity moved to a constant TinyHeapAllocGranularity
git-svn-id: trunk@28417 -
2014-08-15 15:22:51 +00:00
nickysn
14057ef438 * rm EndAddr from the TTinyHeapBlock structure. This:
1) fixes a bug, which causes the next TTinyHeapBlock to be overwritten after
     freeing a memory block, allocated by GetMem(sizeof(pointer)). This bug was
     exposed after r28391, but was present before that; this commit only made
     the damage worse and, therefore, more visible.
  2) brings the internal heap structure closer to the TP7 heap.

git-svn-id: trunk@28416 -
2014-08-15 00:33:33 +00:00
nickysn
21246e973a * TinyHeapMinBlock defined as sizeof(TTinyHeapBlock), as that's the smallest
free block actually supported

git-svn-id: trunk@28401 -
2014-08-13 08:44:53 +00:00
nickysn
e8c1a44068 * swapped the order of the Next and Size fields in TTinyHeapBlock, because that
brings it closer (but still not equal) to the TP7 heap's internal structure

git-svn-id: trunk@28391 -
2014-08-12 20:38:08 +00:00
nickysn
5edbd1cd03 * fixed i8086 ifdef (should be ifdef cpui8086, not i8086, because that's the
rtl, not the compiler)

git-svn-id: trunk@28347 -
2014-08-08 21:37:17 +00:00
sergei
ee8fcc8bdb * softfpu.pp: reverted r28318 and replaced it with a improved solution:
* Moved handling of 64-bit values > high(int64) to qword_to_float64, so that normalizeRoundAndPackFloat64 procedure stays unmodified compared to C source.
  * Using "jamming" right shift instead of regular one, so the least significant bit is not dropped but participates in rounding.
  * Take a shortcut for values with <= 53 significant bits, which are convertible into float64 exactly and do not need rounding.

git-svn-id: trunk@28346 -
2014-08-08 20:47:52 +00:00
nickysn
6720f84d24 + switch to using huge pointers in the tiny heap in the i8086 far data memory
models

git-svn-id: trunk@28333 -
2014-08-07 21:15:56 +00:00
Károly Balogh
3c8b24eead a proposed fix to the qword_to_float64 problem
git-svn-id: trunk@28318 -
2014-08-06 15:14:52 +00:00
Károly Balogh
baac5114a7 added a missing comment from the SoftFPU C source. probably explains why qword_to_float64 fails with values which have the uppermost bit set
git-svn-id: trunk@28316 -
2014-08-06 14:11:09 +00:00
sergei
0dea20d8e7 * softfloat: Fixed int64->double and qword->double conversions to take rounding mode into account (actually, brought them up to date with Softfloat-2b C source). Now test/units/math/troundm.pp is consistent for all targets.
git-svn-id: trunk@28312 -
2014-08-04 21:56:40 +00:00
sergei
bf51683e78 * Softfloat: added some typecasts to prevent promotion to 64 bits where it is not intended.
git-svn-id: trunk@28308 -
2014-08-03 12:14:43 +00:00
sergei
96abd7f370 * Softfloat: marked ExtractFloat32*, ExtractFloat64* and PackFloat32 helpers as inline.
* int64_to_float64 and qword_to_float64: call 'function' overload of PackFloat64. Whenever arguments are constant it can be evaluated entirely at compile time (the procedure PackFloat64 does not have this property even if marked as inline because it is too complex, i.e. consists of more than single statement).

git-svn-id: trunk@28307 -
2014-08-03 12:00:38 +00:00
sergei
cf2b4a4dbd * softfpu cleanup: use Pascal boolean types where appropriate, use 64-bit overload of shift64RightJamming() to simplify things.
git-svn-id: trunk@28280 -
2014-07-30 23:39:10 +00:00
masta
66aca1b104 Optimize generic 64-bit division code
FPC_{DIV,MOD}_QWORD now check if both inputs have their upper 32bit set
to zero and in that case use 32-bit division instead, which many
plattforms can either do in hardware or have optimized assembly code
for.

git-svn-id: trunk@28279 -
2014-07-30 17:07:29 +00:00
nickysn
9a569b9e57 * use P/TTinyHeapMemBlockSize in RegisterTinyHeapBlock as well
git-svn-id: trunk@28248 -
2014-07-22 12:51:20 +00:00
nickysn
6f8a329b4c * use pointer arithmetic for doing address calculations, with a newly introduced
pointer type TTinyHeapPointerArithmeticType, instead of using ptruint. This
  will allow us to use a huge pointer in i8086 far data memory models, in order
  to allow the heap to exceed 64k.

git-svn-id: trunk@28247 -
2014-07-21 23:02:49 +00:00
nickysn
3b9ab33910 * added type TTinyHeapFreeBlockSize, which holds the size of a free memory block
in the tiny heap

git-svn-id: trunk@28246 -
2014-07-21 17:05:52 +00:00
nickysn
1dc09538d0 * introduce a type TTinyHeapMemBlockSize, which holds the size of an allocated
memory block in the tiny heap

git-svn-id: trunk@28245 -
2014-07-20 16:31:40 +00:00
nickysn
16c5849fc6 + added HexStr() overload for huge pointers
git-svn-id: trunk@28180 -
2014-07-07 15:13:29 +00:00
nickysn
13646c7afe + added rtl helper for huge pointer subtraction
git-svn-id: trunk@28178 -
2014-07-06 19:15:14 +00:00
nickysn
4e2cc365d1 * while loop replaced with a repeat..until loop in InternalTinyFreeMem
git-svn-id: trunk@28161 -
2014-07-05 09:47:59 +00:00
nickysn
c306f48c14 + added rtl helpers for huge pointer comparisons
git-svn-id: trunk@28148 -
2014-07-04 08:34:17 +00:00
nickysn
f0346c096f + added rtl helpers for huge pointer arithmetic
git-svn-id: trunk@28099 -
2014-06-28 17:08:40 +00:00
nickysn
47588a287d * ifdef i8086 changed to ifdef cpui8086 in dosh.inc, because that's part of the
rtl, not the compiler

git-svn-id: trunk@28058 -
2014-06-25 10:28:29 +00:00
sergei
04d8e8a5dc * On 64-bit targets, handle abs(int64) internally, using the same code as for abs(longint), i.e. without branching. Both generic and x86-specific pass 2 code is already suitable for different operand sizes, only type checking needs removal of excessive conversions to 32 bits.
git-svn-id: trunk@27989 -
2014-06-17 18:45:11 +00:00