mirror of
https://github.com/openharmony/ark_js_runtime.git
synced 2026-07-25 22:15:32 -04:00
36a1c21412
1.Fix aot newobjdynrange by call JSFunction::Construct. 2.Add native new test case(new non-native constructor depends on `defineclass`). 3.Add StackAssertScope in debug mode. 4.Delete retired `call` code in runtime_stubs. 5.Refactor GetArg from macros to inline function in RuntimeStubs. Signed-off-by: ding <dingding5@huawei.com> Change-Id: Ic89b98af11f2e2fc97aaeba1704d27a95d2c0c7b
105 lines
3.2 KiB
C++
105 lines
3.2 KiB
C++
/*
|
|
* Copyright (c) 2022 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_COMPILER_LOG_H
|
|
#define ECMASCRIPT_COMPILER_LOG_H
|
|
|
|
#include <algorithm>
|
|
#include <iostream>
|
|
#include <map>
|
|
#include <sstream>
|
|
#include <string>
|
|
#include <vector>
|
|
|
|
namespace panda::ecmascript::kungfu {
|
|
class CompilerLog {
|
|
public:
|
|
explicit CompilerLog(const std::string &logMehtods) : methods_(logMehtods) {}
|
|
~CompilerLog() = default;
|
|
|
|
bool IsAlwaysEnabled() const
|
|
{
|
|
return methods_.compare("all") == 0;
|
|
}
|
|
|
|
bool IsAlwaysDisabled() const
|
|
{
|
|
return methods_.compare("none") == 0;
|
|
}
|
|
|
|
bool IncludesMethod(const std::string &methodName) const
|
|
{
|
|
bool empty = methodName.empty();
|
|
bool found = methods_.find(methodName) != std::string::npos;
|
|
return !empty && found;
|
|
}
|
|
|
|
private:
|
|
std::string methods_ {"none"};
|
|
};
|
|
|
|
class AotLog : public CompilerLog {
|
|
public:
|
|
static const char fileSplitSign = ':';
|
|
static const char methodSplitSign = ',';
|
|
|
|
explicit AotLog(const std::string &logMehtods) : CompilerLog(logMehtods)
|
|
{
|
|
ParseFileMethodsName(logMehtods);
|
|
}
|
|
~AotLog() = default;
|
|
|
|
bool IncludesMethod(const std::string &fileName, const std::string &methodName) const
|
|
{
|
|
if (fileMethods_.find(fileName) == fileMethods_.end()) {
|
|
return false;
|
|
}
|
|
std::vector mehtodVector = fileMethods_.at(fileName);
|
|
auto it = find(mehtodVector.begin(), mehtodVector.end(), methodName);
|
|
return (it != mehtodVector.end());
|
|
}
|
|
|
|
private:
|
|
std::vector<std::string> spiltString(const std::string &str, const char ch)
|
|
{
|
|
std::vector<std::string> vec{};
|
|
std::istringstream sstr(str.c_str());
|
|
std::string spilt;
|
|
while(getline(sstr, spilt, ch)) {
|
|
vec.emplace_back(spilt);
|
|
}
|
|
return vec;
|
|
}
|
|
|
|
void ParseFileMethodsName(const std::string &logMehtods)
|
|
{
|
|
if (IsAlwaysEnabled() || IsAlwaysDisabled()) {
|
|
return;
|
|
}
|
|
|
|
std::vector<std::string> fileVector = spiltString(logMehtods, fileSplitSign);
|
|
std::vector<std::string> itemVector;
|
|
for (size_t index = 0; index < fileVector.size(); ++index) {
|
|
itemVector = spiltString(fileVector[index], methodSplitSign);
|
|
std::vector<std::string> methodVector(itemVector.begin() + 1, itemVector.end());
|
|
fileMethods_[itemVector[0]] = methodVector;
|
|
}
|
|
}
|
|
|
|
std::map<std::string, std::vector<std::string>> fileMethods_ {};
|
|
};
|
|
} // namespace panda::ecmascript::kungfu
|
|
#endif // ECMASCRIPT_COMPILER_LOG_H
|