arkcompiler_ets_runtime/ecmascript/sustaining_js_handle.h
xiaoweidong 420b5ec786 [JIT] Set default options for concurrent jit compile
Change-Id: I64c028590421704e408affab581df52a71ab9579
Signed-off-by: xiaoweidong <xiaoweidong@huawei.com>
2024-04-21 23:30:13 +08:00

72 lines
2.1 KiB
C++

/*
* Copyright (c) 2024 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_SUSTAINING_JS_HANDLE_H
#define ECMASCRIPT_SUSTAINING_JS_HANDLE_H
#include "ecmascript/common.h"
#include "ecmascript/platform/mutex.h"
#include "ecmascript/ecma_vm.h"
namespace panda::ecmascript {
class SustainingJSHandle {
public:
SustainingJSHandle(EcmaVM *vm);
~SustainingJSHandle();
template <typename T>
JSHandle<T> NewHandle(JSHandle<T> value)
{
return JSHandle<T>(GetJsHandleSlot(value.GetTaggedType()));
}
template <typename T>
JSHandle<T> NewHandle(JSTaggedType value)
{
return JSHandle<T>(GetJsHandleSlot(value));
}
void Iterate(const RootRangeVisitor &rv);
private:
uintptr_t GetJsHandleSlot(JSTaggedType value);
uintptr_t Expand();
EcmaVM *vm_ { nullptr };
JSTaggedType *blockNext_ { nullptr };
JSTaggedType *blockLimit_ { nullptr };
SustainingJSHandle *pre_ { nullptr };
SustainingJSHandle *next_ { nullptr };
EcmaContext *context_ { nullptr };
static constexpr uint32_t BLOCK_SIZE = 256L;
std::vector<std::array<JSTaggedType, BLOCK_SIZE>*> handleBlocks_;
friend class SustainingJSHandleList;
};
class SustainingJSHandleList {
public:
void AddSustainingJSHandle(SustainingJSHandle *sustainingJSHandle);
void RemoveSustainingJSHandle(SustainingJSHandle *sustainingJSHandle);
void Iterate(const RootRangeVisitor &rv);
private:
SustainingJSHandle *listHead_ { nullptr };
Mutex mutex_;
};
} // namespace panda::ecmascript
#endif // ECMASCRIPT_SUSTAINING_JS_HANDLE_H