Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/arena.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,13 @@
*/
#define PM_ARENA_BLOCK_SIZE(data_size) (offsetof(pm_arena_block_t, data) + (data_size))

/** Initial block data size: 8 KB. */
/**
* Initial block data size: 8 KB. An embedder on a small heap can define a
* smaller one; a parse of a short program then takes blocks of that size.
*/
#ifndef PM_ARENA_INITIAL_SIZE
#define PM_ARENA_INITIAL_SIZE 8192
#endif

/** Double the block size every this many blocks. */
#define PM_ARENA_GROWTH_INTERVAL 8
Expand Down
4 changes: 4 additions & 0 deletions src/errors_format.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#include "prism/internal/parser.h"

#include <assert.h>
// Include sys/types.h before inttypes.h to work around an issue with certain
// versions of GCC and newlib which causes omission of the 64-bit PRI macros
// (see 61ebe5123; the removal of defines.h dropped it).
#include <sys/types.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
Expand Down
4 changes: 4 additions & 0 deletions src/integer.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
#include "prism/internal/buffer.h"

#include <assert.h>
// Include sys/types.h before inttypes.h to work around an issue with certain
// versions of GCC and newlib which causes omission of PRIu64 and the other
// 64-bit macros (see 61ebe5123; the removal of defines.h dropped it).
#include <sys/types.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stddef.h>
Expand Down
13 changes: 12 additions & 1 deletion src/prism.c
Original file line number Diff line number Diff line change
Expand Up @@ -23254,6 +23254,16 @@ pm_parser_init_shebang(pm_parser_t *parser, const pm_options_t *options, const c
parser->frozen_string_literal = next_options.frozen_string_literal;
}

/**
* The smallest capacity the constant pool starts with, whatever the source
* size suggests. An embedder that interns a fixed set of names into the pool
* at every parse (a symbol table) can raise it to that set's size, so the
* pool does not grow to hold them and leave each outgrown array in the arena.
*/
#ifndef PM_CONSTANT_POOL_MIN_CAPACITY
#define PM_CONSTANT_POOL_MIN_CAPACITY 4
#endif

/**
* Initialize a parser with the given start and end pointers.
*/
Expand Down Expand Up @@ -23331,7 +23341,8 @@ pm_parser_init(pm_arena_t *arena, pm_parser_t *parser, const uint8_t *source, si
* frequency. Resizes are cheap with arena allocation, so we lean toward
* under-estimating. */
uint32_t constant_size = ((uint32_t) size) / 120;
pm_constant_pool_init(&parser->metadata_arena, &parser->constant_pool, constant_size < 4 ? 4 : constant_size);
if (constant_size < PM_CONSTANT_POOL_MIN_CAPACITY) constant_size = PM_CONSTANT_POOL_MIN_CAPACITY;
pm_constant_pool_init(&parser->metadata_arena, &parser->constant_pool, constant_size);

/* Initialize the line offset list. Similar to the constant pool, we are
* going to estimate the number of newlines that we will need based on the
Expand Down
Loading