fix bug of "deref bytecode twice" in jerry_exec_snapshot

Enable the snapshot related test code in test-api.c

JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
Zidong Jiang
2016-07-19 15:30:00 +08:00
parent dd3f801ae0
commit ca39875690
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -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);
+7 -3
View File
@@ -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];
@@ -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));
res = jerry_exec_snapshot (eval_mode_snapshot_buffer,
eval_mode_snapshot_size,