Skip to content

Commit

Permalink
put negate into another file so it cannot be inlined
Browse files Browse the repository at this point in the history
JerryScript-DCO-1.0-Signed-off-by: Máté Tokodi mate.tokodi@szteszoftver.hu
  • Loading branch information
matetokodi committed May 16, 2024
1 parent 676659d commit 201b342
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 8 deletions.
6 changes: 4 additions & 2 deletions jerry-core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ set(SOURCE_CORE_FILES
ecma/base/ecma-helpers-string.c
ecma/base/ecma-helpers-value.c
ecma/base/ecma-helpers.c
ecma/base/ecma-helper-helper.c
ecma/base/ecma-init-finalize.c
ecma/base/ecma-lcache.c
ecma/base/ecma-line-info.c
Expand Down Expand Up @@ -348,6 +349,7 @@ if(ENABLE_AMALGAM)
ecma/base/ecma-gc.h
ecma/base/ecma-globals.h
ecma/base/ecma-helpers.h
ecma/base/ecma-helper-helper.h
ecma/base/ecma-init-finalize.h
ecma/base/ecma-lcache.h
ecma/base/ecma-line-info.h
Expand Down Expand Up @@ -528,7 +530,6 @@ if(ENABLE_AMALGAM)
add_custom_target(amalgam-jerry DEPENDS ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
add_dependencies(amalgam amalgam-jerry)

set(SOURCE_CORE_FILES ${AMALGAM_CORE_C} ${AMALGAM_CORE_H} ${AMALGAM_CONFIG_H})
set(INCLUDE_CORE_PUBLIC PARENT_SCOPE)
set(INCLUDE_CORE_PRIVATE PARENT_SCOPE)
endif()
Expand Down Expand Up @@ -742,7 +743,8 @@ else()
endif()
configure_file(config.h jerryscript-config.h @ONLY)

add_library(${JERRY_CORE_NAME} ${SOURCE_CORE_FILES})
add_library(${JERRY_CORE_NAME} ${SOURCE_CORE_FILES}
ecma/base/ecma-helper-helper.h)

target_compile_definitions(${JERRY_CORE_NAME} PUBLIC ${DEFINES_JERRY})
target_include_directories(${JERRY_CORE_NAME} PUBLIC ${INCLUDE_CORE_PUBLIC})
Expand Down
11 changes: 11 additions & 0 deletions jerry-core/ecma/base/ecma-helper-helper.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// Created by skyline on 2024-05-16.
//

#include "ecma-helper-helper.h"

ecma_number_t JERRY_ATTR_CONST
ecma_helper_negate(ecma_number_t num)
{
return -num;
}
12 changes: 12 additions & 0 deletions jerry-core/ecma/base/ecma-helper-helper.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// Created by skyline on 2024-05-16.
//

#ifndef JERRY_ECMA_HELPER_HELPER_H
#define JERRY_ECMA_HELPER_HELPER_H

#include "ecma-globals.h"

ecma_number_t ecma_helper_negate(ecma_number_t num);

#endif // JERRY_ECMA_HELPER_HELPER_H
6 changes: 1 addition & 5 deletions jerry-core/ecma/base/ecma-helpers-number.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <math.h>

#include "ecma-conversion.h"
#include "ecma-helper-helper.h"

#include "lit-char-helpers.h"

Expand Down Expand Up @@ -349,11 +350,6 @@ ecma_number_trunc (ecma_number_t num) /**< ecma-number */
return ecma_number_from_binary (binary);
} /* ecma_number_trunc */

ecma_number_t JERRY_ATTR_CONST
ecma_helper_negate(ecma_number_t num)
{
return -num;
}

/**
* Calculate remainder of division of two numbers,
Expand Down
1 change: 0 additions & 1 deletion jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,6 @@ bool ecma_number_is_finite (ecma_number_t num);
ecma_number_t ecma_number_get_prev (ecma_number_t num);
ecma_number_t ecma_number_get_next (ecma_number_t num);
ecma_number_t ecma_number_trunc (ecma_number_t num);
ecma_number_t ecma_helper_negate(ecma_number_t num);
ecma_number_t ecma_number_remainder (ecma_number_t left_num, ecma_number_t right_num)
#ifdef __APPLE__
/* Disable optimization for macos, beacuse it returns 0 instead of -0 in some cases */
Expand Down

0 comments on commit 201b342

Please sign in to comment.