diff --git a/Makefile b/Makefile index f23600d63..575f0a46a 100644 --- a/Makefile +++ b/Makefile @@ -68,18 +68,18 @@ SIZE = $(CROSS_COMPILE)size STRIP = $(CROSS_COMPILE)strip # General flags -CFLAGS ?= $(INCLUDES) -std=c99 -m32 #-fdiagnostics-color=always -#CFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Winline -#CFLAGS += -Wformat-nonliteral -Winit-self -Wstack-protector -#CFLAGS += -Wconversion -Wsign-conversion -Wformat-security -#CFLAGS += -Wstrict-prototypes -Wmissing-prototypes +CFLAGS ?= $(INCLUDES) -std=c99 #-fdiagnostics-color=always +CFLAGS += -Wall -Wextra -Wpedantic -Wlogical-op -Winline +CFLAGS += -Wformat-nonliteral -Winit-self -Wstack-protector +CFLAGS += -Wconversion -Wsign-conversion -Wformat-security +CFLAGS += -Wstrict-prototypes -Wmissing-prototypes # Flags for MCU MCU_CFLAGS += -mlittle-endian -mcpu=cortex-m4 -march=armv7e-m -mthumb MCU_CFLAGS += -mfpu=fpv4-sp-d16 -mfloat-abi=hard MCU_CFLAGS += -ffunction-sections -fdata-sections -DEBUG_OPTIONS = -g3 -O0 -DJERRY_NDEBUG# -fsanitize=address +DEBUG_OPTIONS = -g3 -O0 # -fsanitize=address RELEASE_OPTIONS = -Os -Werror -DJERRY_NDEBUG DEFINES = -DMEM_HEAP_CHUNK_SIZE=256 -DMEM_HEAP_AREA_SIZE=32768 -DMEM_STATS diff --git a/src/globals.h b/src/globals.h index f421c9623..601af677e 100644 --- a/src/globals.h +++ b/src/globals.h @@ -55,7 +55,11 @@ typedef signed int int32_t; */ #define JERRY_STATIC_ASSERT_GLUE_( a, b ) a ## b #define JERRY_STATIC_ASSERT_GLUE( a, b ) JERRY_STATIC_ASSERT_GLUE_( a, b ) -#define JERRY_STATIC_ASSERT( x ) typedef char JERRY_STATIC_ASSERT_GLUE( static_assertion_failed_, __LINE__) [ ( x ) ? 1 : -1 ] +#define JERRY_STATIC_ASSERT( x ) typedef char JERRY_STATIC_ASSERT_GLUE( static_assertion_failed_, __LINE__) [ ( x ) ? 1 : -1 ] __unused + +#define CALL_PRAGMA(x) _Pragma (#x) +#define TODO(x) CALL_PRAGMA(message ("TODO - " #x)) +#define FIXME(x) CALL_PRAGMA(message ("FIXME - " #x)) /** * Variable that must not be referenced. diff --git a/src/liballocator/mem-heap.c b/src/liballocator/mem-heap.c index 4a4b26a24..dc97f21d2 100644 --- a/src/liballocator/mem-heap.c +++ b/src/liballocator/mem-heap.c @@ -96,9 +96,9 @@ typedef struct */ mem_HeapState_t mem_Heap; -static inline size_t mem_get_block_chunks_count( const mem_BlockHeader_t *block_header_p); -static inline size_t mem_get_block_data_space_size( const mem_BlockHeader_t *block_header_p); -static inline size_t mem_get_block_chunks_count_from_data_size( size_t block_allocated_size); +static size_t mem_get_block_chunks_count( const mem_BlockHeader_t *block_header_p); +static size_t mem_get_block_data_space_size( const mem_BlockHeader_t *block_header_p); +static size_t mem_get_block_chunks_count_from_data_size( size_t block_allocated_size); static void mem_InitBlockHeader( uint8_t *pFirstChunk, size_t sizeInChunks, @@ -119,7 +119,7 @@ static void mem_HeapStatFreeBlock( mem_BlockHeader_t *block_header_p); static void mem_HeapStatFreeBlockSplit( void); static void mem_HeapStatFreeBlockMerge( void); #else /* !MEM_STATS */ -# define mem_InitStats() +# define mem_HeapStatInit() # define mem_HeapStatAllocBlock( v) # define mem_HeapStatFreeBlock( v) # define mem_HeapStatFreeBlockSplit() @@ -131,7 +131,7 @@ static void mem_HeapStatFreeBlockMerge( void); * * @return chunks count */ -static inline size_t +static size_t mem_get_block_chunks_count( const mem_BlockHeader_t *block_header_p) /**< block header */ { JERRY_ASSERT( block_header_p != NULL ); @@ -158,7 +158,7 @@ mem_get_block_chunks_count( const mem_BlockHeader_t *block_header_p) /**< block * * @return size of block area that can be used to store data */ -static inline size_t +static size_t mem_get_block_data_space_size( const mem_BlockHeader_t *block_header_p) /**< block header */ { return mem_get_block_chunks_count( block_header_p) * MEM_HEAP_CHUNK_SIZE - sizeof (mem_BlockHeader_t); @@ -169,7 +169,7 @@ mem_get_block_data_space_size( const mem_BlockHeader_t *block_header_p) /**< blo * * @return chunks count */ -static inline size_t +static size_t mem_get_block_chunks_count_from_data_size( size_t block_allocated_size) /**< size of block's allocated area */ { return JERRY_ALIGNUP( sizeof (mem_BlockHeader_t) + block_allocated_size, MEM_HEAP_CHUNK_SIZE) / MEM_HEAP_CHUNK_SIZE; diff --git a/src/liballocator/mem-poolman.c b/src/liballocator/mem-poolman.c index b8a2d1f8f..f084ceec6 100644 --- a/src/liballocator/mem-poolman.c +++ b/src/liballocator/mem-poolman.c @@ -65,13 +65,28 @@ static void mem_PoolsStatFreePool( mem_PoolChunkType_t); static void mem_PoolsStatAllocChunk( mem_PoolChunkType_t); static void mem_PoolsStatFreeChunk( mem_PoolChunkType_t); #else /* !MEM_STATS */ -# define mem_PoolsStatsInit() -# define mem_PoolsStatAllocPool() -# define mem_PoolsStatsFreePool() -# define mem_PoolsStatAllocChunk() -# define mem_PoolsStatFreeChunk() +# define mem_PoolsStatInit() +# define mem_PoolsStatAllocPool(v) +# define mem_PoolsStatFreePool(v) +# define mem_PoolsStatAllocChunk(v) +# define mem_PoolsStatFreeChunk(v) #endif /* !MEM_STATS */ +/** + * Get chunk size from chunk type. + * + * @return size (in bytes) of chunk of specified type + */ +size_t +mem_GetChunkSize( mem_PoolChunkType_t chunkType) /**< chunk type */ +{ + uint32_t chunkTypeId = (uint32_t) chunkType; + + JERRY_ASSERT( chunkTypeId < MEM_POOL_CHUNK_TYPE__COUNT ); + + return ( 1u << ( chunkTypeId + 2 ) ); +} /* mem_GetChunkSize */ + /** * Initialize pool manager */ diff --git a/src/liballocator/mem-poolman.h b/src/liballocator/mem-poolman.h index 36da10af9..dd2e08582 100644 --- a/src/liballocator/mem-poolman.h +++ b/src/liballocator/mem-poolman.h @@ -51,21 +51,7 @@ typedef enum { ((size) == 64 ? MEM_POOL_CHUNK_TYPE_64 : \ jerry_UnreferencedExpression))))) -/** - * Get chunk size from chunk type. - * - * @return size (in bytes) of chunk of specified type - */ -static inline size_t -mem_GetChunkSize( mem_PoolChunkType_t chunkType) /**< chunk type */ -{ - uint32_t chunkTypeId = (uint32_t) chunkType; - - JERRY_ASSERT( chunkTypeId < MEM_POOL_CHUNK_TYPE__COUNT ); - - return ( 1u << ( chunkTypeId + 2 ) ); -} /* mem_GetChunkSize */ - +extern size_t mem_GetChunkSize( mem_PoolChunkType_t chunkType); extern void mem_PoolsInit(void); extern uint8_t* mem_PoolsAlloc(mem_PoolChunkType_t chunkType); diff --git a/src/libcoreint/interpreter.c b/src/libcoreint/interpreter.c index 088de1733..7ba03e17d 100644 --- a/src/libcoreint/interpreter.c +++ b/src/libcoreint/interpreter.c @@ -32,12 +32,12 @@ gen_bytecode () wait(500); } */ -// save_op_data (0, getop_loop_inf (1)); -// save_op_data (1, getop_call_1 (0, 12)); -// save_op_data (2, getop_call_1 (0, 13)); -// save_op_data (3, getop_call_1 (0, 14)); -// save_op_data (4, getop_call_1 (0, 15)); -// save_op_data (5, getop_jmp (0)); + // save_op_data (0, getop_loop_inf (1)); + // save_op_data (1, getop_call_1 (0, 12)); + // save_op_data (2, getop_call_1 (0, 13)); + // save_op_data (3, getop_call_1 (0, 14)); + // save_op_data (4, getop_call_1 (0, 15)); + // save_op_data (5, getop_jmp (0)); #ifdef __MCU // It's mandatory to restart app! @@ -64,7 +64,7 @@ run_int () while (true) { - run_int_from_pos(&int_data); + run_int_from_pos (&int_data); } } diff --git a/src/libcoreint/interpreter.h b/src/libcoreint/interpreter.h index 9e1a993eb..df556e39c 100644 --- a/src/libcoreint/interpreter.h +++ b/src/libcoreint/interpreter.h @@ -31,10 +31,10 @@ opfunc __opfuncs[LAST_OP]; struct __int_data { - int pos; + int pos; /**< current opcode to execute */ ecma_Object_t *pThisBinding; /**< this binding for current context */ ecma_Object_t *pLexEnv; /**< current lexical environment */ - int *root_op_addr; + int *root_op_addr; /**< pointer to first opcode saved */ }; void gen_bytecode (void); diff --git a/src/main.c b/src/main.c index 092390120..2ee4efd88 100644 --- a/src/main.c +++ b/src/main.c @@ -77,7 +77,7 @@ main (int argc, char **argv) } #endif - // FIXME: Call parser + TODO(Call parser); //gen_bytecode (generated_source); //gen_bytecode (); diff --git a/tests/unit/test_poolman.c b/tests/unit/test_poolman.c index 2c11deb7a..fa5fc56a9 100644 --- a/tests/unit/test_poolman.c +++ b/tests/unit/test_poolman.c @@ -93,8 +93,10 @@ main( int __unused argc, } } +#ifdef MEM_STATS mem_PoolsStats_t stats; mem_PoolsGetStats( &stats); +#endif /* MEM_STATS */ __printf("Pools stats:\n"); for(mem_PoolChunkType_t type = 0;