Modifying Code Alarms

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7163U
This commit is contained in:
hwx1163501 2023-05-18 16:38:08 +08:00
parent 39bf2e59aa
commit 22fe6190c6
31 changed files with 98 additions and 109 deletions

View File

@ -73,16 +73,10 @@ JSTaggedValue TestFunctionApplyAndCall(EcmaRuntimeCallInfo *argv)
}
JSHandle<JSTaggedValue> thisValue(BuiltinsBase::GetThis(argv));
JSTaggedValue testA =
JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_builtins_function_a")))
.GetValue()
.GetTaggedValue();
JSTaggedValue testB =
JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_builtins_function_b")))
.GetValue()
.GetTaggedValue();
JSTaggedValue testA = JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_builtins_function_a"))).GetValue().GetTaggedValue();
JSTaggedValue testB = JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_builtins_function_b"))).GetValue().GetTaggedValue();
result = result + testA.GetInt() + testB.GetInt();
return BuiltinsBase::GetTaggedInt(result);

View File

@ -79,16 +79,10 @@ JSTaggedValue TestReflectApply(EcmaRuntimeCallInfo *argv)
}
JSHandle<JSTaggedValue> thisValue = BuiltinsBase::GetThis(argv);
JSTaggedValue testA =
JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_a")))
.GetValue()
.GetTaggedValue();
JSTaggedValue testB =
JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_b")))
.GetValue()
.GetTaggedValue();
JSTaggedValue testA = JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_a"))).GetValue().GetTaggedValue();
JSTaggedValue testB = JSObject::GetProperty(thread, thisValue,
JSHandle<JSTaggedValue>(factory->NewFromASCII("test_reflect_apply_b"))).GetValue().GetTaggedValue();
result = result + testA.GetInt() + testB.GetInt();
return BuiltinsBase::GetTaggedInt(result);

View File

@ -479,7 +479,7 @@ void ElfBuilder::PackELFSections(std::ofstream &file)
curSecOffset = AlignUp(curSecOffset, PageSize());
file.seekp(curSecOffset);
}
curShdr.sh_link = section.Link();
curShdr.sh_link = static_cast<uint32_t>(section.Link());
curShdr.sh_info = 0;
curShdr.sh_entsize = section.Entsize();
sectionToShdr_[secName] = curShdr;

View File

@ -31,14 +31,14 @@ enum class Triple {
class GCStackMapRegisters {
public:
#if defined(PANDA_TARGET_AMD64)
static constexpr int SP = 7;
static constexpr int FP = 6;
static constexpr int SP = 7; /* x7 */
static constexpr int FP = 6; /* x6 */
#elif defined(PANDA_TARGET_ARM64)
static constexpr int SP = 31; /* x31 */
static constexpr int FP = 29; /* x29 */
#elif defined(PANDA_TARGET_ARM32)
static constexpr int SP = 13;
static constexpr int FP = 11;
static constexpr int SP = 13; /* x13 */
static constexpr int FP = 11; /* x11 */
#else
static constexpr int SP = -1;
static constexpr int FP = -1;
@ -49,13 +49,13 @@ static int GetFpRegByTriple(Triple triple)
int fp = -1;
switch (triple) {
case Triple::TRIPLE_AMD64:
fp = 6;
fp = 6; /* x6 */
break;
case Triple::TRIPLE_ARM32:
fp = 11;
fp = 11; /* x11 */
break;
case Triple::TRIPLE_AARCH64:
fp = 29;
fp = 29; /* x29 */
break;
default:
UNREACHABLE();
@ -69,13 +69,13 @@ static int GetSpRegByTriple(Triple triple)
int sp = -1;
switch (triple) {
case Triple::TRIPLE_AMD64:
sp = 7;
sp = 7; /* x7 */
break;
case Triple::TRIPLE_ARM32:
sp = 13;
sp = 13; /* x13 */
break;
case Triple::TRIPLE_AARCH64:
sp = 31;
sp = 31; /* x31 */
break;
default:
UNREACHABLE();

View File

@ -177,8 +177,9 @@ void AsyncFunctionLowering::UpdateValueSelector(GateRef prevLoopBeginGate,
{controlStateGate, loopBeginFirstState});
if (genNewValuePhiGate) {
GateRef emptyOffsetGate = circuit_->NewGate(circuit_->GetMetaBuilder()->Constant(-1), // -1: distinguish bcoffset
MachineType::I32, GateType::NJSValue());
GateRef emptyOffsetGate =
circuit_->NewGate(circuit_->GetMetaBuilder()->Constant(-1), // -1: distinguish bcoffset
MachineType::I32, GateType::NJSValue());
GateRef restoreOffset = accessor_.GetValueIn(prevBcOffsetPhiGate);
// this value selector is compatible with await in the loop body
GateRef valueSelector = circuit_->NewGate(circuit_->ValueSelector(2), MachineType::I32, // 2: num of valueIn

View File

@ -1103,7 +1103,7 @@ void AsmInterpreterCall::PushFrameState(ExtendedAssembler *assembler, Register p
Register currentSlot, Register callTarget, Register thisObj, Register method, Register pc, Register op)
{
__ Mov(op, Immediate(static_cast<int32_t>(FrameType::ASM_INTERPRETER_FRAME)));
__ Stp(prevSp, op, MemoryOperand(currentSlot, -2 * FRAME_SLOT_SIZE, AddrMode::PREINDEX));// -2: frame type & prevSp
__ Stp(prevSp, op, MemoryOperand(currentSlot, -2 * FRAME_SLOT_SIZE, AddrMode::PREINDEX)); // -2: frame type & prevSp
__ Ldr(pc, MemoryOperand(method, Method::NATIVE_POINTER_OR_BYTECODE_ARRAY_OFFSET));
__ Stp(fp, pc, MemoryOperand(currentSlot, -2 * FRAME_SLOT_SIZE, AddrMode::PREINDEX)); // -2: pc & fp
__ Ldr(op, MemoryOperand(callTarget, JSFunction::LEXICAL_ENV_OFFSET));

View File

@ -358,7 +358,7 @@ JSHandle<JSTaggedValue> ContainersPrivate::InitializeLightWeightMap(JSThread *th
thread, funcPrototype, ContainersLightWeightMap::LightWeightMapConstructor, "LightWeightMap",
FuncLength::ZERO));
JSHandle<JSFunction>::Cast(lightWeightMapFunction)->
SetFunctionPrototype(thread, lightWeightMapInstanceClass.GetTaggedValue());
SetFunctionPrototype(thread, lightWeightMapInstanceClass.GetTaggedValue());
// "constructor" property on the prototype
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
@ -432,7 +432,7 @@ JSHandle<JSTaggedValue> ContainersPrivate::InitializeLightWeightSet(JSThread *th
NewContainerConstructor(thread, funcPrototype, ContainersLightWeightSet::LightWeightSetConstructor,
"LightWeightSet", FuncLength::ZERO));
JSHandle<JSFunction>::Cast(lightweightSetFunction)->SetFunctionPrototype(thread, lightweightSetInstanceClass.
GetTaggedValue());
GetTaggedValue());
// "constructor" property on the prototype
JSHandle<JSTaggedValue> constructorKey = globalConst->GetHandledConstructorString();
JSObject::SetProperty(thread, JSHandle<JSTaggedValue>(funcPrototype), constructorKey, lightweightSetFunction);

View File

@ -52,7 +52,7 @@ bool DateParse::IsIsoDateTime(DateProxy *proxy, DayValue *dayValue)
return false;
}
if (sign.IsSymbol('-')) {
signYear = -signYear;
signYear = -signYear;
}
dayValue->SetData(signYear);
} else if (proxy->GetDate().IsFourDecimalDigit()) {
@ -366,7 +366,8 @@ bool DateParse::TimeValue::SetTimeValue(int *time)
}
return false;
}
if (!HourIsValid(time[HOUR]) || !MinuteIsValid(time[MIN]) || !SecondIsValid(time[SEC]) || !MilliSecondIsValid(time[MS])) {
if (!HourIsValid(time[HOUR]) || !MinuteIsValid(time[MIN]) || !SecondIsValid(time[SEC]) ||
!MilliSecondIsValid(time[MS])) {
return false;
}
return true;
@ -384,6 +385,7 @@ bool DateParse::DayValue::SetDayValue(int *time)
data_[i] = 1;
}
if (month_ == INT_MAX) {
// 2:index of year
if (is_iso_flag_ || (IsFull() && DayIsValid(data_[2]) && !MonthIsValid(data_[0]))) {
year = data_[YEAR];
mon = data_[MONTH];

View File

@ -35,7 +35,7 @@ private:
public:
explicit StringReader(const char *str, int length) : data_(str), length_(length)
{
NextChar();
NextChar();
}
void NextChar()
@ -142,7 +142,7 @@ private:
char value_;
};
enum DateValueType : int8_t{
enum DateValueType : int8_t {
DATE_INVALID,
DATE_UNKNOWN,
DATE_NUMBER,
@ -489,11 +489,13 @@ private:
month_ = month;
}
static bool MonthIsValid(int n) {
static bool MonthIsValid(int n)
{
return IsBetween(n, 1, MOUTH_PER_YEAR);
}
static bool DayIsValid(int n) {
static bool DayIsValid(int n)
{
return IsBetween(n, 1, JSDate::MAX_DAYS_MONTH);
}

View File

@ -14,5 +14,5 @@
*/
function foo() {
print("base foo")
print('base foo');
}

View File

@ -14,5 +14,5 @@
*/
function foo() {
print("patch foo")
print('patch foo');
}

View File

@ -549,8 +549,8 @@ void JSNumberFormat::InitializeNumberFormat(JSThread *thread, const JSHandle<JSN
// 16. Let style be numberFormat.[[Style]].
StyleOption style = numberFormat->GetStyle();
if (style == StyleOption::PERCENT) {
icuNumberFormatter = icuNumberFormatter.unit(icu::MeasureUnit::getPercent())
.scale(icu::number::Scale::powerOfTen(2)); // means 10^2
icuNumberFormatter = icuNumberFormatter.unit(icu::MeasureUnit::getPercent()).
scale(icu::number::Scale::powerOfTen(2)); // means 10^2
}
// 19. Let notation be ? GetOption(

View File

@ -1832,7 +1832,7 @@ JSHandle<JSTaggedValue> JSObject::SpeciesConstructor(JSThread *thread, const JSH
// Let C be Get(O, "constructor").
JSHandle<JSTaggedValue> contructorKey = globalConst->GetHandledConstructorString();
JSHandle<JSTaggedValue> objConstructor(JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(obj),
contructorKey).GetValue());
contructorKey).GetValue());
// ReturnIfAbrupt(C).
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
// If C is undefined, return defaultConstructor.

View File

@ -85,7 +85,7 @@ JSTaggedValue JSRegExpIterator::Next(EcmaRuntimeCallInfo *argv)
if (EcmaStringAccessor(matchStr).GetLength() == 0) {
JSHandle<JSTaggedValue> lastIndexString(globalConstants->GetHandledLastIndexString());
JSHandle<JSTaggedValue> getLastIndex(JSObject::GetProperty(thread, regexHandle,
lastIndexString).GetValue());
lastIndexString).GetValue());
JSTaggedNumber thisIndex = JSTaggedValue::ToLength(thread, getLastIndex);
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
uint32_t nextIndex = BuiltinsRegExp::AdvanceStringIndex(inputStr, thisIndex.ToUint32(),

View File

@ -437,7 +437,7 @@ void FormatToArray(JSThread *thread, const JSHandle<JSArray> &array,
// Add Group type element
resString = intl::LocaleHelper::UStringToString(thread, formattedText, it->first, it->second);
typeString.Update(JSLocale::GetNumberFieldType(thread, taggedValue.GetTaggedValue(),
UNUM_GROUPING_SEPARATOR_FIELD).GetTaggedValue());
UNUM_GROUPING_SEPARATOR_FIELD).GetTaggedValue());
record =
JSLocale::PutElement(thread, index++, array, typeString, JSHandle<JSTaggedValue>::Cast(resString));
RETURN_IF_ABRUPT_COMPLETION(thread);

View File

@ -35,7 +35,7 @@ JSPandaFile::JSPandaFile(const panda_file::File *pf, const CString &descriptor)
isNewVersion_ = pf_->GetHeader()->version > OLD_VERSION;
if (!loadedFirstPandaFile && !isBundlePack_) {
// Tag the first merged abc to use constant string. The lifetime of this first panda file is the same
// as the vm. And make sure the first pandafile is the same at the compile time and runtime.
// as the vm. And make sure the first pandafile is the same at the compile time and runtime.
isFirstPandafile_ = true;
loadedFirstPandaFile = true;
}

View File

@ -14,5 +14,5 @@
*/
function foo() {
print("base foo()")
print('base foo()');
}

View File

@ -14,5 +14,5 @@
*/
function foo() {
print("patch foo()")
print('patch foo()');
}

View File

@ -623,9 +623,8 @@ void Heap::RecomputeLimits()
OPTIONAL_LOG(ecmaVm_, INFO) << "RecomputeLimits oldSpaceAllocLimit_: " << newOldSpaceLimit
<< " globalSpaceAllocLimit_: " << globalSpaceAllocLimit_
<< " globalSpaceNativeLimit_:" << globalSpaceNativeLimit_;
// 2 means half
if ((oldSpace_->GetHeapObjectSize() * 1.0 / SHRINK_OBJECT_SURVIVAL_RATE) < oldSpace_->GetCommittedSize() &&
(oldSpace_->GetCommittedSize() / 2) > newOldSpaceLimit) {
(oldSpace_->GetCommittedSize() / 2) > newOldSpaceLimit) { // 2: means half
OPTIONAL_LOG(ecmaVm_, INFO) << " Old space heap object size is too much lower than committed size"
<< " heapObjectSize: "<< oldSpace_->GetHeapObjectSize()
<< " Committed Size: " << oldSpace_->GetCommittedSize();
@ -808,7 +807,6 @@ void Heap::TryTriggerConcurrentMarking()
double newSpaceAllocSpeed = memController_->GetNewSpaceAllocationThroughputPerMS();
double newSpaceConcurrentMarkSpeed = memController_->GetNewSpaceConcurrentMarkSpeedPerMS();
if (newSpaceConcurrentMarkSpeed == 0 || newSpaceAllocSpeed == 0) {
auto &config = ecmaVm_->GetEcmaParamConfiguration();
if (activeSemiSpace_->GetCommittedSize() >= config.GetSemiSpaceTriggerConcurrentMark()) {

View File

@ -367,7 +367,7 @@ JSHandle<JSTaggedValue> ModuleManager::HostResolveImportedModuleWithMerge(const
RETURN_HANDLE_IF_ABRUPT_COMPLETION(JSTaggedValue, thread);
JSHandle<NameDictionary> handleDict(thread, resolvedModules_);
resolvedModules_ = NameDictionary::Put(thread, handleDict, JSHandle<JSTaggedValue>(recordNameHandle),
moduleRecord, PropertyAttributes::Default()).GetTaggedValue();
moduleRecord, PropertyAttributes::Default()).GetTaggedValue();
return moduleRecord;
}

View File

@ -14,17 +14,17 @@
*/
class Test {
constructor(a) {
this.a = a;
}
constructor(a) {
this.a = a;
}
fun1() {
print('hello world');
}
fun1() {
print('hello world');
}
fun2() {
print('hello world1');
}
fun2() {
print('hello world1');
}
}
var test = new Test('555');
let test = new Test('555');

View File

@ -13,8 +13,8 @@
* limitations under the License.
*/
export var a = 123;
export var b = 321;
export let a = 123;
export let b = 321;
export {module} from './module_test_module_test_module.js';
var c = a * b;
let c = a * b;

View File

@ -13,17 +13,17 @@
* limitations under the License.
*/
import {a, b, module} from './module_test_module_test_B.js'
import * as obj from './module_test_module_test_module.js'
import {a, b, module} from './module_test_module_test_B.js';
import * as obj from './module_test_module_test_module.js';
var c = new obj.Test(obj.module);
let c = new obj.Test(obj.module);
if (module == obj.module) {
print(module);
print(module);
}
if (a > b) {
print('a > b');
print('a > b');
}
export {b}
export {b};

View File

@ -14,17 +14,17 @@
*/
export class Test {
constructor(a) {
this.a = a;
}
constructor(a) {
this.a = a;
}
fun1() {
print('hello world');
}
fun1() {
print('hello world');
}
fun2() {
print('hello world1');
}
fun2() {
print('hello world1');
}
}
export var module = 0;
export let module = 0;

View File

@ -13,6 +13,6 @@
* limitations under the License.
*/
import {Test} from './module_test_module_test_module.js'
import {Test} from './module_test_module_test_module.js';
var test = new Test('555');
let test = new Test('555');

View File

@ -417,9 +417,7 @@ JSTaggedValue ObjectFastOperator::FastGetPropertyByName(JSThread *thread, JSTagg
JSTaggedValue result = ObjectFastOperator::GetPropertyByName(thread, receiver, key);
if (result.IsHole()) {
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(thread, receiver),
JSHandle<JSTaggedValue>(thread, key))
.GetValue()
.GetTaggedValue();
JSHandle<JSTaggedValue>(thread, key)).GetValue().GetTaggedValue();
}
return result;
}
@ -430,9 +428,7 @@ JSTaggedValue ObjectFastOperator::FastGetPropertyByValue(JSThread *thread, JSTag
JSTaggedValue result = ObjectFastOperator::GetPropertyByValue(thread, receiver, key);
if (result.IsHole()) {
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(thread, receiver),
JSHandle<JSTaggedValue>(thread, key))
.GetValue()
.GetTaggedValue();
JSHandle<JSTaggedValue>(thread, key)).GetValue().GetTaggedValue();
}
return result;
}
@ -443,9 +439,8 @@ JSTaggedValue ObjectFastOperator::FastGetPropertyByIndex(JSThread *thread, JSTag
INTERPRETER_TRACE(thread, FastGetPropertyByIndex);
JSTaggedValue result = ObjectFastOperator::GetPropertyByIndex(thread, receiver, index);
if (result.IsHole() && !UseHole) {
return JSTaggedValue::GetProperty(thread, JSHandle<JSTaggedValue>(thread, receiver), index)
.GetValue()
.GetTaggedValue();
return JSTaggedValue::GetProperty(thread,
JSHandle<JSTaggedValue>(thread, receiver), index).GetValue().GetTaggedValue();
}
return result;
}

View File

@ -905,9 +905,9 @@ DEF_RUNTIME_STUBS(CreateClassWithIHClass)
JSHandle<JSHClass> ihclass = GetHArg<JSHClass>(argv, argc, 5); // 5: means the fifth parameter
JSHandle<JSTaggedValue> module = GetHArg<JSTaggedValue>(argv, argc, 6); // 6: means the sixth parameter
return RuntimeCreateClassWithIHClass(thread, base, lexenv, constpool,
static_cast<uint16_t>(methodId.GetInt()),
static_cast<uint16_t>(literalId.GetInt()),
ihclass, module).GetRawData();
static_cast<uint16_t>(methodId.GetInt()),
static_cast<uint16_t>(literalId.GetInt()),
ihclass, module).GetRawData();
}
DEF_RUNTIME_STUBS(SetClassConstructorLength)
@ -1578,7 +1578,7 @@ DEF_RUNTIME_STUBS(NewObjRange)
JSTaggedValue firstArgIdx = GetArg(argv, argc, 2); // 2: means the second parameter
JSTaggedValue length = GetArg(argv, argc, 3); // 3: means the third parameter
return RuntimeNewObjRange(thread, func, newTarget, static_cast<uint16_t>(firstArgIdx.GetInt()),
static_cast<uint16_t>(length.GetInt())).GetRawData();
static_cast<uint16_t>(length.GetInt())).GetRawData();
}
DEF_RUNTIME_STUBS(DefineFunc)

View File

@ -468,11 +468,14 @@ HWTEST_F_L0(ConstantStringTest, StringsAreEqualUtf16_001)
JSHandle<EcmaString> handleEcmaStrU8No3(thread,
EcmaStringAccessor::CreateConstantString(ecmaVMPtr, &arrayU8No3[0], lengthEcmaStrU8No3, true));
EXPECT_TRUE(
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No1, &arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No1,
&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
EXPECT_FALSE(
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No2, &arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No2,
&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
EXPECT_FALSE(
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No3, &arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
EcmaStringAccessor::StringsAreEqualUtf16(*handleEcmaStrU8No3,
&arrayU16NotCompNo1[0], lengthEcmaStrU16NotCompNo1));
}
/*

View File

@ -71,7 +71,7 @@ protected:
JSHandle<JSTaggedValue> globalObject = env->GetJSGlobalObject();
JSHandle<JSTaggedValue> key(factory->NewFromASCII("ArkPrivate"));
JSHandle<JSTaggedValue> value = JSObject::GetProperty(thread,
JSHandle<JSTaggedValue>(globalObject), key).GetValue();
JSHandle<JSTaggedValue>(globalObject), key).GetValue();
auto objCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6);
objCallInfo->SetFunction(JSTaggedValue::Undefined());

View File

@ -71,7 +71,7 @@ protected:
JSHandle<JSTaggedValue> globalObject = env->GetJSGlobalObject();
JSHandle<JSTaggedValue> key(factory->NewFromASCII("ArkPrivate"));
JSHandle<JSTaggedValue> value = JSObject::GetProperty(thread,
JSHandle<JSTaggedValue>(globalObject), key).GetValue();
JSHandle<JSTaggedValue>(globalObject), key).GetValue();
auto objCallInfo = TestHelper::CreateEcmaRuntimeCallInfo(thread, JSTaggedValue::Undefined(), 6);
objCallInfo->SetFunction(JSTaggedValue::Undefined());

View File

@ -88,11 +88,11 @@ namespace OHOS {
return;
}
double input = 0;
const double MAXBYTELEN = 8;
if (size > MAXBYTELEN) {
size = MAXBYTELEN;
const double MAX_BYTE_LEN = 8;
if (size > MAX_BYTE_LEN) {
size = MAX_BYTE_LEN;
}
if (memcpy_s(&input, MAXBYTELEN, data, size) != 0) {
if (memcpy_s(&input, MAX_BYTE_LEN, data, size) != 0) {
std::cout << "memcpy_s failed!";
UNREACHABLE();
}