mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-27 04:00:37 +00:00
Modifying Code Alarms
Signed-off-by: hwx1163501 <hanjing35@huawei.com> issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I83M46
This commit is contained in:
parent
95e4a84a2e
commit
0cfe428522
@ -107,7 +107,6 @@ JSTaggedValue NumberHelper::DoubleToString(JSThread *thread, double number, int
|
|||||||
auto value = bit_cast<uint64_t>(number);
|
auto value = bit_cast<uint64_t>(number);
|
||||||
value += 1;
|
value += 1;
|
||||||
double delta = HALF * (bit_cast<double>(value) - number);
|
double delta = HALF * (bit_cast<double>(value) - number);
|
||||||
|
|
||||||
if (fraction != 0 && fraction >= delta) {
|
if (fraction != 0 && fraction >= delta) {
|
||||||
buffer[fractionCursor++] = '.';
|
buffer[fractionCursor++] = '.';
|
||||||
while (fraction >= delta) {
|
while (fraction >= delta) {
|
||||||
@ -159,8 +158,10 @@ JSTaggedValue NumberHelper::DoubleToString(JSThread *thread, double number, int
|
|||||||
|
|
||||||
size_t size = fractionCursor - integerCursor;
|
size_t size = fractionCursor - integerCursor;
|
||||||
std::unique_ptr<char[]> result = std::make_unique<char[]>(size);
|
std::unique_ptr<char[]> result = std::make_unique<char[]>(size);
|
||||||
memcpy_s(result.get(), size, buffer + integerCursor, size);
|
if (memcpy_s(result.get(), size, buffer + integerCursor, size) != EOK) {
|
||||||
|
LOG_FULL(FATAL) << "memcpy_s failed";
|
||||||
|
UNREACHABLE();
|
||||||
|
}
|
||||||
return BuiltinsBase::GetTaggedString(thread, result.get());
|
return BuiltinsBase::GetTaggedString(thread, result.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2767,7 +2767,8 @@ void Builtins::LazyInitializeSharedArrayBuffer(const JSHandle<GlobalEnv> &env) c
|
|||||||
[[maybe_unused]] EcmaHandleScope scope(thread_);
|
[[maybe_unused]] EcmaHandleScope scope(thread_);
|
||||||
JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
|
JSHandle<JSObject> globalObject(thread_, env->GetGlobalObject());
|
||||||
JSHandle<JSTaggedValue> key(factory_->NewFromUtf8("SharedArrayBuffer"));
|
JSHandle<JSTaggedValue> key(factory_->NewFromUtf8("SharedArrayBuffer"));
|
||||||
auto accessor = factory_->NewInternalAccessor(nullptr, reinterpret_cast<void *>(BuiltinsLazyCallback::SharedArrayBuffer));
|
auto accessor =
|
||||||
|
factory_->NewInternalAccessor(nullptr, reinterpret_cast<void *>(BuiltinsLazyCallback::SharedArrayBuffer));
|
||||||
SetLazyAccessor(globalObject, key, accessor);
|
SetLazyAccessor(globalObject, key, accessor);
|
||||||
env->SetSharedArrayBufferFunction(thread_, accessor);
|
env->SetSharedArrayBufferFunction(thread_, accessor);
|
||||||
}
|
}
|
||||||
|
@ -1531,7 +1531,7 @@ JSTaggedValue BuiltinsRegExp::RegExpBuiltinExec(JSThread *thread, const JSHandle
|
|||||||
if (!global && !sticky) {
|
if (!global && !sticky) {
|
||||||
lastIndex = 0;
|
lastIndex = 0;
|
||||||
}
|
}
|
||||||
uint32_t lastIndexInput = lastIndex;
|
uint32_t lastIndexInput = static_cast<uint32_t>(lastIndex);
|
||||||
if (useCache) {
|
if (useCache) {
|
||||||
JSTaggedValue cacheResult = cacheTable->FindCachedResult(thread, pattern, flags, inputStr,
|
JSTaggedValue cacheResult = cacheTable->FindCachedResult(thread, pattern, flags, inputStr,
|
||||||
RegExpExecResultCache::EXEC_TYPE, regexp,
|
RegExpExecResultCache::EXEC_TYPE, regexp,
|
||||||
|
@ -382,7 +382,7 @@ void ElfBuilder::FixSymtab(llvm::ELF::Elf64_Shdr* shdr)
|
|||||||
|
|
||||||
uint32_t secSize = des_[FullSecIndex].GetSecSize(ElfSecName::SYMTAB);
|
uint32_t secSize = des_[FullSecIndex].GetSecSize(ElfSecName::SYMTAB);
|
||||||
uint64_t secAddr = des_[FullSecIndex].GetSecAddr(ElfSecName::SYMTAB);
|
uint64_t secAddr = des_[FullSecIndex].GetSecAddr(ElfSecName::SYMTAB);
|
||||||
uint32_t secNum = GetSecNum();
|
uint32_t secNum = static_cast<uint32_t>(GetSecNum());
|
||||||
uint64_t textSecOffset = sectionToShdr_[ElfSecName::TEXT].sh_offset;
|
uint64_t textSecOffset = sectionToShdr_[ElfSecName::TEXT].sh_offset;
|
||||||
uint32_t shStrTabIndex = GetShIndex(ElfSecName::SHSTRTAB);
|
uint32_t shStrTabIndex = GetShIndex(ElfSecName::SHSTRTAB);
|
||||||
uint32_t textSecIndex = GetShIndex(ElfSecName::TEXT);
|
uint32_t textSecIndex = GetShIndex(ElfSecName::TEXT);
|
||||||
@ -393,7 +393,7 @@ void ElfBuilder::FixSymtab(llvm::ELF::Elf64_Shdr* shdr)
|
|||||||
for (size_t i = 0; i < n; ++i) {
|
for (size_t i = 0; i < n; ++i) {
|
||||||
Elf64_Sym* sy = &syms[i];
|
Elf64_Sym* sy = &syms[i];
|
||||||
if (sy->getBinding() != llvm::ELF::STB_LOCAL && localCount == -1) {
|
if (sy->getBinding() != llvm::ELF::STB_LOCAL && localCount == -1) {
|
||||||
localCount = i;
|
localCount = static_cast<int>(i);
|
||||||
}
|
}
|
||||||
if (sy->getType() == llvm::ELF::STT_SECTION) {
|
if (sy->getType() == llvm::ELF::STT_SECTION) {
|
||||||
sy->st_shndx = shStrTabIndex;
|
sy->st_shndx = shStrTabIndex;
|
||||||
@ -405,7 +405,7 @@ void ElfBuilder::FixSymtab(llvm::ELF::Elf64_Shdr* shdr)
|
|||||||
sy->st_shndx = 0;
|
sy->st_shndx = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shdr->sh_info = localCount;
|
shdr->sh_info = static_cast<uint32_t>(localCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -452,7 +452,7 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
|
|||||||
llvm::ELF::Elf64_Off curSecOffset = ComputeEndAddrOfShdr(secNum);
|
llvm::ELF::Elf64_Off curSecOffset = ComputeEndAddrOfShdr(secNum);
|
||||||
file.seekp(curSecOffset);
|
file.seekp(curSecOffset);
|
||||||
|
|
||||||
int i = GetShIndex(ElfSecName::TEXT);
|
int i = static_cast<int>(GetShIndex(ElfSecName::TEXT));
|
||||||
auto shStrTab = FindShStrTab();
|
auto shStrTab = FindShStrTab();
|
||||||
|
|
||||||
for (auto const &[secName, secInfo] : sections) {
|
for (auto const &[secName, secInfo] : sections) {
|
||||||
|
@ -689,7 +689,7 @@ void ArrayBoundsCheckElimination::ProcessIndexCheck(GateRegion *loopHeader, Gate
|
|||||||
void ArrayBoundsCheckElimination::ProcessIf(IntegerStack &pushed, GateRegion *parent, OpCode cond)
|
void ArrayBoundsCheckElimination::ProcessIf(IntegerStack &pushed, GateRegion *parent, OpCode cond)
|
||||||
{
|
{
|
||||||
auto& gateLists = parent->GetGates();
|
auto& gateLists = parent->GetGates();
|
||||||
for (int i = gateLists.size() - 1; i >= 0; i--) { // Found the last BinaryOp
|
for (int i = static_cast<int>(gateLists.size()) - 1; i >= 0; i--) { // Found the last BinaryOp
|
||||||
GateRef gate = gateLists[i];
|
GateRef gate = gateLists[i];
|
||||||
if (gate == Circuit::NullGate()) continue;
|
if (gate == Circuit::NullGate()) continue;
|
||||||
OpCode opGate = acc_.GetOpCode(gate);
|
OpCode opGate = acc_.GetOpCode(gate);
|
||||||
|
@ -416,10 +416,7 @@ public:
|
|||||||
// key:constantpool index, value:ItemData
|
// key:constantpool index, value:ItemData
|
||||||
using Item = std::unordered_map<uint64_t, ItemData>;
|
using Item = std::unordered_map<uint64_t, ItemData>;
|
||||||
|
|
||||||
ConstantPoolInfo(JSPandaFile* jsPandaFile) :
|
ConstantPoolInfo(JSPandaFile* jsPandaFile) : items_(ItemType::ITEM_TYPE_NUM, Item{}), jsPandaFile_(jsPandaFile) {}
|
||||||
items_(ItemType::ITEM_TYPE_NUM, Item{}),
|
|
||||||
jsPandaFile_(jsPandaFile)
|
|
||||||
{}
|
|
||||||
|
|
||||||
Item& GetCPItem(ItemType type)
|
Item& GetCPItem(ItemType type)
|
||||||
{
|
{
|
||||||
|
@ -534,7 +534,7 @@ ElementsKind GateAccessor::TryGetElementsKind(GateRef gate) const
|
|||||||
OpCode op = GetOpCode(gate);
|
OpCode op = GetOpCode(gate);
|
||||||
if (op == OpCode::JS_BYTECODE) {
|
if (op == OpCode::JS_BYTECODE) {
|
||||||
auto elementKind = gatePtr->GetJSBytecodeMetaData()->GetElementsKind();
|
auto elementKind = gatePtr->GetJSBytecodeMetaData()->GetElementsKind();
|
||||||
if (static_cast<uint32_t>(elementKind) == 4) {
|
if (static_cast<uint32_t>(elementKind) == 4) { // 4:elementKind
|
||||||
return ElementsKind::NUMBER;
|
return ElementsKind::NUMBER;
|
||||||
}
|
}
|
||||||
return gatePtr->GetJSBytecodeMetaData()->GetElementsKind();
|
return gatePtr->GetJSBytecodeMetaData()->GetElementsKind();
|
||||||
|
@ -140,7 +140,7 @@ void name##StubBuilder::GenerateCircuitImpl(GateRef glue, GateRef sp, GateRef pc
|
|||||||
Jump(&dispatch); \
|
Jump(&dispatch); \
|
||||||
} \
|
} \
|
||||||
Bind(&initialized); \
|
Bind(&initialized); \
|
||||||
callback.TryDump(); \
|
(callback).TryDump(); \
|
||||||
Jump(&dispatch); \
|
Jump(&dispatch); \
|
||||||
} \
|
} \
|
||||||
Bind(&dispatch);
|
Bind(&dispatch);
|
||||||
|
@ -105,9 +105,10 @@ public:
|
|||||||
static constexpr int32_t UINT30_MAX = 0x3fffffff;
|
static constexpr int32_t UINT30_MAX = 0x3fffffff;
|
||||||
static constexpr int32_t TYPED_ARRAY_ONHEAP_MAX = JSTypedArray::MAX_ONHEAP_LENGTH;
|
static constexpr int32_t TYPED_ARRAY_ONHEAP_MAX = JSTypedArray::MAX_ONHEAP_LENGTH;
|
||||||
static constexpr int32_t UINT18_MAX = (1 << 18) - 1;
|
static constexpr int32_t UINT18_MAX = (1 << 18) - 1;
|
||||||
static const inline std::vector<int32_t> rangeBounds_ = { INT32_MIN, INT32_MIN + 1, -UINT18_MAX, -TYPED_ARRAY_ONHEAP_MAX,
|
static const inline std::vector<int32_t> rangeBounds_ = {INT32_MIN, INT32_MIN + 1,
|
||||||
-1, 0, 1, TYPED_ARRAY_ONHEAP_MAX - 1, TYPED_ARRAY_ONHEAP_MAX, TYPED_ARRAY_ONHEAP_MAX + 1,
|
-UINT18_MAX, -TYPED_ARRAY_ONHEAP_MAX, -1, 0, 1, TYPED_ARRAY_ONHEAP_MAX - 1,
|
||||||
TYPED_ARRAY_ONHEAP_MAX * 3, UINT18_MAX, UINT30_MAX, UINT30_MAX + 1, INT32_MAX - 1, INT32_MAX };
|
TYPED_ARRAY_ONHEAP_MAX, TYPED_ARRAY_ONHEAP_MAX + 1, TYPED_ARRAY_ONHEAP_MAX * 3,
|
||||||
|
UINT18_MAX, UINT30_MAX, UINT30_MAX + 1, INT32_MAX - 1, INT32_MAX };
|
||||||
|
|
||||||
static RangeInfo NONE()
|
static RangeInfo NONE()
|
||||||
{
|
{
|
||||||
@ -187,20 +188,22 @@ public:
|
|||||||
|
|
||||||
int32_t GetMaxMulResult(const RangeInfo &rhs) const
|
int32_t GetMaxMulResult(const RangeInfo &rhs) const
|
||||||
{
|
{
|
||||||
return std::max({ TryMul(min_, rhs.min_), TryMul(min_, rhs.max_), TryMul(max_, rhs.min_), TryMul(max_, rhs.max_) });
|
return std::max({ TryMul(min_, rhs.min_), TryMul(min_, rhs.max_),
|
||||||
|
TryMul(max_, rhs.min_), TryMul(max_, rhs.max_) });
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t GetMinMulResult(const RangeInfo &rhs) const
|
int32_t GetMinMulResult(const RangeInfo &rhs) const
|
||||||
{
|
{
|
||||||
return std::min({ TryMul(min_, rhs.min_), TryMul(min_, rhs.max_), TryMul(max_, rhs.min_), TryMul(max_, rhs.max_) });
|
return std::min({ TryMul(min_, rhs.min_), TryMul(min_, rhs.max_),
|
||||||
|
TryMul(max_, rhs.min_), TryMul(max_, rhs.max_) });
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t TryMul(int32_t lhs, int32_t rhs) const
|
int32_t TryMul(int32_t lhs, int32_t rhs) const
|
||||||
{
|
{
|
||||||
if (MaybeMulOverflow(lhs, rhs)){
|
if (MaybeMulOverflow(lhs, rhs)) {
|
||||||
return INT32_MAX;
|
return INT32_MAX;
|
||||||
}
|
}
|
||||||
if (MaybeMulUnderflow(lhs, rhs)){
|
if (MaybeMulUnderflow(lhs, rhs)) {
|
||||||
return INT32_MIN;
|
return INT32_MIN;
|
||||||
}
|
}
|
||||||
return lhs * rhs;
|
return lhs * rhs;
|
||||||
|
@ -383,7 +383,7 @@ void NumberSpeculativeLowering::VisitNumberMod(GateRef gate)
|
|||||||
}
|
}
|
||||||
GateRef result = Circuit::NullGate();
|
GateRef result = Circuit::NullGate();
|
||||||
if (gateType.IsIntType()) {
|
if (gateType.IsIntType()) {
|
||||||
if(GetRange(right).MaybeZero()) {
|
if (GetRange(right).MaybeZero()) {
|
||||||
builder_.Int32CheckRightIsZero(right);
|
builder_.Int32CheckRightIsZero(right);
|
||||||
}
|
}
|
||||||
result = CalculateInts<Op>(left, right);
|
result = CalculateInts<Op>(left, right);
|
||||||
@ -628,7 +628,7 @@ GateRef NumberSpeculativeLowering::CalculateInts(GateRef left, GateRef right)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TypedBinOp::TYPED_MUL:
|
case TypedBinOp::TYPED_MUL:
|
||||||
if(!leftRange.MaybeMulOverflowOrUnderflow(rightRange)) {
|
if (!leftRange.MaybeMulOverflowOrUnderflow(rightRange)) {
|
||||||
return builder_.Int32Mul(left, right);
|
return builder_.Int32Mul(left, right);
|
||||||
}
|
}
|
||||||
res = builder_.MulWithOverflow(left, right);
|
res = builder_.MulWithOverflow(left, right);
|
||||||
|
@ -779,11 +779,11 @@ GateRef NumberSpeculativeRetype::TryConvertConstant(GateRef gate, bool needInt32
|
|||||||
|
|
||||||
if (acc_.GetGateType(gate).IsNJSValueType()) {
|
if (acc_.GetGateType(gate).IsNJSValueType()) {
|
||||||
MachineType mType = acc_.GetMachineType(gate);
|
MachineType mType = acc_.GetMachineType(gate);
|
||||||
if(mType == MachineType::I32) {
|
if (mType == MachineType::I32) {
|
||||||
int32_t rawValue = acc_.GetInt32FromConstant(gate);
|
int32_t rawValue = acc_.GetInt32FromConstant(gate);
|
||||||
double value = static_cast<double>(rawValue);
|
double value = static_cast<double>(rawValue);
|
||||||
return needInt32 ? builder_.Int32(rawValue) : builder_.Double(value);
|
return needInt32 ? builder_.Int32(rawValue) : builder_.Double(value);
|
||||||
} else if(mType == MachineType::F64 && !needInt32) {
|
} else if (mType == MachineType::F64 && !needInt32) {
|
||||||
double rawValue = acc_.GetFloat64FromConstant(gate);
|
double rawValue = acc_.GetFloat64FromConstant(gate);
|
||||||
return builder_.Double(rawValue);
|
return builder_.Double(rawValue);
|
||||||
} else {
|
} else {
|
||||||
@ -792,11 +792,11 @@ GateRef NumberSpeculativeRetype::TryConvertConstant(GateRef gate, bool needInt32
|
|||||||
}
|
}
|
||||||
|
|
||||||
JSTaggedValue value(acc_.GetConstantValue(gate));
|
JSTaggedValue value(acc_.GetConstantValue(gate));
|
||||||
if(value.IsInt()) {
|
if (value.IsInt()) {
|
||||||
int32_t rawValue = value.GetInt();
|
int32_t rawValue = value.GetInt();
|
||||||
double doubleValue = static_cast<double>(rawValue);
|
double doubleValue = static_cast<double>(rawValue);
|
||||||
return needInt32 ? builder_.Int32(rawValue) : builder_.Double(doubleValue);
|
return needInt32 ? builder_.Int32(rawValue) : builder_.Double(doubleValue);
|
||||||
} else if(value.IsDouble() && !needInt32) {
|
} else if (value.IsDouble() && !needInt32) {
|
||||||
double rawValue = value.GetDouble();
|
double rawValue = value.GetDouble();
|
||||||
return builder_.Double(rawValue);
|
return builder_.Double(rawValue);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public:
|
|||||||
abcName_ = value;
|
abcName_ = value;
|
||||||
} else if (strcmp(key, KEY_ABC_OFFSET) == 0) {
|
} else if (strcmp(key, KEY_ABC_OFFSET) == 0) {
|
||||||
char *str = nullptr;
|
char *str = nullptr;
|
||||||
abcOffset_ = strtol(value, &str, 0);
|
abcOffset_ = static_cast<uint32_t>(strtol(value, &str, 0));
|
||||||
} else if (strcmp(key, KEY_ABC_SIZE) == 0) {
|
} else if (strcmp(key, KEY_ABC_SIZE) == 0) {
|
||||||
char *str = nullptr;
|
char *str = nullptr;
|
||||||
abcSize_ = static_cast<uint32_t>(strtol(value, &str, 0));
|
abcSize_ = static_cast<uint32_t>(strtol(value, &str, 0));
|
||||||
|
@ -294,7 +294,7 @@ JSHandle<JSHClass> TSHClassGenerator::CreateCHClass(const JSThread *thread,
|
|||||||
JSHandle<TSObjectType> constructorType(thread, classType->GetConstructorType());
|
JSHandle<TSObjectType> constructorType(thread, classType->GetConstructorType());
|
||||||
JSHandle<TSObjLayoutInfo> tsLayout(thread, constructorType->GetObjLayoutInfo());
|
JSHandle<TSObjLayoutInfo> tsLayout(thread, constructorType->GetObjLayoutInfo());
|
||||||
uint32_t numOfProps = tsLayout->GetNumOfProperties() + ClassInfoExtractor::STATIC_RESERVED_LENGTH;
|
uint32_t numOfProps = tsLayout->GetNumOfProperties() + ClassInfoExtractor::STATIC_RESERVED_LENGTH;
|
||||||
JSHandle<JSHClass> hclass;
|
JSHandle<JSHClass> hclass;
|
||||||
if (LIKELY(numOfProps <= PropertyAttributes::MAX_FAST_PROPS_CAPACITY)) {
|
if (LIKELY(numOfProps <= PropertyAttributes::MAX_FAST_PROPS_CAPACITY)) {
|
||||||
TSManager *tsManager = thread->GetCurrentEcmaContext()->GetTSManager();
|
TSManager *tsManager = thread->GetCurrentEcmaContext()->GetTSManager();
|
||||||
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
const GlobalEnvConstants *globalConst = thread->GlobalConstants();
|
||||||
|
@ -83,7 +83,7 @@ public:
|
|||||||
|
|
||||||
int ShouldFreeMore(size_t cachedSize) {
|
int ShouldFreeMore(size_t cachedSize) {
|
||||||
os::memory::LockHolder lock(lock_);
|
os::memory::LockHolder lock(lock_);
|
||||||
int result = regularMapCommitted_.size();
|
size_t result = regularMapCommitted_.size();
|
||||||
return result - cachedSize / REGULAR_MMAP_SIZE;
|
return result - cachedSize / REGULAR_MMAP_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -555,8 +555,7 @@ void LocalSpace::Stop()
|
|||||||
uintptr_t NonMovableSpace::CheckAndAllocate(size_t size)
|
uintptr_t NonMovableSpace::CheckAndAllocate(size_t size)
|
||||||
{
|
{
|
||||||
if (maximumCapacity_ == committedSize_ && GetHeapObjectSize() > MAX_NONMOVABLE_LIVE_OBJ_SIZE &&
|
if (maximumCapacity_ == committedSize_ && GetHeapObjectSize() > MAX_NONMOVABLE_LIVE_OBJ_SIZE &&
|
||||||
!heap_->GetOldGCRequested())
|
!heap_->GetOldGCRequested()) {
|
||||||
{
|
|
||||||
heap_->CollectGarbage(TriggerGCType::OLD_GC, GCReason::ALLOCATION_LIMIT);
|
heap_->CollectGarbage(TriggerGCType::OLD_GC, GCReason::ALLOCATION_LIMIT);
|
||||||
}
|
}
|
||||||
return Allocate(size);
|
return Allocate(size);
|
||||||
|
@ -511,7 +511,7 @@ JSHandle<JSTaggedValue> ModuleManager::ResolveModuleWithMerge(
|
|||||||
JSRecordInfo recordInfo;
|
JSRecordInfo recordInfo;
|
||||||
bool hasRecord = jsPandaFile->CheckAndGetRecordInfo(recordName, recordInfo);
|
bool hasRecord = jsPandaFile->CheckAndGetRecordInfo(recordName, recordInfo);
|
||||||
if (!hasRecord) {
|
if (!hasRecord) {
|
||||||
CString msg = "cannot find record '" + recordName + "', please check the request path.'"
|
CString msg = "cannot find record '" + recordName + "', please check the request path.'"
|
||||||
+ moduleFileName + "'.";
|
+ moduleFileName + "'.";
|
||||||
LOG_FULL(ERROR) << msg;
|
LOG_FULL(ERROR) << msg;
|
||||||
THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, ErrorType::REFERENCE_ERROR, JSTaggedValue, msg.c_str());
|
THROW_NEW_ERROR_AND_RETURN_HANDLE(thread, ErrorType::REFERENCE_ERROR, JSTaggedValue, msg.c_str());
|
||||||
|
@ -116,7 +116,7 @@ void ArkStackMapParser::GetMethodOffsetInfo(uintptr_t callSiteAddr, std::map<uin
|
|||||||
ASSERT(it->kind == LocationTy::Kind::CONSTANT);
|
ASSERT(it->kind == LocationTy::Kind::CONSTANT);
|
||||||
ASSERT(std::holds_alternative<LLVMStackMapType::IntType>(it->value));
|
ASSERT(std::holds_alternative<LLVMStackMapType::IntType>(it->value));
|
||||||
auto v = std::get<LLVMStackMapType::IntType>(it->value);
|
auto v = std::get<LLVMStackMapType::IntType>(it->value);
|
||||||
info[static_cast<int32_t>(SpecVregIndex::FIRST_METHOD_OFFSET_INDEX) - id] = v;
|
info[static_cast<int32_t>(SpecVregIndex::FIRST_METHOD_OFFSET_INDEX) - id] = static_cast<uint32_t>(v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,27 +21,27 @@ import cv2
|
|||||||
import tempfile
|
import tempfile
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
webPath = os.path.realpath("../dist")
|
web_path = os.path.realpath("../dist")
|
||||||
|
|
||||||
|
|
||||||
class MyHttpRequestHandler(SimpleHTTPRequestHandler):
|
class MyHttpRequestHandler(SimpleHTTPRequestHandler):
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, directory=webPath, **kwargs)
|
super().__init__(*args, directory=web_path, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
httpd = socketserver.TCPServer(("", 9999), MyHttpRequestHandler)
|
httpd = socketserver.TCPServer(("", 9999), MyHttpRequestHandler)
|
||||||
driver = webdriver.Chrome()
|
driver = webdriver.Chrome()
|
||||||
actions = ActionChains(driver)
|
actions = ActionChains(driver)
|
||||||
reader = easyocr.Reader(['ch_sim', 'en'], verbose=False)
|
reader = easyocr.Reader(['ch_sim', 'en'], verbose=False)
|
||||||
windowWidth = -1
|
window_width = -1
|
||||||
windowHeight = -1
|
window_height = -1
|
||||||
tempImageFile = os.path.join(tempfile.gettempdir(), "test.png")
|
temp_image_file = os.path.join(tempfile.gettempdir(), "test.png")
|
||||||
|
|
||||||
|
|
||||||
def cut_image(image, x, y, w, h):
|
def cut_image(image, x, y, w, h):
|
||||||
x = int(x)
|
x = int(x)
|
||||||
y = int(y)
|
y = int(y)
|
||||||
return image[y:y+h, x:x+w]
|
return image[y:y + h, x:x + w]
|
||||||
|
|
||||||
|
|
||||||
oldx = 0
|
oldx = 0
|
||||||
@ -50,7 +50,7 @@ oldy = 0
|
|||||||
|
|
||||||
def click_on_page(x, y):
|
def click_on_page(x, y):
|
||||||
global oldx, oldy
|
global oldx, oldy
|
||||||
actions.move_by_offset(x-oldx, y-oldy).click().perform()
|
actions.move_by_offset(x - oldx, y - oldy).click().perform()
|
||||||
oldx = x
|
oldx = x
|
||||||
oldy = y
|
oldy = y
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
@ -71,9 +71,9 @@ def setup():
|
|||||||
print("setup : selenium打开测试页面")
|
print("setup : selenium打开测试页面")
|
||||||
driver.implicitly_wait(10)
|
driver.implicitly_wait(10)
|
||||||
driver.get("http://127.0.0.1:9999")
|
driver.get("http://127.0.0.1:9999")
|
||||||
global windowWidth, windowHeight
|
global window_width, window_height
|
||||||
windowWidth = driver.execute_script("return document.body.clientWidth")
|
window_width = driver.execute_script("return document.body.clientWidth")
|
||||||
windowHeight = driver.execute_script("return document.body.clientHeight")
|
window_height = driver.execute_script("return document.body.clientHeight")
|
||||||
|
|
||||||
|
|
||||||
def teardown():
|
def teardown():
|
||||||
@ -85,16 +85,16 @@ def teardown():
|
|||||||
|
|
||||||
|
|
||||||
def test_loading(): # 验证载入中画面
|
def test_loading(): # 验证载入中画面
|
||||||
driver.get_screenshot_as_file(tempImageFile)
|
driver.get_screenshot_as_file(temp_image_file)
|
||||||
image = cv2.imread(tempImageFile)
|
image = cv2.imread(temp_image_file)
|
||||||
result = reader.readtext(cut_image(image, windowWidth/2-100, windowHeight/2-20, 200, 40))
|
result = reader.readtext(cut_image(image, window_width / 2 - 100, window_height / 2 - 20, 200, 40))
|
||||||
assert result[0][1][:7] == "Loading"
|
assert result[0][1][:7] == "Loading"
|
||||||
|
|
||||||
|
|
||||||
def test_start(): # 验证主画面显示
|
def test_start(): # 验证主画面显示
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
driver.get_screenshot_as_file(tempImageFile)
|
driver.get_screenshot_as_file(temp_image_file)
|
||||||
image = cv2.imread(tempImageFile)
|
image = cv2.imread(temp_image_file)
|
||||||
result = reader.readtext(cut_image(image, 10, 100, 60, 20))
|
result = reader.readtext(cut_image(image, 10, 100, 60, 20))
|
||||||
assert result[0][1] == "隐藏选中"
|
assert result[0][1] == "隐藏选中"
|
||||||
|
|
||||||
@ -107,7 +107,7 @@ def find_string_in_result(s, result):
|
|||||||
if d < dis:
|
if d < dis:
|
||||||
dis = d
|
dis = d
|
||||||
p = i
|
p = i
|
||||||
if dis < len(s)/2:
|
if dis < len(s) / 2:
|
||||||
return result[p]
|
return result[p]
|
||||||
return False
|
return False
|
||||||
|
|
||||||
@ -116,8 +116,8 @@ def test_selectfunc(): # 点击优化类型切换下拉菜单,选择优化类
|
|||||||
click_on_page(420, 50)
|
click_on_page(420, 50)
|
||||||
click_on_page(420, 150)
|
click_on_page(420, 150)
|
||||||
|
|
||||||
driver.get_screenshot_as_file(tempImageFile)
|
driver.get_screenshot_as_file(temp_image_file)
|
||||||
image = cv2.imread(tempImageFile)
|
image = cv2.imread(temp_image_file)
|
||||||
result = reader.readtext(image)
|
result = reader.readtext(image)
|
||||||
ret = find_string_in_result("0,CIRCUIT_ROOT", result)
|
ret = find_string_in_result("0,CIRCUIT_ROOT", result)
|
||||||
assert ret != False
|
assert ret != False
|
||||||
@ -127,8 +127,8 @@ def test_hide(): # 点击state和root按钮,隐藏0,CIRCUIT_ROOT
|
|||||||
click_on_page(40, 80)
|
click_on_page(40, 80)
|
||||||
click_on_page(350, 80)
|
click_on_page(350, 80)
|
||||||
|
|
||||||
driver.get_screenshot_as_file(tempImageFile)
|
driver.get_screenshot_as_file(temp_image_file)
|
||||||
image = cv2.imread(tempImageFile)
|
image = cv2.imread(temp_image_file)
|
||||||
result = reader.readtext(image)
|
result = reader.readtext(image)
|
||||||
ret = find_string_in_result("0,CIRCUIT_ROOT", result)
|
ret = find_string_in_result("0,CIRCUIT_ROOT", result)
|
||||||
assert ret == False
|
assert ret == False
|
||||||
|
Loading…
Reference in New Issue
Block a user