Skip to content

Conversation

@galpeter
Copy link
Contributor

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

@galpeter galpeter added infrastructure Related to GH Actions or the tested targets snapshot Related to the snapshot feature tools Related to the tooling scripts labels Oct 25, 2017
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);
Copy link
Member

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.")

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);
Copy link
Member

Choose a reason for hiding this comment

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

... and here

@zherczeg
Copy link
Member

I like this change

@galpeter galpeter force-pushed the snapshot-tool-generate branch from b161996 to 2e166b0 Compare October 27, 2017 10:00
@galpeter
Copy link
Contributor Author

@akosthekiss I've updated the PR.

@galpeter galpeter force-pushed the snapshot-tool-generate branch 4 times, most recently from e8995a6 to 3939c7b Compare October 27, 2017 13:08
return bytes_read;
} /* read_file */

/** Generate command line option IDs
Copy link
Member

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

.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"),
Copy link
Member

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)

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";
Copy link
Member

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, ...)

Copy link
Contributor Author

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?

Copy link
Member

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)"),
Copy link
Member

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}.

Copy link
Contributor Author

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.

Copy link
Member

Choose a reason for hiding this comment

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

oh that's right

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)
Copy link
Member

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...)

shift

SNAPSHOT_TOOL=${1#--snapshot-tool=}
SNAPSHOT_TOOL=(${SNAPSHOT_TOOL//,/ })
Copy link
Member

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)

Copy link
Contributor Author

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.

@galpeter galpeter force-pushed the snapshot-tool-generate branch from 3939c7b to 018d2e3 Compare October 30, 2017 15:07
Copy link
Member

@akosthekiss akosthekiss left a comment

Choose a reason for hiding this comment

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

minor changes requested

echo "$0: $SNAPSHOT_TOOL: not an executable"
exit 1
fi
shift;
Copy link
Member

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)

Copy link
Member

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?

Copy link
Member

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,
Copy link
Member

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

@galpeter galpeter force-pushed the snapshot-tool-generate branch from 018d2e3 to c6abc91 Compare October 31, 2017 11:17
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
@akosthekiss akosthekiss force-pushed the snapshot-tool-generate branch from c6abc91 to 7e3d805 Compare November 4, 2017 18:52
Copy link
Member

@akosthekiss akosthekiss left a 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.

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.

LGTM

@akosthekiss akosthekiss merged commit 8ae6592 into jerryscript-project:master Nov 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

infrastructure Related to GH Actions or the tested targets snapshot Related to the snapshot feature tools Related to the tooling scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants