Skip to content
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.c
Original file line number Diff line number Diff line change
Expand Up @@ -2266,13 +2266,13 @@ jerry_exec_snapshot (const void *snapshot_p, /**< snapshot */
if (header_p->is_run_global)
{
ret_val = vm_run_global (bytecode_p);
ecma_bytecode_deref (bytecode_p);
}
else
{
ret_val = vm_run_eval (bytecode_p, false);
}

ecma_bytecode_deref (bytecode_p);
return ret_val;
#else /* !JERRY_ENABLE_SNAPSHOT_EXEC */
JERRY_UNUSED (snapshot_p);
Expand Down
10 changes: 7 additions & 3 deletions tests/unit/test-api.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,8 +725,7 @@ main (void)
jerry_cleanup ();

// Dump / execute snapshot
// FIXME: support save/load snapshot for optimized parser
if (false)
if (true)
{
static uint8_t global_mode_snapshot_buffer[1024];
static uint8_t eval_mode_snapshot_buffer[1024];
Expand Down Expand Up @@ -760,8 +759,13 @@ main (void)
false);

JERRY_ASSERT (!jerry_value_has_error_flag (res));
JERRY_ASSERT (jerry_value_is_undefined (res));
JERRY_ASSERT (jerry_value_is_string (res));
sz = jerry_get_string_size (res);
JERRY_ASSERT (sz == 20);
sz = jerry_string_to_char_buffer (res, (jerry_char_t *) buffer, sz);
JERRY_ASSERT (sz == 20);
jerry_release_value (res);
JERRY_ASSERT (!strncmp (buffer, "string from snapshot", (size_t) sz));

Copy link
Contributor Author

@jiangzidong jiangzidong Jul 19, 2016

Choose a reason for hiding this comment

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

Both global mode and eval mode will return the value of the last js statement. Is it what we expect?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes

res = jerry_exec_snapshot (eval_mode_snapshot_buffer,
eval_mode_snapshot_size,
Expand Down