From 33e1796616366d4aff1d12615507815eb195e5d0 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Mon, 21 Sep 2020 14:30:29 -0700 Subject: [PATCH 01/19] [MapleJS] Initial mplcg code generator for Maple Engine JS. modified: maple_engine/include/mre_opcodes.def modified: mapleall/maple_be/include/cg/ark/ark_mir_emit.h modified: mapleall/maple_be/src/cg/ark/ark_emit.cpp modified: mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp modified: mapleall/maple_be/src/cg/cg_driver.cpp --- maple_engine/include/mre_opcodes.def | 3 + .../maple_be/include/cg/ark/ark_mir_emit.h | 3 +- mapleall/maple_be/src/cg/ark/ark_emit.cpp | 4 +- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 71 ++++++++++++++++--- mapleall/maple_be/src/cg/cg_driver.cpp | 5 +- 5 files changed, 73 insertions(+), 13 deletions(-) diff --git a/maple_engine/include/mre_opcodes.def b/maple_engine/include/mre_opcodes.def index ea5bae1..804fc57 100644 --- a/maple_engine/include/mre_opcodes.def +++ b/maple_engine/include/mre_opcodes.def @@ -22,3 +22,6 @@ OPCODE(brtrue32, none, none, none) OPCODE(brfalse32, none, none, none) OPCODE(goto32, none, none, none) + OPCODE(ireadfpoff32, none, none, none) + OPCODE(iassignfpoff32, none, none, none) + 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 d07de81..a3a8c90 100644 --- a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h +++ b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h @@ -353,7 +353,7 @@ class MirGenerator : public CmplGenerator { void EmitAsmCall(CallNode *fstmt); void EmitAsmComment(CommentNode *comment); void EmitBytes(uint8 *b, int count); - void EmitBytesComment(uint8 *b, int count, string &comment); + void EmitBytesComment(uint8 *b, int count, const string &comment); void EmitAsmShort(uint16 s); void EmitAsmWord(uint32 word); void EmitAsmWord(uint32 word, string comment); @@ -370,6 +370,7 @@ class MirGenerator : public CmplGenerator { void EmitString(const std::string &str, int bytes); void EmitStringNoTab(const std::string &str, int bytes); void EmitYieldPoint(void); + void EmitGlobalDecl(void); void CheckYieldPointInsert(StmtNode *fstmt); int GetFormalsInfo(MIRFunction *func); int GetLocalsInfo(MIRFunction *func); diff --git a/mapleall/maple_be/src/cg/ark/ark_emit.cpp b/mapleall/maple_be/src/cg/ark/ark_emit.cpp index 93f62d6..accf738 100644 --- a/mapleall/maple_be/src/cg/ark/ark_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_emit.cpp @@ -195,7 +195,7 @@ void ArkCGFunc::Emit() { // nothing } else { emitter.Emit("\t.globl\t").Emit(funcSt->GetName()).Emit("\n"); - emitter.Emit("\t.hidden\t").Emit(funcSt->GetName()).Emit("\n"); +// emitter.Emit("\t.hidden\t").Emit(funcSt->GetName()).Emit("\n"); } emitter.Emit("\t.type\t").Emit(funcSt->GetName()).Emit(", %function\n"); @@ -207,7 +207,7 @@ void ArkCGFunc::Emit() { emitter.Emit("\t// mir2bin func begin: ========================\n"); emitter.Emit("\t.cfi_startproc\n"); - emitter.Emit("\t.cfi_personality 155, DW.ref.__mpl_personality_v0\n"); +// emitter.Emit("\t.cfi_personality 155, DW.ref.__mpl_personality_v0\n"); emitter.mirg_->EmitFunc(cg->curCgFunc->func); emitter.Emit("\t.cfi_endproc\n"); emitter.Emit(".label.end."+funcSt->GetName()+":\n"); 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 be2da39..3b660a1 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -282,7 +282,7 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - expr.param.frameIdx = curFunc.EncodePreg(preg->pregNo); + expr.param.frameIdx = preg->pregNo; EmitAsmBaseNode(expr, regName); // check for regread of less than 4 bytes CheckInsertOpCvt(curOp, curPrimType, fexpr->primType); @@ -302,6 +302,19 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) } break; } + case OP_ireadfpoff: { + int32 offset = static_cast(fexpr)->offset; + // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr + if (offset <= 32767 && offset >= -32768) { + expr.param.offset = offset; + EmitAsmBaseNode(expr); + } else { + expr.op = RE_ireadfpoff32; + EmitAsmBaseNode(expr); + EmitAsmWord(offset); + } + break; + } case OP_select: FlattenExpr(fexpr); // no extra fields to handle @@ -473,6 +486,20 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { } break; } + case OP_iassignfpoff: { + int32 offset = static_cast(fstmt)->offset; + FlattenExpr(fstmt); + // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr + if (offset <= 32767 && offset >= -32768) { + stmt.param.offset = offset; + EmitAsmBaseNode(stmt); + } else { + stmt.op = RE_iassignfpoff32; + EmitAsmBaseNode(stmt); + EmitAsmWord(offset); + } + break; + } case OP_regassign: { string regName; FlattenExpr(fstmt); @@ -480,7 +507,7 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - stmt.param.frameIdx = curFunc.EncodePreg(preg->pregNo); + stmt.param.frameIdx = preg->pregNo; EmitAsmBaseNode(stmt, regName); break; } @@ -1079,21 +1106,35 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { //printf("func %d \n", func->puIdxOrigin); curFunc.Init(func); +/* curFunc.numFormalArgs = GetFormalsInfo(func); curFunc.numAutoVars = GetLocalsInfo(func) + 2; // incl. %%retval0 and %%thrownval +*/ curFunc.evalStackDepth = MaxEvalStack(func); - +/* if (func->IsWeak()) curFunc.SetWeakAttr(); if (func->IsStatic()) curFunc.SetStaticAttr(); if (func->IsConstructor()) curFunc.SetConstructorAttr(); if (GlobalTables::GetStrTable().GetStringFromStrIdx(func->GetBaseFuncNameStridx()) == "finalize") curFunc.SetFinalizeAttr(); - +*/ // insert interpreter shim and signature - os << "\t.ascii \"MPLI\"\n"; + int formalsBlkBitVectBytes = BlkSize2BitvectorSize(func->upFormalSize); + int localsBlkBitVectBytes = BlkSize2BitvectorSize(func->frameSize); + os << "\t.ascii \"MPJS\"\n"; os << infoLabel << ":\n"; os << "\t" << ".long " << codeLabel << " - .\n"; - os << "\t" << ".word " << curFunc.numFormalArgs << ", " << curFunc.numAutoVars << ", " << curFunc.evalStackDepth << ", " << curFunc.funcAttrs << " // func storage info\n"; + os << "\t" << ".word " << func->upFormalSize << ", " << func->frameSize << ", " << curFunc.evalStackDepth << ", " << 0 << "\t// upFormalSize, frameSize, evalStackDepth\n"; + os << "\t" << ".word " << formalsBlkBitVectBytes << ", " << localsBlkBitVectBytes << "\t\t// formalWords bit vector byte count, localWords bit vector byte count\n"; + if (formalsBlkBitVectBytes) { + EmitBytesComment(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged"); + EmitBytesComment(func->formalWordsRefCounted, formalsBlkBitVectBytes, "// formalWordsRefCounted"); + } + if (localsBlkBitVectBytes) { + EmitBytesComment(func->localWordsTypeTagged, localsBlkBitVectBytes, "// localWordsTypeTagged"); + EmitBytesComment(func->localWordsRefCounted, localsBlkBitVectBytes, "// localWordsRefCounted"); + } +/* if (curFunc.numFormalArgs) { os << "\t" << "// PrimType of formal arguments\n"; } @@ -1116,11 +1157,25 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { os << "\t// ALIAS %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.first) << " %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.second.memPoolStrIdx) << "\n"; } - +*/ os << "\t.p2align 1\n"; os << codeLabel << ":\n"; } +void MirGenerator::EmitGlobalDecl(void) { + os << "\t.section\t.rodata\n"; + os << "\t.p2align 3\n"; + os << "\t.global __mpljs_module_decl__\n"; + os << "__mpljs_module_decl__:\n"; + os << "\t.word " << mmodule.globalMemSize << "\t// globalMemSize byte count\n"; + if (mmodule.globalMemSize) { + EmitBytesComment(mmodule.globalBlkMap, mmodule.globalMemSize, "\t// globalMemMap");; + os << "\t.word " << BlkSize2BitvectorSize(mmodule.globalMemSize) << "\t// globalwordstypetagged/refcounted byte count\n"; + EmitBytesComment(mmodule.globalWordsTypeTagged, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordstypetagged"); + EmitBytesComment(mmodule.globalWordsRefCounted, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordsrefcounted"); + } +} + void MirGenerator::EmitAsmBaseNode(mre_instr_t &m) { std::stringstream ss1, ss2; base_node_t *b = m.bn(); @@ -1158,7 +1213,7 @@ void MirGenerator::EmitBytes(uint8 *b, int count) { EmitString(ss.str(), count); } -void MirGenerator::EmitBytesComment(uint8 *b, int count, string &comment) { +void MirGenerator::EmitBytesComment(uint8 *b, int count, const string &comment) { stringstream ss; ss << ".byte "; for (int i=0; ibecommon; thecg.emitter_ = themodule->memPool->New(&thecg, output); @@ -200,6 +200,7 @@ int main(int argc, char **argv) { for (int i = 3; i < kREOpLast; ++i) { thecg.emitter_->Emit(string("OP_")+RE_OpName[i]+" = "+to_string(i)+"\n"); } + mirGen->EmitGlobalDecl(); // load profile info for class meta data - uses same binary metadata profile (meta.list) as mpl2mpl uint32 javaNameIdx = themodule->GetFileinfo(GlobalTables::GetStrTable().GetOrCreateStrIdxFromName("INFO_filename")); -- Gitee From 956dfad22667af04889c198a79deb1ac9300b5dd Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Mon, 21 Sep 2020 17:02:08 -0700 Subject: [PATCH 02/19] [MapleJS] Maple Engine code generator use srcLang type of input file at runtime to determine whether to generate Maple Engine code for Java, C, or Javascript. modified: maple_be/src/cg/ark/ark_emit.cpp modified: maple_be/src/cg/ark/ark_mir_emit.cpp modified: maple_be/src/cg/cg_driver.cpp modified: maple_ir/include/mir_module.h --- mapleall/maple_be/src/cg/ark/ark_emit.cpp | 8 +- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 110 ++++++++++-------- mapleall/maple_be/src/cg/cg_driver.cpp | 18 ++- mapleall/maple_ir/include/mir_module.h | 4 + 4 files changed, 84 insertions(+), 56 deletions(-) diff --git a/mapleall/maple_be/src/cg/ark/ark_emit.cpp b/mapleall/maple_be/src/cg/ark/ark_emit.cpp index accf738..905a119 100644 --- a/mapleall/maple_be/src/cg/ark/ark_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_emit.cpp @@ -195,7 +195,9 @@ void ArkCGFunc::Emit() { // nothing } else { emitter.Emit("\t.globl\t").Emit(funcSt->GetName()).Emit("\n"); -// emitter.Emit("\t.hidden\t").Emit(funcSt->GetName()).Emit("\n"); + if (!func->module->IsJsModule()) { + emitter.Emit("\t.hidden\t").Emit(funcSt->GetName()).Emit("\n"); + } } emitter.Emit("\t.type\t").Emit(funcSt->GetName()).Emit(", %function\n"); @@ -207,7 +209,9 @@ void ArkCGFunc::Emit() { emitter.Emit("\t// mir2bin func begin: ========================\n"); emitter.Emit("\t.cfi_startproc\n"); -// emitter.Emit("\t.cfi_personality 155, DW.ref.__mpl_personality_v0\n"); + if (!func->module->IsJsModule()) { + emitter.Emit("\t.cfi_personality 155, DW.ref.__mpl_personality_v0\n"); + } emitter.mirg_->EmitFunc(cg->curCgFunc->func); emitter.Emit("\t.cfi_endproc\n"); emitter.Emit(".label.end."+funcSt->GetName()+":\n"); 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 3b660a1..7023d02 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -282,7 +282,11 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - expr.param.frameIdx = preg->pregNo; + if (curFunc.func->module->IsJsModule()) { + expr.param.frameIdx = preg->pregNo; + } else { + expr.param.frameIdx = curFunc.EncodePreg(preg->pregNo); + } EmitAsmBaseNode(expr, regName); // check for regread of less than 4 bytes CheckInsertOpCvt(curOp, curPrimType, fexpr->primType); @@ -303,6 +307,7 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) break; } case OP_ireadfpoff: { + ASSERT(curFunc.func->module->IsJsModule(), "OP_ireadfpoff in non Maple JS input"); int32 offset = static_cast(fexpr)->offset; // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr if (offset <= 32767 && offset >= -32768) { @@ -487,6 +492,7 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { break; } case OP_iassignfpoff: { + ASSERT(curFunc.func->module->IsJsModule(), "OP_iassignfpoff in non Maple JS input"); int32 offset = static_cast(fstmt)->offset; FlattenExpr(fstmt); // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr @@ -507,7 +513,11 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - stmt.param.frameIdx = preg->pregNo; + if (curFunc.func->module->IsJsModule()) { + stmt.param.frameIdx = preg->pregNo; + } else { + stmt.param.frameIdx = curFunc.EncodePreg(preg->pregNo); + } EmitAsmBaseNode(stmt, regName); break; } @@ -1106,58 +1116,62 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { //printf("func %d \n", func->puIdxOrigin); curFunc.Init(func); -/* - curFunc.numFormalArgs = GetFormalsInfo(func); - curFunc.numAutoVars = GetLocalsInfo(func) + 2; // incl. %%retval0 and %%thrownval -*/ + if (!curFunc.func->module->IsJsModule()) { + curFunc.numFormalArgs = GetFormalsInfo(func); + curFunc.numAutoVars = GetLocalsInfo(func) + 2; // incl. %%retval0 and %%thrownval + if (func->IsWeak()) curFunc.SetWeakAttr(); + if (func->IsStatic()) curFunc.SetStaticAttr(); + if (func->IsConstructor()) curFunc.SetConstructorAttr(); + if (GlobalTables::GetStrTable().GetStringFromStrIdx(func->GetBaseFuncNameStridx()) == "finalize") curFunc.SetFinalizeAttr(); + } curFunc.evalStackDepth = MaxEvalStack(func); -/* - if (func->IsWeak()) curFunc.SetWeakAttr(); - if (func->IsStatic()) curFunc.SetStaticAttr(); - if (func->IsConstructor()) curFunc.SetConstructorAttr(); - if (GlobalTables::GetStrTable().GetStringFromStrIdx(func->GetBaseFuncNameStridx()) == "finalize") curFunc.SetFinalizeAttr(); -*/ // insert interpreter shim and signature - int formalsBlkBitVectBytes = BlkSize2BitvectorSize(func->upFormalSize); - int localsBlkBitVectBytes = BlkSize2BitvectorSize(func->frameSize); - os << "\t.ascii \"MPJS\"\n"; - os << infoLabel << ":\n"; - os << "\t" << ".long " << codeLabel << " - .\n"; - os << "\t" << ".word " << func->upFormalSize << ", " << func->frameSize << ", " << curFunc.evalStackDepth << ", " << 0 << "\t// upFormalSize, frameSize, evalStackDepth\n"; - os << "\t" << ".word " << formalsBlkBitVectBytes << ", " << localsBlkBitVectBytes << "\t\t// formalWords bit vector byte count, localWords bit vector byte count\n"; - if (formalsBlkBitVectBytes) { - EmitBytesComment(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged"); - EmitBytesComment(func->formalWordsRefCounted, formalsBlkBitVectBytes, "// formalWordsRefCounted"); - } - if (localsBlkBitVectBytes) { - EmitBytesComment(func->localWordsTypeTagged, localsBlkBitVectBytes, "// localWordsTypeTagged"); - EmitBytesComment(func->localWordsRefCounted, localsBlkBitVectBytes, "// localWordsRefCounted"); - } + if (curFunc.func->module->IsJsModule()) { + os << "\t.ascii \"MPJS\"\n"; + os << infoLabel << ":\n"; + os << "\t" << ".long " << codeLabel << " - .\n"; + + 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 " << formalsBlkBitVectBytes << ", " << localsBlkBitVectBytes << "\t\t// formalWords bit vector byte count, localWords bit vector byte count\n"; + if (formalsBlkBitVectBytes) { + EmitBytesComment(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged"); + EmitBytesComment(func->formalWordsRefCounted, formalsBlkBitVectBytes, "// formalWordsRefCounted"); + } + if (localsBlkBitVectBytes) { + EmitBytesComment(func->localWordsTypeTagged, localsBlkBitVectBytes, "// localWordsTypeTagged"); + EmitBytesComment(func->localWordsRefCounted, localsBlkBitVectBytes, "// localWordsRefCounted"); + } + } else { + os << "\t.ascii \"MPLI\"\n"; + os << infoLabel << ":\n"; + os << "\t" << ".long " << codeLabel << " - .\n"; -/* - if (curFunc.numFormalArgs) { - os << "\t" << "// PrimType of formal arguments\n"; - } - EmitAsmFormalArgInfo(func); - if (curFunc.numAutoVars) { - os << "\t" << "// PrimType of automatic variables\n"; - } - EmitAsmAutoVarsInfo(func); + if (curFunc.numFormalArgs) { + os << "\t" << "// PrimType of formal arguments\n"; + } + EmitAsmFormalArgInfo(func); + if (curFunc.numAutoVars) { + os << "\t" << "// PrimType of automatic variables\n"; + } + EmitAsmAutoVarsInfo(func); - if (curFunc.numFormalArgs) { - os << "\t" << "// Name of formal arguments\n"; - } - EmitAsmFormalArgNameInfo(func); - if (curFunc.numAutoVars) { - os << "\t" << "// Name of automatic variables\n"; - } - EmitAsmAutoVarsNameInfo(func); + if (curFunc.numFormalArgs) { + os << "\t" << "// Name of formal arguments\n"; + } + EmitAsmFormalArgNameInfo(func); + if (curFunc.numAutoVars) { + os << "\t" << "// Name of automatic variables\n"; + } + EmitAsmAutoVarsNameInfo(func); - for (std::pair it : curFunc.func->aliasVarMap) { - os << "\t// ALIAS %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.first) << " %" - << GlobalTables::GetStrTable().GetStringFromStrIdx(it.second.memPoolStrIdx) << "\n"; + for (std::pair it : curFunc.func->aliasVarMap) { + os << "\t// ALIAS %" << GlobalTables::GetStrTable().GetStringFromStrIdx(it.first) << " %" + << GlobalTables::GetStrTable().GetStringFromStrIdx(it.second.memPoolStrIdx) << "\n"; + } } -*/ + os << "\t.p2align 1\n"; os << codeLabel << ":\n"; } diff --git a/mapleall/maple_be/src/cg/cg_driver.cpp b/mapleall/maple_be/src/cg/cg_driver.cpp index b3f0b2a..6db0456 100644 --- a/mapleall/maple_be/src/cg/cg_driver.cpp +++ b/mapleall/maple_be/src/cg/cg_driver.cpp @@ -177,10 +177,15 @@ int main(int argc, char **argv) { } if (cgoption.run_cg_flag) { -/* - // 1. LowerIR. - thecg.LowerIR(); -*/ +#if TARGARK + if (!themodule->IsJsModule()) { +#endif + // 1. LowerIR. + thecg.LowerIR(); +#if TARGARK + } +#endif + // 2. Generate the output file BECommon &becommon = *g->becommon; thecg.emitter_ = themodule->memPool->New(&thecg, output); @@ -200,8 +205,9 @@ int main(int argc, char **argv) { for (int i = 3; i < kREOpLast; ++i) { thecg.emitter_->Emit(string("OP_")+RE_OpName[i]+" = "+to_string(i)+"\n"); } - mirGen->EmitGlobalDecl(); - + if (themodule->IsJsModule()) { + mirGen->EmitGlobalDecl(); + } // load profile info for class meta data - uses same binary metadata profile (meta.list) as mpl2mpl uint32 javaNameIdx = themodule->GetFileinfo(GlobalTables::GetStrTable().GetOrCreateStrIdxFromName("INFO_filename")); const std::string &javaName = GlobalTables::GetStrTable().GetStringFromStrIdx(GStrIdx(javaNameIdx)); diff --git a/mapleall/maple_ir/include/mir_module.h b/mapleall/maple_ir/include/mir_module.h index 9001649..1f5dd23 100644 --- a/mapleall/maple_ir/include/mir_module.h +++ b/mapleall/maple_ir/include/mir_module.h @@ -240,6 +240,10 @@ class MIRModule : public mir_module_t { return srcLang == kSrcLangC || srcLang == kSrcLangCPlusPlus; } + bool IsJsModule() const { + return srcLang == kSrcLangJs; + } + void ReleaseCurFuncMpTmp(); inline void SetUseFuncCodeMpTmp() { useFuncCodeMpTmp = true; -- Gitee From 99de473d5a10fc03d8251a27d2f0ff2af9d84f02 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Tue, 22 Sep 2020 10:53:20 -0700 Subject: [PATCH 03/19] [MapleJS] Code cleanup modified: ../../include/cg/ark/ark_mir_emit.h modified: ark/ark_mir_emit.cpp modified: cg_driver.cpp --- .../maple_be/include/cg/ark/ark_mir_emit.h | 2 + mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 40 ++++++++++++++----- mapleall/maple_be/src/cg/cg_driver.cpp | 9 +---- 3 files changed, 33 insertions(+), 18 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 a3a8c90..fca5203 100644 --- a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h +++ b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h @@ -370,7 +370,9 @@ class MirGenerator : public CmplGenerator { void EmitString(const std::string &str, int bytes); void EmitStringNoTab(const std::string &str, int bytes); void EmitYieldPoint(void); + void EmitModuleInfo(void); void EmitGlobalDecl(void); + void EmitOpCodes(void); void CheckYieldPointInsert(StmtNode *fstmt); int GetFormalsInfo(MIRFunction *func); int GetLocalsInfo(MIRFunction *func); 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 7023d02..ef108a1 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -30,6 +30,8 @@ #include #define CLANG (mmodule.IsCModule()) +#define JAVALANG (mmodule.IsJavaModule()) +#define JAVASCRIPT (mmodule.IsJsModule()) using std::hex; @@ -119,13 +121,13 @@ std::set PreDefClassInfo = { // TODO: add memcmpMpl to list when we have x86 replacement. // NOTE: IntrinsicList is moved to special_func.cpp -inline void MirGenerator::EmitString(const std::string &str, int bytes) { +inline void MirGenerator::EmitString(const std::string &str, int bytes=0) { int offset = GetFuncOffset(); os << "\t" << str << "\n"; SetFuncOffset(offset + bytes); } -inline void MirGenerator::EmitStringNoTab(const std::string &str, int bytes) { +inline void MirGenerator::EmitStringNoTab(const std::string &str, int bytes=0) { int offset = GetFuncOffset(); os << str << "\n"; SetFuncOffset(offset + bytes); @@ -282,7 +284,7 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - if (curFunc.func->module->IsJsModule()) { + if (JAVASCRIPT) { expr.param.frameIdx = preg->pregNo; } else { expr.param.frameIdx = curFunc.EncodePreg(preg->pregNo); @@ -307,7 +309,7 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) break; } case OP_ireadfpoff: { - ASSERT(curFunc.func->module->IsJsModule(), "OP_ireadfpoff in non Maple JS input"); + ASSERT(JAVASCRIPT, "OP_ireadfpoff in non Maple JS input"); int32 offset = static_cast(fexpr)->offset; // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr if (offset <= 32767 && offset >= -32768) { @@ -492,7 +494,7 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { break; } case OP_iassignfpoff: { - ASSERT(curFunc.func->module->IsJsModule(), "OP_iassignfpoff in non Maple JS input"); + ASSERT(JAVASCRIPT, "OP_iassignfpoff in non Maple JS input"); int32 offset = static_cast(fstmt)->offset; FlattenExpr(fstmt); // generate 4 byte instr if offset fits in 16 bits else generate 8 byte instr @@ -513,7 +515,7 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { ASSERT(preg, "preg is null"); regName.append("%"); regName.append(std::to_string(preg->pregNo)); - if (curFunc.func->module->IsJsModule()) { + if (JAVASCRIPT) { stmt.param.frameIdx = preg->pregNo; } else { stmt.param.frameIdx = curFunc.EncodePreg(preg->pregNo); @@ -1116,7 +1118,7 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { //printf("func %d \n", func->puIdxOrigin); curFunc.Init(func); - if (!curFunc.func->module->IsJsModule()) { + if (!JAVASCRIPT) { curFunc.numFormalArgs = GetFormalsInfo(func); curFunc.numAutoVars = GetLocalsInfo(func) + 2; // incl. %%retval0 and %%thrownval if (func->IsWeak()) curFunc.SetWeakAttr(); @@ -1126,7 +1128,7 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { } curFunc.evalStackDepth = MaxEvalStack(func); // insert interpreter shim and signature - if (curFunc.func->module->IsJsModule()) { + if (JAVASCRIPT) { os << "\t.ascii \"MPJS\"\n"; os << infoLabel << ":\n"; os << "\t" << ".long " << codeLabel << " - .\n"; @@ -1176,6 +1178,23 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { os << codeLabel << ":\n"; } +void MirGenerator::EmitModuleInfo(void) { + EmitOpCodes(); + if (JAVASCRIPT) { + EmitGlobalDecl(); + } +} + +void MirGenerator::EmitOpCodes(void) { + // gen opcodes - skip entry 0 (kOpUndef) and handle duplicate name (OP_dassign, OP_maydassign) + EmitStringNoTab("\nOP_dassign = 1"); + EmitStringNoTab("OP_maydassign = 2"); + for (int i = 3; i < kREOpLast; ++i) { + EmitStringNoTab(string("OP_")+RE_OpName[i]+" = "+to_string(i)); + } + EmitStringNoTab(""); +} + void MirGenerator::EmitGlobalDecl(void) { os << "\t.section\t.rodata\n"; os << "\t.p2align 3\n"; @@ -1421,14 +1440,13 @@ void MirGenerator::EmitAsmConststr(UStrIdx strIdx) { } RE_Opcode MirGenerator::MapEHOpcode(RE_Opcode op) { - MIRModule *module = GetCurFunction()->module; - if (module->IsCModule()) { + if (CLANG) { if (op == RE_catch) { op = RE_cppcatch; } else if (op == RE_try) { op = RE_cpptry; } - } else if (module->IsJavaModule()) { + } else if (JAVALANG) { if (op == RE_catch) { op = RE_javacatch; } else if (op == RE_try) { diff --git a/mapleall/maple_be/src/cg/cg_driver.cpp b/mapleall/maple_be/src/cg/cg_driver.cpp index 6db0456..4cff699 100644 --- a/mapleall/maple_be/src/cg/cg_driver.cpp +++ b/mapleall/maple_be/src/cg/cg_driver.cpp @@ -177,10 +177,10 @@ int main(int argc, char **argv) { } if (cgoption.run_cg_flag) { + // 1. LowerIR. #if TARGARK if (!themodule->IsJsModule()) { #endif - // 1. LowerIR. thecg.LowerIR(); #if TARGARK } @@ -199,12 +199,7 @@ int main(int argc, char **argv) { mirGen->OutputMIR(cgoption.genMirMpl); thecg.emitter_->mirg_ = mirGen; - // gen opcodes - skip entry 0 (kOpUndef) and handle duplicate name (OP_dassign, OP_maydassign) - thecg.emitter_->Emit("\nOP_dassign = 1\n"); - thecg.emitter_->Emit("OP_maydassign = 2\n"); - for (int i = 3; i < kREOpLast; ++i) { - thecg.emitter_->Emit(string("OP_")+RE_OpName[i]+" = "+to_string(i)+"\n"); - } + mirGen->EmitOpCodes(); if (themodule->IsJsModule()) { mirGen->EmitGlobalDecl(); } -- Gitee From 23e443afebf603d59fda83fc9f85a4d169a3be6d Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Tue, 22 Sep 2020 12:20:59 -0700 Subject: [PATCH 04/19] [MapleJS] Exclude JavaScript related global and function declaratins in generated Maple Engine code from instruction offset calculations. modified: ../../../include/cg/ark/ark_mir_emit.h modified: ark_mir_emit.cpp --- .../maple_be/include/cg/ark/ark_mir_emit.h | 1 + mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 22 +++++++++++-------- 2 files changed, 14 insertions(+), 9 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 fca5203..57f62fa 100644 --- a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h +++ b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h @@ -354,6 +354,7 @@ class MirGenerator : public CmplGenerator { void EmitAsmComment(CommentNode *comment); void EmitBytes(uint8 *b, int count); void EmitBytesComment(uint8 *b, int count, const string &comment); + void EmitBytesCommentOffset(uint8 *b, int count, const string &comment, int offset); void EmitAsmShort(uint16 s); void EmitAsmWord(uint32 word); void EmitAsmWord(uint32 word, string comment); 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 ef108a1..1ed12a2 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -1138,12 +1138,12 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { os << "\t" << ".word " << func->upFormalSize << ", " << func->frameSize << ", " << curFunc.evalStackDepth << ", " << 0 << "\t// upFormalSize, frameSize, evalStackDepth\n"; os << "\t" << ".word " << formalsBlkBitVectBytes << ", " << localsBlkBitVectBytes << "\t\t// formalWords bit vector byte count, localWords bit vector byte count\n"; if (formalsBlkBitVectBytes) { - EmitBytesComment(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged"); - EmitBytesComment(func->formalWordsRefCounted, formalsBlkBitVectBytes, "// formalWordsRefCounted"); + EmitBytesCommentOffset(func->formalWordsTypeTagged, formalsBlkBitVectBytes, "// formalWordsTypeTagged", 0); + EmitBytesCommentOffset(func->formalWordsRefCounted, formalsBlkBitVectBytes, "// formalWordsRefCounted", 0); } if (localsBlkBitVectBytes) { - EmitBytesComment(func->localWordsTypeTagged, localsBlkBitVectBytes, "// localWordsTypeTagged"); - EmitBytesComment(func->localWordsRefCounted, localsBlkBitVectBytes, "// localWordsRefCounted"); + EmitBytesCommentOffset(func->localWordsTypeTagged, localsBlkBitVectBytes, "// localWordsTypeTagged", 0); + EmitBytesCommentOffset(func->localWordsRefCounted, localsBlkBitVectBytes, "// localWordsRefCounted", 0); } } else { os << "\t.ascii \"MPLI\"\n"; @@ -1202,10 +1202,10 @@ void MirGenerator::EmitGlobalDecl(void) { os << "__mpljs_module_decl__:\n"; os << "\t.word " << mmodule.globalMemSize << "\t// globalMemSize byte count\n"; if (mmodule.globalMemSize) { - EmitBytesComment(mmodule.globalBlkMap, mmodule.globalMemSize, "\t// globalMemMap");; + EmitBytesCommentOffset(mmodule.globalBlkMap, mmodule.globalMemSize, "\t// globalMemMap", 0);; os << "\t.word " << BlkSize2BitvectorSize(mmodule.globalMemSize) << "\t// globalwordstypetagged/refcounted byte count\n"; - EmitBytesComment(mmodule.globalWordsTypeTagged, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordstypetagged"); - EmitBytesComment(mmodule.globalWordsRefCounted, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordsrefcounted"); + EmitBytesCommentOffset(mmodule.globalWordsTypeTagged, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordstypetagged", 0); + EmitBytesCommentOffset(mmodule.globalWordsRefCounted, BlkSize2BitvectorSize(mmodule.globalMemSize), "\t// globalwordsrefcounted", 0); } } @@ -1246,7 +1246,7 @@ void MirGenerator::EmitBytes(uint8 *b, int count) { EmitString(ss.str(), count); } -void MirGenerator::EmitBytesComment(uint8 *b, int count, const string &comment) { +void MirGenerator::EmitBytesCommentOffset(uint8 *b, int count, const string &comment, int offset=0) { stringstream ss; ss << ".byte "; for (int i=0; i Date: Wed, 23 Sep 2020 17:18:15 -0700 Subject: [PATCH 05/19] [MapleJS] Add support for OP_intrinsicop instruction. modified: ark_mir_emit.cpp --- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 7 +++++++ 1 file changed, 7 insertions(+) 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 1ed12a2..be7f549 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -435,6 +435,13 @@ void MirGenerator::EmitExpr(Opcode curOp, PrimType curPrimType, BaseNode *fexpr) EmitAsmBaseNode(expr); EmitAsmConststr(reinterpret_cast(fexpr)->strIdx); break; + case OP_intrinsicop: { + IntrinsicopNode *intrinsicop = (IntrinsicopNode *)fexpr; + expr.param.intrinsic.intrinsicId = intrinsicop->intrinsic; + FlattenExpr(fexpr); + EmitAsmBaseNode(expr, GetIntrinsicName(intrinsicop->intrinsic)); + break; + } default: MIR_FATAL("unknown expression opcode: [%d]:(%s)\n", fexpr->op, kOpcodeInfo.GetName(fexpr->op)); } -- Gitee From 46b0f10444aaeaad464ca5d79ccbc471bf779fa8 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Thu, 24 Sep 2020 00:50:52 -0700 Subject: [PATCH 06/19] [MapleJS] Generate Maple Engine code for OP_jstry, OP_jscatch, OP_finally, OP_cleanuptry, OP_retsub modified: maple_be/include/cg/ark/ark_mir_emit.h modified: maple_be/src/cg/ark/ark_mir_emit.cpp --- .../maple_be/include/cg/ark/ark_mir_emit.h | 1 + mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 52 ++++++++++++++++--- 2 files changed, 47 insertions(+), 6 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 57f62fa..4cf4445 100644 --- a/mapleall/maple_be/include/cg/ark/ark_mir_emit.h +++ b/mapleall/maple_be/include/cg/ark/ark_mir_emit.h @@ -381,6 +381,7 @@ class MirGenerator : public CmplGenerator { uint32 GetFieldOffsetType(TyIdx tyidx, FieldID fieldid, MIRType *&); RE_Opcode MapEHOpcode(RE_Opcode op); void CheckInsertOpCvt(Opcode expr, PrimType exprType, PrimType insnType); + std::string BuildLabelString(LabelIdx lbidx); int GetFuncOffset(void) { return funcOffset; 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 be7f549..5361b3f 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -558,6 +558,11 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { EmitAsmBaseNode(stmt); EmitAsmLabel(((GotoNode *)fstmt)->offset, true); break; + case OP_gosub: + stmt.op = RE_gosub; + EmitAsmBaseNode(stmt); + EmitAsmLabel(((GotoNode *)fstmt)->offset, true); + break; case OP_rangegoto: { RangegotoNode *rNode = static_cast(fstmt); SmallCaseVector &rTable = rNode->rangegotoTable; @@ -568,9 +573,7 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { EmitAsmBaseNode(stmt); // emit base instr with num jump table entry EmitAsmWord(rNode->tagOffset); // emit tagOffset for (int i = 0; i < numCases; i++) { // emit jump table - MIRFunction *func = GetCurFunction(); - string label = "mirbin_label_"+to_string(func->puIdxOrigin)+"_"+to_string(rTable[i].second); - EmitString(".4byte "+label+"-. "+"\t// jmptbl["+to_string(rTable[i].first)+"]", 2); + EmitString(".4byte "+BuildLabelString(rTable[i].second)+"-. "+"\t// jmptbl["+to_string(rTable[i].first)+"]", 4); } break; } @@ -715,6 +718,22 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { EmitAsmBaseNode(stmt); curFunc.currentTry = nullptr; break; + case OP_cleanuptry: + case OP_finally: + case OP_retsub: + EmitAsmBaseNode(stmt); + break; + case OP_jstry: { + JsTryNode *jstry = static_cast(fstmt); + EmitAsmBaseNode(stmt); + if (jstry->catchOffset) EmitAsmLabel(jstry->catchOffset, true); + if (jstry->finallyOffset) EmitAsmLabel(jstry->finallyOffset, true); + break; + } + case OP_jscatch: { + EmitAsmBaseNode(stmt); + break; + } default: MIR_FATAL("unknown statement opcode: [%d]:(%s)\n", fstmt->op, kOpcodeInfo.GetName(fstmt->op)); } @@ -1423,15 +1442,36 @@ void MirGenerator::EmitYieldPoint(void) { EmitAsmBaseNode(node); } +std::string MirGenerator::BuildLabelString(LabelIdx lbidx) { + MIRFunction *func = GetCurFunction(); + string label; + + // Many strangeness with labels if we generate labels into .s + // by the label's name in string table: + // - we get @ and | characters in name string that the assembler complains + // - duplicate name strings across different label idx in the same function + // - duplicate label idx in same function if all of CG's phases are run. + if (JAVASCRIPT){ + string labelName = func->GetLabelName(lbidx); + replace(labelName.begin(), labelName.end(), '@', '_'); + replace(labelName.begin(), labelName.end(), '|', '_'); + // cannot use puIdxOrigin because they are all 0 in js2mpl generated mpl + MIRSymbol *fnSt = GlobalTables::GetGsymTable().GetSymbolFromStIdx(func->stIdx.Idx()); + label = "mirbin_label_"+fnSt->GetName()+"_"+labelName; + } else { + label = "mirbin_label_"+ to_string(func->puIdxOrigin)+"_"+to_string(lbidx); + } + return label; +} + void MirGenerator::EmitAsmLabel(LabelIdx lbidx, bool genOffset) { MIRFunction *func = GetCurFunction(); - string label = "mirbin_label_"+to_string(func->puIdxOrigin)+"_"+to_string(lbidx); // TODO: fix issue - currently have to disable fpm->run in CG to avoid duplicate labels if (genOffset) { - EmitString(".long "+label+"-.", 4); + EmitString(".long "+BuildLabelString(lbidx)+"-.", 4); } else { - os << label+":\n"; + os << BuildLabelString(lbidx)+":\n"; } } -- Gitee From 1272390ac60aa37bb7036abdbfc6ff8f46e53252 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Wed, 14 Oct 2020 00:50:07 -0700 Subject: [PATCH 07/19] [MapleJS] Handle jstry case when handler or finally lable is 0. Maple Engine Issue #362. modified: maple_be/src/cg/ark/ark_mir_emit.cpp --- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) 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 5361b3f..85c8352 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -726,8 +726,16 @@ void MirGenerator::EmitStmt(StmtNode *fstmt) { case OP_jstry: { JsTryNode *jstry = static_cast(fstmt); EmitAsmBaseNode(stmt); - if (jstry->catchOffset) EmitAsmLabel(jstry->catchOffset, true); - if (jstry->finallyOffset) EmitAsmLabel(jstry->finallyOffset, true); + if (jstry->catchOffset) { + EmitAsmLabel(jstry->catchOffset, true); + } else { + EmitString(".long 0", 4); + } + if (jstry->finallyOffset) { + EmitAsmLabel(jstry->finallyOffset, true); + } else { + EmitString(".long 0", 4); + } break; } case OP_jscatch: { -- Gitee From f097df42492cb1cb819be3cdfd4444c70b6c4806 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Thu, 5 Nov 2020 18:03:22 -0800 Subject: [PATCH 08/19] [MapleJS] Remove trailing slash in comment line otherwise gnu g++-5 treats next line as continuation fo comment and skips compiling it. modified: maple_be/src/cg/ark/ark_mir_emit.cpp --- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 5 +++++ 1 file changed, 5 insertions(+) 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 85c8352..7cd92e3 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -1422,6 +1422,11 @@ uint32 MirGenerator::GetFieldOffsetType(TyIdx tyidx, FieldID fieldID, MIRType *& void MirGenerator::EmitAsmComment(CommentNode *stmt) { // cross ref info to source are in the comments nodes from .mpl input + if (stmt->comment.c_str() && stmt->comment.c_str()[stmt->comment.length()-1] == '\\') { + // remove trailing slash in comment line otherwuse gnu g++-5 treats next line as + // continuation of comment and skips compiling it + stmt->comment.c_str()[stmt->comment.length()-1] = 0; + } os << "\t// " << stmt->comment.data << "\n"; } -- Gitee From fa97e2e2a7d002f030b2789debf2787aa3c4c9d0 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Wed, 11 Nov 2020 21:34:29 -0800 Subject: [PATCH 09/19] Allow leading '$' in function name. modified: lexer.cpp --- mapleall/maple_ir/src/lexer.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mapleall/maple_ir/src/lexer.cpp b/mapleall/maple_ir/src/lexer.cpp index 58074f3..4bb6e2f 100644 --- a/mapleall/maple_ir/src/lexer.cpp +++ b/mapleall/maple_ir/src/lexer.cpp @@ -360,7 +360,7 @@ TokenKind MIRLexer::GetTokenWithPrefixPercent() { TokenKind MIRLexer::GetTokenWithPrefixAmpersand() { // token with prefix '&' char c = GetCurrentCharWithUpperCheck(); - if (isalpha(c) || c == '_') { + if (isalpha(c) || c == '_' || c == '$') { GenName(); return TK_fname; } else { -- Gitee From 9442b814409eb3209aae2cfa2d7a7f76c35265be Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Tue, 13 Oct 2020 23:51:25 -0700 Subject: [PATCH 10/19] Enable source location info generation in mplbe for MapleJS. Maple Engine Issue #356 modified: maple_be/src/be/be_lowerer.cpp --- mapleall/maple_be/src/be/be_lowerer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/mapleall/maple_be/src/be/be_lowerer.cpp b/mapleall/maple_be/src/be/be_lowerer.cpp index c241da7..c7da9bb 100644 --- a/mapleall/maple_be/src/be/be_lowerer.cpp +++ b/mapleall/maple_be/src/be/be_lowerer.cpp @@ -1419,9 +1419,7 @@ BlockNode *BELowerer::LowerBlock(BlockNode *block) { } // Do not leave comment stmt to mmpl. case OP_comment: - if (!IsTargetMMPL()) { - newblk->AddStatement(stmt); - } + newblk->AddStatement(stmt); break; case OP_try: case OP_javatry: -- Gitee From 9e7ca3b87fb2c35b0ccbc91e665fd866af49019f Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Thu, 8 Oct 2020 12:39:45 -0700 Subject: [PATCH 11/19] fix primtive simplestr and simpleobj size to be 8 --- mapleall/maple_ir/src/mir_type.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mapleall/maple_ir/src/mir_type.cpp b/mapleall/maple_ir/src/mir_type.cpp index 17e91d4..fb2cab4 100644 --- a/mapleall/maple_ir/src/mir_type.cpp +++ b/mapleall/maple_ir/src/mir_type.cpp @@ -163,9 +163,10 @@ uint32 GetPrimTypeSize(PrimType pty) { case PTY_f32: case PTY_i32: case PTY_u32: + return 4; case PTY_simplestr: case PTY_simpleobj: - return 4; + return 8; case PTY_a64: case PTY_c64: case PTY_f64: -- Gitee From 81811a5d93218f0472aa35ae28e48fd12cd125bc Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Thu, 8 Oct 2020 13:11:32 -0700 Subject: [PATCH 12/19] move TARGEVM to be 64-bits that might break some 32-bits test cases modified: maple_be/include/be/be_common.h modified: maple_be/src/be/mmpl/mmpl_lowerer.cpp --- mapleall/maple_be/include/be/be_common.h | 4 ++-- mapleall/maple_be/src/be/mmpl/mmpl_lowerer.cpp | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/mapleall/maple_be/include/be/be_common.h b/mapleall/maple_be/include/be/be_common.h index 2fdb4cc..927c538 100644 --- a/mapleall/maple_be/include/be/be_common.h +++ b/mapleall/maple_be/include/be/be_common.h @@ -31,10 +31,10 @@ namespace maplebe { -#if TARGX86_64 || TARGAARCH64 || TARGARK || TARGRISCV64 +#if TARGX86_64 || TARGAARCH64 || TARGARK || TARGRISCV64 || TARGVM #define LOWERED_PTR_TYPE PTY_a64 #define SIZEOFPTR 8 -#elif TARGX86 || TARGARM || TARGVM +#elif TARGX86 || TARGARM #define LOWERED_PTR_TYPE PTY_a32 #define SIZEOFPTR 4 #else diff --git a/mapleall/maple_be/src/be/mmpl/mmpl_lowerer.cpp b/mapleall/maple_be/src/be/mmpl/mmpl_lowerer.cpp index c91631b..aba6a98 100644 --- a/mapleall/maple_be/src/be/mmpl/mmpl_lowerer.cpp +++ b/mapleall/maple_be/src/be/mmpl/mmpl_lowerer.cpp @@ -62,7 +62,7 @@ PregIdx MmplLowerer::GetSpecialRegFromSt(const MIRSymbol *sym) { } BaseNode *MmplLowerer::ReadregNodeForSymbol(MIRSymbol *sym) { - return mirModule.mirBuilder->CreateExprRegread(PTY_a32, GetSpecialRegFromSt(sym)); + return mirModule.mirBuilder->CreateExprRegread(LOWERED_PTR_TYPE, GetSpecialRegFromSt(sym)); } BaseNode *MmplLowerer::LowerAddrof(AddrofNode *expr) { @@ -80,7 +80,7 @@ BaseNode *MmplLowerer::LowerAddrof(AddrofNode *expr) { offset += symbol->IsLocal() ? memlayout->sym_alloc_table[symbol->GetStIndex()].offset : globmemlayout->sym_alloc_table[symbol->GetStIndex()].offset; return (offset == 0) ? rrn - : mirModule.mirBuilder->CreateExprBinary(OP_add, GlobalTables::GetTypeTable().GetTypeFromTyIdx((TyIdx)PTY_a32), rrn, + : mirModule.mirBuilder->CreateExprBinary(OP_add, GlobalTables::GetTypeTable().GetTypeFromTyIdx((TyIdx)LOWERED_PTR_TYPE), rrn, mirModule.mirBuilder->GetConstInt(offset)); } @@ -103,7 +103,7 @@ BaseNode *MmplLowerer::LowerDread(AddrofNode *expr) { symty, memlayout->sym_alloc_table[symbol->GetStIndex()].offset + offset); return ireadoff; } else { - BaseNode *rrn = mirModule.mirBuilder->CreateExprRegread(PTY_a32, spcreg); + BaseNode *rrn = mirModule.mirBuilder->CreateExprRegread(LOWERED_PTR_TYPE, spcreg); SymbolAlloc &symalloc = symbol->IsLocal() ? memlayout->sym_alloc_table[symbol->GetStIndex()] : globmemlayout->sym_alloc_table[symbol->GetStIndex()]; IreadoffNode *ireadoff = mirModule.mirBuilder->CreateExprIreadoff(symty, symalloc.offset + offset, rrn); -- Gitee From e9c0c7af6a47d9d641a00215014e659084b86ff4 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Mon, 16 Nov 2020 14:49:12 -0800 Subject: [PATCH 13/19] introduce INTRN_JS_GET_ARGUMENTOBJECT for javascript modified: maple_ir/include/js2mpl/jsintrinsic.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 2 ++ 1 file changed, 2 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 7d5650c..20978c6 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -116,3 +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_GET_ARGUMENTOBJECT,\ + __jsobj_get_or_create_argument, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -- Gitee From 17ea227dcaf4472b2555566eb8a79e4e139ce255 Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Wed, 18 Nov 2020 13:44:31 -0800 Subject: [PATCH 14/19] some intrinsics to support js error modified: maple_ir/include/js2mpl/jsintrinsic.def --- mapleall/maple_ir/include/js2mpl/jsintrinsic.def | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 20978c6..9e0c9a9 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -118,3 +118,19 @@ DEF_MIR_INTRINSIC(JS_ADDSYSEVENTLISTENER,\ __js_add_sysevent_listener, INTRNISJS, kArgTyU32, kArgTyDynany, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) DEF_MIR_INTRINSIC(JS_GET_ARGUMENTOBJECT,\ __jsobj_get_or_create_argument, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_ERROR_OBJECT,\ + __jsobj_get_or_create_error, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_EVALERROR_OBJECT,\ + __jsobj_get_or_create_evalError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_RANGEERROR_OBJECT,\ + __jsobj_get_or_create_rangeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_REFERENCEERROR_OBJECT,\ + __jsobj_get_or_create_referenceError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_SYNTAXERROR_OBJECT,\ + __jsobj_get_or_create_syntaxError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_TYPEERROR_OBJECT,\ + __jsobj_get_or_create_typeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +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) -- Gitee From 351a5bbb06580f38f4677fe750339a4406e0cd9e Mon Sep 17 00:00:00 2001 From: Yiming Lei Date: Wed, 16 Dec 2020 09:22:39 -0800 Subject: [PATCH 15/19] make parser support PTY_dynf64 modified: maple_ir/src/mir_parser_expr.cpp --- mapleall/maple_ir/src/mir_parser_expr.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mapleall/maple_ir/src/mir_parser_expr.cpp b/mapleall/maple_ir/src/mir_parser_expr.cpp index bb61558..df46f74 100644 --- a/mapleall/maple_ir/src/mir_parser_expr.cpp +++ b/mapleall/maple_ir/src/mir_parser_expr.cpp @@ -1159,11 +1159,14 @@ bool MIRParser::ParseExprIntrinsicopwithtype(BaseNode *&expr) { bool MIRParser::ParseScalarValue(MIRConst *&stype, MIRType *type) { PrimType ptp = type->primType; if (IsPrimitiveInteger(ptp) || IsPrimitiveDynType(ptp) || ptp == PTY_gen) { - if (lexer.GetTokenKind() != TK_intconst) { + if (lexer.GetTokenKind() == TK_intconst) { + stype = mod.memPool->New(lexer.GetTheIntVal(), type); + } else if (lexer.GetTokenKind() == TK_doubleconst) { + stype = mod.memPool->New(lexer.GetTheDoubleVal(), type); + } else { Error("constant value incompatible with integer type at "); return false; } - stype = mod.memPool->New(lexer.GetTheIntVal(), type); } else if (ptp == PTY_f32) { if (lexer.GetTokenKind() != TK_floatconst) { Error("constant value incompatible with single-precision float type at "); -- Gitee From 08231028005f731cbaf850e7ebaeae118750bf48 Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Fri, 18 Dec 2020 12:21:09 -0800 Subject: [PATCH 16/19] Added hooks for future build of js2mpl and mplbe for Maple JS engine. modified: BUILD.gn modified: Makefile modified: build/config/BUILDCONFIG.gn --- BUILD.gn | 9 +++++++++ Makefile | 8 ++++++++ build/config/BUILDCONFIG.gn | 2 ++ 3 files changed, 19 insertions(+) diff --git a/BUILD.gn b/BUILD.gn index e35c304..fca908c 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -18,3 +18,12 @@ group("mapleall") { "${MAPLEALL_ROOT}:mapleall" ] } + +group("js2mpl") { + deps = [] + if(IS_JS2MPL_EXISTS == "1"){ + deps = [ + "${JS2MPL_ROOT}:js2mpl" + ] + } +} diff --git a/Makefile b/Makefile index 3b75bb8..958d153 100644 --- a/Makefile +++ b/Makefile @@ -71,6 +71,14 @@ default: mapleall mapleall: $(call build_gn, ${GN_OPTIONS}, irbuild maple mplcg) +.PHONY: js2mpl +js2mpl: + $(call build_gn, ${GN_OPTIONS}, js2mpl) + +.PHONY: mplbe +mplbe: + $(call build_gn, ${GN_OPTIONS}, mplbe) + .PHONY: install install: mapleall $(shell mkdir -p ${MAPLE_ROOT}/bin; \ diff --git a/build/config/BUILDCONFIG.gn b/build/config/BUILDCONFIG.gn index bbed5be..b36b4e4 100644 --- a/build/config/BUILDCONFIG.gn +++ b/build/config/BUILDCONFIG.gn @@ -39,6 +39,7 @@ declare_args() { # Define global args MAPLE_ROOT = getenv("MAPLE_ROOT") +IS_JS2MPL_EXISTS = getenv("IS_JS2MPL_EXISTS") DYNAMICLANG = true RC_V2 = true if (X86_ARK == 1) { @@ -66,6 +67,7 @@ MAPLEALL_ROOT = "${MAPLE_ROOT}/mapleall" MAPLE_RE_ROOT = "${MAPLE_ROOT}/maple_engine" HUAWEI_SECURE_C_ROOT = "${MAPLE_ROOT}/huawei_secure_c" DWARF_ROOT = "${MAPLE_ROOT}/tools/dwarf" +JS2MPL_ROOT = "${MAPLE_ROOT}/js2mpl" # Toolchain setup if (USE_CLANG == 1) { -- Gitee From 780dc806b1d0eb2fc0a9f16d184f6ed80b7327f7 Mon Sep 17 00:00:00 2001 From: Wen HU Date: Fri, 18 Dec 2020 17:04:29 -0500 Subject: [PATCH 17/19] remove trailing space --- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 7cd92e3..489888c 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -1423,7 +1423,7 @@ uint32 MirGenerator::GetFieldOffsetType(TyIdx tyidx, FieldID fieldID, MIRType *& void MirGenerator::EmitAsmComment(CommentNode *stmt) { // cross ref info to source are in the comments nodes from .mpl input if (stmt->comment.c_str() && stmt->comment.c_str()[stmt->comment.length()-1] == '\\') { - // remove trailing slash in comment line otherwuse gnu g++-5 treats next line as + // remove trailing slash in comment line otherwuse gnu g++-5 treats next line as // continuation of comment and skips compiling it stmt->comment.c_str()[stmt->comment.length()-1] = 0; } -- Gitee From 6e46603b49456725dfb693f2f0e836b1ce51c3fc Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Sat, 19 Dec 2020 03:29:30 -0800 Subject: [PATCH 18/19] Info line in generated Java function header erroneously removed when implementing Maple JavaScript engine support. modified: mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp --- mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp | 1 + 1 file changed, 1 insertion(+) 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 489888c..6384687 100644 --- a/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp +++ b/mapleall/maple_be/src/cg/ark/ark_mir_emit.cpp @@ -1183,6 +1183,7 @@ void MirGenerator::EmitAsmFuncInfo(MIRFunction *func) { os << "\t.ascii \"MPLI\"\n"; os << infoLabel << ":\n"; os << "\t" << ".long " << codeLabel << " - .\n"; + os << "\t" << ".word " << curFunc.numFormalArgs << ", " << curFunc.numAutoVars << ", " << curFunc.evalStackDepth << ", " << curFunc.funcAttrs << " // func storage info\n"; if (curFunc.numFormalArgs) { os << "\t" << "// PrimType of formal arguments\n"; -- Gitee From 6caac27a5be16dc8a04df70cd855cb8705361d4d Mon Sep 17 00:00:00 2001 From: Ed Ching Date: Sat, 19 Dec 2020 23:16:56 -0800 Subject: [PATCH 19/19] Move new intrinsics added for Maple JavaScript Engine to end of intrinsics.def so ID for old intrinsics does not get changed. This is necessary to maintain backward compatibility with prebuilt tools built using oldder versions of intrinsics.def. modified: mapleall/maple_ir/include/intrinsics.def modified: mapleall/maple_ir/include/js2mpl/jsintrinsic.def new file: mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def --- mapleall/maple_ir/include/intrinsics.def | 1 + .../maple_ir/include/js2mpl/jsintrinsic.def | 19 +---------- .../include/js2mpl/jsintrinsic_eng.def | 34 +++++++++++++++++++ 3 files changed, 36 insertions(+), 18 deletions(-) create mode 100644 mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def diff --git a/mapleall/maple_ir/include/intrinsics.def b/mapleall/maple_ir/include/intrinsics.def index 91d027e..18889bb 100644 --- a/mapleall/maple_ir/include/intrinsics.def +++ b/mapleall/maple_ir/include/intrinsics.def @@ -192,6 +192,7 @@ DEF_MIR_INTRINSIC(MCCNewPermanentArray,\ #include "intrinsic_misc.def" #include "intrinsic_c.def" +#include "js2mpl/jsintrinsic_eng.def" DEF_MIR_INTRINSIC(LAST,\ nullptr, kIntrnUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def index 9e0c9a9..1c42c3d 100644 --- a/mapleall/maple_ir/include/js2mpl/jsintrinsic.def +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic.def @@ -116,21 +116,4 @@ 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_GET_ARGUMENTOBJECT,\ - __jsobj_get_or_create_argument, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_ERROR_OBJECT,\ - __jsobj_get_or_create_error, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_EVALERROR_OBJECT,\ - __jsobj_get_or_create_evalError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_RANGEERROR_OBJECT,\ - __jsobj_get_or_create_rangeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_REFERENCEERROR_OBJECT,\ - __jsobj_get_or_create_referenceError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_SYNTAXERROR_OBJECT,\ - __jsobj_get_or_create_syntaxError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -DEF_MIR_INTRINSIC(JS_GET_TYPEERROR_OBJECT,\ - __jsobj_get_or_create_typeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) -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) + diff --git a/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def new file mode 100644 index 0000000..aed9027 --- /dev/null +++ b/mapleall/maple_ir/include/js2mpl/jsintrinsic_eng.def @@ -0,0 +1,34 @@ +/* + * Copyright (c) [2020] Huawei Technologies Co., Ltd. All rights reserved. + * + * OpenArkCompiler is licensed under the Mulan Permissive Software License v2. + * You can use this software according to the terms and conditions of the MulanPSL - 2.0. + * You may obtain a copy of MulanPSL - 2.0 at: + * + * https://opensource.org/licenses/MulanPSL-2.0 + * + * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR + * FIT FOR A PARTICULAR PURPOSE. + * See the MulanPSL - 2.0 for more details. + */ + +// DEF_MIR_INTRINSIC(STR, NAME, INTRN_CLASS, RETURN_TYPE, ARG0, ARG1, ARG2, ARG3, ARG4, ARG5) +DEF_MIR_INTRINSIC(JS_GET_ARGUMENTOBJECT,\ + __jsobj_get_or_create_argument, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_ERROR_OBJECT,\ + __jsobj_get_or_create_error, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_EVALERROR_OBJECT,\ + __jsobj_get_or_create_evalError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_RANGEERROR_OBJECT,\ + __jsobj_get_or_create_rangeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_REFERENCEERROR_OBJECT,\ + __jsobj_get_or_create_referenceError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_SYNTAXERROR_OBJECT,\ + __jsobj_get_or_create_syntaxError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +DEF_MIR_INTRINSIC(JS_GET_TYPEERROR_OBJECT,\ + __jsobj_get_or_create_typeError, INTRNISJS | INTRNISPURE, kArgTySimpleobj, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef, kArgTyUndef) +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) -- Gitee