-
Notifications
You must be signed in to change notification settings - Fork 686
Move snapshot generation function to the snapshot tool #2057
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
Move snapshot generation function to the snapshot tool #2057
Conversation
jerry-main/main-unix-snapshot.c
Outdated
| fwrite (output_buffer, sizeof (uint8_t), snapshot_size, snapshot_file_p); | ||
| fclose (snapshot_file_p); | ||
|
|
||
| printf ("Created snapshot file: '%s' (%d bytes)\n", output_file_name_p, snapshot_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cppcheck signals signed/unsigned int mismatch here ("warning(invalidPrintfArgType_sint): %d in format string (no. 2) requires a signed integer given in the argument list.")
jerry-main/main-unix-snapshot.c
Outdated
| fwrite (output_buffer, sizeof (uint8_t), literal_buffer_size, literal_file_p); | ||
| fclose (literal_file_p); | ||
|
|
||
| printf ("Created literal file: '%s' (%d bytes)\n", save_literals_file_name_p, literal_buffer_size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... and here
|
I like this change |
b161996 to
2e166b0
Compare
|
@akosthekiss I've updated the PR. |
e8995a6 to
3939c7b
Compare
jerry-main/main-unix-snapshot.c
Outdated
| return bytes_read; | ||
| } /* read_file */ | ||
|
|
||
| /** Generate command line option IDs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comment text seems to be off by one line
jerry-main/main-unix-snapshot.c
Outdated
| .help = "print generated opcodes"), | ||
| CLI_OPT_DEF (.id = OPT_GENERATE_CONTEXT, .opt = "c", .longopt = "context", | ||
| .help = "specify the execution context of the snapshot: " | ||
| "global or eval (default: global).", .meta = "MODE"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a bit unidiomatic placement of the .meta initializer (it used to follow .opt/.longopt because that's how it is printed, too)
jerry-main/main-unix-snapshot.c
Outdated
| uint32_t number_of_files = 0; | ||
| uint8_t *source_p = input_buffer; | ||
| size_t source_length = 0; | ||
| const char *output_file_name_p = "js.snapshot"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there should be one single default output file name for all snapshot sub-commands (generate, merge, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMHO having different default output names makes the intent more clear.
But we can change it to a common one. Currently merge uses "merged.snapshot", so what do you think would be the best common name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"js.snapshot" is fine by me for both. it'd be a quite simple and elegant default.
| .help = "export literals found in parsed JS input (in list format)"), | ||
| CLI_OPT_DEF (.id = OPT_GENERATE_LITERAL_C, .longopt = "save-literals-c-format", | ||
| .meta = "FILE", | ||
| .help = "export literals found in parsed JS input (in C source format)"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the original --save-snapshot-for-{global,eval} options have already been rewritten to a new --context={global,eval} format. wouldn't it make sense to have something similar for --save-literals-{c,list}-format, too? e.g., as simple as --save-literals={c,list}.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the logic is different, for --save-literals* you need to specify the output file as argument. This way you can generate the literal file and also the snapshot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh that's right
tools/run-tests.py
Outdated
| def update_test_args_with_snapshot_tool(jerry_path, test_args): | ||
| if "--snapshot-tool" in test_args: | ||
| snapshot_idx = test_args.index("--snapshot-tool") | ||
| test_args[snapshot_idx] = "--snapshot-tool=%s-snapshot" % (jerry_path) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this rewrite really needed? patching up the cli options this way is a bit creepy, and the same effect could be achieved by simply adding this "deduce snapshot tool path from engine path" logic to the run-test-suite.sh script. (explanation following there...)
tools/runners/run-test-suite.sh
Outdated
| shift | ||
|
|
||
| SNAPSHOT_TOOL=${1#--snapshot-tool=} | ||
| SNAPSHOT_TOOL=(${SNAPSHOT_TOOL//,/ }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...following from above: you'd just have SNAPSHOT_TOOL=$ENGINE-snapshot here. (agreed, it looses a bit of flexibility by not allowing for snapshot tools placed anywhere in the file system for those who run this script manually. but who does get restricted by that, actually? run-test.py does force to have jerry and jerry-snapshot side-by-side anyway)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Certainly we can simply assume the path, but I wanted to give the test site runner more freedom if it is executed manually.
But I'll update this part.
3939c7b to
018d2e3
Compare
akosthekiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor changes requested
tools/runners/run-test-suite.sh
Outdated
| echo "$0: $SNAPSHOT_TOOL: not an executable" | ||
| exit 1 | ||
| fi | ||
| shift; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for the semicolon (shouldn't be used elsewhere either)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
semicolon still here but removed from after IS_SNAPSHOT=true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ping on this minor change request
|
|
||
| if (save_literals_file_name_p != NULL) | ||
| { | ||
| const size_t literal_buffer_size = jerry_parse_and_save_literals ((jerry_char_t *) source_p, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems that the arg indentation is off by one space
018d2e3 to
c6abc91
Compare
Now there is a snapshot tool which can merge snapshots but was unable to generate snapshots by itself. This change moves the snapshot generation utilities to the snapshot tool. JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com
c6abc91 to
7e3d805
Compare
akosthekiss
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Note: I've experimented with GitHub's feature of allowing maintainer changes. So, I've fixed the semicolon issue and pushed it to the PR branch. Seems to work.
zherczeg
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Now there is a snapshot tool which can merge snapshots
but was unable to generate snapshots by itself.
This change moves the snapshot generation utilities
to the snapshot tool.
JerryScript-DCO-1.0-Signed-off-by: Peter Gal pgal.u-szeged@partner.samsung.com