修改代码告警

Signed-off-by: hwx1163501 <hanjing35@huawei.com>
issue:https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I7KT7O
This commit is contained in:
hwx1163501 2023-07-13 10:28:47 +08:00
parent 89a9f8292b
commit 75a63d1ea5
9 changed files with 68 additions and 69 deletions

View File

@ -578,7 +578,7 @@ void TSHCRLowering::LowerTypedLdObjByNameForClassOrObject(GateRef gate, GateRef
return;
}
hclassIndex = tsManager_->GetConstructorHClassIndexByClassGateType(receiverType);
} else if (tsManager_->IsObjectTypeKind(receiverType)){
} else if (tsManager_->IsObjectTypeKind(receiverType)) {
hclassIndex = tsManager_->GetHClassIndexByObjectType(receiverType);
}
if (hclassIndex == -1) { // slowpath
@ -672,7 +672,6 @@ void TSHCRLowering::LowerTypedLdObjByName(GateRef gate)
GateRef receiver = acc_.GetValueIn(gate, 2); // 2: acc or this object
GateType receiverType = acc_.GetGateType(receiver);
receiverType = tsManager_->TryNarrowUnionType(receiverType);
if (TryLowerTypedLdObjByNameForArray(gate, receiver, prop)) {
DeleteConstDataIfNoUser(constData);
return;
@ -699,7 +698,7 @@ void TSHCRLowering::LowerTypedStObjByNameForClassOrObject(GateRef gate, GateRef
return;
}
hclassIndex = tsManager_->GetConstructorHClassIndexByClassGateType(receiverType);
} else if (tsManager_->IsObjectTypeKind(receiverType)){
} else if (tsManager_->IsObjectTypeKind(receiverType)) {
hclassIndex = tsManager_->GetHClassIndexByObjectType(receiverType);
}
if (hclassIndex == -1) { // slowpath

View File

@ -35,8 +35,7 @@ void PGOTypeInfer::Run()
}
struct CollectedType {
CollectedType(Chunk *chunk) :
classTypes(chunk), classInstanceTypes(chunk), otherTypes(chunk) {}
explicit CollectedType(Chunk *chunk) : classTypes(chunk), classInstanceTypes(chunk), otherTypes(chunk) {}
bool AllInSameKind() const
{

View File

@ -115,7 +115,7 @@ void TypeRecorder::CreateTypesForPGO(const JSPandaFile *jsPandaFile, const Metho
uint32_t methodOffset = methodLiteral->GetMethodId().GetOffset();
PGOBCInfo *bcInfo = tsManager->GetBytecodeInfoCollector()->GetPGOBCInfo();
bcInfo->IterateInfoAndType(methodOffset, [this, &typeParser, methodOffset, &recordName, &jsPandaFile]
(const PGOBCInfo::Type type, const uint32_t bcIdx, const uint32_t cpIdx){
(const PGOBCInfo::Type type, const uint32_t bcIdx, const uint32_t cpIdx) {
GlobalTSTypeRef gt = typeParser.CreatePGOGT(jsPandaFile, recordName, methodOffset, cpIdx, type);
if (TypeNeedFilter(gt)) {
return;

View File

@ -64,7 +64,7 @@ using PGOMethodId = EntityId;
|--------HEADER_SIZE(4)
|------------{ headerSize, from MAGIC to SECTION_NUMBER }
|--------ENDIAN_TAG(4)
|------------{ ENDIAN_TAG }
|------------{ ENDIAN_TAG }
|--------SECTION_NUMBER(4)
|------------{ 3 }
|--------PANDA_FILE_INFO_SECTION_INFO(12)

View File

@ -14,20 +14,20 @@
*/
class Test {
x
y
constructor(x, y) {
this.x = x;
this.y = y;
}
x;
y;
constructor(x, y) {
this.x = x;
this.y = y;
}
}
function foo(p)
{
return p.x
return p.x;
}
let a = new Test(1, 23)
let a = new Test(1, 23);
for (let i = 0; i < 1000000; i++) {
foo(a)
foo(a);
}

View File

@ -14,38 +14,38 @@
*/
class Body {
constructor(x, y) {
this.x = x;
this.y = y;
}
constructor(x, y) {
this.x = x;
this.y = y;
}
}
class Foot extends Body {
constructor(x, y, u, v) {
super(x, y)
this.u = u
this.v = v
}
constructor(x, y, u, v) {
super(x, y);
this.u = u;
this.v = v;
}
}
class Arm extends Body {
constructor(x, y, t) {
super(x, y)
this.t = t
}
constructor(x, y, t) {
super(x, y);
this.t = t;
}
}
function foo(p)
{
return p.x
return p.x;
}
let a = new Body(1, 23)
let b = new Foot(3, 3.2, 2, 32.3)
let c = new Arm(1.3, 23.2, 23)
let a = new Body(1, 23);
let b = new Foot(3, 3.2, 2, 32.3);
let c = new Arm(1.3, 23.2, 23);
for (let i = 0; i < 1000000; i++) {
foo(a)
foo(b)
foo(c)
foo(a);
foo(b);
foo(c);
}

View File

@ -14,56 +14,56 @@
*/
class Body {
constructor(x, vx, mass) {
constructor(x, vx, mass) {
this.x = x;
this.vx = vx;
this.mass = mass;
}
}
}
function advance(bodies, dt) {
const sqrt = Math.sqrt;
const size = bodies.length;
const sqrt = Math.sqrt;
const size = bodies.length;
for (let i = 0; i < size; i++) {
const bodyi = bodies[i];
let vxi = bodyi.vx;
const xi = bodyi.x;
const massi = bodyi.mass;
for (let i = 0; i < size; i++) {
const bodyi = bodies[i];
let vxi = bodyi.vx;
const xi = bodyi.x;
const massi = bodyi.mass;
for (let j = i + 1; j < size; j++) {
const bodyj = bodies[j];
const dx = xi - bodyj.x;
for (let j = i + 1; j < size; j++) {
const bodyj = bodies[j];
const dx = xi - bodyj.x;
const d2 = dx * dx;
const mag = dt / (d2 * sqrt(d2));
const massiMag = massi * mag;
const d2 = dx * dx;
const mag = dt / (d2 * sqrt(d2));
const massiMag = massi * mag;
const massj = bodyj.mass;
const massjMag = massj * mag;
vxi -= dx * massjMag;
const massj = bodyj.mass;
const massjMag = massj * mag;
vxi -= dx * massjMag;
bodyj.vx += dx * massiMag;
}
bodyi.vx = vxi;
bodyj.vx += dx * massiMag;
}
bodyi.vx = vxi;
bodyi.x += dt * vxi;
}
bodyi.x += dt * vxi;
}
}
const PI = Math.PI;
const SOLAR_MASS = 4 * PI * PI;
function Sun() {
return new Body(0.0, 0.0, SOLAR_MASS);
function sun() {
return new Body(0.0, 0.0, SOLAR_MASS);
}
function Sun1() {
return new Body(1.2, 3.1, PI);
function sun1() {
return new Body(1.2, 3.1, PI);
}
const bodies = [Sun(), Sun1()];
const bodies = [sun(), sun1()];
const n = 100000;
for (let i = 0; i < n; i++) {
advance(bodies, 0.01);
advance(bodies, 0.01);
}

View File

@ -464,7 +464,8 @@ public:
return pgoGTInfo_.methodCpIdxGTMap.find(key) != pgoGTInfo_.methodCpIdxGTMap.end();
}
inline GlobalTSTypeRef GetPGOGT(uint32_t methodOffset, uint32_t cpIdx) {
inline GlobalTSTypeRef GetPGOGT(uint32_t methodOffset, uint32_t cpIdx)
{
auto key = std::make_pair(methodOffset, cpIdx);
return pgoGTInfo_.methodCpIdxGTMap.at(key);
}

View File

@ -823,9 +823,9 @@ GlobalTSTypeRef TSTypeParser::ParsePGOType(const JSPandaFile *jsPandaFile, const
}
JSHandle<JSTaggedValue> TSTypeParser::ParseNonImportPGOType(GlobalTSTypeRef gt, const CString &recordName,
uint32_t cpIdx, kungfu::PGOBCInfo::Type type)
uint32_t cpIdx, kungfu::PGOBCInfo::Type type)
{
switch(type) {
switch (type) {
case kungfu::PGOBCInfo::Type::OBJ_LITERAL: {
return JSHandle<JSTaggedValue>(ParseObjectPGOType(gt, recordName, cpIdx));
}
@ -839,7 +839,7 @@ JSHandle<TSObjectType> TSTypeParser::ParseObjectPGOType(GlobalTSTypeRef gt, cons
{
JSHandle<ConstantPool> constpoolHandle(tsManager_->GetConstantPool());
JSTaggedValue obj = ConstantPool::GetLiteralFromCache<ConstPoolType::OBJECT_LITERAL>(
thread_, constpoolHandle.GetTaggedValue(), cpIdx, recordName);
thread_, constpoolHandle.GetTaggedValue(), cpIdx, recordName);
JSHandle<JSObject> objHandle(thread_, obj);
JSHandle<JSHClass> oldHClass(thread_, objHandle->GetClass());
JSHandle<JSHClass> hclass = JSHClass::Clone(thread_, oldHClass);