Skip to content

New Allocator and improved String handling. #874

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 1, 2016
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
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ project (Jerry C ASM)

# Compiler / Linker flags
set(COMPILE_FLAGS_JERRY "-fno-builtin")
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "x86_64")
set(COMPILE_FLAGS_JERRY "${COMPILE_FLAGS_JERRY} -DMEM_HEAP_PTR_64")
endif()
if(NOT ("${PLATFORM}" STREQUAL "DARWIN"))
set(LINKER_FLAGS_COMMON "-Wl,-z,noexecstack")
endif()
Expand Down
10 changes: 8 additions & 2 deletions jerry-core/config.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
* Copyright 2016 University of Szeged.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -47,10 +48,15 @@
# error "Currently, maximum 256 kilobytes heap size is supported"
#endif /* !CONFIG_MEM_HEAP_AREA_SIZE */

/**
* Max heap usage limit
*/
#define CONFIG_MEM_HEAP_MAX_LIMIT 8192
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the purpose of this macro?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It defines a maximum value for the heap limit. Heap limit is, as the name suggest, a limit of memory usage, and whenever the size of allocated memory since the previous limit would hit the next one, we would run garbage collection. The limit was previously set to HEAP_AREA_SIZE / 32 == 8192. Because I increased the size of the heap, garbage collection became less frequent, so I added a maximum value. This way it wouldn't affect environments where the heap size is different.


/**
* Desired limit of heap usage
*/
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (CONFIG_MEM_HEAP_AREA_SIZE / 32)
#define CONFIG_MEM_HEAP_DESIRED_LIMIT (JERRY_MIN (CONFIG_MEM_HEAP_AREA_SIZE / 32, CONFIG_MEM_HEAP_MAX_LIMIT))

/**
* Log2 of maximum possible offset in the heap
Expand Down Expand Up @@ -80,7 +86,7 @@
* Also the option affects size of ECMA Object Model's data types.
* In any case size of any of the types should not exceed CONFIG_MEM_POOL_CHUNK_SIZE.
*/
#define CONFIG_ECMA_REFERENCE_COUNTER_WIDTH (10)
#define CONFIG_ECMA_REFERENCE_COUNTER_WIDTH (12)

#define CONFIG_ECMA_REFERENCE_COUNTER_LIMIT ((1u << CONFIG_ECMA_REFERENCE_COUNTER_WIDTH) - 1u)

Expand Down
5 changes: 2 additions & 3 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@

#include "config.h"
#include "jrt.h"
#include "lit-globals.h"
#include "lit-magic-strings.h"
#include "mem-allocator.h"

Expand Down Expand Up @@ -384,7 +383,7 @@ typedef struct ecma_object_t
*/
#define ECMA_OBJECT_OBJ_TYPE_POS (ECMA_OBJECT_OBJ_EXTENSIBLE_POS + \
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH)
#define ECMA_OBJECT_OBJ_TYPE_WIDTH (4)
#define ECMA_OBJECT_OBJ_TYPE_WIDTH (3)

/**
* Compressed pointer to prototype object (ecma_object_t)
Expand Down Expand Up @@ -721,7 +720,7 @@ typedef struct ecma_string_t
union
{
/** Index of string in literal table */
lit_cpointer_t lit_cp;
mem_cpointer_t lit_cp;

/** Compressed pointer to an ecma_collection_header_t */
__extension__ mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH;
Expand Down
Loading