mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-07 16:13:49 +00:00
eef37db2c3
1. Add EnumCache for simple properties and no-elements properties 2. Add fastpath for non-special objects 3. Avoid duplicated copy for slowpath 4. Transition hclass when detele prop in TS Issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I84DMO?from=project-issue Signed-off-by: zhangyukun8 <zhangyukun8@huawei.com> Change-Id: I81648b44cc83a907c50ec90c9e8de3bbb104cef8
64 lines
2.3 KiB
C++
64 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2023 Huawei Device 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.
|
|
*/
|
|
|
|
#ifndef ECMASCRIPT_PROPERTY_ACCESSOR_H
|
|
#define ECMASCRIPT_PROPERTY_ACCESSOR_H
|
|
|
|
#include "ecmascript/js_handle.h"
|
|
#include "ecmascript/js_tagged_value.h"
|
|
#include "ecmascript/js_thread.h"
|
|
|
|
namespace panda::ecmascript {
|
|
class JSObject;
|
|
class TaggedArray;
|
|
class PropertyAccessor {
|
|
public:
|
|
PropertyAccessor(JSThread *thread, JSHandle<JSTaggedValue> object);
|
|
|
|
JSHandle<JSTaggedValue> GetKeysFast();
|
|
JSHandle<JSTaggedValue> GetKeysSlow();
|
|
|
|
JSHandle<JSTaggedValue> GetCachedHclass();
|
|
uint32_t GetActualKeyLength() const;
|
|
|
|
private:
|
|
void PreLoad();
|
|
void CollectPrototypeInfo();
|
|
void InitSimplePropertiesEnumCache();
|
|
void AccumulateKeyLength(uint32_t length);
|
|
void AccumulateShadowKeyLength(uint32_t length);
|
|
void PushRemainingKeys(JSHandle<JSObject> object, std::vector<JSHandle<TaggedArray>> &remainings);
|
|
void MergeRemainings(const std::vector<JSHandle<TaggedArray>> &remainings,
|
|
const std::vector<JSHandle<JSTaggedValue>> &visited);
|
|
void SetActualKeyLength(uint32_t length);
|
|
void AddKeysEndIfNeeded(JSHandle<TaggedArray> keys);
|
|
void TryInitEnumCacheWithProtoChainInfo();
|
|
|
|
JSThread *thread_{nullptr};
|
|
JSMutableHandle<JSTaggedValue> receiver_;
|
|
JSMutableHandle<JSTaggedValue> fastKeysArray_;
|
|
JSMutableHandle<JSTaggedValue> cachedHclass_;
|
|
uint32_t keyLength_ {0};
|
|
uint32_t shadowKeyLength_ {0};
|
|
// receiver has no elements, and is not dictionary mode and has empty prototype
|
|
bool onlyHasSimpleProperties_ {true};
|
|
bool canUseEnumCache_ {true};
|
|
bool hasSlowProperties_ {false};
|
|
JSMutableHandle<TaggedArray> slowKeysArray_;
|
|
uint32_t acutalKeyLength_ {0};
|
|
};
|
|
} // namespace panda::ecmascript
|
|
#endif // ECMASCRIPT_PROPERTY_ACCESSOR_H
|