Skip to content

Fix terminology of snapshot saving in literals #953

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
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
2 changes: 1 addition & 1 deletion jerry-core/jerry-snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ typedef struct
uint32_t lit_table_offset; /**< offset of the literal table */
uint32_t lit_table_size; /**< size of literal table */
uint32_t is_run_global; /**< flag, indicating whether the snapshot
* was dumped as 'Global scope'-mode code (true)
* was saved as 'Global scope'-mode code (true)
* or as eval-mode code (false) */
} jerry_snapshot_header_t;

Expand Down
4 changes: 2 additions & 2 deletions jerry-core/jerry.c
Original file line number Diff line number Diff line change
Expand Up @@ -2045,7 +2045,7 @@ jerry_parse_and_save_snapshot (const jerry_api_char_t *source_p, /**< script sou
size_t source_size, /**< script source size */
bool is_for_global, /**< snapshot would be executed as global (true)
* or eval (false) */
uint8_t *buffer_p, /**< buffer to dump snapshot to */
uint8_t *buffer_p, /**< buffer to save snapshot to */
size_t buffer_size) /**< the buffer's size */
{
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
Expand Down Expand Up @@ -2101,7 +2101,7 @@ jerry_parse_and_save_snapshot (const jerry_api_char_t *source_p, /**< script sou
lit_mem_to_snapshot_id_map_entry_t *lit_map_p = NULL;
uint32_t literals_num;

if (!lit_dump_literals_for_snapshot (buffer_p,
if (!lit_save_literals_for_snapshot (buffer_p,
buffer_size,
&snapshot_buffer_write_offset,
&lit_map_p,
Expand Down
28 changes: 14 additions & 14 deletions jerry-core/lit/lit-snapshot.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright 2015 Samsung Electronics Co., Ltd.
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
* Copyright 2015-2016 University of Szeged
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -22,14 +22,14 @@
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE

/**
* Dump a record to specified snapshot buffer.
* Save a record to specified snapshot buffer.
*
* @return number of bytes dumped,
* or 0 - upon dump failure
* @return number of bytes saved,
* or 0 - upon save failure
*/
static uint32_t
lit_snapshot_dump (lit_literal_t lit, /**< literal to dump */
uint8_t *buffer_p, /**< buffer to dump to */
lit_snapshot_save (lit_literal_t lit, /**< literal to save */
uint8_t *buffer_p, /**< buffer to save to */
size_t buffer_size, /**< buffer size */
size_t *in_out_buffer_offset_p) /**< [in,out] buffer write offset */
{
Expand Down Expand Up @@ -118,23 +118,23 @@ lit_snapshot_dump (lit_literal_t lit, /**< literal to dump */

JERRY_UNREACHABLE ();
return 0;
} /* lit_snapshot_dump */
} /* lit_snapshot_save */

/**
* Dump literals to specified snapshot buffer.
* Save literals to specified snapshot buffer.
*
* @return true, if dump was performed successfully (i.e. buffer size is sufficient),
* @return true, if save was performed successfully (i.e. buffer size is sufficient),
* false - otherwise.
*/
bool
lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot buffer */
lit_save_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot buffer */
size_t buffer_size, /**< size of the buffer */
size_t *in_out_buffer_offset_p, /**< [in,out] write position in the buffer */
lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal identifiers
* to the literal offsets
* in snapshot */
uint32_t *out_map_num_p, /**< [out] number of literals */
uint32_t *out_lit_table_size_p) /**< [out] number of bytes, dumped to snapshot buffer */
uint32_t *out_lit_table_size_p) /**< [out] number of bytes, saved to snapshot buffer */
{
uint32_t literals_num = lit_count_literals ();
uint32_t lit_table_size = 0;
Expand Down Expand Up @@ -186,7 +186,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
break;
}

uint32_t bytes = lit_snapshot_dump (lit, buffer_p, buffer_size, in_out_buffer_offset_p);
uint32_t bytes = lit_snapshot_save (lit, buffer_p, buffer_size, in_out_buffer_offset_p);

if (bytes == 0)
{
Expand Down Expand Up @@ -241,7 +241,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
*out_map_num_p = literals_num;
*out_lit_table_size_p = aligned_size;
return true;
} /* lit_dump_literals_for_snapshot */
} /* lit_save_literals_for_snapshot */

#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */

Expand All @@ -250,7 +250,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
/**
* Load literals from snapshot.
*
* @return true, if load was performed successfully (i.e. literals dump in the snapshot is consistent),
* @return true, if load was performed successfully (i.e. literals saved in the snapshot are consistent),
* false - otherwise (i.e. snapshot is incorrect).
*/
bool
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/lit/lit-snapshot.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ typedef struct

#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
extern bool
lit_dump_literals_for_snapshot (uint8_t *,
lit_save_literals_for_snapshot (uint8_t *,
size_t,
size_t *,
lit_mem_to_snapshot_id_map_entry_t **,
Expand Down
36 changes: 18 additions & 18 deletions main-unix.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,9 +215,9 @@ main (int argc,
const char *exec_snapshot_file_names[JERRY_MAX_COMMAND_LINE_ARGS];
int exec_snapshots_count = 0;

bool is_dump_snapshot_mode = false;
bool is_dump_snapshot_mode_for_global_or_eval = false;
const char *dump_snapshot_file_name_p = NULL;
bool is_save_snapshot_mode = false;
bool is_save_snapshot_mode_for_global_or_eval = false;
const char *save_snapshot_file_name_p = NULL;

bool is_repl_mode = false;

Expand Down Expand Up @@ -249,18 +249,18 @@ main (int argc,
{
flags |= JERRY_FLAG_SHOW_OPCODES;
}
else if (!strcmp ("--dump-snapshot-for-global", argv[i])
|| !strcmp ("--dump-snapshot-for-eval", argv[i]))
else if (!strcmp ("--save-snapshot-for-global", argv[i])
|| !strcmp ("--save-snapshot-for-eval", argv[i]))
{
is_dump_snapshot_mode = true;
is_dump_snapshot_mode_for_global_or_eval = !strcmp ("--dump-snapshot-for-global", argv[i]);
is_save_snapshot_mode = true;
is_save_snapshot_mode_for_global_or_eval = !strcmp ("--save-snapshot-for-global", argv[i]);

flags |= JERRY_FLAG_PARSE_ONLY;

if (dump_snapshot_file_name_p == NULL
if (save_snapshot_file_name_p == NULL
&& ++i < argc)
{
dump_snapshot_file_name_p = argv[i];
save_snapshot_file_name_p = argv[i];
}
else
{
Expand Down Expand Up @@ -321,17 +321,17 @@ main (int argc,
}
}

if (is_dump_snapshot_mode)
if (is_save_snapshot_mode)
{
if (files_counter == 0)
{
JERRY_ERROR_MSG ("--dump-snapshot argument is passed, but no script was specified on command line\n");
JERRY_ERROR_MSG ("--save-snapshot argument is passed, but no script was specified on command line\n");
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}

if (exec_snapshots_count != 0)
{
JERRY_ERROR_MSG ("--dump-snapshot and --exec-snapshot options can't be passed simultaneously\n");
JERRY_ERROR_MSG ("--save-snapshot and --exec-snapshot options can't be passed simultaneously\n");
return JERRY_STANDALONE_EXIT_CODE_FAIL;
}
}
Expand Down Expand Up @@ -426,23 +426,23 @@ main (int argc,

if (source_p != NULL)
{
if (is_dump_snapshot_mode)
if (is_save_snapshot_mode)
{
static uint8_t snapshot_dump_buffer[ JERRY_BUFFER_SIZE ];
static uint8_t snapshot_save_buffer[ JERRY_BUFFER_SIZE ];

size_t snapshot_size = jerry_parse_and_save_snapshot (source_p,
source_size,
is_dump_snapshot_mode_for_global_or_eval,
snapshot_dump_buffer,
is_save_snapshot_mode_for_global_or_eval,
snapshot_save_buffer,
JERRY_BUFFER_SIZE);
if (snapshot_size == 0)
{
ret_code = JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION;
}
else
{
FILE *snapshot_file_p = fopen (dump_snapshot_file_name_p, "w");
fwrite (snapshot_dump_buffer, sizeof (uint8_t), snapshot_size, snapshot_file_p);
FILE *snapshot_file_p = fopen (save_snapshot_file_name_p, "w");
fwrite (snapshot_save_buffer, sizeof (uint8_t), snapshot_size, snapshot_file_p);
fclose (snapshot_file_p);
}
}
Expand Down