Skip to content

Commit 0dc4f90

Browse files
committed
Fix terminology of snapshot saving in literals and main
In case of literals and in main, snapshot saving is incorrectly named dumping. Elsewhere in the code, 'dump' functions output debug data (even literals have a `lit_dump_literals` debug function). To help distinction and to align terminologies, snapshot saving functions of literals and command line options of main are also re-named 'save'. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss [email protected]
1 parent 6e687fa commit 0dc4f90

File tree

5 files changed

+36
-36
lines changed

5 files changed

+36
-36
lines changed

jerry-core/jerry-snapshot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ typedef struct
2727
uint32_t last_compiled_code_offset; /**< offset of the last compiled code */
2828
uint32_t lit_table_size; /**< size of literal table */
2929
__extension__ uint32_t is_run_global : 1; /**< flag, indicating whether the snapshot
30-
* was dumped as 'Global scope'-mode code (true)
30+
* was saved as 'Global scope'-mode code (true)
3131
* or as eval-mode code (false) */
3232
} jerry_snapshot_header_t;
3333

jerry-core/jerry.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,7 @@ jerry_parse_and_save_snapshot (const jerry_api_char_t *source_p, /**< script sou
20162016
size_t source_size, /**< script source size */
20172017
bool is_for_global, /**< snapshot would be executed as global (true)
20182018
* or eval (false) */
2019-
uint8_t *buffer_p, /**< buffer to dump snapshot to */
2019+
uint8_t *buffer_p, /**< buffer to save snapshot to */
20202020
size_t buffer_size) /**< the buffer's size */
20212021
{
20222022
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
@@ -2091,7 +2091,7 @@ jerry_parse_and_save_snapshot (const jerry_api_char_t *source_p, /**< script sou
20912091
lit_mem_to_snapshot_id_map_entry_t *lit_map_p = NULL;
20922092
uint32_t literals_num;
20932093

2094-
if (!lit_dump_literals_for_snapshot (buffer_p,
2094+
if (!lit_save_literals_for_snapshot (buffer_p,
20952095
buffer_size,
20962096
&snapshot_buffer_write_offset,
20972097
&lit_map_p,

jerry-core/lit/lit-snapshot.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* Copyright 2015 Samsung Electronics Co., Ltd.
1+
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
22
* Copyright 2015-2016 University of Szeged
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -22,14 +22,14 @@
2222
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
2323

2424
/**
25-
* Dump a record to specified snapshot buffer.
25+
* Save a record to specified snapshot buffer.
2626
*
27-
* @return number of bytes dumped,
28-
* or 0 - upon dump failure
27+
* @return number of bytes saved,
28+
* or 0 - upon save failure
2929
*/
3030
static uint32_t
31-
lit_snapshot_dump (lit_literal_t lit, /**< literal to dump */
32-
uint8_t *buffer_p, /**< buffer to dump to */
31+
lit_snapshot_save (lit_literal_t lit, /**< literal to save */
32+
uint8_t *buffer_p, /**< buffer to save to */
3333
size_t buffer_size, /**< buffer size */
3434
size_t *in_out_buffer_offset_p) /**< [in,out] buffer write offset */
3535
{
@@ -118,23 +118,23 @@ lit_snapshot_dump (lit_literal_t lit, /**< literal to dump */
118118

119119
JERRY_UNREACHABLE ();
120120
return 0;
121-
} /* lit_snapshot_dump */
121+
} /* lit_snapshot_save */
122122

123123
/**
124-
* Dump literals to specified snapshot buffer.
124+
* Save literals to specified snapshot buffer.
125125
*
126-
* @return true, if dump was performed successfully (i.e. buffer size is sufficient),
126+
* @return true, if save was performed successfully (i.e. buffer size is sufficient),
127127
* false - otherwise.
128128
*/
129129
bool
130-
lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot buffer */
130+
lit_save_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot buffer */
131131
size_t buffer_size, /**< size of the buffer */
132132
size_t *in_out_buffer_offset_p, /**< [in,out] write position in the buffer */
133133
lit_mem_to_snapshot_id_map_entry_t **out_map_p, /**< [out] map from literal identifiers
134134
* to the literal offsets
135135
* in snapshot */
136136
uint32_t *out_map_num_p, /**< [out] number of literals */
137-
uint32_t *out_lit_table_size_p) /**< [out] number of bytes, dumped to snapshot buffer */
137+
uint32_t *out_lit_table_size_p) /**< [out] number of bytes, saved to snapshot buffer */
138138
{
139139
uint32_t literals_num = lit_count_literals ();
140140
uint32_t lit_table_size = 0;
@@ -186,7 +186,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
186186
break;
187187
}
188188

189-
uint32_t bytes = lit_snapshot_dump (lit, buffer_p, buffer_size, in_out_buffer_offset_p);
189+
uint32_t bytes = lit_snapshot_save (lit, buffer_p, buffer_size, in_out_buffer_offset_p);
190190

191191
if (bytes == 0)
192192
{
@@ -241,7 +241,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
241241
*out_map_num_p = literals_num;
242242
*out_lit_table_size_p = aligned_size;
243243
return true;
244-
} /* lit_dump_literals_for_snapshot */
244+
} /* lit_save_literals_for_snapshot */
245245

246246
#endif /* JERRY_ENABLE_SNAPSHOT_SAVE */
247247

@@ -250,7 +250,7 @@ lit_dump_literals_for_snapshot (uint8_t *buffer_p, /**< [out] output snapshot bu
250250
/**
251251
* Load literals from snapshot.
252252
*
253-
* @return true, if load was performed successfully (i.e. literals dump in the snapshot is consistent),
253+
* @return true, if load was performed successfully (i.e. literals saved in the snapshot are consistent),
254254
* false - otherwise (i.e. snapshot is incorrect).
255255
*/
256256
bool

jerry-core/lit/lit-snapshot.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ typedef struct
2828

2929
#ifdef JERRY_ENABLE_SNAPSHOT_SAVE
3030
extern bool
31-
lit_dump_literals_for_snapshot (uint8_t *,
31+
lit_save_literals_for_snapshot (uint8_t *,
3232
size_t,
3333
size_t *,
3434
lit_mem_to_snapshot_id_map_entry_t **,

main-unix.c

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,9 @@ main (int argc,
215215
const char *exec_snapshot_file_names[JERRY_MAX_COMMAND_LINE_ARGS];
216216
int exec_snapshots_count = 0;
217217

218-
bool is_dump_snapshot_mode = false;
219-
bool is_dump_snapshot_mode_for_global_or_eval = false;
220-
const char *dump_snapshot_file_name_p = NULL;
218+
bool is_save_snapshot_mode = false;
219+
bool is_save_snapshot_mode_for_global_or_eval = false;
220+
const char *save_snapshot_file_name_p = NULL;
221221

222222
bool is_repl_mode = false;
223223

@@ -249,18 +249,18 @@ main (int argc,
249249
{
250250
flags |= JERRY_FLAG_SHOW_OPCODES;
251251
}
252-
else if (!strcmp ("--dump-snapshot-for-global", argv[i])
253-
|| !strcmp ("--dump-snapshot-for-eval", argv[i]))
252+
else if (!strcmp ("--save-snapshot-for-global", argv[i])
253+
|| !strcmp ("--save-snapshot-for-eval", argv[i]))
254254
{
255-
is_dump_snapshot_mode = true;
256-
is_dump_snapshot_mode_for_global_or_eval = !strcmp ("--dump-snapshot-for-global", argv[i]);
255+
is_save_snapshot_mode = true;
256+
is_save_snapshot_mode_for_global_or_eval = !strcmp ("--save-snapshot-for-global", argv[i]);
257257

258258
flags |= JERRY_FLAG_PARSE_ONLY;
259259

260-
if (dump_snapshot_file_name_p == NULL
260+
if (save_snapshot_file_name_p == NULL
261261
&& ++i < argc)
262262
{
263-
dump_snapshot_file_name_p = argv[i];
263+
save_snapshot_file_name_p = argv[i];
264264
}
265265
else
266266
{
@@ -321,17 +321,17 @@ main (int argc,
321321
}
322322
}
323323

324-
if (is_dump_snapshot_mode)
324+
if (is_save_snapshot_mode)
325325
{
326326
if (files_counter == 0)
327327
{
328-
JERRY_ERROR_MSG ("--dump-snapshot argument is passed, but no script was specified on command line\n");
328+
JERRY_ERROR_MSG ("--save-snapshot argument is passed, but no script was specified on command line\n");
329329
return JERRY_STANDALONE_EXIT_CODE_FAIL;
330330
}
331331

332332
if (exec_snapshots_count != 0)
333333
{
334-
JERRY_ERROR_MSG ("--dump-snapshot and --exec-snapshot options can't be passed simultaneously\n");
334+
JERRY_ERROR_MSG ("--save-snapshot and --exec-snapshot options can't be passed simultaneously\n");
335335
return JERRY_STANDALONE_EXIT_CODE_FAIL;
336336
}
337337
}
@@ -426,23 +426,23 @@ main (int argc,
426426

427427
if (source_p != NULL)
428428
{
429-
if (is_dump_snapshot_mode)
429+
if (is_save_snapshot_mode)
430430
{
431-
static uint8_t snapshot_dump_buffer[ JERRY_BUFFER_SIZE ];
431+
static uint8_t snapshot_save_buffer[ JERRY_BUFFER_SIZE ];
432432

433433
size_t snapshot_size = jerry_parse_and_save_snapshot (source_p,
434434
source_size,
435-
is_dump_snapshot_mode_for_global_or_eval,
436-
snapshot_dump_buffer,
435+
is_save_snapshot_mode_for_global_or_eval,
436+
snapshot_save_buffer,
437437
JERRY_BUFFER_SIZE);
438438
if (snapshot_size == 0)
439439
{
440440
ret_code = JERRY_COMPLETION_CODE_UNHANDLED_EXCEPTION;
441441
}
442442
else
443443
{
444-
FILE *snapshot_file_p = fopen (dump_snapshot_file_name_p, "w");
445-
fwrite (snapshot_dump_buffer, sizeof (uint8_t), snapshot_size, snapshot_file_p);
444+
FILE *snapshot_file_p = fopen (save_snapshot_file_name_p, "w");
445+
fwrite (snapshot_save_buffer, sizeof (uint8_t), snapshot_size, snapshot_file_p);
446446
fclose (snapshot_file_p);
447447
}
448448
}

0 commit comments

Comments
 (0)