From 595aaa2b5d93dc41c17cc97e40fbaa2290ec0f67 Mon Sep 17 00:00:00 2001 From: Alfred Huang Date: Fri, 8 Jan 2021 11:22:26 -0800 Subject: [PATCH 01/33] Dwarf enhancment: Support struct bitfield dwarf emission --- mapleall/maple_be/src/cg/emit_dbg.cpp | 29 ++++++++++++++++--------- mapleall/maple_ir/include/debug_info.h | 1 + mapleall/maple_ir/src/debug_info.cpp | 30 ++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 12 deletions(-) diff --git a/mapleall/maple_be/src/cg/emit_dbg.cpp b/mapleall/maple_be/src/cg/emit_dbg.cpp index 98cce27..68e8f24 100644 --- a/mapleall/maple_be/src/cg/emit_dbg.cpp +++ b/mapleall/maple_be/src/cg/emit_dbg.cpp @@ -493,11 +493,13 @@ void Emitter::EmitDIDebugInfoSection(DebugInfo *mirdi) { string sfile, spath; if (diae->tag_ == DW_TAG_compile_unit && sfile.empty()) { // get full source path from fileMap[2] - string srcPath = emitter->fileMap[2]; - size_t t = srcPath.rfind("/"); - CG_ASSERT(t != string::npos, ""); - sfile = srcPath.substr(t+1); - spath = srcPath.substr(0, t-1); + if (emitter->fileMap.size() > 2) { // have src file map + string srcPath = emitter->fileMap[2]; + size_t t = srcPath.rfind("/"); + CG_ASSERT(t != string::npos, ""); + sfile = srcPath.substr(t+1); + spath = srcPath.substr(0, t-1); + } } for (int i = 0; i < diae->attrpairs_.size(); i += 2) { @@ -686,11 +688,18 @@ void Emitter::SetupDBGInfo(DebugInfo *mirdi) { MIRStructType *sty = static_cast(mty); CHECK_FATAL(sty != nullptr, "pointer cast failed"); CHECK_FATAL(sty->tyIdx.GetIdx() < g->becommon->struct_fieldcount_table.size(), ""); - int32_t myEnd = g->becommon->struct_fieldcount_table[sty->tyIdx.GetIdx()]; - int32_t myBegin = myEnd - sty->fields.size() + 1; - for (int i = myBegin; i <= myEnd; i++) { - int offset = g->becommon->GetFieldOffset(sty, i).first; - GStrIdx fldName = sty->fields[i - myBegin].first; + int embeddedIDs = 0; + MIRStructType *prevSubstruct = nullptr; + for (int i = 0; i < sty->fields.size(); i++) { + TyIdx fieldtyidx = sty->fields[i].second.first; + MIRType *fieldty = GlobalTables::GetTypeTable().GetTypeFromTyIdx(fieldtyidx); + if (prevSubstruct) { + embeddedIDs += g->becommon->struct_fieldcount_table[prevSubstruct->tyIdx.GetIdx()]; + } + prevSubstruct = fieldty->EmbeddedStructType(); + FieldID fieldID = i + embeddedIDs + 1; + int offset = g->becommon->GetFieldOffset(sty, fieldID).first; + GStrIdx fldName = sty->fields[i].first; DBGDie *cdie = LFindChildDieWithName(die, DW_TAG_member, fldName); CHECK_FATAL(cdie != nullptr, "cdie is null in Emitter::SetupDBGInfo"); DBGDieAttr *mloc = LFindDieAttr(cdie, DW_AT_data_member_location); diff --git a/mapleall/maple_ir/include/debug_info.h b/mapleall/maple_ir/include/debug_info.h index 428f28a..285f3e1 100644 --- a/mapleall/maple_ir/include/debug_info.h +++ b/mapleall/maple_ir/include/debug_info.h @@ -394,6 +394,7 @@ class DebugInfo { DBGDie *CreateVarDie(MIRSymbol *sym, uint32 lnum); DBGDie *CreateFormalParaDie(MIRFunction *func, MIRType *type, GStrIdx nameidx, uint32 lnum); DBGDie *CreateFieldDie(maple::FieldPair pair, uint32 lnum); + DBGDie *CreateBitfieldDie(MIRBitfieldType *type, GStrIdx idx); DBGDie *CreateStructTypeDie(GStrIdx strIdx, const MIRStructType *type, bool update = false); DBGDie *CreateClassTypeDie(GStrIdx strIdx, const MIRClassType *type); DBGDie *CreateInterfaceTypeDie(GStrIdx strIdx, const MIRInterfaceType *type); diff --git a/mapleall/maple_ir/src/debug_info.cpp b/mapleall/maple_ir/src/debug_info.cpp index e19645c..2d8022a 100644 --- a/mapleall/maple_ir/src/debug_info.cpp +++ b/mapleall/maple_ir/src/debug_info.cpp @@ -763,6 +763,26 @@ DBGDie *DebugInfo::CreateFieldDie(maple::FieldPair pair, uint32 lnum) { return die; } +DBGDie *DebugInfo::CreateBitfieldDie(MIRBitfieldType *type, GStrIdx sidx) { + DBGDie *die = mod_->memPool->New(mod_, DW_TAG_member); + + die->AddAttr(DW_AT_name, DW_FORM_strp, sidx.GetIdx()); + die->AddAttr(DW_AT_decl_file, DW_FORM_data4, mplsrcidx_.GetIdx()); + die->AddAttr(DW_AT_decl_line, DW_FORM_data4, 0); + + MIRType *ty = GlobalTables::GetTypeTable().typeTable[type->primType]; + (void)GetOrCreateTypeDie(ty); + die->AddAttr(DW_AT_type, DW_FORM_ref4, ty->tyIdx.GetIdx()); + + die->AddAttr(DW_AT_byte_size, DW_FORM_data4, GetPrimTypeSize(type->primType)); + die->AddAttr(DW_AT_bit_size, DW_FORM_data4, type->fieldSize); + die->AddAttr(DW_AT_bit_offset, DW_FORM_data4, GetPrimTypeSize(type->primType)*8-type->fieldSize); + + die->AddAttr(DW_AT_data_member_location, DW_FORM_data4, 0); + + return die; +} + DBGDie *DebugInfo::GetOrCreateStructTypeDie(const MIRType *type) { ASSERT(type, "null struture type"); GStrIdx strIdx = type->nameStrIdx; @@ -835,9 +855,15 @@ DBGDie *DebugInfo::CreateStructTypeDie(GStrIdx strIdx, const MIRStructType *stru // fields for (int64 i = 0; i < structtype->fields.size(); i++) { + MIRType *ety = structtype->GetElemType(i); FieldPair fp = structtype->fields[i]; - DBGDie *fdie = CreateFieldDie(fp, 0); - die->AddSubVec(fdie); + if (MIRBitfieldType *bfty = dynamic_cast(ety)) { + DBGDie *bfdie = CreateBitfieldDie(bfty, fp.first); + die->AddSubVec(bfdie); + } else { + DBGDie *fdie = CreateFieldDie(fp, 0); + die->AddSubVec(fdie); + } } // parentFields -- Gitee From 8cb33af07d42598f394384b13cf583a924628cf3 Mon Sep 17 00:00:00 2001 From: Alfred Huang Date: Sun, 10 Jan 2021 22:12:35 -0800 Subject: [PATCH 02/33] Dwarf enhancement: Added Debug Info Enry for pointer to function --- mapleall/maple_ir/include/debug_info.h | 1 + mapleall/maple_ir/src/debug_info.cpp | 35 +++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/debug_info.h b/mapleall/maple_ir/include/debug_info.h index 285f3e1..56cbea7 100644 --- a/mapleall/maple_ir/include/debug_info.h +++ b/mapleall/maple_ir/include/debug_info.h @@ -398,6 +398,7 @@ class DebugInfo { DBGDie *CreateStructTypeDie(GStrIdx strIdx, const MIRStructType *type, bool update = false); DBGDie *CreateClassTypeDie(GStrIdx strIdx, const MIRClassType *type); DBGDie *CreateInterfaceTypeDie(GStrIdx strIdx, const MIRInterfaceType *type); + DBGDie *CreatePointedFuncTypeDie(MIRFuncType *func); DBGDie *GetOrCreateLabelDie(LabelIdx labid); DBGDie *GetOrCreateTypeAttrDie(MIRSymbol *sym); diff --git a/mapleall/maple_ir/src/debug_info.cpp b/mapleall/maple_ir/src/debug_info.cpp index 2d8022a..fa24b2f 100644 --- a/mapleall/maple_ir/src/debug_info.cpp +++ b/mapleall/maple_ir/src/debug_info.cpp @@ -603,6 +603,28 @@ DBGDie *DebugInfo::GetOrCreatePrimTypeDie(PrimType pty) { return die; } +DBGDie *DebugInfo::CreatePointedFuncTypeDie(MIRFuncType *func) { + DBGDie *die = mod_->memPool->New(mod_, DW_TAG_subroutine_type); + + die->AddAttr(DW_AT_prototyped, DW_FORM_data4, (int)(func->paramTypeList.size()>0)); + MIRType *rtype = GlobalTables::GetTypeTable().GetTypeFromTyIdx(func->retTyIdx); + (void)GetOrCreateTypeDie(rtype); + die->AddAttr(DW_AT_type, DW_FORM_ref4, func->retTyIdx.GetIdx()); + + cu_->AddSubVec(die); + + for (int i = 0; i < func->paramTypeList.size(); i++) { + DBGDie *paramdie = mod_->memPool->New(mod_, DW_TAG_formal_parameter); + MIRType *ptype = GlobalTables::GetTypeTable().GetTypeFromTyIdx(func->paramTypeList[i]); + (void)GetOrCreateTypeDie(ptype); + paramdie->AddAttr(DW_AT_type, DW_FORM_ref4, func->paramTypeList[i].GetIdx()); + die->AddSubVec(paramdie); + } + + tyidx_dieid_map_[func->tyIdx.GetIdx()] = die->id; + return die; +} + DBGDie *DebugInfo::GetOrCreateTypeDie(MIRType *type) { if (!type) { return nullptr; @@ -632,6 +654,11 @@ DBGDie *DebugInfo::GetOrCreateTypeDie(MIRType *type) { die = GetOrCreatePointTypeDie(ptype); break; } + case kTypeFunction: { + MIRFuncType *ftype = static_cast(type); + die = CreatePointedFuncTypeDie(ftype); + break; + } case kTypeArray: case kTypeFArray: case kTypeJArray: { @@ -668,9 +695,15 @@ DBGDie *DebugInfo::GetOrCreatePointTypeDie(const MIRPtrType *ptrtype) { MIRType *type = ptrtype->GetPointedType(); // for <* void> - if (type && type->primType == PTY_void) { + if (type && + (type->primType == PTY_void || type->typeKind == kTypeFunction)) { DBGDie *die = mod_->memPool->New(mod_, DW_TAG_pointer_type); die->AddAttr(DW_AT_byte_size, DW_FORM_data4, 8); + if (type->typeKind == kTypeFunction) { + DBGDie *pdie = GetOrCreateTypeDie(type); + die->AddAttr(DW_AT_type, DW_FORM_ref4, type->tyIdx.GetIdx()); + tyidx_dieid_map_[type->tyIdx.GetIdx()] = pdie->id; + } tyidx_dieid_map_[ptrtype->tyIdx.GetIdx()] = die->id; cu_->AddSubVec(die); return die; -- Gitee From 25ba6e33175516bbc33e6f3e4f48604a2ef3dadc Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Mon, 11 Jan 2021 13:57:29 -0800 Subject: [PATCH 03/33] fix a comparison between unsigned and signed int, that will errored by gcc modified: maple_ir/src/debug_info.cpp --- mapleall/maple_ir/src/debug_info.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_ir/src/debug_info.cpp b/mapleall/maple_ir/src/debug_info.cpp index fa24b2f..b0c93ec 100644 --- a/mapleall/maple_ir/src/debug_info.cpp +++ b/mapleall/maple_ir/src/debug_info.cpp @@ -613,7 +613,7 @@ DBGDie *DebugInfo::CreatePointedFuncTypeDie(MIRFuncType *func) { cu_->AddSubVec(die); - for (int i = 0; i < func->paramTypeList.size(); i++) { + for (uint32 i = 0; i < func->paramTypeList.size(); i++) { DBGDie *paramdie = mod_->memPool->New(mod_, DW_TAG_formal_parameter); MIRType *ptype = GlobalTables::GetTypeTable().GetTypeFromTyIdx(func->paramTypeList[i]); (void)GetOrCreateTypeDie(ptype); -- Gitee From a7b32923e27c0425d6171ce0b6574863fdfd1c89 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Mon, 11 Jan 2021 19:00:39 -0500 Subject: [PATCH 04/33] add setup and resetup targets: "make resetup" to reset tools --- Makefile | 8 ++++++++ README.md | 3 +-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ba140ce..45a511d 100644 --- a/Makefile +++ b/Makefile @@ -86,6 +86,14 @@ install: mapleall mkdir -p ${MAPLE_EXECUTE_BIN}; \ cp -p ${OUTPUT_BIN_DIR}/* ${MAPLE_EXECUTE_BIN}) +.PHONY: setup +setup: + (cd tools; ./setup_tools.sh) + +.PHONY: resetup +resetup: + (cd tools; rm -rf dwsrf gn ninja open64_prebuilt; ./setup_tools.sh) + .PHONY: clean clean: @rm -rf out/bin/${MAPLE_BUILD_TYPE} out/${MAPLE_BUILD_TYPE} diff --git a/README.md b/README.md index d05b41f..4a16412 100644 --- a/README.md +++ b/README.md @@ -44,8 +44,7 @@ The directory structure as follows: ### Set up tools 1. `cd $MAPLE_ROOT` -2. `cd tools` -3. `./setup_tools.sh` +2. `make setup` ### Build compiler 1. `cd $MAPLE_ROOT` -- Gitee From c3c72fe5957213da7bb893d797ce45c43ac2ab95 Mon Sep 17 00:00:00 2001 From: Alfred Huang Date: Tue, 12 Jan 2021 16:29:56 -0800 Subject: [PATCH 05/33] Dwarf enhancement: use srcPosition in MIRSymbol for decl_file/line/column --- mapleall/maple_be/src/cg/emit_dbg.cpp | 2 ++ mapleall/maple_ir/include/debug_info.h | 2 +- mapleall/maple_ir/src/debug_info.cpp | 30 +++++++++++++++----------- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/mapleall/maple_be/src/cg/emit_dbg.cpp b/mapleall/maple_be/src/cg/emit_dbg.cpp index 68e8f24..e661b9b 100644 --- a/mapleall/maple_be/src/cg/emit_dbg.cpp +++ b/mapleall/maple_be/src/cg/emit_dbg.cpp @@ -234,6 +234,7 @@ void Emitter::EmitDIFormSpecification(unsigned int dwform) { void Emitter::EmitDIAttrValue(DBGDie *die, DBGDieAttr *attr, dw_at attrName, dw_tag tagName, DebugInfo *di) { MapleVector &attrvec = die->attrvec_; +#if 0 switch (attr->dwattr_) { case DW_AT_decl_file: EmitHexUnsigned(1); // file num, 1 for debugging .mpl @@ -241,6 +242,7 @@ void Emitter::EmitDIAttrValue(DBGDie *die, DBGDieAttr *attr, dw_at attrName, dw_ default: break; } +#endif switch (attr->dwform_) { case DW_FORM_string: { diff --git a/mapleall/maple_ir/include/debug_info.h b/mapleall/maple_ir/include/debug_info.h index 56cbea7..2a674a1 100644 --- a/mapleall/maple_ir/include/debug_info.h +++ b/mapleall/maple_ir/include/debug_info.h @@ -392,7 +392,7 @@ class DebugInfo { DBGDieAttr *CreateAttr(dw_at attr, dw_form form, uint64 val); DBGDie *CreateVarDie(MIRSymbol *sym, uint32 lnum); - DBGDie *CreateFormalParaDie(MIRFunction *func, MIRType *type, GStrIdx nameidx, uint32 lnum); + DBGDie *CreateFormalParaDie(MIRFunction *func, MIRType *type, MIRSymbol *sym); DBGDie *CreateFieldDie(maple::FieldPair pair, uint32 lnum); DBGDie *CreateBitfieldDie(MIRBitfieldType *type, GStrIdx idx); DBGDie *CreateStructTypeDie(GStrIdx strIdx, const MIRStructType *type, bool update = false); diff --git a/mapleall/maple_ir/src/debug_info.cpp b/mapleall/maple_ir/src/debug_info.cpp index b0c93ec..3fe9b53 100644 --- a/mapleall/maple_ir/src/debug_info.cpp +++ b/mapleall/maple_ir/src/debug_info.cpp @@ -391,19 +391,20 @@ LabelIdx DebugInfo::GetLabelIdx(GStrIdx strIdx) { return labidx; } -DBGDie *DebugInfo::CreateFormalParaDie(MIRFunction *func, MIRType *type, GStrIdx nameidx, uint32 lnum) { +DBGDie *DebugInfo::CreateFormalParaDie(MIRFunction *func, MIRType *type, MIRSymbol *sym) { DBGDie *die = mod_->memPool->New(mod_, DW_TAG_formal_parameter); (void)GetOrCreateTypeDie(type); die->AddAttr(DW_AT_type, DW_FORM_ref4, type->tyIdx.GetIdx()); /* var Name */ - if (nameidx.GetIdx()) { - die->AddAttr(DW_AT_name, DW_FORM_strp, nameidx.GetIdx()); - die->AddAttr(DW_AT_decl_file, DW_FORM_data4, mplsrcidx_.GetIdx()); - die->AddAttr(DW_AT_decl_line, DW_FORM_data4, lnum); + if (sym) { + die->AddAttr(DW_AT_name, DW_FORM_strp, sym->nameStrIdx.GetIdx()); + die->AddAttr(DW_AT_decl_file, DW_FORM_data4, sym->srcPosition.Filenum()); + die->AddAttr(DW_AT_decl_line, DW_FORM_data4, sym->srcPosition.Linenum()); + die->AddAttr(DW_AT_decl_column, DW_FORM_data4, sym->srcPosition.Column()); die->AddSimpLocAttr(DW_AT_location, DW_FORM_exprloc, kDbgDefaultVal); - SetLocalDie(func, nameidx, die); + SetLocalDie(func, sym->nameStrIdx, die); } return die; } @@ -461,8 +462,9 @@ DBGDie *DebugInfo::CreateVarDie(MIRSymbol *sym, uint32 lnum) { /* var Name */ die->AddAttr(DW_AT_name, DW_FORM_strp, sym->nameStrIdx.GetIdx()); - die->AddAttr(DW_AT_decl_file, DW_FORM_data4, mplsrcidx_.GetIdx()); - die->AddAttr(DW_AT_decl_line, DW_FORM_data4, lnum); + die->AddAttr(DW_AT_decl_file, DW_FORM_data4, sym->srcPosition.Filenum()); + die->AddAttr(DW_AT_decl_line, DW_FORM_data4, sym->srcPosition.Linenum()); + die->AddAttr(DW_AT_decl_column, DW_FORM_data4, sym->srcPosition.Column()); if (isLocal) { die->AddSimpLocAttr(DW_AT_location, DW_FORM_exprloc, kDbgDefaultVal); @@ -502,9 +504,12 @@ DBGDie *DebugInfo::GetOrCreateFuncDeclDie(MIRFunction *func, uint32 lnum) { die->AddAttr(DW_AT_external, DW_FORM_flag_present, 1); // Function Name + MIRSymbol *sym = GlobalTables::GetGsymTable().GetSymbolFromStIdx(func->stIdx.Idx()); + die->AddAttr(DW_AT_name, DW_FORM_strp, funcnameidx); - die->AddAttr(DW_AT_decl_file, DW_FORM_data4, mplsrcidx_.GetIdx()); - die->AddAttr(DW_AT_decl_line, DW_FORM_data4, lnum); + die->AddAttr(DW_AT_decl_file, DW_FORM_data4, sym->srcPosition.Filenum()); + die->AddAttr(DW_AT_decl_line, DW_FORM_data4, sym->srcPosition.Linenum()); + die->AddAttr(DW_AT_decl_column, DW_FORM_data4, sym->srcPosition.Column()); // Attributes for DW_AT_accessibility uint32 access = 0; @@ -524,10 +529,9 @@ DBGDie *DebugInfo::GetOrCreateFuncDeclDie(MIRFunction *func, uint32 lnum) { PushParentDie(die); // formal parameter - GStrIdx strIdx(0); for (uint32 i = 0; i < func->formalDefVec.size(); i++) { MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(func->formalDefVec[i].formalTyIdx); - DBGDie *param = CreateFormalParaDie(func, type, strIdx, lnum); + DBGDie *param = CreateFormalParaDie(func, type, nullptr); die->AddSubVec(param); } @@ -567,7 +571,7 @@ DBGDie *DebugInfo::GetOrCreateFuncDefDie(MIRFunction *func, uint32 lnum) { // formal parameter for (uint32 i = 0; i < func->formalDefVec.size(); i++) { MIRType *type = GlobalTables::GetTypeTable().GetTypeFromTyIdx(func->formalDefVec[i].formalTyIdx); - DBGDie *pdie = CreateFormalParaDie(func, type, func->formalDefVec[i].formalStrIdx, lnum); + DBGDie *pdie = CreateFormalParaDie(func, type, func->formalDefVec[i].formalSym); die->AddSubVec(pdie); } -- Gitee From 9d6551c63bb53eed9f7c7d9af4eaba6ccdcf3641 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Fri, 15 Jan 2021 13:53:17 -0800 Subject: [PATCH 06/33] add INTRN_JS_ISNAN for JavaScript modified: mapleall/maple_ir/include/js2mpl/jsintrinsic.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 1c42c3d..6306085 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -116,4 +116,5 @@ DEF_MIR_INTRINSIC(JSOP_MORE_ITERATOR,\ __jsop_more_iterator, INTRNISJS, kArgTyU32, kArgTyPtr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_ADDSYSEVENTLISTENER,\ __js_add_sysevent_listener, INTRNISJS, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) - +DEF_MIR_INTRINSIC(JS_ISNAN,\ + __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 800b191c44dab6ddabc8e5ca72154080459635af Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 15 Jan 2021 15:19:53 -0800 Subject: [PATCH 07/33] move new jsintrinsic from jsintrinsic.def to jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 2 -- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 3 +++ 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 6306085..7d5650c 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -116,5 +116,3 @@ DEF_MIR_INTRINSIC(JSOP_MORE_ITERATOR,\ __jsop_more_iterator, INTRNISJS, kArgTyU32, kArgTyPtr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_ADDSYSEVENTLISTENER,\ __js_add_sysevent_listener, INTRNISJS, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_ISNAN,\ - __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index aed9027..8c7a45c 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -32,3 +32,6 @@ DEF_MIR_INTRINSIC(JS_GET_URIERROR_OBJECT,\ __jsobj_get_or_create_uriError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_ASSERTVALUE, __jsop_assert_value, INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_ISNAN,\ + __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) + -- Gitee From 8d9fd1cc4c613505d0e3e856534961373e5fb5c5 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 15 Jan 2021 15:51:18 -0800 Subject: [PATCH 08/33] disable JS_ISNAN for now, let yiming work on it --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index 8c7a45c..010e5a5 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -32,6 +32,6 @@ DEF_MIR_INTRINSIC(JS_GET_URIERROR_OBJECT,\ __jsobj_get_or_create_uriError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_ASSERTVALUE, __jsop_assert_value, INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_ISNAN,\ - __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +// DEF_MIR_INTRINSIC(JS_ISNAN,\ +// __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From ffedb2135f624bc9a7ad03260430f7bb8c388e84 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 15 Jan 2021 14:44:16 -0800 Subject: [PATCH 09/33] fix seg fault due to static member initialization using not yet created global string table these static members of type GStrIdx might be better placed in the string table itself modified: mapleall/maple_ir/include/mir_symbol.h modified: mapleall/maple_ir/src/mir_symbol.cpp --- mapleall/maple_ir/include/mir_symbol.h | 6 ++++-- mapleall/maple_ir/src/mir_symbol.cpp | 26 ++++++++++++++++++++------ 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/mapleall/maple_ir/include/mir_symbol.h b/mapleall/maple_ir/include/mir_symbol.h index 465e5e2..702b1b9 100644 --- a/mapleall/maple_ir/include/mir_symbol.h +++ b/mapleall/maple_ir/include/mir_symbol.h @@ -102,7 +102,7 @@ class MIRSymbol { istmpunused(0), stIdx(0, 0), nameStrIdx(0), - value({ nullptr }) {} + value({ nullptr }) { UpdateStaticMembers(); } MIRSymbol(uint32 idx, uint8 scp) : tyIdx(0), @@ -120,10 +120,12 @@ class MIRSymbol { istmpunused(0), stIdx(scp, idx), nameStrIdx(0), - value({ nullptr }) {} + value({ nullptr }) { UpdateStaticMembers(); } ~MIRSymbol() {} + void UpdateStaticMembers(); + void SetTyIdx(TyIdx tyIdx) { this->tyIdx = tyIdx; } diff --git a/mapleall/maple_ir/src/mir_symbol.cpp b/mapleall/maple_ir/src/mir_symbol.cpp index 8408a00..bbba1d9 100644 --- a/mapleall/maple_ir/src/mir_symbol.cpp +++ b/mapleall/maple_ir/src/mir_symbol.cpp @@ -232,11 +232,25 @@ bool MIRSymbol::IsGctibSym() { // Some symbols are ignored by reference counting as they represent objects not managed by us. These include // string-based exact comparison for "current_vptr", "vtabptr", "itabptr", "funcptr", "env_ptr", "retvar_stubfunc". -GStrIdx MIRSymbol::reflectClassNameIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangClassStr); -GStrIdx MIRSymbol::reflectMethodNameIdx = - GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangReflectMethod); -GStrIdx MIRSymbol::reflectFieldNameIdx = - GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangReflectField); +GStrIdx MIRSymbol::reflectClassNameIdx = GStrIdx(0); +GStrIdx MIRSymbol::reflectMethodNameIdx = GStrIdx(0); +GStrIdx MIRSymbol::reflectFieldNameIdx = GStrIdx(0); + +void MIRSymbol::UpdateStaticMembers() { + if (MIRSymbol::reflectClassNameIdx == GStrIdx(0)) { + MIRSymbol::reflectClassNameIdx = + GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangClassStr); + } + if (MIRSymbol::reflectMethodNameIdx == GStrIdx(0)) { + MIRSymbol::reflectMethodNameIdx = + GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangReflectMethod); + } + if (MIRSymbol::reflectFieldNameIdx == GStrIdx(0)) { + MIRSymbol::reflectFieldNameIdx = + GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(NameMangler::kJavaLangReflectField); + } + return; +} bool MIRSymbol::IgnoreRC() { // is RC needed if (isDeleted || GetAttr(ATTR_rcunowned)) { @@ -268,7 +282,7 @@ bool MIRSymbol::IgnoreRC() { // is RC needed MIRPtrType *ptype = static_cast(type); GStrIdx strIdx = GlobalTables::GetTypeTable().GetTypeFromTyIdx(ptype->pointedTyIdx)->nameStrIdx; // LogInfo::MapleLogger() << globaltable.GetStringFromStrIdx(strIdx) << std::endl; - if (strIdx == reflectClassNameIdx || strIdx == reflectMethodNameIdx || strIdx == reflectFieldNameIdx) { + if (strIdx == MIRSymbol::reflectClassNameIdx || strIdx == MIRSymbol::reflectMethodNameIdx || strIdx == MIRSymbol::reflectFieldNameIdx) { return true; } -- Gitee From de39e8587b1a8eb6bfe973049abb6c3244d715f6 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Mon, 18 Jan 2021 12:08:19 -0800 Subject: [PATCH 10/33] turn on JS_ISNAN intrinsic modified: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index 010e5a5..d688035 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -32,6 +32,6 @@ DEF_MIR_INTRINSIC(JS_GET_URIERROR_OBJECT,\ __jsobj_get_or_create_uriError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_ASSERTVALUE, __jsop_assert_value, INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -// DEF_MIR_INTRINSIC(JS_ISNAN,\ -// __jsop_isnan, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_ISNAN,\ + NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 8e2a8447fe373de6919164b75f8c0de76ec645b0 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Wed, 20 Jan 2021 11:18:39 -0800 Subject: [PATCH 11/33] add Get/CreateLocalDecl APIs without using current function --- mapleall/maple_ir/include/mir_builder.h | 7 +++++ mapleall/maple_ir/src/mir_builder.cpp | 34 +++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/mapleall/maple_ir/include/mir_builder.h b/mapleall/maple_ir/include/mir_builder.h index 66ccf62..36b0f5e 100644 --- a/mapleall/maple_ir/include/mir_builder.h +++ b/mapleall/maple_ir/include/mir_builder.h @@ -147,6 +147,13 @@ class MIRBuilder { } public: + virtual MIRSymbol *GetOrCreateLocalDecl(const string &name, MIRType *type, MIRFunction *func); + virtual MIRSymbol *GetOrCreateLocalDecl(const char *name, MIRType *type, MIRFunction *func); + MIRSymbol *GetLocalDecl(const string &name, MIRFunction *func); + MIRSymbol *GetLocalDecl(const char *name, MIRFunction *func); + MIRSymbol *CreateLocalDecl(const string &name, MIRType *type, MIRFunction *func); + MIRSymbol *CreateLocalDecl(const char *name, MIRType *type, MIRFunction *func); + virtual MIRSymbol *GetOrCreateLocalDecl(const string &name, MIRType *type); virtual MIRSymbol *GetOrCreateLocalDecl(const char *name, MIRType *type); MIRSymbol *GetLocalDecl(const string &name); diff --git a/mapleall/maple_ir/src/mir_builder.cpp b/mapleall/maple_ir/src/mir_builder.cpp index 06b380e..3ad86e7 100644 --- a/mapleall/maple_ir/src/mir_builder.cpp +++ b/mapleall/maple_ir/src/mir_builder.cpp @@ -335,6 +335,40 @@ MIRSymbol *MIRBuilder::CreateSymbol(TyIdx tyIdx, GStrIdx strIdx, MIRSymKind sKin return st; } +MIRSymbol *MIRBuilder::GetLocalDecl(const string &name, MIRFunction *func) { + return GetSymbol(TyIdx(0), GetStringIndex(name), kStVar, kScAuto, kScopeLocal, func); +} + +MIRSymbol *MIRBuilder::GetLocalDecl(const char *name, MIRFunction *func) { + return GetSymbol(TyIdx(0), GetStringIndex(name), kStVar, kScAuto, kScopeLocal, func); +} + +MIRSymbol *MIRBuilder::CreateLocalDecl(const string &name, MIRType *type, MIRFunction *func) { + return MIRSymbolBuilder::Instance().CreateLocalDecl(*func->symTab, + GetOrCreateStringIndex(name), *type); +} + +MIRSymbol *MIRBuilder::CreateLocalDecl(const char *name, MIRType *type, MIRFunction *func) { + return MIRSymbolBuilder::Instance().CreateLocalDecl(*func->symTab, + GetOrCreateStringIndex(name), *type); +} + +MIRSymbol *MIRBuilder::GetOrCreateLocalDecl(const string &name, MIRType *type, MIRFunction *func) { + MIRSymbol *st = GetLocalDecl(name, func); + if (!st) { + st = CreateLocalDecl(name, type, func); + } + return st; +} + +MIRSymbol *MIRBuilder::GetOrCreateLocalDecl(const char *name, MIRType *type, MIRFunction *func) { + MIRSymbol *st = GetLocalDecl(name, func); + if (!st) { + st = CreateLocalDecl(name, type, func); + } + return st; +} + MIRSymbol *MIRBuilder::GetLocalDecl(const string &name) { return GetSymbol(TyIdx(0), GetStringIndex(name), kStVar, kScAuto, kScopeLocal, GetCurrentFunction()); } -- Gitee From 7f30a0ec2012eb5ca9e5616168ef36485f0d60b7 Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Wed, 20 Jan 2021 19:36:25 -0800 Subject: [PATCH 12/33] PIC support for RISC-V --- mapleall/maple_be/include/cg/asm_info.h | 6 +++++ mapleall/maple_be/include/cg/emit.h | 1 + .../include/cg/riscv64/riscv64_md.def | 2 ++ .../include/cg/riscv64/riscv64_operand.h | 23 ++++++++----------- mapleall/maple_be/src/cg/cg_driver.cpp | 1 + mapleall/maple_be/src/cg/emit.cpp | 11 +++++++++ .../src/cg/riscv64/riscv64_cg_func.cpp | 3 +-- .../src/cg/riscv64/riscv64_insn_slct.cpp | 3 +-- .../src/cg/riscv64/riscv64_load_store.cpp | 20 +++++++++++----- mapleall/maple_driver/src/driver_runner.cpp | 2 ++ 10 files changed, 49 insertions(+), 23 deletions(-) diff --git a/mapleall/maple_be/include/cg/asm_info.h b/mapleall/maple_be/include/cg/asm_info.h index 6727bb3..759dae6 100644 --- a/mapleall/maple_be/include/cg/asm_info.h +++ b/mapleall/maple_be/include/cg/asm_info.h @@ -45,6 +45,7 @@ class Asminfo { MapleString asm_cmnt; MapleString asm_atobt; MapleString asm_file; + MapleString asm_option; MapleString asm_section; MapleString asm_rodata; MapleString asm_global; @@ -89,6 +90,11 @@ class Asminfo { asm_file.setMemPool(mp); asm_file = "\t.file\t"; +#if TARGRISCV64 + asm_option.setMemPool(mp); + asm_option = "\t.option\t"; +#endif + asm_section.setMemPool(mp); asm_section = "\t.section\t"; diff --git a/mapleall/maple_be/include/cg/emit.h b/mapleall/maple_be/include/cg/emit.h index d2c402b..bc84edb 100644 --- a/mapleall/maple_be/include/cg/emit.h +++ b/mapleall/maple_be/include/cg/emit.h @@ -123,6 +123,7 @@ class Emitter { void EmitAsmLabel(Asmlabel al); void EmitAsmLabel(const MIRSymbol *st, Asmlabel al); void EmitFileInfo(const std::string &fileName); + void EmitCompilationInfo(); void EmitBlockMarker(const char *markerName); // a symbol start/end a block void EmitBlockMarkerWithAddr(const char *markerName, const std::string &addrName); void EmitNullConstant(uint32 size); diff --git a/mapleall/maple_be/include/cg/riscv64/riscv64_md.def b/mapleall/maple_be/include/cg/riscv64/riscv64_md.def index ec0a63a..354ce90 100644 --- a/mapleall/maple_be/include/cg/riscv64/riscv64_md.def +++ b/mapleall/maple_be/include/cg/riscv64/riscv64_md.def @@ -66,6 +66,8 @@ DEFINE_MOP(MOP_vdupf64, {MOPD_Reg128FD,MOPD_Reg64FS,MOPD_Undef,MOPD_Undef,MOPD_U DEFINE_MOP(MOP_adrp, {MOPD_Reg64ID,MOPD_Literal,MOPD_Undef,MOPD_Undef,MOPD_Undef},ISLOADADDR,kLtShift,"lui","0,1", 1, 1) // MOP_laddr // riscv64 load label address DEFINE_MOP(MOP_laddr, {MOPD_Reg64ID,MOPD_Literal,MOPD_Undef,MOPD_Undef,MOPD_Undef},ISLOADADDR,kLtShift,"la","0,1", 1, 1) +// MOP_lladdr // riscv64 load local label address +DEFINE_MOP(MOP_lladdr, {MOPD_Reg64ID,MOPD_Literal,MOPD_Undef,MOPD_Undef,MOPD_Undef},ISLOADADDR,kLtShift,"lla","0,1", 1, 1) // MOP_xadr (Java) DEFINE_MOP(MOP_xadri64, {MOPD_Reg64ID,MOPD_Imm64,MOPD_Undef,MOPD_Undef,MOPD_Undef},ISLOADADDR,kLtShift,"err","0,1", 1, 1) // MOP_adrpl12 // riscv64 add label address low diff --git a/mapleall/maple_be/include/cg/riscv64/riscv64_operand.h b/mapleall/maple_be/include/cg/riscv64/riscv64_operand.h index 6aca64a..3b39656 100644 --- a/mapleall/maple_be/include/cg/riscv64/riscv64_operand.h +++ b/mapleall/maple_be/include/cg/riscv64/riscv64_operand.h @@ -415,27 +415,19 @@ class StImmOperand : public Operand // representing for global variables addres } /* virtual */ void Emit(Emitter &emitter, OpndProp *opndprop) override { - bool isLower12 = static_cast(opndprop)->IsLiteralLow12(); - if (isLower12) { - emitter.Emit("%lo("); - } if (CGOptions::doPIC && (st_->GetStorageClass() == kScGlobal || st_->GetStorageClass() == kScExtern)) { - emitter.Emit(":got:" + GetName()); + emitter.Emit(GetName()); } else { - if (isLower12 == false) { - emitter.Emit("%hi("); - } // check for sKind since it might be created by cg. (i.eg. LB_*) if (st_->storageClass == kScPstatic && st_->sKind != kStConst && st_->IsLocal()) { emitter.Emit(GetName() + to_string(CG::curPuIdx)); } else { emitter.Emit(GetName()); } + if (offset_ != 0) { + emitter.Emit("+" + to_string(offset_)); + } } - if (offset_ != 0) { - emitter.Emit("+" + to_string(offset_)); - } - emitter.Emit(")"); } /* virtual */ void dump() override { @@ -489,7 +481,12 @@ class FuncNameOperand : public Operand { } /* virtual */ void Emit(Emitter &emitter, OpndProp *opndprop) override { - emitter.Emit(GetName()); + auto func = symbol_->GetFunction(); + if (CGOptions::doPIC && func && !(func->IsLocal())) { + emitter.Emit(GetName() + "@plt"); + } else { + emitter.Emit(GetName()); + } } virtual bool Less(Operand *right) const override { diff --git a/mapleall/maple_be/src/cg/cg_driver.cpp b/mapleall/maple_be/src/cg/cg_driver.cpp index 4cff699..c4060aa 100644 --- a/mapleall/maple_be/src/cg/cg_driver.cpp +++ b/mapleall/maple_be/src/cg/cg_driver.cpp @@ -193,6 +193,7 @@ int main(int argc, char **argv) { if (!cgoption.SuppressFileInfo()) { thecg.emitter_->EmitFileInfo(fileName); } + thecg.emitter_->EmitCompilationInfo(); #if TARGARK MirGenerator *mirGen = new MirGenerator(*themodule, thecg.emitter_->out, *g->becommon); diff --git a/mapleall/maple_be/src/cg/emit.cpp b/mapleall/maple_be/src/cg/emit.cpp index c9e6308..92c8c4d 100644 --- a/mapleall/maple_be/src/cg/emit.cpp +++ b/mapleall/maple_be/src/cg/emit.cpp @@ -173,6 +173,17 @@ void Emitter::EmitFileInfo(const std::string &fileName) { #endif /* TARGARM */ } +void Emitter::EmitCompilationInfo() { +#if TARGRISCV64 + // gnu as risc-v dependent directives + if (CGOptions::doPIC) { + Emit(asminfo_->asm_option); + Emit("pic"); + Emit("\n"); + } +#endif +} + void Emitter::EmitAsmLabel(Asmlabel al) { switch (al) { case kAsmData: { diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp index c0cc29b..50e2633 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp @@ -3411,8 +3411,7 @@ RegOperand *Riscv64CGFunc::CreateCallStructParamMemcpy(MIRSymbol *sym, RegOperan } StImmOperand *stopnd = CreateStImmOperand(sym, 0, 0); Riscv64RegOperand *staddropnd = static_cast(CreateRegisterOperandOfType(PTY_u64)); - curbb->AppendInsn(cg->BuildInstruction(MOP_adrp, staddropnd, stopnd)); - curbb->AppendInsn(cg->BuildInstruction(MOP_adrpl12, staddropnd, staddropnd, stopnd)); + curbb->AppendInsn(cg->BuildInstruction(MOP_laddr, staddropnd, stopnd)); opndvec.push_back(staddropnd); // param 1 } else { CHECK_FATAL(0,"Unsupported sym for struct param"); diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_insn_slct.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_insn_slct.cpp index 3c05f9d..5bd5edc 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_insn_slct.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_insn_slct.cpp @@ -2442,8 +2442,7 @@ void Riscv64CGFunc::SelectRangegoto(RangegotoNode *rangegotonode, Operand *opnd0 StImmOperand *switchTable = CreateStImmOperand(lblst, 0, 0); // load the address of the switch table - curbb->AppendInsn(cg->BuildInstruction(MOP_adrp, baseopnd, switchTable)); - curbb->AppendInsn(cg->BuildInstruction(MOP_adrpl12, baseopnd, baseopnd, switchTable)); + curbb->AppendInsn(cg->BuildInstruction(MOP_laddr, baseopnd, switchTable)); // Compute the address of the load RegOperand *sllDst = CreateVirtualRegisterOperand(New_V_Reg(kRegTyInt, 8)); diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp index 4a161f3..6c7db57 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp @@ -1907,14 +1907,22 @@ void Riscv64CGFunc::SelectAddrof(Operand *result, StImmOperand *stimm) { insn->AddComment(comm); } } else { - curbb->AppendInsn(cg->BuildInstruction(MOP_adrp, result, stimm)); if (CGOptions::doPIC && (symbol->GetStorageClass() == kScGlobal || symbol->GetStorageClass() == kScExtern)) { - // ldr x0, [x0, #:got_lo12:Ljava_2Flang_2FSystem_3B_7Cout] - Riscv64MemOperand *mo = GetOrCreateMemOpnd(SIZEOFPTR * BITS_PER_BYTE, - static_cast(result), nullptr, stimm, nullptr); - curbb->AppendInsn(cg->BuildInstruction(MOP_xldr, result, mo)); + curbb->AppendInsn(cg->BuildInstruction(MOP_laddr, result, stimm)); + int64 offsetVal = stimm->GetOffset(); + if (offsetVal != 0) { + if (llabs(offsetVal) < 1<<12) { + curbb->AppendInsn(cg->BuildInstruction(MOP_xaddrri12, result, result, + CreateImmOperand(offsetVal, 8, true))); + } else { + Riscv64RegOperand *offsetReg = static_cast(CreateRegisterOperandOfType(PTY_u64)); + curbb->AppendInsn(cg->BuildInstruction(MOP_xmovri64, offsetReg, + CreateImmOperand(offsetVal, 8, true))); + curbb->AppendInsn(cg->BuildInstruction(MOP_xaddrrr, result, result, offsetReg)); + } + } } else { - curbb->AppendInsn(cg->BuildInstruction(MOP_adrpl12, result, result, stimm)); + curbb->AppendInsn(cg->BuildInstruction(MOP_lladdr, result, stimm)); } } } diff --git a/mapleall/maple_driver/src/driver_runner.cpp b/mapleall/maple_driver/src/driver_runner.cpp index 5b9e640..4cf3261 100644 --- a/mapleall/maple_driver/src/driver_runner.cpp +++ b/mapleall/maple_driver/src/driver_runner.cpp @@ -318,6 +318,8 @@ void DriverRunner::ProcessMpl2mplAndMeAndMplCgPhases(const std::string &interimO thecg.emitter_->EmitFileInfo(actualInput); } + thecg.emitter_->EmitCompilationInfo(); + #if TARGARK MirGenerator *mirGen = new MirGenerator(*theModule, thecg.emitter_->out, *g->becommon); mirGen->OutputMIR(cgOptions->genMirMpl); -- Gitee From 43a90188ce33a412b786552d9b4846e124999201 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 22 Jan 2021 14:22:22 -0800 Subject: [PATCH 13/33] fix a bug to get func signature string --- mapleall/maple_ir/src/mir_function.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_ir/src/mir_function.cpp b/mapleall/maple_ir/src/mir_function.cpp index d965fff..9708a41 100644 --- a/mapleall/maple_ir/src/mir_function.cpp +++ b/mapleall/maple_ir/src/mir_function.cpp @@ -189,8 +189,11 @@ void MIRFunction::SetBaseClassFuncNames(GStrIdx strIdx) { baseClassStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(classname); std::string funcnameWithtype = name.substr(pos + width, name.length() - pos - width); baseFuncWithTypeStrIdx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(funcnameWithtype); - size_t posEnd = name.find(NameMangler::kRightBracketStr) + (std::string(NameMangler::kRightBracketStr)).length(); - funcnameWithtype = name.substr(pos + width, posEnd - pos - width); + size_t index = name.find(NameMangler::kRightBracketStr); + if (index != std::string::npos) { + size_t posEnd = index + (std::string(NameMangler::kRightBracketStr)).length(); + funcnameWithtype = name.substr(pos + width, posEnd - pos - width); + } baseFuncSigStridx = GlobalTables::GetStrTable().GetOrCreateStrIdxFromName(funcnameWithtype); size_t pos1 = name.find(delimiter, pos + width); while (pos1 != std::string::npos && (name[pos1 - 1] == '_' && name[pos1 - 2] != '_')) { -- Gitee From 42f68b095de8400f1fff001751fc245ea0dbf914 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Wed, 27 Jan 2021 14:03:38 -0800 Subject: [PATCH 14/33] introduce INTRN_JS_DATE modified: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index d688035..dc6c6e0 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -34,4 +34,6 @@ DEF_MIR_INTRINSIC(JSOP_ASSERTVALUE, __jsop_assert_value, INTRNISJS, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_ISNAN,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_DATE,\ + NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 93d628f92aa373d09be9c98b4ddf81a66c808331 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Thu, 28 Jan 2021 07:06:21 -0800 Subject: [PATCH 15/33] add API --- mapleall/maple_ir/include/mir_nodes.h | 5 +++++ mapleall/maple_ir/include/mir_type.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/mapleall/maple_ir/include/mir_nodes.h b/mapleall/maple_ir/include/mir_nodes.h index 239d436..dd30637 100644 --- a/mapleall/maple_ir/include/mir_nodes.h +++ b/mapleall/maple_ir/include/mir_nodes.h @@ -1403,6 +1403,11 @@ class IassignNode : public StmtNode { numOpnds = 2; } + IassignNode(TyIdx t, FieldID f, BaseNode* a, BaseNode *r) : + StmtNode(OP_iassign), tyIdx(t), fieldID(f), addrExpr(a), rhs(r) { + numOpnds = 2; + } + ~IassignNode() = default; BaseNode *Opnd(size_t i) const { diff --git a/mapleall/maple_ir/include/mir_type.h b/mapleall/maple_ir/include/mir_type.h index 5202beb..35e9617 100644 --- a/mapleall/maple_ir/include/mir_type.h +++ b/mapleall/maple_ir/include/mir_type.h @@ -328,6 +328,11 @@ class FieldAttrs { return !(*this == tA); } + void Clear() { + attrFlag = 0; + attrAlign = 0; + } + void DumpAttributes() const; TypeAttrs ConvertToTypeAttrs(); }; -- Gitee From 9083a039a5ac84318bdde3d204602705ee3eda14 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Fri, 29 Jan 2021 13:01:34 -0800 Subject: [PATCH 16/33] add INTRN_JS_REGEXP for supporting regexp modified: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index dc6c6e0..de50ac5 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -36,4 +36,6 @@ DEF_MIR_INTRINSIC(JS_ISNAN,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_DATE,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_REGEXP,\ + NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 757b717c9ad883bfb5917f06fb11288f39b47950 Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Fri, 29 Jan 2021 15:23:00 -0800 Subject: [PATCH 17/33] SelectIread must handle struct of both top and component levels --- mapleall/maple_be/src/cg/aarch64/aarch64_load_store.cpp | 2 +- mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_be/src/cg/aarch64/aarch64_load_store.cpp b/mapleall/maple_be/src/cg/aarch64/aarch64_load_store.cpp index 497215a..c93d2f7 100644 --- a/mapleall/maple_be/src/cg/aarch64/aarch64_load_store.cpp +++ b/mapleall/maple_be/src/cg/aarch64/aarch64_load_store.cpp @@ -2131,7 +2131,7 @@ Operand *AArch64CGFunc::SelectIread(BaseNode *parent, IreadNode *expr) { if (regty == kRegTyFloat) { destType = expr->primType; bitsize = GetPrimTypeBitSize(destType); - } else if (expr->fieldID == 0 && destType == PTY_agg) { // entire struct + } else if (destType == PTY_agg) { // entire struct switch (bitsize) { case 8: destType = PTY_u8; diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp index 6c7db57..223cc42 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_load_store.cpp @@ -2089,7 +2089,7 @@ Operand *Riscv64CGFunc::SelectIread(BaseNode *parent, IreadNode *expr) { if (regty == kRegTyFloat) { destType = expr->primType; bitsize = GetPrimTypeBitSize(destType); - } else if (expr->fieldID == 0 && destType == PTY_agg) { // entire struct + } else if (destType == PTY_agg) { // entire struct switch (bitsize) { case 8: destType = PTY_u8; -- Gitee From 5a56b797e1ea450b6ca55c4787d52679b5a1142c Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Mon, 1 Feb 2021 21:25:31 -0800 Subject: [PATCH 18/33] fix INTRN_JS_NUMBER's type which shouldn't be always int32 modified: mapleall/maple_ir/include/js2mpl/jsintrinsic.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 7d5650c..2bf62c8 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -55,7 +55,7 @@ DEF_MIR_INTRINSIC(JSSTR_LENGTH,\ DEF_MIR_INTRINSIC(JS_BOOLEAN,\ __js_ToBoolean, INTRNISJS | INTRNISJSUNARY | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyU1, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_NUMBER,\ - __js_ToNumber, INTRNISJS | INTRNISJSUNARY | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyI32, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) + __js_ToNumber, INTRNISJS | INTRNISJSUNARY | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_INT32,\ __js_ToInt32, INTRNISJS | INTRNISJSUNARY | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyI32, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_PRINT,\ -- Gitee From f13b5320b7461448bd571c484970df6f7c2c756e Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Wed, 10 Feb 2021 10:37:09 -0800 Subject: [PATCH 19/33] RISC-V code generation for stack check guard --- .../include/cg/riscv64/riscv64_mem_layout.h | 2 ++ .../src/cg/riscv64/riscv64_cg_func.cpp | 21 +++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/mapleall/maple_be/include/cg/riscv64/riscv64_mem_layout.h b/mapleall/maple_be/include/cg/riscv64/riscv64_mem_layout.h index 2c48b08..a27dd60 100644 --- a/mapleall/maple_be/include/cg/riscv64/riscv64_mem_layout.h +++ b/mapleall/maple_be/include/cg/riscv64/riscv64_mem_layout.h @@ -123,6 +123,8 @@ class Riscv64SymbolAlloc : public SymbolAlloc { | including those used for | | parameter passing | ||----------------------------| + | StackChkguard if enabled | + |----------------------------| | empty space. should have | | at least 16-byte alignment | ||----------------------------| diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp index 50e2633..2c7522d 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp @@ -1179,11 +1179,9 @@ void Riscv64CGFunc::Genstackguard(BB *bb) { Riscv64RegOperand *staddropnd = static_cast(GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * 8, kRegTyInt)); SelectAddrof(staddropnd, stopnd); - Riscv64MemOperand *guardmemopn = - memPool->New(SIZEOFPTR * 8, staddropnd, - static_cast(nullptr), GetOrCreateOfstOpnd(0, 32), stkguardsym); MOperator mop = PickLdInsn(64, PTY_u64); - Insn *ins = cg->BuildInstruction(mop, staddropnd, guardmemopn); + Insn *ins = cg->BuildInstruction(mop, staddropnd, + memPool->New(R9, 0, SIZEOFPTR * BITS_PER_BYTE)); ins->do_not_remove = true; curbb->AppendInsn(ins); @@ -1201,7 +1199,10 @@ void Riscv64CGFunc::Genstackguard(BB *bb) { int32 stksize = static_cast(memlayout)->RealStackFrameSize() - static_cast(memlayout)->SizeOfArgsToStackpass() - varea; - downstk = memPool->New(RFP, stksize - 8, SIZEOFPTR * BITS_PER_BYTE); + // Note that the total size of stack frame alread count in a slot for stackguard + // Use a lot right below callee-saved registers in stack frame and FP and RA are saved on top of frame + downstk = memPool->New(RFP, stksize - (SizeOfCalleeSaved() - 2 * kIntregBytelen) - kIntregBytelen, + SIZEOFPTR * BITS_PER_BYTE); } else { downstk = memPool->New(RSP, static_cast(memlayout)->RealStackFrameSize() - 8 - varea, SIZEOFPTR * BITS_PER_BYTE); @@ -2442,11 +2443,9 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { Riscv64RegOperand *staddropnd = static_cast(GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * 8, kRegTyInt)); SelectAddrof(staddropnd, stopnd); - Riscv64MemOperand *guardmemopn = - memPool->New(SIZEOFPTR * 8, staddropnd, - static_cast(nullptr), GetOrCreateOfstOpnd(0, 32), stkguardsym); MOperator mop = PickLdInsn(64, PTY_u64); - Insn *ins = cg->BuildInstruction(mop, staddropnd, guardmemopn); + Insn *ins = cg->BuildInstruction(mop, staddropnd, + memPool->New(R9, 0, SIZEOFPTR * BITS_PER_BYTE)); ins->do_not_remove = true; curbb->AppendInsn(ins); @@ -2466,7 +2465,8 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { int32 stksize = static_cast(memlayout)->RealStackFrameSize() - static_cast(memlayout)->SizeOfArgsToStackpass() - varea; - downstk = memPool->New(RFP, stksize - 8, SIZEOFPTR * BITS_PER_BYTE); + downstk = memPool->New(RFP, stksize - (SizeOfCalleeSaved() - 2 * kIntregBytelen) - kIntregBytelen, + SIZEOFPTR * BITS_PER_BYTE); } else { downstk = memPool->New(RSP, static_cast(memlayout)->RealStackFrameSize() - 8 - varea, SIZEOFPTR * BITS_PER_BYTE); @@ -2475,7 +2475,6 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { if (IsImmediateOffsetOutOfRange(static_cast(downstk), 64)) { downstk = SplitOffsetWithAddInstruction(static_cast(downstk), 64, R12); } - mop = PickLdInsn(SIZEOFPTR * BITS_PER_BYTE, PTY_u64); ins = cg->BuildInstruction(mop, checkopn, downstk); ins->do_not_remove = true; -- Gitee From c0df1ef49a676f7585d6499fcfeec360ed6a2d47 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Wed, 10 Feb 2021 14:43:47 -0800 Subject: [PATCH 20/33] Add JS_DELNAME intrinsic for Maple JavaScript. modified: maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index de50ac5..71fc098 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -38,4 +38,5 @@ DEF_MIR_INTRINSIC(JS_DATE,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_REGEXP,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) - +DEF_MIR_INTRINSIC(JS_DELNAME,\ + NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 20f4d0aeaed9d265f38095336139f95d6e6dc23a Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Thu, 11 Feb 2021 11:52:59 -0800 Subject: [PATCH 21/33] JSOP_GET_THIS_PROP_BY_NAME and JSOP_SET_THIS_PROP_BY_NAME modified: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index 71fc098..0978322 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -40,3 +40,7 @@ DEF_MIR_INTRINSIC(JS_REGEXP,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_DELNAME,\ NULL, INTRNISJS | INTRNISPURE | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JSOP_GET_THIS_PROP_BY_NAME,\ + NULL, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTySimplestr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JSOP_SET_THIS_PROP_BY_NAME,\ + NULL, INTRNISJS, kArgTyVoid, kArgTyDynany, kArgTySimplestr, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 99240171dfaa8d94d90110b1ea49b6d26192c343 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Thu, 11 Feb 2021 10:28:55 -0500 Subject: [PATCH 22/33] Add `firstarg_return` flag The frontend may set this flag if it converts a function which returns a large struct by implicitly passing the return address as the first parameter. On ARM architectures, this implicit return address must be passed in register x8, not as a typical first parameter. --- mapleall/maple_ir/include/all_attributes.def | 3 +++ mapleall/maple_ir/include/mir_function.h | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/mapleall/maple_ir/include/all_attributes.def b/mapleall/maple_ir/include/all_attributes.def index 100ff8e..1f1edac 100644 --- a/mapleall/maple_ir/include/all_attributes.def +++ b/mapleall/maple_ir/include/all_attributes.def @@ -78,3 +78,6 @@ ATTR(localrefvar) ATTR(rcunownedthis) #endif +#ifdef FUNC_ATTR + ATTR(firstarg_return) +#endif diff --git a/mapleall/maple_ir/include/mir_function.h b/mapleall/maple_ir/include/mir_function.h index db21a20..ef2df97 100644 --- a/mapleall/maple_ir/include/mir_function.h +++ b/mapleall/maple_ir/include/mir_function.h @@ -382,6 +382,10 @@ class MIRFunction : public mir_func_t { return funcAttrs.GetAttr(FUNCATTR_pure); } + bool IsFirstArgReturn() const { + return funcAttrs.GetAttr(FUNCATTR_firstarg_return); + } + void SetVarargs() { funcAttrs.SetAttr(FUNCATTR_varargs); } @@ -406,6 +410,10 @@ class MIRFunction : public mir_func_t { funcAttrs.SetAttr(FUNCATTR_pure); } + void SetFirstArgReturn() { + funcAttrs.SetAttr(FUNCATTR_firstarg_return); + } + void UnsetNoDefEffect() { funcAttrs.SetAttr(FUNCATTR_nodefeffect, true); } -- Gitee From 4d7c804cef1d2c1b5f1b60e51b5eb4b148010274 Mon Sep 17 00:00:00 2001 From: Brice Dobry Date: Thu, 11 Feb 2021 15:17:35 -0500 Subject: [PATCH 23/33] Check for `firstarg_return` flag in codegen The frontend uses this flag to indicate that the first parameter is actually the return address. For ARM, this needs to be passed in register x8, not as a normal first parameter. --- mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp | 8 ++++++++ mapleall/maple_be/src/cg/aarch64/aarch64_cg_func.cpp | 3 ++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp b/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp index fc5fb1a..738ce08 100644 --- a/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp +++ b/mapleall/maple_be/src/cg/aarch64/aarch64_abi.cpp @@ -219,6 +219,14 @@ int32 ParmLocator::LocateNextParm(MIRType *ty, PLocInfo &ploc, bool isFirst) { InitPlocInfo(ploc); if (isFirst) { MIRFunction *func = _be.mirModule.CurFunction(); + + // Check if the front-end moved the return address to an implicit first + // paramter. If it is, this must be in register x8. + if (func->IsFirstArgReturn()) { + ploc.reg0 = R8; + return SIZEOFPTR; + } + auto funcIt = _be.funcReturnType.find(func); if (funcIt != _be.funcReturnType.end()) { TyIdx retidx = funcIt->second; diff --git a/mapleall/maple_be/src/cg/aarch64/aarch64_cg_func.cpp b/mapleall/maple_be/src/cg/aarch64/aarch64_cg_func.cpp index 27cad3e..7c08bd3 100644 --- a/mapleall/maple_be/src/cg/aarch64/aarch64_cg_func.cpp +++ b/mapleall/maple_be/src/cg/aarch64/aarch64_cg_func.cpp @@ -3809,7 +3809,8 @@ void AArch64CGFunc::SelectParmList(StmtNode * narynode, AArch64ListOperand * src expregopnd = static_cast(opnd); } - if (pnum == 0 && retSize > 16) { + // If the first parameter is actually the return address, put it in x8. + if (pnum == 0 && (retSize > 16 || (callfunc && callfunc->IsFirstArgReturn()))) { parmlocator.InitPlocInfo(ploc); ploc.reg0 = R8; } else { -- Gitee From cad2eab2e25d2ffb06b4c76e5002e24747475068 Mon Sep 17 00:00:00 2001 From: Feng Ye Date: Tue, 16 Feb 2021 09:59:01 -0800 Subject: [PATCH 24/33] Wrong uses of R9/R12 as temp registers --- .../src/cg/riscv64/riscv64_cg_func.cpp | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp index 2c7522d..d48ecd6 100644 --- a/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp +++ b/mapleall/maple_be/src/cg/riscv64/riscv64_cg_func.cpp @@ -295,7 +295,7 @@ void Riscv64CGFunc::AppendInstructionPushSingle(Riscv64reg_t reg, RegType rty, i uint32 datasize = SIZEOFPTR * BITS_PER_BYTE; if (IsImmediateOffsetOutOfRange(static_cast(o1), datasize)) { - o1 = SplitOffsetWithAddInstruction(static_cast(o1), datasize, R9); + o1 = SplitOffsetWithAddInstruction(static_cast(o1), datasize, R5); } Insn *pushInsn = cg->BuildInstruction(mop, o0, o1); @@ -449,7 +449,7 @@ void Riscv64CGFunc::AppendInstructionAllocateCallFrame(Riscv64reg_t reg0, Riscv6 allocInsn = cg->BuildInstruction(mop, o1, o2); AppendInstructionTo(allocInsn, this); } else { - Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); + Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); Riscv64ImmOperand *io = CreateImmOperand(argsToStkpassSize, 64, true); SelectCopyImm(oo, io, PTY_i64); @@ -569,7 +569,7 @@ void Riscv64CGFunc::AppendInstructionAllocateCallFrameDebug(Riscv64reg_t reg0, R CreateCfiRegOperand(RRA, 64), CreateCfiImmOperand(-cfiOffset + 8, 64))); } } else { - Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); + Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); Riscv64ImmOperand *io = CreateImmOperand(argsToStkpassSize, 64, true); SelectCopyImm(oo, io, PTY_i64); @@ -822,7 +822,7 @@ void Riscv64CGFunc::AppendInstructionDeallocateCallFrame(Riscv64reg_t reg0, Risc popInsn = cg->BuildInstruction(mop, o1, o2); AppendInstructionTo(popInsn, this); } else { - Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); + Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); Riscv64ImmOperand *io = CreateImmOperand(argsToStkpassSize, 64, true); SelectCopyImm(oo, io, PTY_i64); @@ -939,7 +939,7 @@ void Riscv64CGFunc::AppendInstructionDeallocateCallFrameDebug(Riscv64reg_t reg0, AppendInstructionTo(popInsn, this); curbb->AppendInsn(cg->BuildInstruction(cfi::OP_CFI_restore, CreateCfiRegOperand(RRA, 64))); } else { - Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); + Riscv64RegOperand *oo = GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * BITS_PER_BYTE, kRegTyInt); Riscv64ImmOperand *io = CreateImmOperand(argsToStkpassSize, 64, true); SelectCopyImm(oo, io, PTY_i64); @@ -1177,11 +1177,11 @@ void Riscv64CGFunc::Genstackguard(BB *bb) { MIRSymbol *stkguardsym = GlobalTables::GetGsymTable().GetSymbolFromStrIdx(GlobalTables::GetStrTable().GetStrIdxFromName("__stack_chk_guard")); StImmOperand *stopnd = CreateStImmOperand(stkguardsym, 0, 0); Riscv64RegOperand *staddropnd = - static_cast(GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * 8, kRegTyInt)); + static_cast(GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * 8, kRegTyInt)); SelectAddrof(staddropnd, stopnd); MOperator mop = PickLdInsn(64, PTY_u64); Insn *ins = cg->BuildInstruction(mop, staddropnd, - memPool->New(R9, 0, SIZEOFPTR * BITS_PER_BYTE)); + memPool->New(R5, 0, SIZEOFPTR * BITS_PER_BYTE)); ins->do_not_remove = true; curbb->AppendInsn(ins); @@ -1994,7 +1994,7 @@ void Riscv64CGFunc::InitialSpillSlot(BB * bb) { uint32 datasize = SIZEOFPTR * BITS_PER_BYTE; Operand* memopnd = CreateStkTopOpnd(offset + i, datasize); if (IsImmediateOffsetOutOfRange(static_cast(memopnd), datasize)) { - memopnd = SplitOffsetWithAddInstruction(static_cast(memopnd), datasize, R9); + memopnd = SplitOffsetWithAddInstruction(static_cast(memopnd), datasize, R5); } Insn* pushInsn = cg->BuildInstruction( MOP_xstr, GetZeroOpnd(64), memopnd); @@ -2441,11 +2441,11 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { MIRSymbol *stkguardsym = GlobalTables::GetGsymTable().GetSymbolFromStrIdx(GlobalTables::GetStrTable().GetStrIdxFromName("__stack_chk_guard")); StImmOperand *stopnd = CreateStImmOperand(stkguardsym, 0, 0); Riscv64RegOperand *staddropnd = - static_cast(GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * 8, kRegTyInt)); + static_cast(GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * 8, kRegTyInt)); SelectAddrof(staddropnd, stopnd); MOperator mop = PickLdInsn(64, PTY_u64); Insn *ins = cg->BuildInstruction(mop, staddropnd, - memPool->New(R9, 0, SIZEOFPTR * BITS_PER_BYTE)); + memPool->New(R5, 0, SIZEOFPTR * BITS_PER_BYTE)); ins->do_not_remove = true; curbb->AppendInsn(ins); @@ -2459,7 +2459,7 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { } Riscv64RegOperand *checkopn = - static_cast(GetOrCreatePhysicalRegisterOperand(R12, SIZEOFPTR * 8, kRegTyInt)); + static_cast(GetOrCreatePhysicalRegisterOperand(R6, SIZEOFPTR * 8, kRegTyInt)); Riscv64MemOperand *downstk = nullptr; if (cg->UseFP() || HasVLAOrAlloca()) { int32 stksize = static_cast(memlayout)->RealStackFrameSize() - @@ -2473,7 +2473,7 @@ void Riscv64CGFunc::GenerateEpilog(BB * bb) { } if (IsImmediateOffsetOutOfRange(static_cast(downstk), 64)) { - downstk = SplitOffsetWithAddInstruction(static_cast(downstk), 64, R12); + downstk = SplitOffsetWithAddInstruction(static_cast(downstk), 64, R6); } mop = PickLdInsn(SIZEOFPTR * BITS_PER_BYTE, PTY_u64); ins = cg->BuildInstruction(mop, checkopn, downstk); @@ -4337,7 +4337,7 @@ MemOperand *Riscv64CGFunc::GetOrCreateArgMemOpnd(MIRSymbol * symbol, int32 offse return it->second; } - RegOperand *tempreg = GetOrCreatePhysicalRegisterOperand(R9, SIZEOFPTR * 8, kRegTyInt); + RegOperand *tempreg = GetOrCreatePhysicalRegisterOperand(R5, SIZEOFPTR * 8, kRegTyInt); Riscv64RegOperand *baseOpnd = static_cast(GetBaseReg(symloc)); int32 stoffset = GetBaseOffset(symloc); @@ -5272,7 +5272,7 @@ void Riscv64CGFunc::InsertYieldpoint() { // Converting x31 to x9 for alternate calling convention used in special functions. for (auto &p : callnativemap) { Insn *in = p.first; - Riscv64RegOperand *funcreg = GetOrCreatePhysicalRegisterOperand(R9, 64, kRegTyInt); + Riscv64RegOperand *funcreg = GetOrCreatePhysicalRegisterOperand(R5, 64, kRegTyInt); in->SetOperand(0, funcreg); } // do not insert yieldpoint in function that not saved X30 into stack, -- Gitee From 229b22ba8ede075dbabec8a190a36cab405594dd Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Tue, 23 Feb 2021 13:51:32 -0800 Subject: [PATCH 25/33] define JSOP_INIT_THIS_PROP_BY_NAME --- mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index 0978322..6076ed3 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -44,3 +44,5 @@ DEF_MIR_INTRINSIC(JSOP_GET_THIS_PROP_BY_NAME,\ NULL, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT, kArgTyDynany, kArgTyDynany, kArgTySimplestr, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_SET_THIS_PROP_BY_NAME,\ NULL, INTRNISJS, kArgTyVoid, kArgTyDynany, kArgTySimplestr, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JSOP_INIT_THIS_PROP_BY_NAME,\ + NULL, INTRNISJS, kArgTyVoid, kArgTyDynany, kArgTySimplestr, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From e15fe9e5fbd2dd5963932a5821e0979ff8814f30 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Wed, 24 Feb 2021 21:40:45 -0800 Subject: [PATCH 26/33] setup switch for dynamic type, including parser and lower switch modified: mapleall/maple_be/include/be/switch_lowerer.h modified: mapleall/maple_be/src/be/switch_lowerer.cpp modified: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def modified: mapleall/maple_ir/src/mir_parser_stmt.cpp --- mapleall/maple_be/include/be/switch_lowerer.h | 3 ++ mapleall/maple_be/src/be/switch_lowerer.cpp | 53 +++++++++++++++++-- .../include/js2mpl/jsintrinsic_eng.def | 2 + mapleall/maple_ir/src/mir_parser_stmt.cpp | 12 ++++- 4 files changed, 65 insertions(+), 5 deletions(-) diff --git a/mapleall/maple_be/include/be/switch_lowerer.h b/mapleall/maple_be/include/be/switch_lowerer.h index b4fb465..7f23117 100644 --- a/mapleall/maple_be/include/be/switch_lowerer.h +++ b/mapleall/maple_be/include/be/switch_lowerer.h @@ -66,6 +66,9 @@ class SwitchLowerer { GotoNode *BuildGotoNode(int32 idx); CondGotoNode *BuildCondGotoNode(int32 idx, Opcode opcode, BaseNode *cond); BlockNode *BuildCodeForSwitchItems(int32 start, int32 end, bool lowbndchecked, bool highbndchecked); +#ifdef DYNAMICLANG + IntrinsicopNode *BuildSwitchCmpNode(Opcode opcode, uint32 idx); +#endif }; } // namespace maplebe diff --git a/mapleall/maple_be/src/be/switch_lowerer.cpp b/mapleall/maple_be/src/be/switch_lowerer.cpp index 23b3992..518642e 100644 --- a/mapleall/maple_be/src/be/switch_lowerer.cpp +++ b/mapleall/maple_be/src/be/switch_lowerer.cpp @@ -126,6 +126,22 @@ RangegotoNode *SwitchLowerer::BuildRangegotoNode(int32 startIdx, int32 endIdx) { return node; } +#ifdef DYNAMICLANG +IntrinsicopNode *SwitchLowerer::BuildSwitchCmpNode(Opcode opcode, uint32 idx) { + // CompareNode *binaryExpr = mirModule.CurFuncCodeMemPool()->New(opcode); + MIRBuilder *mirBuilder = mirModule.mirBuilder; + ConstvalNode *op0 = mirBuilder->CreateIntConst((int64)opcode, PTY_u32); + BaseNode *op1 = stmt->switchOpnd; + ConstvalNode *op2 = mirBuilder->CreateIntConst(stmt->switchTable.at(idx).first, PTY_i32); + MapleVector opVec(mirModule.CurFuncCodeMemPoolAllocator()->Adapter()); + opVec.push_back(op0); + opVec.push_back(op1); + opVec.push_back(op2); + IntrinsicopNode *cmpExpr = mirBuilder->CreateExprIntrinsicop(INTRN_JSOP_SWITCH_CMP, GlobalTables::GetTypeTable().GetUInt1(), opVec, false); + return cmpExpr; +} +#endif + CompareNode *SwitchLowerer::BuildCmpNode(Opcode opcode, uint32 idx) { CompareNode *binaryExpr = mirModule.CurFuncCodeMemPool()->New(opcode); binaryExpr->primType = PTY_u32; @@ -172,17 +188,30 @@ BlockNode *SwitchLowerer::BuildCodeForSwitchItems(int32 start, int32 end, bool l CondGotoNode *cgoto = nullptr; RangegotoNode *rangegoto = nullptr; IfStmtNode *ifstmt = nullptr; +#ifdef DYNAMICLANG + BaseNode *cmpnode = nullptr; +#else CompareNode *cmpnode = nullptr; +#endif MIRLower mirlowerer(mirModule, lowerer->GetCurrentFunc()); // if low side starts with a dense item, handle it first while (start <= end && switch_items[start].second != 0) { if (!lowbndchecked) { - cgoto = BuildCondGotoNode(-1, OP_brtrue, BuildCmpNode(OP_lt, switch_items[start].first)); + cgoto = BuildCondGotoNode(-1, OP_brtrue, +#ifdef DYNAMICLANG + BuildSwitchCmpNode(OP_lt, switch_items[start].first)); +#else + BuildCmpNode(OP_lt, switch_items[start].first)); +#endif localBlk->AddStatement(cgoto); lowbndchecked = true; } rangegoto = BuildRangegotoNode(switch_items[start].first, switch_items[start].second); +#ifdef DYNAMICLANG + cmpnode = BuildSwitchCmpNode(OP_le, switch_items[start].second); +#else cmpnode = BuildCmpNode(OP_le, switch_items[start].second); +#endif ifstmt = static_cast(mirModule.mirBuilder->CreateStmtIf(cmpnode)); ifstmt->thenPart->AddStatement(rangegoto); localBlk->AppendStatementsFromBlock(mirlowerer.LowerIfStmt(ifstmt, false)); @@ -195,12 +224,21 @@ BlockNode *SwitchLowerer::BuildCodeForSwitchItems(int32 start, int32 end, bool l // if high side starts with a dense item, handle it also while (start <= end && switch_items[end].second != 0) { if (!highbndchecked) { - cgoto = BuildCondGotoNode(-1, OP_brtrue, BuildCmpNode(OP_gt, switch_items[end].second)); + cgoto = BuildCondGotoNode(-1, OP_brtrue, +#ifdef DYNAMICLANG + BuildSwitchCmpNode(OP_gt, switch_items[end].second)); +#else + BuildCmpNode(OP_gt, switch_items[end].second)); +#endif localBlk->AddStatement(cgoto); highbndchecked = true; } rangegoto = BuildRangegotoNode(switch_items[end].first, switch_items[end].second); +#ifdef DYNAMICLANG + cmpnode = BuildSwitchCmpNode(OP_ge, switch_items[end].first); +#else cmpnode = BuildCmpNode(OP_ge, switch_items[end].first); +#endif ifstmt = static_cast(mirModule.mirBuilder->CreateStmtIf(cmpnode)); ifstmt->thenPart->AddStatement(rangegoto); localBlk->AppendStatementsFromBlock(mirlowerer.LowerIfStmt(ifstmt, false)); @@ -230,7 +268,12 @@ BlockNode *SwitchLowerer::BuildCodeForSwitchItems(int32 start, int32 end, bool l if (start == end && lowbndchecked && highbndchecked) { cgoto = (CondGotoNode *)BuildGotoNode(switch_items[start].first); // can omit the condition } else { - cgoto = BuildCondGotoNode(switch_items[start].first, OP_brtrue, BuildCmpNode(OP_eq, switch_items[start].first)); + cgoto = BuildCondGotoNode(switch_items[start].first, OP_brtrue, +#ifdef DYNAMICLANG + BuildSwitchCmpNode(OP_eq, switch_items[start].first)); +#else + BuildCmpNode(OP_eq, switch_items[start].first)); +#endif } localBlk->AddStatement(cgoto); if (lowbndchecked && start < end) { @@ -267,7 +310,11 @@ BlockNode *SwitchLowerer::BuildCodeForSwitchItems(int32 start, int32 end, bool l ASSERT(mid >= start, "switch lowering mid must be > start"); ASSERT(mid <= end, "switch lowering mid must be <= end"); // generate test for binary search +#ifdef DYNAMICLANG + cmpnode = BuildSwitchCmpNode(OP_ge, switch_items[mid].first); +#else cmpnode = BuildCmpNode(OP_ge, switch_items[mid].first); +#endif BaseNode *expnode = static_cast(mirModule.mirBuilder->CreateExprUnary(OP_lnot, GlobalTables::GetTypeTable().GetUInt1(), cmpnode)); ifstmt = static_cast(mirModule.mirBuilder->CreateStmtIf(expnode)); diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def index 6076ed3..98c9b9a 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -46,3 +46,5 @@ DEF_MIR_INTRINSIC(JSOP_SET_THIS_PROP_BY_NAME,\ NULL, INTRNISJS, kArgTyVoid, kArgTyDynany, kArgTySimplestr, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_INIT_THIS_PROP_BY_NAME,\ NULL, INTRNISJS, kArgTyVoid, kArgTyDynany, kArgTySimplestr, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JSOP_SWITCH_CMP,\ + NULL, INTRNISJS, kArgTyU1, kArgTyDynany, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef) diff --git a/mapleall/maple_ir/src/mir_parser_stmt.cpp b/mapleall/maple_ir/src/mir_parser_stmt.cpp index d4e8dba..74cd015 100644 --- a/mapleall/maple_ir/src/mir_parser_stmt.cpp +++ b/mapleall/maple_ir/src/mir_parser_stmt.cpp @@ -677,7 +677,11 @@ bool MIRParser::ParseStmtSwitch(StmtNode *&stmt) { Error("expect expression parsing switch but get "); return false; } - if (!IsPrimitiveInteger(opnd0->primType)) { + if (!IsPrimitiveInteger(opnd0->primType) +#ifdef DYNAMICLANG + && opnd0->primType != PTY_dynany +#endif + ) { Error("expect expression return integer but get "); return false; } @@ -738,7 +742,11 @@ bool MIRParser::ParseStmtRangegoto(StmtNode *&stmt) { Error("expect expression parsing rangegoto but get "); return false; } - if (!IsPrimitiveInteger(opnd0->primType)) { + if (!IsPrimitiveInteger(opnd0->primType) +#ifdef DYNAMICLANG + && opnd0->primType != PTY_dynany +#endif + ) { Error("expect expression return integer but get "); return false; } -- Gitee From f06676936cee215d58f3f4ae1c52e69ca1092dd1 Mon Sep 17 00:00:00 2001 From: linma Date: Thu, 25 Feb 2021 20:26:46 -0800 Subject: [PATCH 27/33] change jsintrinsic JSOP_LENGTH return type from I32 to U32 modified: mapleall/maple_ir/include/js2mpl/jsintrinsic.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 2bf62c8..dbd12f8 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -107,7 +107,7 @@ DEF_MIR_INTRINSIC(JS_NEW_ARR_ELEMS,\ DEF_MIR_INTRINSIC(JS_NEW_ARR_LENGTH,\ __js_new_arr_length, INTRNISJS | INTRNNOSIDEEFFECT, kArgTySimpleobj, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_LENGTH,\ - __jsop_length, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT | INTRNISPURE, kArgTyI32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) + __jsop_length, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT | INTRNISPURE, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_NEW_ITERATOR,\ __jsop_valueto_iterator, INTRNISJS, kArgTyPtr, kArgTyDynany, kArgTyU32, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_NEXT_ITERATOR,\ -- Gitee From 89ef9e059cff0d20a8d24ef07981a67f09935553 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Mon, 1 Mar 2021 14:09:15 -0800 Subject: [PATCH 28/33] fix source code is Java/C/C++ and turning on DYNAMICLANG modified: mapleall/maple_be/include/be/switch_lowerer.h modified: mapleall/maple_be/src/be/switch_lowerer.cpp --- mapleall/maple_be/include/be/switch_lowerer.h | 4 ++-- mapleall/maple_be/src/be/switch_lowerer.cpp | 11 +++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mapleall/maple_be/include/be/switch_lowerer.h b/mapleall/maple_be/include/be/switch_lowerer.h index 7f23117..75cb7fe 100644 --- a/mapleall/maple_be/include/be/switch_lowerer.h +++ b/mapleall/maple_be/include/be/switch_lowerer.h @@ -62,12 +62,12 @@ class SwitchLowerer { void FindClusters(MapleVector &); void InitSwitchItems(MapleVector &clusters); RangegotoNode *BuildRangegotoNode(int32 startIdx, int32 endIdx); - CompareNode *BuildCmpNode(Opcode opcode, uint32 idx); + BaseNode *BuildCmpNode(Opcode opcode, uint32 idx); GotoNode *BuildGotoNode(int32 idx); CondGotoNode *BuildCondGotoNode(int32 idx, Opcode opcode, BaseNode *cond); BlockNode *BuildCodeForSwitchItems(int32 start, int32 end, bool lowbndchecked, bool highbndchecked); #ifdef DYNAMICLANG - IntrinsicopNode *BuildSwitchCmpNode(Opcode opcode, uint32 idx); + BaseNode* BuildSwitchCmpNode(Opcode opcode, uint32 idx); #endif }; diff --git a/mapleall/maple_be/src/be/switch_lowerer.cpp b/mapleall/maple_be/src/be/switch_lowerer.cpp index 518642e..f457180 100644 --- a/mapleall/maple_be/src/be/switch_lowerer.cpp +++ b/mapleall/maple_be/src/be/switch_lowerer.cpp @@ -127,8 +127,11 @@ RangegotoNode *SwitchLowerer::BuildRangegotoNode(int32 startIdx, int32 endIdx) { } #ifdef DYNAMICLANG -IntrinsicopNode *SwitchLowerer::BuildSwitchCmpNode(Opcode opcode, uint32 idx) { +BaseNode *SwitchLowerer::BuildSwitchCmpNode(Opcode opcode, uint32 idx) { // CompareNode *binaryExpr = mirModule.CurFuncCodeMemPool()->New(opcode); + if (mirModule.IsJavaModule() || mirModule.IsJavaModule()) { // DYNAMICLANG on is conflicting with Java or C/C++ + return BuildCmpNode(opcode, idx); + } MIRBuilder *mirBuilder = mirModule.mirBuilder; ConstvalNode *op0 = mirBuilder->CreateIntConst((int64)opcode, PTY_u32); BaseNode *op1 = stmt->switchOpnd; @@ -142,7 +145,7 @@ IntrinsicopNode *SwitchLowerer::BuildSwitchCmpNode(Opcode opcode, uint32 idx) { } #endif -CompareNode *SwitchLowerer::BuildCmpNode(Opcode opcode, uint32 idx) { +BaseNode *SwitchLowerer::BuildCmpNode(Opcode opcode, uint32 idx) { CompareNode *binaryExpr = mirModule.CurFuncCodeMemPool()->New(opcode); binaryExpr->primType = PTY_u32; binaryExpr->opndType = stmt->switchOpnd->primType; @@ -188,11 +191,7 @@ BlockNode *SwitchLowerer::BuildCodeForSwitchItems(int32 start, int32 end, bool l CondGotoNode *cgoto = nullptr; RangegotoNode *rangegoto = nullptr; IfStmtNode *ifstmt = nullptr; -#ifdef DYNAMICLANG BaseNode *cmpnode = nullptr; -#else - CompareNode *cmpnode = nullptr; -#endif MIRLower mirlowerer(mirModule, lowerer->GetCurrentFunc()); // if low side starts with a dense item, handle it first while (start <= end && switch_items[start].second != 0) { -- Gitee From 7170658e159d17984a8e37244dc0c85749734793 Mon Sep 17 00:00:00 2001 From: Frederick Chow Date: Tue, 2 Mar 2021 17:43:34 -0800 Subject: [PATCH 29/33] Removed static version of GetFieldType() in mir_nodes.cpp (bug 64) Changed CasePair's case tag from int32 to int64 (bug 63) --- mapleall/maple_ir/include/mir_nodes.h | 2 +- mapleall/maple_ir/include/mir_parser.h | 2 +- mapleall/maple_ir/src/bin_func_import.cpp | 2 +- mapleall/maple_ir/src/mir_nodes.cpp | 46 ++--------------------- mapleall/maple_ir/src/mir_parser_stmt.cpp | 6 +-- mapleall/maple_ir/src/mir_type.cpp | 2 +- 6 files changed, 10 insertions(+), 50 deletions(-) diff --git a/mapleall/maple_ir/include/mir_nodes.h b/mapleall/maple_ir/include/mir_nodes.h index dd30637..c8b8e9f 100644 --- a/mapleall/maple_ir/include/mir_nodes.h +++ b/mapleall/maple_ir/include/mir_nodes.h @@ -1599,7 +1599,7 @@ class CatchNode : public StmtNode { } }; -using CasePair = std::pair; +using CasePair = std::pair; using CaseVector = MapleVector; class SwitchNode : public StmtNode { diff --git a/mapleall/maple_ir/include/mir_parser.h b/mapleall/maple_ir/include/mir_parser.h index 75fba40..5155b64 100644 --- a/mapleall/maple_ir/include/mir_parser.h +++ b/mapleall/maple_ir/include/mir_parser.h @@ -159,7 +159,7 @@ class MIRParser { bool ParseLocStmt(StmtNode *&stmt); bool ParseAlias(StmtNode *&stmt); uint8 *ParseWordsInfo(uint32 size); - bool ParseSwitchCase(int32 &constVal, LabelIdx &lblidx); + bool ParseSwitchCase(int64 &constVal, LabelIdx &lblidx); bool ParseExprOneOperand(BaseNode *&expr); bool ParseExprTwoOperand(BaseNode *&opnd0, BaseNode *&opnd1); bool ParseExprNaryOperand(MapleVector &opndvec); diff --git a/mapleall/maple_ir/src/bin_func_import.cpp b/mapleall/maple_ir/src/bin_func_import.cpp index 9aadcc4..e88c238 100644 --- a/mapleall/maple_ir/src/bin_func_import.cpp +++ b/mapleall/maple_ir/src/bin_func_import.cpp @@ -708,7 +708,7 @@ BlockNode *BinaryMplImport::ImportBlockNode(MIRFunction *func) { s->defaultLabel = ReadNum(); uint32 size = ReadNum(); for (uint32 i = 0; i < size; i++) { - int32 casetag = ReadNum(); + int64 casetag = ReadNum(); LabelIdx lidx(ReadNum()); CasePair cpair = std::make_pair(casetag, lidx); s->switchTable.push_back(cpair); diff --git a/mapleall/maple_ir/src/mir_nodes.cpp b/mapleall/maple_ir/src/mir_nodes.cpp index 5df4f5f..b9a5472 100644 --- a/mapleall/maple_ir/src/mir_nodes.cpp +++ b/mapleall/maple_ir/src/mir_nodes.cpp @@ -1496,51 +1496,11 @@ static inline MIRTypeKind GetPointedTypeKind(TyIdx tyIdx) { return pointedType->GetKind(); } -static bool GetFieldType(const MIRStructType *structType, FieldID targetFid, TyIdx &tid) { - if (structType == nullptr) { - return false; - } - // For Java module class, find targetFid in inheritance chain firstly - if (theModule->IsJavaModule()) { - if (structType->GetKind() == kTypeClass || structType->GetKind() == kTypeClassIncomplete) { - const MIRClassType *classType = static_cast(structType); - std::stack inheritChain; - TyIdx parentTyIdx = classType->parentTyIdx; - while (parentTyIdx.GetIdx() > 0) { - MIRStructType *parentType = - static_cast(GlobalTables::GetTypeTable().GetTypeFromTyIdx(parentTyIdx)); - inheritChain.push(parentType); - parentTyIdx = static_cast(parentType)->parentTyIdx; - } - targetFid -= inheritChain.size(); - while (!inheritChain.empty()) { - MIRClassType *curClassType = static_cast(inheritChain.top()); - if (0 < static_cast(targetFid) && static_cast(targetFid) <= curClassType->fields.size()) { - tid = curClassType->fields.at(targetFid - 1).second.first; - return true; - } else { - targetFid -= curClassType->fields.size(); - } - inheritChain.pop(); - } - if (0 < static_cast(targetFid) && static_cast(targetFid) <= classType->fields.size()) { - tid = classType->fields.at(targetFid - 1).second.first; - return true; - } - } - } - return false; -} - -static MIRTypeKind GetFieldTypeKind(const MIRStructType *structType, FieldID fieldID) { +static MIRTypeKind GetFieldTypeKind(MIRStructType *structType, FieldID fieldID) { TyIdx fieldTyIdx; if (fieldID > 0) { - bool isValid = GetFieldType(structType, fieldID, fieldTyIdx); - // when mpl does not have complete class info - if (!isValid) { - LogInfo::MapleLogger() << "\n#Error:field not found, must have complete class info\n"; - return kTypeInvalid; - } + MIRType *mirType = structType->GetFieldType(fieldID); + fieldTyIdx = mirType->GetTypeIndex(); } else { ASSERT(static_cast(-fieldID) < structType->parentFields.size() + 1, "array index out of range"); fieldTyIdx = structType->parentFields.at(-fieldID - 1).second.first; diff --git a/mapleall/maple_ir/src/mir_parser_stmt.cpp b/mapleall/maple_ir/src/mir_parser_stmt.cpp index 74cd015..61d14f0 100644 --- a/mapleall/maple_ir/src/mir_parser_stmt.cpp +++ b/mapleall/maple_ir/src/mir_parser_stmt.cpp @@ -637,7 +637,7 @@ bool MIRParser::ParseStmtBr(StmtNode *&stmt) { return true; } -bool MIRParser::ParseSwitchCase(int32 &constVal, LabelIdx &lblidx) { +bool MIRParser::ParseSwitchCase(int64 &constVal, LabelIdx &lblidx) { // syntax : goto if (lexer.GetTokenKind() != TK_intconst) { Error("expect intconst in switch but get "); @@ -711,7 +711,7 @@ bool MIRParser::ParseStmtSwitch(StmtNode *&stmt) { MapleVector &switchTable = switchnode->switchTable; std::set casesSet; while (tk != TK_rbrace) { - int32 constVal = 0; + int64 constVal = 0; LabelIdx lbl = 0; if (!ParseSwitchCase(constVal, lbl)) { Error("parse switch case failed "); @@ -778,7 +778,7 @@ bool MIRParser::ParseStmtRangegoto(StmtNode *&stmt) { int32 minidx = MAXUINT16; int32 maxidx = 0; while (tk != TK_rbrace) { - int32 constVal = 0; + int64 constVal = 0; LabelIdx lbl = 0; if (!ParseSwitchCase(constVal, lbl)) { Error("parse switch case failed "); diff --git a/mapleall/maple_ir/src/mir_type.cpp b/mapleall/maple_ir/src/mir_type.cpp index fb2cab4..324dabc 100644 --- a/mapleall/maple_ir/src/mir_type.cpp +++ b/mapleall/maple_ir/src/mir_type.cpp @@ -1377,7 +1377,7 @@ MIRType *MIRStructType::GetFieldType(FieldID fieldID) { if (fieldID == 0) { return this; } - FieldPair fldpair = TraverseToField(fieldID); + FieldPair fldpair = TraverseToFieldRef(fieldID); return GlobalTables::GetTypeTable().GetTypeFromTyIdx(fldpair.second.first); } -- Gitee From df86d5f7affc867abee84d9d5515ac383c611f6c Mon Sep 17 00:00:00 2001 From: Frederick Chow Date: Tue, 2 Mar 2021 19:48:44 -0800 Subject: [PATCH 30/33] Fixed typo that prevents C from working --- mapleall/maple_be/src/be/switch_lowerer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_be/src/be/switch_lowerer.cpp b/mapleall/maple_be/src/be/switch_lowerer.cpp index f457180..0833042 100644 --- a/mapleall/maple_be/src/be/switch_lowerer.cpp +++ b/mapleall/maple_be/src/be/switch_lowerer.cpp @@ -129,7 +129,7 @@ RangegotoNode *SwitchLowerer::BuildRangegotoNode(int32 startIdx, int32 endIdx) { #ifdef DYNAMICLANG BaseNode *SwitchLowerer::BuildSwitchCmpNode(Opcode opcode, uint32 idx) { // CompareNode *binaryExpr = mirModule.CurFuncCodeMemPool()->New(opcode); - if (mirModule.IsJavaModule() || mirModule.IsJavaModule()) { // DYNAMICLANG on is conflicting with Java or C/C++ + if (mirModule.IsJavaModule() || mirModule.IsCModule()) { // DYNAMICLANG on is conflicting with Java or C/C++ return BuildCmpNode(opcode, idx); } MIRBuilder *mirBuilder = mirModule.mirBuilder; -- Gitee From 066ea111508881edc9f556afff3a3de6dd2c9563 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Wed, 10 Mar 2021 15:24:59 -0800 Subject: [PATCH 31/33] Add strict mode info when generating Maple Engine code for Maple JavaScript. modified: mapleall/maple_be/include/cg/ark/ark_mir_emit.h modified: mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp --- mapleall/maple_be/include/cg/ark/ark_mir_emit.h | 6 +++++- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h index 4cf4445..d5d6948 100644 --- a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h +++ b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h @@ -219,7 +219,8 @@ enum RE_FuncAttr { FuncAttrWeak = 1 << 0, FuncAttrFinalize = 1 << 1, FuncAttrStatic = 1 << 2, - FuncAttrConstructor = 1 << 3 + FuncAttrConstructor = 1 << 3, + FuncAttrJSStrict = 1 << 4 }; class RE_Func { @@ -275,6 +276,9 @@ class RE_Func { void SetConstructorAttr() { funcAttrs |= FuncAttrConstructor; } + void SetJSStrictAttr() { + funcAttrs |= FuncAttrJSStrict; + } void AddFormalPreg(int pregno) { formalPregs[pregno] = 1+numFormalArgs++; } diff --git a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp index 6384687..4a212a8 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -1159,6 +1159,8 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { if (func->IsStatic()) curFunc.SetStaticAttr(); if (func->IsConstructor()) curFunc.SetConstructorAttr(); if (GlobalTables::GetStrTable().GetStringFromStrIdx(func->GetBaseFuncNameStridx()) == "finalize") curFunc.SetFinalizeAttr(); + } else { + if (func->GetAttr(FUNCATTR_strict)) curFunc.SetJSStrictAttr(); } curFunc.evalStackDepth = MaxEvalStack(func); // insert interpreter shim and signature @@ -1169,7 +1171,7 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { int formalsBlkBitVectBytes = BlkSize2BitvectorSize(func->upFormalSize); int localsBlkBitVectBytes = BlkSize2BitvectorSize(func->frameSize); - os << "\t" << ".word " << func->upFormalSize << ", " << func->frameSize << ", " << curFunc.evalStackDepth << ", " << 0 << "\t// upFormalSize, frameSize, evalStackDepth\n"; + os << "\t" << ".word " << func->upFormalSize << ", " << func->frameSize << ", " << curFunc.evalStackDepth << ", " << curFunc.funcAttrs << "\t// upFormalSize, frameSize, evalStackDepth, funcAttrs\n"; os << "\t" << ".word " << formalsBlkBitVectBytes << ", " << localsBlkBitVectBytes << "\t\t// formalWords bit vector byte count, localWords bit vector byte count\n"; if (formalsBlkBitVectBytes) { EmitBytesCommentOffset(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged", 0); -- Gitee From 43f8b549795b97563d47ac9952d321c98f997ab3 Mon Sep 17 00:00:00 2001 From: linma Date: Sat, 27 Mar 2021 14:40:16 -0700 Subject: [PATCH 32/33] change return type of __jsop_length to dynany --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index dbd12f8..16a8b07 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -107,7 +107,7 @@ DEF_MIR_INTRINSIC(JS_NEW_ARR_ELEMS,\ DEF_MIR_INTRINSIC(JS_NEW_ARR_LENGTH,\ __js_new_arr_length, INTRNISJS | INTRNNOSIDEEFFECT, kArgTySimpleobj, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_LENGTH,\ - __jsop_length, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT | INTRNISPURE, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) + __jsop_length, INTRNISJS | INTRNLOADMEM | INTRNNOSIDEEFFECT | INTRNISPURE, kArgTyDynany, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_NEW_ITERATOR,\ __jsop_valueto_iterator, INTRNISJS, kArgTyPtr, kArgTyDynany, kArgTyU32, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JSOP_NEXT_ITERATOR,\ -- Gitee From daa026eefc95521d1b55024b8eda5ce7a40aa38c Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Tue, 30 Mar 2021 17:24:31 -0700 Subject: [PATCH 33/33] Add build options and settings for building js2mpl and mplbe_js for Maple JavaScript. modified: Makefile modified: build/config/BUILDCONFIG.gn --- Makefile | 21 +++++++++++++++++++++ build/config/BUILDCONFIG.gn | 1 + 2 files changed, 22 insertions(+) diff --git a/Makefile b/Makefile index 45a511d..eb4864a 100644 --- a/Makefile +++ b/Makefile @@ -64,6 +64,22 @@ GN_OPTIONS := \ TARGET="$(TARGET)" \ X86=1 +GN_OPTIONS_MPLJS := \ + GN_INSTALL_PREFIX="$(MAPLE_ROOT)" \ + GN_BUILD_TYPE="$(BUILD_TYPE_OP)" \ + USE_CLANG=$(USE_CLANG_OP) \ + HOST_ARCH=$(HOST_ARCH_OP) \ + JAVA=0 \ + USE_ZRT=$(USE_ZRT) \ + DEFERRAL_RC="$(DEFERRAL_RC)" \ + STRICT_NAIVE_RC="$(STRICT_NAIVE_RC)" \ + RC_TESTING="$(RC_TESTING)" \ + USE_MALLOC="$(USE_MALLOC)" \ + COV_CHECK=$(COV_CHECK) \ + PLATFORM_SDK_VERSION=27 \ + TARGET="vm" \ + X86=1 + .PHONY: default default: mapleall @@ -79,6 +95,11 @@ js2mpl: mplbe: $(call build_gn, ${GN_OPTIONS}, mplbe) +.PHONY: mplbe_js +mplbe_js: + $(call build_gn, ${GN_OPTIONS_MPLJS}, mplbe) + mv ${OUTPUT_BIN_DIR}/mplbe ${OUTPUT_BIN_DIR}/mplbe_js + .PHONY: install install: mapleall $(shell mkdir -p ${MAPLE_ROOT}/bin; \ diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index a53f631..564fb41 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -45,6 +45,7 @@ if (IS_JS2MPL_EXISTS == "1") { JAVA = 0 TARGET = "vm" JAVA_OP = 0 + USE_CLANG = 0 } DYNAMICLANG = true RC_V2 = true -- Gitee