Skip to content

Add feature to remove parser. #1476

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

Conversation

sergioamr
Copy link
Contributor

Remove the parser so we can save space if we are only interested in running snapshots.
Removing the parser enables the snapshot execution.

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez [email protected]

@@ -20,6 +20,8 @@
#include "jcontext.h"
#include "js-parser-internal.h"

#ifndef CONFIG_DISABLE_PARSER_BUILTIN
Copy link
Member

Choose a reason for hiding this comment

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

Parser is not exactly a built-in. JERRY_DISABLE_PARSER would sound better. Shouldn't we guard the other files too?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good, i was not certain how to call it. Let me change it,
I checked on the rest of the code and you guys don't guard the includes, that is why is there after the js-parser-internal.h

@sergioamr sergioamr force-pushed the next/sergio/remove_parser branch from 5c41e41 to db062ac Compare December 8, 2016 10:56
@zherczeg
Copy link
Member

zherczeg commented Dec 8, 2016

I mean all files in parser/js should have guards. I know the linker can eliminate dead code, but I would prefer a complete solution. Btw how much is the binary size gain on your system?

@sergioamr
Copy link
Contributor Author

It is quite a good saving.

Parser On
126468 build/arduino_101/zephyr/zephyr.bin

Parser Off
93524 build/arduino_101/zephyr/zephyr.bin

I will add the guards to the rest of the files.

@sergioamr sergioamr force-pushed the next/sergio/remove_parser branch from db062ac to 9112714 Compare December 8, 2016 15:47
Copy link
Member

@zherczeg zherczeg left a comment

Choose a reason for hiding this comment

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

I think after a few more changes we are ready to land this patch.

@@ -28,6 +28,7 @@ set(FEATURE_PARSER_DUMP OFF CACHE BOOL "Enable parser byte-code dumps?"
set(FEATURE_REGEXP_DUMP OFF CACHE BOOL "Enable regexp byte-code dumps?")
set(FEATURE_SNAPSHOT_SAVE OFF CACHE BOOL "Enable saving snapshot files?")
set(FEATURE_SNAPSHOT_EXEC OFF CACHE BOOL "Enable executing snapshot files?")
set(FEATURE_PARSER_DISABLE OFF CACHE BOOL "Disable the parser and 'eval' and use only snapshots?")
Copy link
Member

Choose a reason for hiding this comment

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

It seems to me these features are in alphabetic order except the first few (perhaps that should be fixed in a separate patch). You should put this before FEATURE_PARSER_DUMP.

@@ -42,6 +43,7 @@ message(STATUS "FEATURE_PARSER_DUMP " ${FEATURE_PARSER_DUMP})
message(STATUS "FEATURE_REGEXP_DUMP " ${FEATURE_REGEXP_DUMP})
message(STATUS "FEATURE_SNAPSHOT_SAVE " ${FEATURE_SNAPSHOT_SAVE})
message(STATUS "FEATURE_SNAPSHOT_EXEC " ${FEATURE_SNAPSHOT_EXEC})
message(STATUS "FEATURE_PARSER_DISABLE " ${FEATURE_PARSER_DISABLE})
Copy link
Member

Choose a reason for hiding this comment

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

Ditto.

set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_DISABLE_PARSER)
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_ENABLE_SNAPSHOT_EXEC)
endif()

Copy link
Member

Choose a reason for hiding this comment

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

It seems these checks also follows the order in the feature list.

Copy link
Contributor

@robertsipka robertsipka Dec 9, 2016

Choose a reason for hiding this comment

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

I think it would be better to set the FEATURE_SNAPSHOT_EXEC option to ON in case of disabled parser instead of set this define. I am suggesting to do this check before the status messages or you can create another message which will reports that the FEATURE_SNAPSHOT_EXEC is enabled now (if it was disabled earlier).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds reasonable

JERRY_UNUSED (is_strict);
JERRY_UNUSED (bytecode_data_p);

return ecma_raise_syntax_error ("");
Copy link
Member

Choose a reason for hiding this comment

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

Please add a valid error message enclosed in ECMA_ERR_MSG, since disabling the parser does not mean disabling error messages.

@sergioamr sergioamr force-pushed the next/sergio/remove_parser branch 4 times, most recently from 44dbda7 to 0d919de Compare December 9, 2016 12:03
Copy link
Contributor

@LaszloLango LaszloLango left a comment

Choose a reason for hiding this comment

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

LGTM

Remove the parser so we can save space if we are
only interested in running snapshots.

Removing the parser enables the snapshot execution.

JerryScript-DCO-1.0-Signed-off-by: Sergio Martinez [email protected]
@sergioamr sergioamr force-pushed the next/sergio/remove_parser branch from 0d919de to b6940b4 Compare December 9, 2016 13:56
@zherczeg zherczeg merged commit db05d85 into jerryscript-project:master Dec 9, 2016
@sergioamr sergioamr deleted the next/sergio/remove_parser branch December 9, 2016 14:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants