mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Throwing CompactProfileError in cases required by Compact Profile.
This commit is contained in:
parent
bd7fd40a32
commit
e54023caf2
@ -236,7 +236,11 @@ ecma_builtin_function_dispatch_construct (ecma_value_t *arguments_list_p, /**< a
|
|||||||
{
|
{
|
||||||
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
JERRY_ASSERT (arguments_list_len == 0 || arguments_list_p != NULL);
|
||||||
|
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||||
|
#else /* !CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (arguments_list_p, arguments_list_len);
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (arguments_list_p, arguments_list_len);
|
||||||
|
#endif /* !CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
} /* ecma_builtin_function_dispatch_construct */
|
} /* ecma_builtin_function_dispatch_construct */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -93,7 +93,13 @@ JERRY_STATIC_ASSERT (sizeof (ecma_builtin_global_property_names) > sizeof (void*
|
|||||||
static ecma_completion_value_t
|
static ecma_completion_value_t
|
||||||
ecma_builtin_global_object_eval (ecma_value_t x) /**< routine's first argument */
|
ecma_builtin_global_object_eval (ecma_value_t x) /**< routine's first argument */
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
(void) x;
|
||||||
|
|
||||||
|
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||||
|
#else /* !CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (x);
|
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS (x);
|
||||||
|
#endif /* !CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
} /* ecma_builtin_global_object_eval */
|
} /* ecma_builtin_global_object_eval */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -555,6 +561,21 @@ ecma_builtin_global_try_to_instantiate_property (ecma_object_t *obj_p, /**< obje
|
|||||||
case ECMA_MAGIC_STRING_URI_ERROR_UL:
|
case ECMA_MAGIC_STRING_URI_ERROR_UL:
|
||||||
case ECMA_MAGIC_STRING_JSON_U:
|
case ECMA_MAGIC_STRING_JSON_U:
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
/* The object throws CompactProfileError upon invocation */
|
||||||
|
ecma_object_t *get_set_p = ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR);
|
||||||
|
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, get_set_p);
|
||||||
|
ecma_property_t *compact_profile_thrower_property_p = ecma_create_named_accessor_property (obj_p,
|
||||||
|
prop_name_p,
|
||||||
|
get_set_p,
|
||||||
|
get_set_p,
|
||||||
|
true,
|
||||||
|
false);
|
||||||
|
ecma_deref_object (get_set_p);
|
||||||
|
|
||||||
|
return compact_profile_thrower_property_p;
|
||||||
|
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
|
|
||||||
JERRY_UNIMPLEMENTED ();
|
JERRY_UNIMPLEMENTED ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,7 +125,7 @@ ecma_builtin_bin_search_for_magic_string_id_in_array (const ecma_magic_string_id
|
|||||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, \
|
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE, \
|
||||||
function) \
|
function) \
|
||||||
macro (COMPACT_PROFILE_ERROR, \
|
macro (COMPACT_PROFILE_ERROR, \
|
||||||
TYPE_GENERAL, \
|
TYPE_FUNCTION, \
|
||||||
COMPACT_PROFILE_ERROR_UL, \
|
COMPACT_PROFILE_ERROR_UL, \
|
||||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, \
|
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE, \
|
||||||
compact_profile_error) \
|
compact_profile_error) \
|
||||||
|
|||||||
@ -72,6 +72,21 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||||
|
bool is_equal = false;
|
||||||
|
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
|
||||||
|
{
|
||||||
|
is_equal = true;
|
||||||
|
}
|
||||||
|
ecma_deref_ecma_string (arguments_magic_string_p);
|
||||||
|
|
||||||
|
if (is_equal)
|
||||||
|
{
|
||||||
|
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_TRUE);
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
|
|
||||||
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
ecma_property_t *property_p = ecma_find_named_property (lex_env_p, name_p);
|
||||||
|
|
||||||
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
|
has_binding = (property_p != NULL) ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE;
|
||||||
@ -194,6 +209,22 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
|
|||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
bool is_equal = false;
|
||||||
|
|
||||||
|
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||||
|
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
|
||||||
|
{
|
||||||
|
is_equal = true;
|
||||||
|
}
|
||||||
|
ecma_deref_ecma_string (arguments_magic_string_p);
|
||||||
|
|
||||||
|
if (is_equal)
|
||||||
|
{
|
||||||
|
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
|
|
||||||
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||||
|
|
||||||
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
|
if (property_p->u.named_data_property.writable == ECMA_PROPERTY_WRITABLE)
|
||||||
@ -255,6 +286,22 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
|
|||||||
{
|
{
|
||||||
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
case ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE:
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||||
|
bool is_equal = false;
|
||||||
|
|
||||||
|
ecma_string_t *arguments_magic_string_p = ecma_get_magic_string (ECMA_MAGIC_STRING_ARGUMENTS);
|
||||||
|
if (ecma_compare_ecma_strings (name_p, arguments_magic_string_p))
|
||||||
|
{
|
||||||
|
is_equal = true;
|
||||||
|
}
|
||||||
|
ecma_deref_ecma_string (arguments_magic_string_p);
|
||||||
|
|
||||||
|
if (is_equal)
|
||||||
|
{
|
||||||
|
return ecma_make_throw_obj_completion_value (ecma_builtin_get (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR));
|
||||||
|
}
|
||||||
|
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||||
|
|
||||||
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
ecma_property_t *property_p = ecma_get_named_data_property (lex_env_p, name_p);
|
||||||
|
|
||||||
ecma_value_t prop_value = property_p->u.named_data_property.value;
|
ecma_value_t prop_value = property_p->u.named_data_property.value;
|
||||||
|
|||||||
107
tests/jerry/compact_profile_error.js
Normal file
107
tests/jerry/compact_profile_error.js
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
// Copyright 2014 Samsung Electronics Co., Ltd.
|
||||||
|
//
|
||||||
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
// you may not use this file except in compliance with the License.
|
||||||
|
// You may obtain a copy of the License at
|
||||||
|
//
|
||||||
|
// http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
//
|
||||||
|
// Unless required by applicable law or agreed to in writing, software
|
||||||
|
// distributed under the License is distributed on an "AS IS" BASIS
|
||||||
|
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
// See the License for the specific language governing permissions and
|
||||||
|
// limitations under the License.
|
||||||
|
|
||||||
|
var catched = false;
|
||||||
|
|
||||||
|
function f1()
|
||||||
|
{
|
||||||
|
var arguments = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f1();
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
|
|
||||||
|
catched = false;
|
||||||
|
|
||||||
|
function f2()
|
||||||
|
{
|
||||||
|
var a = arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
f2();
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
|
|
||||||
|
catched = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
eval('abc');
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
|
|
||||||
|
catched = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Function('abc');
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
|
|
||||||
|
catched = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
new Function('abc');
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
|
|
||||||
|
catched = false;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var a = Date.now();
|
||||||
|
} catch (e)
|
||||||
|
{
|
||||||
|
assert (e === CompactProfileError);
|
||||||
|
|
||||||
|
catched = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
assert(catched);
|
||||||
Loading…
x
Reference in New Issue
Block a user