Renaming rest camelCase-named identifiers according to underscore_named_value-naming.
This commit is contained in:
+10
-10
@@ -140,7 +140,7 @@ extern void __noreturn jerry_exit( jerry_status_t code);
|
||||
*/
|
||||
inline uint32_t jerry_extract_bit_field(uint32_t value, uint32_t lsb,
|
||||
uint32_t width);
|
||||
inline uint32_t jerry_set_bit_field_value(uint32_t value, uint32_t bitFieldValue,
|
||||
inline uint32_t jerry_set_bit_field_value(uint32_t value, uint32_t bit_field_value,
|
||||
uint32_t lsb, uint32_t width);
|
||||
|
||||
/**
|
||||
@@ -158,10 +158,10 @@ jerry_extract_bit_field(uint32_t
|
||||
JERRY_ASSERT(lsb < JERRY_BITSINBYTE * sizeof (uint32_t));
|
||||
JERRY_ASSERT((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint32_t));
|
||||
|
||||
uint32_t shiftedValue = container >> lsb;
|
||||
uint32_t bitFieldMask = (1u << width) - 1;
|
||||
uint32_t shifted_value = container >> lsb;
|
||||
uint32_t bit_field_mask = (1u << width) - 1;
|
||||
|
||||
return ( shiftedValue & bitFieldMask);
|
||||
return ( shifted_value & bit_field_mask);
|
||||
} /* jerry_extract_bit_field */
|
||||
|
||||
/**
|
||||
@@ -172,20 +172,20 @@ jerry_extract_bit_field(uint32_t
|
||||
inline uint32_t
|
||||
jerry_set_bit_field_value(uint32_t
|
||||
container, /**< container to insert bit-field to */
|
||||
uint32_t newBitFieldValue, /**< value of bit-field to insert */
|
||||
uint32_t new_bit_field_value, /**< value of bit-field to insert */
|
||||
uint32_t lsb, /**< least significant bit of the value
|
||||
* to be extracted */
|
||||
uint32_t width) /**< width of the bit-field to be extracted */
|
||||
{
|
||||
JERRY_ASSERT(lsb < JERRY_BITSINBYTE * sizeof (uint32_t));
|
||||
JERRY_ASSERT((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint32_t));
|
||||
JERRY_ASSERT(newBitFieldValue <= (1u << width));
|
||||
JERRY_ASSERT(new_bit_field_value <= (1u << width));
|
||||
|
||||
uint32_t bitFieldMask = (1u << width) - 1;
|
||||
uint32_t shiftedBitFieldMask = bitFieldMask << lsb;
|
||||
uint32_t shiftedNewBitFieldValue = newBitFieldValue << lsb;
|
||||
uint32_t bit_field_mask = (1u << width) - 1;
|
||||
uint32_t shifted_bit_field_mask = bit_field_mask << lsb;
|
||||
uint32_t shifted_new_bit_field_value = new_bit_field_value << lsb;
|
||||
|
||||
return ( container & ~shiftedBitFieldMask) | shiftedNewBitFieldValue;
|
||||
return ( container & ~shifted_bit_field_mask) | shifted_new_bit_field_value;
|
||||
} /* jerry_set_bit_field_value */
|
||||
|
||||
#endif /* !JERRY_GLOBALS_H */
|
||||
|
||||
+135
-135
@@ -64,9 +64,9 @@ typedef enum
|
||||
*/
|
||||
typedef struct mem_block_header_t
|
||||
{
|
||||
mem_magic_num_of_block_t MagicNum; /**< magic number - MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK for allocated block
|
||||
mem_magic_num_of_block_t magic_num; /**< magic number - MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK for allocated block
|
||||
and MEM_MAGIC_NUM_OF_FREE_BLOCK for free block */
|
||||
struct mem_block_header_t *Neighbours[ MEM_DIRECTION_COUNT ]; /**< neighbour blocks */
|
||||
struct mem_block_header_t *neighbours[ MEM_DIRECTION_COUNT ]; /**< neighbour blocks */
|
||||
size_t allocated_bytes; /**< allocated area size - for allocated blocks; 0 - for free blocks */
|
||||
} mem_block_header_t;
|
||||
|
||||
@@ -85,10 +85,10 @@ JERRY_STATIC_ASSERT( MEM_HEAP_CHUNK_SIZE % MEM_ALIGNMENT == 0 );
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t* HeapStart; /**< first address of heap space */
|
||||
size_t HeapSize; /**< heap space size */
|
||||
mem_block_header_t* pFirstBlock; /**< first block of the heap */
|
||||
mem_block_header_t* pLastBlock; /**< last block of the heap */
|
||||
uint8_t* heap_start; /**< first address of heap space */
|
||||
size_t heap_size; /**< heap space size */
|
||||
mem_block_header_t* first_block_p; /**< first block of the heap */
|
||||
mem_block_header_t* last_block_p; /**< last block of the heap */
|
||||
} mem_heap_state_t;
|
||||
|
||||
/**
|
||||
@@ -100,11 +100,11 @@ static size_t mem_get_block_chunks_count( const mem_block_header_t *block_header
|
||||
static size_t mem_get_block_data_space_size( const mem_block_header_t *block_header_p);
|
||||
static size_t mem_get_block_chunks_count_from_data_size( size_t block_allocated_size);
|
||||
|
||||
static void mem_init_block_header( uint8_t *pFirstChunk,
|
||||
size_t sizeInChunks,
|
||||
mem_block_state_t blockState,
|
||||
mem_block_header_t *pPrevBlock,
|
||||
mem_block_header_t *pNextBlock);
|
||||
static void mem_init_block_header( uint8_t *first_chunk_p,
|
||||
size_t size_in_chunks,
|
||||
mem_block_state_t block_state,
|
||||
mem_block_header_t *prev_block_p,
|
||||
mem_block_header_t *next_block_p);
|
||||
static void mem_check_heap( void);
|
||||
|
||||
#ifdef MEM_STATS
|
||||
@@ -136,18 +136,18 @@ mem_get_block_chunks_count( const mem_block_header_t *block_header_p) /**< block
|
||||
{
|
||||
JERRY_ASSERT( block_header_p != NULL );
|
||||
|
||||
const mem_block_header_t *next_block_p = block_header_p->Neighbours[ MEM_DIRECTION_NEXT ];
|
||||
const mem_block_header_t *next_block_p = block_header_p->neighbours[ MEM_DIRECTION_NEXT ];
|
||||
size_t dist_till_block_end;
|
||||
|
||||
if ( next_block_p == NULL )
|
||||
{
|
||||
dist_till_block_end = (size_t) ( mem_heap.HeapStart + mem_heap.HeapSize - (uint8_t*) block_header_p );
|
||||
dist_till_block_end = (size_t) ( mem_heap.heap_start + mem_heap.heap_size - (uint8_t*) block_header_p );
|
||||
} else
|
||||
{
|
||||
dist_till_block_end = (size_t) ( (uint8_t*) next_block_p - (uint8_t*) block_header_p );
|
||||
}
|
||||
|
||||
JERRY_ASSERT( dist_till_block_end <= mem_heap.HeapSize );
|
||||
JERRY_ASSERT( dist_till_block_end <= mem_heap.heap_size );
|
||||
JERRY_ASSERT( dist_till_block_end % MEM_HEAP_CHUNK_SIZE == 0 );
|
||||
|
||||
return dist_till_block_end / MEM_HEAP_CHUNK_SIZE;
|
||||
@@ -179,25 +179,25 @@ mem_get_block_chunks_count_from_data_size( size_t block_allocated_size) /**< siz
|
||||
* Startup initialization of heap
|
||||
*/
|
||||
void
|
||||
mem_heap_init(uint8_t *heapStart, /**< first address of heap space */
|
||||
size_t heapSize) /**< heap space size */
|
||||
mem_heap_init(uint8_t *heap_start, /**< first address of heap space */
|
||||
size_t heap_size) /**< heap space size */
|
||||
{
|
||||
JERRY_ASSERT( heapStart != NULL );
|
||||
JERRY_ASSERT( heapSize != 0 );
|
||||
JERRY_ASSERT( heapSize % MEM_HEAP_CHUNK_SIZE == 0 );
|
||||
JERRY_ASSERT( (uintptr_t) heapStart % MEM_ALIGNMENT == 0);
|
||||
JERRY_ASSERT( heap_start != NULL );
|
||||
JERRY_ASSERT( heap_size != 0 );
|
||||
JERRY_ASSERT( heap_size % MEM_HEAP_CHUNK_SIZE == 0 );
|
||||
JERRY_ASSERT( (uintptr_t) heap_start % MEM_ALIGNMENT == 0);
|
||||
|
||||
mem_heap.HeapStart = heapStart;
|
||||
mem_heap.HeapSize = heapSize;
|
||||
mem_heap.heap_start = heap_start;
|
||||
mem_heap.heap_size = heap_size;
|
||||
|
||||
mem_init_block_header(mem_heap.HeapStart,
|
||||
mem_init_block_header(mem_heap.heap_start,
|
||||
0,
|
||||
MEM_BLOCK_FREE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
mem_heap.pFirstBlock = (mem_block_header_t*) mem_heap.HeapStart;
|
||||
mem_heap.pLastBlock = mem_heap.pFirstBlock;
|
||||
mem_heap.first_block_p = (mem_block_header_t*) mem_heap.heap_start;
|
||||
mem_heap.last_block_p = mem_heap.first_block_p;
|
||||
|
||||
mem_heap_stat_init();
|
||||
} /* mem_heap_init */
|
||||
@@ -206,29 +206,29 @@ mem_heap_init(uint8_t *heapStart, /**< first address of heap space */
|
||||
* Initialize block header
|
||||
*/
|
||||
static void
|
||||
mem_init_block_header( uint8_t *pFirstChunk, /**< address of the first chunk to use for the block */
|
||||
mem_init_block_header( uint8_t *first_chunk_p, /**< address of the first chunk to use for the block */
|
||||
size_t allocated_bytes, /**< size of block's allocated area */
|
||||
mem_block_state_t blockState, /**< state of the block (allocated or free) */
|
||||
mem_block_header_t *pPrevBlock, /**< previous block */
|
||||
mem_block_header_t *pNextBlock) /**< next block */
|
||||
mem_block_state_t block_state, /**< state of the block (allocated or free) */
|
||||
mem_block_header_t *prev_block_p, /**< previous block */
|
||||
mem_block_header_t *next_block_p) /**< next block */
|
||||
{
|
||||
mem_block_header_t *pBlockHeader = (mem_block_header_t*) pFirstChunk;
|
||||
mem_block_header_t *block_header_p = (mem_block_header_t*) first_chunk_p;
|
||||
|
||||
if ( blockState == MEM_BLOCK_FREE )
|
||||
if ( block_state == MEM_BLOCK_FREE )
|
||||
{
|
||||
pBlockHeader->MagicNum = MEM_MAGIC_NUM_OF_FREE_BLOCK;
|
||||
block_header_p->magic_num = MEM_MAGIC_NUM_OF_FREE_BLOCK;
|
||||
|
||||
JERRY_ASSERT( allocated_bytes == 0 );
|
||||
} else
|
||||
{
|
||||
pBlockHeader->MagicNum = MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK;
|
||||
block_header_p->magic_num = MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK;
|
||||
}
|
||||
|
||||
pBlockHeader->Neighbours[ MEM_DIRECTION_PREV ] = pPrevBlock;
|
||||
pBlockHeader->Neighbours[ MEM_DIRECTION_NEXT ] = pNextBlock;
|
||||
pBlockHeader->allocated_bytes = allocated_bytes;
|
||||
block_header_p->neighbours[ MEM_DIRECTION_PREV ] = prev_block_p;
|
||||
block_header_p->neighbours[ MEM_DIRECTION_NEXT ] = next_block_p;
|
||||
block_header_p->allocated_bytes = allocated_bytes;
|
||||
|
||||
JERRY_ASSERT( allocated_bytes <= mem_get_block_data_space_size( pBlockHeader) );
|
||||
JERRY_ASSERT( allocated_bytes <= mem_get_block_data_space_size( block_header_p) );
|
||||
} /* mem_init_block_header */
|
||||
|
||||
/**
|
||||
@@ -245,94 +245,94 @@ mem_init_block_header( uint8_t *pFirstChunk, /**< address of the first c
|
||||
* NULL - if there is not enough memory.
|
||||
*/
|
||||
uint8_t*
|
||||
mem_heap_alloc_block( size_t sizeInBytes, /**< size of region to allocate in bytes */
|
||||
mem_heap_alloc_term_t allocTerm) /**< expected allocation term */
|
||||
mem_heap_alloc_block( size_t size_in_bytes, /**< size of region to allocate in bytes */
|
||||
mem_heap_alloc_term_t alloc_term) /**< expected allocation term */
|
||||
{
|
||||
mem_block_header_t *pBlock;
|
||||
mem_block_header_t *block_p;
|
||||
mem_direction_t direction;
|
||||
|
||||
mem_check_heap();
|
||||
|
||||
if ( allocTerm == MEM_HEAP_ALLOC_SHORT_TERM )
|
||||
if ( alloc_term == MEM_HEAP_ALLOC_SHORT_TERM )
|
||||
{
|
||||
pBlock = mem_heap.pFirstBlock;
|
||||
block_p = mem_heap.first_block_p;
|
||||
direction = MEM_DIRECTION_NEXT;
|
||||
} else
|
||||
{
|
||||
pBlock = mem_heap.pLastBlock;
|
||||
block_p = mem_heap.last_block_p;
|
||||
direction = MEM_DIRECTION_PREV;
|
||||
}
|
||||
|
||||
/* searching for appropriate block */
|
||||
while ( pBlock != NULL )
|
||||
while ( block_p != NULL )
|
||||
{
|
||||
if ( pBlock->MagicNum == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
if ( block_p->magic_num == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
{
|
||||
if ( mem_get_block_data_space_size( pBlock) >= sizeInBytes )
|
||||
if ( mem_get_block_data_space_size( block_p) >= size_in_bytes )
|
||||
{
|
||||
break;
|
||||
}
|
||||
} else
|
||||
{
|
||||
JERRY_ASSERT( pBlock->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
JERRY_ASSERT( block_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
}
|
||||
|
||||
pBlock = pBlock->Neighbours[ direction ];
|
||||
block_p = block_p->neighbours[ direction ];
|
||||
}
|
||||
|
||||
if ( pBlock == NULL )
|
||||
if ( block_p == NULL )
|
||||
{
|
||||
/* not enough free space */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* appropriate block found, allocating space */
|
||||
size_t newBlockSizeInChunks = mem_get_block_chunks_count_from_data_size( sizeInBytes);
|
||||
size_t foundBlockSizeInChunks = mem_get_block_chunks_count( pBlock);
|
||||
size_t new_block_size_in_chunks = mem_get_block_chunks_count_from_data_size( size_in_bytes);
|
||||
size_t found_block_size_in_chunks = mem_get_block_chunks_count( block_p);
|
||||
|
||||
JERRY_ASSERT( newBlockSizeInChunks <= foundBlockSizeInChunks );
|
||||
JERRY_ASSERT( new_block_size_in_chunks <= found_block_size_in_chunks );
|
||||
|
||||
mem_block_header_t *pPrevBlock = pBlock->Neighbours[ MEM_DIRECTION_PREV ];
|
||||
mem_block_header_t *pNextBlock = pBlock->Neighbours[ MEM_DIRECTION_NEXT ];
|
||||
mem_block_header_t *prev_block_p = block_p->neighbours[ MEM_DIRECTION_PREV ];
|
||||
mem_block_header_t *next_block_p = block_p->neighbours[ MEM_DIRECTION_NEXT ];
|
||||
|
||||
if ( newBlockSizeInChunks < foundBlockSizeInChunks )
|
||||
if ( new_block_size_in_chunks < found_block_size_in_chunks )
|
||||
{
|
||||
mem_heap_stat_free_block_split();
|
||||
|
||||
uint8_t *pNewFreeBlockFirstChunk = (uint8_t*) pBlock + newBlockSizeInChunks * MEM_HEAP_CHUNK_SIZE;
|
||||
mem_init_block_header(pNewFreeBlockFirstChunk,
|
||||
uint8_t *new_free_block_first_chunk_p = (uint8_t*) block_p + new_block_size_in_chunks * MEM_HEAP_CHUNK_SIZE;
|
||||
mem_init_block_header(new_free_block_first_chunk_p,
|
||||
0,
|
||||
MEM_BLOCK_FREE,
|
||||
pBlock /* there we will place new allocated block */,
|
||||
pNextBlock);
|
||||
block_p /* there we will place new allocated block */,
|
||||
next_block_p);
|
||||
|
||||
mem_block_header_t *pNewFreeBlock = (mem_block_header_t*) pNewFreeBlockFirstChunk;
|
||||
mem_block_header_t *new_free_block_p = (mem_block_header_t*) new_free_block_first_chunk_p;
|
||||
|
||||
if ( pNextBlock == NULL )
|
||||
if ( next_block_p == NULL )
|
||||
{
|
||||
mem_heap.pLastBlock = pNewFreeBlock;
|
||||
mem_heap.last_block_p = new_free_block_p;
|
||||
}
|
||||
|
||||
pNextBlock = pNewFreeBlock;
|
||||
next_block_p = new_free_block_p;
|
||||
}
|
||||
|
||||
mem_init_block_header((uint8_t*) pBlock,
|
||||
sizeInBytes,
|
||||
mem_init_block_header((uint8_t*) block_p,
|
||||
size_in_bytes,
|
||||
MEM_BLOCK_ALLOCATED,
|
||||
pPrevBlock,
|
||||
pNextBlock);
|
||||
prev_block_p,
|
||||
next_block_p);
|
||||
|
||||
mem_heap_stat_alloc_block( pBlock);
|
||||
mem_heap_stat_alloc_block( block_p);
|
||||
|
||||
JERRY_ASSERT( mem_get_block_data_space_size( pBlock) >= sizeInBytes );
|
||||
JERRY_ASSERT( mem_get_block_data_space_size( block_p) >= size_in_bytes );
|
||||
|
||||
mem_check_heap();
|
||||
|
||||
/* return data space beginning address */
|
||||
uint8_t *pDataSpace = (uint8_t*) (pBlock + 1);
|
||||
JERRY_ASSERT( (uintptr_t) pDataSpace % MEM_ALIGNMENT == 0);
|
||||
uint8_t *data_space_p = (uint8_t*) (block_p + 1);
|
||||
JERRY_ASSERT( (uintptr_t) data_space_p % MEM_ALIGNMENT == 0);
|
||||
|
||||
return pDataSpace;
|
||||
return data_space_p;
|
||||
} /* mem_heap_alloc_block */
|
||||
|
||||
/**
|
||||
@@ -342,57 +342,57 @@ void
|
||||
mem_heap_free_block( uint8_t *ptr) /**< pointer to beginning of data space of the block */
|
||||
{
|
||||
/* checking that ptr points to the heap */
|
||||
JERRY_ASSERT( ptr >= mem_heap.HeapStart
|
||||
&& ptr <= mem_heap.HeapStart + mem_heap.HeapSize );
|
||||
JERRY_ASSERT( ptr >= mem_heap.heap_start
|
||||
&& ptr <= mem_heap.heap_start + mem_heap.heap_size );
|
||||
|
||||
mem_check_heap();
|
||||
|
||||
mem_block_header_t *pBlock = (mem_block_header_t*) ptr - 1;
|
||||
mem_block_header_t *pPrevBlock = pBlock->Neighbours[ MEM_DIRECTION_PREV ];
|
||||
mem_block_header_t *pNextBlock = pBlock->Neighbours[ MEM_DIRECTION_NEXT ];
|
||||
mem_block_header_t *block_p = (mem_block_header_t*) ptr - 1;
|
||||
mem_block_header_t *prev_block_p = block_p->neighbours[ MEM_DIRECTION_PREV ];
|
||||
mem_block_header_t *next_block_p = block_p->neighbours[ MEM_DIRECTION_NEXT ];
|
||||
|
||||
mem_heap_stat_free_block( pBlock);
|
||||
mem_heap_stat_free_block( block_p);
|
||||
|
||||
/* checking magic nums that are neighbour to data space */
|
||||
JERRY_ASSERT( pBlock->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
if ( pNextBlock != NULL )
|
||||
JERRY_ASSERT( block_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
if ( next_block_p != NULL )
|
||||
{
|
||||
JERRY_ASSERT( pNextBlock->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK
|
||||
|| pNextBlock->MagicNum == MEM_MAGIC_NUM_OF_FREE_BLOCK );
|
||||
JERRY_ASSERT( next_block_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK
|
||||
|| next_block_p->magic_num == MEM_MAGIC_NUM_OF_FREE_BLOCK );
|
||||
}
|
||||
|
||||
pBlock->MagicNum = MEM_MAGIC_NUM_OF_FREE_BLOCK;
|
||||
block_p->magic_num = MEM_MAGIC_NUM_OF_FREE_BLOCK;
|
||||
|
||||
if ( pNextBlock != NULL
|
||||
&& pNextBlock->MagicNum == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
if ( next_block_p != NULL
|
||||
&& next_block_p->magic_num == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
{
|
||||
/* merge with the next block */
|
||||
mem_heap_stat_free_block_merge();
|
||||
|
||||
pNextBlock = pNextBlock->Neighbours[ MEM_DIRECTION_NEXT ];
|
||||
pBlock->Neighbours[ MEM_DIRECTION_NEXT ] = pNextBlock;
|
||||
if ( pNextBlock != NULL )
|
||||
next_block_p = next_block_p->neighbours[ MEM_DIRECTION_NEXT ];
|
||||
block_p->neighbours[ MEM_DIRECTION_NEXT ] = next_block_p;
|
||||
if ( next_block_p != NULL )
|
||||
{
|
||||
pNextBlock->Neighbours[ MEM_DIRECTION_PREV ] = pBlock;
|
||||
next_block_p->neighbours[ MEM_DIRECTION_PREV ] = block_p;
|
||||
} else
|
||||
{
|
||||
mem_heap.pLastBlock = pBlock;
|
||||
mem_heap.last_block_p = block_p;
|
||||
}
|
||||
}
|
||||
|
||||
if ( pPrevBlock != NULL
|
||||
&& pPrevBlock->MagicNum == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
if ( prev_block_p != NULL
|
||||
&& prev_block_p->magic_num == MEM_MAGIC_NUM_OF_FREE_BLOCK )
|
||||
{
|
||||
/* merge with the previous block */
|
||||
mem_heap_stat_free_block_merge();
|
||||
|
||||
pPrevBlock->Neighbours[ MEM_DIRECTION_NEXT ] = pNextBlock;
|
||||
if ( pNextBlock != NULL )
|
||||
prev_block_p->neighbours[ MEM_DIRECTION_NEXT ] = next_block_p;
|
||||
if ( next_block_p != NULL )
|
||||
{
|
||||
pNextBlock->Neighbours[ MEM_DIRECTION_PREV ] = pBlock->Neighbours[ MEM_DIRECTION_PREV ];
|
||||
next_block_p->neighbours[ MEM_DIRECTION_PREV ] = block_p->neighbours[ MEM_DIRECTION_PREV ];
|
||||
} else
|
||||
{
|
||||
mem_heap.pLastBlock = pPrevBlock;
|
||||
mem_heap.last_block_p = prev_block_p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -405,48 +405,48 @@ mem_heap_free_block( uint8_t *ptr) /**< pointer to beginning of data space of th
|
||||
* @return recommended allocation size
|
||||
*/
|
||||
size_t
|
||||
mem_heap_recommend_allocation_size( size_t minimumAllocationSize) /**< minimum allocation size */
|
||||
mem_heap_recommend_allocation_size( size_t minimum_allocation_size) /**< minimum allocation size */
|
||||
{
|
||||
size_t minimumAllocationSizeWithBlockHeader = minimumAllocationSize + sizeof (mem_block_header_t);
|
||||
size_t heapChunkAlignedAllocationSize = JERRY_ALIGNUP( minimumAllocationSizeWithBlockHeader, MEM_HEAP_CHUNK_SIZE);
|
||||
size_t minimum_allocation_size_with_block_header = minimum_allocation_size + sizeof (mem_block_header_t);
|
||||
size_t heap_chunk_aligned_allocation_size = JERRY_ALIGNUP( minimum_allocation_size_with_block_header, MEM_HEAP_CHUNK_SIZE);
|
||||
|
||||
return heapChunkAlignedAllocationSize - sizeof (mem_block_header_t);
|
||||
return heap_chunk_aligned_allocation_size - sizeof (mem_block_header_t);
|
||||
} /* mem_heap_recommend_allocation_size */
|
||||
|
||||
/**
|
||||
* Print heap
|
||||
*/
|
||||
void
|
||||
mem_heap_print( bool dumpBlockData) /**< print block with data (true)
|
||||
mem_heap_print( bool dump_block_data) /**< print block with data (true)
|
||||
or print only block header (false) */
|
||||
{
|
||||
mem_check_heap();
|
||||
|
||||
__printf("Heap: start=%p size=%lu, first block->%p, last block->%p\n",
|
||||
mem_heap.HeapStart,
|
||||
mem_heap.HeapSize,
|
||||
(void*) mem_heap.pFirstBlock,
|
||||
(void*) mem_heap.pLastBlock);
|
||||
mem_heap.heap_start,
|
||||
mem_heap.heap_size,
|
||||
(void*) mem_heap.first_block_p,
|
||||
(void*) mem_heap.last_block_p);
|
||||
|
||||
for ( mem_block_header_t *pBlock = mem_heap.pFirstBlock;
|
||||
pBlock != NULL;
|
||||
pBlock = pBlock->Neighbours[ MEM_DIRECTION_NEXT ] )
|
||||
for ( mem_block_header_t *block_p = mem_heap.first_block_p;
|
||||
block_p != NULL;
|
||||
block_p = block_p->neighbours[ MEM_DIRECTION_NEXT ] )
|
||||
{
|
||||
__printf("Block (%p): magic num=0x%08x, size in chunks=%lu, previous block->%p next block->%p\n",
|
||||
(void*) pBlock,
|
||||
pBlock->MagicNum,
|
||||
mem_get_block_chunks_count( pBlock),
|
||||
(void*) pBlock->Neighbours[ MEM_DIRECTION_PREV ],
|
||||
(void*) pBlock->Neighbours[ MEM_DIRECTION_NEXT ]);
|
||||
(void*) block_p,
|
||||
block_p->magic_num,
|
||||
mem_get_block_chunks_count( block_p),
|
||||
(void*) block_p->neighbours[ MEM_DIRECTION_PREV ],
|
||||
(void*) block_p->neighbours[ MEM_DIRECTION_NEXT ]);
|
||||
|
||||
if ( dumpBlockData )
|
||||
if ( dump_block_data )
|
||||
{
|
||||
uint8_t *pBlockData = (uint8_t*) (pBlock + 1);
|
||||
uint8_t *block_data_p = (uint8_t*) (block_p + 1);
|
||||
for ( uint32_t offset = 0;
|
||||
offset < mem_get_block_data_space_size( pBlock);
|
||||
offset < mem_get_block_data_space_size( block_p);
|
||||
offset++ )
|
||||
{
|
||||
__printf("%02x ", pBlockData[ offset ]);
|
||||
__printf("%02x ", block_data_p[ offset ]);
|
||||
}
|
||||
__printf("\n");
|
||||
}
|
||||
@@ -486,31 +486,31 @@ static void
|
||||
mem_check_heap( void)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT( (uint8_t*) mem_heap.pFirstBlock == mem_heap.HeapStart );
|
||||
JERRY_ASSERT( mem_heap.HeapSize % MEM_HEAP_CHUNK_SIZE == 0 );
|
||||
JERRY_ASSERT( (uint8_t*) mem_heap.first_block_p == mem_heap.heap_start );
|
||||
JERRY_ASSERT( mem_heap.heap_size % MEM_HEAP_CHUNK_SIZE == 0 );
|
||||
|
||||
bool isLastBlockWasMet = false;
|
||||
for ( mem_block_header_t *pBlock = mem_heap.pFirstBlock;
|
||||
pBlock != NULL;
|
||||
pBlock = pBlock->Neighbours[ MEM_DIRECTION_NEXT ] )
|
||||
bool is_last_block_was_met = false;
|
||||
for ( mem_block_header_t *block_p = mem_heap.first_block_p;
|
||||
block_p != NULL;
|
||||
block_p = block_p->neighbours[ MEM_DIRECTION_NEXT ] )
|
||||
{
|
||||
JERRY_ASSERT( pBlock != NULL );
|
||||
JERRY_ASSERT( pBlock->MagicNum == MEM_MAGIC_NUM_OF_FREE_BLOCK
|
||||
|| pBlock->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
JERRY_ASSERT( block_p != NULL );
|
||||
JERRY_ASSERT( block_p->magic_num == MEM_MAGIC_NUM_OF_FREE_BLOCK
|
||||
|| block_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
|
||||
mem_block_header_t *pNextBlock = pBlock->Neighbours[ MEM_DIRECTION_NEXT ];
|
||||
if ( pBlock == mem_heap.pLastBlock )
|
||||
mem_block_header_t *next_block_p = block_p->neighbours[ MEM_DIRECTION_NEXT ];
|
||||
if ( block_p == mem_heap.last_block_p )
|
||||
{
|
||||
isLastBlockWasMet = true;
|
||||
is_last_block_was_met = true;
|
||||
|
||||
JERRY_ASSERT( pNextBlock == NULL );
|
||||
JERRY_ASSERT( next_block_p == NULL );
|
||||
} else
|
||||
{
|
||||
JERRY_ASSERT( pNextBlock != NULL );
|
||||
JERRY_ASSERT( next_block_p != NULL );
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT( isLastBlockWasMet );
|
||||
JERRY_ASSERT( is_last_block_was_met );
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
} /* mem_check_heap */
|
||||
|
||||
@@ -532,7 +532,7 @@ mem_heap_stat_init()
|
||||
{
|
||||
__memset( &mem_heap_stats, 0, sizeof (mem_heap_stats));
|
||||
|
||||
mem_heap_stats.size = mem_heap.HeapSize;
|
||||
mem_heap_stats.size = mem_heap.heap_size;
|
||||
mem_heap_stats.blocks = 1;
|
||||
} /* mem_InitStats */
|
||||
|
||||
@@ -542,7 +542,7 @@ mem_heap_stat_init()
|
||||
static void
|
||||
mem_heap_stat_alloc_block( mem_block_header_t *block_header_p) /**< allocated block */
|
||||
{
|
||||
JERRY_ASSERT( block_header_p->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
JERRY_ASSERT( block_header_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
|
||||
const size_t chunks = mem_get_block_chunks_count( block_header_p);
|
||||
const size_t bytes = block_header_p->allocated_bytes;
|
||||
@@ -584,7 +584,7 @@ mem_heap_stat_alloc_block( mem_block_header_t *block_header_p) /**< allocated bl
|
||||
static void
|
||||
mem_heap_stat_free_block( mem_block_header_t *block_header_p) /**< block to be freed */
|
||||
{
|
||||
JERRY_ASSERT( block_header_p->MagicNum == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
JERRY_ASSERT( block_header_p->magic_num == MEM_MAGIC_NUM_OF_ALLOCATED_BLOCK );
|
||||
|
||||
const size_t chunks = mem_get_block_chunks_count( block_header_p);
|
||||
const size_t bytes = block_header_p->allocated_bytes;
|
||||
|
||||
@@ -38,11 +38,11 @@ typedef enum {
|
||||
MEM_HEAP_ALLOC_LONG_TERM /**< allocated region most likely will not be freed soon */
|
||||
} mem_heap_alloc_term_t;
|
||||
|
||||
extern void mem_heap_init(uint8_t *heapStart, size_t heapSize);
|
||||
extern uint8_t* mem_heap_alloc_block(size_t sizeInBytes, mem_heap_alloc_term_t allocTerm);
|
||||
extern void mem_heap_init(uint8_t *heap_start, size_t heap_size);
|
||||
extern uint8_t* mem_heap_alloc_block(size_t size_in_bytes, mem_heap_alloc_term_t alloc_term);
|
||||
extern void mem_heap_free_block(uint8_t *ptr);
|
||||
extern size_t mem_heap_recommend_allocation_size(size_t minimumAllocationSize);
|
||||
extern void mem_heap_print(bool dumpBlockData);
|
||||
extern size_t mem_heap_recommend_allocation_size(size_t minimum_allocation_size);
|
||||
extern void mem_heap_print(bool dump_block_data);
|
||||
|
||||
#ifdef MEM_STATS
|
||||
/**
|
||||
|
||||
+92
-92
@@ -41,114 +41,114 @@ static const uint8_t mem_pool_free_chunk_magic_num = 0x71;
|
||||
*/
|
||||
static const mword_t mem_bitmap_bits_in_block = sizeof (mword_t) * JERRY_BITSINBYTE;
|
||||
|
||||
static void mem_check_pool( mem_pool_state_t *pPool);
|
||||
static void mem_check_pool( mem_pool_state_t *pool_p);
|
||||
|
||||
/**
|
||||
* Initialization of memory pool.
|
||||
*
|
||||
* Pool will be located in the segment [poolStart; poolStart + poolSize).
|
||||
* Pool will be located in the segment [pool_start; pool_start + pool_size).
|
||||
* Part of pool space will be used for bitmap and the rest will store chunks.
|
||||
*
|
||||
* Warning:
|
||||
* it is incorrect to suppose, that chunk number = poolSize / chunkSize.
|
||||
* it is incorrect to suppose, that chunk number = pool_size / chunk_size.
|
||||
*/
|
||||
void
|
||||
mem_pool_init(mem_pool_state_t *pPool, /**< pool */
|
||||
size_t chunkSize, /**< size of one chunk */
|
||||
uint8_t *poolStart, /**< start of pool space */
|
||||
size_t poolSize) /**< pool space size */
|
||||
mem_pool_init(mem_pool_state_t *pool_p, /**< pool */
|
||||
size_t chunk_size, /**< size of one chunk */
|
||||
uint8_t *pool_start, /**< start of pool space */
|
||||
size_t pool_size) /**< pool space size */
|
||||
{
|
||||
JERRY_ASSERT( pPool != NULL );
|
||||
JERRY_ASSERT( (uintptr_t) poolStart % MEM_ALIGNMENT == 0);
|
||||
JERRY_ASSERT( chunkSize % MEM_ALIGNMENT == 0 );
|
||||
JERRY_ASSERT( pool_p != NULL );
|
||||
JERRY_ASSERT( (uintptr_t) pool_start % MEM_ALIGNMENT == 0);
|
||||
JERRY_ASSERT( chunk_size % MEM_ALIGNMENT == 0 );
|
||||
|
||||
pPool->pPoolStart = poolStart;
|
||||
pPool->PoolSize = poolSize;
|
||||
pPool->ChunkSize = chunkSize;
|
||||
pool_p->pool_start_p = pool_start;
|
||||
pool_p->pool_size = pool_size;
|
||||
pool_p->chunk_size = chunk_size;
|
||||
|
||||
const size_t bitsInByte = JERRY_BITSINBYTE;
|
||||
const size_t bitmapAreaSizeAlignment = JERRY_MAX( sizeof (mword_t), MEM_ALIGNMENT);
|
||||
const size_t bits_in_byte = JERRY_BITSINBYTE;
|
||||
const size_t bitmap_area_size_alignment = JERRY_MAX( sizeof (mword_t), MEM_ALIGNMENT);
|
||||
|
||||
/*
|
||||
* Calculation chunks number
|
||||
*/
|
||||
|
||||
size_t bitmapAreaSize = 0;
|
||||
size_t chunksAreaSize = JERRY_ALIGNDOWN( poolSize - bitmapAreaSize, chunkSize);
|
||||
size_t chunksNumber = chunksAreaSize / chunkSize;
|
||||
size_t bitmap_area_size = 0;
|
||||
size_t chunks_area_size = JERRY_ALIGNDOWN( pool_size - bitmap_area_size, chunk_size);
|
||||
size_t chunks_number = chunks_area_size / chunk_size;
|
||||
|
||||
/* while there is not enough area to hold state of all chunks*/
|
||||
while ( bitmapAreaSize * bitsInByte < chunksNumber )
|
||||
while ( bitmap_area_size * bits_in_byte < chunks_number )
|
||||
{
|
||||
JERRY_ASSERT( bitmapAreaSize + chunksAreaSize <= poolSize );
|
||||
JERRY_ASSERT( bitmap_area_size + chunks_area_size <= pool_size );
|
||||
|
||||
/* correct bitmap area's size and, accordingly, chunks' area's size*/
|
||||
|
||||
size_t newBitmapAreaSize = bitmapAreaSize + bitmapAreaSizeAlignment;
|
||||
size_t newChunksAreaSize = JERRY_ALIGNDOWN( poolSize - newBitmapAreaSize, chunkSize);
|
||||
size_t newChunksNumber = newChunksAreaSize / chunkSize;
|
||||
size_t new_bitmap_area_size = bitmap_area_size + bitmap_area_size_alignment;
|
||||
size_t new_chunks_area_size = JERRY_ALIGNDOWN( pool_size - new_bitmap_area_size, chunk_size);
|
||||
size_t new_chunks_number = new_chunks_area_size / chunk_size;
|
||||
|
||||
bitmapAreaSize = newBitmapAreaSize;
|
||||
chunksAreaSize = newChunksAreaSize;
|
||||
chunksNumber = newChunksNumber;
|
||||
bitmap_area_size = new_bitmap_area_size;
|
||||
chunks_area_size = new_chunks_area_size;
|
||||
chunks_number = new_chunks_number;
|
||||
}
|
||||
|
||||
/*
|
||||
* Final calculation checks
|
||||
*/
|
||||
JERRY_ASSERT( bitmapAreaSize * bitsInByte >= chunksNumber );
|
||||
JERRY_ASSERT( chunksAreaSize >= chunksNumber * chunkSize );
|
||||
JERRY_ASSERT( bitmapAreaSize + chunksAreaSize <= poolSize );
|
||||
JERRY_ASSERT( bitmap_area_size * bits_in_byte >= chunks_number );
|
||||
JERRY_ASSERT( chunks_area_size >= chunks_number * chunk_size );
|
||||
JERRY_ASSERT( bitmap_area_size + chunks_area_size <= pool_size );
|
||||
|
||||
pPool->pBitmap = (mword_t*) poolStart;
|
||||
pPool->pChunks = poolStart + bitmapAreaSize;
|
||||
pool_p->bitmap_p = (mword_t*) pool_start;
|
||||
pool_p->chunks_p = pool_start + bitmap_area_size;
|
||||
|
||||
JERRY_ASSERT( (uintptr_t) pPool->pChunks % MEM_ALIGNMENT == 0 );
|
||||
JERRY_ASSERT( (uintptr_t) pool_p->chunks_p % MEM_ALIGNMENT == 0 );
|
||||
|
||||
pPool->ChunksNumber = chunksNumber;
|
||||
pool_p->chunks_number = chunks_number;
|
||||
|
||||
/*
|
||||
* All chunks are free right after initialization
|
||||
*/
|
||||
pPool->FreeChunksNumber = chunksNumber;
|
||||
__memset( pPool->pBitmap, 0, bitmapAreaSize);
|
||||
pool_p->free_chunks_number = chunks_number;
|
||||
__memset( pool_p->bitmap_p, 0, bitmap_area_size);
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
__memset( pPool->pChunks, mem_pool_free_chunk_magic_num, chunksAreaSize);
|
||||
__memset( pool_p->chunks_p, mem_pool_free_chunk_magic_num, chunks_area_size);
|
||||
#endif /* JERRY_NDEBUG */
|
||||
|
||||
mem_check_pool( pPool);
|
||||
mem_check_pool( pool_p);
|
||||
} /* mem_pool_init */
|
||||
|
||||
/**
|
||||
* Allocate a chunk in the pool
|
||||
*/
|
||||
uint8_t*
|
||||
mem_pool_alloc_chunk(mem_pool_state_t *pPool) /**< pool */
|
||||
mem_pool_alloc_chunk(mem_pool_state_t *pool_p) /**< pool */
|
||||
{
|
||||
mem_check_pool( pPool);
|
||||
mem_check_pool( pool_p);
|
||||
|
||||
if ( pPool->FreeChunksNumber == 0 )
|
||||
if ( pool_p->free_chunks_number == 0 )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
size_t chunkIndex = 0;
|
||||
size_t bitmapBlockIndex = 0;
|
||||
size_t chunk_index = 0;
|
||||
size_t bitmap_block_index = 0;
|
||||
|
||||
while ( chunkIndex < pPool->ChunksNumber )
|
||||
while ( chunk_index < pool_p->chunks_number )
|
||||
{
|
||||
if ( ~pPool->pBitmap[ bitmapBlockIndex ] != 0 )
|
||||
if ( ~pool_p->bitmap_p[ bitmap_block_index ] != 0 )
|
||||
{
|
||||
break;
|
||||
} else
|
||||
{
|
||||
bitmapBlockIndex++;
|
||||
chunkIndex += mem_bitmap_bits_in_block;
|
||||
bitmap_block_index++;
|
||||
chunk_index += mem_bitmap_bits_in_block;
|
||||
}
|
||||
}
|
||||
|
||||
if ( chunkIndex >= pPool->ChunksNumber )
|
||||
if ( chunk_index >= pool_p->chunks_number )
|
||||
{
|
||||
/* no free chunks */
|
||||
return NULL;
|
||||
@@ -157,21 +157,21 @@ mem_pool_alloc_chunk(mem_pool_state_t *pPool) /**< pool */
|
||||
/* found bitmap block with a zero bit */
|
||||
|
||||
mword_t bit = 1;
|
||||
for ( size_t bitIndex = 0;
|
||||
bitIndex < mem_bitmap_bits_in_block && chunkIndex < pPool->ChunksNumber;
|
||||
bitIndex++, chunkIndex++, bit <<= 1 )
|
||||
for ( size_t bit_index = 0;
|
||||
bit_index < mem_bitmap_bits_in_block && chunk_index < pool_p->chunks_number;
|
||||
bit_index++, chunk_index++, bit <<= 1 )
|
||||
{
|
||||
if ( ~pPool->pBitmap[ bitmapBlockIndex ] & bit )
|
||||
if ( ~pool_p->bitmap_p[ bitmap_block_index ] & bit )
|
||||
{
|
||||
/* found free chunk */
|
||||
pPool->pBitmap[ bitmapBlockIndex ] |= bit;
|
||||
pool_p->bitmap_p[ bitmap_block_index ] |= bit;
|
||||
|
||||
uint8_t *pChunk = &pPool->pChunks[ chunkIndex * pPool->ChunkSize ];
|
||||
pPool->FreeChunksNumber--;
|
||||
uint8_t *chunk_p = &pool_p->chunks_p[ chunk_index * pool_p->chunk_size ];
|
||||
pool_p->free_chunks_number--;
|
||||
|
||||
mem_check_pool( pPool);
|
||||
mem_check_pool( pool_p);
|
||||
|
||||
return pChunk;
|
||||
return chunk_p;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,71 +183,71 @@ mem_pool_alloc_chunk(mem_pool_state_t *pPool) /**< pool */
|
||||
* Free the chunk in the pool
|
||||
*/
|
||||
void
|
||||
mem_pool_free_chunk(mem_pool_state_t *pPool, /**< pool */
|
||||
uint8_t *pChunk) /**< chunk pointer */
|
||||
mem_pool_free_chunk(mem_pool_state_t *pool_p, /**< pool */
|
||||
uint8_t *chunk_p) /**< chunk pointer */
|
||||
{
|
||||
JERRY_ASSERT( pPool->FreeChunksNumber < pPool->ChunksNumber );
|
||||
JERRY_ASSERT( pChunk >= pPool->pChunks && pChunk <= pPool->pChunks + pPool->ChunksNumber * pPool->ChunkSize );
|
||||
JERRY_ASSERT( ( (uintptr_t) pChunk - (uintptr_t) pPool->pChunks ) % pPool->ChunkSize == 0 );
|
||||
JERRY_ASSERT( pool_p->free_chunks_number < pool_p->chunks_number );
|
||||
JERRY_ASSERT( chunk_p >= pool_p->chunks_p && chunk_p <= pool_p->chunks_p + pool_p->chunks_number * pool_p->chunk_size );
|
||||
JERRY_ASSERT( ( (uintptr_t) chunk_p - (uintptr_t) pool_p->chunks_p ) % pool_p->chunk_size == 0 );
|
||||
|
||||
mem_check_pool( pPool);
|
||||
mem_check_pool( pool_p);
|
||||
|
||||
size_t chunkIndex = (size_t) (pChunk - pPool->pChunks) / pPool->ChunkSize;
|
||||
size_t bitmapBlockIndex = chunkIndex / mem_bitmap_bits_in_block;
|
||||
size_t bitmapBitInBlock = chunkIndex % mem_bitmap_bits_in_block;
|
||||
mword_t bitMask = ( 1lu << bitmapBitInBlock );
|
||||
size_t chunk_index = (size_t) (chunk_p - pool_p->chunks_p) / pool_p->chunk_size;
|
||||
size_t bitmap_block_index = chunk_index / mem_bitmap_bits_in_block;
|
||||
size_t bitmap_bit_in_block = chunk_index % mem_bitmap_bits_in_block;
|
||||
mword_t bit_mask = ( 1lu << bitmap_bit_in_block );
|
||||
|
||||
#ifndef JERRY_NDEBUG
|
||||
__memset( (uint8_t*) pChunk, mem_pool_free_chunk_magic_num, pPool->ChunkSize);
|
||||
__memset( (uint8_t*) chunk_p, mem_pool_free_chunk_magic_num, pool_p->chunk_size);
|
||||
#endif /* JERRY_NDEBUG */
|
||||
JERRY_ASSERT( pPool->pBitmap[ bitmapBlockIndex ] & bitMask );
|
||||
JERRY_ASSERT( pool_p->bitmap_p[ bitmap_block_index ] & bit_mask );
|
||||
|
||||
pPool->pBitmap[ bitmapBlockIndex ] &= ~bitMask;
|
||||
pPool->FreeChunksNumber++;
|
||||
pool_p->bitmap_p[ bitmap_block_index ] &= ~bit_mask;
|
||||
pool_p->free_chunks_number++;
|
||||
|
||||
mem_check_pool( pPool);
|
||||
mem_check_pool( pool_p);
|
||||
} /* mem_pool_free_chunk */
|
||||
|
||||
/**
|
||||
* Check pool state consistency
|
||||
*/
|
||||
static void
|
||||
mem_check_pool( mem_pool_state_t __unused *pPool) /**< pool (unused #ifdef JERRY_NDEBUG) */
|
||||
mem_check_pool( mem_pool_state_t __unused *pool_p) /**< pool (unused #ifdef JERRY_NDEBUG) */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
JERRY_ASSERT( pPool->ChunksNumber != 0 );
|
||||
JERRY_ASSERT( pPool->FreeChunksNumber <= pPool->ChunksNumber );
|
||||
JERRY_ASSERT( (uint8_t*) pPool->pBitmap == pPool->pPoolStart );
|
||||
JERRY_ASSERT( (uint8_t*) pPool->pChunks > pPool->pPoolStart );
|
||||
JERRY_ASSERT( pool_p->chunks_number != 0 );
|
||||
JERRY_ASSERT( pool_p->free_chunks_number <= pool_p->chunks_number );
|
||||
JERRY_ASSERT( (uint8_t*) pool_p->bitmap_p == pool_p->pool_start_p );
|
||||
JERRY_ASSERT( (uint8_t*) pool_p->chunks_p > pool_p->pool_start_p );
|
||||
|
||||
uint8_t freeChunkTemplate[ pPool->ChunkSize ];
|
||||
__memset( &freeChunkTemplate, mem_pool_free_chunk_magic_num, sizeof (freeChunkTemplate));
|
||||
uint8_t free_chunk_template[ pool_p->chunk_size ];
|
||||
__memset( &free_chunk_template, mem_pool_free_chunk_magic_num, sizeof (free_chunk_template));
|
||||
|
||||
size_t metFreeChunksNumber = 0;
|
||||
size_t met_free_chunks_number = 0;
|
||||
|
||||
for ( size_t chunkIndex = 0, bitmapBlockIndex = 0;
|
||||
chunkIndex < pPool->ChunksNumber;
|
||||
bitmapBlockIndex++ )
|
||||
for ( size_t chunk_index = 0, bitmap_block_index = 0;
|
||||
chunk_index < pool_p->chunks_number;
|
||||
bitmap_block_index++ )
|
||||
{
|
||||
JERRY_ASSERT( (uint8_t*) & pPool->pBitmap[ bitmapBlockIndex ] < pPool->pChunks );
|
||||
JERRY_ASSERT( (uint8_t*) & pool_p->bitmap_p[ bitmap_block_index ] < pool_p->chunks_p );
|
||||
|
||||
mword_t bitmapBlock = pPool->pBitmap[ bitmapBlockIndex ];
|
||||
mword_t bitmap_block = pool_p->bitmap_p[ bitmap_block_index ];
|
||||
|
||||
mword_t bitMask = 1;
|
||||
for ( size_t bitmapBitInBlock = 0;
|
||||
chunkIndex < pPool->ChunksNumber && bitmapBitInBlock < mem_bitmap_bits_in_block;
|
||||
bitmapBitInBlock++, bitMask <<= 1, chunkIndex++ )
|
||||
mword_t bit_mask = 1;
|
||||
for ( size_t bitmap_bit_in_block = 0;
|
||||
chunk_index < pool_p->chunks_number && bitmap_bit_in_block < mem_bitmap_bits_in_block;
|
||||
bitmap_bit_in_block++, bit_mask <<= 1, chunk_index++ )
|
||||
{
|
||||
if ( ~bitmapBlock & bitMask )
|
||||
if ( ~bitmap_block & bit_mask )
|
||||
{
|
||||
metFreeChunksNumber++;
|
||||
met_free_chunks_number++;
|
||||
|
||||
JERRY_ASSERT( __memcmp( &pPool->pChunks[ chunkIndex * pPool->ChunkSize ], freeChunkTemplate, pPool->ChunkSize) == 0 );
|
||||
JERRY_ASSERT( __memcmp( &pool_p->chunks_p[ chunk_index * pool_p->chunk_size ], free_chunk_template, pool_p->chunk_size) == 0 );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT( metFreeChunksNumber == pPool->FreeChunksNumber );
|
||||
JERRY_ASSERT( met_free_chunks_number == pool_p->free_chunks_number );
|
||||
#endif /* !JERRY_NDEBUG */
|
||||
} /* mem_check_pool */
|
||||
|
||||
|
||||
+11
-11
@@ -31,23 +31,23 @@
|
||||
* Compact the struct
|
||||
*/
|
||||
typedef struct mem_pool_state_t {
|
||||
uint8_t *pPoolStart; /**< first address of pool space */
|
||||
size_t PoolSize; /**< pool space size */
|
||||
uint8_t *pool_start_p; /**< first address of pool space */
|
||||
size_t pool_size; /**< pool space size */
|
||||
|
||||
size_t ChunkSize; /**< size of one chunk */
|
||||
size_t chunk_size; /**< size of one chunk */
|
||||
|
||||
mword_t *pBitmap; /**< bitmap - pool chunks' state */
|
||||
uint8_t *pChunks; /**< chunks with data */
|
||||
mword_t *bitmap_p; /**< bitmap - pool chunks' state */
|
||||
uint8_t *chunks_p; /**< chunks with data */
|
||||
|
||||
size_t ChunksNumber; /**< number of chunks */
|
||||
size_t FreeChunksNumber; /**< number of free chunks */
|
||||
size_t chunks_number; /**< number of chunks */
|
||||
size_t free_chunks_number; /**< number of free chunks */
|
||||
|
||||
struct mem_pool_state_t *pNextPool; /**< pointer to the next pool with same chunk size */
|
||||
struct mem_pool_state_t *next_pool_p; /**< pointer to the next pool with same chunk size */
|
||||
} mem_pool_state_t;
|
||||
|
||||
extern void mem_pool_init(mem_pool_state_t *pPool, size_t chunkSize, uint8_t *poolStart, size_t poolSize);
|
||||
extern uint8_t* mem_pool_alloc_chunk(mem_pool_state_t *pPool);
|
||||
extern void mem_pool_free_chunk(mem_pool_state_t *pPool, uint8_t *pChunk);
|
||||
extern void mem_pool_init(mem_pool_state_t *pool_p, size_t chunk_size, uint8_t *pool_start, size_t pool_size);
|
||||
extern uint8_t* mem_pool_alloc_chunk(mem_pool_state_t *pool_p);
|
||||
extern void mem_pool_free_chunk(mem_pool_state_t *pool_p, uint8_t *chunk_p);
|
||||
|
||||
#endif /* JERRY_MEM_POOL_H */
|
||||
|
||||
|
||||
@@ -78,13 +78,13 @@ static void mem_pools_stat_free_chunk( mem_pool_chunk_type_t);
|
||||
* @return size (in bytes) of chunk of specified type
|
||||
*/
|
||||
size_t
|
||||
mem_get_chunk_size( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_get_chunk_size( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
uint32_t chunkTypeId = (uint32_t) chunkType;
|
||||
uint32_t chunk_type_id = (uint32_t) chunk_type;
|
||||
|
||||
JERRY_ASSERT( chunkTypeId < MEM_POOL_CHUNK_TYPE__COUNT );
|
||||
JERRY_ASSERT( chunk_type_id < MEM_POOL_CHUNK_TYPE__COUNT );
|
||||
|
||||
return ( 1u << ( chunkTypeId + 2 ) );
|
||||
return ( 1u << ( chunk_type_id + 2 ) );
|
||||
} /* mem_get_chunk_size */
|
||||
|
||||
/**
|
||||
@@ -104,20 +104,20 @@ mem_pools_init(void)
|
||||
*
|
||||
* TODO: Research.
|
||||
*/
|
||||
size_t poolSpaceSize = mem_heap_recommend_allocation_size( 4 * sizeof (mem_pool_state_t) + sizeof (mword_t) );
|
||||
size_t pool_space_size = mem_heap_recommend_allocation_size( 4 * sizeof (mem_pool_state_t) + sizeof (mword_t) );
|
||||
|
||||
mem_space_for_pool_for_pool_headers = mem_heap_alloc_block(poolSpaceSize,
|
||||
mem_space_for_pool_for_pool_headers = mem_heap_alloc_block(pool_space_size,
|
||||
MEM_HEAP_ALLOC_LONG_TERM);
|
||||
|
||||
/*
|
||||
* Get chunk type, checking that there is a type corresponding to specified size.
|
||||
*/
|
||||
const mem_pool_chunk_type_t chunkType = mem_size_to_pool_chunk_type( sizeof(mem_pool_state_t));
|
||||
const mem_pool_chunk_type_t chunk_type = mem_size_to_pool_chunk_type( sizeof(mem_pool_state_t));
|
||||
|
||||
mem_pool_init(&mem_pool_for_pool_headers,
|
||||
mem_get_chunk_size( chunkType),
|
||||
mem_get_chunk_size( chunk_type),
|
||||
mem_space_for_pool_for_pool_headers,
|
||||
poolSpaceSize);
|
||||
pool_space_size);
|
||||
|
||||
mem_pools_stat_init();
|
||||
} /* mem_pools_init */
|
||||
@@ -129,18 +129,18 @@ mem_pools_init(void)
|
||||
* or NULL - if not enough memory.
|
||||
*/
|
||||
uint8_t*
|
||||
mem_pools_alloc( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_pools_alloc( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
size_t chunkSize = mem_get_chunk_size( chunkType);
|
||||
size_t chunk_size = mem_get_chunk_size( chunk_type);
|
||||
|
||||
/**
|
||||
* If there are no free chunks, allocate new pool.
|
||||
*/
|
||||
if ( mem_free_chunks_number[ chunkType ] == 0 )
|
||||
if ( mem_free_chunks_number[ chunk_type ] == 0 )
|
||||
{
|
||||
mem_pool_state_t *poolState = (mem_pool_state_t*) mem_pool_alloc_chunk( &mem_pool_for_pool_headers);
|
||||
mem_pool_state_t *pool_state = (mem_pool_state_t*) mem_pool_alloc_chunk( &mem_pool_for_pool_headers);
|
||||
|
||||
if ( poolState == NULL )
|
||||
if ( pool_state == NULL )
|
||||
{
|
||||
/**
|
||||
* Not enough space for new pool' header.
|
||||
@@ -153,12 +153,12 @@ mem_pools_alloc( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
*
|
||||
* TODO: Research.
|
||||
*/
|
||||
size_t poolSpaceSize = mem_heap_recommend_allocation_size( 8 * chunkSize + sizeof (mword_t) );
|
||||
size_t pool_space_size = mem_heap_recommend_allocation_size( 8 * chunk_size + sizeof (mword_t) );
|
||||
|
||||
uint8_t *poolSpace = mem_heap_alloc_block( poolSpaceSize,
|
||||
uint8_t *pool_space = mem_heap_alloc_block( pool_space_size,
|
||||
MEM_HEAP_ALLOC_LONG_TERM);
|
||||
|
||||
if ( poolSpace == NULL )
|
||||
if ( pool_space == NULL )
|
||||
{
|
||||
/**
|
||||
* Not enough memory.
|
||||
@@ -166,17 +166,17 @@ mem_pools_alloc( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
return NULL;
|
||||
}
|
||||
|
||||
mem_pool_init( poolState,
|
||||
chunkSize,
|
||||
poolSpace,
|
||||
poolSpaceSize);
|
||||
mem_pool_init( pool_state,
|
||||
chunk_size,
|
||||
pool_space,
|
||||
pool_space_size);
|
||||
|
||||
poolState->pNextPool = mem_pools[ chunkType ];
|
||||
mem_pools[ chunkType ] = poolState;
|
||||
pool_state->next_pool_p = mem_pools[ chunk_type ];
|
||||
mem_pools[ chunk_type ] = pool_state;
|
||||
|
||||
mem_free_chunks_number[ chunkType ] += poolState->FreeChunksNumber;
|
||||
mem_free_chunks_number[ chunk_type ] += pool_state->free_chunks_number;
|
||||
|
||||
mem_pools_stat_alloc_pool( chunkType);
|
||||
mem_pools_stat_alloc_pool( chunk_type);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,74 +184,74 @@ mem_pools_alloc( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
*
|
||||
* Search for the pool.
|
||||
*/
|
||||
mem_pool_state_t *poolState = mem_pools[ chunkType ];
|
||||
mem_pool_state_t *pool_state = mem_pools[ chunk_type ];
|
||||
|
||||
while ( poolState->FreeChunksNumber == 0 )
|
||||
while ( pool_state->free_chunks_number == 0 )
|
||||
{
|
||||
poolState = poolState->pNextPool;
|
||||
pool_state = pool_state->next_pool_p;
|
||||
|
||||
JERRY_ASSERT( poolState != NULL );
|
||||
JERRY_ASSERT( pool_state != NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
* And allocate chunk within it.
|
||||
*/
|
||||
mem_free_chunks_number[ chunkType ]--;
|
||||
mem_free_chunks_number[ chunk_type ]--;
|
||||
|
||||
mem_pools_stat_alloc_chunk( chunkType);
|
||||
mem_pools_stat_alloc_chunk( chunk_type);
|
||||
|
||||
return mem_pool_alloc_chunk( poolState);
|
||||
return mem_pool_alloc_chunk( pool_state);
|
||||
} /* mem_pools_alloc */
|
||||
|
||||
/**
|
||||
* Free the chunk
|
||||
*/
|
||||
void
|
||||
mem_pools_free( mem_pool_chunk_type_t chunkType, /**< the chunk type */
|
||||
uint8_t *pChunk) /**< pointer to the chunk */
|
||||
mem_pools_free(mem_pool_chunk_type_t chunk_type, /**< the chunk type */
|
||||
uint8_t *chunk_p) /**< pointer to the chunk */
|
||||
{
|
||||
mem_pool_state_t *poolState = mem_pools[ chunkType ], *prevPoolState = NULL;
|
||||
mem_pool_state_t *pool_state = mem_pools[ chunk_type ], *prev_pool_state = NULL;
|
||||
|
||||
/**
|
||||
* Search for the pool containing specified chunk.
|
||||
*/
|
||||
while ( !( pChunk >= poolState->pChunks
|
||||
&& pChunk <= poolState->pPoolStart + poolState->PoolSize ) )
|
||||
while ( !( chunk_p >= pool_state->chunks_p
|
||||
&& chunk_p <= pool_state->pool_start_p + pool_state->pool_size ) )
|
||||
{
|
||||
prevPoolState = poolState;
|
||||
poolState = poolState->pNextPool;
|
||||
prev_pool_state = pool_state;
|
||||
pool_state = pool_state->next_pool_p;
|
||||
|
||||
JERRY_ASSERT( poolState != NULL );
|
||||
JERRY_ASSERT( pool_state != NULL );
|
||||
}
|
||||
|
||||
/**
|
||||
* Free the chunk
|
||||
*/
|
||||
mem_pool_free_chunk( poolState, pChunk);
|
||||
mem_free_chunks_number[ chunkType ]++;
|
||||
mem_pool_free_chunk( pool_state, chunk_p);
|
||||
mem_free_chunks_number[ chunk_type ]++;
|
||||
|
||||
mem_pools_stat_free_chunk( chunkType);
|
||||
mem_pools_stat_free_chunk( chunk_type);
|
||||
|
||||
/**
|
||||
* If all chunks of the pool are free, free the pool itself.
|
||||
*/
|
||||
if ( poolState->FreeChunksNumber == poolState->ChunksNumber )
|
||||
if ( pool_state->free_chunks_number == pool_state->chunks_number )
|
||||
{
|
||||
if ( prevPoolState != NULL )
|
||||
if ( prev_pool_state != NULL )
|
||||
{
|
||||
prevPoolState->pNextPool = poolState->pNextPool;
|
||||
prev_pool_state->next_pool_p = pool_state->next_pool_p;
|
||||
} else
|
||||
{
|
||||
mem_pools[ chunkType ] = poolState->pNextPool;
|
||||
mem_pools[ chunk_type ] = pool_state->next_pool_p;
|
||||
}
|
||||
|
||||
mem_free_chunks_number[ chunkType ] -= poolState->ChunksNumber;
|
||||
mem_free_chunks_number[ chunk_type ] -= pool_state->chunks_number;
|
||||
|
||||
mem_heap_free_block( poolState->pPoolStart);
|
||||
mem_heap_free_block( pool_state->pool_start_p);
|
||||
|
||||
mem_pool_free_chunk( &mem_pool_for_pool_headers, (uint8_t*) poolState);
|
||||
mem_pool_free_chunk( &mem_pool_for_pool_headers, (uint8_t*) pool_state);
|
||||
|
||||
mem_pools_stat_free_pool( chunkType);
|
||||
mem_pools_stat_free_pool( chunk_type);
|
||||
}
|
||||
} /* mem_pools_free */
|
||||
|
||||
@@ -280,14 +280,14 @@ mem_pools_stat_init( void)
|
||||
* Account allocation of a pool
|
||||
*/
|
||||
static void
|
||||
mem_pools_stat_alloc_pool( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_pools_stat_alloc_pool( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
mem_pools_stats.pools_count[ chunkType ]++;
|
||||
mem_pools_stats.free_chunks[ chunkType ] = mem_free_chunks_number[ chunkType ];
|
||||
mem_pools_stats.pools_count[ chunk_type ]++;
|
||||
mem_pools_stats.free_chunks[ chunk_type ] = mem_free_chunks_number[ chunk_type ];
|
||||
|
||||
if ( mem_pools_stats.pools_count[ chunkType ] > mem_pools_stats.peak_pools_count[ chunkType ] )
|
||||
if ( mem_pools_stats.pools_count[ chunk_type ] > mem_pools_stats.peak_pools_count[ chunk_type ] )
|
||||
{
|
||||
mem_pools_stats.peak_pools_count[ chunkType ] = mem_pools_stats.pools_count[ chunkType ];
|
||||
mem_pools_stats.peak_pools_count[ chunk_type ] = mem_pools_stats.pools_count[ chunk_type ];
|
||||
}
|
||||
} /* mem_pools_stat_alloc_pool */
|
||||
|
||||
@@ -295,28 +295,28 @@ mem_pools_stat_alloc_pool( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
* Account freeing of a pool
|
||||
*/
|
||||
static void
|
||||
mem_pools_stat_free_pool( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_pools_stat_free_pool( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
JERRY_ASSERT( mem_pools_stats.pools_count[ chunkType ] > 0 );
|
||||
JERRY_ASSERT( mem_pools_stats.pools_count[ chunk_type ] > 0 );
|
||||
|
||||
mem_pools_stats.pools_count[ chunkType ]--;
|
||||
mem_pools_stats.free_chunks[ chunkType ] = mem_free_chunks_number[ chunkType ];
|
||||
mem_pools_stats.pools_count[ chunk_type ]--;
|
||||
mem_pools_stats.free_chunks[ chunk_type ] = mem_free_chunks_number[ chunk_type ];
|
||||
} /* mem_pools_stat_free_pool */
|
||||
|
||||
/**
|
||||
* Account allocation of chunk in a pool
|
||||
*/
|
||||
static void
|
||||
mem_pools_stat_alloc_chunk( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_pools_stat_alloc_chunk( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
JERRY_ASSERT( mem_pools_stats.free_chunks[ chunkType ] > 0 );
|
||||
JERRY_ASSERT( mem_pools_stats.free_chunks[ chunk_type ] > 0 );
|
||||
|
||||
mem_pools_stats.allocated_chunks[ chunkType ]++;
|
||||
mem_pools_stats.free_chunks[ chunkType ]--;
|
||||
mem_pools_stats.allocated_chunks[ chunk_type ]++;
|
||||
mem_pools_stats.free_chunks[ chunk_type ]--;
|
||||
|
||||
if ( mem_pools_stats.allocated_chunks[ chunkType ] > mem_pools_stats.peak_allocated_chunks[ chunkType ] )
|
||||
if ( mem_pools_stats.allocated_chunks[ chunk_type ] > mem_pools_stats.peak_allocated_chunks[ chunk_type ] )
|
||||
{
|
||||
mem_pools_stats.peak_allocated_chunks[ chunkType ] = mem_pools_stats.allocated_chunks[ chunkType ];
|
||||
mem_pools_stats.peak_allocated_chunks[ chunk_type ] = mem_pools_stats.allocated_chunks[ chunk_type ];
|
||||
}
|
||||
} /* mem_pools_stat_alloc_chunk */
|
||||
|
||||
@@ -324,12 +324,12 @@ mem_pools_stat_alloc_chunk( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
* Account freeing of chunk in a pool
|
||||
*/
|
||||
static void
|
||||
mem_pools_stat_free_chunk( mem_pool_chunk_type_t chunkType) /**< chunk type */
|
||||
mem_pools_stat_free_chunk( mem_pool_chunk_type_t chunk_type) /**< chunk type */
|
||||
{
|
||||
JERRY_ASSERT( mem_pools_stats.allocated_chunks[ chunkType ] > 0 );
|
||||
JERRY_ASSERT( mem_pools_stats.allocated_chunks[ chunk_type ] > 0 );
|
||||
|
||||
mem_pools_stats.allocated_chunks[ chunkType ]--;
|
||||
mem_pools_stats.free_chunks[ chunkType ]++;
|
||||
mem_pools_stats.allocated_chunks[ chunk_type ]--;
|
||||
mem_pools_stats.free_chunks[ chunk_type ]++;
|
||||
} /* mem_pools_stat_free_chunk */
|
||||
#endif /* MEM_STATS */
|
||||
|
||||
|
||||
@@ -51,11 +51,11 @@ typedef enum {
|
||||
((size) == 64 ? MEM_POOL_CHUNK_TYPE_64 : \
|
||||
jerry_unreferenced_expression)))))
|
||||
|
||||
extern size_t mem_get_chunk_size( mem_pool_chunk_type_t chunkType);
|
||||
extern size_t mem_get_chunk_size( mem_pool_chunk_type_t chunk_type);
|
||||
|
||||
extern void mem_pools_init(void);
|
||||
extern uint8_t* mem_pools_alloc(mem_pool_chunk_type_t chunkType);
|
||||
extern void mem_pools_free(mem_pool_chunk_type_t chunkType, uint8_t *pChunk);
|
||||
extern uint8_t* mem_pools_alloc(mem_pool_chunk_type_t chunk_type);
|
||||
extern void mem_pools_free(mem_pool_chunk_type_t chunk_type, uint8_t *chunk_p);
|
||||
|
||||
#ifdef MEM_STATS
|
||||
/**
|
||||
|
||||
@@ -166,9 +166,9 @@ do_strict_eval_arguments_check( ecma_reference_t ref) /**< ECMA-reference */
|
||||
return ( ref.is_strict
|
||||
&& ( __strcmp( (char*)ref.referenced_name_p, "eval") == 0
|
||||
|| __strcmp( (char*)ref.referenced_name_p, "arguments") == 0 )
|
||||
&& ( ref.base.ValueType == ECMA_TYPE_OBJECT )
|
||||
&& ( ecma_get_pointer( ref.base.Value) != NULL )
|
||||
&& ( ( (ecma_object_t*) ecma_get_pointer( ref.base.Value) )->IsLexicalEnvironment ) );
|
||||
&& ( ref.base.value_type == ECMA_TYPE_OBJECT )
|
||||
&& ( ecma_get_pointer( ref.base.value) != NULL )
|
||||
&& ( ( (ecma_object_t*) ecma_get_pointer( ref.base.value) )->is_lexical_environment ) );
|
||||
} /* do_strict_eval_arguments_check */
|
||||
|
||||
/**
|
||||
@@ -279,8 +279,8 @@ do_number_arithmetic(struct __int_data *int_data, /**< interpreter context */
|
||||
TRY_CATCH(num_right_value, ecma_op_to_number( right_value), ret_value);
|
||||
|
||||
ecma_number_t *left_p, *right_p, *res_p;
|
||||
left_p = (ecma_number_t*)ecma_get_pointer( num_left_value.value.Value);
|
||||
right_p = (ecma_number_t*)ecma_get_pointer( num_right_value.value.Value);
|
||||
left_p = (ecma_number_t*)ecma_get_pointer( num_left_value.value.value);
|
||||
right_p = (ecma_number_t*)ecma_get_pointer( num_right_value.value.value);
|
||||
|
||||
res_p = ecma_alloc_number();
|
||||
|
||||
@@ -562,8 +562,8 @@ opfunc_addition(OPCODE opdata, /**< operation data */
|
||||
TRY_CATCH(prim_left_value, ecma_op_to_primitive( left_value.value), ret_value);
|
||||
TRY_CATCH(prim_right_value, ecma_op_to_primitive( right_value.value), ret_value);
|
||||
|
||||
if ( prim_left_value.value.ValueType == ECMA_TYPE_STRING
|
||||
|| prim_right_value.value.ValueType == ECMA_TYPE_STRING )
|
||||
if ( prim_left_value.value.value_type == ECMA_TYPE_STRING
|
||||
|| prim_right_value.value.value_type == ECMA_TYPE_STRING )
|
||||
{
|
||||
JERRY_UNIMPLEMENTED();
|
||||
}
|
||||
|
||||
@@ -51,34 +51,34 @@ JERRY_STATIC_ASSERT( sizeof (ecma_completion_value_t) == sizeof(uint32_t) );
|
||||
*
|
||||
* FIXME: Run GC only if allocation failed.
|
||||
*/
|
||||
#define ALLOC( ecmaType) ecma_ ## ecmaType ## _t * \
|
||||
ecma_alloc_ ## ecmaType (void) \
|
||||
#define ALLOC( ecma_type) ecma_ ## ecma_type ## _t * \
|
||||
ecma_alloc_ ## ecma_type (void) \
|
||||
{ \
|
||||
ecma_ ## ecmaType ## _t *p ## ecmaType = (ecma_ ## ecmaType ## _t *) \
|
||||
mem_pools_alloc( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecmaType ## _t))); \
|
||||
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
|
||||
mem_pools_alloc( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecma_type ## _t))); \
|
||||
\
|
||||
ecma_gc_run(); \
|
||||
JERRY_ASSERT( p ## ecmaType != NULL ); \
|
||||
JERRY_ASSERT( p ## ecma_type != NULL ); \
|
||||
\
|
||||
return p ## ecmaType; \
|
||||
return p ## ecma_type; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocation routine template
|
||||
*/
|
||||
#define DEALLOC( ecmaType) void \
|
||||
ecma_dealloc_ ## ecmaType( ecma_ ## ecmaType ## _t *p ## ecmaType) \
|
||||
#define DEALLOC( ecma_type) void \
|
||||
ecma_dealloc_ ## ecma_type( ecma_ ## ecma_type ## _t *p ## ecma_type) \
|
||||
{ \
|
||||
mem_pools_free( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecmaType ## _t)), \
|
||||
(uint8_t*) p ## ecmaType); \
|
||||
mem_pools_free( mem_size_to_pool_chunk_type( sizeof(ecma_ ## ecma_type ## _t)), \
|
||||
(uint8_t*) p ## ecma_type); \
|
||||
}
|
||||
|
||||
/**
|
||||
* Declaration of alloc/free routine for specified ecma-type.
|
||||
*/
|
||||
#define DECLARE_ROUTINES_FOR( ecmaType) \
|
||||
ALLOC( ecmaType) \
|
||||
DEALLOC( ecmaType)
|
||||
#define DECLARE_ROUTINES_FOR( ecma_type) \
|
||||
ALLOC( ecma_type) \
|
||||
DEALLOC( ecma_type)
|
||||
|
||||
DECLARE_ROUTINES_FOR (object)
|
||||
DECLARE_ROUTINES_FOR (property)
|
||||
|
||||
@@ -35,7 +35,7 @@ extern ecma_object_t *ecma_alloc_object(void);
|
||||
/**
|
||||
* Dealloc memory from an ecma-object
|
||||
*/
|
||||
extern void ecma_dealloc_object( ecma_object_t *pObject);
|
||||
extern void ecma_dealloc_object( ecma_object_t *object_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property
|
||||
@@ -47,7 +47,7 @@ extern ecma_property_t *ecma_alloc_property(void);
|
||||
/**
|
||||
* Dealloc memory from an ecma-property
|
||||
*/
|
||||
extern void ecma_dealloc_property( ecma_property_t *pProperty);
|
||||
extern void ecma_dealloc_property( ecma_property_t *property_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-number
|
||||
@@ -59,7 +59,7 @@ extern ecma_number_t *ecma_alloc_number(void);
|
||||
/**
|
||||
* Dealloc memory from an ecma-number
|
||||
*/
|
||||
extern void ecma_dealloc_number( ecma_number_t *pNumber);
|
||||
extern void ecma_dealloc_number( ecma_number_t *number_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for first chunk of an ecma-array
|
||||
@@ -71,7 +71,7 @@ extern ecma_array_first_chunk_t *ecma_alloc_array_first_chunk(void);
|
||||
/**
|
||||
* Dealloc memory from first chunk of an ecma-array
|
||||
*/
|
||||
extern void ecma_dealloc_array_first_chunk( ecma_array_first_chunk_t *pFirstChunk);
|
||||
extern void ecma_dealloc_array_first_chunk( ecma_array_first_chunk_t *first_chunk_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for non-first chunk of an ecma-array
|
||||
@@ -83,7 +83,7 @@ extern ecma_array_non_first_chunk_t *ecma_alloc_array_non_first_chunk(void);
|
||||
/**
|
||||
* Dealloc memory from non-first chunk of an ecma-array
|
||||
*/
|
||||
extern void ecma_dealloc_array_non_first_chunk( ecma_array_non_first_chunk_t *pNumber);
|
||||
extern void ecma_dealloc_array_non_first_chunk( ecma_array_non_first_chunk_t *number_p);
|
||||
|
||||
#endif /* JERRY_ECMA_ALLOC_H */
|
||||
|
||||
|
||||
@@ -42,49 +42,49 @@ static ecma_object_t *ecma_gc_objs_to_free_queue;
|
||||
* After this operation the object is not longer valid for general use.
|
||||
*/
|
||||
static void
|
||||
ecma_gc_queue( ecma_object_t *pObject) /**< object */
|
||||
ecma_gc_queue( ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT( pObject != NULL );
|
||||
JERRY_ASSERT( pObject->GCInfo.IsObjectValid );
|
||||
JERRY_ASSERT( pObject->GCInfo.u.Refs == 0 );
|
||||
JERRY_ASSERT( object_p != NULL );
|
||||
JERRY_ASSERT( object_p->GCInfo.is_object_valid );
|
||||
JERRY_ASSERT( object_p->GCInfo.u.refs == 0 );
|
||||
|
||||
pObject->GCInfo.IsObjectValid = false;
|
||||
ecma_set_pointer( pObject->GCInfo.u.NextQueuedForGC, ecma_gc_objs_to_free_queue);
|
||||
object_p->GCInfo.is_object_valid = false;
|
||||
ecma_set_pointer( object_p->GCInfo.u.next_queued_for_gc, ecma_gc_objs_to_free_queue);
|
||||
|
||||
ecma_gc_objs_to_free_queue = pObject;
|
||||
ecma_gc_objs_to_free_queue = object_p;
|
||||
} /* ecma_gc_queue */
|
||||
|
||||
/**
|
||||
* Increase reference counter of an object
|
||||
*/
|
||||
void
|
||||
ecma_ref_object(ecma_object_t *pObject) /**< object */
|
||||
ecma_ref_object(ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT(pObject->GCInfo.IsObjectValid);
|
||||
JERRY_ASSERT(object_p->GCInfo.is_object_valid);
|
||||
|
||||
pObject->GCInfo.u.Refs++;
|
||||
object_p->GCInfo.u.refs++;
|
||||
|
||||
/**
|
||||
* Check that value was not overflowed
|
||||
*/
|
||||
JERRY_ASSERT(pObject->GCInfo.u.Refs > 0);
|
||||
JERRY_ASSERT(object_p->GCInfo.u.refs > 0);
|
||||
} /* ecma_ref_object */
|
||||
|
||||
/**
|
||||
* Decrease reference counter of an object
|
||||
*/
|
||||
void
|
||||
ecma_deref_object(ecma_object_t *pObject) /**< object */
|
||||
ecma_deref_object(ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT(pObject != NULL);
|
||||
JERRY_ASSERT(pObject->GCInfo.IsObjectValid);
|
||||
JERRY_ASSERT(pObject->GCInfo.u.Refs > 0);
|
||||
JERRY_ASSERT(object_p != NULL);
|
||||
JERRY_ASSERT(object_p->GCInfo.is_object_valid);
|
||||
JERRY_ASSERT(object_p->GCInfo.u.refs > 0);
|
||||
|
||||
pObject->GCInfo.u.Refs--;
|
||||
object_p->GCInfo.u.refs--;
|
||||
|
||||
if ( pObject->GCInfo.u.Refs == 0 )
|
||||
if ( object_p->GCInfo.u.refs == 0 )
|
||||
{
|
||||
ecma_gc_queue( pObject);
|
||||
ecma_gc_queue( object_p);
|
||||
}
|
||||
} /* ecma_deref_object */
|
||||
|
||||
@@ -105,39 +105,39 @@ ecma_gc_run( void)
|
||||
{
|
||||
while ( ecma_gc_objs_to_free_queue != NULL )
|
||||
{
|
||||
ecma_object_t *pObject = ecma_gc_objs_to_free_queue;
|
||||
ecma_gc_objs_to_free_queue = ecma_get_pointer( pObject->GCInfo.u.NextQueuedForGC);
|
||||
ecma_object_t *object_p = ecma_gc_objs_to_free_queue;
|
||||
ecma_gc_objs_to_free_queue = ecma_get_pointer( object_p->GCInfo.u.next_queued_for_gc);
|
||||
|
||||
JERRY_ASSERT( !pObject->GCInfo.IsObjectValid );
|
||||
JERRY_ASSERT( !object_p->GCInfo.is_object_valid );
|
||||
|
||||
for ( ecma_property_t *property = ecma_get_pointer( pObject->pProperties), *pNextProperty;
|
||||
for ( ecma_property_t *property = ecma_get_pointer( object_p->properties_p), *next_property_p;
|
||||
property != NULL;
|
||||
property = pNextProperty )
|
||||
property = next_property_p )
|
||||
{
|
||||
pNextProperty = ecma_get_pointer( property->pNextProperty);
|
||||
next_property_p = ecma_get_pointer( property->next_property_p);
|
||||
|
||||
ecma_free_property( property);
|
||||
}
|
||||
|
||||
if ( pObject->IsLexicalEnvironment )
|
||||
if ( object_p->is_lexical_environment )
|
||||
{
|
||||
ecma_object_t *pOuterLexicalEnvironment = ecma_get_pointer( pObject->u.LexicalEnvironment.pOuterReference);
|
||||
ecma_object_t *outer_lexical_environment_p = ecma_get_pointer( object_p->u.lexical_environment.outer_reference_p);
|
||||
|
||||
if ( pOuterLexicalEnvironment != NULL )
|
||||
if ( outer_lexical_environment_p != NULL )
|
||||
{
|
||||
ecma_deref_object( pOuterLexicalEnvironment);
|
||||
ecma_deref_object( outer_lexical_environment_p);
|
||||
}
|
||||
} else
|
||||
{
|
||||
ecma_object_t *pPrototypeObject = ecma_get_pointer( pObject->u.Object.pPrototypeObject);
|
||||
ecma_object_t *prototype_object_p = ecma_get_pointer( object_p->u.object.prototype_object_p);
|
||||
|
||||
if ( pPrototypeObject != NULL )
|
||||
if ( prototype_object_p != NULL )
|
||||
{
|
||||
ecma_deref_object( pPrototypeObject);
|
||||
ecma_deref_object( prototype_object_p);
|
||||
}
|
||||
}
|
||||
|
||||
ecma_dealloc_object( pObject);
|
||||
ecma_dealloc_object( object_p);
|
||||
}
|
||||
} /* ecma_gc_run */
|
||||
|
||||
|
||||
@@ -30,8 +30,8 @@
|
||||
#include "ecma-globals.h"
|
||||
|
||||
extern void ecma_gc_init( void);
|
||||
extern void ecma_ref_object(ecma_object_t *pObject);
|
||||
extern void ecma_deref_object(ecma_object_t *pObject);
|
||||
extern void ecma_ref_object(ecma_object_t *object_p);
|
||||
extern void ecma_deref_object(ecma_object_t *object_p);
|
||||
extern void ecma_gc_run( void);
|
||||
|
||||
#endif /* !ECMA_GC_H */
|
||||
|
||||
@@ -103,12 +103,12 @@ typedef enum {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Value type (ecma_type_t) */
|
||||
unsigned int ValueType : 2;
|
||||
unsigned int value_type : 2;
|
||||
|
||||
/**
|
||||
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on ValueType)
|
||||
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on value_type)
|
||||
*/
|
||||
unsigned int Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed ecma_value_t;
|
||||
|
||||
/**
|
||||
@@ -187,10 +187,10 @@ typedef enum
|
||||
*/
|
||||
typedef struct ecma_property_t {
|
||||
/** Property's type (ecma_property_type_t) */
|
||||
unsigned int Type : 2;
|
||||
unsigned int type : 2;
|
||||
|
||||
/** Compressed pointer to next property */
|
||||
unsigned int pNextProperty : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Property's details (depending on Type) */
|
||||
union {
|
||||
@@ -198,47 +198,47 @@ typedef struct ecma_property_t {
|
||||
/** Description of named data property */
|
||||
struct __packed ecma_named_data_property_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
unsigned int pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Writable' (ecma_property_writable_value_t) */
|
||||
unsigned int Writable : 1;
|
||||
unsigned int writable : 1;
|
||||
|
||||
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
||||
unsigned int Enumerable : 1;
|
||||
unsigned int enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
||||
unsigned int Configurable : 1;
|
||||
unsigned int configurable : 1;
|
||||
|
||||
/** Value */
|
||||
ecma_value_t Value;
|
||||
} NamedDataProperty;
|
||||
ecma_value_t value;
|
||||
} named_data_property;
|
||||
|
||||
/** Description of named accessor property */
|
||||
struct __packed ecma_named_accessor_property_t {
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
unsigned int pName : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
||||
unsigned int Enumerable : 1;
|
||||
unsigned int enumerable : 1;
|
||||
|
||||
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
|
||||
unsigned int Configurable : 1;
|
||||
unsigned int configurable : 1;
|
||||
|
||||
/** Compressed pointer to property's getter */
|
||||
unsigned int pGet : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int get_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to property's setter */
|
||||
unsigned int pSet : ECMA_POINTER_FIELD_WIDTH;
|
||||
} NamedAccessorProperty;
|
||||
unsigned int set_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
} named_accessor_property;
|
||||
|
||||
/** Description of internal property */
|
||||
struct __packed ecma_internal_property_t {
|
||||
/** Internal property's type */
|
||||
unsigned int InternalPropertyType : 4;
|
||||
unsigned int internal_property_type : 4;
|
||||
|
||||
/** Value (may be a compressed pointer) */
|
||||
unsigned int Value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} InternalProperty;
|
||||
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
|
||||
} internal_property;
|
||||
} u;
|
||||
} ecma_property_t;
|
||||
|
||||
@@ -250,22 +250,22 @@ typedef struct {
|
||||
* Flag that indicates if the object is valid for normal usage.
|
||||
* If the flag is zero, then the object is not valid and is queued for GC.
|
||||
*/
|
||||
unsigned int IsObjectValid : 1;
|
||||
unsigned int is_object_valid : 1;
|
||||
|
||||
/** Details (depending on IsObjectValid) */
|
||||
/** Details (depending on is_object_valid) */
|
||||
union {
|
||||
/**
|
||||
* Number of refs to the object (if IsObjectValid).
|
||||
* Number of refs to the object (if is_object_valid).
|
||||
*
|
||||
* Note: It is not a pointer. Maximum value of reference counter
|
||||
* willn't be bigger than overall count of variables/objects/properties,
|
||||
* which is limited by size of address space allocated for JerryScript
|
||||
* (and, consequently, by ECMA_POINTER_FIELD_WIDTH).
|
||||
*/
|
||||
unsigned int Refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int refs : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to next object in the list of objects, queued for GC (if !IsObjectValid) */
|
||||
unsigned int NextQueuedForGC : ECMA_POINTER_FIELD_WIDTH;
|
||||
/** Compressed pointer to next object in the list of objects, queued for GC (if !is_object_valid) */
|
||||
unsigned int next_queued_for_gc : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed u;
|
||||
} ecma_gc_info_t;
|
||||
|
||||
@@ -279,44 +279,44 @@ typedef enum {
|
||||
|
||||
/**
|
||||
* Description of ECMA-object or lexical environment
|
||||
* (depending on IsLexicalEnvironment).
|
||||
* (depending on is_lexical_environment).
|
||||
*/
|
||||
typedef struct ecma_object_t {
|
||||
/** Compressed pointer to property list */
|
||||
unsigned int pProperties : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Flag indicating whether it is a general object (false)
|
||||
or a lexical environment (true) */
|
||||
unsigned int IsLexicalEnvironment : 1;
|
||||
unsigned int is_lexical_environment : 1;
|
||||
|
||||
/**
|
||||
* Attributes of either general object or lexical environment
|
||||
* (depending on IsLexicalEnvironment)
|
||||
* (depending on is_lexical_environment)
|
||||
*/
|
||||
union {
|
||||
/**
|
||||
* A general object's attributes (if !IsLexicalEnvironment)
|
||||
* A general object's attributes (if !is_lexical_environment)
|
||||
*/
|
||||
struct {
|
||||
/** Attribute 'Extensible' */
|
||||
unsigned int Extensible : 1;
|
||||
unsigned int extensible : 1;
|
||||
|
||||
/** Compressed pointer to prototype object (ecma_object_t) */
|
||||
unsigned int pPrototypeObject : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed Object;
|
||||
unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed object;
|
||||
|
||||
/**
|
||||
* A lexical environment's attribute (if IsLexicalEnvironment)
|
||||
* A lexical environment's attribute (if is_lexical_environment)
|
||||
*/
|
||||
struct {
|
||||
/**
|
||||
* Type of lexical environment (ecma_lexical_environment_type_t).
|
||||
*/
|
||||
unsigned int Type : 1;
|
||||
unsigned int type : 1;
|
||||
|
||||
/** Compressed pointer to outer lexical environment */
|
||||
unsigned int pOuterReference : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed LexicalEnvironment;
|
||||
unsigned int outer_reference_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
} __packed lexical_environment;
|
||||
|
||||
} __packed u;
|
||||
|
||||
@@ -344,10 +344,10 @@ typedef uint16_t ecma_length_t;
|
||||
*/
|
||||
typedef struct {
|
||||
/** Compressed pointer to next chunk */
|
||||
uint16_t pNextChunk;
|
||||
uint16_t next_chunk_p;
|
||||
|
||||
/** Number of elements in the Array */
|
||||
ecma_length_t UnitNumber;
|
||||
ecma_length_t unit_number;
|
||||
} ecma_array_header_t;
|
||||
|
||||
/**
|
||||
@@ -360,10 +360,10 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Array's header */
|
||||
ecma_array_header_t Header;
|
||||
ecma_array_header_t header;
|
||||
|
||||
/** Elements */
|
||||
uint8_t Data[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (ecma_array_header_t) ];
|
||||
uint8_t data[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (ecma_array_header_t) ];
|
||||
} ecma_array_first_chunk_t;
|
||||
|
||||
/**
|
||||
@@ -371,10 +371,10 @@ typedef struct {
|
||||
*/
|
||||
typedef struct {
|
||||
/** Compressed pointer to next chunk */
|
||||
uint16_t pNextChunk;
|
||||
uint16_t next_chunk_p;
|
||||
|
||||
/** Characters */
|
||||
uint8_t Data[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (uint16_t) ];
|
||||
uint8_t data[ ECMA_ARRAY_CHUNK_SIZE_IN_BYTES - sizeof (uint16_t) ];
|
||||
} ecma_array_non_first_chunk_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
bool
|
||||
ecma_is_value_undefined( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.ValueType == ECMA_TYPE_SIMPLE && value.Value == ECMA_SIMPLE_VALUE_UNDEFINED );
|
||||
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_UNDEFINED );
|
||||
} /* ecma_is_value_undefined */
|
||||
|
||||
/**
|
||||
@@ -47,7 +47,7 @@ ecma_is_value_undefined( ecma_value_t value) /**< ecma-value */
|
||||
bool
|
||||
ecma_is_value_null( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( value.ValueType == ECMA_TYPE_SIMPLE && value.Value == ECMA_SIMPLE_VALUE_NULL );
|
||||
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_NULL );
|
||||
} /* ecma_is_value_null */
|
||||
|
||||
/**
|
||||
@@ -59,8 +59,8 @@ ecma_is_value_null( ecma_value_t value) /**< ecma-value */
|
||||
bool
|
||||
ecma_is_value_boolean( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
return ( ( value.ValueType == ECMA_TYPE_SIMPLE && value.Value == ECMA_SIMPLE_VALUE_FALSE )
|
||||
|| ( value.ValueType == ECMA_TYPE_SIMPLE && value.Value == ECMA_SIMPLE_VALUE_TRUE ) );
|
||||
return ( ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_FALSE )
|
||||
|| ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE ) );
|
||||
} /* ecma_is_value_boolean */
|
||||
|
||||
/**
|
||||
@@ -77,7 +77,7 @@ ecma_is_value_true( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
JERRY_ASSERT( ecma_is_value_boolean( value) );
|
||||
|
||||
return ( value.ValueType == ECMA_TYPE_SIMPLE && value.Value == ECMA_SIMPLE_VALUE_TRUE );
|
||||
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE );
|
||||
} /* ecma_is_value_true */
|
||||
|
||||
/**
|
||||
@@ -86,7 +86,7 @@ ecma_is_value_true( ecma_value_t value) /**< ecma-value */
|
||||
ecma_value_t
|
||||
ecma_make_simple_value( ecma_simple_value_t value) /**< simple value */
|
||||
{
|
||||
return (ecma_value_t) { .ValueType = ECMA_TYPE_SIMPLE, .Value = value };
|
||||
return (ecma_value_t) { .value_type = ECMA_TYPE_SIMPLE, .value = value };
|
||||
} /* ecma_make_simple_value */
|
||||
|
||||
/**
|
||||
@@ -99,8 +99,8 @@ ecma_make_number_value( ecma_number_t* num_p) /**< number to reference in value
|
||||
|
||||
ecma_value_t number_value;
|
||||
|
||||
number_value.ValueType = ECMA_TYPE_NUMBER;
|
||||
ecma_set_pointer( number_value.Value, num_p);
|
||||
number_value.value_type = ECMA_TYPE_NUMBER;
|
||||
ecma_set_pointer( number_value.value, num_p);
|
||||
|
||||
return number_value;
|
||||
} /* ecma_make_number_value */
|
||||
@@ -115,14 +115,14 @@ ecma_make_string_value( ecma_array_first_chunk_t* ecma_string_p) /**< string to
|
||||
|
||||
ecma_value_t string_value;
|
||||
|
||||
string_value.ValueType = ECMA_TYPE_STRING;
|
||||
ecma_set_pointer( string_value.Value, ecma_string_p);
|
||||
string_value.value_type = ECMA_TYPE_STRING;
|
||||
ecma_set_pointer( string_value.value, ecma_string_p);
|
||||
|
||||
return string_value;
|
||||
} /* ecma_make_string_value */
|
||||
|
||||
/**
|
||||
* Object value constructor
|
||||
* object value constructor
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_make_object_value( ecma_object_t* object_p) /**< object to reference in value */
|
||||
@@ -131,8 +131,8 @@ ecma_make_object_value( ecma_object_t* object_p) /**< object to reference in val
|
||||
|
||||
ecma_value_t object_value;
|
||||
|
||||
object_value.ValueType = ECMA_TYPE_OBJECT;
|
||||
ecma_set_pointer( object_value.Value, object_p);
|
||||
object_value.value_type = ECMA_TYPE_OBJECT;
|
||||
ecma_set_pointer( object_value.value, object_p);
|
||||
|
||||
return object_value;
|
||||
} /* ecma_make_object_value */
|
||||
@@ -163,7 +163,7 @@ ecma_copy_value( const ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
ecma_value_t value_copy;
|
||||
|
||||
switch ( (ecma_type_t)value.ValueType )
|
||||
switch ( (ecma_type_t)value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
@@ -173,32 +173,32 @@ ecma_copy_value( const ecma_value_t value) /**< ecma-value */
|
||||
}
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *num_p = ecma_get_pointer( value.Value);
|
||||
ecma_number_t *num_p = ecma_get_pointer( value.value);
|
||||
JERRY_ASSERT( num_p != NULL );
|
||||
|
||||
ecma_number_t *number_copy_p = ecma_alloc_number();
|
||||
*number_copy_p = *num_p;
|
||||
|
||||
value_copy = (ecma_value_t) { .ValueType = ECMA_TYPE_NUMBER };
|
||||
ecma_set_pointer( value_copy.Value, number_copy_p);
|
||||
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_NUMBER };
|
||||
ecma_set_pointer( value_copy.value, number_copy_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_array_first_chunk_t *string_p = ecma_get_pointer( value.Value);
|
||||
ecma_array_first_chunk_t *string_p = ecma_get_pointer( value.value);
|
||||
JERRY_ASSERT( string_p != NULL );
|
||||
|
||||
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string( string_p);
|
||||
|
||||
value_copy = (ecma_value_t) { .ValueType = ECMA_TYPE_STRING };
|
||||
ecma_set_pointer( value_copy.Value, string_copy_p);
|
||||
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_STRING };
|
||||
ecma_set_pointer( value_copy.value, string_copy_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_pointer( value.Value);
|
||||
ecma_object_t *obj_p = ecma_get_pointer( value.value);
|
||||
JERRY_ASSERT( obj_p != NULL );
|
||||
|
||||
ecma_ref_object( obj_p);
|
||||
@@ -222,7 +222,7 @@ ecma_copy_value( const ecma_value_t value) /**< ecma-value */
|
||||
void
|
||||
ecma_free_value( ecma_value_t value) /**< value description */
|
||||
{
|
||||
switch ( (ecma_type_t) value.ValueType )
|
||||
switch ( (ecma_type_t) value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
@@ -232,21 +232,21 @@ ecma_free_value( ecma_value_t value) /**< value description */
|
||||
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
ecma_number_t *pNumber = ecma_get_pointer( value.Value);
|
||||
ecma_dealloc_number( pNumber);
|
||||
ecma_number_t *number_p = ecma_get_pointer( value.value);
|
||||
ecma_dealloc_number( number_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_STRING:
|
||||
{
|
||||
ecma_array_first_chunk_t *pString = ecma_get_pointer( value.Value);
|
||||
ecma_free_array( pString);
|
||||
ecma_array_first_chunk_t *string_p = ecma_get_pointer( value.value);
|
||||
ecma_free_array( string_p);
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_TYPE_OBJECT:
|
||||
{
|
||||
ecma_deref_object( ecma_get_pointer( value.Value));
|
||||
ecma_deref_object( ecma_get_pointer( value.value));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -278,7 +278,7 @@ ecma_make_completion_value(ecma_completion_type_t type, /**< type */
|
||||
ecma_completion_value_t
|
||||
ecma_make_throw_value( ecma_object_t *exception_p) /**< an object */
|
||||
{
|
||||
JERRY_ASSERT( exception_p != NULL && !exception_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( exception_p != NULL && !exception_p->is_lexical_environment );
|
||||
|
||||
ecma_value_t exception = ecma_make_object_value( exception_p);
|
||||
|
||||
@@ -329,7 +329,7 @@ ecma_free_completion_value( ecma_completion_value_t completion_value) /**< compl
|
||||
case ECMA_COMPLETION_TYPE_CONTINUE:
|
||||
case ECMA_COMPLETION_TYPE_BREAK:
|
||||
case ECMA_COMPLETION_TYPE_EXIT:
|
||||
JERRY_ASSERT( completion_value.value.ValueType == ECMA_TYPE_SIMPLE );
|
||||
JERRY_ASSERT( completion_value.value.value_type == ECMA_TYPE_SIMPLE );
|
||||
break;
|
||||
}
|
||||
} /* ecma_free_completion_value */
|
||||
@@ -370,8 +370,8 @@ ecma_is_completion_value_normal_simple_value(ecma_completion_value_t value, /**<
|
||||
ecma_simple_value_t simple_value) /**< simple value to check for equality with */
|
||||
{
|
||||
return ( value.type == ECMA_COMPLETION_TYPE_NORMAL
|
||||
&& value.value.ValueType == ECMA_TYPE_SIMPLE
|
||||
&& value.value.Value == simple_value );
|
||||
&& value.value.value_type == ECMA_TYPE_SIMPLE
|
||||
&& value.value.value == simple_value );
|
||||
} /* ecma_is_completion_value_normal_simple_value */
|
||||
|
||||
/**
|
||||
|
||||
+183
-183
@@ -37,35 +37,35 @@ ecma_compress_pointer(void *pointer) /**< pointer to compress */
|
||||
return ECMA_NULL_POINTER;
|
||||
}
|
||||
|
||||
uintptr_t intPtr = (uintptr_t) pointer;
|
||||
uintptr_t int_ptr = (uintptr_t) pointer;
|
||||
|
||||
JERRY_ASSERT(intPtr % MEM_ALIGNMENT == 0);
|
||||
JERRY_ASSERT(int_ptr % MEM_ALIGNMENT == 0);
|
||||
|
||||
intPtr -= mem_get_base_pointer();
|
||||
intPtr >>= MEM_ALIGNMENT_LOG;
|
||||
int_ptr -= mem_get_base_pointer();
|
||||
int_ptr >>= MEM_ALIGNMENT_LOG;
|
||||
|
||||
JERRY_ASSERT((intPtr & ~((1u << ECMA_POINTER_FIELD_WIDTH) - 1)) == 0);
|
||||
JERRY_ASSERT((int_ptr & ~((1u << ECMA_POINTER_FIELD_WIDTH) - 1)) == 0);
|
||||
|
||||
return intPtr;
|
||||
return int_ptr;
|
||||
} /* ecma_compress_pointer */
|
||||
|
||||
/**
|
||||
* Decompress pointer.
|
||||
*/
|
||||
void*
|
||||
ecma_decompress_pointer(uintptr_t compressedPointer) /**< pointer to decompress */
|
||||
ecma_decompress_pointer(uintptr_t compressed_pointer) /**< pointer to decompress */
|
||||
{
|
||||
if ( compressedPointer == ECMA_NULL_POINTER )
|
||||
if ( compressed_pointer == ECMA_NULL_POINTER )
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintptr_t intPtr = compressedPointer;
|
||||
uintptr_t int_ptr = compressed_pointer;
|
||||
|
||||
intPtr <<= MEM_ALIGNMENT_LOG;
|
||||
intPtr += mem_get_base_pointer();
|
||||
int_ptr <<= MEM_ALIGNMENT_LOG;
|
||||
int_ptr += mem_get_base_pointer();
|
||||
|
||||
return (void*) intPtr;
|
||||
return (void*) int_ptr;
|
||||
} /* ecma_decompress_pointer */
|
||||
|
||||
/**
|
||||
@@ -78,23 +78,23 @@ ecma_decompress_pointer(uintptr_t compressedPointer) /**< pointer to decompress
|
||||
* @return pointer to the object's descriptor
|
||||
*/
|
||||
ecma_object_t*
|
||||
ecma_create_object( ecma_object_t *pPrototypeObject, /**< pointer to prototybe of the object (or NULL) */
|
||||
bool isExtensible) /**< value of extensible attribute */
|
||||
ecma_create_object( ecma_object_t *prototype_object_p, /**< pointer to prototybe of the object (or NULL) */
|
||||
bool is_extensible) /**< value of extensible attribute */
|
||||
{
|
||||
ecma_object_t *pObject = ecma_alloc_object();
|
||||
ecma_object_t *object_p = ecma_alloc_object();
|
||||
|
||||
pObject->pProperties = ECMA_NULL_POINTER;
|
||||
pObject->IsLexicalEnvironment = false;
|
||||
pObject->GCInfo.IsObjectValid = true;
|
||||
object_p->properties_p = ECMA_NULL_POINTER;
|
||||
object_p->is_lexical_environment = false;
|
||||
object_p->GCInfo.is_object_valid = true;
|
||||
|
||||
/* The global object is always referenced
|
||||
* (at least with the ctx_GlobalObject variable) */
|
||||
pObject->GCInfo.u.Refs = 1;
|
||||
object_p->GCInfo.u.refs = 1;
|
||||
|
||||
pObject->u.Object.Extensible = isExtensible;
|
||||
ecma_set_pointer( pObject->u.Object.pPrototypeObject, pPrototypeObject);
|
||||
object_p->u.object.extensible = is_extensible;
|
||||
ecma_set_pointer( object_p->u.object.prototype_object_p, prototype_object_p);
|
||||
|
||||
return pObject;
|
||||
return object_p;
|
||||
} /* ecma_create_object */
|
||||
|
||||
/**
|
||||
@@ -110,22 +110,22 @@ ecma_create_object( ecma_object_t *pPrototypeObject, /**< pointer to prototybe o
|
||||
* @return pointer to the descriptor of lexical environment
|
||||
*/
|
||||
ecma_object_t*
|
||||
ecma_create_lexical_environment(ecma_object_t *pOuterLexicalEnvironment, /**< outer lexical environment */
|
||||
ecma_create_lexical_environment(ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
|
||||
ecma_lexical_environment_type_t type) /**< type of lexical environment to create */
|
||||
{
|
||||
ecma_object_t *pNewLexicalEnvironment = ecma_alloc_object();
|
||||
ecma_object_t *new_lexical_environment_p = ecma_alloc_object();
|
||||
|
||||
pNewLexicalEnvironment->IsLexicalEnvironment = true;
|
||||
pNewLexicalEnvironment->u.LexicalEnvironment.Type = type;
|
||||
new_lexical_environment_p->is_lexical_environment = true;
|
||||
new_lexical_environment_p->u.lexical_environment.type = type;
|
||||
|
||||
pNewLexicalEnvironment->pProperties = ECMA_NULL_POINTER;
|
||||
new_lexical_environment_p->properties_p = ECMA_NULL_POINTER;
|
||||
|
||||
pNewLexicalEnvironment->GCInfo.IsObjectValid = true;
|
||||
pNewLexicalEnvironment->GCInfo.u.Refs = 1;
|
||||
new_lexical_environment_p->GCInfo.is_object_valid = true;
|
||||
new_lexical_environment_p->GCInfo.u.refs = 1;
|
||||
|
||||
ecma_set_pointer( pNewLexicalEnvironment->u.LexicalEnvironment.pOuterReference, pOuterLexicalEnvironment);
|
||||
ecma_set_pointer( new_lexical_environment_p->u.lexical_environment.outer_reference_p, outer_lexical_environment_p);
|
||||
|
||||
return pNewLexicalEnvironment;
|
||||
return new_lexical_environment_p;
|
||||
} /* ecma_create_lexical_environment */
|
||||
|
||||
/**
|
||||
@@ -135,20 +135,20 @@ ecma_create_lexical_environment(ecma_object_t *pOuterLexicalEnvironment, /**< ou
|
||||
* @return pointer to newly created property's des
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_create_internal_property(ecma_object_t *pObject, /**< the object */
|
||||
ecma_internal_property_id_t propertyId) /**< internal property identifier */
|
||||
ecma_create_internal_property(ecma_object_t *object_p, /**< the object */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
ecma_property_t *pNewProperty = ecma_alloc_property();
|
||||
ecma_property_t *new_property_p = ecma_alloc_property();
|
||||
|
||||
pNewProperty->Type = ECMA_PROPERTY_INTERNAL;
|
||||
new_property_p->type = ECMA_PROPERTY_INTERNAL;
|
||||
|
||||
ecma_set_pointer( pNewProperty->pNextProperty, ecma_get_pointer( pObject->pProperties));
|
||||
ecma_set_pointer( pObject->pProperties, pNewProperty);
|
||||
ecma_set_pointer( new_property_p->next_property_p, ecma_get_pointer( object_p->properties_p));
|
||||
ecma_set_pointer( object_p->properties_p, new_property_p);
|
||||
|
||||
pNewProperty->u.InternalProperty.InternalPropertyType = propertyId;
|
||||
pNewProperty->u.InternalProperty.Value = ECMA_NULL_POINTER;
|
||||
new_property_p->u.internal_property.internal_property_type = property_id;
|
||||
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
|
||||
|
||||
return pNewProperty;
|
||||
return new_property_p;
|
||||
} /* ecma_create_internal_property */
|
||||
|
||||
/**
|
||||
@@ -158,23 +158,23 @@ ecma_create_internal_property(ecma_object_t *pObject, /**< the object */
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_find_internal_property(ecma_object_t *pObject, /**< object descriptor */
|
||||
ecma_internal_property_id_t propertyId) /**< internal property identifier */
|
||||
ecma_find_internal_property(ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
JERRY_ASSERT( pObject != NULL );
|
||||
JERRY_ASSERT( object_p != NULL );
|
||||
|
||||
JERRY_ASSERT( propertyId != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
||||
&& propertyId != ECMA_INTERNAL_PROPERTY_EXTENSIBLE );
|
||||
JERRY_ASSERT( property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
||||
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE );
|
||||
|
||||
for ( ecma_property_t *pProperty = ecma_get_pointer( pObject->pProperties);
|
||||
pProperty != NULL;
|
||||
pProperty = ecma_get_pointer( pProperty->pNextProperty) )
|
||||
for ( ecma_property_t *property_p = ecma_get_pointer( object_p->properties_p);
|
||||
property_p != NULL;
|
||||
property_p = ecma_get_pointer( property_p->next_property_p) )
|
||||
{
|
||||
if ( pProperty->Type == ECMA_PROPERTY_INTERNAL )
|
||||
if ( property_p->type == ECMA_PROPERTY_INTERNAL )
|
||||
{
|
||||
if ( pProperty->u.InternalProperty.InternalPropertyType == propertyId )
|
||||
if ( property_p->u.internal_property.internal_property_type == property_id )
|
||||
{
|
||||
return pProperty;
|
||||
return property_p;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -191,14 +191,14 @@ ecma_find_internal_property(ecma_object_t *pObject, /**< object descriptor */
|
||||
* @return pointer to the property
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_get_internal_property(ecma_object_t *pObject, /**< object descriptor */
|
||||
ecma_internal_property_id_t propertyId) /**< internal property identifier */
|
||||
ecma_get_internal_property(ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
ecma_property_t *pProperty = ecma_find_internal_property( pObject, propertyId);
|
||||
ecma_property_t *property_p = ecma_find_internal_property( object_p, property_id);
|
||||
|
||||
JERRY_ASSERT( pProperty != NULL );
|
||||
JERRY_ASSERT( property_p != NULL );
|
||||
|
||||
return pProperty;
|
||||
return property_p;
|
||||
} /* ecma_get_internal_property */
|
||||
|
||||
/**
|
||||
@@ -218,18 +218,18 @@ ecma_create_named_property(ecma_object_t *obj_p, /**< object */
|
||||
|
||||
ecma_property_t *prop = ecma_alloc_property();
|
||||
|
||||
prop->Type = ECMA_PROPERTY_NAMEDDATA;
|
||||
prop->type = ECMA_PROPERTY_NAMEDDATA;
|
||||
|
||||
ecma_set_pointer( prop->u.NamedDataProperty.pName, ecma_new_ecma_string( name_p));
|
||||
ecma_set_pointer( prop->u.named_data_property.name_p, ecma_new_ecma_string( name_p));
|
||||
|
||||
prop->u.NamedDataProperty.Writable = writable;
|
||||
prop->u.NamedDataProperty.Enumerable = enumerable;
|
||||
prop->u.NamedDataProperty.Configurable = configurable;
|
||||
prop->u.named_data_property.writable = writable;
|
||||
prop->u.named_data_property.enumerable = enumerable;
|
||||
prop->u.named_data_property.configurable = configurable;
|
||||
|
||||
prop->u.NamedDataProperty.Value = ecma_make_simple_value( ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
prop->u.named_data_property.value = ecma_make_simple_value( ECMA_SIMPLE_VALUE_UNDEFINED);
|
||||
|
||||
ecma_set_pointer( prop->pNextProperty, ecma_get_pointer( obj_p->pProperties));
|
||||
ecma_set_pointer( obj_p->pProperties, prop);
|
||||
ecma_set_pointer( prop->next_property_p, ecma_get_pointer( obj_p->properties_p));
|
||||
ecma_set_pointer( obj_p->properties_p, prop);
|
||||
|
||||
return prop;
|
||||
} /* ecma_create_named_property */
|
||||
@@ -247,18 +247,18 @@ ecma_find_named_property(ecma_object_t *obj_p, /**< object to find property in *
|
||||
JERRY_ASSERT( obj_p != NULL );
|
||||
JERRY_ASSERT( name_p != NULL );
|
||||
|
||||
for ( ecma_property_t *property_p = ecma_get_pointer( obj_p->pProperties);
|
||||
for ( ecma_property_t *property_p = ecma_get_pointer( obj_p->properties_p);
|
||||
property_p != NULL;
|
||||
property_p = ecma_get_pointer( property_p->pNextProperty) )
|
||||
property_p = ecma_get_pointer( property_p->next_property_p) )
|
||||
{
|
||||
ecma_array_first_chunk_t *property_name_p;
|
||||
|
||||
if ( property_p->Type == ECMA_PROPERTY_NAMEDDATA )
|
||||
if ( property_p->type == ECMA_PROPERTY_NAMEDDATA )
|
||||
{
|
||||
property_name_p = ecma_get_pointer( property_p->u.NamedDataProperty.pName);
|
||||
} else if ( property_p->Type == ECMA_PROPERTY_NAMEDACCESSOR )
|
||||
property_name_p = ecma_get_pointer( property_p->u.named_data_property.name_p);
|
||||
} else if ( property_p->type == ECMA_PROPERTY_NAMEDACCESSOR )
|
||||
{
|
||||
property_name_p = ecma_get_pointer( property_p->u.NamedAccessorProperty.pName);
|
||||
property_name_p = ecma_get_pointer( property_p->u.named_accessor_property.name_p);
|
||||
} else
|
||||
{
|
||||
continue;
|
||||
@@ -316,7 +316,7 @@ ecma_get_named_data_property(ecma_object_t *obj_p, /**< object to find property
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property( obj_p, name_p);
|
||||
|
||||
JERRY_ASSERT( property_p != NULL && property_p->Type == ECMA_PROPERTY_NAMEDDATA );
|
||||
JERRY_ASSERT( property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA );
|
||||
|
||||
return property_p;
|
||||
} /* ecma_get_named_data_property */
|
||||
@@ -325,67 +325,67 @@ ecma_get_named_data_property(ecma_object_t *obj_p, /**< object to find property
|
||||
* Free the named data property and values it references.
|
||||
*/
|
||||
void
|
||||
ecma_free_named_data_property( ecma_property_t *pProperty) /**< the property */
|
||||
ecma_free_named_data_property( ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT( pProperty->Type == ECMA_PROPERTY_NAMEDDATA );
|
||||
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_NAMEDDATA );
|
||||
|
||||
ecma_free_array( ecma_get_pointer( pProperty->u.NamedDataProperty.pName));
|
||||
ecma_free_value( pProperty->u.NamedDataProperty.Value);
|
||||
ecma_free_array( ecma_get_pointer( property_p->u.named_data_property.name_p));
|
||||
ecma_free_value( property_p->u.named_data_property.value);
|
||||
|
||||
ecma_dealloc_property( pProperty);
|
||||
ecma_dealloc_property( property_p);
|
||||
} /* ecma_free_named_data_property */
|
||||
|
||||
/**
|
||||
* Free the named accessor property and values it references.
|
||||
*/
|
||||
void
|
||||
ecma_free_named_accessor_property( ecma_property_t *pProperty) /**< the property */
|
||||
ecma_free_named_accessor_property( ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT( pProperty->Type == ECMA_PROPERTY_NAMEDACCESSOR );
|
||||
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_NAMEDACCESSOR );
|
||||
|
||||
ecma_free_array( ecma_get_pointer( pProperty->u.NamedAccessorProperty.pName));
|
||||
ecma_free_array( ecma_get_pointer( property_p->u.named_accessor_property.name_p));
|
||||
|
||||
ecma_object_t *pGet = ecma_get_pointer(pProperty->u.NamedAccessorProperty.pGet);
|
||||
ecma_object_t *pSet = ecma_get_pointer(pProperty->u.NamedAccessorProperty.pSet);
|
||||
ecma_object_t *get_p = ecma_get_pointer(property_p->u.named_accessor_property.get_p);
|
||||
ecma_object_t *set_p = ecma_get_pointer(property_p->u.named_accessor_property.set_p);
|
||||
|
||||
if ( pGet != NULL )
|
||||
if ( get_p != NULL )
|
||||
{
|
||||
ecma_deref_object( pGet);
|
||||
ecma_deref_object( get_p);
|
||||
}
|
||||
|
||||
if ( pSet != NULL )
|
||||
if ( set_p != NULL )
|
||||
{
|
||||
ecma_deref_object( pSet);
|
||||
ecma_deref_object( set_p);
|
||||
}
|
||||
|
||||
ecma_dealloc_property( pProperty);
|
||||
ecma_dealloc_property( property_p);
|
||||
} /* ecma_free_named_accessor_property */
|
||||
|
||||
/**
|
||||
* Free the internal property and values it references.
|
||||
*/
|
||||
void
|
||||
ecma_free_internal_property( ecma_property_t *pProperty) /**< the property */
|
||||
ecma_free_internal_property( ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT( pProperty->Type == ECMA_PROPERTY_INTERNAL );
|
||||
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_INTERNAL );
|
||||
|
||||
ecma_internal_property_id_t propertyId = pProperty->u.InternalProperty.InternalPropertyType;
|
||||
uint32_t propertyValue = pProperty->u.InternalProperty.Value;
|
||||
ecma_internal_property_id_t property_id = property_p->u.internal_property.internal_property_type;
|
||||
uint32_t property_value = property_p->u.internal_property.value;
|
||||
|
||||
switch ( propertyId )
|
||||
switch ( property_id )
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* a string */
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
||||
{
|
||||
ecma_free_array( ecma_get_pointer( propertyValue));
|
||||
ecma_free_array( ecma_get_pointer( property_value));
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
|
||||
{
|
||||
ecma_deref_object( ecma_get_pointer( propertyValue));
|
||||
ecma_deref_object( ecma_get_pointer( property_value));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -397,7 +397,7 @@ ecma_free_internal_property( ecma_property_t *pProperty) /**< the property */
|
||||
}
|
||||
}
|
||||
|
||||
ecma_dealloc_property( pProperty);
|
||||
ecma_dealloc_property( property_p);
|
||||
} /* ecma_free_internal_property */
|
||||
|
||||
/**
|
||||
@@ -406,7 +406,7 @@ ecma_free_internal_property( ecma_property_t *pProperty) /**< the property */
|
||||
void
|
||||
ecma_free_property(ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
switch ( (ecma_property_type_t) prop_p->Type )
|
||||
switch ( (ecma_property_type_t) prop_p->type )
|
||||
{
|
||||
case ECMA_PROPERTY_NAMEDDATA:
|
||||
{
|
||||
@@ -440,11 +440,11 @@ void
|
||||
ecma_delete_property(ecma_object_t *obj_p, /**< object */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
for ( ecma_property_t *cur_prop_p = ecma_get_pointer( obj_p->pProperties), *prev_prop_p = NULL, *next_prop_p;
|
||||
for ( ecma_property_t *cur_prop_p = ecma_get_pointer( obj_p->properties_p), *prev_prop_p = NULL, *next_prop_p;
|
||||
cur_prop_p != NULL;
|
||||
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p )
|
||||
{
|
||||
next_prop_p = ecma_get_pointer( cur_prop_p->pNextProperty);
|
||||
next_prop_p = ecma_get_pointer( cur_prop_p->next_property_p);
|
||||
|
||||
if ( cur_prop_p == prop_p )
|
||||
{
|
||||
@@ -452,10 +452,10 @@ ecma_delete_property(ecma_object_t *obj_p, /**< object */
|
||||
|
||||
if ( prev_prop_p == NULL )
|
||||
{
|
||||
ecma_set_pointer( obj_p->pProperties, next_prop_p);
|
||||
ecma_set_pointer( obj_p->properties_p, next_prop_p);
|
||||
} else
|
||||
{
|
||||
ecma_set_pointer( prev_prop_p->pNextProperty, next_prop_p);
|
||||
ecma_set_pointer( prev_prop_p->next_property_p, next_prop_p);
|
||||
}
|
||||
|
||||
return;
|
||||
@@ -471,53 +471,53 @@ ecma_delete_property(ecma_object_t *obj_p, /**< object */
|
||||
* @return Pointer to first chunk of an array, containing allocated string
|
||||
*/
|
||||
ecma_array_first_chunk_t*
|
||||
ecma_new_ecma_string(const ecma_char_t *pString) /**< zero-terminated string of ecma-characters */
|
||||
ecma_new_ecma_string(const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
|
||||
{
|
||||
ecma_length_t length = 0;
|
||||
|
||||
/*
|
||||
* TODO: Do not precalculate length.
|
||||
*/
|
||||
if ( pString != NULL )
|
||||
if ( string_p != NULL )
|
||||
{
|
||||
const ecma_char_t *iter_p = pString;
|
||||
const ecma_char_t *iter_p = string_p;
|
||||
while ( *iter_p++ )
|
||||
{
|
||||
length++;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_array_first_chunk_t *pStringFirstChunk = ecma_alloc_array_first_chunk();
|
||||
ecma_array_first_chunk_t *string_first_chunk_p = ecma_alloc_array_first_chunk();
|
||||
|
||||
pStringFirstChunk->Header.UnitNumber = length;
|
||||
uint8_t *copyPointer = (uint8_t*) pString;
|
||||
size_t charsLeft = length;
|
||||
size_t charsToCopy = JERRY_MIN( length, sizeof (pStringFirstChunk->Data) / sizeof (ecma_char_t));
|
||||
__memcpy(pStringFirstChunk->Data, copyPointer, charsToCopy * sizeof (ecma_char_t));
|
||||
charsLeft -= charsToCopy;
|
||||
copyPointer += charsToCopy * sizeof (ecma_char_t);
|
||||
string_first_chunk_p->header.unit_number = length;
|
||||
uint8_t *copy_pointer = (uint8_t*) string_p;
|
||||
size_t chars_left = length;
|
||||
size_t chars_to_copy = JERRY_MIN( length, sizeof (string_first_chunk_p->data) / sizeof (ecma_char_t));
|
||||
__memcpy(string_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
||||
chars_left -= chars_to_copy;
|
||||
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
||||
|
||||
ecma_array_non_first_chunk_t *pStringNonFirstChunk;
|
||||
ecma_array_non_first_chunk_t *string_non_first_chunk_p;
|
||||
|
||||
JERRY_STATIC_ASSERT( ECMA_POINTER_FIELD_WIDTH <= sizeof(uint16_t) * JERRY_BITSINBYTE );
|
||||
uint16_t *pNextChunkCompressedPointer = &pStringFirstChunk->Header.pNextChunk;
|
||||
uint16_t *next_chunk_compressed_pointer_p = &string_first_chunk_p->header.next_chunk_p;
|
||||
|
||||
while ( charsLeft > 0 )
|
||||
while ( chars_left > 0 )
|
||||
{
|
||||
pStringNonFirstChunk = ecma_alloc_array_non_first_chunk();
|
||||
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk();
|
||||
|
||||
size_t charsToCopy = JERRY_MIN( charsLeft, sizeof (pStringNonFirstChunk->Data) / sizeof (ecma_char_t));
|
||||
__memcpy(pStringNonFirstChunk->Data, copyPointer, charsToCopy * sizeof (ecma_char_t));
|
||||
charsLeft -= charsToCopy;
|
||||
copyPointer += charsToCopy * sizeof (ecma_char_t);
|
||||
size_t chars_to_copy = JERRY_MIN( chars_left, sizeof (string_non_first_chunk_p->data) / sizeof (ecma_char_t));
|
||||
__memcpy(string_non_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
|
||||
chars_left -= chars_to_copy;
|
||||
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
|
||||
|
||||
ecma_set_pointer( *pNextChunkCompressedPointer, pStringNonFirstChunk);
|
||||
pNextChunkCompressedPointer = &pStringNonFirstChunk->pNextChunk;
|
||||
ecma_set_pointer( *next_chunk_compressed_pointer_p, string_non_first_chunk_p);
|
||||
next_chunk_compressed_pointer_p = &string_non_first_chunk_p->next_chunk_p;
|
||||
}
|
||||
|
||||
*pNextChunkCompressedPointer = ECMA_NULL_POINTER;
|
||||
*next_chunk_compressed_pointer_p = ECMA_NULL_POINTER;
|
||||
|
||||
return pStringFirstChunk;
|
||||
return string_first_chunk_p;
|
||||
} /* ecma_new_ecma_string */
|
||||
|
||||
/**
|
||||
@@ -530,44 +530,44 @@ ecma_new_ecma_string(const ecma_char_t *pString) /**< zero-terminated string of
|
||||
* to hold the string's content (in case size of buffer is insuficcient).
|
||||
*/
|
||||
ssize_t
|
||||
ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *pFirstChunk, /**< first chunk of ecma-string */
|
||||
uint8_t *pBuffer, /**< destination buffer */
|
||||
size_t bufferSize) /**< size of buffer */
|
||||
ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *first_chunk_p, /**< first chunk of ecma-string */
|
||||
uint8_t *buffer_p, /**< destination buffer */
|
||||
size_t buffer_size) /**< size of buffer */
|
||||
{
|
||||
ecma_length_t stringLength = pFirstChunk->Header.UnitNumber;
|
||||
size_t requiredBufferSize = sizeof (ecma_length_t) + sizeof (ecma_char_t) * stringLength;
|
||||
ecma_length_t string_length = first_chunk_p->header.unit_number;
|
||||
size_t required_buffer_size = sizeof (ecma_length_t) + sizeof (ecma_char_t) * string_length;
|
||||
|
||||
if ( requiredBufferSize < bufferSize )
|
||||
if ( required_buffer_size < buffer_size )
|
||||
{
|
||||
return -(ssize_t) requiredBufferSize;
|
||||
return -(ssize_t) required_buffer_size;
|
||||
}
|
||||
|
||||
*(ecma_length_t*) pBuffer = stringLength;
|
||||
*(ecma_length_t*) buffer_p = string_length;
|
||||
|
||||
size_t charsLeft = stringLength;
|
||||
uint8_t *destPointer = pBuffer + sizeof (ecma_length_t);
|
||||
size_t copyChunkChars = JERRY_MIN(sizeof (pFirstChunk->Data) / sizeof (ecma_char_t),
|
||||
charsLeft);
|
||||
__memcpy( destPointer, pFirstChunk->Data, copyChunkChars * sizeof (ecma_char_t));
|
||||
destPointer += copyChunkChars * sizeof (ecma_char_t);
|
||||
charsLeft -= copyChunkChars;
|
||||
size_t chars_left = string_length;
|
||||
uint8_t *dest_pointer = buffer_p + sizeof (ecma_length_t);
|
||||
size_t copy_chunk_chars = JERRY_MIN(sizeof (first_chunk_p->data) / sizeof (ecma_char_t),
|
||||
chars_left);
|
||||
__memcpy( dest_pointer, first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
||||
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
||||
chars_left -= copy_chunk_chars;
|
||||
|
||||
ecma_array_non_first_chunk_t *pNonFirstChunk = ecma_get_pointer( pFirstChunk->Header.pNextChunk);
|
||||
ecma_array_non_first_chunk_t *non_first_chunk_p = ecma_get_pointer( first_chunk_p->header.next_chunk_p);
|
||||
|
||||
while ( charsLeft > 0 )
|
||||
while ( chars_left > 0 )
|
||||
{
|
||||
JERRY_ASSERT( charsLeft < stringLength );
|
||||
JERRY_ASSERT( chars_left < string_length );
|
||||
|
||||
copyChunkChars = JERRY_MIN(sizeof (pNonFirstChunk->Data) / sizeof (ecma_char_t),
|
||||
charsLeft);
|
||||
__memcpy( destPointer, pNonFirstChunk->Data, copyChunkChars * sizeof (ecma_char_t));
|
||||
destPointer += copyChunkChars * sizeof (ecma_char_t);
|
||||
charsLeft -= copyChunkChars;
|
||||
copy_chunk_chars = JERRY_MIN(sizeof (non_first_chunk_p->data) / sizeof (ecma_char_t),
|
||||
chars_left);
|
||||
__memcpy( dest_pointer, non_first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
|
||||
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
|
||||
chars_left -= copy_chunk_chars;
|
||||
|
||||
pNonFirstChunk = ecma_get_pointer( pNonFirstChunk->pNextChunk);
|
||||
non_first_chunk_p = ecma_get_pointer( non_first_chunk_p->next_chunk_p);
|
||||
}
|
||||
|
||||
return (ssize_t) requiredBufferSize;
|
||||
return (ssize_t) required_buffer_size;
|
||||
} /* ecma_copy_ecma_string_chars_to_buffer */
|
||||
|
||||
/**
|
||||
@@ -576,31 +576,31 @@ ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *pFirstChunk, /**
|
||||
* @return pointer to new ecma-string's first chunk
|
||||
*/
|
||||
ecma_array_first_chunk_t*
|
||||
ecma_duplicate_ecma_string( ecma_array_first_chunk_t *pFirstChunk) /**< first chunk of string to duplicate */
|
||||
ecma_duplicate_ecma_string( ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of string to duplicate */
|
||||
{
|
||||
JERRY_ASSERT( pFirstChunk != NULL );
|
||||
JERRY_ASSERT( first_chunk_p != NULL );
|
||||
|
||||
ecma_array_first_chunk_t *pFirstChunkCopy = ecma_alloc_array_first_chunk();
|
||||
__memcpy( pFirstChunkCopy, pFirstChunk, sizeof (ecma_array_first_chunk_t));
|
||||
ecma_array_first_chunk_t *first_chunk_copy_p = ecma_alloc_array_first_chunk();
|
||||
__memcpy( first_chunk_copy_p, first_chunk_p, sizeof (ecma_array_first_chunk_t));
|
||||
|
||||
ecma_array_non_first_chunk_t *pNonFirstChunk, *pNonFirstChunkCopy;
|
||||
pNonFirstChunk = ecma_get_pointer( pFirstChunk->Header.pNextChunk);
|
||||
uint16_t *pNextPointer = &pFirstChunkCopy->Header.pNextChunk;
|
||||
ecma_array_non_first_chunk_t *non_first_chunk_p, *non_first_chunk_copy_p;
|
||||
non_first_chunk_p = ecma_get_pointer( first_chunk_p->header.next_chunk_p);
|
||||
uint16_t *next_pointer_p = &first_chunk_copy_p->header.next_chunk_p;
|
||||
|
||||
while ( pNonFirstChunk != NULL )
|
||||
while ( non_first_chunk_p != NULL )
|
||||
{
|
||||
pNonFirstChunkCopy = ecma_alloc_array_non_first_chunk();
|
||||
ecma_set_pointer( *pNextPointer, pNonFirstChunkCopy);
|
||||
pNextPointer = &pNonFirstChunkCopy->pNextChunk;
|
||||
non_first_chunk_copy_p = ecma_alloc_array_non_first_chunk();
|
||||
ecma_set_pointer( *next_pointer_p, non_first_chunk_copy_p);
|
||||
next_pointer_p = &non_first_chunk_copy_p->next_chunk_p;
|
||||
|
||||
__memcpy( pNonFirstChunkCopy, pNonFirstChunk, sizeof (ecma_array_non_first_chunk_t));
|
||||
__memcpy( non_first_chunk_copy_p, non_first_chunk_p, sizeof (ecma_array_non_first_chunk_t));
|
||||
|
||||
pNonFirstChunk = ecma_get_pointer( pNonFirstChunk->pNextChunk);
|
||||
non_first_chunk_p = ecma_get_pointer( non_first_chunk_p->next_chunk_p);
|
||||
}
|
||||
|
||||
*pNextPointer = ECMA_NULL_POINTER;
|
||||
*next_pointer_p = ECMA_NULL_POINTER;
|
||||
|
||||
return pFirstChunkCopy;
|
||||
return first_chunk_copy_p;
|
||||
} /* ecma_duplicate_ecma_string */
|
||||
|
||||
/**
|
||||
@@ -623,20 +623,20 @@ ecma_compare_ecma_string_to_ecma_string(const ecma_array_first_chunk_t *string1_
|
||||
* false - otherwise.
|
||||
*/
|
||||
bool
|
||||
ecma_compare_zt_string_to_ecma_string(const ecma_char_t *pString, /**< zero-terminated string */
|
||||
const ecma_array_first_chunk_t *pEcmaString) /* ecma-string */
|
||||
ecma_compare_zt_string_to_ecma_string(const ecma_char_t *string_p, /**< zero-terminated string */
|
||||
const ecma_array_first_chunk_t *ecma_string_p) /* ecma-string */
|
||||
{
|
||||
JERRY_ASSERT( pString != NULL );
|
||||
JERRY_ASSERT( pEcmaString != NULL );
|
||||
JERRY_ASSERT( string_p != NULL );
|
||||
JERRY_ASSERT( ecma_string_p != NULL );
|
||||
|
||||
const ecma_char_t *str_iter_p = pString;
|
||||
ecma_length_t ecma_str_len = pEcmaString->Header.UnitNumber;
|
||||
const ecma_char_t *current_chunk_chars_cur = (ecma_char_t*) pEcmaString->Data,
|
||||
*current_chunk_chars_end = (ecma_char_t*) (pEcmaString->Data
|
||||
+ sizeof(pEcmaString->Data));
|
||||
const ecma_char_t *str_iter_p = string_p;
|
||||
ecma_length_t ecma_str_len = ecma_string_p->header.unit_number;
|
||||
const ecma_char_t *current_chunk_chars_cur = (ecma_char_t*) ecma_string_p->data,
|
||||
*current_chunk_chars_end = (ecma_char_t*) (ecma_string_p->data
|
||||
+ sizeof(ecma_string_p->data));
|
||||
|
||||
JERRY_STATIC_ASSERT( ECMA_POINTER_FIELD_WIDTH <= sizeof(uint16_t) * JERRY_BITSINBYTE );
|
||||
const uint16_t *next_chunk_compressed_pointer_p = &pEcmaString->Header.pNextChunk;
|
||||
const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p;
|
||||
|
||||
for ( ecma_length_t str_index = 0;
|
||||
str_index < ecma_str_len;
|
||||
@@ -651,10 +651,10 @@ ecma_compare_zt_string_to_ecma_string(const ecma_char_t *pString, /**< zero-term
|
||||
|
||||
JERRY_ASSERT( next_chunk_p != NULL );
|
||||
|
||||
current_chunk_chars_cur = (ecma_char_t*) pEcmaString->Data;
|
||||
current_chunk_chars_end = (ecma_char_t*) (next_chunk_p->Data + sizeof(next_chunk_p->Data));
|
||||
current_chunk_chars_cur = (ecma_char_t*) ecma_string_p->data;
|
||||
current_chunk_chars_end = (ecma_char_t*) (next_chunk_p->data + sizeof(next_chunk_p->data));
|
||||
|
||||
next_chunk_compressed_pointer_p = &next_chunk_p->pNextChunk;
|
||||
next_chunk_compressed_pointer_p = &next_chunk_p->next_chunk_p;
|
||||
}
|
||||
|
||||
if ( *str_iter_p != *current_chunk_chars_cur )
|
||||
@@ -682,21 +682,21 @@ ecma_compare_zt_string_to_ecma_string(const ecma_char_t *pString, /**< zero-term
|
||||
* Free all chunks of an array
|
||||
*/
|
||||
void
|
||||
ecma_free_array( ecma_array_first_chunk_t *pFirstChunk) /**< first chunk of the array */
|
||||
ecma_free_array( ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
|
||||
{
|
||||
JERRY_ASSERT( pFirstChunk != NULL );
|
||||
JERRY_ASSERT( first_chunk_p != NULL );
|
||||
|
||||
ecma_array_non_first_chunk_t *pNonFirstChunk = ecma_get_pointer( pFirstChunk->Header.pNextChunk);
|
||||
ecma_array_non_first_chunk_t *non_first_chunk_p = ecma_get_pointer( first_chunk_p->header.next_chunk_p);
|
||||
|
||||
ecma_dealloc_array_first_chunk( pFirstChunk);
|
||||
ecma_dealloc_array_first_chunk( first_chunk_p);
|
||||
|
||||
while ( pNonFirstChunk != NULL )
|
||||
while ( non_first_chunk_p != NULL )
|
||||
{
|
||||
ecma_array_non_first_chunk_t *pNextChunk = ecma_get_pointer( pNonFirstChunk->pNextChunk);
|
||||
ecma_array_non_first_chunk_t *next_chunk_p = ecma_get_pointer( non_first_chunk_p->next_chunk_p);
|
||||
|
||||
ecma_dealloc_array_non_first_chunk( pNonFirstChunk);
|
||||
ecma_dealloc_array_non_first_chunk( non_first_chunk_p);
|
||||
|
||||
pNonFirstChunk = pNextChunk;
|
||||
non_first_chunk_p = next_chunk_p;
|
||||
}
|
||||
} /* ecma_free_array */
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "ecma-globals.h"
|
||||
|
||||
extern uintptr_t ecma_compress_pointer(void *pointer);
|
||||
extern void* ecma_decompress_pointer(uintptr_t compressedPointer);
|
||||
extern void* ecma_decompress_pointer(uintptr_t compressed_pointer);
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer field.
|
||||
@@ -36,10 +36,10 @@ extern void* ecma_decompress_pointer(uintptr_t compressedPointer);
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer field so that it will correspond
|
||||
* to specified nonCompressedPointer.
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ecma_set_pointer( field, nonCompressedPointer) \
|
||||
(field) = ecma_compress_pointer( nonCompressedPointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1)
|
||||
#define ecma_set_pointer( field, non_compressed_pointer) \
|
||||
(field) = ecma_compress_pointer( non_compressed_pointer) & ( ( 1u << ECMA_POINTER_FIELD_WIDTH ) - 1)
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
extern bool ecma_is_value_undefined( ecma_value_t value);
|
||||
@@ -66,13 +66,13 @@ extern bool ecma_is_completion_value_normal_simple_value( ecma_completion_value_
|
||||
extern bool ecma_is_completion_value_normal_false( ecma_completion_value_t value);
|
||||
extern bool ecma_is_completion_value_normal_true( ecma_completion_value_t value);
|
||||
|
||||
extern ecma_object_t* ecma_create_object( ecma_object_t *pPrototypeObject, bool isExtensible);
|
||||
extern ecma_object_t* ecma_create_lexical_environment( ecma_object_t *pOuterLexicalEnvironment, ecma_lexical_environment_type_t type);
|
||||
extern ecma_object_t* ecma_create_object( ecma_object_t *prototype_object_p, bool is_extensible);
|
||||
extern ecma_object_t* ecma_create_lexical_environment( ecma_object_t *outer_lexical_environment_p, ecma_lexical_environment_type_t type);
|
||||
|
||||
/* ecma-helpers.c */
|
||||
extern ecma_property_t* ecma_create_internal_property(ecma_object_t *pObject, ecma_internal_property_id_t propertyId);
|
||||
extern ecma_property_t* ecma_find_internal_property(ecma_object_t *pObject, ecma_internal_property_id_t propertyId);
|
||||
extern ecma_property_t* ecma_get_internal_property(ecma_object_t *pObject, ecma_internal_property_id_t propertyId);
|
||||
extern ecma_property_t* ecma_create_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
extern ecma_property_t* ecma_find_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
extern ecma_property_t* ecma_get_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
|
||||
extern ecma_property_t *ecma_create_named_property(ecma_object_t *obj_p, ecma_char_t *name_p, ecma_property_writable_value_t writable, ecma_property_enumerable_value_t enumerable, ecma_property_configurable_value_t configurable);
|
||||
extern ecma_property_t *ecma_find_named_property(ecma_object_t *obj_p, ecma_char_t *name_p);
|
||||
@@ -86,12 +86,12 @@ extern void ecma_free_property(ecma_property_t *prop_p);
|
||||
|
||||
extern void ecma_delete_property( ecma_object_t *obj_p, ecma_property_t *prop_p);
|
||||
|
||||
extern ecma_array_first_chunk_t* ecma_new_ecma_string( const ecma_char_t *pString);
|
||||
extern ssize_t ecma_copy_ecma_string_chars_to_buffer( ecma_array_first_chunk_t *pFirstChunk, uint8_t *pBuffer, size_t bufferSize);
|
||||
extern ecma_array_first_chunk_t* ecma_duplicate_ecma_string( ecma_array_first_chunk_t *pFirstChunk);
|
||||
extern bool ecma_compare_zt_string_to_ecma_string( const ecma_char_t *pString, const ecma_array_first_chunk_t *pEcmaString);
|
||||
extern ecma_array_first_chunk_t* ecma_new_ecma_string( const ecma_char_t *string_p);
|
||||
extern ssize_t ecma_copy_ecma_string_chars_to_buffer( ecma_array_first_chunk_t *first_chunk_p, uint8_t *buffer_p, size_t buffer_size);
|
||||
extern ecma_array_first_chunk_t* ecma_duplicate_ecma_string( ecma_array_first_chunk_t *first_chunk_p);
|
||||
extern bool ecma_compare_zt_string_to_ecma_string( const ecma_char_t *string_p, const ecma_array_first_chunk_t *ecma_string_p);
|
||||
extern bool ecma_compare_ecma_string_to_ecma_string(const ecma_array_first_chunk_t *string1_p, const ecma_array_first_chunk_t *string2_p);
|
||||
extern void ecma_free_array( ecma_array_first_chunk_t *pFirstChunk);
|
||||
extern void ecma_free_array( ecma_array_first_chunk_t *first_chunk_p);
|
||||
|
||||
#endif /* !JERRY_ECMA_HELPERS_H */
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ ecma_abstract_equality_compare(ecma_value_t x, /**< first operand */
|
||||
const bool is_x_undefined = ecma_is_value_undefined( x);
|
||||
const bool is_x_null = ecma_is_value_null( x);
|
||||
const bool is_x_boolean = ecma_is_value_boolean( x);
|
||||
const bool is_x_number = ( x.ValueType == ECMA_TYPE_NUMBER );
|
||||
const bool is_x_string = ( x.ValueType == ECMA_TYPE_STRING );
|
||||
const bool is_x_object = ( x.ValueType == ECMA_TYPE_OBJECT );
|
||||
const bool is_x_number = ( x.value_type == ECMA_TYPE_NUMBER );
|
||||
const bool is_x_string = ( x.value_type == ECMA_TYPE_STRING );
|
||||
const bool is_x_object = ( x.value_type == ECMA_TYPE_OBJECT );
|
||||
|
||||
const bool is_y_undefined = ecma_is_value_undefined( y);
|
||||
const bool is_y_null = ecma_is_value_null( y);
|
||||
const bool is_y_boolean = ecma_is_value_boolean( y);
|
||||
const bool is_y_number = ( y.ValueType == ECMA_TYPE_NUMBER );
|
||||
const bool is_y_string = ( y.ValueType == ECMA_TYPE_STRING );
|
||||
const bool is_y_object = ( y.ValueType == ECMA_TYPE_OBJECT );
|
||||
const bool is_y_number = ( y.value_type == ECMA_TYPE_NUMBER );
|
||||
const bool is_y_string = ( y.value_type == ECMA_TYPE_STRING );
|
||||
const bool is_y_object = ( y.value_type == ECMA_TYPE_OBJECT );
|
||||
|
||||
const bool is_types_equal = ( ( is_x_undefined && is_y_undefined )
|
||||
|| ( is_x_null && is_y_null )
|
||||
@@ -68,26 +68,26 @@ ecma_abstract_equality_compare(ecma_value_t x, /**< first operand */
|
||||
return true;
|
||||
} else if ( is_x_number )
|
||||
{ // c.
|
||||
ecma_number_t x_num = *(ecma_number_t*)( ecma_get_pointer(x.Value) );
|
||||
ecma_number_t y_num = *(ecma_number_t*)( ecma_get_pointer(y.Value) );
|
||||
ecma_number_t x_num = *(ecma_number_t*)( ecma_get_pointer(x.value) );
|
||||
ecma_number_t y_num = *(ecma_number_t*)( ecma_get_pointer(y.value) );
|
||||
|
||||
TODO( Implement according to ECMA );
|
||||
|
||||
return (x_num == y_num);
|
||||
} else if ( is_x_string )
|
||||
{ // d.
|
||||
ecma_array_first_chunk_t* x_str = (ecma_array_first_chunk_t*)( ecma_get_pointer(x.Value) );
|
||||
ecma_array_first_chunk_t* y_str = (ecma_array_first_chunk_t*)( ecma_get_pointer(y.Value) );
|
||||
ecma_array_first_chunk_t* x_str = (ecma_array_first_chunk_t*)( ecma_get_pointer(x.value) );
|
||||
ecma_array_first_chunk_t* y_str = (ecma_array_first_chunk_t*)( ecma_get_pointer(y.value) );
|
||||
|
||||
return ecma_compare_ecma_string_to_ecma_string( x_str, y_str);
|
||||
} else if ( is_x_boolean )
|
||||
{ // e.
|
||||
return ( x.Value == y.Value );
|
||||
return ( x.value == y.value );
|
||||
} else
|
||||
{ // f.
|
||||
JERRY_ASSERT( is_x_object );
|
||||
|
||||
return ( x.Value == y.Value );
|
||||
return ( x.value == y.value );
|
||||
}
|
||||
} else if ( ( is_x_null && is_y_undefined )
|
||||
|| ( is_x_undefined && is_y_null ) )
|
||||
|
||||
@@ -40,11 +40,11 @@
|
||||
ecma_completion_value_t
|
||||
ecma_op_check_object_coercible( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
switch ( (ecma_type_t)value.ValueType )
|
||||
switch ( (ecma_type_t)value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
{
|
||||
switch ( (ecma_simple_value_t)value.Value )
|
||||
switch ( (ecma_simple_value_t)value.value )
|
||||
{
|
||||
case ECMA_SIMPLE_VALUE_UNDEFINED:
|
||||
case ECMA_SIMPLE_VALUE_NULL:
|
||||
@@ -95,7 +95,7 @@ ecma_op_check_object_coercible( ecma_value_t value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_primitive( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
switch ( (ecma_type_t)value.ValueType )
|
||||
switch ( (ecma_type_t)value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_SIMPLE:
|
||||
case ECMA_TYPE_NUMBER:
|
||||
@@ -130,7 +130,7 @@ ecma_op_to_primitive( ecma_value_t value) /**< ecma-value */
|
||||
ecma_completion_value_t
|
||||
ecma_op_to_number( ecma_value_t value) /**< ecma-value */
|
||||
{
|
||||
switch ( (ecma_type_t)value.ValueType )
|
||||
switch ( (ecma_type_t)value.value_type )
|
||||
{
|
||||
case ECMA_TYPE_NUMBER:
|
||||
{
|
||||
|
||||
@@ -43,10 +43,10 @@ ecma_op_get_value( ecma_reference_t ref) /**< ECMA-reference */
|
||||
const ecma_value_t base = ref.base;
|
||||
const bool is_unresolvable_reference = ecma_is_value_undefined( base);
|
||||
const bool has_primitive_base = ( ecma_is_value_boolean( base)
|
||||
|| base.ValueType == ECMA_TYPE_NUMBER
|
||||
|| base.ValueType == ECMA_TYPE_STRING );
|
||||
const bool has_object_base = ( base.ValueType == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_object_t*)ecma_get_pointer(base.Value))->IsLexicalEnvironment );
|
||||
|| base.value_type == ECMA_TYPE_NUMBER
|
||||
|| base.value_type == ECMA_TYPE_STRING );
|
||||
const bool has_object_base = ( base.value_type == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_object_t*)ecma_get_pointer(base.value))->is_lexical_environment );
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
// GetValue_3
|
||||
@@ -60,8 +60,8 @@ ecma_op_get_value( ecma_reference_t ref) /**< ECMA-reference */
|
||||
{
|
||||
if ( !has_primitive_base ) // GetValue_4.a
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_pointer( base.Value);
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->IsLexicalEnvironment );
|
||||
ecma_object_t *obj_p = ecma_get_pointer( base.value);
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->is_lexical_environment );
|
||||
|
||||
// GetValue_4.b case 1
|
||||
/* return [[Get]]( base as this, ref.referenced_name_p) */
|
||||
@@ -70,18 +70,18 @@ ecma_op_get_value( ecma_reference_t ref) /**< ECMA-reference */
|
||||
{ // GetValue_4.b case 2
|
||||
/*
|
||||
ecma_object_t *obj_p = ecma_ToObject( base);
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->is_lexical_environment );
|
||||
ecma_property_t *property = obj_p->[[GetProperty]]( ref.referenced_name_p);
|
||||
if ( property->Type == ECMA_PROPERTY_NAMEDDATA )
|
||||
{
|
||||
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_copy_value( property->u.NamedDataProperty.Value),
|
||||
ecma_copy_value( property->u.named_data_property.value),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} else
|
||||
{
|
||||
JERRY_ASSERT( property->Type == ECMA_PROPERTY_NAMEDACCESSOR );
|
||||
|
||||
ecma_object_t *getter = ecma_get_pointer( property->u.NamedAccessorProperty.pGet);
|
||||
ecma_object_t *getter = ecma_get_pointer( property->u.named_accessor_property.get_p);
|
||||
|
||||
if ( getter == NULL )
|
||||
{
|
||||
@@ -99,9 +99,9 @@ ecma_op_get_value( ecma_reference_t ref) /**< ECMA-reference */
|
||||
} else
|
||||
{
|
||||
// GetValue_5
|
||||
ecma_object_t *lex_env_p = ecma_get_pointer( base.Value);
|
||||
ecma_object_t *lex_env_p = ecma_get_pointer( base.value);
|
||||
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
return ecma_op_get_binding_value( lex_env_p, ref.referenced_name_p, ref.is_strict);
|
||||
}
|
||||
@@ -122,10 +122,10 @@ ecma_op_put_value(ecma_reference_t ref, /**< ECMA-reference */
|
||||
const ecma_value_t base = ref.base;
|
||||
const bool is_unresolvable_reference = ecma_is_value_undefined( base);
|
||||
const bool has_primitive_base = ( ecma_is_value_boolean( base)
|
||||
|| base.ValueType == ECMA_TYPE_NUMBER
|
||||
|| base.ValueType == ECMA_TYPE_STRING );
|
||||
const bool has_object_base = ( base.ValueType == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_object_t*)ecma_get_pointer(base.Value))->IsLexicalEnvironment );
|
||||
|| base.value_type == ECMA_TYPE_NUMBER
|
||||
|| base.value_type == ECMA_TYPE_STRING );
|
||||
const bool has_object_base = ( base.value_type == ECMA_TYPE_OBJECT
|
||||
&& !((ecma_object_t*)ecma_get_pointer(base.value))->is_lexical_environment );
|
||||
const bool is_property_reference = has_primitive_base || has_object_base;
|
||||
|
||||
if ( is_unresolvable_reference ) // PutValue_3
|
||||
@@ -158,7 +158,7 @@ ecma_op_put_value(ecma_reference_t ref, /**< ECMA-reference */
|
||||
/*
|
||||
// PutValue_sub_1
|
||||
ecma_object_t *obj_p = ecma_ToObject( base);
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( obj_p != NULL && !obj_p->is_lexical_environment );
|
||||
|
||||
// PutValue_sub_2
|
||||
if ( !obj_p->[[CanPut]]( ref.referenced_name_p) )
|
||||
@@ -200,7 +200,7 @@ ecma_op_put_value(ecma_reference_t ref, /**< ECMA-reference */
|
||||
if ( ecma_OpIsAccessorDescriptor( prop) )
|
||||
{
|
||||
// PutValue_sub_6.a
|
||||
ecma_object_t *setter = ecma_get_pointer( property->u.NamedAccessorProperty.pSet);
|
||||
ecma_object_t *setter = ecma_get_pointer( property->u.named_accessor_property.set_p);
|
||||
JERRY_ASSERT( setter != NULL );
|
||||
|
||||
// PutValue_sub_6.b
|
||||
@@ -225,9 +225,9 @@ ecma_op_put_value(ecma_reference_t ref, /**< ECMA-reference */
|
||||
} else
|
||||
{
|
||||
// PutValue_7
|
||||
ecma_object_t *lex_env_p = ecma_get_pointer( base.Value);
|
||||
ecma_object_t *lex_env_p = ecma_get_pointer( base.value);
|
||||
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
return ecma_op_set_mutable_binding( lex_env_p, ref.referenced_name_p, value, ref.is_strict);
|
||||
}
|
||||
|
||||
@@ -41,11 +41,11 @@ ecma_completion_value_t
|
||||
ecma_op_has_binding(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
ecma_simple_value_t has_binding = ECMA_SIMPLE_VALUE_UNDEFINED;
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -81,10 +81,10 @@ ecma_op_create_mutable_binding(ecma_object_t *lex_env_p, /**< lexical environmen
|
||||
ecma_char_t *name_p, /**< argument N */
|
||||
bool is_deletable) /**< argument D */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
JERRY_ASSERT( name_p != NULL );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -125,21 +125,21 @@ ecma_op_set_mutable_binding(ecma_object_t *lex_env_p, /**< lexical environment *
|
||||
ecma_value_t value, /**< argument V */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
JERRY_ASSERT( name_p != NULL );
|
||||
|
||||
JERRY_ASSERT( ecma_is_completion_value_normal_true( ecma_op_has_binding( lex_env_p, name_p)) );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
ecma_property_t *property_p = ecma_get_named_data_property( lex_env_p, name_p);
|
||||
|
||||
if ( property_p->u.NamedDataProperty.Writable == ECMA_PROPERTY_WRITABLE )
|
||||
if ( property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE )
|
||||
{
|
||||
ecma_free_value( property_p->u.NamedDataProperty.Value);
|
||||
property_p->u.NamedDataProperty.Value = ecma_copy_value( value);
|
||||
ecma_free_value( property_p->u.named_data_property.value);
|
||||
property_p->u.named_data_property.value = ecma_copy_value( value);
|
||||
} else if ( is_strict )
|
||||
{
|
||||
return ecma_make_throw_value( ecma_new_standard_error( ECMA_ERROR_TYPE));
|
||||
@@ -171,27 +171,27 @@ ecma_op_get_binding_value(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_char_t *name_p, /**< argument N */
|
||||
bool is_strict) /**< argument S */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
JERRY_ASSERT( name_p != NULL );
|
||||
|
||||
JERRY_ASSERT( ecma_is_completion_value_normal_true( ecma_op_has_binding( lex_env_p, name_p)) );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
ecma_property_t *property_p = ecma_get_named_data_property( lex_env_p, name_p);
|
||||
|
||||
ecma_value_t prop_value = property_p->u.NamedDataProperty.Value;
|
||||
ecma_value_t prop_value = property_p->u.named_data_property.value;
|
||||
|
||||
/* is the binding mutable? */
|
||||
if ( property_p->u.NamedDataProperty.Writable == ECMA_PROPERTY_WRITABLE )
|
||||
if ( property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE )
|
||||
{
|
||||
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
|
||||
ecma_copy_value( prop_value),
|
||||
ECMA_TARGET_ID_RESERVED);
|
||||
} else if ( prop_value.ValueType == ECMA_TYPE_SIMPLE
|
||||
&& prop_value.Value == ECMA_SIMPLE_VALUE_EMPTY )
|
||||
} else if ( prop_value.value_type == ECMA_TYPE_SIMPLE
|
||||
&& prop_value.value == ECMA_SIMPLE_VALUE_EMPTY )
|
||||
{
|
||||
/* unitialized immutable binding */
|
||||
if ( is_strict )
|
||||
@@ -229,10 +229,10 @@ ecma_completion_value_t
|
||||
ecma_op_delete_binding(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
JERRY_ASSERT( name_p != NULL );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -244,9 +244,9 @@ ecma_op_delete_binding(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ret_val = ECMA_SIMPLE_VALUE_TRUE;
|
||||
} else
|
||||
{
|
||||
JERRY_ASSERT( prop_p->Type == ECMA_PROPERTY_NAMEDDATA );
|
||||
JERRY_ASSERT( prop_p->type == ECMA_PROPERTY_NAMEDDATA );
|
||||
|
||||
if ( prop_p->u.NamedDataProperty.Configurable == ECMA_PROPERTY_NOT_CONFIGURABLE )
|
||||
if ( prop_p->u.named_data_property.configurable == ECMA_PROPERTY_NOT_CONFIGURABLE )
|
||||
{
|
||||
ret_val = ECMA_SIMPLE_VALUE_FALSE;
|
||||
} else
|
||||
@@ -281,9 +281,9 @@ ecma_op_delete_binding(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_completion_value_t
|
||||
ecma_op_implicit_this_value( ecma_object_t *lex_env_p) /**< lexical environment */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -309,9 +309,9 @@ void
|
||||
ecma_op_create_immutable_binding(ecma_object_t *lex_env_p, /**< lexical environment */
|
||||
ecma_char_t *name_p) /**< argument N */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -327,9 +327,9 @@ ecma_op_create_immutable_binding(ecma_object_t *lex_env_p, /**< lexical environm
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
|
||||
JERRY_ASSERT( prop_p->u.NamedDataProperty.Value.ValueType == ECMA_TYPE_SIMPLE );
|
||||
JERRY_ASSERT( prop_p->u.named_data_property.value.value_type == ECMA_TYPE_SIMPLE );
|
||||
|
||||
prop_p->u.NamedDataProperty.Value.Value = ECMA_SIMPLE_VALUE_EMPTY;
|
||||
prop_p->u.named_data_property.value.value = ECMA_SIMPLE_VALUE_EMPTY;
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
{
|
||||
@@ -350,9 +350,9 @@ ecma_op_initialize_immutable_binding(ecma_object_t *lex_env_p, /**< lexical envi
|
||||
ecma_char_t *name_p, /**< argument N */
|
||||
ecma_value_t value) /**< argument V */
|
||||
{
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->IsLexicalEnvironment );
|
||||
JERRY_ASSERT( lex_env_p != NULL && lex_env_p->is_lexical_environment );
|
||||
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.LexicalEnvironment.Type )
|
||||
switch ( (ecma_lexical_environment_type_t) lex_env_p->u.lexical_environment.type )
|
||||
{
|
||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||
{
|
||||
@@ -361,11 +361,11 @@ ecma_op_initialize_immutable_binding(ecma_object_t *lex_env_p, /**< lexical envi
|
||||
ecma_property_t *prop_p = ecma_get_named_data_property( lex_env_p, name_p);
|
||||
|
||||
/* The binding must be unitialized immutable binding */
|
||||
JERRY_ASSERT( prop_p->u.NamedDataProperty.Writable == ECMA_PROPERTY_NOT_WRITABLE
|
||||
&& prop_p->u.NamedDataProperty.Value.ValueType == ECMA_TYPE_SIMPLE
|
||||
&& prop_p->u.NamedDataProperty.Value.Value == ECMA_SIMPLE_VALUE_EMPTY );
|
||||
JERRY_ASSERT( prop_p->u.named_data_property.writable == ECMA_PROPERTY_NOT_WRITABLE
|
||||
&& prop_p->u.named_data_property.value.value_type == ECMA_TYPE_SIMPLE
|
||||
&& prop_p->u.named_data_property.value.value == ECMA_SIMPLE_VALUE_EMPTY );
|
||||
|
||||
prop_p->u.NamedDataProperty.Value = ecma_copy_value( value);
|
||||
prop_p->u.named_data_property.value = ecma_copy_value( value);
|
||||
}
|
||||
case ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND:
|
||||
{
|
||||
|
||||
@@ -63,7 +63,7 @@ ecma_op_get_identifier_reference(ecma_object_t *lex_env_p, /**< lexical environm
|
||||
JERRY_ASSERT( ecma_is_completion_value_normal_false( completion_value) );
|
||||
}
|
||||
|
||||
lex_env_iter_p = ecma_get_pointer( lex_env_iter_p->u.LexicalEnvironment.pOuterReference);
|
||||
lex_env_iter_p = ecma_get_pointer( lex_env_iter_p->u.lexical_environment.outer_reference_p);
|
||||
}
|
||||
|
||||
return ecma_make_reference( ecma_make_simple_value( ECMA_SIMPLE_VALUE_UNDEFINED),
|
||||
|
||||
@@ -59,10 +59,10 @@ __memset(void *s, /**< area to set values in */
|
||||
int c, /**< value to set */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
uint8_t *pArea = s;
|
||||
uint8_t *area_p = s;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
{
|
||||
pArea[ index ] = (uint8_t)c;
|
||||
area_p[ index ] = (uint8_t)c;
|
||||
}
|
||||
|
||||
return s;
|
||||
@@ -80,13 +80,13 @@ __memcmp(const void *s1, /**< first area */
|
||||
const void *s2, /**< second area */
|
||||
size_t n) /**< area size */
|
||||
{
|
||||
const uint8_t *pArea1 = s1, *pArea2 = s2;
|
||||
const uint8_t *area1_p = s1, *area2_p = s2;
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
{
|
||||
if ( pArea1[ index ] < pArea2[ index ] )
|
||||
if ( area1_p[ index ] < area2_p[ index ] )
|
||||
{
|
||||
return -1;
|
||||
} else if ( pArea1[ index ] > pArea2[ index ] )
|
||||
} else if ( area1_p[ index ] > area2_p[ index ] )
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
@@ -103,12 +103,12 @@ __memcpy(void *s1, /**< destination */
|
||||
const void *s2, /**< source */
|
||||
size_t n) /**< bytes number */
|
||||
{
|
||||
uint8_t *pArea1 = s1;
|
||||
const uint8_t *pArea2 = s2;
|
||||
uint8_t *area1_p = s1;
|
||||
const uint8_t *area2_p = s2;
|
||||
|
||||
for ( size_t index = 0; index < n; index++ )
|
||||
{
|
||||
pArea1[ index ] = pArea2[ index ];
|
||||
area1_p[ index ] = area2_p[ index ];
|
||||
}
|
||||
|
||||
return s1;
|
||||
|
||||
Reference in New Issue
Block a user