mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-08-27 02:31:17 -04:00
61b6782b65
Description:Snapshot code optimization include modify class name SnapShotSerialize to SnapShotHandler, delete some magic number, add interface to acquire global env and global const object index. Issue:https://gitee.com/openharmony/ark_js_runtime/issues/I55CQ3 Signed-off-by: dingwen <dingwen6@huawei.com> Change-Id: I338028c5cfd4f992095f2bded2956e33f275bb1b
68 lines
2.3 KiB
C++
68 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2021 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_STRING_TABLE_H
|
|
#define ECMASCRIPT_STRING_TABLE_H
|
|
|
|
#include "ecmascript/mem/c_containers.h"
|
|
#include "ecmascript/mem/visitor.h"
|
|
|
|
namespace panda::ecmascript {
|
|
class EcmaString;
|
|
class EcmaVM;
|
|
|
|
class EcmaStringTable {
|
|
public:
|
|
explicit EcmaStringTable(const EcmaVM *vm);
|
|
virtual ~EcmaStringTable()
|
|
{
|
|
table_.clear();
|
|
}
|
|
|
|
void InternEmptyString(EcmaString *emptyStr);
|
|
EcmaString *GetOrInternString(const JSHandle<EcmaString> &firstString, const JSHandle<EcmaString> &secondString);
|
|
EcmaString *GetOrInternString(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress);
|
|
EcmaString *GetOrInternString(const uint16_t *utf16Data, uint32_t utf16Len, bool canBeCompress);
|
|
EcmaString *GetOrInternString(EcmaString *string);
|
|
|
|
void SweepWeakReference(const WeakRootVisitor &visitor);
|
|
|
|
private:
|
|
NO_COPY_SEMANTIC(EcmaStringTable);
|
|
NO_MOVE_SEMANTIC(EcmaStringTable);
|
|
|
|
EcmaString *GetString(const JSHandle<EcmaString> &firstString, const JSHandle<EcmaString> &secondString) const;
|
|
EcmaString *GetString(const uint8_t *utf8Data, uint32_t utf8Len, bool canBeCompress) const;
|
|
EcmaString *GetString(const uint16_t *utf16Data, uint32_t utf16Len) const;
|
|
EcmaString *GetString(EcmaString *string) const;
|
|
|
|
void InternString(EcmaString *string);
|
|
|
|
void InsertStringIfNotExist(EcmaString *string)
|
|
{
|
|
EcmaString *str = GetString(string);
|
|
if (str == nullptr) {
|
|
InternString(string);
|
|
}
|
|
}
|
|
|
|
CUnorderedMultiMap<uint32_t, EcmaString *> table_;
|
|
const EcmaVM *vm_{nullptr};
|
|
friend class SnapshotProcessor;
|
|
};
|
|
} // namespace panda::ecmascript
|
|
|
|
#endif // ECMASCRIPT_STRING_TABLE_H
|