mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 08:03:29 +00:00
!9009 解释器hasownproperty性能优化
Merge pull request !9009 from jiangmengyang/hasownproperty
This commit is contained in:
commit
9dab80bc7c
@ -662,11 +662,12 @@ void BuiltinsObjectStubBuilder::HasOwnProperty(Variable *result, Label *exit, La
|
||||
BRANCH(TaggedIsString(prop), &keyIsString, slowPath); // 2 : two args
|
||||
Bind(&keyIsString);
|
||||
{
|
||||
GateRef res = CallRuntime(glue_, RTSTUB_ID(TryToElementsIndexOrFindInStringTable), { prop });
|
||||
BRANCH(TaggedIsNumber(res), &isIndex, ¬Index);
|
||||
GateRef res = StringToElementIndex(glue_, prop);
|
||||
// -1: not find element index
|
||||
BRANCH(Int64NotEqual(res, Int64(-1)), &isIndex, ¬Index);
|
||||
Bind(&isIndex);
|
||||
{
|
||||
GateRef index = NumberGetInt(glue_, res);
|
||||
GateRef index = TruncInt64ToInt32(res);
|
||||
Label findByIndex(env);
|
||||
GateRef elements = GetElementsArray(thisValue);
|
||||
GateRef len = GetLengthOfTaggedArray(elements);
|
||||
@ -709,7 +710,15 @@ void BuiltinsObjectStubBuilder::HasOwnProperty(Variable *result, Label *exit, La
|
||||
Bind(¬Index);
|
||||
{
|
||||
Label findInStringTabel(env);
|
||||
BRANCH(TaggedIsHole(res), exit, &findInStringTabel);
|
||||
Label notInternString(env);
|
||||
DEFVARIABLE(stringTable, VariableType::JS_ANY(), prop);
|
||||
BRANCH(IsInternalString(prop), &findInStringTabel, ¬InternString);
|
||||
Bind(¬InternString);
|
||||
{
|
||||
GateRef internString = CallRuntime(glue_, RTSTUB_ID(TryGetInternString), { prop });
|
||||
stringTable = internString;
|
||||
BRANCH(TaggedIsHole(internString), exit, &findInStringTabel)
|
||||
}
|
||||
Bind(&findInStringTabel);
|
||||
{
|
||||
Label isDicMode(env);
|
||||
@ -721,7 +730,7 @@ void BuiltinsObjectStubBuilder::HasOwnProperty(Variable *result, Label *exit, La
|
||||
GateRef layOutInfo = GetLayoutFromHClass(hclass);
|
||||
GateRef propsNum = GetNumberOfPropsFromHClass(hclass);
|
||||
// int entry = layoutInfo->FindElementWithCache(thread, hclass, key, propsNumber)
|
||||
GateRef entryA = FindElementWithCache(glue_, layOutInfo, hclass, res, propsNum, hir);
|
||||
GateRef entryA = FindElementWithCache(glue_, layOutInfo, hclass, *stringTable, propsNum, hir);
|
||||
Label hasEntry(env);
|
||||
// if branch condition : entry != -1
|
||||
BRANCH(Int32NotEqual(entryA, Int32(-1)), &hasEntry, exit);
|
||||
@ -735,7 +744,7 @@ void BuiltinsObjectStubBuilder::HasOwnProperty(Variable *result, Label *exit, La
|
||||
{
|
||||
GateRef array = GetPropertiesArray(thisValue);
|
||||
// int entry = dict->FindEntry(key)
|
||||
GateRef entryB = FindEntryFromNameDictionary(glue_, array, res, hir);
|
||||
GateRef entryB = FindEntryFromNameDictionary(glue_, array, *stringTable, hir);
|
||||
Label notNegtiveOne(env);
|
||||
// if branch condition : entry != -1
|
||||
BRANCH(Int32NotEqual(entryB, Int32(-1)), ¬NegtiveOne, exit);
|
||||
|
@ -463,7 +463,6 @@ namespace panda::ecmascript {
|
||||
V(HasProperty) \
|
||||
V(DumpObject) \
|
||||
V(TryGetInternString) \
|
||||
V(TryToElementsIndexOrFindInStringTable) \
|
||||
V(BigIntConstructor) \
|
||||
V(ObjectPrototypeHasOwnProperty) \
|
||||
V(ReflectHas) \
|
||||
|
@ -3007,20 +3007,6 @@ DEF_RUNTIME_STUBS(SlowFlattenString)
|
||||
return JSTaggedValue(EcmaStringAccessor::SlowFlatten(thread->GetEcmaVM(), str)).GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(TryToElementsIndexOrFindInStringTable)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(TryToElementsIndexOrFindInStringTable);
|
||||
JSHandle<EcmaString> string = GetHArg<EcmaString>(argv, argc, 0); // 0: means the zeroth parameter
|
||||
uint32_t index = 0;
|
||||
if (EcmaStringAccessor(string).ToElementIndex(&index)) {
|
||||
return JSTaggedValue(index).GetRawData();
|
||||
}
|
||||
if (!EcmaStringAccessor(string).IsInternString()) {
|
||||
return RuntimeTryGetInternString(argGlue, string);
|
||||
}
|
||||
return string.GetTaggedValue().GetRawData();
|
||||
}
|
||||
|
||||
DEF_RUNTIME_STUBS(TryGetInternString)
|
||||
{
|
||||
RUNTIME_STUBS_HEADER(TryGetInternString);
|
||||
|
@ -30,3 +30,5 @@ hhh
|
||||
cuowu
|
||||
true
|
||||
false
|
||||
false
|
||||
false
|
||||
|
@ -77,4 +77,11 @@ var proxy = new Proxy(person, {
|
||||
print(proxy.name);
|
||||
print(proxy.age);
|
||||
print(proxy.hasOwnProperty('name'));
|
||||
print(proxy.hasOwnProperty('age'));
|
||||
print(proxy.hasOwnProperty('age'));
|
||||
|
||||
let obj2 = {};
|
||||
obj2.property1 = 12;
|
||||
// is not intern string branch and not found in intern string table
|
||||
print(obj2.hasOwnProperty(String.fromCodePoint("")));
|
||||
// is not intern string branch and found in intern string table
|
||||
print(obj2.hasOwnProperty(String.fromCodePoint(123)));
|
Loading…
Reference in New Issue
Block a user