Simplify resource name handling (#3929)
JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
@@ -1481,15 +1481,9 @@ ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *b
|
||||
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_function_name (bytecode_header_p);
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
base_p--;
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
return ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t, base_p[-1]);
|
||||
} /* ecma_compiled_code_get_tagged_template_collection */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ESNEXT)
|
||||
/**
|
||||
* Get the number of formal parameters of the compiled code
|
||||
*
|
||||
@@ -1517,7 +1511,7 @@ ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_heade
|
||||
* @return start position of the arguments list start of the compiled code
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p)
|
||||
ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
|
||||
@@ -1533,7 +1527,7 @@ ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode
|
||||
* @return position of the function name of the compiled code
|
||||
*/
|
||||
inline ecma_value_t * JERRY_ATTR_ALWAYS_INLINE
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p)
|
||||
ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p) /**< compiled code */
|
||||
{
|
||||
JERRY_ASSERT (bytecode_header_p != NULL);
|
||||
ecma_value_t *base_p = ecma_compiled_code_resolve_arguments_start (bytecode_header_p);
|
||||
@@ -1547,7 +1541,32 @@ ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_h
|
||||
|
||||
return base_p;
|
||||
} /* ecma_compiled_code_resolve_function_name */
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ESNEXT) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Get the resource name of a compiled code.
|
||||
*
|
||||
* @return resource name value
|
||||
*/
|
||||
ecma_value_t
|
||||
ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p) /**< compiled code */
|
||||
{
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
if (bytecode_p->status_flags & CBC_CODE_FLAGS_UINT16_ARGUMENTS)
|
||||
{
|
||||
cbc_uint16_arguments_t *args_p = (cbc_uint16_arguments_t *) bytecode_p;
|
||||
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint16_arguments_t));
|
||||
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
|
||||
}
|
||||
|
||||
cbc_uint8_arguments_t *args_p = (cbc_uint8_arguments_t *) bytecode_p;
|
||||
ecma_value_t *lit_pool_p = (ecma_value_t *) ((uint8_t *) bytecode_p + sizeof (cbc_uint8_arguments_t));
|
||||
return lit_pool_p[args_p->const_literal_end - args_p->register_end - 1];
|
||||
#else /* !ENABLED (JERRY_RESOURCE_NAME) */
|
||||
JERRY_UNUSED (bytecode_p);
|
||||
return ecma_make_magic_string_value (LIT_MAGIC_STRING_RESOURCE_ANON);
|
||||
#endif /* !ENABLED (JERRY_RESOURCE_NAME) */
|
||||
} /* ecma_get_resource_name */
|
||||
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
/**
|
||||
|
||||
@@ -500,11 +500,12 @@ void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_collection_t *ecma_compiled_code_get_tagged_template_collection (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
#if ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ESNEXT)
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ecma_length_t ecma_compiled_code_get_formal_params (const ecma_compiled_code_t *bytecode_p);
|
||||
ecma_value_t *ecma_compiled_code_resolve_arguments_start (const ecma_compiled_code_t *bytecode_header_p);
|
||||
ecma_value_t *ecma_compiled_code_resolve_function_name (const ecma_compiled_code_t *bytecode_header_p);
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) || ENABLED (JERRY_ESNEXT) */
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
ecma_value_t ecma_get_resource_name (const ecma_compiled_code_t *bytecode_p);
|
||||
#if (JERRY_STACK_LIMIT != 0)
|
||||
uintptr_t ecma_get_current_stack_usage (void);
|
||||
#endif /* (JERRY_STACK_LIMIT != 0) */
|
||||
|
||||
@@ -543,7 +543,6 @@ ecma_snapshot_get_literal (const uint8_t *literal_base_p, /**< literal start */
|
||||
* Related values:
|
||||
* - function argument names, if CBC_CODE_FLAGS_MAPPED_ARGUMENTS_NEEDED is present
|
||||
* - function name, if CBC_CODE_FLAGS_CLASS_CONSTRUCTOR is not present and ES.next profile is enabled
|
||||
* - resource name, if JERRY_RESOURCE_NAME is enabled
|
||||
*
|
||||
* @return pointer to the beginning of the serializable ecma-values
|
||||
*/
|
||||
@@ -576,11 +575,6 @@ ecma_snapshot_resolve_serializable_values (ecma_compiled_code_t *compiled_code_p
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
#if ENABLED (JERRY_RESOURCE_NAME)
|
||||
/* resource name */
|
||||
base_p--;
|
||||
#endif /* ENABLED (JERRY_RESOURCE_NAME) */
|
||||
|
||||
return base_p;
|
||||
} /* ecma_snapshot_resolve_serializable_values */
|
||||
#endif /* ENABLED (JERRY_SNAPSHOT_EXEC) || ENABLED (JERRY_SNAPSHOT_SAVE) */
|
||||
|
||||
@@ -877,28 +877,23 @@ ecma_module_parse (ecma_module_t *module_p) /**< module */
|
||||
}
|
||||
#endif /* ENABLED (JERRY_DEBUGGER) && ENABLED (JERRY_PARSER) */
|
||||
|
||||
JERRY_CONTEXT (resource_name) = ecma_make_string_value (module_p->path_p);
|
||||
|
||||
ecma_compiled_code_t *bytecode_data_p;
|
||||
ecma_value_t ret_value = parser_parse_script (NULL,
|
||||
0,
|
||||
(jerry_char_t *) source_p,
|
||||
source_size,
|
||||
ECMA_PARSE_STRICT_MODE | ECMA_PARSE_MODULE,
|
||||
&bytecode_data_p);
|
||||
ecma_compiled_code_t *bytecode_p = parser_parse_script (NULL,
|
||||
0,
|
||||
(jerry_char_t *) source_p,
|
||||
source_size,
|
||||
ecma_make_string_value (module_p->path_p),
|
||||
ECMA_PARSE_STRICT_MODE | ECMA_PARSE_MODULE);
|
||||
|
||||
JERRY_CONTEXT (module_top_context_p) = module_p->context_p->parent_p;
|
||||
|
||||
jerry_port_release_source (source_p);
|
||||
|
||||
if (ECMA_IS_VALUE_ERROR (ret_value))
|
||||
if (JERRY_UNLIKELY (bytecode_p == NULL))
|
||||
{
|
||||
return ret_value;
|
||||
return ECMA_VALUE_ERROR;
|
||||
}
|
||||
|
||||
ecma_free_value (ret_value);
|
||||
|
||||
module_p->compiled_code_p = bytecode_data_p;
|
||||
module_p->compiled_code_p = bytecode_p;
|
||||
module_p->state = ECMA_MODULE_STATE_PARSED;
|
||||
|
||||
return ECMA_VALUE_EMPTY;
|
||||
|
||||
Reference in New Issue
Block a user