mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 18:20:04 +00:00
Remove JSArgument's unused accessor
------------------------------------- Remove JSArgument's unused accessor:set [[ParameterMap]] as undefined issue:https://gitee.com/openharmony/ark_js_runtime/issues/I5C71F?from=project-issue Signed-off-by: DaiHN <daihuina1@huawei.com> Change-Id: Ic96b8ff2797b76fb63c20d70461680afea992483
This commit is contained in:
parent
ca95915302
commit
74287cd45a
@ -30,22 +30,6 @@ bool JSArguments::GetOwnProperty(JSThread *thread, const JSHandle<JSArguments> &
|
||||
return true;
|
||||
}
|
||||
|
||||
// 4.Let map be the value of the [[ParameterMap]] internal slot of the arguments object.
|
||||
JSHandle<JSTaggedValue> map(thread, args->GetParameterMap());
|
||||
|
||||
// 5.Let isMapped be HasOwnProperty(map, P).
|
||||
bool isMapped = JSTaggedValue::HasOwnProperty(thread, map, key);
|
||||
|
||||
// 6.Assert: isMapped is never an abrupt completion.
|
||||
ASSERT(!thread->HasPendingException());
|
||||
|
||||
// 7.If the value of isMapped is true, then
|
||||
// a.Set desc.[[Value]] to Get(map, P).
|
||||
if (isMapped) {
|
||||
auto prop = JSObject::GetProperty(thread, map, key).GetValue();
|
||||
desc.SetValue(prop);
|
||||
}
|
||||
|
||||
// 8.If IsDataDescriptor(desc) is true and P is "caller" and desc.[[Value]] is a strict mode Function object,
|
||||
// throw a TypeError exception.
|
||||
JSHandle<EcmaString> caller = thread->GetEcmaVM()->GetFactory()->NewFromASCII("caller");
|
||||
@ -60,46 +44,12 @@ bool JSArguments::GetOwnProperty(JSThread *thread, const JSHandle<JSArguments> &
|
||||
bool JSArguments::DefineOwnProperty(JSThread *thread, const JSHandle<JSArguments> &args,
|
||||
const JSHandle<JSTaggedValue> &key, const PropertyDescriptor &desc)
|
||||
{
|
||||
// 1 ~ 2 Let args be the arguments object and get map.
|
||||
JSHandle<JSTaggedValue> map(thread, args->GetParameterMap());
|
||||
|
||||
// 3.Let isMapped be HasOwnProperty(map, P).
|
||||
bool isMapped = JSTaggedValue::HasOwnProperty(thread, map, key);
|
||||
|
||||
// 4.Let allowed be OrdinaryDefineOwnProperty(args, P, Desc).
|
||||
bool allowed = JSObject::OrdinaryDefineOwnProperty(thread, JSHandle<JSObject>(args), key, desc);
|
||||
|
||||
// 5.ReturnIfAbrupt(allowed).
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, allowed);
|
||||
|
||||
// 6.If allowed is false, return false.
|
||||
if (!allowed) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 7.If the value of isMapped is true, then
|
||||
// a.If IsAccessorDescriptor(Desc) is true, then
|
||||
// i.Call map.[[Delete]](P).
|
||||
// b.Else
|
||||
// i.If Desc.[[Value]] is present, then
|
||||
// 1.Let setStatus be Set(map, P, Desc.[[Value]], false).
|
||||
// 2.Assert: setStatus is true because formal parameters mapped by argument objects are always writable.
|
||||
// ii.If Desc.[[Writable]] is present and its value is false, then
|
||||
// 1.Call map.[[Delete]](P).
|
||||
if (isMapped) {
|
||||
if (desc.IsAccessorDescriptor()) {
|
||||
JSTaggedValue::DeleteProperty(thread, map, key);
|
||||
} else {
|
||||
if (desc.HasValue()) {
|
||||
[[maybe_unused]] bool setStatus = JSTaggedValue::SetProperty(thread, map, key, desc.GetValue(), false);
|
||||
ASSERT(setStatus == true);
|
||||
}
|
||||
if (desc.HasWritable() && !desc.IsWritable()) {
|
||||
JSTaggedValue::DeleteProperty(thread, map, key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 8.Return true.
|
||||
return true;
|
||||
}
|
||||
@ -107,53 +57,15 @@ bool JSArguments::DefineOwnProperty(JSThread *thread, const JSHandle<JSArguments
|
||||
OperationResult JSArguments::GetProperty(JSThread *thread, const JSHandle<JSArguments> &args,
|
||||
const JSHandle<JSTaggedValue> &key, const JSHandle<JSTaggedValue> &receiver)
|
||||
{
|
||||
// 1 ~ 2 Let args be the arguments object and get map.
|
||||
JSHandle<JSTaggedValue> map(thread, args->GetParameterMap());
|
||||
|
||||
// 3.Let isMapped be HasOwnProperty(map, P).
|
||||
bool isMapped = JSTaggedValue::HasOwnProperty(thread, map, key);
|
||||
|
||||
// 4.Assert: isMapped is not an abrupt completion.
|
||||
ASSERT(!thread->HasPendingException());
|
||||
|
||||
// 5.If the value of isMapped is false, then
|
||||
// a.Return the result of calling the default ordinary object [[Get]] internal method (9.1.8)
|
||||
// on args passing P and Receiver as the arguments.
|
||||
if (!isMapped) {
|
||||
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>::Cast(args), key, receiver);
|
||||
}
|
||||
|
||||
// 6.Else map contains a formal parameter mapping for P,
|
||||
// a.Return Get(map, P).
|
||||
return JSTaggedValue::GetProperty(thread, map, key);
|
||||
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>::Cast(args), key, receiver);
|
||||
}
|
||||
|
||||
bool JSArguments::SetProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key,
|
||||
const JSHandle<JSTaggedValue> &value, const JSHandle<JSTaggedValue> &receiver)
|
||||
{
|
||||
// 1.Let args be the arguments object.
|
||||
JSHandle<JSTaggedValue> map(thread, args->GetParameterMap());
|
||||
|
||||
// 2.If SameValue(args, Receiver) is false, then
|
||||
// a.Let isMapped be false.
|
||||
bool isMapped = false;
|
||||
if (JSTaggedValue::SameValue(args.GetTaggedValue(), receiver.GetTaggedValue())) {
|
||||
// 3.Else,
|
||||
// a.Let map be the value of the [[ParameterMap]] internal slot of the arguments object.
|
||||
// b.Let isMapped be HasOwnProperty(map, P).
|
||||
// c.Assert: isMapped is not an abrupt completion.
|
||||
isMapped = JSTaggedValue::HasOwnProperty(thread, map, key);
|
||||
ASSERT(!thread->HasPendingException());
|
||||
}
|
||||
|
||||
// 4.If isMapped is true, then
|
||||
// a.Let setStatus be Set(map, P, V, false).
|
||||
// b.Assert: setStatus is true because formal parameters mapped by argument objects are always writable.
|
||||
if (isMapped) {
|
||||
[[maybe_unused]] bool setStatus = JSTaggedValue::SetProperty(thread, map, key, value);
|
||||
ASSERT(setStatus == true);
|
||||
}
|
||||
|
||||
// 5.Return the result of calling the default ordinary object [[Set]] internal method (9.1.9)
|
||||
// on args passing P, V and Receiver as the arguments.
|
||||
return JSTaggedValue::SetProperty(thread, JSHandle<JSTaggedValue>::Cast(args), key, value, receiver);
|
||||
@ -162,15 +74,6 @@ bool JSArguments::SetProperty(JSThread *thread, const JSHandle<JSArguments> &arg
|
||||
bool JSArguments::DeleteProperty(JSThread *thread, const JSHandle<JSArguments> &args,
|
||||
const JSHandle<JSTaggedValue> &key)
|
||||
{
|
||||
// 1.Let map be the value of the [[ParameterMap]] internal slot of the arguments object.
|
||||
JSHandle<JSTaggedValue> map(thread, args->GetParameterMap());
|
||||
|
||||
// 2.Let isMapped be HasOwnProperty(map, P).
|
||||
bool isMapped = JSTaggedValue::HasOwnProperty(thread, map, key);
|
||||
|
||||
// 3.Assert: isMapped is not an abrupt completion.
|
||||
ASSERT(!thread->HasPendingException());
|
||||
|
||||
// 4.Let result be the result of calling the default [[Delete]] internal method for ordinary objects (9.1.10)
|
||||
// on the arguments object passing P as the argument.
|
||||
bool result = JSTaggedValue::DeleteProperty(thread, JSHandle<JSTaggedValue>(args), key);
|
||||
@ -178,12 +81,6 @@ bool JSArguments::DeleteProperty(JSThread *thread, const JSHandle<JSArguments> &
|
||||
// 5.ReturnIfAbrupt(result).
|
||||
RETURN_VALUE_IF_ABRUPT_COMPLETION(thread, result);
|
||||
|
||||
// 6.If result is true and the value of isMapped is true, then
|
||||
// a.Call map.[[Delete]](P).
|
||||
if (result && isMapped) {
|
||||
JSTaggedValue::DeleteProperty(thread, map, key);
|
||||
}
|
||||
|
||||
// 7.Return result.
|
||||
return result;
|
||||
}
|
||||
|
@ -58,11 +58,6 @@ public:
|
||||
static bool DeleteProperty(JSThread *thread, const JSHandle<JSArguments> &args, const JSHandle<JSTaggedValue> &key);
|
||||
// 9.4.4.6 CreateUnmappedArgumentsObject(argumentsList)
|
||||
// 9.4.4.7 CreateMappedArgumentsObject ( func, formals, argumentsList, env )
|
||||
|
||||
static constexpr size_t PARAMETER_MAP_OFFSET = JSObject::SIZE;
|
||||
ACCESSORS(ParameterMap, PARAMETER_MAP_OFFSET, SIZE)
|
||||
|
||||
DECL_VISIT_OBJECT_FOR_JS_OBJECT(JSObject, PARAMETER_MAP_OFFSET, SIZE)
|
||||
};
|
||||
} // namespace panda::ecmascript
|
||||
|
||||
|
@ -781,7 +781,6 @@ JSHandle<JSArguments> ObjectFactory::NewJSArguments()
|
||||
JSHandle<GlobalEnv> env = vm_->GetGlobalEnv();
|
||||
JSHandle<JSHClass> dynclass = JSHandle<JSHClass>::Cast(env->GetArgumentsClass());
|
||||
JSHandle<JSArguments> obj = JSHandle<JSArguments>::Cast(NewJSObject(dynclass));
|
||||
obj->SetParameterMap(thread_, JSTaggedValue::Undefined());
|
||||
return obj;
|
||||
}
|
||||
|
||||
@ -1163,7 +1162,6 @@ void ObjectFactory::InitializeJSObject(const JSHandle<JSObject> &obj, const JSHa
|
||||
JSBoundFunction::Cast(*obj)->SetBoundArguments(JSTaggedValue::Undefined());
|
||||
break;
|
||||
case JSType::JS_ARGUMENTS:
|
||||
JSArguments::Cast(*obj)->SetParameterMap(JSTaggedValue::Undefined());
|
||||
break;
|
||||
case JSType::JS_FORIN_ITERATOR:
|
||||
case JSType::JS_MAP_ITERATOR:
|
||||
|
@ -1215,6 +1215,7 @@ JSTaggedValue RuntimeStubs::RuntimeGetUnmapedArgs(JSThread *thread, JSTaggedType
|
||||
uint32_t len = argumentsList->GetLength();
|
||||
// 2. Let obj be ObjectCreate(%ObjectPrototype%, «[[ParameterMap]]»).
|
||||
// 3. Set obj’s [[ParameterMap]] internal slot to undefined.
|
||||
// [[ParameterMap]] setted as undifined.
|
||||
JSHandle<JSArguments> obj = factory->NewJSArguments();
|
||||
// 4. Perform DefinePropertyOrThrow(obj, "length", PropertyDescriptor{[[Value]]: len, [[Writable]]: true,
|
||||
// [[Enumerable]]: false, [[Configurable]]: true}).
|
||||
|
@ -336,6 +336,7 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
case JSType::JS_TYPE_ERROR:
|
||||
case JSType::JS_REFERENCE_ERROR:
|
||||
case JSType::JS_URI_ERROR:
|
||||
case JSType::JS_ARGUMENTS:
|
||||
case JSType::JS_SYNTAX_ERROR:
|
||||
case JSType::JS_OBJECT: {
|
||||
CHECK_DUMP_FIELDS(ECMAObject::SIZE, JSObject::SIZE, 2U)
|
||||
@ -491,9 +492,6 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
DUMP_FOR_HANDLE(date)
|
||||
break;
|
||||
}
|
||||
case JSType::JS_ITERATOR:
|
||||
// JS Iterate is a tool class, so we don't need to check it.
|
||||
break;
|
||||
case JSType::JS_FORIN_ITERATOR: {
|
||||
CHECK_DUMP_FIELDS(JSObject::SIZE, JSForInIterator::SIZE, 4U)
|
||||
JSHandle<JSTaggedValue> array(thread, factory->NewJSArray().GetTaggedValue());
|
||||
@ -598,11 +596,6 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
NEW_OBJECT_AND_DUMP(JSDataView, JS_DATA_VIEW)
|
||||
break;
|
||||
}
|
||||
case JSType::JS_ARGUMENTS: {
|
||||
CHECK_DUMP_FIELDS(JSObject::SIZE, JSArguments::SIZE, 1U)
|
||||
NEW_OBJECT_AND_DUMP(JSArguments, JS_ARGUMENTS)
|
||||
break;
|
||||
}
|
||||
case JSType::JS_GENERATOR_OBJECT: {
|
||||
CHECK_DUMP_FIELDS(JSObject::SIZE, JSGeneratorObject::SIZE, 3U)
|
||||
NEW_OBJECT_AND_DUMP(JSGeneratorObject, JS_GENERATOR_OBJECT)
|
||||
@ -678,15 +671,6 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
DUMP_FOR_HANDLE(dict)
|
||||
break;
|
||||
}
|
||||
case JSType::FREE_OBJECT_WITH_ONE_FIELD:
|
||||
case JSType::FREE_OBJECT_WITH_NONE_FIELD:
|
||||
case JSType::FREE_OBJECT_WITH_TWO_FIELD:
|
||||
{
|
||||
break;
|
||||
}
|
||||
case JSType::JS_NATIVE_POINTER: {
|
||||
break;
|
||||
}
|
||||
case JSType::GLOBAL_ENV: {
|
||||
DUMP_FOR_HANDLE(globalEnv)
|
||||
break;
|
||||
@ -1068,6 +1052,13 @@ HWTEST_F_L0(EcmaDumpTest, HeapProfileDump)
|
||||
DUMP_FOR_HANDLE(cjsRequire);
|
||||
break;
|
||||
}
|
||||
case JSType::JS_ITERATOR:
|
||||
case JSType::FREE_OBJECT_WITH_ONE_FIELD:
|
||||
case JSType::FREE_OBJECT_WITH_NONE_FIELD:
|
||||
case JSType::FREE_OBJECT_WITH_TWO_FIELD:
|
||||
case JSType::JS_NATIVE_POINTER: {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ECMA_MEM(ERROR) << "JSType " << static_cast<int>(type) << " cannot be dumped.";
|
||||
UNREACHABLE();
|
||||
|
Loading…
Reference in New Issue
Block a user