mirror of
https://github.com/Ed94/gencpp.git
synced 2025-06-14 18:51:47 -07:00
Adding tuning macros for memory usage of the library, fixes.
Reduced the sanity test case to half its original iterations.
This commit is contained in:
@ -4115,6 +4115,7 @@ CodeAttributes parse_attributes( Parser::TokArray& toks, char const* context )
|
||||
using namespace Parser;
|
||||
|
||||
Token start;
|
||||
s32 len = 0;
|
||||
|
||||
if ( check(TokType::Attribute_Open) )
|
||||
{
|
||||
@ -4126,6 +4127,8 @@ CodeAttributes parse_attributes( Parser::TokArray& toks, char const* context )
|
||||
}
|
||||
|
||||
eat( TokType::Attribute_Close );
|
||||
|
||||
s32 len = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)start.Text;
|
||||
}
|
||||
|
||||
else if ( check(TokType::Decl_GNU_Attribute) )
|
||||
@ -4140,6 +4143,8 @@ CodeAttributes parse_attributes( Parser::TokArray& toks, char const* context )
|
||||
|
||||
eat(TokType::BraceCurly_Close);
|
||||
eat(TokType::BraceCurly_Close);
|
||||
|
||||
s32 len = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)start.Text;
|
||||
}
|
||||
|
||||
else if ( check(TokType::Decl_MSVC_Attribute) )
|
||||
@ -4153,15 +4158,16 @@ CodeAttributes parse_attributes( Parser::TokArray& toks, char const* context )
|
||||
}
|
||||
|
||||
eat(TokType::BraceCurly_Close);
|
||||
|
||||
s32 len = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)start.Text;
|
||||
}
|
||||
|
||||
else if ( tok_is_attribute( currtok ) )
|
||||
{
|
||||
eat(currtok.Type);
|
||||
s32 len = start.Length;
|
||||
}
|
||||
|
||||
s32 len = ( (sptr)prevtok.Text + prevtok.Length ) - (sptr)start.Text;
|
||||
|
||||
if ( len > 0 )
|
||||
{
|
||||
StrC attribute_txt = { len, start.Text };
|
||||
@ -6237,7 +6243,7 @@ CodeUsing parse_using( Parser::TokArray& toks, char const* context )
|
||||
{
|
||||
using namespace Parser;
|
||||
|
||||
SpecifierT specs_found[16] { ESpecifier::Num_Specifiers };
|
||||
SpecifierT specs_found[16] { ESpecifier::Invalid };
|
||||
s32 num_specifiers = 0;
|
||||
|
||||
Token name = { nullptr, 0, TokType::Invalid };
|
||||
@ -6416,11 +6422,13 @@ sw token_fmt_va( char* buf, uw buf_size, s32 num_tokens, va_list va )
|
||||
char const* buf_begin = buf;
|
||||
sw remaining = buf_size;
|
||||
|
||||
static Arena tok_map_arena;
|
||||
local_persist
|
||||
Arena tok_map_arena;
|
||||
|
||||
HashTable<StrC> tok_map;
|
||||
{
|
||||
static char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
|
||||
local_persist
|
||||
char tok_map_mem[ TokenFmt_TokenMap_MemSize ];
|
||||
|
||||
tok_map_arena = Arena::init_from_memory( tok_map_mem, sizeof(tok_map_mem) );
|
||||
|
||||
|
@ -1888,26 +1888,52 @@ StrC token_fmt_impl( sw num, ... )
|
||||
extern CodeType t_f64;
|
||||
#endif
|
||||
|
||||
#ifndef GEN_GLOBAL_BUCKET_SIZE
|
||||
# define GEN_GLOBAL_BUCKET_SIZE megabytes(10)
|
||||
#endif
|
||||
#ifndef GEN_CODEPOOL_NUM_BLOCKS
|
||||
# define GEN_CODEPOOL_NUM_BLOCKS kilobytes(64)
|
||||
#endif
|
||||
#ifndef GEN_SIZE_PER_STRING_ARENA
|
||||
# define GEN_SIZE_PER_STRING_ARENA megabytes(1)
|
||||
#endif
|
||||
#ifndef GEN_MAX_COMMENT_LINE_LENGTH
|
||||
# define GEN_MAX_COMMENT_LINE_LENGTH 1024
|
||||
#endif
|
||||
#ifndef GEN_MAX_NAME_LENGTH
|
||||
# define GEN_MAX_NAME_LENGTH 128
|
||||
#endif
|
||||
#ifndef GEN_MAX_UNTYPED_STR_LENGTH
|
||||
# define GEN_MAX_UNTYPED_STR_LENGTH kilobytes(640)
|
||||
#endif
|
||||
#ifndef GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE
|
||||
# define GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE kilobytes(4)
|
||||
#endif
|
||||
#ifndef GEN_LEX_ALLOCATOR_SIZE
|
||||
# define GEN_LEX_ALLOCATOR_SIZE megabytes(10)
|
||||
#endif
|
||||
#ifndef GEN_BUILDER_STR_BUFFER_RESERVE
|
||||
# define GEN_BUILDER_STR_BUFFER_RESERVE megabytes(1)
|
||||
#endif
|
||||
|
||||
// These constexprs are used for allocation behavior of data structures
|
||||
// or string handling while constructing or serializing.
|
||||
// Change them to suit your needs.
|
||||
|
||||
constexpr s32 InitSize_DataArrays = 16;
|
||||
constexpr s32 InitSize_StringTable = megabytes(4);
|
||||
constexpr s32 InitSize_DataArrays = 16;
|
||||
|
||||
// NOTE: This limits the maximum size of an allocation
|
||||
// If you are generating a string larger than this, increase the size of the bucket here.
|
||||
constexpr uw Global_BucketSize = megabytes(10);
|
||||
constexpr s32 CodePool_NumBlocks = kilobytes(64);
|
||||
constexpr s32 SizePer_StringArena = megabytes(1);
|
||||
constexpr uw Global_BucketSize = GEN_GLOBAL_BUCKET_SIZE;
|
||||
constexpr s32 CodePool_NumBlocks = GEN_CODEPOOL_NUM_BLOCKS;
|
||||
constexpr s32 SizePer_StringArena = GEN_SIZE_PER_STRING_ARENA;
|
||||
|
||||
constexpr s32 MaxCommentLineLength = 1024;
|
||||
constexpr s32 MaxNameLength = 128;
|
||||
constexpr s32 MaxUntypedStrLength = kilobytes(640);
|
||||
constexpr s32 StringTable_MaxHashLength = kilobytes(1);
|
||||
constexpr s32 TokenFmt_TokenMap_MemSize = kilobytes(4);
|
||||
constexpr s32 LexAllocator_Size = megabytes(10);
|
||||
constexpr s32 Builder_StrBufferReserve = megabytes(1);
|
||||
constexpr s32 MaxCommentLineLength = GEN_MAX_COMMENT_LINE_LENGTH;
|
||||
constexpr s32 MaxNameLength = GEN_MAX_NAME_LENGTH;
|
||||
constexpr s32 MaxUntypedStrLength = GEN_MAX_UNTYPED_STR_LENGTH;
|
||||
constexpr s32 TokenFmt_TokenMap_MemSize = GEN_TOKEN_FMT_TOKEN_MAP_MEM_SIZE;
|
||||
constexpr s32 LexAllocator_Size = GEN_LEX_ALLOCATOR_SIZE;
|
||||
constexpr s32 Builder_StrBufferReserve = GEN_BUILDER_STR_BUFFER_RESERVE;
|
||||
|
||||
extern CodeType t_auto;
|
||||
extern CodeType t_void;
|
||||
|
Reference in New Issue
Block a user