: print infos about number \n"); PrintF(" or all stop(s).\n"); PrintF(" stop enable/disable all/ : enables / disables\n"); PrintF(" all or number stop(s)\n"); PrintF(" stop unstop\n"); PrintF(" ignore the stop instruction at the current location\n"); PrintF(" from now on\n"); } else { PrintF("Unknown command: %s\n", cmd); } } } // Add all the breakpoints back to stop execution and enter the debugger // shell when hit. RedoBreakpoints(); // Restore tracing ::v8::internal::FLAG_trace_sim = trace; #undef COMMAND_SIZE #undef ARG_SIZE #undef STR #undef XSTR } static bool ICacheMatch(void* one, void* two) { DCHECK((reinterpret_cast(one) & CachePage::kPageMask) == 0); DCHECK((reinterpret_cast(two) & CachePage::kPageMask) == 0); return one == two; } static uint32_t ICacheHash(void* key) { return static_cast(reinterpret_cast(key)) >> 2; } static bool AllOnOnePage(uintptr_t start, int size) { intptr_t start_page = (start & ~CachePage::kPageMask); intptr_t end_page = ((start + size) & ~CachePage::kPageMask); return start_page == end_page; } void Simulator::set_last_debugger_input(char* input) { DeleteArray(last_debugger_input_); last_debugger_input_ = input; } void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, void* start_addr, size_t size) { intptr_t start = reinterpret_cast(start_addr); int intra_line = (start & CachePage::kLineMask); start -= intra_line; size += intra_line; size = ((size - 1) | CachePage::kLineMask) + 1; int offset = (start & CachePage::kPageMask); while (!AllOnOnePage(start, size - 1)) { int bytes_to_flush = CachePage::kPageSize - offset; FlushOnePage(i_cache, start, bytes_to_flush); start += bytes_to_flush; size -= bytes_to_flush; DCHECK_EQ(0, static_cast(start & CachePage::kPageMask)); offset = 0; } if (size != 0) { FlushOnePage(i_cache, start, size); } } CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, void* page) { base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); if (entry->value == NULL) { CachePage* new_page = new CachePage(); entry->value = new_page; } return reinterpret_cast(entry->value); } // Flush from start up to and not including start + size. void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, int size) { DCHECK(size <= CachePage::kPageSize); DCHECK(AllOnOnePage(start, size - 1)); DCHECK((start & CachePage::kLineMask) == 0); DCHECK((size & CachePage::kLineMask) == 0); void* page = reinterpret_cast(start & (~CachePage::kPageMask)); int offset = (start & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* valid_bytemap = cache_page->ValidityByte(offset); memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); } void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, Instruction* instr) { intptr_t address = reinterpret_cast(instr); void* page = reinterpret_cast(address & (~CachePage::kPageMask)); void* line = reinterpret_cast(address & (~CachePage::kLineMask)); int offset = (address & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* cache_valid_byte = cache_page->ValidityByte(offset); bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); if (cache_hit) { // Check that the data in memory matches the contents of the I-cache. CHECK_EQ(memcmp(reinterpret_cast(instr), cache_page->CachedData(offset), sizeof(FourByteInstr)), 0); } else { // Cache miss. Load memory into the cache. memcpy(cached_line, line, CachePage::kLineLength); *cache_valid_byte = CachePage::LINE_VALID; } } void Simulator::Initialize(Isolate* isolate) { if (isolate->simulator_initialized()) return; isolate->set_simulator_initialized(true); ::v8::internal::ExternalReference::set_redirector(isolate, &RedirectExternalReference); static base::OnceType once = V8_ONCE_INIT; base::CallOnce(&once, &Simulator::EvalTableInit); } Simulator::EvaluateFuncType Simulator::EvalTable[] = {NULL}; void Simulator::EvalTableInit() { for (int i = 0; i < MAX_NUM_OPCODES; i++) { EvalTable[i] = &Simulator::Evaluate_Unknown; } EvalTable[BKPT] = &Simulator::Evaluate_BKPT; EvalTable[SPM] = &Simulator::Evaluate_SPM; EvalTable[BALR] = &Simulator::Evaluate_BALR; EvalTable[BCTR] = &Simulator::Evaluate_BCTR; EvalTable[BCR] = &Simulator::Evaluate_BCR; EvalTable[SVC] = &Simulator::Evaluate_SVC; EvalTable[BSM] = &Simulator::Evaluate_BSM; EvalTable[BASSM] = &Simulator::Evaluate_BASSM; EvalTable[BASR] = &Simulator::Evaluate_BASR; EvalTable[MVCL] = &Simulator::Evaluate_MVCL; EvalTable[CLCL] = &Simulator::Evaluate_CLCL; EvalTable[LPR] = &Simulator::Evaluate_LPR; EvalTable[LNR] = &Simulator::Evaluate_LNR; EvalTable[LTR] = &Simulator::Evaluate_LTR; EvalTable[LCR] = &Simulator::Evaluate_LCR; EvalTable[NR] = &Simulator::Evaluate_NR; EvalTable[CLR] = &Simulator::Evaluate_CLR; EvalTable[OR] = &Simulator::Evaluate_OR; EvalTable[XR] = &Simulator::Evaluate_XR; EvalTable[LR] = &Simulator::Evaluate_LR; EvalTable[CR] = &Simulator::Evaluate_CR; EvalTable[AR] = &Simulator::Evaluate_AR; EvalTable[SR] = &Simulator::Evaluate_SR; EvalTable[MR] = &Simulator::Evaluate_MR; EvalTable[DR] = &Simulator::Evaluate_DR; EvalTable[ALR] = &Simulator::Evaluate_ALR; EvalTable[SLR] = &Simulator::Evaluate_SLR; EvalTable[LDR] = &Simulator::Evaluate_LDR; EvalTable[CDR] = &Simulator::Evaluate_CDR; EvalTable[LER] = &Simulator::Evaluate_LER; EvalTable[STH] = &Simulator::Evaluate_STH; EvalTable[LA] = &Simulator::Evaluate_LA; EvalTable[STC] = &Simulator::Evaluate_STC; EvalTable[IC_z] = &Simulator::Evaluate_IC_z; EvalTable[EX] = &Simulator::Evaluate_EX; EvalTable[BAL] = &Simulator::Evaluate_BAL; EvalTable[BCT] = &Simulator::Evaluate_BCT; EvalTable[BC] = &Simulator::Evaluate_BC; EvalTable[LH] = &Simulator::Evaluate_LH; EvalTable[CH] = &Simulator::Evaluate_CH; EvalTable[AH] = &Simulator::Evaluate_AH; EvalTable[SH] = &Simulator::Evaluate_SH; EvalTable[MH] = &Simulator::Evaluate_MH; EvalTable[BAS] = &Simulator::Evaluate_BAS; EvalTable[CVD] = &Simulator::Evaluate_CVD; EvalTable[CVB] = &Simulator::Evaluate_CVB; EvalTable[ST] = &Simulator::Evaluate_ST; EvalTable[LAE] = &Simulator::Evaluate_LAE; EvalTable[N] = &Simulator::Evaluate_N; EvalTable[CL] = &Simulator::Evaluate_CL; EvalTable[O] = &Simulator::Evaluate_O; EvalTable[X] = &Simulator::Evaluate_X; EvalTable[L] = &Simulator::Evaluate_L; EvalTable[C] = &Simulator::Evaluate_C; EvalTable[A] = &Simulator::Evaluate_A; EvalTable[S] = &Simulator::Evaluate_S; EvalTable[M] = &Simulator::Evaluate_M; EvalTable[D] = &Simulator::Evaluate_D; EvalTable[AL] = &Simulator::Evaluate_AL; EvalTable[SL] = &Simulator::Evaluate_SL; EvalTable[STD] = &Simulator::Evaluate_STD; EvalTable[LD] = &Simulator::Evaluate_LD; EvalTable[CD] = &Simulator::Evaluate_CD; EvalTable[STE] = &Simulator::Evaluate_STE; EvalTable[MS] = &Simulator::Evaluate_MS; EvalTable[LE] = &Simulator::Evaluate_LE; EvalTable[BRXH] = &Simulator::Evaluate_BRXH; EvalTable[BRXLE] = &Simulator::Evaluate_BRXLE; EvalTable[BXH] = &Simulator::Evaluate_BXH; EvalTable[BXLE] = &Simulator::Evaluate_BXLE; EvalTable[SRL] = &Simulator::Evaluate_SRL; EvalTable[SLL] = &Simulator::Evaluate_SLL; EvalTable[SRA] = &Simulator::Evaluate_SRA; EvalTable[SLA] = &Simulator::Evaluate_SLA; EvalTable[SRDL] = &Simulator::Evaluate_SRDL; EvalTable[SLDL] = &Simulator::Evaluate_SLDL; EvalTable[SRDA] = &Simulator::Evaluate_SRDA; EvalTable[SLDA] = &Simulator::Evaluate_SLDA; EvalTable[STM] = &Simulator::Evaluate_STM; EvalTable[TM] = &Simulator::Evaluate_TM; EvalTable[MVI] = &Simulator::Evaluate_MVI; EvalTable[TS] = &Simulator::Evaluate_TS; EvalTable[NI] = &Simulator::Evaluate_NI; EvalTable[CLI] = &Simulator::Evaluate_CLI; EvalTable[OI] = &Simulator::Evaluate_OI; EvalTable[XI] = &Simulator::Evaluate_XI; EvalTable[LM] = &Simulator::Evaluate_LM; EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE; EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE; EvalTable[MC] = &Simulator::Evaluate_MC; EvalTable[CDS] = &Simulator::Evaluate_CDS; EvalTable[STCM] = &Simulator::Evaluate_STCM; EvalTable[ICM] = &Simulator::Evaluate_ICM; EvalTable[BPRP] = &Simulator::Evaluate_BPRP; EvalTable[BPP] = &Simulator::Evaluate_BPP; EvalTable[TRTR] = &Simulator::Evaluate_TRTR; EvalTable[MVN] = &Simulator::Evaluate_MVN; EvalTable[MVC] = &Simulator::Evaluate_MVC; EvalTable[MVZ] = &Simulator::Evaluate_MVZ; EvalTable[NC] = &Simulator::Evaluate_NC; EvalTable[CLC] = &Simulator::Evaluate_CLC; EvalTable[OC] = &Simulator::Evaluate_OC; EvalTable[XC] = &Simulator::Evaluate_XC; EvalTable[MVCP] = &Simulator::Evaluate_MVCP; EvalTable[TR] = &Simulator::Evaluate_TR; EvalTable[TRT] = &Simulator::Evaluate_TRT; EvalTable[ED] = &Simulator::Evaluate_ED; EvalTable[EDMK] = &Simulator::Evaluate_EDMK; EvalTable[PKU] = &Simulator::Evaluate_PKU; EvalTable[UNPKU] = &Simulator::Evaluate_UNPKU; EvalTable[MVCIN] = &Simulator::Evaluate_MVCIN; EvalTable[PKA] = &Simulator::Evaluate_PKA; EvalTable[UNPKA] = &Simulator::Evaluate_UNPKA; EvalTable[PLO] = &Simulator::Evaluate_PLO; EvalTable[LMD] = &Simulator::Evaluate_LMD; EvalTable[SRP] = &Simulator::Evaluate_SRP; EvalTable[MVO] = &Simulator::Evaluate_MVO; EvalTable[PACK] = &Simulator::Evaluate_PACK; EvalTable[UNPK] = &Simulator::Evaluate_UNPK; EvalTable[ZAP] = &Simulator::Evaluate_ZAP; EvalTable[AP] = &Simulator::Evaluate_AP; EvalTable[SP] = &Simulator::Evaluate_SP; EvalTable[MP] = &Simulator::Evaluate_MP; EvalTable[DP] = &Simulator::Evaluate_DP; EvalTable[UPT] = &Simulator::Evaluate_UPT; EvalTable[PFPO] = &Simulator::Evaluate_PFPO; EvalTable[IIHH] = &Simulator::Evaluate_IIHH; EvalTable[IIHL] = &Simulator::Evaluate_IIHL; EvalTable[IILH] = &Simulator::Evaluate_IILH; EvalTable[IILL] = &Simulator::Evaluate_IILL; EvalTable[NIHH] = &Simulator::Evaluate_NIHH; EvalTable[NIHL] = &Simulator::Evaluate_NIHL; EvalTable[NILH] = &Simulator::Evaluate_NILH; EvalTable[NILL] = &Simulator::Evaluate_NILL; EvalTable[OIHH] = &Simulator::Evaluate_OIHH; EvalTable[OIHL] = &Simulator::Evaluate_OIHL; EvalTable[OILH] = &Simulator::Evaluate_OILH; EvalTable[OILL] = &Simulator::Evaluate_OILL; EvalTable[LLIHH] = &Simulator::Evaluate_LLIHH; EvalTable[LLIHL] = &Simulator::Evaluate_LLIHL; EvalTable[LLILH] = &Simulator::Evaluate_LLILH; EvalTable[LLILL] = &Simulator::Evaluate_LLILL; EvalTable[TMLH] = &Simulator::Evaluate_TMLH; EvalTable[TMLL] = &Simulator::Evaluate_TMLL; EvalTable[TMHH] = &Simulator::Evaluate_TMHH; EvalTable[TMHL] = &Simulator::Evaluate_TMHL; EvalTable[BRC] = &Simulator::Evaluate_BRC; EvalTable[BRAS] = &Simulator::Evaluate_BRAS; EvalTable[BRCT] = &Simulator::Evaluate_BRCT; EvalTable[BRCTG] = &Simulator::Evaluate_BRCTG; EvalTable[LHI] = &Simulator::Evaluate_LHI; EvalTable[LGHI] = &Simulator::Evaluate_LGHI; EvalTable[AHI] = &Simulator::Evaluate_AHI; EvalTable[AGHI] = &Simulator::Evaluate_AGHI; EvalTable[MHI] = &Simulator::Evaluate_MHI; EvalTable[MGHI] = &Simulator::Evaluate_MGHI; EvalTable[CHI] = &Simulator::Evaluate_CHI; EvalTable[CGHI] = &Simulator::Evaluate_CGHI; EvalTable[LARL] = &Simulator::Evaluate_LARL; EvalTable[LGFI] = &Simulator::Evaluate_LGFI; EvalTable[BRCL] = &Simulator::Evaluate_BRCL; EvalTable[BRASL] = &Simulator::Evaluate_BRASL; EvalTable[XIHF] = &Simulator::Evaluate_XIHF; EvalTable[XILF] = &Simulator::Evaluate_XILF; EvalTable[IIHF] = &Simulator::Evaluate_IIHF; EvalTable[IILF] = &Simulator::Evaluate_IILF; EvalTable[NIHF] = &Simulator::Evaluate_NIHF; EvalTable[NILF] = &Simulator::Evaluate_NILF; EvalTable[OIHF] = &Simulator::Evaluate_OIHF; EvalTable[OILF] = &Simulator::Evaluate_OILF; EvalTable[LLIHF] = &Simulator::Evaluate_LLIHF; EvalTable[LLILF] = &Simulator::Evaluate_LLILF; EvalTable[MSGFI] = &Simulator::Evaluate_MSGFI; EvalTable[MSFI] = &Simulator::Evaluate_MSFI; EvalTable[SLGFI] = &Simulator::Evaluate_SLGFI; EvalTable[SLFI] = &Simulator::Evaluate_SLFI; EvalTable[AGFI] = &Simulator::Evaluate_AGFI; EvalTable[AFI] = &Simulator::Evaluate_AFI; EvalTable[ALGFI] = &Simulator::Evaluate_ALGFI; EvalTable[ALFI] = &Simulator::Evaluate_ALFI; EvalTable[CGFI] = &Simulator::Evaluate_CGFI; EvalTable[CFI] = &Simulator::Evaluate_CFI; EvalTable[CLGFI] = &Simulator::Evaluate_CLGFI; EvalTable[CLFI] = &Simulator::Evaluate_CLFI; EvalTable[LLHRL] = &Simulator::Evaluate_LLHRL; EvalTable[LGHRL] = &Simulator::Evaluate_LGHRL; EvalTable[LHRL] = &Simulator::Evaluate_LHRL; EvalTable[LLGHRL] = &Simulator::Evaluate_LLGHRL; EvalTable[STHRL] = &Simulator::Evaluate_STHRL; EvalTable[LGRL] = &Simulator::Evaluate_LGRL; EvalTable[STGRL] = &Simulator::Evaluate_STGRL; EvalTable[LGFRL] = &Simulator::Evaluate_LGFRL; EvalTable[LRL] = &Simulator::Evaluate_LRL; EvalTable[LLGFRL] = &Simulator::Evaluate_LLGFRL; EvalTable[STRL] = &Simulator::Evaluate_STRL; EvalTable[EXRL] = &Simulator::Evaluate_EXRL; EvalTable[PFDRL] = &Simulator::Evaluate_PFDRL; EvalTable[CGHRL] = &Simulator::Evaluate_CGHRL; EvalTable[CHRL] = &Simulator::Evaluate_CHRL; EvalTable[CGRL] = &Simulator::Evaluate_CGRL; EvalTable[CGFRL] = &Simulator::Evaluate_CGFRL; EvalTable[ECTG] = &Simulator::Evaluate_ECTG; EvalTable[CSST] = &Simulator::Evaluate_CSST; EvalTable[LPD] = &Simulator::Evaluate_LPD; EvalTable[LPDG] = &Simulator::Evaluate_LPDG; EvalTable[BRCTH] = &Simulator::Evaluate_BRCTH; EvalTable[AIH] = &Simulator::Evaluate_AIH; EvalTable[ALSIH] = &Simulator::Evaluate_ALSIH; EvalTable[ALSIHN] = &Simulator::Evaluate_ALSIHN; EvalTable[CIH] = &Simulator::Evaluate_CIH; EvalTable[STCK] = &Simulator::Evaluate_STCK; EvalTable[CFC] = &Simulator::Evaluate_CFC; EvalTable[IPM] = &Simulator::Evaluate_IPM; EvalTable[HSCH] = &Simulator::Evaluate_HSCH; EvalTable[MSCH] = &Simulator::Evaluate_MSCH; EvalTable[SSCH] = &Simulator::Evaluate_SSCH; EvalTable[STSCH] = &Simulator::Evaluate_STSCH; EvalTable[TSCH] = &Simulator::Evaluate_TSCH; EvalTable[TPI] = &Simulator::Evaluate_TPI; EvalTable[SAL] = &Simulator::Evaluate_SAL; EvalTable[RSCH] = &Simulator::Evaluate_RSCH; EvalTable[STCRW] = &Simulator::Evaluate_STCRW; EvalTable[STCPS] = &Simulator::Evaluate_STCPS; EvalTable[RCHP] = &Simulator::Evaluate_RCHP; EvalTable[SCHM] = &Simulator::Evaluate_SCHM; EvalTable[CKSM] = &Simulator::Evaluate_CKSM; EvalTable[SAR] = &Simulator::Evaluate_SAR; EvalTable[EAR] = &Simulator::Evaluate_EAR; EvalTable[MSR] = &Simulator::Evaluate_MSR; EvalTable[MVST] = &Simulator::Evaluate_MVST; EvalTable[CUSE] = &Simulator::Evaluate_CUSE; EvalTable[SRST] = &Simulator::Evaluate_SRST; EvalTable[XSCH] = &Simulator::Evaluate_XSCH; EvalTable[STCKE] = &Simulator::Evaluate_STCKE; EvalTable[STCKF] = &Simulator::Evaluate_STCKF; EvalTable[SRNM] = &Simulator::Evaluate_SRNM; EvalTable[STFPC] = &Simulator::Evaluate_STFPC; EvalTable[LFPC] = &Simulator::Evaluate_LFPC; EvalTable[TRE] = &Simulator::Evaluate_TRE; EvalTable[CUUTF] = &Simulator::Evaluate_CUUTF; EvalTable[CUTFU] = &Simulator::Evaluate_CUTFU; EvalTable[STFLE] = &Simulator::Evaluate_STFLE; EvalTable[SRNMB] = &Simulator::Evaluate_SRNMB; EvalTable[SRNMT] = &Simulator::Evaluate_SRNMT; EvalTable[LFAS] = &Simulator::Evaluate_LFAS; EvalTable[PPA] = &Simulator::Evaluate_PPA; EvalTable[ETND] = &Simulator::Evaluate_ETND; EvalTable[TEND] = &Simulator::Evaluate_TEND; EvalTable[NIAI] = &Simulator::Evaluate_NIAI; EvalTable[TABORT] = &Simulator::Evaluate_TABORT; EvalTable[TRAP4] = &Simulator::Evaluate_TRAP4; EvalTable[LPEBR] = &Simulator::Evaluate_LPEBR; EvalTable[LNEBR] = &Simulator::Evaluate_LNEBR; EvalTable[LTEBR] = &Simulator::Evaluate_LTEBR; EvalTable[LCEBR] = &Simulator::Evaluate_LCEBR; EvalTable[LDEBR] = &Simulator::Evaluate_LDEBR; EvalTable[LXDBR] = &Simulator::Evaluate_LXDBR; EvalTable[LXEBR] = &Simulator::Evaluate_LXEBR; EvalTable[MXDBR] = &Simulator::Evaluate_MXDBR; EvalTable[KEBR] = &Simulator::Evaluate_KEBR; EvalTable[CEBR] = &Simulator::Evaluate_CEBR; EvalTable[AEBR] = &Simulator::Evaluate_AEBR; EvalTable[SEBR] = &Simulator::Evaluate_SEBR; EvalTable[MDEBR] = &Simulator::Evaluate_MDEBR; EvalTable[DEBR] = &Simulator::Evaluate_DEBR; EvalTable[MAEBR] = &Simulator::Evaluate_MAEBR; EvalTable[MSEBR] = &Simulator::Evaluate_MSEBR; EvalTable[LPDBR] = &Simulator::Evaluate_LPDBR; EvalTable[LNDBR] = &Simulator::Evaluate_LNDBR; EvalTable[LTDBR] = &Simulator::Evaluate_LTDBR; EvalTable[LCDBR] = &Simulator::Evaluate_LCDBR; EvalTable[SQEBR] = &Simulator::Evaluate_SQEBR; EvalTable[SQDBR] = &Simulator::Evaluate_SQDBR; EvalTable[SQXBR] = &Simulator::Evaluate_SQXBR; EvalTable[MEEBR] = &Simulator::Evaluate_MEEBR; EvalTable[KDBR] = &Simulator::Evaluate_KDBR; EvalTable[CDBR] = &Simulator::Evaluate_CDBR; EvalTable[ADBR] = &Simulator::Evaluate_ADBR; EvalTable[SDBR] = &Simulator::Evaluate_SDBR; EvalTable[MDBR] = &Simulator::Evaluate_MDBR; EvalTable[DDBR] = &Simulator::Evaluate_DDBR; EvalTable[MADBR] = &Simulator::Evaluate_MADBR; EvalTable[MSDBR] = &Simulator::Evaluate_MSDBR; EvalTable[LPXBR] = &Simulator::Evaluate_LPXBR; EvalTable[LNXBR] = &Simulator::Evaluate_LNXBR; EvalTable[LTXBR] = &Simulator::Evaluate_LTXBR; EvalTable[LCXBR] = &Simulator::Evaluate_LCXBR; EvalTable[LEDBRA] = &Simulator::Evaluate_LEDBRA; EvalTable[LDXBRA] = &Simulator::Evaluate_LDXBRA; EvalTable[LEXBRA] = &Simulator::Evaluate_LEXBRA; EvalTable[FIXBRA] = &Simulator::Evaluate_FIXBRA; EvalTable[KXBR] = &Simulator::Evaluate_KXBR; EvalTable[CXBR] = &Simulator::Evaluate_CXBR; EvalTable[AXBR] = &Simulator::Evaluate_AXBR; EvalTable[SXBR] = &Simulator::Evaluate_SXBR; EvalTable[MXBR] = &Simulator::Evaluate_MXBR; EvalTable[DXBR] = &Simulator::Evaluate_DXBR; EvalTable[TBEDR] = &Simulator::Evaluate_TBEDR; EvalTable[TBDR] = &Simulator::Evaluate_TBDR; EvalTable[DIEBR] = &Simulator::Evaluate_DIEBR; EvalTable[FIEBRA] = &Simulator::Evaluate_FIEBRA; EvalTable[THDER] = &Simulator::Evaluate_THDER; EvalTable[THDR] = &Simulator::Evaluate_THDR; EvalTable[DIDBR] = &Simulator::Evaluate_DIDBR; EvalTable[FIDBRA] = &Simulator::Evaluate_FIDBRA; EvalTable[LXR] = &Simulator::Evaluate_LXR; EvalTable[LPDFR] = &Simulator::Evaluate_LPDFR; EvalTable[LNDFR] = &Simulator::Evaluate_LNDFR; EvalTable[LCDFR] = &Simulator::Evaluate_LCDFR; EvalTable[LZER] = &Simulator::Evaluate_LZER; EvalTable[LZDR] = &Simulator::Evaluate_LZDR; EvalTable[LZXR] = &Simulator::Evaluate_LZXR; EvalTable[SFPC] = &Simulator::Evaluate_SFPC; EvalTable[SFASR] = &Simulator::Evaluate_SFASR; EvalTable[EFPC] = &Simulator::Evaluate_EFPC; EvalTable[CELFBR] = &Simulator::Evaluate_CELFBR; EvalTable[CDLFBR] = &Simulator::Evaluate_CDLFBR; EvalTable[CXLFBR] = &Simulator::Evaluate_CXLFBR; EvalTable[CEFBRA] = &Simulator::Evaluate_CEFBRA; EvalTable[CDFBRA] = &Simulator::Evaluate_CDFBRA; EvalTable[CXFBRA] = &Simulator::Evaluate_CXFBRA; EvalTable[CFEBRA] = &Simulator::Evaluate_CFEBRA; EvalTable[CFDBRA] = &Simulator::Evaluate_CFDBRA; EvalTable[CFXBRA] = &Simulator::Evaluate_CFXBRA; EvalTable[CLFEBR] = &Simulator::Evaluate_CLFEBR; EvalTable[CLFDBR] = &Simulator::Evaluate_CLFDBR; EvalTable[CLFXBR] = &Simulator::Evaluate_CLFXBR; EvalTable[CELGBR] = &Simulator::Evaluate_CELGBR; EvalTable[CDLGBR] = &Simulator::Evaluate_CDLGBR; EvalTable[CXLGBR] = &Simulator::Evaluate_CXLGBR; EvalTable[CEGBRA] = &Simulator::Evaluate_CEGBRA; EvalTable[CDGBRA] = &Simulator::Evaluate_CDGBRA; EvalTable[CXGBRA] = &Simulator::Evaluate_CXGBRA; EvalTable[CGEBRA] = &Simulator::Evaluate_CGEBRA; EvalTable[CGDBRA] = &Simulator::Evaluate_CGDBRA; EvalTable[CGXBRA] = &Simulator::Evaluate_CGXBRA; EvalTable[CLGEBR] = &Simulator::Evaluate_CLGEBR; EvalTable[CLGDBR] = &Simulator::Evaluate_CLGDBR; EvalTable[CFER] = &Simulator::Evaluate_CFER; EvalTable[CFDR] = &Simulator::Evaluate_CFDR; EvalTable[CFXR] = &Simulator::Evaluate_CFXR; EvalTable[LDGR] = &Simulator::Evaluate_LDGR; EvalTable[CGER] = &Simulator::Evaluate_CGER; EvalTable[CGDR] = &Simulator::Evaluate_CGDR; EvalTable[CGXR] = &Simulator::Evaluate_CGXR; EvalTable[LGDR] = &Simulator::Evaluate_LGDR; EvalTable[MDTR] = &Simulator::Evaluate_MDTR; EvalTable[MDTRA] = &Simulator::Evaluate_MDTRA; EvalTable[DDTRA] = &Simulator::Evaluate_DDTRA; EvalTable[ADTRA] = &Simulator::Evaluate_ADTRA; EvalTable[SDTRA] = &Simulator::Evaluate_SDTRA; EvalTable[LDETR] = &Simulator::Evaluate_LDETR; EvalTable[LEDTR] = &Simulator::Evaluate_LEDTR; EvalTable[LTDTR] = &Simulator::Evaluate_LTDTR; EvalTable[FIDTR] = &Simulator::Evaluate_FIDTR; EvalTable[MXTRA] = &Simulator::Evaluate_MXTRA; EvalTable[DXTRA] = &Simulator::Evaluate_DXTRA; EvalTable[AXTRA] = &Simulator::Evaluate_AXTRA; EvalTable[SXTRA] = &Simulator::Evaluate_SXTRA; EvalTable[LXDTR] = &Simulator::Evaluate_LXDTR; EvalTable[LDXTR] = &Simulator::Evaluate_LDXTR; EvalTable[LTXTR] = &Simulator::Evaluate_LTXTR; EvalTable[FIXTR] = &Simulator::Evaluate_FIXTR; EvalTable[KDTR] = &Simulator::Evaluate_KDTR; EvalTable[CGDTRA] = &Simulator::Evaluate_CGDTRA; EvalTable[CUDTR] = &Simulator::Evaluate_CUDTR; EvalTable[CDTR] = &Simulator::Evaluate_CDTR; EvalTable[EEDTR] = &Simulator::Evaluate_EEDTR; EvalTable[ESDTR] = &Simulator::Evaluate_ESDTR; EvalTable[KXTR] = &Simulator::Evaluate_KXTR; EvalTable[CGXTRA] = &Simulator::Evaluate_CGXTRA; EvalTable[CUXTR] = &Simulator::Evaluate_CUXTR; EvalTable[CSXTR] = &Simulator::Evaluate_CSXTR; EvalTable[CXTR] = &Simulator::Evaluate_CXTR; EvalTable[EEXTR] = &Simulator::Evaluate_EEXTR; EvalTable[ESXTR] = &Simulator::Evaluate_ESXTR; EvalTable[CDGTRA] = &Simulator::Evaluate_CDGTRA; EvalTable[CDUTR] = &Simulator::Evaluate_CDUTR; EvalTable[CDSTR] = &Simulator::Evaluate_CDSTR; EvalTable[CEDTR] = &Simulator::Evaluate_CEDTR; EvalTable[QADTR] = &Simulator::Evaluate_QADTR; EvalTable[IEDTR] = &Simulator::Evaluate_IEDTR; EvalTable[RRDTR] = &Simulator::Evaluate_RRDTR; EvalTable[CXGTRA] = &Simulator::Evaluate_CXGTRA; EvalTable[CXUTR] = &Simulator::Evaluate_CXUTR; EvalTable[CXSTR] = &Simulator::Evaluate_CXSTR; EvalTable[CEXTR] = &Simulator::Evaluate_CEXTR; EvalTable[QAXTR] = &Simulator::Evaluate_QAXTR; EvalTable[IEXTR] = &Simulator::Evaluate_IEXTR; EvalTable[RRXTR] = &Simulator::Evaluate_RRXTR; EvalTable[LPGR] = &Simulator::Evaluate_LPGR; EvalTable[LNGR] = &Simulator::Evaluate_LNGR; EvalTable[LTGR] = &Simulator::Evaluate_LTGR; EvalTable[LCGR] = &Simulator::Evaluate_LCGR; EvalTable[LGR] = &Simulator::Evaluate_LGR; EvalTable[LGBR] = &Simulator::Evaluate_LGBR; EvalTable[LGHR] = &Simulator::Evaluate_LGHR; EvalTable[AGR] = &Simulator::Evaluate_AGR; EvalTable[SGR] = &Simulator::Evaluate_SGR; EvalTable[ALGR] = &Simulator::Evaluate_ALGR; EvalTable[SLGR] = &Simulator::Evaluate_SLGR; EvalTable[MSGR] = &Simulator::Evaluate_MSGR; EvalTable[DSGR] = &Simulator::Evaluate_DSGR; EvalTable[LRVGR] = &Simulator::Evaluate_LRVGR; EvalTable[LPGFR] = &Simulator::Evaluate_LPGFR; EvalTable[LNGFR] = &Simulator::Evaluate_LNGFR; EvalTable[LTGFR] = &Simulator::Evaluate_LTGFR; EvalTable[LCGFR] = &Simulator::Evaluate_LCGFR; EvalTable[LGFR] = &Simulator::Evaluate_LGFR; EvalTable[LLGFR] = &Simulator::Evaluate_LLGFR; EvalTable[LLGTR] = &Simulator::Evaluate_LLGTR; EvalTable[AGFR] = &Simulator::Evaluate_AGFR; EvalTable[SGFR] = &Simulator::Evaluate_SGFR; EvalTable[ALGFR] = &Simulator::Evaluate_ALGFR; EvalTable[SLGFR] = &Simulator::Evaluate_SLGFR; EvalTable[MSGFR] = &Simulator::Evaluate_MSGFR; EvalTable[DSGFR] = &Simulator::Evaluate_DSGFR; EvalTable[KMAC] = &Simulator::Evaluate_KMAC; EvalTable[LRVR] = &Simulator::Evaluate_LRVR; EvalTable[CGR] = &Simulator::Evaluate_CGR; EvalTable[CLGR] = &Simulator::Evaluate_CLGR; EvalTable[LBR] = &Simulator::Evaluate_LBR; EvalTable[LHR] = &Simulator::Evaluate_LHR; EvalTable[KMF] = &Simulator::Evaluate_KMF; EvalTable[KMO] = &Simulator::Evaluate_KMO; EvalTable[PCC] = &Simulator::Evaluate_PCC; EvalTable[KMCTR] = &Simulator::Evaluate_KMCTR; EvalTable[KM] = &Simulator::Evaluate_KM; EvalTable[KMC] = &Simulator::Evaluate_KMC; EvalTable[CGFR] = &Simulator::Evaluate_CGFR; EvalTable[KIMD] = &Simulator::Evaluate_KIMD; EvalTable[KLMD] = &Simulator::Evaluate_KLMD; EvalTable[CFDTR] = &Simulator::Evaluate_CFDTR; EvalTable[CLGDTR] = &Simulator::Evaluate_CLGDTR; EvalTable[CLFDTR] = &Simulator::Evaluate_CLFDTR; EvalTable[BCTGR] = &Simulator::Evaluate_BCTGR; EvalTable[CFXTR] = &Simulator::Evaluate_CFXTR; EvalTable[CLFXTR] = &Simulator::Evaluate_CLFXTR; EvalTable[CDFTR] = &Simulator::Evaluate_CDFTR; EvalTable[CDLGTR] = &Simulator::Evaluate_CDLGTR; EvalTable[CDLFTR] = &Simulator::Evaluate_CDLFTR; EvalTable[CXFTR] = &Simulator::Evaluate_CXFTR; EvalTable[CXLGTR] = &Simulator::Evaluate_CXLGTR; EvalTable[CXLFTR] = &Simulator::Evaluate_CXLFTR; EvalTable[CGRT] = &Simulator::Evaluate_CGRT; EvalTable[NGR] = &Simulator::Evaluate_NGR; EvalTable[OGR] = &Simulator::Evaluate_OGR; EvalTable[XGR] = &Simulator::Evaluate_XGR; EvalTable[FLOGR] = &Simulator::Evaluate_FLOGR; EvalTable[LLGCR] = &Simulator::Evaluate_LLGCR; EvalTable[LLGHR] = &Simulator::Evaluate_LLGHR; EvalTable[MLGR] = &Simulator::Evaluate_MLGR; EvalTable[DLGR] = &Simulator::Evaluate_DLGR; EvalTable[ALCGR] = &Simulator::Evaluate_ALCGR; EvalTable[SLBGR] = &Simulator::Evaluate_SLBGR; EvalTable[EPSW] = &Simulator::Evaluate_EPSW; EvalTable[TRTT] = &Simulator::Evaluate_TRTT; EvalTable[TRTO] = &Simulator::Evaluate_TRTO; EvalTable[TROT] = &Simulator::Evaluate_TROT; EvalTable[TROO] = &Simulator::Evaluate_TROO; EvalTable[LLCR] = &Simulator::Evaluate_LLCR; EvalTable[LLHR] = &Simulator::Evaluate_LLHR; EvalTable[MLR] = &Simulator::Evaluate_MLR; EvalTable[DLR] = &Simulator::Evaluate_DLR; EvalTable[ALCR] = &Simulator::Evaluate_ALCR; EvalTable[SLBR] = &Simulator::Evaluate_SLBR; EvalTable[CU14] = &Simulator::Evaluate_CU14; EvalTable[CU24] = &Simulator::Evaluate_CU24; EvalTable[CU41] = &Simulator::Evaluate_CU41; EvalTable[CU42] = &Simulator::Evaluate_CU42; EvalTable[TRTRE] = &Simulator::Evaluate_TRTRE; EvalTable[SRSTU] = &Simulator::Evaluate_SRSTU; EvalTable[TRTE] = &Simulator::Evaluate_TRTE; EvalTable[AHHHR] = &Simulator::Evaluate_AHHHR; EvalTable[SHHHR] = &Simulator::Evaluate_SHHHR; EvalTable[ALHHHR] = &Simulator::Evaluate_ALHHHR; EvalTable[SLHHHR] = &Simulator::Evaluate_SLHHHR; EvalTable[CHHR] = &Simulator::Evaluate_CHHR; EvalTable[AHHLR] = &Simulator::Evaluate_AHHLR; EvalTable[SHHLR] = &Simulator::Evaluate_SHHLR; EvalTable[ALHHLR] = &Simulator::Evaluate_ALHHLR; EvalTable[SLHHLR] = &Simulator::Evaluate_SLHHLR; EvalTable[CHLR] = &Simulator::Evaluate_CHLR; EvalTable[POPCNT_Z] = &Simulator::Evaluate_POPCNT_Z; EvalTable[LOCGR] = &Simulator::Evaluate_LOCGR; EvalTable[NGRK] = &Simulator::Evaluate_NGRK; EvalTable[OGRK] = &Simulator::Evaluate_OGRK; EvalTable[XGRK] = &Simulator::Evaluate_XGRK; EvalTable[AGRK] = &Simulator::Evaluate_AGRK; EvalTable[SGRK] = &Simulator::Evaluate_SGRK; EvalTable[ALGRK] = &Simulator::Evaluate_ALGRK; EvalTable[SLGRK] = &Simulator::Evaluate_SLGRK; EvalTable[LOCR] = &Simulator::Evaluate_LOCR; EvalTable[NRK] = &Simulator::Evaluate_NRK; EvalTable[ORK] = &Simulator::Evaluate_ORK; EvalTable[XRK] = &Simulator::Evaluate_XRK; EvalTable[ARK] = &Simulator::Evaluate_ARK; EvalTable[SRK] = &Simulator::Evaluate_SRK; EvalTable[ALRK] = &Simulator::Evaluate_ALRK; EvalTable[SLRK] = &Simulator::Evaluate_SLRK; EvalTable[LTG] = &Simulator::Evaluate_LTG; EvalTable[LG] = &Simulator::Evaluate_LG; EvalTable[CVBY] = &Simulator::Evaluate_CVBY; EvalTable[AG] = &Simulator::Evaluate_AG; EvalTable[SG] = &Simulator::Evaluate_SG; EvalTable[ALG] = &Simulator::Evaluate_ALG; EvalTable[SLG] = &Simulator::Evaluate_SLG; EvalTable[MSG] = &Simulator::Evaluate_MSG; EvalTable[DSG] = &Simulator::Evaluate_DSG; EvalTable[CVBG] = &Simulator::Evaluate_CVBG; EvalTable[LRVG] = &Simulator::Evaluate_LRVG; EvalTable[LT] = &Simulator::Evaluate_LT; EvalTable[LGF] = &Simulator::Evaluate_LGF; EvalTable[LGH] = &Simulator::Evaluate_LGH; EvalTable[LLGF] = &Simulator::Evaluate_LLGF; EvalTable[LLGT] = &Simulator::Evaluate_LLGT; EvalTable[AGF] = &Simulator::Evaluate_AGF; EvalTable[SGF] = &Simulator::Evaluate_SGF; EvalTable[ALGF] = &Simulator::Evaluate_ALGF; EvalTable[SLGF] = &Simulator::Evaluate_SLGF; EvalTable[MSGF] = &Simulator::Evaluate_MSGF; EvalTable[DSGF] = &Simulator::Evaluate_DSGF; EvalTable[LRV] = &Simulator::Evaluate_LRV; EvalTable[LRVH] = &Simulator::Evaluate_LRVH; EvalTable[CG] = &Simulator::Evaluate_CG; EvalTable[CLG] = &Simulator::Evaluate_CLG; EvalTable[STG] = &Simulator::Evaluate_STG; EvalTable[NTSTG] = &Simulator::Evaluate_NTSTG; EvalTable[CVDY] = &Simulator::Evaluate_CVDY; EvalTable[CVDG] = &Simulator::Evaluate_CVDG; EvalTable[STRVG] = &Simulator::Evaluate_STRVG; EvalTable[CGF] = &Simulator::Evaluate_CGF; EvalTable[CLGF] = &Simulator::Evaluate_CLGF; EvalTable[LTGF] = &Simulator::Evaluate_LTGF; EvalTable[CGH] = &Simulator::Evaluate_CGH; EvalTable[PFD] = &Simulator::Evaluate_PFD; EvalTable[STRV] = &Simulator::Evaluate_STRV; EvalTable[STRVH] = &Simulator::Evaluate_STRVH; EvalTable[BCTG] = &Simulator::Evaluate_BCTG; EvalTable[STY] = &Simulator::Evaluate_STY; EvalTable[MSY] = &Simulator::Evaluate_MSY; EvalTable[NY] = &Simulator::Evaluate_NY; EvalTable[CLY] = &Simulator::Evaluate_CLY; EvalTable[OY] = &Simulator::Evaluate_OY; EvalTable[XY] = &Simulator::Evaluate_XY; EvalTable[LY] = &Simulator::Evaluate_LY; EvalTable[CY] = &Simulator::Evaluate_CY; EvalTable[AY] = &Simulator::Evaluate_AY; EvalTable[SY] = &Simulator::Evaluate_SY; EvalTable[MFY] = &Simulator::Evaluate_MFY; EvalTable[ALY] = &Simulator::Evaluate_ALY; EvalTable[SLY] = &Simulator::Evaluate_SLY; EvalTable[STHY] = &Simulator::Evaluate_STHY; EvalTable[LAY] = &Simulator::Evaluate_LAY; EvalTable[STCY] = &Simulator::Evaluate_STCY; EvalTable[ICY] = &Simulator::Evaluate_ICY; EvalTable[LAEY] = &Simulator::Evaluate_LAEY; EvalTable[LB] = &Simulator::Evaluate_LB; EvalTable[LGB] = &Simulator::Evaluate_LGB; EvalTable[LHY] = &Simulator::Evaluate_LHY; EvalTable[CHY] = &Simulator::Evaluate_CHY; EvalTable[AHY] = &Simulator::Evaluate_AHY; EvalTable[SHY] = &Simulator::Evaluate_SHY; EvalTable[MHY] = &Simulator::Evaluate_MHY; EvalTable[NG] = &Simulator::Evaluate_NG; EvalTable[OG] = &Simulator::Evaluate_OG; EvalTable[XG] = &Simulator::Evaluate_XG; EvalTable[LGAT] = &Simulator::Evaluate_LGAT; EvalTable[MLG] = &Simulator::Evaluate_MLG; EvalTable[DLG] = &Simulator::Evaluate_DLG; EvalTable[ALCG] = &Simulator::Evaluate_ALCG; EvalTable[SLBG] = &Simulator::Evaluate_SLBG; EvalTable[STPQ] = &Simulator::Evaluate_STPQ; EvalTable[LPQ] = &Simulator::Evaluate_LPQ; EvalTable[LLGC] = &Simulator::Evaluate_LLGC; EvalTable[LLGH] = &Simulator::Evaluate_LLGH; EvalTable[LLC] = &Simulator::Evaluate_LLC; EvalTable[LLH] = &Simulator::Evaluate_LLH; EvalTable[ML] = &Simulator::Evaluate_ML; EvalTable[DL] = &Simulator::Evaluate_DL; EvalTable[ALC] = &Simulator::Evaluate_ALC; EvalTable[SLB] = &Simulator::Evaluate_SLB; EvalTable[LLGTAT] = &Simulator::Evaluate_LLGTAT; EvalTable[LLGFAT] = &Simulator::Evaluate_LLGFAT; EvalTable[LAT] = &Simulator::Evaluate_LAT; EvalTable[LBH] = &Simulator::Evaluate_LBH; EvalTable[LLCH] = &Simulator::Evaluate_LLCH; EvalTable[STCH] = &Simulator::Evaluate_STCH; EvalTable[LHH] = &Simulator::Evaluate_LHH; EvalTable[LLHH] = &Simulator::Evaluate_LLHH; EvalTable[STHH] = &Simulator::Evaluate_STHH; EvalTable[LFHAT] = &Simulator::Evaluate_LFHAT; EvalTable[LFH] = &Simulator::Evaluate_LFH; EvalTable[STFH] = &Simulator::Evaluate_STFH; EvalTable[CHF] = &Simulator::Evaluate_CHF; EvalTable[MVCDK] = &Simulator::Evaluate_MVCDK; EvalTable[MVHHI] = &Simulator::Evaluate_MVHHI; EvalTable[MVGHI] = &Simulator::Evaluate_MVGHI; EvalTable[MVHI] = &Simulator::Evaluate_MVHI; EvalTable[CHHSI] = &Simulator::Evaluate_CHHSI; EvalTable[CGHSI] = &Simulator::Evaluate_CGHSI; EvalTable[CHSI] = &Simulator::Evaluate_CHSI; EvalTable[CLFHSI] = &Simulator::Evaluate_CLFHSI; EvalTable[TBEGIN] = &Simulator::Evaluate_TBEGIN; EvalTable[TBEGINC] = &Simulator::Evaluate_TBEGINC; EvalTable[LMG] = &Simulator::Evaluate_LMG; EvalTable[SRAG] = &Simulator::Evaluate_SRAG; EvalTable[SLAG] = &Simulator::Evaluate_SLAG; EvalTable[SRLG] = &Simulator::Evaluate_SRLG; EvalTable[SLLG] = &Simulator::Evaluate_SLLG; EvalTable[CSY] = &Simulator::Evaluate_CSY; EvalTable[RLLG] = &Simulator::Evaluate_RLLG; EvalTable[RLL] = &Simulator::Evaluate_RLL; EvalTable[STMG] = &Simulator::Evaluate_STMG; EvalTable[STMH] = &Simulator::Evaluate_STMH; EvalTable[STCMH] = &Simulator::Evaluate_STCMH; EvalTable[STCMY] = &Simulator::Evaluate_STCMY; EvalTable[CDSY] = &Simulator::Evaluate_CDSY; EvalTable[CDSG] = &Simulator::Evaluate_CDSG; EvalTable[BXHG] = &Simulator::Evaluate_BXHG; EvalTable[BXLEG] = &Simulator::Evaluate_BXLEG; EvalTable[ECAG] = &Simulator::Evaluate_ECAG; EvalTable[TMY] = &Simulator::Evaluate_TMY; EvalTable[MVIY] = &Simulator::Evaluate_MVIY; EvalTable[NIY] = &Simulator::Evaluate_NIY; EvalTable[CLIY] = &Simulator::Evaluate_CLIY; EvalTable[OIY] = &Simulator::Evaluate_OIY; EvalTable[XIY] = &Simulator::Evaluate_XIY; EvalTable[ASI] = &Simulator::Evaluate_ASI; EvalTable[ALSI] = &Simulator::Evaluate_ALSI; EvalTable[AGSI] = &Simulator::Evaluate_AGSI; EvalTable[ALGSI] = &Simulator::Evaluate_ALGSI; EvalTable[ICMH] = &Simulator::Evaluate_ICMH; EvalTable[ICMY] = &Simulator::Evaluate_ICMY; EvalTable[MVCLU] = &Simulator::Evaluate_MVCLU; EvalTable[CLCLU] = &Simulator::Evaluate_CLCLU; EvalTable[STMY] = &Simulator::Evaluate_STMY; EvalTable[LMH] = &Simulator::Evaluate_LMH; EvalTable[LMY] = &Simulator::Evaluate_LMY; EvalTable[TP] = &Simulator::Evaluate_TP; EvalTable[SRAK] = &Simulator::Evaluate_SRAK; EvalTable[SLAK] = &Simulator::Evaluate_SLAK; EvalTable[SRLK] = &Simulator::Evaluate_SRLK; EvalTable[SLLK] = &Simulator::Evaluate_SLLK; EvalTable[LOCG] = &Simulator::Evaluate_LOCG; EvalTable[STOCG] = &Simulator::Evaluate_STOCG; EvalTable[LANG] = &Simulator::Evaluate_LANG; EvalTable[LAOG] = &Simulator::Evaluate_LAOG; EvalTable[LAXG] = &Simulator::Evaluate_LAXG; EvalTable[LAAG] = &Simulator::Evaluate_LAAG; EvalTable[LAALG] = &Simulator::Evaluate_LAALG; EvalTable[LOC] = &Simulator::Evaluate_LOC; EvalTable[STOC] = &Simulator::Evaluate_STOC; EvalTable[LAN] = &Simulator::Evaluate_LAN; EvalTable[LAO] = &Simulator::Evaluate_LAO; EvalTable[LAX] = &Simulator::Evaluate_LAX; EvalTable[LAA] = &Simulator::Evaluate_LAA; EvalTable[LAAL] = &Simulator::Evaluate_LAAL; EvalTable[BRXHG] = &Simulator::Evaluate_BRXHG; EvalTable[BRXLG] = &Simulator::Evaluate_BRXLG; EvalTable[RISBLG] = &Simulator::Evaluate_RISBLG; EvalTable[RNSBG] = &Simulator::Evaluate_RNSBG; EvalTable[RISBG] = &Simulator::Evaluate_RISBG; EvalTable[ROSBG] = &Simulator::Evaluate_ROSBG; EvalTable[RXSBG] = &Simulator::Evaluate_RXSBG; EvalTable[RISBGN] = &Simulator::Evaluate_RISBGN; EvalTable[RISBHG] = &Simulator::Evaluate_RISBHG; EvalTable[CGRJ] = &Simulator::Evaluate_CGRJ; EvalTable[CGIT] = &Simulator::Evaluate_CGIT; EvalTable[CIT] = &Simulator::Evaluate_CIT; EvalTable[CLFIT] = &Simulator::Evaluate_CLFIT; EvalTable[CGIJ] = &Simulator::Evaluate_CGIJ; EvalTable[CIJ] = &Simulator::Evaluate_CIJ; EvalTable[AHIK] = &Simulator::Evaluate_AHIK; EvalTable[AGHIK] = &Simulator::Evaluate_AGHIK; EvalTable[ALHSIK] = &Simulator::Evaluate_ALHSIK; EvalTable[ALGHSIK] = &Simulator::Evaluate_ALGHSIK; EvalTable[CGRB] = &Simulator::Evaluate_CGRB; EvalTable[CGIB] = &Simulator::Evaluate_CGIB; EvalTable[CIB] = &Simulator::Evaluate_CIB; EvalTable[LDEB] = &Simulator::Evaluate_LDEB; EvalTable[LXDB] = &Simulator::Evaluate_LXDB; EvalTable[LXEB] = &Simulator::Evaluate_LXEB; EvalTable[MXDB] = &Simulator::Evaluate_MXDB; EvalTable[KEB] = &Simulator::Evaluate_KEB; EvalTable[CEB] = &Simulator::Evaluate_CEB; EvalTable[AEB] = &Simulator::Evaluate_AEB; EvalTable[SEB] = &Simulator::Evaluate_SEB; EvalTable[MDEB] = &Simulator::Evaluate_MDEB; EvalTable[DEB] = &Simulator::Evaluate_DEB; EvalTable[MAEB] = &Simulator::Evaluate_MAEB; EvalTable[MSEB] = &Simulator::Evaluate_MSEB; EvalTable[TCEB] = &Simulator::Evaluate_TCEB; EvalTable[TCDB] = &Simulator::Evaluate_TCDB; EvalTable[TCXB] = &Simulator::Evaluate_TCXB; EvalTable[SQEB] = &Simulator::Evaluate_SQEB; EvalTable[SQDB] = &Simulator::Evaluate_SQDB; EvalTable[MEEB] = &Simulator::Evaluate_MEEB; EvalTable[KDB] = &Simulator::Evaluate_KDB; EvalTable[CDB] = &Simulator::Evaluate_CDB; EvalTable[ADB] = &Simulator::Evaluate_ADB; EvalTable[SDB] = &Simulator::Evaluate_SDB; EvalTable[MDB] = &Simulator::Evaluate_MDB; EvalTable[DDB] = &Simulator::Evaluate_DDB; EvalTable[MADB] = &Simulator::Evaluate_MADB; EvalTable[MSDB] = &Simulator::Evaluate_MSDB; EvalTable[SLDT] = &Simulator::Evaluate_SLDT; EvalTable[SRDT] = &Simulator::Evaluate_SRDT; EvalTable[SLXT] = &Simulator::Evaluate_SLXT; EvalTable[SRXT] = &Simulator::Evaluate_SRXT; EvalTable[TDCET] = &Simulator::Evaluate_TDCET; EvalTable[TDGET] = &Simulator::Evaluate_TDGET; EvalTable[TDCDT] = &Simulator::Evaluate_TDCDT; EvalTable[TDGDT] = &Simulator::Evaluate_TDGDT; EvalTable[TDCXT] = &Simulator::Evaluate_TDCXT; EvalTable[TDGXT] = &Simulator::Evaluate_TDGXT; EvalTable[LEY] = &Simulator::Evaluate_LEY; EvalTable[LDY] = &Simulator::Evaluate_LDY; EvalTable[STEY] = &Simulator::Evaluate_STEY; EvalTable[STDY] = &Simulator::Evaluate_STDY; EvalTable[CZDT] = &Simulator::Evaluate_CZDT; EvalTable[CZXT] = &Simulator::Evaluate_CZXT; EvalTable[CDZT] = &Simulator::Evaluate_CDZT; EvalTable[CXZT] = &Simulator::Evaluate_CXZT; } // NOLINT Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { i_cache_ = isolate_->simulator_i_cache(); if (i_cache_ == NULL) { i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch); isolate_->set_simulator_i_cache(i_cache_); } Initialize(isolate); // Set up simulator support first. Some of this information is needed to // setup the architecture state. #if V8_TARGET_ARCH_S390X size_t stack_size = FLAG_sim_stack_size * KB; #else size_t stack_size = MB; // allocate 1MB for stack #endif stack_size += 2 * stack_protection_size_; stack_ = reinterpret_cast(malloc(stack_size)); pc_modified_ = false; icount_ = 0; break_pc_ = NULL; break_instr_ = 0; // make sure our register type can hold exactly 4/8 bytes #ifdef V8_TARGET_ARCH_S390X DCHECK(sizeof(intptr_t) == 8); #else DCHECK(sizeof(intptr_t) == 4); #endif // Set up architecture state. // All registers are initialized to zero to start with. for (int i = 0; i < kNumGPRs; i++) { registers_[i] = 0; } condition_reg_ = 0; special_reg_pc_ = 0; // Initializing FP registers. for (int i = 0; i < kNumFPRs; i++) { fp_registers_[i] = 0.0; } // The sp is initialized to point to the bottom (high address) of the // allocated stack area. To be safe in potential stack underflows we leave // some buffer below. registers_[sp] = reinterpret_cast(stack_) + stack_size - stack_protection_size_; last_debugger_input_ = NULL; } Simulator::~Simulator() { free(stack_); } // When the generated code calls an external reference we need to catch that in // the simulator. The external reference will be a function compiled for the // host architecture. We need to call that function instead of trying to // execute it with the simulator. We do that by redirecting the external // reference to a svc (Supervisor Call) instruction that is handled by // the simulator. We write the original destination of the jump just at a known // offset from the svc instruction so the simulator knows what to call. class Redirection { public: Redirection(Isolate* isolate, void* external_function, ExternalReference::Type type) : external_function_(external_function), // we use TRAP4 here (0xBF22) #if V8_TARGET_LITTLE_ENDIAN swi_instruction_(0x1000FFB2), #else swi_instruction_(0xB2FF0000 | kCallRtRedirected), #endif type_(type), next_(NULL) { next_ = isolate->simulator_redirection(); Simulator::current(isolate)->FlushICache( isolate->simulator_i_cache(), reinterpret_cast(&swi_instruction_), sizeof(FourByteInstr)); isolate->set_simulator_redirection(this); if (ABI_USES_FUNCTION_DESCRIPTORS) { function_descriptor_[0] = reinterpret_cast(&swi_instruction_); function_descriptor_[1] = 0; function_descriptor_[2] = 0; } } void* address() { if (ABI_USES_FUNCTION_DESCRIPTORS) { return reinterpret_cast(function_descriptor_); } else { return reinterpret_cast(&swi_instruction_); } } void* external_function() { return external_function_; } ExternalReference::Type type() { return type_; } static Redirection* Get(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* current = isolate->simulator_redirection(); for (; current != NULL; current = current->next_) { if (current->external_function_ == external_function) { DCHECK_EQ(current->type(), type); return current; } } return new Redirection(isolate, external_function, type); } static Redirection* FromSwiInstruction(Instruction* swi_instruction) { char* addr_of_swi = reinterpret_cast(swi_instruction); char* addr_of_redirection = addr_of_swi - offsetof(Redirection, swi_instruction_); return reinterpret_cast(addr_of_redirection); } static Redirection* FromAddress(void* address) { int delta = ABI_USES_FUNCTION_DESCRIPTORS ? offsetof(Redirection, function_descriptor_) : offsetof(Redirection, swi_instruction_); char* addr_of_redirection = reinterpret_cast(address) - delta; return reinterpret_cast(addr_of_redirection); } static void* ReverseRedirection(intptr_t reg) { Redirection* redirection = FromAddress(reinterpret_cast(reg)); return redirection->external_function(); } static void DeleteChain(Redirection* redirection) { while (redirection != nullptr) { Redirection* next = redirection->next_; delete redirection; redirection = next; } } private: void* external_function_; uint32_t swi_instruction_; ExternalReference::Type type_; Redirection* next_; intptr_t function_descriptor_[3]; }; // static void Simulator::TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first) { Redirection::DeleteChain(first); if (i_cache != nullptr) { for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; entry = i_cache->Next(entry)) { delete static_cast(entry->value); } delete i_cache; } } void* Simulator::RedirectExternalReference(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* redirection = Redirection::Get(isolate, external_function, type); return redirection->address(); } // Get the active Simulator for the current thread. Simulator* Simulator::current(Isolate* isolate) { v8::internal::Isolate::PerIsolateThreadData* isolate_data = isolate->FindOrAllocatePerThreadDataForThisThread(); DCHECK(isolate_data != NULL); Simulator* sim = isolate_data->simulator(); if (sim == NULL) { // TODO(146): delete the simulator object when a thread/isolate goes away. sim = new Simulator(isolate); isolate_data->set_simulator(sim); } return sim; } // Sets the register in the architecture state. void Simulator::set_register(int reg, uint64_t value) { DCHECK((reg >= 0) && (reg < kNumGPRs)); registers_[reg] = value; } // Get the register from the architecture state. uint64_t Simulator::get_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return registers_[reg]; } template T Simulator::get_low_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] & 0xFFFFFFFF); } template T Simulator::get_high_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] >> 32); } void Simulator::set_low_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value); uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val >> 32 << 32) | shifted_val; registers_[reg] = result; } void Simulator::set_high_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value) << 32; uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val & 0xFFFFFFFF) | shifted_val; registers_[reg] = result; } double Simulator::get_double_from_register_pair(int reg) { DCHECK((reg >= 0) && (reg < kNumGPRs) && ((reg % 2) == 0)); double dm_val = 0.0; #if 0 && !V8_TARGET_ARCH_S390X // doesn't make sense in 64bit mode // Read the bits from the unsigned integer register_[] array // into the double precision floating point value and return it. char buffer[sizeof(fp_registers_[0])]; memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0])); memcpy(&dm_val, buffer, 2 * sizeof(registers_[0])); #endif return (dm_val); } // Raw access to the PC register. void Simulator::set_pc(intptr_t value) { pc_modified_ = true; special_reg_pc_ = value; } bool Simulator::has_bad_pc() const { return ((special_reg_pc_ == bad_lr) || (special_reg_pc_ == end_sim_pc)); } // Raw access to the PC register without the special adjustment when reading. intptr_t Simulator::get_pc() const { return special_reg_pc_; } // Runtime FP routines take: // - two double arguments // - one double argument and zero or one integer arguments. // All are consructed here from d1, d2 and r2. void Simulator::GetFpArgs(double* x, double* y, intptr_t* z) { *x = get_double_from_d_register(0); *y = get_double_from_d_register(2); *z = get_register(2); } // The return value is in d0. void Simulator::SetFpResult(const double& result) { set_d_register_from_double(0, result); } void Simulator::TrashCallerSaveRegisters() { // We don't trash the registers with the return value. #if 0 // A good idea to trash volatile registers, needs to be done registers_[2] = 0x50Bad4U; registers_[3] = 0x50Bad4U; registers_[12] = 0x50Bad4U; #endif } uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); return *ptr; } int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteW(intptr_t addr, int32_t value, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint16_t Simulator::ReadHU(intptr_t addr, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); return *ptr; } int16_t Simulator::ReadH(intptr_t addr, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteH(intptr_t addr, uint16_t value, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteH(intptr_t addr, int16_t value, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint8_t Simulator::ReadBU(intptr_t addr) { uint8_t* ptr = reinterpret_cast(addr); return *ptr; } int8_t Simulator::ReadB(intptr_t addr) { int8_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteB(intptr_t addr, uint8_t value) { uint8_t* ptr = reinterpret_cast(addr); *ptr = value; } void Simulator::WriteB(intptr_t addr, int8_t value) { int8_t* ptr = reinterpret_cast(addr); *ptr = value; } int64_t Simulator::ReadDW(intptr_t addr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteDW(intptr_t addr, int64_t value) { int64_t* ptr = reinterpret_cast(addr); *ptr = value; return; } /** * Reads a double value from memory at given address. */ double Simulator::ReadDouble(intptr_t addr) { double* ptr = reinterpret_cast(addr); return *ptr; } // Returns the limit of the stack area to enable checking for stack overflows. uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { // The simulator uses a separate JS stack. If we have exhausted the C stack, // we also drop down the JS limit to reflect the exhaustion on the JS stack. if (GetCurrentStackPosition() < c_limit) { return reinterpret_cast(get_sp()); } // Otherwise the limit is the JS stack. Leave a safety margin to prevent // overrunning the stack when pushing values. return reinterpret_cast(stack_) + stack_protection_size_; } // Unsupported instructions use Format to print an error and stop execution. void Simulator::Format(Instruction* instr, const char* format) { PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", reinterpret_cast(instr), format); UNIMPLEMENTED(); } // Calculate C flag value for additions. bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); uint32_t urest = 0xffffffffU - uleft; return (uright > urest) || (carry && (((uright + 1) > urest) || (uright > (urest - 1)))); } // Calculate C flag value for subtractions. bool Simulator::BorrowFrom(int32_t left, int32_t right) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); return (uright > uleft); } // Calculate V flag value for additions and subtractions. template bool Simulator::OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition) { bool overflow; if (addition) { // operands have the same sign overflow = ((left >= 0 && right >= 0) || (left < 0 && right < 0)) // and operands and result have different sign && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } else { // operands have different signs overflow = ((left < 0 && right >= 0) || (left >= 0 && right < 0)) // and first operand and result have different signs && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } return overflow; } #if V8_TARGET_ARCH_S390X static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { *x = reinterpret_cast(pair->x); *y = reinterpret_cast(pair->y); } #else static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { #if V8_TARGET_BIG_ENDIAN *x = static_cast(*pair >> 32); *y = static_cast(*pair); #else *x = static_cast(*pair); *y = static_cast(*pair >> 32); #endif } #endif // Calls into the V8 runtime. typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); // These prototypes handle the four types of FP calls. typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPCall)(double darg0); typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). typedef void (*SimulatorRuntimeDirectApiCall)(intptr_t arg0); typedef void (*SimulatorRuntimeProfilingApiCall)(intptr_t arg0, void* arg1); // This signature supports direct call to accessor getter callback. typedef void (*SimulatorRuntimeDirectGetterCall)(intptr_t arg0, intptr_t arg1); typedef void (*SimulatorRuntimeProfilingGetterCall)(intptr_t arg0, intptr_t arg1, void* arg2); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. void Simulator::SoftwareInterrupt(Instruction* instr) { int svc = instr->SvcValue(); switch (svc) { case kCallRtRedirected: { // Check if stack is aligned. Error if not aligned is reported below to // include information on the function called. bool stack_aligned = (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; Redirection* redirection = Redirection::FromSwiInstruction(instr); const int kArgCount = 6; int arg0_regnum = 2; intptr_t result_buffer = 0; bool uses_result_buffer = redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && !ABI_RETURNS_OBJECTPAIR_IN_REGS); if (uses_result_buffer) { result_buffer = get_register(r2); arg0_regnum++; } intptr_t arg[kArgCount]; for (int i = 0; i < kArgCount - 1; i++) { arg[i] = get_register(arg0_regnum + i); } intptr_t* stack_pointer = reinterpret_cast(get_register(sp)); arg[5] = stack_pointer[kCalleeRegisterSaveAreaSize / kPointerSize]; bool fp_call = (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); // Place the return address on the stack, making the call GC safe. *reinterpret_cast(get_register(sp) + kStackFrameRASlot * kPointerSize) = get_register(r14); intptr_t external = reinterpret_cast(redirection->external_function()); if (fp_call) { double dval0, dval1; // one or two double parameters intptr_t ival; // zero or one integer parameters int iresult = 0; // integer return value double dresult = 0; // double return value GetFpArgs(&dval0, &dval1, &ival); if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall generic_target = reinterpret_cast(external); switch (redirection->type()) { case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Call to host function at %p with args %f, %f", static_cast(FUNCTION_ADDR(generic_target)), dval0, dval1); break; case ExternalReference::BUILTIN_FP_CALL: PrintF("Call to host function at %p with arg %f", static_cast(FUNCTION_ADDR(generic_target)), dval0); break; case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Call to host function at %p with args %f, %" V8PRIdPTR, static_cast(FUNCTION_ADDR(generic_target)), dval0, ival); break; default: UNREACHABLE(); break; } if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: { SimulatorRuntimeCompareCall target = reinterpret_cast(external); iresult = target(dval0, dval1); set_register(r2, iresult); break; } case ExternalReference::BUILTIN_FP_FP_CALL: { SimulatorRuntimeFPFPCall target = reinterpret_cast(external); dresult = target(dval0, dval1); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_CALL: { SimulatorRuntimeFPCall target = reinterpret_cast(external); dresult = target(dval0); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_INT_CALL: { SimulatorRuntimeFPIntCall target = reinterpret_cast(external); dresult = target(dval0, ival); SetFpResult(dresult); break; } default: UNREACHABLE(); break; } if (::v8::internal::FLAG_trace_sim || !stack_aligned) { switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Returned %08x\n", iresult); break; case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_FP_CALL: case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Returned %f\n", dresult); break; default: UNREACHABLE(); break; } } } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR, reinterpret_cast(external), arg[0]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectApiCall target = reinterpret_cast(external); target(arg[0]); } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingApiCall target = reinterpret_cast(external); target(arg[0], Redirection::ReverseRedirection(arg[1])); } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1]); } else if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1], arg[2]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); } else { // builtin call. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall target = reinterpret_cast(external); PrintF( "Call to host function at %p,\n" "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, static_cast(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { SimulatorRuntimeTripleCall target = reinterpret_cast(external); ObjectTriple result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", reinterpret_cast(result.x), reinterpret_cast(result.y), reinterpret_cast(result.z)); } memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectTriple)); set_register(r2, result_buffer); } else { if (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR) { SimulatorRuntimePairCall target = reinterpret_cast(external); ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); intptr_t x; intptr_t y; decodeObjectPair(&result, &x, &y); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); } if (ABI_RETURNS_OBJECTPAIR_IN_REGS) { set_register(r2, x); set_register(r3, y); } else { memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectPair)); set_register(r2, result_buffer); } } else { DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); SimulatorRuntimeCall target = reinterpret_cast(external); intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned %08" V8PRIxPTR "\n", result); } set_register(r2, result); } } // #if !V8_TARGET_ARCH_S390X // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL); // SimulatorRuntimeCall target = // reinterpret_cast(external); // int64_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // int32_t lo_res = static_cast(result); // int32_t hi_res = static_cast(result >> 32); // #if !V8_TARGET_LITTLE_ENDIAN // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", hi_res); // } // set_register(r2, hi_res); // set_register(r3, lo_res); // #else // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", lo_res); // } // set_register(r2, lo_res); // set_register(r3, hi_res); // #endif // #else // if (redirection->type() == ExternalReference::BUILTIN_CALL) { // SimulatorRuntimeCall target = // reinterpret_cast(external); // intptr_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR "\n", result); // } // set_register(r2, result); // } else { // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL_PAIR); // SimulatorRuntimePairCall target = // reinterpret_cast(external); // ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR ", %08" V8PRIxPTR "\n", // result.x, result.y); // } // #if ABI_RETURNS_OBJECTPAIR_IN_REGS // set_register(r2, result.x); // set_register(r3, result.y); // #else // memcpy(reinterpret_cast(result_buffer), &result, // sizeof(ObjectPair)); // #endif // } // #endif } int64_t saved_lr = *reinterpret_cast( get_register(sp) + kStackFrameRASlot * kPointerSize); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On zLinux-31, the saved_lr might be tagged with a high bit of 1. // Cleanse it before proceeding with simulation. saved_lr &= 0x7FFFFFFF; #endif set_pc(saved_lr); break; } case kBreakpoint: { S390Debugger dbg(this); dbg.Debug(); break; } // stop uses all codes greater than 1 << 23. default: { if (svc >= (1 << 23)) { uint32_t code = svc & kStopCodeMask; if (isWatchedStop(code)) { IncreaseStopCounter(code); } // Stop if it is enabled, otherwise go on jumping over the stop // and the message address. if (isEnabledStop(code)) { S390Debugger dbg(this); dbg.Stop(instr); } else { set_pc(get_pc() + sizeof(FourByteInstr) + kPointerSize); } } else { // This is not a valid svc code. UNREACHABLE(); break; } } } } // Stop helper functions. bool Simulator::isStopInstruction(Instruction* instr) { return (instr->Bits(27, 24) == 0xF) && (instr->SvcValue() >= kStopCode); } bool Simulator::isWatchedStop(uint32_t code) { DCHECK(code <= kMaxStopCode); return code < kNumOfWatchedStops; } bool Simulator::isEnabledStop(uint32_t code) { DCHECK(code <= kMaxStopCode); // Unwatched stops are always enabled. return !isWatchedStop(code) || !(watched_stops_[code].count & kStopDisabledBit); } void Simulator::EnableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (!isEnabledStop(code)) { watched_stops_[code].count &= ~kStopDisabledBit; } } void Simulator::DisableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (isEnabledStop(code)) { watched_stops_[code].count |= kStopDisabledBit; } } void Simulator::IncreaseStopCounter(uint32_t code) { DCHECK(code <= kMaxStopCode); DCHECK(isWatchedStop(code)); if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) { PrintF( "Stop counter for code %i has overflowed.\n" "Enabling this code and reseting the counter to 0.\n", code); watched_stops_[code].count = 0; EnableStop(code); } else { watched_stops_[code].count++; } } // Print a stop status. void Simulator::PrintStopInfo(uint32_t code) { DCHECK(code <= kMaxStopCode); if (!isWatchedStop(code)) { PrintF("Stop not watched."); } else { const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; int32_t count = watched_stops_[code].count & ~kStopDisabledBit; // Don't print the state of unused breakpoints. if (count != 0) { if (watched_stops_[code].desc) { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", code, code, state, count, watched_stops_[code].desc); } else { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", code, code, state, count); } } } } // Method for checking overflow on signed addition: // Test src1 and src2 have opposite sign, // (1) No overflow if they have opposite sign // (2) Test the result and one of the operands have opposite sign // (a) No overflow if they don't have opposite sign // (b) Overflow if opposite #define CheckOverflowForIntAdd(src1, src2, type) \ OverflowFromSigned(src1 + src2, src1, src2, true); #define CheckOverflowForIntSub(src1, src2, type) \ OverflowFromSigned(src1 - src2, src1, src2, false); // Method for checking overflow on unsigned addtion #define CheckOverflowForUIntAdd(src1, src2) \ ((src1) + (src2) < (src1) || (src1) + (src2) < (src2)) // Method for checking overflow on unsigned subtraction #define CheckOverflowForUIntSub(src1, src2) ((src1) - (src2) > (src1)) // Method for checking overflow on multiplication #define CheckOverflowForMul(src1, src2) (((src1) * (src2)) / (src2) != (src1)) // Method for checking overflow on shift right #define CheckOverflowForShiftRight(src1, src2) \ (((src1) >> (src2)) << (src2) != (src1)) // Method for checking overflow on shift left #define CheckOverflowForShiftLeft(src1, src2) \ (((src1) << (src2)) >> (src2) != (src1)) // S390 Decode and simulate helpers bool Simulator::DecodeTwoByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); switch (op) { // RR format instructions case AR: case SR: case MR: case DR: case OR: case NR: case XR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); bool isOF = false; switch (op) { case AR: isOF = CheckOverflowForIntAdd(r1_val, r2_val, int32_t); r1_val += r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case SR: isOF = CheckOverflowForIntSub(r1_val, r2_val, int32_t); r1_val -= r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case OR: r1_val |= r2_val; SetS390BitWiseConditionCode(r1_val); break; case NR: r1_val &= r2_val; SetS390BitWiseConditionCode(r1_val); break; case XR: r1_val ^= r2_val; SetS390BitWiseConditionCode(r1_val); break; case MR: { DCHECK(r1 % 2 == 0); r1_val = get_low_register(r1 + 1); int64_t product = static_cast(r1_val) * static_cast(r2_val); int32_t high_bits = product >> 32; r1_val = high_bits; int32_t low_bits = product & 0x00000000FFFFFFFF; set_low_register(r1, high_bits); set_low_register(r1 + 1, low_bits); break; } case DR: { // reg-reg pair should be even-odd pair, assert r1 is an even register DCHECK(r1 % 2 == 0); // leftmost 32 bits of the dividend are in r1 // rightmost 32 bits of the dividend are in r1+1 // get the signed value from r1 int64_t dividend = static_cast(r1_val) << 32; // get unsigned value from r1+1 // avoid addition with sign-extended r1+1 value dividend += get_low_register(r1 + 1); int32_t remainder = dividend % r2_val; int32_t quotient = dividend / r2_val; r1_val = remainder; set_low_register(r1, remainder); set_low_register(r1 + 1, quotient); break; // reg pair } default: UNREACHABLE(); break; } set_low_register(r1, r1_val); break; } case LR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); set_low_register(r1, get_low_register(r2)); break; } case LDR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int64_t r2_val = get_d_register(r2); set_d_register(r1, r2_val); break; } case CR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case CLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case BCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); if (TestConditionCode(Condition(r1))) { intptr_t r2_val = get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, but is ignored by the // hardware. Cleanse the top bit before jumping to it, unless it's one // of the special PCs if (r2_val != bad_lr && r2_val != end_sim_pc) r2_val &= 0x7FFFFFFF; #endif set_pc(r2_val); } break; } case LTR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r2_val, 0); set_low_register(r1, r2_val); break; } case ALR: case SLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); uint32_t alu_out = 0; bool isOF = false; if (ALR == op) { alu_out = r1_val + r2_val; isOF = CheckOverflowForUIntAdd(r1_val, r2_val); } else if (SLR == op) { alu_out = r1_val - r2_val; isOF = CheckOverflowForUIntSub(r1_val, r2_val); } else { UNREACHABLE(); } set_low_register(r1, alu_out); SetS390ConditionCodeCarry(alu_out, isOF); break; } case LNR: { // Load Negative (32) RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); r2_val = (r2_val >= 0) ? -r2_val : r2_val; // If pos, then negate it. set_low_register(r1, r2_val); condition_reg_ = (r2_val == 0) ? CC_EQ : CC_LT; // CC0 - result is zero // CC1 - result is negative break; } case BASR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); intptr_t link_addr = get_pc() + 2; // If R2 is zero, the BASR does not branch. int64_t r2_val = (r2 == 0) ? link_addr : get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, which can cause issues // for stackwalker. The top bit should either be cleanse before being // pushed onto the stack, or during stack walking when dereferenced. // For simulator, we'll take the worst case scenario and always tag // the high bit, to flush out more problems. link_addr |= 0x80000000; #endif set_register(r1, link_addr); set_pc(r2_val); break; } case LCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); int32_t original_r2_val = r2_val; r2_val = ~r2_val; r2_val = r2_val + 1; set_low_register(r1, r2_val); SetS390ConditionCode(r2_val, 0); // Checks for overflow where r2_val = -2147483648. // Cannot do int comparison due to GCC 4.8 bug on x86. // Detect INT_MIN alternatively, as it is the only value where both // original and result are negative due to overflow. if (r2_val < 0 && original_r2_val < 0) { SetS390OverflowCode(true); } break; } case BKPT: { set_pc(get_pc() + 2); S390Debugger dbg(this); dbg.Debug(); break; } default: UNREACHABLE(); return false; break; } return true; } // Decode routine for four-byte instructions bool Simulator::DecodeFourByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); // Pre-cast instruction to various types RREInstruction* rreInst = reinterpret_cast(instr); SIInstruction* siInstr = reinterpret_cast(instr); switch (op) { case POPCNT_Z: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); int64_t r1_val = 0; uint8_t* r2_val_ptr = reinterpret_cast(&r2_val); uint8_t* r1_val_ptr = reinterpret_cast(&r1_val); for (int i = 0; i < 8; i++) { uint32_t x = static_cast(r2_val_ptr[i]); #if defined(__GNUC__) r1_val_ptr[i] = __builtin_popcount(x); #else #error unsupport __builtin_popcount #endif } set_register(r1, static_cast(r1_val)); break; } case LLGFR: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int32_t r2_val = get_low_register(r2); uint64_t r2_finalval = (static_cast(r2_val) & 0x00000000ffffffff); set_register(r1, r2_finalval); break; } case EX: { RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int b2 = rxinst->B2Value(); int x2 = rxinst->X2Value(); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); intptr_t d2_val = rxinst->D2Value(); int32_t r1_val = get_low_register(r1); SixByteInstr the_instr = Instruction::InstructionBits( reinterpret_cast(b2_val + x2_val + d2_val)); int length = Instruction::InstructionLength( reinterpret_cast(b2_val + x2_val + d2_val)); char new_instr_buf[8]; char* addr = reinterpret_cast(&new_instr_buf[0]); the_instr |= static_cast(r1_val & 0xff) << (8 * length - 16); Instruction::SetInstructionBits( reinterpret_cast(addr), static_cast(the_instr)); ExecuteInstruction(reinterpret_cast(addr), false); break; } case LGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); set_register(r1, get_register(r2)); break; } case LDGR: { // Load FPR from GPR (L <- 64) uint64_t int_val = get_register(rreInst->R2Value()); // double double_val = bit_cast(int_val); // set_d_register_from_double(rreInst->R1Value(), double_val); set_d_register(rreInst->R1Value(), int_val); break; } case LGDR: { // Load GPR from FPR (64 <- L) int64_t double_val = get_d_register(rreInst->R2Value()); set_register(rreInst->R1Value(), double_val); break; } case LTGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); SetS390ConditionCode(r2_val, 0); set_register(r1, get_register(r2)); break; } case LZDR: { int r1 = rreInst->R1Value(); set_d_register_from_double(r1, 0.0); break; } case LTEBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); float fr2_val = get_float32_from_d_register(r2); SetS390ConditionCode(fr2_val, 0.0); set_d_register(r1, r2_val); break; } case LTDBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); SetS390ConditionCode(bit_cast(r2_val), 0.0); set_d_register(r1, r2_val); break; } case CGR: { // Compare (64) int64_t r1_val = get_register(rreInst->R1Value()); int64_t r2_val = get_register(rreInst->R2Value()); SetS390ConditionCode(r1_val, r2_val); break; } case CLGR: { // Compare Logical (64) uint64_t r1_val = static_cast(get_register(rreInst->R1Value())); uint64_t r2_val = static_cast(get_register(rreInst->R2Value())); SetS390ConditionCode(r1_val, r2_val); break; } case LH: { // Load Halfword RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int x2 = rxinst->X2Value(); int b2 = rxinst->B2Value(); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); intptr_t d2_val = rxinst->D2Value(); intptr_t mem_addr = x2_val + b2_val + d2_val; int32_t result = static_cast(ReadH(mem_addr, instr)); set_low_register(r1, result); break; } case LHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int i = riinst->I2Value(); set_low_register(r1, i); break; } case LGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = riinst->I2Value(); set_register(r1, i); break; } case CHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int16_t i = riinst->I2Value(); int32_t r1_val = get_low_register(r1); SetS390ConditionCode(r1_val, i); break; } case CGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = static_cast(riinst->I2Value()); int64_t r1_val = get_register(r1); SetS390ConditionCode(r1_val, i); break; } case BRAS: { // Branch Relative and Save RILInstruction* rilInstr = reinterpret_cast(instr); int r1 = rilInstr->R1Value(); intptr_t d2 = rilInstr->I2Value(); intptr_t pc = get_pc(); // Set PC of next instruction to register set_register(r1, pc + sizeof(FourByteInstr)); // Update PC to branch target set_pc(pc + d2 * 2); break; } case BRC: { // Branch Relative on Condition RIInstruction* riinst = reinterpret_cast(instr); int m1 = riinst->M1Value(); if (TestConditionCode((Condition)m1)) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BRCT: case BRCTG: { // Branch On Count (32/64). RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t value = (op == BRCT) ? get_low_register(r1) : get_register(r1); if (BRCT == op) set_low_register(r1, --value); else set_register(r1, --value); // Branch if value != 0 if (value != 0) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BXH: { RSInstruction* rsinst = reinterpret_cast(instr); int r1 = rsinst->R1Value(); int r3 = rsinst->R3Value(); int b2 = rsinst->B2Value(); int d2 = rsinst->D2Value(); // r1_val is the first operand, r3_val is the increment int32_t r1_val = r1 == 0 ? 0 : get_register(r1); int32_t r3_val = r2 == 0 ? 0 : get_register(r3); intptr_t b2_val = b2 == 0 ? 0 : get_register(b2); intptr_t branch_address = b2_val + d2; // increment r1_val r1_val += r3_val; // if the increment is even, then it designates a pair of registers // and the contents of the even and odd registers of the pair are used as // the increment and compare value respectively. If the increment is odd, // the increment itself is used as both the increment and compare value int32_t compare_val = r3 % 2 == 0 ? get_register(r3 + 1) : r3_val; if (r1_val > compare_val) { // branch to address if r1_val is greater than compare value set_pc(branch_address); } // update contents of register in r1 with the new incremented value set_register(r1, r1_val); break; } case IIHH: case IIHL: case IILH: case IILL: { UNIMPLEMENTED(); break; } case STM: case LM: { // Store Multiple 32-bits. RSInstruction* rsinstr = reinterpret_cast(instr); int r1 = rsinstr->R1Value(); int r3 = rsinstr->R3Value(); int rb = rsinstr->B2Value(); int offset = rsinstr->D2Value(); // Regs roll around if r3 is less than r1. // Artifically increase r3 by 16 so we can calculate // the number of regs stored properly. if (r3 < r1) r3 += 16; int32_t rb_val = (rb == 0) ? 0 : get_low_register(rb); // Store each register in ascending order. for (int i = 0; i <= r3 - r1; i++) { if (op == STM) { int32_t value = get_low_register((r1 + i) % 16); WriteW(rb_val + offset + 4 * i, value, instr); } else if (op == LM) { int32_t value = ReadW(rb_val + offset + 4 * i, instr); set_low_register((r1 + i) % 16, value); } } break; } case SLL: case SRL: { RSInstruction* rsInstr = reinterpret_cast(instr); int r1 = rsInstr->R1Value(); int b2 = rsInstr->B2Value(); intptr_t d2 = rsInstr->D2Value(); // only takes rightmost 6bits int64_t b2_val = b2 == 0 ? 0 : get_register(b2); int shiftBits = (b2_val + d2) & 0x3F; uint32_t r1_val = get_low_register
\n"); PrintF(" or all stop(s).\n"); PrintF(" stop enable/disable all/ : enables / disables\n"); PrintF(" all or number stop(s)\n"); PrintF(" stop unstop\n"); PrintF(" ignore the stop instruction at the current location\n"); PrintF(" from now on\n"); } else { PrintF("Unknown command: %s\n", cmd); } } } // Add all the breakpoints back to stop execution and enter the debugger // shell when hit. RedoBreakpoints(); // Restore tracing ::v8::internal::FLAG_trace_sim = trace; #undef COMMAND_SIZE #undef ARG_SIZE #undef STR #undef XSTR } static bool ICacheMatch(void* one, void* two) { DCHECK((reinterpret_cast(one) & CachePage::kPageMask) == 0); DCHECK((reinterpret_cast(two) & CachePage::kPageMask) == 0); return one == two; } static uint32_t ICacheHash(void* key) { return static_cast(reinterpret_cast(key)) >> 2; } static bool AllOnOnePage(uintptr_t start, int size) { intptr_t start_page = (start & ~CachePage::kPageMask); intptr_t end_page = ((start + size) & ~CachePage::kPageMask); return start_page == end_page; } void Simulator::set_last_debugger_input(char* input) { DeleteArray(last_debugger_input_); last_debugger_input_ = input; } void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, void* start_addr, size_t size) { intptr_t start = reinterpret_cast(start_addr); int intra_line = (start & CachePage::kLineMask); start -= intra_line; size += intra_line; size = ((size - 1) | CachePage::kLineMask) + 1; int offset = (start & CachePage::kPageMask); while (!AllOnOnePage(start, size - 1)) { int bytes_to_flush = CachePage::kPageSize - offset; FlushOnePage(i_cache, start, bytes_to_flush); start += bytes_to_flush; size -= bytes_to_flush; DCHECK_EQ(0, static_cast(start & CachePage::kPageMask)); offset = 0; } if (size != 0) { FlushOnePage(i_cache, start, size); } } CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, void* page) { base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); if (entry->value == NULL) { CachePage* new_page = new CachePage(); entry->value = new_page; } return reinterpret_cast(entry->value); } // Flush from start up to and not including start + size. void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, int size) { DCHECK(size <= CachePage::kPageSize); DCHECK(AllOnOnePage(start, size - 1)); DCHECK((start & CachePage::kLineMask) == 0); DCHECK((size & CachePage::kLineMask) == 0); void* page = reinterpret_cast(start & (~CachePage::kPageMask)); int offset = (start & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* valid_bytemap = cache_page->ValidityByte(offset); memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); } void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, Instruction* instr) { intptr_t address = reinterpret_cast(instr); void* page = reinterpret_cast(address & (~CachePage::kPageMask)); void* line = reinterpret_cast(address & (~CachePage::kLineMask)); int offset = (address & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* cache_valid_byte = cache_page->ValidityByte(offset); bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); if (cache_hit) { // Check that the data in memory matches the contents of the I-cache. CHECK_EQ(memcmp(reinterpret_cast(instr), cache_page->CachedData(offset), sizeof(FourByteInstr)), 0); } else { // Cache miss. Load memory into the cache. memcpy(cached_line, line, CachePage::kLineLength); *cache_valid_byte = CachePage::LINE_VALID; } } void Simulator::Initialize(Isolate* isolate) { if (isolate->simulator_initialized()) return; isolate->set_simulator_initialized(true); ::v8::internal::ExternalReference::set_redirector(isolate, &RedirectExternalReference); static base::OnceType once = V8_ONCE_INIT; base::CallOnce(&once, &Simulator::EvalTableInit); } Simulator::EvaluateFuncType Simulator::EvalTable[] = {NULL}; void Simulator::EvalTableInit() { for (int i = 0; i < MAX_NUM_OPCODES; i++) { EvalTable[i] = &Simulator::Evaluate_Unknown; } EvalTable[BKPT] = &Simulator::Evaluate_BKPT; EvalTable[SPM] = &Simulator::Evaluate_SPM; EvalTable[BALR] = &Simulator::Evaluate_BALR; EvalTable[BCTR] = &Simulator::Evaluate_BCTR; EvalTable[BCR] = &Simulator::Evaluate_BCR; EvalTable[SVC] = &Simulator::Evaluate_SVC; EvalTable[BSM] = &Simulator::Evaluate_BSM; EvalTable[BASSM] = &Simulator::Evaluate_BASSM; EvalTable[BASR] = &Simulator::Evaluate_BASR; EvalTable[MVCL] = &Simulator::Evaluate_MVCL; EvalTable[CLCL] = &Simulator::Evaluate_CLCL; EvalTable[LPR] = &Simulator::Evaluate_LPR; EvalTable[LNR] = &Simulator::Evaluate_LNR; EvalTable[LTR] = &Simulator::Evaluate_LTR; EvalTable[LCR] = &Simulator::Evaluate_LCR; EvalTable[NR] = &Simulator::Evaluate_NR; EvalTable[CLR] = &Simulator::Evaluate_CLR; EvalTable[OR] = &Simulator::Evaluate_OR; EvalTable[XR] = &Simulator::Evaluate_XR; EvalTable[LR] = &Simulator::Evaluate_LR; EvalTable[CR] = &Simulator::Evaluate_CR; EvalTable[AR] = &Simulator::Evaluate_AR; EvalTable[SR] = &Simulator::Evaluate_SR; EvalTable[MR] = &Simulator::Evaluate_MR; EvalTable[DR] = &Simulator::Evaluate_DR; EvalTable[ALR] = &Simulator::Evaluate_ALR; EvalTable[SLR] = &Simulator::Evaluate_SLR; EvalTable[LDR] = &Simulator::Evaluate_LDR; EvalTable[CDR] = &Simulator::Evaluate_CDR; EvalTable[LER] = &Simulator::Evaluate_LER; EvalTable[STH] = &Simulator::Evaluate_STH; EvalTable[LA] = &Simulator::Evaluate_LA; EvalTable[STC] = &Simulator::Evaluate_STC; EvalTable[IC_z] = &Simulator::Evaluate_IC_z; EvalTable[EX] = &Simulator::Evaluate_EX; EvalTable[BAL] = &Simulator::Evaluate_BAL; EvalTable[BCT] = &Simulator::Evaluate_BCT; EvalTable[BC] = &Simulator::Evaluate_BC; EvalTable[LH] = &Simulator::Evaluate_LH; EvalTable[CH] = &Simulator::Evaluate_CH; EvalTable[AH] = &Simulator::Evaluate_AH; EvalTable[SH] = &Simulator::Evaluate_SH; EvalTable[MH] = &Simulator::Evaluate_MH; EvalTable[BAS] = &Simulator::Evaluate_BAS; EvalTable[CVD] = &Simulator::Evaluate_CVD; EvalTable[CVB] = &Simulator::Evaluate_CVB; EvalTable[ST] = &Simulator::Evaluate_ST; EvalTable[LAE] = &Simulator::Evaluate_LAE; EvalTable[N] = &Simulator::Evaluate_N; EvalTable[CL] = &Simulator::Evaluate_CL; EvalTable[O] = &Simulator::Evaluate_O; EvalTable[X] = &Simulator::Evaluate_X; EvalTable[L] = &Simulator::Evaluate_L; EvalTable[C] = &Simulator::Evaluate_C; EvalTable[A] = &Simulator::Evaluate_A; EvalTable[S] = &Simulator::Evaluate_S; EvalTable[M] = &Simulator::Evaluate_M; EvalTable[D] = &Simulator::Evaluate_D; EvalTable[AL] = &Simulator::Evaluate_AL; EvalTable[SL] = &Simulator::Evaluate_SL; EvalTable[STD] = &Simulator::Evaluate_STD; EvalTable[LD] = &Simulator::Evaluate_LD; EvalTable[CD] = &Simulator::Evaluate_CD; EvalTable[STE] = &Simulator::Evaluate_STE; EvalTable[MS] = &Simulator::Evaluate_MS; EvalTable[LE] = &Simulator::Evaluate_LE; EvalTable[BRXH] = &Simulator::Evaluate_BRXH; EvalTable[BRXLE] = &Simulator::Evaluate_BRXLE; EvalTable[BXH] = &Simulator::Evaluate_BXH; EvalTable[BXLE] = &Simulator::Evaluate_BXLE; EvalTable[SRL] = &Simulator::Evaluate_SRL; EvalTable[SLL] = &Simulator::Evaluate_SLL; EvalTable[SRA] = &Simulator::Evaluate_SRA; EvalTable[SLA] = &Simulator::Evaluate_SLA; EvalTable[SRDL] = &Simulator::Evaluate_SRDL; EvalTable[SLDL] = &Simulator::Evaluate_SLDL; EvalTable[SRDA] = &Simulator::Evaluate_SRDA; EvalTable[SLDA] = &Simulator::Evaluate_SLDA; EvalTable[STM] = &Simulator::Evaluate_STM; EvalTable[TM] = &Simulator::Evaluate_TM; EvalTable[MVI] = &Simulator::Evaluate_MVI; EvalTable[TS] = &Simulator::Evaluate_TS; EvalTable[NI] = &Simulator::Evaluate_NI; EvalTable[CLI] = &Simulator::Evaluate_CLI; EvalTable[OI] = &Simulator::Evaluate_OI; EvalTable[XI] = &Simulator::Evaluate_XI; EvalTable[LM] = &Simulator::Evaluate_LM; EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE; EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE; EvalTable[MC] = &Simulator::Evaluate_MC; EvalTable[CDS] = &Simulator::Evaluate_CDS; EvalTable[STCM] = &Simulator::Evaluate_STCM; EvalTable[ICM] = &Simulator::Evaluate_ICM; EvalTable[BPRP] = &Simulator::Evaluate_BPRP; EvalTable[BPP] = &Simulator::Evaluate_BPP; EvalTable[TRTR] = &Simulator::Evaluate_TRTR; EvalTable[MVN] = &Simulator::Evaluate_MVN; EvalTable[MVC] = &Simulator::Evaluate_MVC; EvalTable[MVZ] = &Simulator::Evaluate_MVZ; EvalTable[NC] = &Simulator::Evaluate_NC; EvalTable[CLC] = &Simulator::Evaluate_CLC; EvalTable[OC] = &Simulator::Evaluate_OC; EvalTable[XC] = &Simulator::Evaluate_XC; EvalTable[MVCP] = &Simulator::Evaluate_MVCP; EvalTable[TR] = &Simulator::Evaluate_TR; EvalTable[TRT] = &Simulator::Evaluate_TRT; EvalTable[ED] = &Simulator::Evaluate_ED; EvalTable[EDMK] = &Simulator::Evaluate_EDMK; EvalTable[PKU] = &Simulator::Evaluate_PKU; EvalTable[UNPKU] = &Simulator::Evaluate_UNPKU; EvalTable[MVCIN] = &Simulator::Evaluate_MVCIN; EvalTable[PKA] = &Simulator::Evaluate_PKA; EvalTable[UNPKA] = &Simulator::Evaluate_UNPKA; EvalTable[PLO] = &Simulator::Evaluate_PLO; EvalTable[LMD] = &Simulator::Evaluate_LMD; EvalTable[SRP] = &Simulator::Evaluate_SRP; EvalTable[MVO] = &Simulator::Evaluate_MVO; EvalTable[PACK] = &Simulator::Evaluate_PACK; EvalTable[UNPK] = &Simulator::Evaluate_UNPK; EvalTable[ZAP] = &Simulator::Evaluate_ZAP; EvalTable[AP] = &Simulator::Evaluate_AP; EvalTable[SP] = &Simulator::Evaluate_SP; EvalTable[MP] = &Simulator::Evaluate_MP; EvalTable[DP] = &Simulator::Evaluate_DP; EvalTable[UPT] = &Simulator::Evaluate_UPT; EvalTable[PFPO] = &Simulator::Evaluate_PFPO; EvalTable[IIHH] = &Simulator::Evaluate_IIHH; EvalTable[IIHL] = &Simulator::Evaluate_IIHL; EvalTable[IILH] = &Simulator::Evaluate_IILH; EvalTable[IILL] = &Simulator::Evaluate_IILL; EvalTable[NIHH] = &Simulator::Evaluate_NIHH; EvalTable[NIHL] = &Simulator::Evaluate_NIHL; EvalTable[NILH] = &Simulator::Evaluate_NILH; EvalTable[NILL] = &Simulator::Evaluate_NILL; EvalTable[OIHH] = &Simulator::Evaluate_OIHH; EvalTable[OIHL] = &Simulator::Evaluate_OIHL; EvalTable[OILH] = &Simulator::Evaluate_OILH; EvalTable[OILL] = &Simulator::Evaluate_OILL; EvalTable[LLIHH] = &Simulator::Evaluate_LLIHH; EvalTable[LLIHL] = &Simulator::Evaluate_LLIHL; EvalTable[LLILH] = &Simulator::Evaluate_LLILH; EvalTable[LLILL] = &Simulator::Evaluate_LLILL; EvalTable[TMLH] = &Simulator::Evaluate_TMLH; EvalTable[TMLL] = &Simulator::Evaluate_TMLL; EvalTable[TMHH] = &Simulator::Evaluate_TMHH; EvalTable[TMHL] = &Simulator::Evaluate_TMHL; EvalTable[BRC] = &Simulator::Evaluate_BRC; EvalTable[BRAS] = &Simulator::Evaluate_BRAS; EvalTable[BRCT] = &Simulator::Evaluate_BRCT; EvalTable[BRCTG] = &Simulator::Evaluate_BRCTG; EvalTable[LHI] = &Simulator::Evaluate_LHI; EvalTable[LGHI] = &Simulator::Evaluate_LGHI; EvalTable[AHI] = &Simulator::Evaluate_AHI; EvalTable[AGHI] = &Simulator::Evaluate_AGHI; EvalTable[MHI] = &Simulator::Evaluate_MHI; EvalTable[MGHI] = &Simulator::Evaluate_MGHI; EvalTable[CHI] = &Simulator::Evaluate_CHI; EvalTable[CGHI] = &Simulator::Evaluate_CGHI; EvalTable[LARL] = &Simulator::Evaluate_LARL; EvalTable[LGFI] = &Simulator::Evaluate_LGFI; EvalTable[BRCL] = &Simulator::Evaluate_BRCL; EvalTable[BRASL] = &Simulator::Evaluate_BRASL; EvalTable[XIHF] = &Simulator::Evaluate_XIHF; EvalTable[XILF] = &Simulator::Evaluate_XILF; EvalTable[IIHF] = &Simulator::Evaluate_IIHF; EvalTable[IILF] = &Simulator::Evaluate_IILF; EvalTable[NIHF] = &Simulator::Evaluate_NIHF; EvalTable[NILF] = &Simulator::Evaluate_NILF; EvalTable[OIHF] = &Simulator::Evaluate_OIHF; EvalTable[OILF] = &Simulator::Evaluate_OILF; EvalTable[LLIHF] = &Simulator::Evaluate_LLIHF; EvalTable[LLILF] = &Simulator::Evaluate_LLILF; EvalTable[MSGFI] = &Simulator::Evaluate_MSGFI; EvalTable[MSFI] = &Simulator::Evaluate_MSFI; EvalTable[SLGFI] = &Simulator::Evaluate_SLGFI; EvalTable[SLFI] = &Simulator::Evaluate_SLFI; EvalTable[AGFI] = &Simulator::Evaluate_AGFI; EvalTable[AFI] = &Simulator::Evaluate_AFI; EvalTable[ALGFI] = &Simulator::Evaluate_ALGFI; EvalTable[ALFI] = &Simulator::Evaluate_ALFI; EvalTable[CGFI] = &Simulator::Evaluate_CGFI; EvalTable[CFI] = &Simulator::Evaluate_CFI; EvalTable[CLGFI] = &Simulator::Evaluate_CLGFI; EvalTable[CLFI] = &Simulator::Evaluate_CLFI; EvalTable[LLHRL] = &Simulator::Evaluate_LLHRL; EvalTable[LGHRL] = &Simulator::Evaluate_LGHRL; EvalTable[LHRL] = &Simulator::Evaluate_LHRL; EvalTable[LLGHRL] = &Simulator::Evaluate_LLGHRL; EvalTable[STHRL] = &Simulator::Evaluate_STHRL; EvalTable[LGRL] = &Simulator::Evaluate_LGRL; EvalTable[STGRL] = &Simulator::Evaluate_STGRL; EvalTable[LGFRL] = &Simulator::Evaluate_LGFRL; EvalTable[LRL] = &Simulator::Evaluate_LRL; EvalTable[LLGFRL] = &Simulator::Evaluate_LLGFRL; EvalTable[STRL] = &Simulator::Evaluate_STRL; EvalTable[EXRL] = &Simulator::Evaluate_EXRL; EvalTable[PFDRL] = &Simulator::Evaluate_PFDRL; EvalTable[CGHRL] = &Simulator::Evaluate_CGHRL; EvalTable[CHRL] = &Simulator::Evaluate_CHRL; EvalTable[CGRL] = &Simulator::Evaluate_CGRL; EvalTable[CGFRL] = &Simulator::Evaluate_CGFRL; EvalTable[ECTG] = &Simulator::Evaluate_ECTG; EvalTable[CSST] = &Simulator::Evaluate_CSST; EvalTable[LPD] = &Simulator::Evaluate_LPD; EvalTable[LPDG] = &Simulator::Evaluate_LPDG; EvalTable[BRCTH] = &Simulator::Evaluate_BRCTH; EvalTable[AIH] = &Simulator::Evaluate_AIH; EvalTable[ALSIH] = &Simulator::Evaluate_ALSIH; EvalTable[ALSIHN] = &Simulator::Evaluate_ALSIHN; EvalTable[CIH] = &Simulator::Evaluate_CIH; EvalTable[STCK] = &Simulator::Evaluate_STCK; EvalTable[CFC] = &Simulator::Evaluate_CFC; EvalTable[IPM] = &Simulator::Evaluate_IPM; EvalTable[HSCH] = &Simulator::Evaluate_HSCH; EvalTable[MSCH] = &Simulator::Evaluate_MSCH; EvalTable[SSCH] = &Simulator::Evaluate_SSCH; EvalTable[STSCH] = &Simulator::Evaluate_STSCH; EvalTable[TSCH] = &Simulator::Evaluate_TSCH; EvalTable[TPI] = &Simulator::Evaluate_TPI; EvalTable[SAL] = &Simulator::Evaluate_SAL; EvalTable[RSCH] = &Simulator::Evaluate_RSCH; EvalTable[STCRW] = &Simulator::Evaluate_STCRW; EvalTable[STCPS] = &Simulator::Evaluate_STCPS; EvalTable[RCHP] = &Simulator::Evaluate_RCHP; EvalTable[SCHM] = &Simulator::Evaluate_SCHM; EvalTable[CKSM] = &Simulator::Evaluate_CKSM; EvalTable[SAR] = &Simulator::Evaluate_SAR; EvalTable[EAR] = &Simulator::Evaluate_EAR; EvalTable[MSR] = &Simulator::Evaluate_MSR; EvalTable[MVST] = &Simulator::Evaluate_MVST; EvalTable[CUSE] = &Simulator::Evaluate_CUSE; EvalTable[SRST] = &Simulator::Evaluate_SRST; EvalTable[XSCH] = &Simulator::Evaluate_XSCH; EvalTable[STCKE] = &Simulator::Evaluate_STCKE; EvalTable[STCKF] = &Simulator::Evaluate_STCKF; EvalTable[SRNM] = &Simulator::Evaluate_SRNM; EvalTable[STFPC] = &Simulator::Evaluate_STFPC; EvalTable[LFPC] = &Simulator::Evaluate_LFPC; EvalTable[TRE] = &Simulator::Evaluate_TRE; EvalTable[CUUTF] = &Simulator::Evaluate_CUUTF; EvalTable[CUTFU] = &Simulator::Evaluate_CUTFU; EvalTable[STFLE] = &Simulator::Evaluate_STFLE; EvalTable[SRNMB] = &Simulator::Evaluate_SRNMB; EvalTable[SRNMT] = &Simulator::Evaluate_SRNMT; EvalTable[LFAS] = &Simulator::Evaluate_LFAS; EvalTable[PPA] = &Simulator::Evaluate_PPA; EvalTable[ETND] = &Simulator::Evaluate_ETND; EvalTable[TEND] = &Simulator::Evaluate_TEND; EvalTable[NIAI] = &Simulator::Evaluate_NIAI; EvalTable[TABORT] = &Simulator::Evaluate_TABORT; EvalTable[TRAP4] = &Simulator::Evaluate_TRAP4; EvalTable[LPEBR] = &Simulator::Evaluate_LPEBR; EvalTable[LNEBR] = &Simulator::Evaluate_LNEBR; EvalTable[LTEBR] = &Simulator::Evaluate_LTEBR; EvalTable[LCEBR] = &Simulator::Evaluate_LCEBR; EvalTable[LDEBR] = &Simulator::Evaluate_LDEBR; EvalTable[LXDBR] = &Simulator::Evaluate_LXDBR; EvalTable[LXEBR] = &Simulator::Evaluate_LXEBR; EvalTable[MXDBR] = &Simulator::Evaluate_MXDBR; EvalTable[KEBR] = &Simulator::Evaluate_KEBR; EvalTable[CEBR] = &Simulator::Evaluate_CEBR; EvalTable[AEBR] = &Simulator::Evaluate_AEBR; EvalTable[SEBR] = &Simulator::Evaluate_SEBR; EvalTable[MDEBR] = &Simulator::Evaluate_MDEBR; EvalTable[DEBR] = &Simulator::Evaluate_DEBR; EvalTable[MAEBR] = &Simulator::Evaluate_MAEBR; EvalTable[MSEBR] = &Simulator::Evaluate_MSEBR; EvalTable[LPDBR] = &Simulator::Evaluate_LPDBR; EvalTable[LNDBR] = &Simulator::Evaluate_LNDBR; EvalTable[LTDBR] = &Simulator::Evaluate_LTDBR; EvalTable[LCDBR] = &Simulator::Evaluate_LCDBR; EvalTable[SQEBR] = &Simulator::Evaluate_SQEBR; EvalTable[SQDBR] = &Simulator::Evaluate_SQDBR; EvalTable[SQXBR] = &Simulator::Evaluate_SQXBR; EvalTable[MEEBR] = &Simulator::Evaluate_MEEBR; EvalTable[KDBR] = &Simulator::Evaluate_KDBR; EvalTable[CDBR] = &Simulator::Evaluate_CDBR; EvalTable[ADBR] = &Simulator::Evaluate_ADBR; EvalTable[SDBR] = &Simulator::Evaluate_SDBR; EvalTable[MDBR] = &Simulator::Evaluate_MDBR; EvalTable[DDBR] = &Simulator::Evaluate_DDBR; EvalTable[MADBR] = &Simulator::Evaluate_MADBR; EvalTable[MSDBR] = &Simulator::Evaluate_MSDBR; EvalTable[LPXBR] = &Simulator::Evaluate_LPXBR; EvalTable[LNXBR] = &Simulator::Evaluate_LNXBR; EvalTable[LTXBR] = &Simulator::Evaluate_LTXBR; EvalTable[LCXBR] = &Simulator::Evaluate_LCXBR; EvalTable[LEDBRA] = &Simulator::Evaluate_LEDBRA; EvalTable[LDXBRA] = &Simulator::Evaluate_LDXBRA; EvalTable[LEXBRA] = &Simulator::Evaluate_LEXBRA; EvalTable[FIXBRA] = &Simulator::Evaluate_FIXBRA; EvalTable[KXBR] = &Simulator::Evaluate_KXBR; EvalTable[CXBR] = &Simulator::Evaluate_CXBR; EvalTable[AXBR] = &Simulator::Evaluate_AXBR; EvalTable[SXBR] = &Simulator::Evaluate_SXBR; EvalTable[MXBR] = &Simulator::Evaluate_MXBR; EvalTable[DXBR] = &Simulator::Evaluate_DXBR; EvalTable[TBEDR] = &Simulator::Evaluate_TBEDR; EvalTable[TBDR] = &Simulator::Evaluate_TBDR; EvalTable[DIEBR] = &Simulator::Evaluate_DIEBR; EvalTable[FIEBRA] = &Simulator::Evaluate_FIEBRA; EvalTable[THDER] = &Simulator::Evaluate_THDER; EvalTable[THDR] = &Simulator::Evaluate_THDR; EvalTable[DIDBR] = &Simulator::Evaluate_DIDBR; EvalTable[FIDBRA] = &Simulator::Evaluate_FIDBRA; EvalTable[LXR] = &Simulator::Evaluate_LXR; EvalTable[LPDFR] = &Simulator::Evaluate_LPDFR; EvalTable[LNDFR] = &Simulator::Evaluate_LNDFR; EvalTable[LCDFR] = &Simulator::Evaluate_LCDFR; EvalTable[LZER] = &Simulator::Evaluate_LZER; EvalTable[LZDR] = &Simulator::Evaluate_LZDR; EvalTable[LZXR] = &Simulator::Evaluate_LZXR; EvalTable[SFPC] = &Simulator::Evaluate_SFPC; EvalTable[SFASR] = &Simulator::Evaluate_SFASR; EvalTable[EFPC] = &Simulator::Evaluate_EFPC; EvalTable[CELFBR] = &Simulator::Evaluate_CELFBR; EvalTable[CDLFBR] = &Simulator::Evaluate_CDLFBR; EvalTable[CXLFBR] = &Simulator::Evaluate_CXLFBR; EvalTable[CEFBRA] = &Simulator::Evaluate_CEFBRA; EvalTable[CDFBRA] = &Simulator::Evaluate_CDFBRA; EvalTable[CXFBRA] = &Simulator::Evaluate_CXFBRA; EvalTable[CFEBRA] = &Simulator::Evaluate_CFEBRA; EvalTable[CFDBRA] = &Simulator::Evaluate_CFDBRA; EvalTable[CFXBRA] = &Simulator::Evaluate_CFXBRA; EvalTable[CLFEBR] = &Simulator::Evaluate_CLFEBR; EvalTable[CLFDBR] = &Simulator::Evaluate_CLFDBR; EvalTable[CLFXBR] = &Simulator::Evaluate_CLFXBR; EvalTable[CELGBR] = &Simulator::Evaluate_CELGBR; EvalTable[CDLGBR] = &Simulator::Evaluate_CDLGBR; EvalTable[CXLGBR] = &Simulator::Evaluate_CXLGBR; EvalTable[CEGBRA] = &Simulator::Evaluate_CEGBRA; EvalTable[CDGBRA] = &Simulator::Evaluate_CDGBRA; EvalTable[CXGBRA] = &Simulator::Evaluate_CXGBRA; EvalTable[CGEBRA] = &Simulator::Evaluate_CGEBRA; EvalTable[CGDBRA] = &Simulator::Evaluate_CGDBRA; EvalTable[CGXBRA] = &Simulator::Evaluate_CGXBRA; EvalTable[CLGEBR] = &Simulator::Evaluate_CLGEBR; EvalTable[CLGDBR] = &Simulator::Evaluate_CLGDBR; EvalTable[CFER] = &Simulator::Evaluate_CFER; EvalTable[CFDR] = &Simulator::Evaluate_CFDR; EvalTable[CFXR] = &Simulator::Evaluate_CFXR; EvalTable[LDGR] = &Simulator::Evaluate_LDGR; EvalTable[CGER] = &Simulator::Evaluate_CGER; EvalTable[CGDR] = &Simulator::Evaluate_CGDR; EvalTable[CGXR] = &Simulator::Evaluate_CGXR; EvalTable[LGDR] = &Simulator::Evaluate_LGDR; EvalTable[MDTR] = &Simulator::Evaluate_MDTR; EvalTable[MDTRA] = &Simulator::Evaluate_MDTRA; EvalTable[DDTRA] = &Simulator::Evaluate_DDTRA; EvalTable[ADTRA] = &Simulator::Evaluate_ADTRA; EvalTable[SDTRA] = &Simulator::Evaluate_SDTRA; EvalTable[LDETR] = &Simulator::Evaluate_LDETR; EvalTable[LEDTR] = &Simulator::Evaluate_LEDTR; EvalTable[LTDTR] = &Simulator::Evaluate_LTDTR; EvalTable[FIDTR] = &Simulator::Evaluate_FIDTR; EvalTable[MXTRA] = &Simulator::Evaluate_MXTRA; EvalTable[DXTRA] = &Simulator::Evaluate_DXTRA; EvalTable[AXTRA] = &Simulator::Evaluate_AXTRA; EvalTable[SXTRA] = &Simulator::Evaluate_SXTRA; EvalTable[LXDTR] = &Simulator::Evaluate_LXDTR; EvalTable[LDXTR] = &Simulator::Evaluate_LDXTR; EvalTable[LTXTR] = &Simulator::Evaluate_LTXTR; EvalTable[FIXTR] = &Simulator::Evaluate_FIXTR; EvalTable[KDTR] = &Simulator::Evaluate_KDTR; EvalTable[CGDTRA] = &Simulator::Evaluate_CGDTRA; EvalTable[CUDTR] = &Simulator::Evaluate_CUDTR; EvalTable[CDTR] = &Simulator::Evaluate_CDTR; EvalTable[EEDTR] = &Simulator::Evaluate_EEDTR; EvalTable[ESDTR] = &Simulator::Evaluate_ESDTR; EvalTable[KXTR] = &Simulator::Evaluate_KXTR; EvalTable[CGXTRA] = &Simulator::Evaluate_CGXTRA; EvalTable[CUXTR] = &Simulator::Evaluate_CUXTR; EvalTable[CSXTR] = &Simulator::Evaluate_CSXTR; EvalTable[CXTR] = &Simulator::Evaluate_CXTR; EvalTable[EEXTR] = &Simulator::Evaluate_EEXTR; EvalTable[ESXTR] = &Simulator::Evaluate_ESXTR; EvalTable[CDGTRA] = &Simulator::Evaluate_CDGTRA; EvalTable[CDUTR] = &Simulator::Evaluate_CDUTR; EvalTable[CDSTR] = &Simulator::Evaluate_CDSTR; EvalTable[CEDTR] = &Simulator::Evaluate_CEDTR; EvalTable[QADTR] = &Simulator::Evaluate_QADTR; EvalTable[IEDTR] = &Simulator::Evaluate_IEDTR; EvalTable[RRDTR] = &Simulator::Evaluate_RRDTR; EvalTable[CXGTRA] = &Simulator::Evaluate_CXGTRA; EvalTable[CXUTR] = &Simulator::Evaluate_CXUTR; EvalTable[CXSTR] = &Simulator::Evaluate_CXSTR; EvalTable[CEXTR] = &Simulator::Evaluate_CEXTR; EvalTable[QAXTR] = &Simulator::Evaluate_QAXTR; EvalTable[IEXTR] = &Simulator::Evaluate_IEXTR; EvalTable[RRXTR] = &Simulator::Evaluate_RRXTR; EvalTable[LPGR] = &Simulator::Evaluate_LPGR; EvalTable[LNGR] = &Simulator::Evaluate_LNGR; EvalTable[LTGR] = &Simulator::Evaluate_LTGR; EvalTable[LCGR] = &Simulator::Evaluate_LCGR; EvalTable[LGR] = &Simulator::Evaluate_LGR; EvalTable[LGBR] = &Simulator::Evaluate_LGBR; EvalTable[LGHR] = &Simulator::Evaluate_LGHR; EvalTable[AGR] = &Simulator::Evaluate_AGR; EvalTable[SGR] = &Simulator::Evaluate_SGR; EvalTable[ALGR] = &Simulator::Evaluate_ALGR; EvalTable[SLGR] = &Simulator::Evaluate_SLGR; EvalTable[MSGR] = &Simulator::Evaluate_MSGR; EvalTable[DSGR] = &Simulator::Evaluate_DSGR; EvalTable[LRVGR] = &Simulator::Evaluate_LRVGR; EvalTable[LPGFR] = &Simulator::Evaluate_LPGFR; EvalTable[LNGFR] = &Simulator::Evaluate_LNGFR; EvalTable[LTGFR] = &Simulator::Evaluate_LTGFR; EvalTable[LCGFR] = &Simulator::Evaluate_LCGFR; EvalTable[LGFR] = &Simulator::Evaluate_LGFR; EvalTable[LLGFR] = &Simulator::Evaluate_LLGFR; EvalTable[LLGTR] = &Simulator::Evaluate_LLGTR; EvalTable[AGFR] = &Simulator::Evaluate_AGFR; EvalTable[SGFR] = &Simulator::Evaluate_SGFR; EvalTable[ALGFR] = &Simulator::Evaluate_ALGFR; EvalTable[SLGFR] = &Simulator::Evaluate_SLGFR; EvalTable[MSGFR] = &Simulator::Evaluate_MSGFR; EvalTable[DSGFR] = &Simulator::Evaluate_DSGFR; EvalTable[KMAC] = &Simulator::Evaluate_KMAC; EvalTable[LRVR] = &Simulator::Evaluate_LRVR; EvalTable[CGR] = &Simulator::Evaluate_CGR; EvalTable[CLGR] = &Simulator::Evaluate_CLGR; EvalTable[LBR] = &Simulator::Evaluate_LBR; EvalTable[LHR] = &Simulator::Evaluate_LHR; EvalTable[KMF] = &Simulator::Evaluate_KMF; EvalTable[KMO] = &Simulator::Evaluate_KMO; EvalTable[PCC] = &Simulator::Evaluate_PCC; EvalTable[KMCTR] = &Simulator::Evaluate_KMCTR; EvalTable[KM] = &Simulator::Evaluate_KM; EvalTable[KMC] = &Simulator::Evaluate_KMC; EvalTable[CGFR] = &Simulator::Evaluate_CGFR; EvalTable[KIMD] = &Simulator::Evaluate_KIMD; EvalTable[KLMD] = &Simulator::Evaluate_KLMD; EvalTable[CFDTR] = &Simulator::Evaluate_CFDTR; EvalTable[CLGDTR] = &Simulator::Evaluate_CLGDTR; EvalTable[CLFDTR] = &Simulator::Evaluate_CLFDTR; EvalTable[BCTGR] = &Simulator::Evaluate_BCTGR; EvalTable[CFXTR] = &Simulator::Evaluate_CFXTR; EvalTable[CLFXTR] = &Simulator::Evaluate_CLFXTR; EvalTable[CDFTR] = &Simulator::Evaluate_CDFTR; EvalTable[CDLGTR] = &Simulator::Evaluate_CDLGTR; EvalTable[CDLFTR] = &Simulator::Evaluate_CDLFTR; EvalTable[CXFTR] = &Simulator::Evaluate_CXFTR; EvalTable[CXLGTR] = &Simulator::Evaluate_CXLGTR; EvalTable[CXLFTR] = &Simulator::Evaluate_CXLFTR; EvalTable[CGRT] = &Simulator::Evaluate_CGRT; EvalTable[NGR] = &Simulator::Evaluate_NGR; EvalTable[OGR] = &Simulator::Evaluate_OGR; EvalTable[XGR] = &Simulator::Evaluate_XGR; EvalTable[FLOGR] = &Simulator::Evaluate_FLOGR; EvalTable[LLGCR] = &Simulator::Evaluate_LLGCR; EvalTable[LLGHR] = &Simulator::Evaluate_LLGHR; EvalTable[MLGR] = &Simulator::Evaluate_MLGR; EvalTable[DLGR] = &Simulator::Evaluate_DLGR; EvalTable[ALCGR] = &Simulator::Evaluate_ALCGR; EvalTable[SLBGR] = &Simulator::Evaluate_SLBGR; EvalTable[EPSW] = &Simulator::Evaluate_EPSW; EvalTable[TRTT] = &Simulator::Evaluate_TRTT; EvalTable[TRTO] = &Simulator::Evaluate_TRTO; EvalTable[TROT] = &Simulator::Evaluate_TROT; EvalTable[TROO] = &Simulator::Evaluate_TROO; EvalTable[LLCR] = &Simulator::Evaluate_LLCR; EvalTable[LLHR] = &Simulator::Evaluate_LLHR; EvalTable[MLR] = &Simulator::Evaluate_MLR; EvalTable[DLR] = &Simulator::Evaluate_DLR; EvalTable[ALCR] = &Simulator::Evaluate_ALCR; EvalTable[SLBR] = &Simulator::Evaluate_SLBR; EvalTable[CU14] = &Simulator::Evaluate_CU14; EvalTable[CU24] = &Simulator::Evaluate_CU24; EvalTable[CU41] = &Simulator::Evaluate_CU41; EvalTable[CU42] = &Simulator::Evaluate_CU42; EvalTable[TRTRE] = &Simulator::Evaluate_TRTRE; EvalTable[SRSTU] = &Simulator::Evaluate_SRSTU; EvalTable[TRTE] = &Simulator::Evaluate_TRTE; EvalTable[AHHHR] = &Simulator::Evaluate_AHHHR; EvalTable[SHHHR] = &Simulator::Evaluate_SHHHR; EvalTable[ALHHHR] = &Simulator::Evaluate_ALHHHR; EvalTable[SLHHHR] = &Simulator::Evaluate_SLHHHR; EvalTable[CHHR] = &Simulator::Evaluate_CHHR; EvalTable[AHHLR] = &Simulator::Evaluate_AHHLR; EvalTable[SHHLR] = &Simulator::Evaluate_SHHLR; EvalTable[ALHHLR] = &Simulator::Evaluate_ALHHLR; EvalTable[SLHHLR] = &Simulator::Evaluate_SLHHLR; EvalTable[CHLR] = &Simulator::Evaluate_CHLR; EvalTable[POPCNT_Z] = &Simulator::Evaluate_POPCNT_Z; EvalTable[LOCGR] = &Simulator::Evaluate_LOCGR; EvalTable[NGRK] = &Simulator::Evaluate_NGRK; EvalTable[OGRK] = &Simulator::Evaluate_OGRK; EvalTable[XGRK] = &Simulator::Evaluate_XGRK; EvalTable[AGRK] = &Simulator::Evaluate_AGRK; EvalTable[SGRK] = &Simulator::Evaluate_SGRK; EvalTable[ALGRK] = &Simulator::Evaluate_ALGRK; EvalTable[SLGRK] = &Simulator::Evaluate_SLGRK; EvalTable[LOCR] = &Simulator::Evaluate_LOCR; EvalTable[NRK] = &Simulator::Evaluate_NRK; EvalTable[ORK] = &Simulator::Evaluate_ORK; EvalTable[XRK] = &Simulator::Evaluate_XRK; EvalTable[ARK] = &Simulator::Evaluate_ARK; EvalTable[SRK] = &Simulator::Evaluate_SRK; EvalTable[ALRK] = &Simulator::Evaluate_ALRK; EvalTable[SLRK] = &Simulator::Evaluate_SLRK; EvalTable[LTG] = &Simulator::Evaluate_LTG; EvalTable[LG] = &Simulator::Evaluate_LG; EvalTable[CVBY] = &Simulator::Evaluate_CVBY; EvalTable[AG] = &Simulator::Evaluate_AG; EvalTable[SG] = &Simulator::Evaluate_SG; EvalTable[ALG] = &Simulator::Evaluate_ALG; EvalTable[SLG] = &Simulator::Evaluate_SLG; EvalTable[MSG] = &Simulator::Evaluate_MSG; EvalTable[DSG] = &Simulator::Evaluate_DSG; EvalTable[CVBG] = &Simulator::Evaluate_CVBG; EvalTable[LRVG] = &Simulator::Evaluate_LRVG; EvalTable[LT] = &Simulator::Evaluate_LT; EvalTable[LGF] = &Simulator::Evaluate_LGF; EvalTable[LGH] = &Simulator::Evaluate_LGH; EvalTable[LLGF] = &Simulator::Evaluate_LLGF; EvalTable[LLGT] = &Simulator::Evaluate_LLGT; EvalTable[AGF] = &Simulator::Evaluate_AGF; EvalTable[SGF] = &Simulator::Evaluate_SGF; EvalTable[ALGF] = &Simulator::Evaluate_ALGF; EvalTable[SLGF] = &Simulator::Evaluate_SLGF; EvalTable[MSGF] = &Simulator::Evaluate_MSGF; EvalTable[DSGF] = &Simulator::Evaluate_DSGF; EvalTable[LRV] = &Simulator::Evaluate_LRV; EvalTable[LRVH] = &Simulator::Evaluate_LRVH; EvalTable[CG] = &Simulator::Evaluate_CG; EvalTable[CLG] = &Simulator::Evaluate_CLG; EvalTable[STG] = &Simulator::Evaluate_STG; EvalTable[NTSTG] = &Simulator::Evaluate_NTSTG; EvalTable[CVDY] = &Simulator::Evaluate_CVDY; EvalTable[CVDG] = &Simulator::Evaluate_CVDG; EvalTable[STRVG] = &Simulator::Evaluate_STRVG; EvalTable[CGF] = &Simulator::Evaluate_CGF; EvalTable[CLGF] = &Simulator::Evaluate_CLGF; EvalTable[LTGF] = &Simulator::Evaluate_LTGF; EvalTable[CGH] = &Simulator::Evaluate_CGH; EvalTable[PFD] = &Simulator::Evaluate_PFD; EvalTable[STRV] = &Simulator::Evaluate_STRV; EvalTable[STRVH] = &Simulator::Evaluate_STRVH; EvalTable[BCTG] = &Simulator::Evaluate_BCTG; EvalTable[STY] = &Simulator::Evaluate_STY; EvalTable[MSY] = &Simulator::Evaluate_MSY; EvalTable[NY] = &Simulator::Evaluate_NY; EvalTable[CLY] = &Simulator::Evaluate_CLY; EvalTable[OY] = &Simulator::Evaluate_OY; EvalTable[XY] = &Simulator::Evaluate_XY; EvalTable[LY] = &Simulator::Evaluate_LY; EvalTable[CY] = &Simulator::Evaluate_CY; EvalTable[AY] = &Simulator::Evaluate_AY; EvalTable[SY] = &Simulator::Evaluate_SY; EvalTable[MFY] = &Simulator::Evaluate_MFY; EvalTable[ALY] = &Simulator::Evaluate_ALY; EvalTable[SLY] = &Simulator::Evaluate_SLY; EvalTable[STHY] = &Simulator::Evaluate_STHY; EvalTable[LAY] = &Simulator::Evaluate_LAY; EvalTable[STCY] = &Simulator::Evaluate_STCY; EvalTable[ICY] = &Simulator::Evaluate_ICY; EvalTable[LAEY] = &Simulator::Evaluate_LAEY; EvalTable[LB] = &Simulator::Evaluate_LB; EvalTable[LGB] = &Simulator::Evaluate_LGB; EvalTable[LHY] = &Simulator::Evaluate_LHY; EvalTable[CHY] = &Simulator::Evaluate_CHY; EvalTable[AHY] = &Simulator::Evaluate_AHY; EvalTable[SHY] = &Simulator::Evaluate_SHY; EvalTable[MHY] = &Simulator::Evaluate_MHY; EvalTable[NG] = &Simulator::Evaluate_NG; EvalTable[OG] = &Simulator::Evaluate_OG; EvalTable[XG] = &Simulator::Evaluate_XG; EvalTable[LGAT] = &Simulator::Evaluate_LGAT; EvalTable[MLG] = &Simulator::Evaluate_MLG; EvalTable[DLG] = &Simulator::Evaluate_DLG; EvalTable[ALCG] = &Simulator::Evaluate_ALCG; EvalTable[SLBG] = &Simulator::Evaluate_SLBG; EvalTable[STPQ] = &Simulator::Evaluate_STPQ; EvalTable[LPQ] = &Simulator::Evaluate_LPQ; EvalTable[LLGC] = &Simulator::Evaluate_LLGC; EvalTable[LLGH] = &Simulator::Evaluate_LLGH; EvalTable[LLC] = &Simulator::Evaluate_LLC; EvalTable[LLH] = &Simulator::Evaluate_LLH; EvalTable[ML] = &Simulator::Evaluate_ML; EvalTable[DL] = &Simulator::Evaluate_DL; EvalTable[ALC] = &Simulator::Evaluate_ALC; EvalTable[SLB] = &Simulator::Evaluate_SLB; EvalTable[LLGTAT] = &Simulator::Evaluate_LLGTAT; EvalTable[LLGFAT] = &Simulator::Evaluate_LLGFAT; EvalTable[LAT] = &Simulator::Evaluate_LAT; EvalTable[LBH] = &Simulator::Evaluate_LBH; EvalTable[LLCH] = &Simulator::Evaluate_LLCH; EvalTable[STCH] = &Simulator::Evaluate_STCH; EvalTable[LHH] = &Simulator::Evaluate_LHH; EvalTable[LLHH] = &Simulator::Evaluate_LLHH; EvalTable[STHH] = &Simulator::Evaluate_STHH; EvalTable[LFHAT] = &Simulator::Evaluate_LFHAT; EvalTable[LFH] = &Simulator::Evaluate_LFH; EvalTable[STFH] = &Simulator::Evaluate_STFH; EvalTable[CHF] = &Simulator::Evaluate_CHF; EvalTable[MVCDK] = &Simulator::Evaluate_MVCDK; EvalTable[MVHHI] = &Simulator::Evaluate_MVHHI; EvalTable[MVGHI] = &Simulator::Evaluate_MVGHI; EvalTable[MVHI] = &Simulator::Evaluate_MVHI; EvalTable[CHHSI] = &Simulator::Evaluate_CHHSI; EvalTable[CGHSI] = &Simulator::Evaluate_CGHSI; EvalTable[CHSI] = &Simulator::Evaluate_CHSI; EvalTable[CLFHSI] = &Simulator::Evaluate_CLFHSI; EvalTable[TBEGIN] = &Simulator::Evaluate_TBEGIN; EvalTable[TBEGINC] = &Simulator::Evaluate_TBEGINC; EvalTable[LMG] = &Simulator::Evaluate_LMG; EvalTable[SRAG] = &Simulator::Evaluate_SRAG; EvalTable[SLAG] = &Simulator::Evaluate_SLAG; EvalTable[SRLG] = &Simulator::Evaluate_SRLG; EvalTable[SLLG] = &Simulator::Evaluate_SLLG; EvalTable[CSY] = &Simulator::Evaluate_CSY; EvalTable[RLLG] = &Simulator::Evaluate_RLLG; EvalTable[RLL] = &Simulator::Evaluate_RLL; EvalTable[STMG] = &Simulator::Evaluate_STMG; EvalTable[STMH] = &Simulator::Evaluate_STMH; EvalTable[STCMH] = &Simulator::Evaluate_STCMH; EvalTable[STCMY] = &Simulator::Evaluate_STCMY; EvalTable[CDSY] = &Simulator::Evaluate_CDSY; EvalTable[CDSG] = &Simulator::Evaluate_CDSG; EvalTable[BXHG] = &Simulator::Evaluate_BXHG; EvalTable[BXLEG] = &Simulator::Evaluate_BXLEG; EvalTable[ECAG] = &Simulator::Evaluate_ECAG; EvalTable[TMY] = &Simulator::Evaluate_TMY; EvalTable[MVIY] = &Simulator::Evaluate_MVIY; EvalTable[NIY] = &Simulator::Evaluate_NIY; EvalTable[CLIY] = &Simulator::Evaluate_CLIY; EvalTable[OIY] = &Simulator::Evaluate_OIY; EvalTable[XIY] = &Simulator::Evaluate_XIY; EvalTable[ASI] = &Simulator::Evaluate_ASI; EvalTable[ALSI] = &Simulator::Evaluate_ALSI; EvalTable[AGSI] = &Simulator::Evaluate_AGSI; EvalTable[ALGSI] = &Simulator::Evaluate_ALGSI; EvalTable[ICMH] = &Simulator::Evaluate_ICMH; EvalTable[ICMY] = &Simulator::Evaluate_ICMY; EvalTable[MVCLU] = &Simulator::Evaluate_MVCLU; EvalTable[CLCLU] = &Simulator::Evaluate_CLCLU; EvalTable[STMY] = &Simulator::Evaluate_STMY; EvalTable[LMH] = &Simulator::Evaluate_LMH; EvalTable[LMY] = &Simulator::Evaluate_LMY; EvalTable[TP] = &Simulator::Evaluate_TP; EvalTable[SRAK] = &Simulator::Evaluate_SRAK; EvalTable[SLAK] = &Simulator::Evaluate_SLAK; EvalTable[SRLK] = &Simulator::Evaluate_SRLK; EvalTable[SLLK] = &Simulator::Evaluate_SLLK; EvalTable[LOCG] = &Simulator::Evaluate_LOCG; EvalTable[STOCG] = &Simulator::Evaluate_STOCG; EvalTable[LANG] = &Simulator::Evaluate_LANG; EvalTable[LAOG] = &Simulator::Evaluate_LAOG; EvalTable[LAXG] = &Simulator::Evaluate_LAXG; EvalTable[LAAG] = &Simulator::Evaluate_LAAG; EvalTable[LAALG] = &Simulator::Evaluate_LAALG; EvalTable[LOC] = &Simulator::Evaluate_LOC; EvalTable[STOC] = &Simulator::Evaluate_STOC; EvalTable[LAN] = &Simulator::Evaluate_LAN; EvalTable[LAO] = &Simulator::Evaluate_LAO; EvalTable[LAX] = &Simulator::Evaluate_LAX; EvalTable[LAA] = &Simulator::Evaluate_LAA; EvalTable[LAAL] = &Simulator::Evaluate_LAAL; EvalTable[BRXHG] = &Simulator::Evaluate_BRXHG; EvalTable[BRXLG] = &Simulator::Evaluate_BRXLG; EvalTable[RISBLG] = &Simulator::Evaluate_RISBLG; EvalTable[RNSBG] = &Simulator::Evaluate_RNSBG; EvalTable[RISBG] = &Simulator::Evaluate_RISBG; EvalTable[ROSBG] = &Simulator::Evaluate_ROSBG; EvalTable[RXSBG] = &Simulator::Evaluate_RXSBG; EvalTable[RISBGN] = &Simulator::Evaluate_RISBGN; EvalTable[RISBHG] = &Simulator::Evaluate_RISBHG; EvalTable[CGRJ] = &Simulator::Evaluate_CGRJ; EvalTable[CGIT] = &Simulator::Evaluate_CGIT; EvalTable[CIT] = &Simulator::Evaluate_CIT; EvalTable[CLFIT] = &Simulator::Evaluate_CLFIT; EvalTable[CGIJ] = &Simulator::Evaluate_CGIJ; EvalTable[CIJ] = &Simulator::Evaluate_CIJ; EvalTable[AHIK] = &Simulator::Evaluate_AHIK; EvalTable[AGHIK] = &Simulator::Evaluate_AGHIK; EvalTable[ALHSIK] = &Simulator::Evaluate_ALHSIK; EvalTable[ALGHSIK] = &Simulator::Evaluate_ALGHSIK; EvalTable[CGRB] = &Simulator::Evaluate_CGRB; EvalTable[CGIB] = &Simulator::Evaluate_CGIB; EvalTable[CIB] = &Simulator::Evaluate_CIB; EvalTable[LDEB] = &Simulator::Evaluate_LDEB; EvalTable[LXDB] = &Simulator::Evaluate_LXDB; EvalTable[LXEB] = &Simulator::Evaluate_LXEB; EvalTable[MXDB] = &Simulator::Evaluate_MXDB; EvalTable[KEB] = &Simulator::Evaluate_KEB; EvalTable[CEB] = &Simulator::Evaluate_CEB; EvalTable[AEB] = &Simulator::Evaluate_AEB; EvalTable[SEB] = &Simulator::Evaluate_SEB; EvalTable[MDEB] = &Simulator::Evaluate_MDEB; EvalTable[DEB] = &Simulator::Evaluate_DEB; EvalTable[MAEB] = &Simulator::Evaluate_MAEB; EvalTable[MSEB] = &Simulator::Evaluate_MSEB; EvalTable[TCEB] = &Simulator::Evaluate_TCEB; EvalTable[TCDB] = &Simulator::Evaluate_TCDB; EvalTable[TCXB] = &Simulator::Evaluate_TCXB; EvalTable[SQEB] = &Simulator::Evaluate_SQEB; EvalTable[SQDB] = &Simulator::Evaluate_SQDB; EvalTable[MEEB] = &Simulator::Evaluate_MEEB; EvalTable[KDB] = &Simulator::Evaluate_KDB; EvalTable[CDB] = &Simulator::Evaluate_CDB; EvalTable[ADB] = &Simulator::Evaluate_ADB; EvalTable[SDB] = &Simulator::Evaluate_SDB; EvalTable[MDB] = &Simulator::Evaluate_MDB; EvalTable[DDB] = &Simulator::Evaluate_DDB; EvalTable[MADB] = &Simulator::Evaluate_MADB; EvalTable[MSDB] = &Simulator::Evaluate_MSDB; EvalTable[SLDT] = &Simulator::Evaluate_SLDT; EvalTable[SRDT] = &Simulator::Evaluate_SRDT; EvalTable[SLXT] = &Simulator::Evaluate_SLXT; EvalTable[SRXT] = &Simulator::Evaluate_SRXT; EvalTable[TDCET] = &Simulator::Evaluate_TDCET; EvalTable[TDGET] = &Simulator::Evaluate_TDGET; EvalTable[TDCDT] = &Simulator::Evaluate_TDCDT; EvalTable[TDGDT] = &Simulator::Evaluate_TDGDT; EvalTable[TDCXT] = &Simulator::Evaluate_TDCXT; EvalTable[TDGXT] = &Simulator::Evaluate_TDGXT; EvalTable[LEY] = &Simulator::Evaluate_LEY; EvalTable[LDY] = &Simulator::Evaluate_LDY; EvalTable[STEY] = &Simulator::Evaluate_STEY; EvalTable[STDY] = &Simulator::Evaluate_STDY; EvalTable[CZDT] = &Simulator::Evaluate_CZDT; EvalTable[CZXT] = &Simulator::Evaluate_CZXT; EvalTable[CDZT] = &Simulator::Evaluate_CDZT; EvalTable[CXZT] = &Simulator::Evaluate_CXZT; } // NOLINT Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { i_cache_ = isolate_->simulator_i_cache(); if (i_cache_ == NULL) { i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch); isolate_->set_simulator_i_cache(i_cache_); } Initialize(isolate); // Set up simulator support first. Some of this information is needed to // setup the architecture state. #if V8_TARGET_ARCH_S390X size_t stack_size = FLAG_sim_stack_size * KB; #else size_t stack_size = MB; // allocate 1MB for stack #endif stack_size += 2 * stack_protection_size_; stack_ = reinterpret_cast(malloc(stack_size)); pc_modified_ = false; icount_ = 0; break_pc_ = NULL; break_instr_ = 0; // make sure our register type can hold exactly 4/8 bytes #ifdef V8_TARGET_ARCH_S390X DCHECK(sizeof(intptr_t) == 8); #else DCHECK(sizeof(intptr_t) == 4); #endif // Set up architecture state. // All registers are initialized to zero to start with. for (int i = 0; i < kNumGPRs; i++) { registers_[i] = 0; } condition_reg_ = 0; special_reg_pc_ = 0; // Initializing FP registers. for (int i = 0; i < kNumFPRs; i++) { fp_registers_[i] = 0.0; } // The sp is initialized to point to the bottom (high address) of the // allocated stack area. To be safe in potential stack underflows we leave // some buffer below. registers_[sp] = reinterpret_cast(stack_) + stack_size - stack_protection_size_; last_debugger_input_ = NULL; } Simulator::~Simulator() { free(stack_); } // When the generated code calls an external reference we need to catch that in // the simulator. The external reference will be a function compiled for the // host architecture. We need to call that function instead of trying to // execute it with the simulator. We do that by redirecting the external // reference to a svc (Supervisor Call) instruction that is handled by // the simulator. We write the original destination of the jump just at a known // offset from the svc instruction so the simulator knows what to call. class Redirection { public: Redirection(Isolate* isolate, void* external_function, ExternalReference::Type type) : external_function_(external_function), // we use TRAP4 here (0xBF22) #if V8_TARGET_LITTLE_ENDIAN swi_instruction_(0x1000FFB2), #else swi_instruction_(0xB2FF0000 | kCallRtRedirected), #endif type_(type), next_(NULL) { next_ = isolate->simulator_redirection(); Simulator::current(isolate)->FlushICache( isolate->simulator_i_cache(), reinterpret_cast(&swi_instruction_), sizeof(FourByteInstr)); isolate->set_simulator_redirection(this); if (ABI_USES_FUNCTION_DESCRIPTORS) { function_descriptor_[0] = reinterpret_cast(&swi_instruction_); function_descriptor_[1] = 0; function_descriptor_[2] = 0; } } void* address() { if (ABI_USES_FUNCTION_DESCRIPTORS) { return reinterpret_cast(function_descriptor_); } else { return reinterpret_cast(&swi_instruction_); } } void* external_function() { return external_function_; } ExternalReference::Type type() { return type_; } static Redirection* Get(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* current = isolate->simulator_redirection(); for (; current != NULL; current = current->next_) { if (current->external_function_ == external_function) { DCHECK_EQ(current->type(), type); return current; } } return new Redirection(isolate, external_function, type); } static Redirection* FromSwiInstruction(Instruction* swi_instruction) { char* addr_of_swi = reinterpret_cast(swi_instruction); char* addr_of_redirection = addr_of_swi - offsetof(Redirection, swi_instruction_); return reinterpret_cast(addr_of_redirection); } static Redirection* FromAddress(void* address) { int delta = ABI_USES_FUNCTION_DESCRIPTORS ? offsetof(Redirection, function_descriptor_) : offsetof(Redirection, swi_instruction_); char* addr_of_redirection = reinterpret_cast(address) - delta; return reinterpret_cast(addr_of_redirection); } static void* ReverseRedirection(intptr_t reg) { Redirection* redirection = FromAddress(reinterpret_cast(reg)); return redirection->external_function(); } static void DeleteChain(Redirection* redirection) { while (redirection != nullptr) { Redirection* next = redirection->next_; delete redirection; redirection = next; } } private: void* external_function_; uint32_t swi_instruction_; ExternalReference::Type type_; Redirection* next_; intptr_t function_descriptor_[3]; }; // static void Simulator::TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first) { Redirection::DeleteChain(first); if (i_cache != nullptr) { for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; entry = i_cache->Next(entry)) { delete static_cast(entry->value); } delete i_cache; } } void* Simulator::RedirectExternalReference(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* redirection = Redirection::Get(isolate, external_function, type); return redirection->address(); } // Get the active Simulator for the current thread. Simulator* Simulator::current(Isolate* isolate) { v8::internal::Isolate::PerIsolateThreadData* isolate_data = isolate->FindOrAllocatePerThreadDataForThisThread(); DCHECK(isolate_data != NULL); Simulator* sim = isolate_data->simulator(); if (sim == NULL) { // TODO(146): delete the simulator object when a thread/isolate goes away. sim = new Simulator(isolate); isolate_data->set_simulator(sim); } return sim; } // Sets the register in the architecture state. void Simulator::set_register(int reg, uint64_t value) { DCHECK((reg >= 0) && (reg < kNumGPRs)); registers_[reg] = value; } // Get the register from the architecture state. uint64_t Simulator::get_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return registers_[reg]; } template T Simulator::get_low_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] & 0xFFFFFFFF); } template T Simulator::get_high_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] >> 32); } void Simulator::set_low_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value); uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val >> 32 << 32) | shifted_val; registers_[reg] = result; } void Simulator::set_high_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value) << 32; uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val & 0xFFFFFFFF) | shifted_val; registers_[reg] = result; } double Simulator::get_double_from_register_pair(int reg) { DCHECK((reg >= 0) && (reg < kNumGPRs) && ((reg % 2) == 0)); double dm_val = 0.0; #if 0 && !V8_TARGET_ARCH_S390X // doesn't make sense in 64bit mode // Read the bits from the unsigned integer register_[] array // into the double precision floating point value and return it. char buffer[sizeof(fp_registers_[0])]; memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0])); memcpy(&dm_val, buffer, 2 * sizeof(registers_[0])); #endif return (dm_val); } // Raw access to the PC register. void Simulator::set_pc(intptr_t value) { pc_modified_ = true; special_reg_pc_ = value; } bool Simulator::has_bad_pc() const { return ((special_reg_pc_ == bad_lr) || (special_reg_pc_ == end_sim_pc)); } // Raw access to the PC register without the special adjustment when reading. intptr_t Simulator::get_pc() const { return special_reg_pc_; } // Runtime FP routines take: // - two double arguments // - one double argument and zero or one integer arguments. // All are consructed here from d1, d2 and r2. void Simulator::GetFpArgs(double* x, double* y, intptr_t* z) { *x = get_double_from_d_register(0); *y = get_double_from_d_register(2); *z = get_register(2); } // The return value is in d0. void Simulator::SetFpResult(const double& result) { set_d_register_from_double(0, result); } void Simulator::TrashCallerSaveRegisters() { // We don't trash the registers with the return value. #if 0 // A good idea to trash volatile registers, needs to be done registers_[2] = 0x50Bad4U; registers_[3] = 0x50Bad4U; registers_[12] = 0x50Bad4U; #endif } uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); return *ptr; } int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteW(intptr_t addr, int32_t value, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint16_t Simulator::ReadHU(intptr_t addr, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); return *ptr; } int16_t Simulator::ReadH(intptr_t addr, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteH(intptr_t addr, uint16_t value, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteH(intptr_t addr, int16_t value, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint8_t Simulator::ReadBU(intptr_t addr) { uint8_t* ptr = reinterpret_cast(addr); return *ptr; } int8_t Simulator::ReadB(intptr_t addr) { int8_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteB(intptr_t addr, uint8_t value) { uint8_t* ptr = reinterpret_cast(addr); *ptr = value; } void Simulator::WriteB(intptr_t addr, int8_t value) { int8_t* ptr = reinterpret_cast(addr); *ptr = value; } int64_t Simulator::ReadDW(intptr_t addr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteDW(intptr_t addr, int64_t value) { int64_t* ptr = reinterpret_cast(addr); *ptr = value; return; } /** * Reads a double value from memory at given address. */ double Simulator::ReadDouble(intptr_t addr) { double* ptr = reinterpret_cast(addr); return *ptr; } // Returns the limit of the stack area to enable checking for stack overflows. uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { // The simulator uses a separate JS stack. If we have exhausted the C stack, // we also drop down the JS limit to reflect the exhaustion on the JS stack. if (GetCurrentStackPosition() < c_limit) { return reinterpret_cast(get_sp()); } // Otherwise the limit is the JS stack. Leave a safety margin to prevent // overrunning the stack when pushing values. return reinterpret_cast(stack_) + stack_protection_size_; } // Unsupported instructions use Format to print an error and stop execution. void Simulator::Format(Instruction* instr, const char* format) { PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", reinterpret_cast(instr), format); UNIMPLEMENTED(); } // Calculate C flag value for additions. bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); uint32_t urest = 0xffffffffU - uleft; return (uright > urest) || (carry && (((uright + 1) > urest) || (uright > (urest - 1)))); } // Calculate C flag value for subtractions. bool Simulator::BorrowFrom(int32_t left, int32_t right) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); return (uright > uleft); } // Calculate V flag value for additions and subtractions. template bool Simulator::OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition) { bool overflow; if (addition) { // operands have the same sign overflow = ((left >= 0 && right >= 0) || (left < 0 && right < 0)) // and operands and result have different sign && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } else { // operands have different signs overflow = ((left < 0 && right >= 0) || (left >= 0 && right < 0)) // and first operand and result have different signs && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } return overflow; } #if V8_TARGET_ARCH_S390X static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { *x = reinterpret_cast(pair->x); *y = reinterpret_cast(pair->y); } #else static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { #if V8_TARGET_BIG_ENDIAN *x = static_cast(*pair >> 32); *y = static_cast(*pair); #else *x = static_cast(*pair); *y = static_cast(*pair >> 32); #endif } #endif // Calls into the V8 runtime. typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); // These prototypes handle the four types of FP calls. typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPCall)(double darg0); typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). typedef void (*SimulatorRuntimeDirectApiCall)(intptr_t arg0); typedef void (*SimulatorRuntimeProfilingApiCall)(intptr_t arg0, void* arg1); // This signature supports direct call to accessor getter callback. typedef void (*SimulatorRuntimeDirectGetterCall)(intptr_t arg0, intptr_t arg1); typedef void (*SimulatorRuntimeProfilingGetterCall)(intptr_t arg0, intptr_t arg1, void* arg2); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. void Simulator::SoftwareInterrupt(Instruction* instr) { int svc = instr->SvcValue(); switch (svc) { case kCallRtRedirected: { // Check if stack is aligned. Error if not aligned is reported below to // include information on the function called. bool stack_aligned = (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; Redirection* redirection = Redirection::FromSwiInstruction(instr); const int kArgCount = 6; int arg0_regnum = 2; intptr_t result_buffer = 0; bool uses_result_buffer = redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && !ABI_RETURNS_OBJECTPAIR_IN_REGS); if (uses_result_buffer) { result_buffer = get_register(r2); arg0_regnum++; } intptr_t arg[kArgCount]; for (int i = 0; i < kArgCount - 1; i++) { arg[i] = get_register(arg0_regnum + i); } intptr_t* stack_pointer = reinterpret_cast(get_register(sp)); arg[5] = stack_pointer[kCalleeRegisterSaveAreaSize / kPointerSize]; bool fp_call = (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); // Place the return address on the stack, making the call GC safe. *reinterpret_cast(get_register(sp) + kStackFrameRASlot * kPointerSize) = get_register(r14); intptr_t external = reinterpret_cast(redirection->external_function()); if (fp_call) { double dval0, dval1; // one or two double parameters intptr_t ival; // zero or one integer parameters int iresult = 0; // integer return value double dresult = 0; // double return value GetFpArgs(&dval0, &dval1, &ival); if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall generic_target = reinterpret_cast(external); switch (redirection->type()) { case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Call to host function at %p with args %f, %f", static_cast(FUNCTION_ADDR(generic_target)), dval0, dval1); break; case ExternalReference::BUILTIN_FP_CALL: PrintF("Call to host function at %p with arg %f", static_cast(FUNCTION_ADDR(generic_target)), dval0); break; case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Call to host function at %p with args %f, %" V8PRIdPTR, static_cast(FUNCTION_ADDR(generic_target)), dval0, ival); break; default: UNREACHABLE(); break; } if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: { SimulatorRuntimeCompareCall target = reinterpret_cast(external); iresult = target(dval0, dval1); set_register(r2, iresult); break; } case ExternalReference::BUILTIN_FP_FP_CALL: { SimulatorRuntimeFPFPCall target = reinterpret_cast(external); dresult = target(dval0, dval1); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_CALL: { SimulatorRuntimeFPCall target = reinterpret_cast(external); dresult = target(dval0); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_INT_CALL: { SimulatorRuntimeFPIntCall target = reinterpret_cast(external); dresult = target(dval0, ival); SetFpResult(dresult); break; } default: UNREACHABLE(); break; } if (::v8::internal::FLAG_trace_sim || !stack_aligned) { switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Returned %08x\n", iresult); break; case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_FP_CALL: case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Returned %f\n", dresult); break; default: UNREACHABLE(); break; } } } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR, reinterpret_cast(external), arg[0]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectApiCall target = reinterpret_cast(external); target(arg[0]); } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingApiCall target = reinterpret_cast(external); target(arg[0], Redirection::ReverseRedirection(arg[1])); } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1]); } else if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1], arg[2]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); } else { // builtin call. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall target = reinterpret_cast(external); PrintF( "Call to host function at %p,\n" "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, static_cast(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { SimulatorRuntimeTripleCall target = reinterpret_cast(external); ObjectTriple result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", reinterpret_cast(result.x), reinterpret_cast(result.y), reinterpret_cast(result.z)); } memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectTriple)); set_register(r2, result_buffer); } else { if (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR) { SimulatorRuntimePairCall target = reinterpret_cast(external); ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); intptr_t x; intptr_t y; decodeObjectPair(&result, &x, &y); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); } if (ABI_RETURNS_OBJECTPAIR_IN_REGS) { set_register(r2, x); set_register(r3, y); } else { memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectPair)); set_register(r2, result_buffer); } } else { DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); SimulatorRuntimeCall target = reinterpret_cast(external); intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned %08" V8PRIxPTR "\n", result); } set_register(r2, result); } } // #if !V8_TARGET_ARCH_S390X // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL); // SimulatorRuntimeCall target = // reinterpret_cast(external); // int64_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // int32_t lo_res = static_cast(result); // int32_t hi_res = static_cast(result >> 32); // #if !V8_TARGET_LITTLE_ENDIAN // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", hi_res); // } // set_register(r2, hi_res); // set_register(r3, lo_res); // #else // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", lo_res); // } // set_register(r2, lo_res); // set_register(r3, hi_res); // #endif // #else // if (redirection->type() == ExternalReference::BUILTIN_CALL) { // SimulatorRuntimeCall target = // reinterpret_cast(external); // intptr_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR "\n", result); // } // set_register(r2, result); // } else { // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL_PAIR); // SimulatorRuntimePairCall target = // reinterpret_cast(external); // ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR ", %08" V8PRIxPTR "\n", // result.x, result.y); // } // #if ABI_RETURNS_OBJECTPAIR_IN_REGS // set_register(r2, result.x); // set_register(r3, result.y); // #else // memcpy(reinterpret_cast(result_buffer), &result, // sizeof(ObjectPair)); // #endif // } // #endif } int64_t saved_lr = *reinterpret_cast( get_register(sp) + kStackFrameRASlot * kPointerSize); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On zLinux-31, the saved_lr might be tagged with a high bit of 1. // Cleanse it before proceeding with simulation. saved_lr &= 0x7FFFFFFF; #endif set_pc(saved_lr); break; } case kBreakpoint: { S390Debugger dbg(this); dbg.Debug(); break; } // stop uses all codes greater than 1 << 23. default: { if (svc >= (1 << 23)) { uint32_t code = svc & kStopCodeMask; if (isWatchedStop(code)) { IncreaseStopCounter(code); } // Stop if it is enabled, otherwise go on jumping over the stop // and the message address. if (isEnabledStop(code)) { S390Debugger dbg(this); dbg.Stop(instr); } else { set_pc(get_pc() + sizeof(FourByteInstr) + kPointerSize); } } else { // This is not a valid svc code. UNREACHABLE(); break; } } } } // Stop helper functions. bool Simulator::isStopInstruction(Instruction* instr) { return (instr->Bits(27, 24) == 0xF) && (instr->SvcValue() >= kStopCode); } bool Simulator::isWatchedStop(uint32_t code) { DCHECK(code <= kMaxStopCode); return code < kNumOfWatchedStops; } bool Simulator::isEnabledStop(uint32_t code) { DCHECK(code <= kMaxStopCode); // Unwatched stops are always enabled. return !isWatchedStop(code) || !(watched_stops_[code].count & kStopDisabledBit); } void Simulator::EnableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (!isEnabledStop(code)) { watched_stops_[code].count &= ~kStopDisabledBit; } } void Simulator::DisableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (isEnabledStop(code)) { watched_stops_[code].count |= kStopDisabledBit; } } void Simulator::IncreaseStopCounter(uint32_t code) { DCHECK(code <= kMaxStopCode); DCHECK(isWatchedStop(code)); if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) { PrintF( "Stop counter for code %i has overflowed.\n" "Enabling this code and reseting the counter to 0.\n", code); watched_stops_[code].count = 0; EnableStop(code); } else { watched_stops_[code].count++; } } // Print a stop status. void Simulator::PrintStopInfo(uint32_t code) { DCHECK(code <= kMaxStopCode); if (!isWatchedStop(code)) { PrintF("Stop not watched."); } else { const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; int32_t count = watched_stops_[code].count & ~kStopDisabledBit; // Don't print the state of unused breakpoints. if (count != 0) { if (watched_stops_[code].desc) { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", code, code, state, count, watched_stops_[code].desc); } else { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", code, code, state, count); } } } } // Method for checking overflow on signed addition: // Test src1 and src2 have opposite sign, // (1) No overflow if they have opposite sign // (2) Test the result and one of the operands have opposite sign // (a) No overflow if they don't have opposite sign // (b) Overflow if opposite #define CheckOverflowForIntAdd(src1, src2, type) \ OverflowFromSigned(src1 + src2, src1, src2, true); #define CheckOverflowForIntSub(src1, src2, type) \ OverflowFromSigned(src1 - src2, src1, src2, false); // Method for checking overflow on unsigned addtion #define CheckOverflowForUIntAdd(src1, src2) \ ((src1) + (src2) < (src1) || (src1) + (src2) < (src2)) // Method for checking overflow on unsigned subtraction #define CheckOverflowForUIntSub(src1, src2) ((src1) - (src2) > (src1)) // Method for checking overflow on multiplication #define CheckOverflowForMul(src1, src2) (((src1) * (src2)) / (src2) != (src1)) // Method for checking overflow on shift right #define CheckOverflowForShiftRight(src1, src2) \ (((src1) >> (src2)) << (src2) != (src1)) // Method for checking overflow on shift left #define CheckOverflowForShiftLeft(src1, src2) \ (((src1) << (src2)) >> (src2) != (src1)) // S390 Decode and simulate helpers bool Simulator::DecodeTwoByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); switch (op) { // RR format instructions case AR: case SR: case MR: case DR: case OR: case NR: case XR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); bool isOF = false; switch (op) { case AR: isOF = CheckOverflowForIntAdd(r1_val, r2_val, int32_t); r1_val += r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case SR: isOF = CheckOverflowForIntSub(r1_val, r2_val, int32_t); r1_val -= r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case OR: r1_val |= r2_val; SetS390BitWiseConditionCode(r1_val); break; case NR: r1_val &= r2_val; SetS390BitWiseConditionCode(r1_val); break; case XR: r1_val ^= r2_val; SetS390BitWiseConditionCode(r1_val); break; case MR: { DCHECK(r1 % 2 == 0); r1_val = get_low_register(r1 + 1); int64_t product = static_cast(r1_val) * static_cast(r2_val); int32_t high_bits = product >> 32; r1_val = high_bits; int32_t low_bits = product & 0x00000000FFFFFFFF; set_low_register(r1, high_bits); set_low_register(r1 + 1, low_bits); break; } case DR: { // reg-reg pair should be even-odd pair, assert r1 is an even register DCHECK(r1 % 2 == 0); // leftmost 32 bits of the dividend are in r1 // rightmost 32 bits of the dividend are in r1+1 // get the signed value from r1 int64_t dividend = static_cast(r1_val) << 32; // get unsigned value from r1+1 // avoid addition with sign-extended r1+1 value dividend += get_low_register(r1 + 1); int32_t remainder = dividend % r2_val; int32_t quotient = dividend / r2_val; r1_val = remainder; set_low_register(r1, remainder); set_low_register(r1 + 1, quotient); break; // reg pair } default: UNREACHABLE(); break; } set_low_register(r1, r1_val); break; } case LR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); set_low_register(r1, get_low_register(r2)); break; } case LDR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int64_t r2_val = get_d_register(r2); set_d_register(r1, r2_val); break; } case CR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case CLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case BCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); if (TestConditionCode(Condition(r1))) { intptr_t r2_val = get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, but is ignored by the // hardware. Cleanse the top bit before jumping to it, unless it's one // of the special PCs if (r2_val != bad_lr && r2_val != end_sim_pc) r2_val &= 0x7FFFFFFF; #endif set_pc(r2_val); } break; } case LTR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r2_val, 0); set_low_register(r1, r2_val); break; } case ALR: case SLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); uint32_t alu_out = 0; bool isOF = false; if (ALR == op) { alu_out = r1_val + r2_val; isOF = CheckOverflowForUIntAdd(r1_val, r2_val); } else if (SLR == op) { alu_out = r1_val - r2_val; isOF = CheckOverflowForUIntSub(r1_val, r2_val); } else { UNREACHABLE(); } set_low_register(r1, alu_out); SetS390ConditionCodeCarry(alu_out, isOF); break; } case LNR: { // Load Negative (32) RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); r2_val = (r2_val >= 0) ? -r2_val : r2_val; // If pos, then negate it. set_low_register(r1, r2_val); condition_reg_ = (r2_val == 0) ? CC_EQ : CC_LT; // CC0 - result is zero // CC1 - result is negative break; } case BASR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); intptr_t link_addr = get_pc() + 2; // If R2 is zero, the BASR does not branch. int64_t r2_val = (r2 == 0) ? link_addr : get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, which can cause issues // for stackwalker. The top bit should either be cleanse before being // pushed onto the stack, or during stack walking when dereferenced. // For simulator, we'll take the worst case scenario and always tag // the high bit, to flush out more problems. link_addr |= 0x80000000; #endif set_register(r1, link_addr); set_pc(r2_val); break; } case LCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); int32_t original_r2_val = r2_val; r2_val = ~r2_val; r2_val = r2_val + 1; set_low_register(r1, r2_val); SetS390ConditionCode(r2_val, 0); // Checks for overflow where r2_val = -2147483648. // Cannot do int comparison due to GCC 4.8 bug on x86. // Detect INT_MIN alternatively, as it is the only value where both // original and result are negative due to overflow. if (r2_val < 0 && original_r2_val < 0) { SetS390OverflowCode(true); } break; } case BKPT: { set_pc(get_pc() + 2); S390Debugger dbg(this); dbg.Debug(); break; } default: UNREACHABLE(); return false; break; } return true; } // Decode routine for four-byte instructions bool Simulator::DecodeFourByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); // Pre-cast instruction to various types RREInstruction* rreInst = reinterpret_cast(instr); SIInstruction* siInstr = reinterpret_cast(instr); switch (op) { case POPCNT_Z: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); int64_t r1_val = 0; uint8_t* r2_val_ptr = reinterpret_cast(&r2_val); uint8_t* r1_val_ptr = reinterpret_cast(&r1_val); for (int i = 0; i < 8; i++) { uint32_t x = static_cast(r2_val_ptr[i]); #if defined(__GNUC__) r1_val_ptr[i] = __builtin_popcount(x); #else #error unsupport __builtin_popcount #endif } set_register(r1, static_cast(r1_val)); break; } case LLGFR: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int32_t r2_val = get_low_register(r2); uint64_t r2_finalval = (static_cast(r2_val) & 0x00000000ffffffff); set_register(r1, r2_finalval); break; } case EX: { RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int b2 = rxinst->B2Value(); int x2 = rxinst->X2Value(); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); intptr_t d2_val = rxinst->D2Value(); int32_t r1_val = get_low_register(r1); SixByteInstr the_instr = Instruction::InstructionBits( reinterpret_cast(b2_val + x2_val + d2_val)); int length = Instruction::InstructionLength( reinterpret_cast(b2_val + x2_val + d2_val)); char new_instr_buf[8]; char* addr = reinterpret_cast(&new_instr_buf[0]); the_instr |= static_cast(r1_val & 0xff) << (8 * length - 16); Instruction::SetInstructionBits( reinterpret_cast(addr), static_cast(the_instr)); ExecuteInstruction(reinterpret_cast(addr), false); break; } case LGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); set_register(r1, get_register(r2)); break; } case LDGR: { // Load FPR from GPR (L <- 64) uint64_t int_val = get_register(rreInst->R2Value()); // double double_val = bit_cast(int_val); // set_d_register_from_double(rreInst->R1Value(), double_val); set_d_register(rreInst->R1Value(), int_val); break; } case LGDR: { // Load GPR from FPR (64 <- L) int64_t double_val = get_d_register(rreInst->R2Value()); set_register(rreInst->R1Value(), double_val); break; } case LTGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); SetS390ConditionCode(r2_val, 0); set_register(r1, get_register(r2)); break; } case LZDR: { int r1 = rreInst->R1Value(); set_d_register_from_double(r1, 0.0); break; } case LTEBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); float fr2_val = get_float32_from_d_register(r2); SetS390ConditionCode(fr2_val, 0.0); set_d_register(r1, r2_val); break; } case LTDBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); SetS390ConditionCode(bit_cast(r2_val), 0.0); set_d_register(r1, r2_val); break; } case CGR: { // Compare (64) int64_t r1_val = get_register(rreInst->R1Value()); int64_t r2_val = get_register(rreInst->R2Value()); SetS390ConditionCode(r1_val, r2_val); break; } case CLGR: { // Compare Logical (64) uint64_t r1_val = static_cast(get_register(rreInst->R1Value())); uint64_t r2_val = static_cast(get_register(rreInst->R2Value())); SetS390ConditionCode(r1_val, r2_val); break; } case LH: { // Load Halfword RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int x2 = rxinst->X2Value(); int b2 = rxinst->B2Value(); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); intptr_t d2_val = rxinst->D2Value(); intptr_t mem_addr = x2_val + b2_val + d2_val; int32_t result = static_cast(ReadH(mem_addr, instr)); set_low_register(r1, result); break; } case LHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int i = riinst->I2Value(); set_low_register(r1, i); break; } case LGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = riinst->I2Value(); set_register(r1, i); break; } case CHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int16_t i = riinst->I2Value(); int32_t r1_val = get_low_register(r1); SetS390ConditionCode(r1_val, i); break; } case CGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = static_cast(riinst->I2Value()); int64_t r1_val = get_register(r1); SetS390ConditionCode(r1_val, i); break; } case BRAS: { // Branch Relative and Save RILInstruction* rilInstr = reinterpret_cast(instr); int r1 = rilInstr->R1Value(); intptr_t d2 = rilInstr->I2Value(); intptr_t pc = get_pc(); // Set PC of next instruction to register set_register(r1, pc + sizeof(FourByteInstr)); // Update PC to branch target set_pc(pc + d2 * 2); break; } case BRC: { // Branch Relative on Condition RIInstruction* riinst = reinterpret_cast(instr); int m1 = riinst->M1Value(); if (TestConditionCode((Condition)m1)) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BRCT: case BRCTG: { // Branch On Count (32/64). RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t value = (op == BRCT) ? get_low_register(r1) : get_register(r1); if (BRCT == op) set_low_register(r1, --value); else set_register(r1, --value); // Branch if value != 0 if (value != 0) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BXH: { RSInstruction* rsinst = reinterpret_cast(instr); int r1 = rsinst->R1Value(); int r3 = rsinst->R3Value(); int b2 = rsinst->B2Value(); int d2 = rsinst->D2Value(); // r1_val is the first operand, r3_val is the increment int32_t r1_val = r1 == 0 ? 0 : get_register(r1); int32_t r3_val = r2 == 0 ? 0 : get_register(r3); intptr_t b2_val = b2 == 0 ? 0 : get_register(b2); intptr_t branch_address = b2_val + d2; // increment r1_val r1_val += r3_val; // if the increment is even, then it designates a pair of registers // and the contents of the even and odd registers of the pair are used as // the increment and compare value respectively. If the increment is odd, // the increment itself is used as both the increment and compare value int32_t compare_val = r3 % 2 == 0 ? get_register(r3 + 1) : r3_val; if (r1_val > compare_val) { // branch to address if r1_val is greater than compare value set_pc(branch_address); } // update contents of register in r1 with the new incremented value set_register(r1, r1_val); break; } case IIHH: case IIHL: case IILH: case IILL: { UNIMPLEMENTED(); break; } case STM: case LM: { // Store Multiple 32-bits. RSInstruction* rsinstr = reinterpret_cast(instr); int r1 = rsinstr->R1Value(); int r3 = rsinstr->R3Value(); int rb = rsinstr->B2Value(); int offset = rsinstr->D2Value(); // Regs roll around if r3 is less than r1. // Artifically increase r3 by 16 so we can calculate // the number of regs stored properly. if (r3 < r1) r3 += 16; int32_t rb_val = (rb == 0) ? 0 : get_low_register(rb); // Store each register in ascending order. for (int i = 0; i <= r3 - r1; i++) { if (op == STM) { int32_t value = get_low_register((r1 + i) % 16); WriteW(rb_val + offset + 4 * i, value, instr); } else if (op == LM) { int32_t value = ReadW(rb_val + offset + 4 * i, instr); set_low_register((r1 + i) % 16, value); } } break; } case SLL: case SRL: { RSInstruction* rsInstr = reinterpret_cast(instr); int r1 = rsInstr->R1Value(); int b2 = rsInstr->B2Value(); intptr_t d2 = rsInstr->D2Value(); // only takes rightmost 6bits int64_t b2_val = b2 == 0 ? 0 : get_register(b2); int shiftBits = (b2_val + d2) & 0x3F; uint32_t r1_val = get_low_register
: enables / disables\n"); PrintF(" all or number stop(s)\n"); PrintF(" stop unstop\n"); PrintF(" ignore the stop instruction at the current location\n"); PrintF(" from now on\n"); } else { PrintF("Unknown command: %s\n", cmd); } } } // Add all the breakpoints back to stop execution and enter the debugger // shell when hit. RedoBreakpoints(); // Restore tracing ::v8::internal::FLAG_trace_sim = trace; #undef COMMAND_SIZE #undef ARG_SIZE #undef STR #undef XSTR } static bool ICacheMatch(void* one, void* two) { DCHECK((reinterpret_cast(one) & CachePage::kPageMask) == 0); DCHECK((reinterpret_cast(two) & CachePage::kPageMask) == 0); return one == two; } static uint32_t ICacheHash(void* key) { return static_cast(reinterpret_cast(key)) >> 2; } static bool AllOnOnePage(uintptr_t start, int size) { intptr_t start_page = (start & ~CachePage::kPageMask); intptr_t end_page = ((start + size) & ~CachePage::kPageMask); return start_page == end_page; } void Simulator::set_last_debugger_input(char* input) { DeleteArray(last_debugger_input_); last_debugger_input_ = input; } void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, void* start_addr, size_t size) { intptr_t start = reinterpret_cast(start_addr); int intra_line = (start & CachePage::kLineMask); start -= intra_line; size += intra_line; size = ((size - 1) | CachePage::kLineMask) + 1; int offset = (start & CachePage::kPageMask); while (!AllOnOnePage(start, size - 1)) { int bytes_to_flush = CachePage::kPageSize - offset; FlushOnePage(i_cache, start, bytes_to_flush); start += bytes_to_flush; size -= bytes_to_flush; DCHECK_EQ(0, static_cast(start & CachePage::kPageMask)); offset = 0; } if (size != 0) { FlushOnePage(i_cache, start, size); } } CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, void* page) { base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); if (entry->value == NULL) { CachePage* new_page = new CachePage(); entry->value = new_page; } return reinterpret_cast(entry->value); } // Flush from start up to and not including start + size. void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, int size) { DCHECK(size <= CachePage::kPageSize); DCHECK(AllOnOnePage(start, size - 1)); DCHECK((start & CachePage::kLineMask) == 0); DCHECK((size & CachePage::kLineMask) == 0); void* page = reinterpret_cast(start & (~CachePage::kPageMask)); int offset = (start & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* valid_bytemap = cache_page->ValidityByte(offset); memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); } void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, Instruction* instr) { intptr_t address = reinterpret_cast(instr); void* page = reinterpret_cast(address & (~CachePage::kPageMask)); void* line = reinterpret_cast(address & (~CachePage::kLineMask)); int offset = (address & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* cache_valid_byte = cache_page->ValidityByte(offset); bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); if (cache_hit) { // Check that the data in memory matches the contents of the I-cache. CHECK_EQ(memcmp(reinterpret_cast(instr), cache_page->CachedData(offset), sizeof(FourByteInstr)), 0); } else { // Cache miss. Load memory into the cache. memcpy(cached_line, line, CachePage::kLineLength); *cache_valid_byte = CachePage::LINE_VALID; } } void Simulator::Initialize(Isolate* isolate) { if (isolate->simulator_initialized()) return; isolate->set_simulator_initialized(true); ::v8::internal::ExternalReference::set_redirector(isolate, &RedirectExternalReference); static base::OnceType once = V8_ONCE_INIT; base::CallOnce(&once, &Simulator::EvalTableInit); } Simulator::EvaluateFuncType Simulator::EvalTable[] = {NULL}; void Simulator::EvalTableInit() { for (int i = 0; i < MAX_NUM_OPCODES; i++) { EvalTable[i] = &Simulator::Evaluate_Unknown; } EvalTable[BKPT] = &Simulator::Evaluate_BKPT; EvalTable[SPM] = &Simulator::Evaluate_SPM; EvalTable[BALR] = &Simulator::Evaluate_BALR; EvalTable[BCTR] = &Simulator::Evaluate_BCTR; EvalTable[BCR] = &Simulator::Evaluate_BCR; EvalTable[SVC] = &Simulator::Evaluate_SVC; EvalTable[BSM] = &Simulator::Evaluate_BSM; EvalTable[BASSM] = &Simulator::Evaluate_BASSM; EvalTable[BASR] = &Simulator::Evaluate_BASR; EvalTable[MVCL] = &Simulator::Evaluate_MVCL; EvalTable[CLCL] = &Simulator::Evaluate_CLCL; EvalTable[LPR] = &Simulator::Evaluate_LPR; EvalTable[LNR] = &Simulator::Evaluate_LNR; EvalTable[LTR] = &Simulator::Evaluate_LTR; EvalTable[LCR] = &Simulator::Evaluate_LCR; EvalTable[NR] = &Simulator::Evaluate_NR; EvalTable[CLR] = &Simulator::Evaluate_CLR; EvalTable[OR] = &Simulator::Evaluate_OR; EvalTable[XR] = &Simulator::Evaluate_XR; EvalTable[LR] = &Simulator::Evaluate_LR; EvalTable[CR] = &Simulator::Evaluate_CR; EvalTable[AR] = &Simulator::Evaluate_AR; EvalTable[SR] = &Simulator::Evaluate_SR; EvalTable[MR] = &Simulator::Evaluate_MR; EvalTable[DR] = &Simulator::Evaluate_DR; EvalTable[ALR] = &Simulator::Evaluate_ALR; EvalTable[SLR] = &Simulator::Evaluate_SLR; EvalTable[LDR] = &Simulator::Evaluate_LDR; EvalTable[CDR] = &Simulator::Evaluate_CDR; EvalTable[LER] = &Simulator::Evaluate_LER; EvalTable[STH] = &Simulator::Evaluate_STH; EvalTable[LA] = &Simulator::Evaluate_LA; EvalTable[STC] = &Simulator::Evaluate_STC; EvalTable[IC_z] = &Simulator::Evaluate_IC_z; EvalTable[EX] = &Simulator::Evaluate_EX; EvalTable[BAL] = &Simulator::Evaluate_BAL; EvalTable[BCT] = &Simulator::Evaluate_BCT; EvalTable[BC] = &Simulator::Evaluate_BC; EvalTable[LH] = &Simulator::Evaluate_LH; EvalTable[CH] = &Simulator::Evaluate_CH; EvalTable[AH] = &Simulator::Evaluate_AH; EvalTable[SH] = &Simulator::Evaluate_SH; EvalTable[MH] = &Simulator::Evaluate_MH; EvalTable[BAS] = &Simulator::Evaluate_BAS; EvalTable[CVD] = &Simulator::Evaluate_CVD; EvalTable[CVB] = &Simulator::Evaluate_CVB; EvalTable[ST] = &Simulator::Evaluate_ST; EvalTable[LAE] = &Simulator::Evaluate_LAE; EvalTable[N] = &Simulator::Evaluate_N; EvalTable[CL] = &Simulator::Evaluate_CL; EvalTable[O] = &Simulator::Evaluate_O; EvalTable[X] = &Simulator::Evaluate_X; EvalTable[L] = &Simulator::Evaluate_L; EvalTable[C] = &Simulator::Evaluate_C; EvalTable[A] = &Simulator::Evaluate_A; EvalTable[S] = &Simulator::Evaluate_S; EvalTable[M] = &Simulator::Evaluate_M; EvalTable[D] = &Simulator::Evaluate_D; EvalTable[AL] = &Simulator::Evaluate_AL; EvalTable[SL] = &Simulator::Evaluate_SL; EvalTable[STD] = &Simulator::Evaluate_STD; EvalTable[LD] = &Simulator::Evaluate_LD; EvalTable[CD] = &Simulator::Evaluate_CD; EvalTable[STE] = &Simulator::Evaluate_STE; EvalTable[MS] = &Simulator::Evaluate_MS; EvalTable[LE] = &Simulator::Evaluate_LE; EvalTable[BRXH] = &Simulator::Evaluate_BRXH; EvalTable[BRXLE] = &Simulator::Evaluate_BRXLE; EvalTable[BXH] = &Simulator::Evaluate_BXH; EvalTable[BXLE] = &Simulator::Evaluate_BXLE; EvalTable[SRL] = &Simulator::Evaluate_SRL; EvalTable[SLL] = &Simulator::Evaluate_SLL; EvalTable[SRA] = &Simulator::Evaluate_SRA; EvalTable[SLA] = &Simulator::Evaluate_SLA; EvalTable[SRDL] = &Simulator::Evaluate_SRDL; EvalTable[SLDL] = &Simulator::Evaluate_SLDL; EvalTable[SRDA] = &Simulator::Evaluate_SRDA; EvalTable[SLDA] = &Simulator::Evaluate_SLDA; EvalTable[STM] = &Simulator::Evaluate_STM; EvalTable[TM] = &Simulator::Evaluate_TM; EvalTable[MVI] = &Simulator::Evaluate_MVI; EvalTable[TS] = &Simulator::Evaluate_TS; EvalTable[NI] = &Simulator::Evaluate_NI; EvalTable[CLI] = &Simulator::Evaluate_CLI; EvalTable[OI] = &Simulator::Evaluate_OI; EvalTable[XI] = &Simulator::Evaluate_XI; EvalTable[LM] = &Simulator::Evaluate_LM; EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE; EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE; EvalTable[MC] = &Simulator::Evaluate_MC; EvalTable[CDS] = &Simulator::Evaluate_CDS; EvalTable[STCM] = &Simulator::Evaluate_STCM; EvalTable[ICM] = &Simulator::Evaluate_ICM; EvalTable[BPRP] = &Simulator::Evaluate_BPRP; EvalTable[BPP] = &Simulator::Evaluate_BPP; EvalTable[TRTR] = &Simulator::Evaluate_TRTR; EvalTable[MVN] = &Simulator::Evaluate_MVN; EvalTable[MVC] = &Simulator::Evaluate_MVC; EvalTable[MVZ] = &Simulator::Evaluate_MVZ; EvalTable[NC] = &Simulator::Evaluate_NC; EvalTable[CLC] = &Simulator::Evaluate_CLC; EvalTable[OC] = &Simulator::Evaluate_OC; EvalTable[XC] = &Simulator::Evaluate_XC; EvalTable[MVCP] = &Simulator::Evaluate_MVCP; EvalTable[TR] = &Simulator::Evaluate_TR; EvalTable[TRT] = &Simulator::Evaluate_TRT; EvalTable[ED] = &Simulator::Evaluate_ED; EvalTable[EDMK] = &Simulator::Evaluate_EDMK; EvalTable[PKU] = &Simulator::Evaluate_PKU; EvalTable[UNPKU] = &Simulator::Evaluate_UNPKU; EvalTable[MVCIN] = &Simulator::Evaluate_MVCIN; EvalTable[PKA] = &Simulator::Evaluate_PKA; EvalTable[UNPKA] = &Simulator::Evaluate_UNPKA; EvalTable[PLO] = &Simulator::Evaluate_PLO; EvalTable[LMD] = &Simulator::Evaluate_LMD; EvalTable[SRP] = &Simulator::Evaluate_SRP; EvalTable[MVO] = &Simulator::Evaluate_MVO; EvalTable[PACK] = &Simulator::Evaluate_PACK; EvalTable[UNPK] = &Simulator::Evaluate_UNPK; EvalTable[ZAP] = &Simulator::Evaluate_ZAP; EvalTable[AP] = &Simulator::Evaluate_AP; EvalTable[SP] = &Simulator::Evaluate_SP; EvalTable[MP] = &Simulator::Evaluate_MP; EvalTable[DP] = &Simulator::Evaluate_DP; EvalTable[UPT] = &Simulator::Evaluate_UPT; EvalTable[PFPO] = &Simulator::Evaluate_PFPO; EvalTable[IIHH] = &Simulator::Evaluate_IIHH; EvalTable[IIHL] = &Simulator::Evaluate_IIHL; EvalTable[IILH] = &Simulator::Evaluate_IILH; EvalTable[IILL] = &Simulator::Evaluate_IILL; EvalTable[NIHH] = &Simulator::Evaluate_NIHH; EvalTable[NIHL] = &Simulator::Evaluate_NIHL; EvalTable[NILH] = &Simulator::Evaluate_NILH; EvalTable[NILL] = &Simulator::Evaluate_NILL; EvalTable[OIHH] = &Simulator::Evaluate_OIHH; EvalTable[OIHL] = &Simulator::Evaluate_OIHL; EvalTable[OILH] = &Simulator::Evaluate_OILH; EvalTable[OILL] = &Simulator::Evaluate_OILL; EvalTable[LLIHH] = &Simulator::Evaluate_LLIHH; EvalTable[LLIHL] = &Simulator::Evaluate_LLIHL; EvalTable[LLILH] = &Simulator::Evaluate_LLILH; EvalTable[LLILL] = &Simulator::Evaluate_LLILL; EvalTable[TMLH] = &Simulator::Evaluate_TMLH; EvalTable[TMLL] = &Simulator::Evaluate_TMLL; EvalTable[TMHH] = &Simulator::Evaluate_TMHH; EvalTable[TMHL] = &Simulator::Evaluate_TMHL; EvalTable[BRC] = &Simulator::Evaluate_BRC; EvalTable[BRAS] = &Simulator::Evaluate_BRAS; EvalTable[BRCT] = &Simulator::Evaluate_BRCT; EvalTable[BRCTG] = &Simulator::Evaluate_BRCTG; EvalTable[LHI] = &Simulator::Evaluate_LHI; EvalTable[LGHI] = &Simulator::Evaluate_LGHI; EvalTable[AHI] = &Simulator::Evaluate_AHI; EvalTable[AGHI] = &Simulator::Evaluate_AGHI; EvalTable[MHI] = &Simulator::Evaluate_MHI; EvalTable[MGHI] = &Simulator::Evaluate_MGHI; EvalTable[CHI] = &Simulator::Evaluate_CHI; EvalTable[CGHI] = &Simulator::Evaluate_CGHI; EvalTable[LARL] = &Simulator::Evaluate_LARL; EvalTable[LGFI] = &Simulator::Evaluate_LGFI; EvalTable[BRCL] = &Simulator::Evaluate_BRCL; EvalTable[BRASL] = &Simulator::Evaluate_BRASL; EvalTable[XIHF] = &Simulator::Evaluate_XIHF; EvalTable[XILF] = &Simulator::Evaluate_XILF; EvalTable[IIHF] = &Simulator::Evaluate_IIHF; EvalTable[IILF] = &Simulator::Evaluate_IILF; EvalTable[NIHF] = &Simulator::Evaluate_NIHF; EvalTable[NILF] = &Simulator::Evaluate_NILF; EvalTable[OIHF] = &Simulator::Evaluate_OIHF; EvalTable[OILF] = &Simulator::Evaluate_OILF; EvalTable[LLIHF] = &Simulator::Evaluate_LLIHF; EvalTable[LLILF] = &Simulator::Evaluate_LLILF; EvalTable[MSGFI] = &Simulator::Evaluate_MSGFI; EvalTable[MSFI] = &Simulator::Evaluate_MSFI; EvalTable[SLGFI] = &Simulator::Evaluate_SLGFI; EvalTable[SLFI] = &Simulator::Evaluate_SLFI; EvalTable[AGFI] = &Simulator::Evaluate_AGFI; EvalTable[AFI] = &Simulator::Evaluate_AFI; EvalTable[ALGFI] = &Simulator::Evaluate_ALGFI; EvalTable[ALFI] = &Simulator::Evaluate_ALFI; EvalTable[CGFI] = &Simulator::Evaluate_CGFI; EvalTable[CFI] = &Simulator::Evaluate_CFI; EvalTable[CLGFI] = &Simulator::Evaluate_CLGFI; EvalTable[CLFI] = &Simulator::Evaluate_CLFI; EvalTable[LLHRL] = &Simulator::Evaluate_LLHRL; EvalTable[LGHRL] = &Simulator::Evaluate_LGHRL; EvalTable[LHRL] = &Simulator::Evaluate_LHRL; EvalTable[LLGHRL] = &Simulator::Evaluate_LLGHRL; EvalTable[STHRL] = &Simulator::Evaluate_STHRL; EvalTable[LGRL] = &Simulator::Evaluate_LGRL; EvalTable[STGRL] = &Simulator::Evaluate_STGRL; EvalTable[LGFRL] = &Simulator::Evaluate_LGFRL; EvalTable[LRL] = &Simulator::Evaluate_LRL; EvalTable[LLGFRL] = &Simulator::Evaluate_LLGFRL; EvalTable[STRL] = &Simulator::Evaluate_STRL; EvalTable[EXRL] = &Simulator::Evaluate_EXRL; EvalTable[PFDRL] = &Simulator::Evaluate_PFDRL; EvalTable[CGHRL] = &Simulator::Evaluate_CGHRL; EvalTable[CHRL] = &Simulator::Evaluate_CHRL; EvalTable[CGRL] = &Simulator::Evaluate_CGRL; EvalTable[CGFRL] = &Simulator::Evaluate_CGFRL; EvalTable[ECTG] = &Simulator::Evaluate_ECTG; EvalTable[CSST] = &Simulator::Evaluate_CSST; EvalTable[LPD] = &Simulator::Evaluate_LPD; EvalTable[LPDG] = &Simulator::Evaluate_LPDG; EvalTable[BRCTH] = &Simulator::Evaluate_BRCTH; EvalTable[AIH] = &Simulator::Evaluate_AIH; EvalTable[ALSIH] = &Simulator::Evaluate_ALSIH; EvalTable[ALSIHN] = &Simulator::Evaluate_ALSIHN; EvalTable[CIH] = &Simulator::Evaluate_CIH; EvalTable[STCK] = &Simulator::Evaluate_STCK; EvalTable[CFC] = &Simulator::Evaluate_CFC; EvalTable[IPM] = &Simulator::Evaluate_IPM; EvalTable[HSCH] = &Simulator::Evaluate_HSCH; EvalTable[MSCH] = &Simulator::Evaluate_MSCH; EvalTable[SSCH] = &Simulator::Evaluate_SSCH; EvalTable[STSCH] = &Simulator::Evaluate_STSCH; EvalTable[TSCH] = &Simulator::Evaluate_TSCH; EvalTable[TPI] = &Simulator::Evaluate_TPI; EvalTable[SAL] = &Simulator::Evaluate_SAL; EvalTable[RSCH] = &Simulator::Evaluate_RSCH; EvalTable[STCRW] = &Simulator::Evaluate_STCRW; EvalTable[STCPS] = &Simulator::Evaluate_STCPS; EvalTable[RCHP] = &Simulator::Evaluate_RCHP; EvalTable[SCHM] = &Simulator::Evaluate_SCHM; EvalTable[CKSM] = &Simulator::Evaluate_CKSM; EvalTable[SAR] = &Simulator::Evaluate_SAR; EvalTable[EAR] = &Simulator::Evaluate_EAR; EvalTable[MSR] = &Simulator::Evaluate_MSR; EvalTable[MVST] = &Simulator::Evaluate_MVST; EvalTable[CUSE] = &Simulator::Evaluate_CUSE; EvalTable[SRST] = &Simulator::Evaluate_SRST; EvalTable[XSCH] = &Simulator::Evaluate_XSCH; EvalTable[STCKE] = &Simulator::Evaluate_STCKE; EvalTable[STCKF] = &Simulator::Evaluate_STCKF; EvalTable[SRNM] = &Simulator::Evaluate_SRNM; EvalTable[STFPC] = &Simulator::Evaluate_STFPC; EvalTable[LFPC] = &Simulator::Evaluate_LFPC; EvalTable[TRE] = &Simulator::Evaluate_TRE; EvalTable[CUUTF] = &Simulator::Evaluate_CUUTF; EvalTable[CUTFU] = &Simulator::Evaluate_CUTFU; EvalTable[STFLE] = &Simulator::Evaluate_STFLE; EvalTable[SRNMB] = &Simulator::Evaluate_SRNMB; EvalTable[SRNMT] = &Simulator::Evaluate_SRNMT; EvalTable[LFAS] = &Simulator::Evaluate_LFAS; EvalTable[PPA] = &Simulator::Evaluate_PPA; EvalTable[ETND] = &Simulator::Evaluate_ETND; EvalTable[TEND] = &Simulator::Evaluate_TEND; EvalTable[NIAI] = &Simulator::Evaluate_NIAI; EvalTable[TABORT] = &Simulator::Evaluate_TABORT; EvalTable[TRAP4] = &Simulator::Evaluate_TRAP4; EvalTable[LPEBR] = &Simulator::Evaluate_LPEBR; EvalTable[LNEBR] = &Simulator::Evaluate_LNEBR; EvalTable[LTEBR] = &Simulator::Evaluate_LTEBR; EvalTable[LCEBR] = &Simulator::Evaluate_LCEBR; EvalTable[LDEBR] = &Simulator::Evaluate_LDEBR; EvalTable[LXDBR] = &Simulator::Evaluate_LXDBR; EvalTable[LXEBR] = &Simulator::Evaluate_LXEBR; EvalTable[MXDBR] = &Simulator::Evaluate_MXDBR; EvalTable[KEBR] = &Simulator::Evaluate_KEBR; EvalTable[CEBR] = &Simulator::Evaluate_CEBR; EvalTable[AEBR] = &Simulator::Evaluate_AEBR; EvalTable[SEBR] = &Simulator::Evaluate_SEBR; EvalTable[MDEBR] = &Simulator::Evaluate_MDEBR; EvalTable[DEBR] = &Simulator::Evaluate_DEBR; EvalTable[MAEBR] = &Simulator::Evaluate_MAEBR; EvalTable[MSEBR] = &Simulator::Evaluate_MSEBR; EvalTable[LPDBR] = &Simulator::Evaluate_LPDBR; EvalTable[LNDBR] = &Simulator::Evaluate_LNDBR; EvalTable[LTDBR] = &Simulator::Evaluate_LTDBR; EvalTable[LCDBR] = &Simulator::Evaluate_LCDBR; EvalTable[SQEBR] = &Simulator::Evaluate_SQEBR; EvalTable[SQDBR] = &Simulator::Evaluate_SQDBR; EvalTable[SQXBR] = &Simulator::Evaluate_SQXBR; EvalTable[MEEBR] = &Simulator::Evaluate_MEEBR; EvalTable[KDBR] = &Simulator::Evaluate_KDBR; EvalTable[CDBR] = &Simulator::Evaluate_CDBR; EvalTable[ADBR] = &Simulator::Evaluate_ADBR; EvalTable[SDBR] = &Simulator::Evaluate_SDBR; EvalTable[MDBR] = &Simulator::Evaluate_MDBR; EvalTable[DDBR] = &Simulator::Evaluate_DDBR; EvalTable[MADBR] = &Simulator::Evaluate_MADBR; EvalTable[MSDBR] = &Simulator::Evaluate_MSDBR; EvalTable[LPXBR] = &Simulator::Evaluate_LPXBR; EvalTable[LNXBR] = &Simulator::Evaluate_LNXBR; EvalTable[LTXBR] = &Simulator::Evaluate_LTXBR; EvalTable[LCXBR] = &Simulator::Evaluate_LCXBR; EvalTable[LEDBRA] = &Simulator::Evaluate_LEDBRA; EvalTable[LDXBRA] = &Simulator::Evaluate_LDXBRA; EvalTable[LEXBRA] = &Simulator::Evaluate_LEXBRA; EvalTable[FIXBRA] = &Simulator::Evaluate_FIXBRA; EvalTable[KXBR] = &Simulator::Evaluate_KXBR; EvalTable[CXBR] = &Simulator::Evaluate_CXBR; EvalTable[AXBR] = &Simulator::Evaluate_AXBR; EvalTable[SXBR] = &Simulator::Evaluate_SXBR; EvalTable[MXBR] = &Simulator::Evaluate_MXBR; EvalTable[DXBR] = &Simulator::Evaluate_DXBR; EvalTable[TBEDR] = &Simulator::Evaluate_TBEDR; EvalTable[TBDR] = &Simulator::Evaluate_TBDR; EvalTable[DIEBR] = &Simulator::Evaluate_DIEBR; EvalTable[FIEBRA] = &Simulator::Evaluate_FIEBRA; EvalTable[THDER] = &Simulator::Evaluate_THDER; EvalTable[THDR] = &Simulator::Evaluate_THDR; EvalTable[DIDBR] = &Simulator::Evaluate_DIDBR; EvalTable[FIDBRA] = &Simulator::Evaluate_FIDBRA; EvalTable[LXR] = &Simulator::Evaluate_LXR; EvalTable[LPDFR] = &Simulator::Evaluate_LPDFR; EvalTable[LNDFR] = &Simulator::Evaluate_LNDFR; EvalTable[LCDFR] = &Simulator::Evaluate_LCDFR; EvalTable[LZER] = &Simulator::Evaluate_LZER; EvalTable[LZDR] = &Simulator::Evaluate_LZDR; EvalTable[LZXR] = &Simulator::Evaluate_LZXR; EvalTable[SFPC] = &Simulator::Evaluate_SFPC; EvalTable[SFASR] = &Simulator::Evaluate_SFASR; EvalTable[EFPC] = &Simulator::Evaluate_EFPC; EvalTable[CELFBR] = &Simulator::Evaluate_CELFBR; EvalTable[CDLFBR] = &Simulator::Evaluate_CDLFBR; EvalTable[CXLFBR] = &Simulator::Evaluate_CXLFBR; EvalTable[CEFBRA] = &Simulator::Evaluate_CEFBRA; EvalTable[CDFBRA] = &Simulator::Evaluate_CDFBRA; EvalTable[CXFBRA] = &Simulator::Evaluate_CXFBRA; EvalTable[CFEBRA] = &Simulator::Evaluate_CFEBRA; EvalTable[CFDBRA] = &Simulator::Evaluate_CFDBRA; EvalTable[CFXBRA] = &Simulator::Evaluate_CFXBRA; EvalTable[CLFEBR] = &Simulator::Evaluate_CLFEBR; EvalTable[CLFDBR] = &Simulator::Evaluate_CLFDBR; EvalTable[CLFXBR] = &Simulator::Evaluate_CLFXBR; EvalTable[CELGBR] = &Simulator::Evaluate_CELGBR; EvalTable[CDLGBR] = &Simulator::Evaluate_CDLGBR; EvalTable[CXLGBR] = &Simulator::Evaluate_CXLGBR; EvalTable[CEGBRA] = &Simulator::Evaluate_CEGBRA; EvalTable[CDGBRA] = &Simulator::Evaluate_CDGBRA; EvalTable[CXGBRA] = &Simulator::Evaluate_CXGBRA; EvalTable[CGEBRA] = &Simulator::Evaluate_CGEBRA; EvalTable[CGDBRA] = &Simulator::Evaluate_CGDBRA; EvalTable[CGXBRA] = &Simulator::Evaluate_CGXBRA; EvalTable[CLGEBR] = &Simulator::Evaluate_CLGEBR; EvalTable[CLGDBR] = &Simulator::Evaluate_CLGDBR; EvalTable[CFER] = &Simulator::Evaluate_CFER; EvalTable[CFDR] = &Simulator::Evaluate_CFDR; EvalTable[CFXR] = &Simulator::Evaluate_CFXR; EvalTable[LDGR] = &Simulator::Evaluate_LDGR; EvalTable[CGER] = &Simulator::Evaluate_CGER; EvalTable[CGDR] = &Simulator::Evaluate_CGDR; EvalTable[CGXR] = &Simulator::Evaluate_CGXR; EvalTable[LGDR] = &Simulator::Evaluate_LGDR; EvalTable[MDTR] = &Simulator::Evaluate_MDTR; EvalTable[MDTRA] = &Simulator::Evaluate_MDTRA; EvalTable[DDTRA] = &Simulator::Evaluate_DDTRA; EvalTable[ADTRA] = &Simulator::Evaluate_ADTRA; EvalTable[SDTRA] = &Simulator::Evaluate_SDTRA; EvalTable[LDETR] = &Simulator::Evaluate_LDETR; EvalTable[LEDTR] = &Simulator::Evaluate_LEDTR; EvalTable[LTDTR] = &Simulator::Evaluate_LTDTR; EvalTable[FIDTR] = &Simulator::Evaluate_FIDTR; EvalTable[MXTRA] = &Simulator::Evaluate_MXTRA; EvalTable[DXTRA] = &Simulator::Evaluate_DXTRA; EvalTable[AXTRA] = &Simulator::Evaluate_AXTRA; EvalTable[SXTRA] = &Simulator::Evaluate_SXTRA; EvalTable[LXDTR] = &Simulator::Evaluate_LXDTR; EvalTable[LDXTR] = &Simulator::Evaluate_LDXTR; EvalTable[LTXTR] = &Simulator::Evaluate_LTXTR; EvalTable[FIXTR] = &Simulator::Evaluate_FIXTR; EvalTable[KDTR] = &Simulator::Evaluate_KDTR; EvalTable[CGDTRA] = &Simulator::Evaluate_CGDTRA; EvalTable[CUDTR] = &Simulator::Evaluate_CUDTR; EvalTable[CDTR] = &Simulator::Evaluate_CDTR; EvalTable[EEDTR] = &Simulator::Evaluate_EEDTR; EvalTable[ESDTR] = &Simulator::Evaluate_ESDTR; EvalTable[KXTR] = &Simulator::Evaluate_KXTR; EvalTable[CGXTRA] = &Simulator::Evaluate_CGXTRA; EvalTable[CUXTR] = &Simulator::Evaluate_CUXTR; EvalTable[CSXTR] = &Simulator::Evaluate_CSXTR; EvalTable[CXTR] = &Simulator::Evaluate_CXTR; EvalTable[EEXTR] = &Simulator::Evaluate_EEXTR; EvalTable[ESXTR] = &Simulator::Evaluate_ESXTR; EvalTable[CDGTRA] = &Simulator::Evaluate_CDGTRA; EvalTable[CDUTR] = &Simulator::Evaluate_CDUTR; EvalTable[CDSTR] = &Simulator::Evaluate_CDSTR; EvalTable[CEDTR] = &Simulator::Evaluate_CEDTR; EvalTable[QADTR] = &Simulator::Evaluate_QADTR; EvalTable[IEDTR] = &Simulator::Evaluate_IEDTR; EvalTable[RRDTR] = &Simulator::Evaluate_RRDTR; EvalTable[CXGTRA] = &Simulator::Evaluate_CXGTRA; EvalTable[CXUTR] = &Simulator::Evaluate_CXUTR; EvalTable[CXSTR] = &Simulator::Evaluate_CXSTR; EvalTable[CEXTR] = &Simulator::Evaluate_CEXTR; EvalTable[QAXTR] = &Simulator::Evaluate_QAXTR; EvalTable[IEXTR] = &Simulator::Evaluate_IEXTR; EvalTable[RRXTR] = &Simulator::Evaluate_RRXTR; EvalTable[LPGR] = &Simulator::Evaluate_LPGR; EvalTable[LNGR] = &Simulator::Evaluate_LNGR; EvalTable[LTGR] = &Simulator::Evaluate_LTGR; EvalTable[LCGR] = &Simulator::Evaluate_LCGR; EvalTable[LGR] = &Simulator::Evaluate_LGR; EvalTable[LGBR] = &Simulator::Evaluate_LGBR; EvalTable[LGHR] = &Simulator::Evaluate_LGHR; EvalTable[AGR] = &Simulator::Evaluate_AGR; EvalTable[SGR] = &Simulator::Evaluate_SGR; EvalTable[ALGR] = &Simulator::Evaluate_ALGR; EvalTable[SLGR] = &Simulator::Evaluate_SLGR; EvalTable[MSGR] = &Simulator::Evaluate_MSGR; EvalTable[DSGR] = &Simulator::Evaluate_DSGR; EvalTable[LRVGR] = &Simulator::Evaluate_LRVGR; EvalTable[LPGFR] = &Simulator::Evaluate_LPGFR; EvalTable[LNGFR] = &Simulator::Evaluate_LNGFR; EvalTable[LTGFR] = &Simulator::Evaluate_LTGFR; EvalTable[LCGFR] = &Simulator::Evaluate_LCGFR; EvalTable[LGFR] = &Simulator::Evaluate_LGFR; EvalTable[LLGFR] = &Simulator::Evaluate_LLGFR; EvalTable[LLGTR] = &Simulator::Evaluate_LLGTR; EvalTable[AGFR] = &Simulator::Evaluate_AGFR; EvalTable[SGFR] = &Simulator::Evaluate_SGFR; EvalTable[ALGFR] = &Simulator::Evaluate_ALGFR; EvalTable[SLGFR] = &Simulator::Evaluate_SLGFR; EvalTable[MSGFR] = &Simulator::Evaluate_MSGFR; EvalTable[DSGFR] = &Simulator::Evaluate_DSGFR; EvalTable[KMAC] = &Simulator::Evaluate_KMAC; EvalTable[LRVR] = &Simulator::Evaluate_LRVR; EvalTable[CGR] = &Simulator::Evaluate_CGR; EvalTable[CLGR] = &Simulator::Evaluate_CLGR; EvalTable[LBR] = &Simulator::Evaluate_LBR; EvalTable[LHR] = &Simulator::Evaluate_LHR; EvalTable[KMF] = &Simulator::Evaluate_KMF; EvalTable[KMO] = &Simulator::Evaluate_KMO; EvalTable[PCC] = &Simulator::Evaluate_PCC; EvalTable[KMCTR] = &Simulator::Evaluate_KMCTR; EvalTable[KM] = &Simulator::Evaluate_KM; EvalTable[KMC] = &Simulator::Evaluate_KMC; EvalTable[CGFR] = &Simulator::Evaluate_CGFR; EvalTable[KIMD] = &Simulator::Evaluate_KIMD; EvalTable[KLMD] = &Simulator::Evaluate_KLMD; EvalTable[CFDTR] = &Simulator::Evaluate_CFDTR; EvalTable[CLGDTR] = &Simulator::Evaluate_CLGDTR; EvalTable[CLFDTR] = &Simulator::Evaluate_CLFDTR; EvalTable[BCTGR] = &Simulator::Evaluate_BCTGR; EvalTable[CFXTR] = &Simulator::Evaluate_CFXTR; EvalTable[CLFXTR] = &Simulator::Evaluate_CLFXTR; EvalTable[CDFTR] = &Simulator::Evaluate_CDFTR; EvalTable[CDLGTR] = &Simulator::Evaluate_CDLGTR; EvalTable[CDLFTR] = &Simulator::Evaluate_CDLFTR; EvalTable[CXFTR] = &Simulator::Evaluate_CXFTR; EvalTable[CXLGTR] = &Simulator::Evaluate_CXLGTR; EvalTable[CXLFTR] = &Simulator::Evaluate_CXLFTR; EvalTable[CGRT] = &Simulator::Evaluate_CGRT; EvalTable[NGR] = &Simulator::Evaluate_NGR; EvalTable[OGR] = &Simulator::Evaluate_OGR; EvalTable[XGR] = &Simulator::Evaluate_XGR; EvalTable[FLOGR] = &Simulator::Evaluate_FLOGR; EvalTable[LLGCR] = &Simulator::Evaluate_LLGCR; EvalTable[LLGHR] = &Simulator::Evaluate_LLGHR; EvalTable[MLGR] = &Simulator::Evaluate_MLGR; EvalTable[DLGR] = &Simulator::Evaluate_DLGR; EvalTable[ALCGR] = &Simulator::Evaluate_ALCGR; EvalTable[SLBGR] = &Simulator::Evaluate_SLBGR; EvalTable[EPSW] = &Simulator::Evaluate_EPSW; EvalTable[TRTT] = &Simulator::Evaluate_TRTT; EvalTable[TRTO] = &Simulator::Evaluate_TRTO; EvalTable[TROT] = &Simulator::Evaluate_TROT; EvalTable[TROO] = &Simulator::Evaluate_TROO; EvalTable[LLCR] = &Simulator::Evaluate_LLCR; EvalTable[LLHR] = &Simulator::Evaluate_LLHR; EvalTable[MLR] = &Simulator::Evaluate_MLR; EvalTable[DLR] = &Simulator::Evaluate_DLR; EvalTable[ALCR] = &Simulator::Evaluate_ALCR; EvalTable[SLBR] = &Simulator::Evaluate_SLBR; EvalTable[CU14] = &Simulator::Evaluate_CU14; EvalTable[CU24] = &Simulator::Evaluate_CU24; EvalTable[CU41] = &Simulator::Evaluate_CU41; EvalTable[CU42] = &Simulator::Evaluate_CU42; EvalTable[TRTRE] = &Simulator::Evaluate_TRTRE; EvalTable[SRSTU] = &Simulator::Evaluate_SRSTU; EvalTable[TRTE] = &Simulator::Evaluate_TRTE; EvalTable[AHHHR] = &Simulator::Evaluate_AHHHR; EvalTable[SHHHR] = &Simulator::Evaluate_SHHHR; EvalTable[ALHHHR] = &Simulator::Evaluate_ALHHHR; EvalTable[SLHHHR] = &Simulator::Evaluate_SLHHHR; EvalTable[CHHR] = &Simulator::Evaluate_CHHR; EvalTable[AHHLR] = &Simulator::Evaluate_AHHLR; EvalTable[SHHLR] = &Simulator::Evaluate_SHHLR; EvalTable[ALHHLR] = &Simulator::Evaluate_ALHHLR; EvalTable[SLHHLR] = &Simulator::Evaluate_SLHHLR; EvalTable[CHLR] = &Simulator::Evaluate_CHLR; EvalTable[POPCNT_Z] = &Simulator::Evaluate_POPCNT_Z; EvalTable[LOCGR] = &Simulator::Evaluate_LOCGR; EvalTable[NGRK] = &Simulator::Evaluate_NGRK; EvalTable[OGRK] = &Simulator::Evaluate_OGRK; EvalTable[XGRK] = &Simulator::Evaluate_XGRK; EvalTable[AGRK] = &Simulator::Evaluate_AGRK; EvalTable[SGRK] = &Simulator::Evaluate_SGRK; EvalTable[ALGRK] = &Simulator::Evaluate_ALGRK; EvalTable[SLGRK] = &Simulator::Evaluate_SLGRK; EvalTable[LOCR] = &Simulator::Evaluate_LOCR; EvalTable[NRK] = &Simulator::Evaluate_NRK; EvalTable[ORK] = &Simulator::Evaluate_ORK; EvalTable[XRK] = &Simulator::Evaluate_XRK; EvalTable[ARK] = &Simulator::Evaluate_ARK; EvalTable[SRK] = &Simulator::Evaluate_SRK; EvalTable[ALRK] = &Simulator::Evaluate_ALRK; EvalTable[SLRK] = &Simulator::Evaluate_SLRK; EvalTable[LTG] = &Simulator::Evaluate_LTG; EvalTable[LG] = &Simulator::Evaluate_LG; EvalTable[CVBY] = &Simulator::Evaluate_CVBY; EvalTable[AG] = &Simulator::Evaluate_AG; EvalTable[SG] = &Simulator::Evaluate_SG; EvalTable[ALG] = &Simulator::Evaluate_ALG; EvalTable[SLG] = &Simulator::Evaluate_SLG; EvalTable[MSG] = &Simulator::Evaluate_MSG; EvalTable[DSG] = &Simulator::Evaluate_DSG; EvalTable[CVBG] = &Simulator::Evaluate_CVBG; EvalTable[LRVG] = &Simulator::Evaluate_LRVG; EvalTable[LT] = &Simulator::Evaluate_LT; EvalTable[LGF] = &Simulator::Evaluate_LGF; EvalTable[LGH] = &Simulator::Evaluate_LGH; EvalTable[LLGF] = &Simulator::Evaluate_LLGF; EvalTable[LLGT] = &Simulator::Evaluate_LLGT; EvalTable[AGF] = &Simulator::Evaluate_AGF; EvalTable[SGF] = &Simulator::Evaluate_SGF; EvalTable[ALGF] = &Simulator::Evaluate_ALGF; EvalTable[SLGF] = &Simulator::Evaluate_SLGF; EvalTable[MSGF] = &Simulator::Evaluate_MSGF; EvalTable[DSGF] = &Simulator::Evaluate_DSGF; EvalTable[LRV] = &Simulator::Evaluate_LRV; EvalTable[LRVH] = &Simulator::Evaluate_LRVH; EvalTable[CG] = &Simulator::Evaluate_CG; EvalTable[CLG] = &Simulator::Evaluate_CLG; EvalTable[STG] = &Simulator::Evaluate_STG; EvalTable[NTSTG] = &Simulator::Evaluate_NTSTG; EvalTable[CVDY] = &Simulator::Evaluate_CVDY; EvalTable[CVDG] = &Simulator::Evaluate_CVDG; EvalTable[STRVG] = &Simulator::Evaluate_STRVG; EvalTable[CGF] = &Simulator::Evaluate_CGF; EvalTable[CLGF] = &Simulator::Evaluate_CLGF; EvalTable[LTGF] = &Simulator::Evaluate_LTGF; EvalTable[CGH] = &Simulator::Evaluate_CGH; EvalTable[PFD] = &Simulator::Evaluate_PFD; EvalTable[STRV] = &Simulator::Evaluate_STRV; EvalTable[STRVH] = &Simulator::Evaluate_STRVH; EvalTable[BCTG] = &Simulator::Evaluate_BCTG; EvalTable[STY] = &Simulator::Evaluate_STY; EvalTable[MSY] = &Simulator::Evaluate_MSY; EvalTable[NY] = &Simulator::Evaluate_NY; EvalTable[CLY] = &Simulator::Evaluate_CLY; EvalTable[OY] = &Simulator::Evaluate_OY; EvalTable[XY] = &Simulator::Evaluate_XY; EvalTable[LY] = &Simulator::Evaluate_LY; EvalTable[CY] = &Simulator::Evaluate_CY; EvalTable[AY] = &Simulator::Evaluate_AY; EvalTable[SY] = &Simulator::Evaluate_SY; EvalTable[MFY] = &Simulator::Evaluate_MFY; EvalTable[ALY] = &Simulator::Evaluate_ALY; EvalTable[SLY] = &Simulator::Evaluate_SLY; EvalTable[STHY] = &Simulator::Evaluate_STHY; EvalTable[LAY] = &Simulator::Evaluate_LAY; EvalTable[STCY] = &Simulator::Evaluate_STCY; EvalTable[ICY] = &Simulator::Evaluate_ICY; EvalTable[LAEY] = &Simulator::Evaluate_LAEY; EvalTable[LB] = &Simulator::Evaluate_LB; EvalTable[LGB] = &Simulator::Evaluate_LGB; EvalTable[LHY] = &Simulator::Evaluate_LHY; EvalTable[CHY] = &Simulator::Evaluate_CHY; EvalTable[AHY] = &Simulator::Evaluate_AHY; EvalTable[SHY] = &Simulator::Evaluate_SHY; EvalTable[MHY] = &Simulator::Evaluate_MHY; EvalTable[NG] = &Simulator::Evaluate_NG; EvalTable[OG] = &Simulator::Evaluate_OG; EvalTable[XG] = &Simulator::Evaluate_XG; EvalTable[LGAT] = &Simulator::Evaluate_LGAT; EvalTable[MLG] = &Simulator::Evaluate_MLG; EvalTable[DLG] = &Simulator::Evaluate_DLG; EvalTable[ALCG] = &Simulator::Evaluate_ALCG; EvalTable[SLBG] = &Simulator::Evaluate_SLBG; EvalTable[STPQ] = &Simulator::Evaluate_STPQ; EvalTable[LPQ] = &Simulator::Evaluate_LPQ; EvalTable[LLGC] = &Simulator::Evaluate_LLGC; EvalTable[LLGH] = &Simulator::Evaluate_LLGH; EvalTable[LLC] = &Simulator::Evaluate_LLC; EvalTable[LLH] = &Simulator::Evaluate_LLH; EvalTable[ML] = &Simulator::Evaluate_ML; EvalTable[DL] = &Simulator::Evaluate_DL; EvalTable[ALC] = &Simulator::Evaluate_ALC; EvalTable[SLB] = &Simulator::Evaluate_SLB; EvalTable[LLGTAT] = &Simulator::Evaluate_LLGTAT; EvalTable[LLGFAT] = &Simulator::Evaluate_LLGFAT; EvalTable[LAT] = &Simulator::Evaluate_LAT; EvalTable[LBH] = &Simulator::Evaluate_LBH; EvalTable[LLCH] = &Simulator::Evaluate_LLCH; EvalTable[STCH] = &Simulator::Evaluate_STCH; EvalTable[LHH] = &Simulator::Evaluate_LHH; EvalTable[LLHH] = &Simulator::Evaluate_LLHH; EvalTable[STHH] = &Simulator::Evaluate_STHH; EvalTable[LFHAT] = &Simulator::Evaluate_LFHAT; EvalTable[LFH] = &Simulator::Evaluate_LFH; EvalTable[STFH] = &Simulator::Evaluate_STFH; EvalTable[CHF] = &Simulator::Evaluate_CHF; EvalTable[MVCDK] = &Simulator::Evaluate_MVCDK; EvalTable[MVHHI] = &Simulator::Evaluate_MVHHI; EvalTable[MVGHI] = &Simulator::Evaluate_MVGHI; EvalTable[MVHI] = &Simulator::Evaluate_MVHI; EvalTable[CHHSI] = &Simulator::Evaluate_CHHSI; EvalTable[CGHSI] = &Simulator::Evaluate_CGHSI; EvalTable[CHSI] = &Simulator::Evaluate_CHSI; EvalTable[CLFHSI] = &Simulator::Evaluate_CLFHSI; EvalTable[TBEGIN] = &Simulator::Evaluate_TBEGIN; EvalTable[TBEGINC] = &Simulator::Evaluate_TBEGINC; EvalTable[LMG] = &Simulator::Evaluate_LMG; EvalTable[SRAG] = &Simulator::Evaluate_SRAG; EvalTable[SLAG] = &Simulator::Evaluate_SLAG; EvalTable[SRLG] = &Simulator::Evaluate_SRLG; EvalTable[SLLG] = &Simulator::Evaluate_SLLG; EvalTable[CSY] = &Simulator::Evaluate_CSY; EvalTable[RLLG] = &Simulator::Evaluate_RLLG; EvalTable[RLL] = &Simulator::Evaluate_RLL; EvalTable[STMG] = &Simulator::Evaluate_STMG; EvalTable[STMH] = &Simulator::Evaluate_STMH; EvalTable[STCMH] = &Simulator::Evaluate_STCMH; EvalTable[STCMY] = &Simulator::Evaluate_STCMY; EvalTable[CDSY] = &Simulator::Evaluate_CDSY; EvalTable[CDSG] = &Simulator::Evaluate_CDSG; EvalTable[BXHG] = &Simulator::Evaluate_BXHG; EvalTable[BXLEG] = &Simulator::Evaluate_BXLEG; EvalTable[ECAG] = &Simulator::Evaluate_ECAG; EvalTable[TMY] = &Simulator::Evaluate_TMY; EvalTable[MVIY] = &Simulator::Evaluate_MVIY; EvalTable[NIY] = &Simulator::Evaluate_NIY; EvalTable[CLIY] = &Simulator::Evaluate_CLIY; EvalTable[OIY] = &Simulator::Evaluate_OIY; EvalTable[XIY] = &Simulator::Evaluate_XIY; EvalTable[ASI] = &Simulator::Evaluate_ASI; EvalTable[ALSI] = &Simulator::Evaluate_ALSI; EvalTable[AGSI] = &Simulator::Evaluate_AGSI; EvalTable[ALGSI] = &Simulator::Evaluate_ALGSI; EvalTable[ICMH] = &Simulator::Evaluate_ICMH; EvalTable[ICMY] = &Simulator::Evaluate_ICMY; EvalTable[MVCLU] = &Simulator::Evaluate_MVCLU; EvalTable[CLCLU] = &Simulator::Evaluate_CLCLU; EvalTable[STMY] = &Simulator::Evaluate_STMY; EvalTable[LMH] = &Simulator::Evaluate_LMH; EvalTable[LMY] = &Simulator::Evaluate_LMY; EvalTable[TP] = &Simulator::Evaluate_TP; EvalTable[SRAK] = &Simulator::Evaluate_SRAK; EvalTable[SLAK] = &Simulator::Evaluate_SLAK; EvalTable[SRLK] = &Simulator::Evaluate_SRLK; EvalTable[SLLK] = &Simulator::Evaluate_SLLK; EvalTable[LOCG] = &Simulator::Evaluate_LOCG; EvalTable[STOCG] = &Simulator::Evaluate_STOCG; EvalTable[LANG] = &Simulator::Evaluate_LANG; EvalTable[LAOG] = &Simulator::Evaluate_LAOG; EvalTable[LAXG] = &Simulator::Evaluate_LAXG; EvalTable[LAAG] = &Simulator::Evaluate_LAAG; EvalTable[LAALG] = &Simulator::Evaluate_LAALG; EvalTable[LOC] = &Simulator::Evaluate_LOC; EvalTable[STOC] = &Simulator::Evaluate_STOC; EvalTable[LAN] = &Simulator::Evaluate_LAN; EvalTable[LAO] = &Simulator::Evaluate_LAO; EvalTable[LAX] = &Simulator::Evaluate_LAX; EvalTable[LAA] = &Simulator::Evaluate_LAA; EvalTable[LAAL] = &Simulator::Evaluate_LAAL; EvalTable[BRXHG] = &Simulator::Evaluate_BRXHG; EvalTable[BRXLG] = &Simulator::Evaluate_BRXLG; EvalTable[RISBLG] = &Simulator::Evaluate_RISBLG; EvalTable[RNSBG] = &Simulator::Evaluate_RNSBG; EvalTable[RISBG] = &Simulator::Evaluate_RISBG; EvalTable[ROSBG] = &Simulator::Evaluate_ROSBG; EvalTable[RXSBG] = &Simulator::Evaluate_RXSBG; EvalTable[RISBGN] = &Simulator::Evaluate_RISBGN; EvalTable[RISBHG] = &Simulator::Evaluate_RISBHG; EvalTable[CGRJ] = &Simulator::Evaluate_CGRJ; EvalTable[CGIT] = &Simulator::Evaluate_CGIT; EvalTable[CIT] = &Simulator::Evaluate_CIT; EvalTable[CLFIT] = &Simulator::Evaluate_CLFIT; EvalTable[CGIJ] = &Simulator::Evaluate_CGIJ; EvalTable[CIJ] = &Simulator::Evaluate_CIJ; EvalTable[AHIK] = &Simulator::Evaluate_AHIK; EvalTable[AGHIK] = &Simulator::Evaluate_AGHIK; EvalTable[ALHSIK] = &Simulator::Evaluate_ALHSIK; EvalTable[ALGHSIK] = &Simulator::Evaluate_ALGHSIK; EvalTable[CGRB] = &Simulator::Evaluate_CGRB; EvalTable[CGIB] = &Simulator::Evaluate_CGIB; EvalTable[CIB] = &Simulator::Evaluate_CIB; EvalTable[LDEB] = &Simulator::Evaluate_LDEB; EvalTable[LXDB] = &Simulator::Evaluate_LXDB; EvalTable[LXEB] = &Simulator::Evaluate_LXEB; EvalTable[MXDB] = &Simulator::Evaluate_MXDB; EvalTable[KEB] = &Simulator::Evaluate_KEB; EvalTable[CEB] = &Simulator::Evaluate_CEB; EvalTable[AEB] = &Simulator::Evaluate_AEB; EvalTable[SEB] = &Simulator::Evaluate_SEB; EvalTable[MDEB] = &Simulator::Evaluate_MDEB; EvalTable[DEB] = &Simulator::Evaluate_DEB; EvalTable[MAEB] = &Simulator::Evaluate_MAEB; EvalTable[MSEB] = &Simulator::Evaluate_MSEB; EvalTable[TCEB] = &Simulator::Evaluate_TCEB; EvalTable[TCDB] = &Simulator::Evaluate_TCDB; EvalTable[TCXB] = &Simulator::Evaluate_TCXB; EvalTable[SQEB] = &Simulator::Evaluate_SQEB; EvalTable[SQDB] = &Simulator::Evaluate_SQDB; EvalTable[MEEB] = &Simulator::Evaluate_MEEB; EvalTable[KDB] = &Simulator::Evaluate_KDB; EvalTable[CDB] = &Simulator::Evaluate_CDB; EvalTable[ADB] = &Simulator::Evaluate_ADB; EvalTable[SDB] = &Simulator::Evaluate_SDB; EvalTable[MDB] = &Simulator::Evaluate_MDB; EvalTable[DDB] = &Simulator::Evaluate_DDB; EvalTable[MADB] = &Simulator::Evaluate_MADB; EvalTable[MSDB] = &Simulator::Evaluate_MSDB; EvalTable[SLDT] = &Simulator::Evaluate_SLDT; EvalTable[SRDT] = &Simulator::Evaluate_SRDT; EvalTable[SLXT] = &Simulator::Evaluate_SLXT; EvalTable[SRXT] = &Simulator::Evaluate_SRXT; EvalTable[TDCET] = &Simulator::Evaluate_TDCET; EvalTable[TDGET] = &Simulator::Evaluate_TDGET; EvalTable[TDCDT] = &Simulator::Evaluate_TDCDT; EvalTable[TDGDT] = &Simulator::Evaluate_TDGDT; EvalTable[TDCXT] = &Simulator::Evaluate_TDCXT; EvalTable[TDGXT] = &Simulator::Evaluate_TDGXT; EvalTable[LEY] = &Simulator::Evaluate_LEY; EvalTable[LDY] = &Simulator::Evaluate_LDY; EvalTable[STEY] = &Simulator::Evaluate_STEY; EvalTable[STDY] = &Simulator::Evaluate_STDY; EvalTable[CZDT] = &Simulator::Evaluate_CZDT; EvalTable[CZXT] = &Simulator::Evaluate_CZXT; EvalTable[CDZT] = &Simulator::Evaluate_CDZT; EvalTable[CXZT] = &Simulator::Evaluate_CXZT; } // NOLINT Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { i_cache_ = isolate_->simulator_i_cache(); if (i_cache_ == NULL) { i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch); isolate_->set_simulator_i_cache(i_cache_); } Initialize(isolate); // Set up simulator support first. Some of this information is needed to // setup the architecture state. #if V8_TARGET_ARCH_S390X size_t stack_size = FLAG_sim_stack_size * KB; #else size_t stack_size = MB; // allocate 1MB for stack #endif stack_size += 2 * stack_protection_size_; stack_ = reinterpret_cast(malloc(stack_size)); pc_modified_ = false; icount_ = 0; break_pc_ = NULL; break_instr_ = 0; // make sure our register type can hold exactly 4/8 bytes #ifdef V8_TARGET_ARCH_S390X DCHECK(sizeof(intptr_t) == 8); #else DCHECK(sizeof(intptr_t) == 4); #endif // Set up architecture state. // All registers are initialized to zero to start with. for (int i = 0; i < kNumGPRs; i++) { registers_[i] = 0; } condition_reg_ = 0; special_reg_pc_ = 0; // Initializing FP registers. for (int i = 0; i < kNumFPRs; i++) { fp_registers_[i] = 0.0; } // The sp is initialized to point to the bottom (high address) of the // allocated stack area. To be safe in potential stack underflows we leave // some buffer below. registers_[sp] = reinterpret_cast(stack_) + stack_size - stack_protection_size_; last_debugger_input_ = NULL; } Simulator::~Simulator() { free(stack_); } // When the generated code calls an external reference we need to catch that in // the simulator. The external reference will be a function compiled for the // host architecture. We need to call that function instead of trying to // execute it with the simulator. We do that by redirecting the external // reference to a svc (Supervisor Call) instruction that is handled by // the simulator. We write the original destination of the jump just at a known // offset from the svc instruction so the simulator knows what to call. class Redirection { public: Redirection(Isolate* isolate, void* external_function, ExternalReference::Type type) : external_function_(external_function), // we use TRAP4 here (0xBF22) #if V8_TARGET_LITTLE_ENDIAN swi_instruction_(0x1000FFB2), #else swi_instruction_(0xB2FF0000 | kCallRtRedirected), #endif type_(type), next_(NULL) { next_ = isolate->simulator_redirection(); Simulator::current(isolate)->FlushICache( isolate->simulator_i_cache(), reinterpret_cast(&swi_instruction_), sizeof(FourByteInstr)); isolate->set_simulator_redirection(this); if (ABI_USES_FUNCTION_DESCRIPTORS) { function_descriptor_[0] = reinterpret_cast(&swi_instruction_); function_descriptor_[1] = 0; function_descriptor_[2] = 0; } } void* address() { if (ABI_USES_FUNCTION_DESCRIPTORS) { return reinterpret_cast(function_descriptor_); } else { return reinterpret_cast(&swi_instruction_); } } void* external_function() { return external_function_; } ExternalReference::Type type() { return type_; } static Redirection* Get(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* current = isolate->simulator_redirection(); for (; current != NULL; current = current->next_) { if (current->external_function_ == external_function) { DCHECK_EQ(current->type(), type); return current; } } return new Redirection(isolate, external_function, type); } static Redirection* FromSwiInstruction(Instruction* swi_instruction) { char* addr_of_swi = reinterpret_cast(swi_instruction); char* addr_of_redirection = addr_of_swi - offsetof(Redirection, swi_instruction_); return reinterpret_cast(addr_of_redirection); } static Redirection* FromAddress(void* address) { int delta = ABI_USES_FUNCTION_DESCRIPTORS ? offsetof(Redirection, function_descriptor_) : offsetof(Redirection, swi_instruction_); char* addr_of_redirection = reinterpret_cast(address) - delta; return reinterpret_cast(addr_of_redirection); } static void* ReverseRedirection(intptr_t reg) { Redirection* redirection = FromAddress(reinterpret_cast(reg)); return redirection->external_function(); } static void DeleteChain(Redirection* redirection) { while (redirection != nullptr) { Redirection* next = redirection->next_; delete redirection; redirection = next; } } private: void* external_function_; uint32_t swi_instruction_; ExternalReference::Type type_; Redirection* next_; intptr_t function_descriptor_[3]; }; // static void Simulator::TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first) { Redirection::DeleteChain(first); if (i_cache != nullptr) { for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; entry = i_cache->Next(entry)) { delete static_cast(entry->value); } delete i_cache; } } void* Simulator::RedirectExternalReference(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* redirection = Redirection::Get(isolate, external_function, type); return redirection->address(); } // Get the active Simulator for the current thread. Simulator* Simulator::current(Isolate* isolate) { v8::internal::Isolate::PerIsolateThreadData* isolate_data = isolate->FindOrAllocatePerThreadDataForThisThread(); DCHECK(isolate_data != NULL); Simulator* sim = isolate_data->simulator(); if (sim == NULL) { // TODO(146): delete the simulator object when a thread/isolate goes away. sim = new Simulator(isolate); isolate_data->set_simulator(sim); } return sim; } // Sets the register in the architecture state. void Simulator::set_register(int reg, uint64_t value) { DCHECK((reg >= 0) && (reg < kNumGPRs)); registers_[reg] = value; } // Get the register from the architecture state. uint64_t Simulator::get_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return registers_[reg]; } template T Simulator::get_low_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] & 0xFFFFFFFF); } template T Simulator::get_high_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] >> 32); } void Simulator::set_low_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value); uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val >> 32 << 32) | shifted_val; registers_[reg] = result; } void Simulator::set_high_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value) << 32; uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val & 0xFFFFFFFF) | shifted_val; registers_[reg] = result; } double Simulator::get_double_from_register_pair(int reg) { DCHECK((reg >= 0) && (reg < kNumGPRs) && ((reg % 2) == 0)); double dm_val = 0.0; #if 0 && !V8_TARGET_ARCH_S390X // doesn't make sense in 64bit mode // Read the bits from the unsigned integer register_[] array // into the double precision floating point value and return it. char buffer[sizeof(fp_registers_[0])]; memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0])); memcpy(&dm_val, buffer, 2 * sizeof(registers_[0])); #endif return (dm_val); } // Raw access to the PC register. void Simulator::set_pc(intptr_t value) { pc_modified_ = true; special_reg_pc_ = value; } bool Simulator::has_bad_pc() const { return ((special_reg_pc_ == bad_lr) || (special_reg_pc_ == end_sim_pc)); } // Raw access to the PC register without the special adjustment when reading. intptr_t Simulator::get_pc() const { return special_reg_pc_; } // Runtime FP routines take: // - two double arguments // - one double argument and zero or one integer arguments. // All are consructed here from d1, d2 and r2. void Simulator::GetFpArgs(double* x, double* y, intptr_t* z) { *x = get_double_from_d_register(0); *y = get_double_from_d_register(2); *z = get_register(2); } // The return value is in d0. void Simulator::SetFpResult(const double& result) { set_d_register_from_double(0, result); } void Simulator::TrashCallerSaveRegisters() { // We don't trash the registers with the return value. #if 0 // A good idea to trash volatile registers, needs to be done registers_[2] = 0x50Bad4U; registers_[3] = 0x50Bad4U; registers_[12] = 0x50Bad4U; #endif } uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); return *ptr; } int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteW(intptr_t addr, int32_t value, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint16_t Simulator::ReadHU(intptr_t addr, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); return *ptr; } int16_t Simulator::ReadH(intptr_t addr, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteH(intptr_t addr, uint16_t value, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteH(intptr_t addr, int16_t value, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint8_t Simulator::ReadBU(intptr_t addr) { uint8_t* ptr = reinterpret_cast(addr); return *ptr; } int8_t Simulator::ReadB(intptr_t addr) { int8_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteB(intptr_t addr, uint8_t value) { uint8_t* ptr = reinterpret_cast(addr); *ptr = value; } void Simulator::WriteB(intptr_t addr, int8_t value) { int8_t* ptr = reinterpret_cast(addr); *ptr = value; } int64_t Simulator::ReadDW(intptr_t addr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteDW(intptr_t addr, int64_t value) { int64_t* ptr = reinterpret_cast(addr); *ptr = value; return; } /** * Reads a double value from memory at given address. */ double Simulator::ReadDouble(intptr_t addr) { double* ptr = reinterpret_cast(addr); return *ptr; } // Returns the limit of the stack area to enable checking for stack overflows. uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { // The simulator uses a separate JS stack. If we have exhausted the C stack, // we also drop down the JS limit to reflect the exhaustion on the JS stack. if (GetCurrentStackPosition() < c_limit) { return reinterpret_cast(get_sp()); } // Otherwise the limit is the JS stack. Leave a safety margin to prevent // overrunning the stack when pushing values. return reinterpret_cast(stack_) + stack_protection_size_; } // Unsupported instructions use Format to print an error and stop execution. void Simulator::Format(Instruction* instr, const char* format) { PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", reinterpret_cast(instr), format); UNIMPLEMENTED(); } // Calculate C flag value for additions. bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); uint32_t urest = 0xffffffffU - uleft; return (uright > urest) || (carry && (((uright + 1) > urest) || (uright > (urest - 1)))); } // Calculate C flag value for subtractions. bool Simulator::BorrowFrom(int32_t left, int32_t right) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); return (uright > uleft); } // Calculate V flag value for additions and subtractions. template bool Simulator::OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition) { bool overflow; if (addition) { // operands have the same sign overflow = ((left >= 0 && right >= 0) || (left < 0 && right < 0)) // and operands and result have different sign && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } else { // operands have different signs overflow = ((left < 0 && right >= 0) || (left >= 0 && right < 0)) // and first operand and result have different signs && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } return overflow; } #if V8_TARGET_ARCH_S390X static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { *x = reinterpret_cast(pair->x); *y = reinterpret_cast(pair->y); } #else static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { #if V8_TARGET_BIG_ENDIAN *x = static_cast(*pair >> 32); *y = static_cast(*pair); #else *x = static_cast(*pair); *y = static_cast(*pair >> 32); #endif } #endif // Calls into the V8 runtime. typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); // These prototypes handle the four types of FP calls. typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPCall)(double darg0); typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). typedef void (*SimulatorRuntimeDirectApiCall)(intptr_t arg0); typedef void (*SimulatorRuntimeProfilingApiCall)(intptr_t arg0, void* arg1); // This signature supports direct call to accessor getter callback. typedef void (*SimulatorRuntimeDirectGetterCall)(intptr_t arg0, intptr_t arg1); typedef void (*SimulatorRuntimeProfilingGetterCall)(intptr_t arg0, intptr_t arg1, void* arg2); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. void Simulator::SoftwareInterrupt(Instruction* instr) { int svc = instr->SvcValue(); switch (svc) { case kCallRtRedirected: { // Check if stack is aligned. Error if not aligned is reported below to // include information on the function called. bool stack_aligned = (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; Redirection* redirection = Redirection::FromSwiInstruction(instr); const int kArgCount = 6; int arg0_regnum = 2; intptr_t result_buffer = 0; bool uses_result_buffer = redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && !ABI_RETURNS_OBJECTPAIR_IN_REGS); if (uses_result_buffer) { result_buffer = get_register(r2); arg0_regnum++; } intptr_t arg[kArgCount]; for (int i = 0; i < kArgCount - 1; i++) { arg[i] = get_register(arg0_regnum + i); } intptr_t* stack_pointer = reinterpret_cast(get_register(sp)); arg[5] = stack_pointer[kCalleeRegisterSaveAreaSize / kPointerSize]; bool fp_call = (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); // Place the return address on the stack, making the call GC safe. *reinterpret_cast(get_register(sp) + kStackFrameRASlot * kPointerSize) = get_register(r14); intptr_t external = reinterpret_cast(redirection->external_function()); if (fp_call) { double dval0, dval1; // one or two double parameters intptr_t ival; // zero or one integer parameters int iresult = 0; // integer return value double dresult = 0; // double return value GetFpArgs(&dval0, &dval1, &ival); if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall generic_target = reinterpret_cast(external); switch (redirection->type()) { case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Call to host function at %p with args %f, %f", static_cast(FUNCTION_ADDR(generic_target)), dval0, dval1); break; case ExternalReference::BUILTIN_FP_CALL: PrintF("Call to host function at %p with arg %f", static_cast(FUNCTION_ADDR(generic_target)), dval0); break; case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Call to host function at %p with args %f, %" V8PRIdPTR, static_cast(FUNCTION_ADDR(generic_target)), dval0, ival); break; default: UNREACHABLE(); break; } if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: { SimulatorRuntimeCompareCall target = reinterpret_cast(external); iresult = target(dval0, dval1); set_register(r2, iresult); break; } case ExternalReference::BUILTIN_FP_FP_CALL: { SimulatorRuntimeFPFPCall target = reinterpret_cast(external); dresult = target(dval0, dval1); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_CALL: { SimulatorRuntimeFPCall target = reinterpret_cast(external); dresult = target(dval0); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_INT_CALL: { SimulatorRuntimeFPIntCall target = reinterpret_cast(external); dresult = target(dval0, ival); SetFpResult(dresult); break; } default: UNREACHABLE(); break; } if (::v8::internal::FLAG_trace_sim || !stack_aligned) { switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Returned %08x\n", iresult); break; case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_FP_CALL: case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Returned %f\n", dresult); break; default: UNREACHABLE(); break; } } } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR, reinterpret_cast(external), arg[0]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectApiCall target = reinterpret_cast(external); target(arg[0]); } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingApiCall target = reinterpret_cast(external); target(arg[0], Redirection::ReverseRedirection(arg[1])); } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1]); } else if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1], arg[2]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); } else { // builtin call. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall target = reinterpret_cast(external); PrintF( "Call to host function at %p,\n" "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, static_cast(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { SimulatorRuntimeTripleCall target = reinterpret_cast(external); ObjectTriple result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", reinterpret_cast(result.x), reinterpret_cast(result.y), reinterpret_cast(result.z)); } memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectTriple)); set_register(r2, result_buffer); } else { if (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR) { SimulatorRuntimePairCall target = reinterpret_cast(external); ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); intptr_t x; intptr_t y; decodeObjectPair(&result, &x, &y); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); } if (ABI_RETURNS_OBJECTPAIR_IN_REGS) { set_register(r2, x); set_register(r3, y); } else { memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectPair)); set_register(r2, result_buffer); } } else { DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); SimulatorRuntimeCall target = reinterpret_cast(external); intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned %08" V8PRIxPTR "\n", result); } set_register(r2, result); } } // #if !V8_TARGET_ARCH_S390X // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL); // SimulatorRuntimeCall target = // reinterpret_cast(external); // int64_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // int32_t lo_res = static_cast(result); // int32_t hi_res = static_cast(result >> 32); // #if !V8_TARGET_LITTLE_ENDIAN // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", hi_res); // } // set_register(r2, hi_res); // set_register(r3, lo_res); // #else // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", lo_res); // } // set_register(r2, lo_res); // set_register(r3, hi_res); // #endif // #else // if (redirection->type() == ExternalReference::BUILTIN_CALL) { // SimulatorRuntimeCall target = // reinterpret_cast(external); // intptr_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR "\n", result); // } // set_register(r2, result); // } else { // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL_PAIR); // SimulatorRuntimePairCall target = // reinterpret_cast(external); // ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR ", %08" V8PRIxPTR "\n", // result.x, result.y); // } // #if ABI_RETURNS_OBJECTPAIR_IN_REGS // set_register(r2, result.x); // set_register(r3, result.y); // #else // memcpy(reinterpret_cast(result_buffer), &result, // sizeof(ObjectPair)); // #endif // } // #endif } int64_t saved_lr = *reinterpret_cast( get_register(sp) + kStackFrameRASlot * kPointerSize); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On zLinux-31, the saved_lr might be tagged with a high bit of 1. // Cleanse it before proceeding with simulation. saved_lr &= 0x7FFFFFFF; #endif set_pc(saved_lr); break; } case kBreakpoint: { S390Debugger dbg(this); dbg.Debug(); break; } // stop uses all codes greater than 1 << 23. default: { if (svc >= (1 << 23)) { uint32_t code = svc & kStopCodeMask; if (isWatchedStop(code)) { IncreaseStopCounter(code); } // Stop if it is enabled, otherwise go on jumping over the stop // and the message address. if (isEnabledStop(code)) { S390Debugger dbg(this); dbg.Stop(instr); } else { set_pc(get_pc() + sizeof(FourByteInstr) + kPointerSize); } } else { // This is not a valid svc code. UNREACHABLE(); break; } } } } // Stop helper functions. bool Simulator::isStopInstruction(Instruction* instr) { return (instr->Bits(27, 24) == 0xF) && (instr->SvcValue() >= kStopCode); } bool Simulator::isWatchedStop(uint32_t code) { DCHECK(code <= kMaxStopCode); return code < kNumOfWatchedStops; } bool Simulator::isEnabledStop(uint32_t code) { DCHECK(code <= kMaxStopCode); // Unwatched stops are always enabled. return !isWatchedStop(code) || !(watched_stops_[code].count & kStopDisabledBit); } void Simulator::EnableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (!isEnabledStop(code)) { watched_stops_[code].count &= ~kStopDisabledBit; } } void Simulator::DisableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (isEnabledStop(code)) { watched_stops_[code].count |= kStopDisabledBit; } } void Simulator::IncreaseStopCounter(uint32_t code) { DCHECK(code <= kMaxStopCode); DCHECK(isWatchedStop(code)); if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) { PrintF( "Stop counter for code %i has overflowed.\n" "Enabling this code and reseting the counter to 0.\n", code); watched_stops_[code].count = 0; EnableStop(code); } else { watched_stops_[code].count++; } } // Print a stop status. void Simulator::PrintStopInfo(uint32_t code) { DCHECK(code <= kMaxStopCode); if (!isWatchedStop(code)) { PrintF("Stop not watched."); } else { const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; int32_t count = watched_stops_[code].count & ~kStopDisabledBit; // Don't print the state of unused breakpoints. if (count != 0) { if (watched_stops_[code].desc) { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", code, code, state, count, watched_stops_[code].desc); } else { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", code, code, state, count); } } } } // Method for checking overflow on signed addition: // Test src1 and src2 have opposite sign, // (1) No overflow if they have opposite sign // (2) Test the result and one of the operands have opposite sign // (a) No overflow if they don't have opposite sign // (b) Overflow if opposite #define CheckOverflowForIntAdd(src1, src2, type) \ OverflowFromSigned(src1 + src2, src1, src2, true); #define CheckOverflowForIntSub(src1, src2, type) \ OverflowFromSigned(src1 - src2, src1, src2, false); // Method for checking overflow on unsigned addtion #define CheckOverflowForUIntAdd(src1, src2) \ ((src1) + (src2) < (src1) || (src1) + (src2) < (src2)) // Method for checking overflow on unsigned subtraction #define CheckOverflowForUIntSub(src1, src2) ((src1) - (src2) > (src1)) // Method for checking overflow on multiplication #define CheckOverflowForMul(src1, src2) (((src1) * (src2)) / (src2) != (src1)) // Method for checking overflow on shift right #define CheckOverflowForShiftRight(src1, src2) \ (((src1) >> (src2)) << (src2) != (src1)) // Method for checking overflow on shift left #define CheckOverflowForShiftLeft(src1, src2) \ (((src1) << (src2)) >> (src2) != (src1)) // S390 Decode and simulate helpers bool Simulator::DecodeTwoByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); switch (op) { // RR format instructions case AR: case SR: case MR: case DR: case OR: case NR: case XR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); bool isOF = false; switch (op) { case AR: isOF = CheckOverflowForIntAdd(r1_val, r2_val, int32_t); r1_val += r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case SR: isOF = CheckOverflowForIntSub(r1_val, r2_val, int32_t); r1_val -= r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case OR: r1_val |= r2_val; SetS390BitWiseConditionCode(r1_val); break; case NR: r1_val &= r2_val; SetS390BitWiseConditionCode(r1_val); break; case XR: r1_val ^= r2_val; SetS390BitWiseConditionCode(r1_val); break; case MR: { DCHECK(r1 % 2 == 0); r1_val = get_low_register(r1 + 1); int64_t product = static_cast(r1_val) * static_cast(r2_val); int32_t high_bits = product >> 32; r1_val = high_bits; int32_t low_bits = product & 0x00000000FFFFFFFF; set_low_register(r1, high_bits); set_low_register(r1 + 1, low_bits); break; } case DR: { // reg-reg pair should be even-odd pair, assert r1 is an even register DCHECK(r1 % 2 == 0); // leftmost 32 bits of the dividend are in r1 // rightmost 32 bits of the dividend are in r1+1 // get the signed value from r1 int64_t dividend = static_cast(r1_val) << 32; // get unsigned value from r1+1 // avoid addition with sign-extended r1+1 value dividend += get_low_register(r1 + 1); int32_t remainder = dividend % r2_val; int32_t quotient = dividend / r2_val; r1_val = remainder; set_low_register(r1, remainder); set_low_register(r1 + 1, quotient); break; // reg pair } default: UNREACHABLE(); break; } set_low_register(r1, r1_val); break; } case LR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); set_low_register(r1, get_low_register(r2)); break; } case LDR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int64_t r2_val = get_d_register(r2); set_d_register(r1, r2_val); break; } case CR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case CLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case BCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); if (TestConditionCode(Condition(r1))) { intptr_t r2_val = get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, but is ignored by the // hardware. Cleanse the top bit before jumping to it, unless it's one // of the special PCs if (r2_val != bad_lr && r2_val != end_sim_pc) r2_val &= 0x7FFFFFFF; #endif set_pc(r2_val); } break; } case LTR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r2_val, 0); set_low_register(r1, r2_val); break; } case ALR: case SLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); uint32_t alu_out = 0; bool isOF = false; if (ALR == op) { alu_out = r1_val + r2_val; isOF = CheckOverflowForUIntAdd(r1_val, r2_val); } else if (SLR == op) { alu_out = r1_val - r2_val; isOF = CheckOverflowForUIntSub(r1_val, r2_val); } else { UNREACHABLE(); } set_low_register(r1, alu_out); SetS390ConditionCodeCarry(alu_out, isOF); break; } case LNR: { // Load Negative (32) RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); r2_val = (r2_val >= 0) ? -r2_val : r2_val; // If pos, then negate it. set_low_register(r1, r2_val); condition_reg_ = (r2_val == 0) ? CC_EQ : CC_LT; // CC0 - result is zero // CC1 - result is negative break; } case BASR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); intptr_t link_addr = get_pc() + 2; // If R2 is zero, the BASR does not branch. int64_t r2_val = (r2 == 0) ? link_addr : get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, which can cause issues // for stackwalker. The top bit should either be cleanse before being // pushed onto the stack, or during stack walking when dereferenced. // For simulator, we'll take the worst case scenario and always tag // the high bit, to flush out more problems. link_addr |= 0x80000000; #endif set_register(r1, link_addr); set_pc(r2_val); break; } case LCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); int32_t original_r2_val = r2_val; r2_val = ~r2_val; r2_val = r2_val + 1; set_low_register(r1, r2_val); SetS390ConditionCode(r2_val, 0); // Checks for overflow where r2_val = -2147483648. // Cannot do int comparison due to GCC 4.8 bug on x86. // Detect INT_MIN alternatively, as it is the only value where both // original and result are negative due to overflow. if (r2_val < 0 && original_r2_val < 0) { SetS390OverflowCode(true); } break; } case BKPT: { set_pc(get_pc() + 2); S390Debugger dbg(this); dbg.Debug(); break; } default: UNREACHABLE(); return false; break; } return true; } // Decode routine for four-byte instructions bool Simulator::DecodeFourByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); // Pre-cast instruction to various types RREInstruction* rreInst = reinterpret_cast(instr); SIInstruction* siInstr = reinterpret_cast(instr); switch (op) { case POPCNT_Z: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); int64_t r1_val = 0; uint8_t* r2_val_ptr = reinterpret_cast(&r2_val); uint8_t* r1_val_ptr = reinterpret_cast(&r1_val); for (int i = 0; i < 8; i++) { uint32_t x = static_cast(r2_val_ptr[i]); #if defined(__GNUC__) r1_val_ptr[i] = __builtin_popcount(x); #else #error unsupport __builtin_popcount #endif } set_register(r1, static_cast(r1_val)); break; } case LLGFR: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int32_t r2_val = get_low_register(r2); uint64_t r2_finalval = (static_cast(r2_val) & 0x00000000ffffffff); set_register(r1, r2_finalval); break; } case EX: { RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int b2 = rxinst->B2Value(); int x2 = rxinst->X2Value(); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); intptr_t d2_val = rxinst->D2Value(); int32_t r1_val = get_low_register(r1); SixByteInstr the_instr = Instruction::InstructionBits( reinterpret_cast(b2_val + x2_val + d2_val)); int length = Instruction::InstructionLength( reinterpret_cast(b2_val + x2_val + d2_val)); char new_instr_buf[8]; char* addr = reinterpret_cast(&new_instr_buf[0]); the_instr |= static_cast(r1_val & 0xff) << (8 * length - 16); Instruction::SetInstructionBits( reinterpret_cast(addr), static_cast(the_instr)); ExecuteInstruction(reinterpret_cast(addr), false); break; } case LGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); set_register(r1, get_register(r2)); break; } case LDGR: { // Load FPR from GPR (L <- 64) uint64_t int_val = get_register(rreInst->R2Value()); // double double_val = bit_cast(int_val); // set_d_register_from_double(rreInst->R1Value(), double_val); set_d_register(rreInst->R1Value(), int_val); break; } case LGDR: { // Load GPR from FPR (64 <- L) int64_t double_val = get_d_register(rreInst->R2Value()); set_register(rreInst->R1Value(), double_val); break; } case LTGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); SetS390ConditionCode(r2_val, 0); set_register(r1, get_register(r2)); break; } case LZDR: { int r1 = rreInst->R1Value(); set_d_register_from_double(r1, 0.0); break; } case LTEBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); float fr2_val = get_float32_from_d_register(r2); SetS390ConditionCode(fr2_val, 0.0); set_d_register(r1, r2_val); break; } case LTDBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); SetS390ConditionCode(bit_cast(r2_val), 0.0); set_d_register(r1, r2_val); break; } case CGR: { // Compare (64) int64_t r1_val = get_register(rreInst->R1Value()); int64_t r2_val = get_register(rreInst->R2Value()); SetS390ConditionCode(r1_val, r2_val); break; } case CLGR: { // Compare Logical (64) uint64_t r1_val = static_cast(get_register(rreInst->R1Value())); uint64_t r2_val = static_cast(get_register(rreInst->R2Value())); SetS390ConditionCode(r1_val, r2_val); break; } case LH: { // Load Halfword RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int x2 = rxinst->X2Value(); int b2 = rxinst->B2Value(); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); intptr_t d2_val = rxinst->D2Value(); intptr_t mem_addr = x2_val + b2_val + d2_val; int32_t result = static_cast(ReadH(mem_addr, instr)); set_low_register(r1, result); break; } case LHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int i = riinst->I2Value(); set_low_register(r1, i); break; } case LGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = riinst->I2Value(); set_register(r1, i); break; } case CHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int16_t i = riinst->I2Value(); int32_t r1_val = get_low_register(r1); SetS390ConditionCode(r1_val, i); break; } case CGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = static_cast(riinst->I2Value()); int64_t r1_val = get_register(r1); SetS390ConditionCode(r1_val, i); break; } case BRAS: { // Branch Relative and Save RILInstruction* rilInstr = reinterpret_cast(instr); int r1 = rilInstr->R1Value(); intptr_t d2 = rilInstr->I2Value(); intptr_t pc = get_pc(); // Set PC of next instruction to register set_register(r1, pc + sizeof(FourByteInstr)); // Update PC to branch target set_pc(pc + d2 * 2); break; } case BRC: { // Branch Relative on Condition RIInstruction* riinst = reinterpret_cast(instr); int m1 = riinst->M1Value(); if (TestConditionCode((Condition)m1)) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BRCT: case BRCTG: { // Branch On Count (32/64). RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t value = (op == BRCT) ? get_low_register(r1) : get_register(r1); if (BRCT == op) set_low_register(r1, --value); else set_register(r1, --value); // Branch if value != 0 if (value != 0) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BXH: { RSInstruction* rsinst = reinterpret_cast(instr); int r1 = rsinst->R1Value(); int r3 = rsinst->R3Value(); int b2 = rsinst->B2Value(); int d2 = rsinst->D2Value(); // r1_val is the first operand, r3_val is the increment int32_t r1_val = r1 == 0 ? 0 : get_register(r1); int32_t r3_val = r2 == 0 ? 0 : get_register(r3); intptr_t b2_val = b2 == 0 ? 0 : get_register(b2); intptr_t branch_address = b2_val + d2; // increment r1_val r1_val += r3_val; // if the increment is even, then it designates a pair of registers // and the contents of the even and odd registers of the pair are used as // the increment and compare value respectively. If the increment is odd, // the increment itself is used as both the increment and compare value int32_t compare_val = r3 % 2 == 0 ? get_register(r3 + 1) : r3_val; if (r1_val > compare_val) { // branch to address if r1_val is greater than compare value set_pc(branch_address); } // update contents of register in r1 with the new incremented value set_register(r1, r1_val); break; } case IIHH: case IIHL: case IILH: case IILL: { UNIMPLEMENTED(); break; } case STM: case LM: { // Store Multiple 32-bits. RSInstruction* rsinstr = reinterpret_cast(instr); int r1 = rsinstr->R1Value(); int r3 = rsinstr->R3Value(); int rb = rsinstr->B2Value(); int offset = rsinstr->D2Value(); // Regs roll around if r3 is less than r1. // Artifically increase r3 by 16 so we can calculate // the number of regs stored properly. if (r3 < r1) r3 += 16; int32_t rb_val = (rb == 0) ? 0 : get_low_register(rb); // Store each register in ascending order. for (int i = 0; i <= r3 - r1; i++) { if (op == STM) { int32_t value = get_low_register((r1 + i) % 16); WriteW(rb_val + offset + 4 * i, value, instr); } else if (op == LM) { int32_t value = ReadW(rb_val + offset + 4 * i, instr); set_low_register((r1 + i) % 16, value); } } break; } case SLL: case SRL: { RSInstruction* rsInstr = reinterpret_cast(instr); int r1 = rsInstr->R1Value(); int b2 = rsInstr->B2Value(); intptr_t d2 = rsInstr->D2Value(); // only takes rightmost 6bits int64_t b2_val = b2 == 0 ? 0 : get_register(b2); int shiftBits = (b2_val + d2) & 0x3F; uint32_t r1_val = get_low_register
stop(s)\n"); PrintF(" stop unstop\n"); PrintF(" ignore the stop instruction at the current location\n"); PrintF(" from now on\n"); } else { PrintF("Unknown command: %s\n", cmd); } } } // Add all the breakpoints back to stop execution and enter the debugger // shell when hit. RedoBreakpoints(); // Restore tracing ::v8::internal::FLAG_trace_sim = trace; #undef COMMAND_SIZE #undef ARG_SIZE #undef STR #undef XSTR } static bool ICacheMatch(void* one, void* two) { DCHECK((reinterpret_cast(one) & CachePage::kPageMask) == 0); DCHECK((reinterpret_cast(two) & CachePage::kPageMask) == 0); return one == two; } static uint32_t ICacheHash(void* key) { return static_cast(reinterpret_cast(key)) >> 2; } static bool AllOnOnePage(uintptr_t start, int size) { intptr_t start_page = (start & ~CachePage::kPageMask); intptr_t end_page = ((start + size) & ~CachePage::kPageMask); return start_page == end_page; } void Simulator::set_last_debugger_input(char* input) { DeleteArray(last_debugger_input_); last_debugger_input_ = input; } void Simulator::FlushICache(base::CustomMatcherHashMap* i_cache, void* start_addr, size_t size) { intptr_t start = reinterpret_cast(start_addr); int intra_line = (start & CachePage::kLineMask); start -= intra_line; size += intra_line; size = ((size - 1) | CachePage::kLineMask) + 1; int offset = (start & CachePage::kPageMask); while (!AllOnOnePage(start, size - 1)) { int bytes_to_flush = CachePage::kPageSize - offset; FlushOnePage(i_cache, start, bytes_to_flush); start += bytes_to_flush; size -= bytes_to_flush; DCHECK_EQ(0, static_cast(start & CachePage::kPageMask)); offset = 0; } if (size != 0) { FlushOnePage(i_cache, start, size); } } CachePage* Simulator::GetCachePage(base::CustomMatcherHashMap* i_cache, void* page) { base::HashMap::Entry* entry = i_cache->LookupOrInsert(page, ICacheHash(page)); if (entry->value == NULL) { CachePage* new_page = new CachePage(); entry->value = new_page; } return reinterpret_cast(entry->value); } // Flush from start up to and not including start + size. void Simulator::FlushOnePage(base::CustomMatcherHashMap* i_cache, intptr_t start, int size) { DCHECK(size <= CachePage::kPageSize); DCHECK(AllOnOnePage(start, size - 1)); DCHECK((start & CachePage::kLineMask) == 0); DCHECK((size & CachePage::kLineMask) == 0); void* page = reinterpret_cast(start & (~CachePage::kPageMask)); int offset = (start & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* valid_bytemap = cache_page->ValidityByte(offset); memset(valid_bytemap, CachePage::LINE_INVALID, size >> CachePage::kLineShift); } void Simulator::CheckICache(base::CustomMatcherHashMap* i_cache, Instruction* instr) { intptr_t address = reinterpret_cast(instr); void* page = reinterpret_cast(address & (~CachePage::kPageMask)); void* line = reinterpret_cast(address & (~CachePage::kLineMask)); int offset = (address & CachePage::kPageMask); CachePage* cache_page = GetCachePage(i_cache, page); char* cache_valid_byte = cache_page->ValidityByte(offset); bool cache_hit = (*cache_valid_byte == CachePage::LINE_VALID); char* cached_line = cache_page->CachedData(offset & ~CachePage::kLineMask); if (cache_hit) { // Check that the data in memory matches the contents of the I-cache. CHECK_EQ(memcmp(reinterpret_cast(instr), cache_page->CachedData(offset), sizeof(FourByteInstr)), 0); } else { // Cache miss. Load memory into the cache. memcpy(cached_line, line, CachePage::kLineLength); *cache_valid_byte = CachePage::LINE_VALID; } } void Simulator::Initialize(Isolate* isolate) { if (isolate->simulator_initialized()) return; isolate->set_simulator_initialized(true); ::v8::internal::ExternalReference::set_redirector(isolate, &RedirectExternalReference); static base::OnceType once = V8_ONCE_INIT; base::CallOnce(&once, &Simulator::EvalTableInit); } Simulator::EvaluateFuncType Simulator::EvalTable[] = {NULL}; void Simulator::EvalTableInit() { for (int i = 0; i < MAX_NUM_OPCODES; i++) { EvalTable[i] = &Simulator::Evaluate_Unknown; } EvalTable[BKPT] = &Simulator::Evaluate_BKPT; EvalTable[SPM] = &Simulator::Evaluate_SPM; EvalTable[BALR] = &Simulator::Evaluate_BALR; EvalTable[BCTR] = &Simulator::Evaluate_BCTR; EvalTable[BCR] = &Simulator::Evaluate_BCR; EvalTable[SVC] = &Simulator::Evaluate_SVC; EvalTable[BSM] = &Simulator::Evaluate_BSM; EvalTable[BASSM] = &Simulator::Evaluate_BASSM; EvalTable[BASR] = &Simulator::Evaluate_BASR; EvalTable[MVCL] = &Simulator::Evaluate_MVCL; EvalTable[CLCL] = &Simulator::Evaluate_CLCL; EvalTable[LPR] = &Simulator::Evaluate_LPR; EvalTable[LNR] = &Simulator::Evaluate_LNR; EvalTable[LTR] = &Simulator::Evaluate_LTR; EvalTable[LCR] = &Simulator::Evaluate_LCR; EvalTable[NR] = &Simulator::Evaluate_NR; EvalTable[CLR] = &Simulator::Evaluate_CLR; EvalTable[OR] = &Simulator::Evaluate_OR; EvalTable[XR] = &Simulator::Evaluate_XR; EvalTable[LR] = &Simulator::Evaluate_LR; EvalTable[CR] = &Simulator::Evaluate_CR; EvalTable[AR] = &Simulator::Evaluate_AR; EvalTable[SR] = &Simulator::Evaluate_SR; EvalTable[MR] = &Simulator::Evaluate_MR; EvalTable[DR] = &Simulator::Evaluate_DR; EvalTable[ALR] = &Simulator::Evaluate_ALR; EvalTable[SLR] = &Simulator::Evaluate_SLR; EvalTable[LDR] = &Simulator::Evaluate_LDR; EvalTable[CDR] = &Simulator::Evaluate_CDR; EvalTable[LER] = &Simulator::Evaluate_LER; EvalTable[STH] = &Simulator::Evaluate_STH; EvalTable[LA] = &Simulator::Evaluate_LA; EvalTable[STC] = &Simulator::Evaluate_STC; EvalTable[IC_z] = &Simulator::Evaluate_IC_z; EvalTable[EX] = &Simulator::Evaluate_EX; EvalTable[BAL] = &Simulator::Evaluate_BAL; EvalTable[BCT] = &Simulator::Evaluate_BCT; EvalTable[BC] = &Simulator::Evaluate_BC; EvalTable[LH] = &Simulator::Evaluate_LH; EvalTable[CH] = &Simulator::Evaluate_CH; EvalTable[AH] = &Simulator::Evaluate_AH; EvalTable[SH] = &Simulator::Evaluate_SH; EvalTable[MH] = &Simulator::Evaluate_MH; EvalTable[BAS] = &Simulator::Evaluate_BAS; EvalTable[CVD] = &Simulator::Evaluate_CVD; EvalTable[CVB] = &Simulator::Evaluate_CVB; EvalTable[ST] = &Simulator::Evaluate_ST; EvalTable[LAE] = &Simulator::Evaluate_LAE; EvalTable[N] = &Simulator::Evaluate_N; EvalTable[CL] = &Simulator::Evaluate_CL; EvalTable[O] = &Simulator::Evaluate_O; EvalTable[X] = &Simulator::Evaluate_X; EvalTable[L] = &Simulator::Evaluate_L; EvalTable[C] = &Simulator::Evaluate_C; EvalTable[A] = &Simulator::Evaluate_A; EvalTable[S] = &Simulator::Evaluate_S; EvalTable[M] = &Simulator::Evaluate_M; EvalTable[D] = &Simulator::Evaluate_D; EvalTable[AL] = &Simulator::Evaluate_AL; EvalTable[SL] = &Simulator::Evaluate_SL; EvalTable[STD] = &Simulator::Evaluate_STD; EvalTable[LD] = &Simulator::Evaluate_LD; EvalTable[CD] = &Simulator::Evaluate_CD; EvalTable[STE] = &Simulator::Evaluate_STE; EvalTable[MS] = &Simulator::Evaluate_MS; EvalTable[LE] = &Simulator::Evaluate_LE; EvalTable[BRXH] = &Simulator::Evaluate_BRXH; EvalTable[BRXLE] = &Simulator::Evaluate_BRXLE; EvalTable[BXH] = &Simulator::Evaluate_BXH; EvalTable[BXLE] = &Simulator::Evaluate_BXLE; EvalTable[SRL] = &Simulator::Evaluate_SRL; EvalTable[SLL] = &Simulator::Evaluate_SLL; EvalTable[SRA] = &Simulator::Evaluate_SRA; EvalTable[SLA] = &Simulator::Evaluate_SLA; EvalTable[SRDL] = &Simulator::Evaluate_SRDL; EvalTable[SLDL] = &Simulator::Evaluate_SLDL; EvalTable[SRDA] = &Simulator::Evaluate_SRDA; EvalTable[SLDA] = &Simulator::Evaluate_SLDA; EvalTable[STM] = &Simulator::Evaluate_STM; EvalTable[TM] = &Simulator::Evaluate_TM; EvalTable[MVI] = &Simulator::Evaluate_MVI; EvalTable[TS] = &Simulator::Evaluate_TS; EvalTable[NI] = &Simulator::Evaluate_NI; EvalTable[CLI] = &Simulator::Evaluate_CLI; EvalTable[OI] = &Simulator::Evaluate_OI; EvalTable[XI] = &Simulator::Evaluate_XI; EvalTable[LM] = &Simulator::Evaluate_LM; EvalTable[MVCLE] = &Simulator::Evaluate_MVCLE; EvalTable[CLCLE] = &Simulator::Evaluate_CLCLE; EvalTable[MC] = &Simulator::Evaluate_MC; EvalTable[CDS] = &Simulator::Evaluate_CDS; EvalTable[STCM] = &Simulator::Evaluate_STCM; EvalTable[ICM] = &Simulator::Evaluate_ICM; EvalTable[BPRP] = &Simulator::Evaluate_BPRP; EvalTable[BPP] = &Simulator::Evaluate_BPP; EvalTable[TRTR] = &Simulator::Evaluate_TRTR; EvalTable[MVN] = &Simulator::Evaluate_MVN; EvalTable[MVC] = &Simulator::Evaluate_MVC; EvalTable[MVZ] = &Simulator::Evaluate_MVZ; EvalTable[NC] = &Simulator::Evaluate_NC; EvalTable[CLC] = &Simulator::Evaluate_CLC; EvalTable[OC] = &Simulator::Evaluate_OC; EvalTable[XC] = &Simulator::Evaluate_XC; EvalTable[MVCP] = &Simulator::Evaluate_MVCP; EvalTable[TR] = &Simulator::Evaluate_TR; EvalTable[TRT] = &Simulator::Evaluate_TRT; EvalTable[ED] = &Simulator::Evaluate_ED; EvalTable[EDMK] = &Simulator::Evaluate_EDMK; EvalTable[PKU] = &Simulator::Evaluate_PKU; EvalTable[UNPKU] = &Simulator::Evaluate_UNPKU; EvalTable[MVCIN] = &Simulator::Evaluate_MVCIN; EvalTable[PKA] = &Simulator::Evaluate_PKA; EvalTable[UNPKA] = &Simulator::Evaluate_UNPKA; EvalTable[PLO] = &Simulator::Evaluate_PLO; EvalTable[LMD] = &Simulator::Evaluate_LMD; EvalTable[SRP] = &Simulator::Evaluate_SRP; EvalTable[MVO] = &Simulator::Evaluate_MVO; EvalTable[PACK] = &Simulator::Evaluate_PACK; EvalTable[UNPK] = &Simulator::Evaluate_UNPK; EvalTable[ZAP] = &Simulator::Evaluate_ZAP; EvalTable[AP] = &Simulator::Evaluate_AP; EvalTable[SP] = &Simulator::Evaluate_SP; EvalTable[MP] = &Simulator::Evaluate_MP; EvalTable[DP] = &Simulator::Evaluate_DP; EvalTable[UPT] = &Simulator::Evaluate_UPT; EvalTable[PFPO] = &Simulator::Evaluate_PFPO; EvalTable[IIHH] = &Simulator::Evaluate_IIHH; EvalTable[IIHL] = &Simulator::Evaluate_IIHL; EvalTable[IILH] = &Simulator::Evaluate_IILH; EvalTable[IILL] = &Simulator::Evaluate_IILL; EvalTable[NIHH] = &Simulator::Evaluate_NIHH; EvalTable[NIHL] = &Simulator::Evaluate_NIHL; EvalTable[NILH] = &Simulator::Evaluate_NILH; EvalTable[NILL] = &Simulator::Evaluate_NILL; EvalTable[OIHH] = &Simulator::Evaluate_OIHH; EvalTable[OIHL] = &Simulator::Evaluate_OIHL; EvalTable[OILH] = &Simulator::Evaluate_OILH; EvalTable[OILL] = &Simulator::Evaluate_OILL; EvalTable[LLIHH] = &Simulator::Evaluate_LLIHH; EvalTable[LLIHL] = &Simulator::Evaluate_LLIHL; EvalTable[LLILH] = &Simulator::Evaluate_LLILH; EvalTable[LLILL] = &Simulator::Evaluate_LLILL; EvalTable[TMLH] = &Simulator::Evaluate_TMLH; EvalTable[TMLL] = &Simulator::Evaluate_TMLL; EvalTable[TMHH] = &Simulator::Evaluate_TMHH; EvalTable[TMHL] = &Simulator::Evaluate_TMHL; EvalTable[BRC] = &Simulator::Evaluate_BRC; EvalTable[BRAS] = &Simulator::Evaluate_BRAS; EvalTable[BRCT] = &Simulator::Evaluate_BRCT; EvalTable[BRCTG] = &Simulator::Evaluate_BRCTG; EvalTable[LHI] = &Simulator::Evaluate_LHI; EvalTable[LGHI] = &Simulator::Evaluate_LGHI; EvalTable[AHI] = &Simulator::Evaluate_AHI; EvalTable[AGHI] = &Simulator::Evaluate_AGHI; EvalTable[MHI] = &Simulator::Evaluate_MHI; EvalTable[MGHI] = &Simulator::Evaluate_MGHI; EvalTable[CHI] = &Simulator::Evaluate_CHI; EvalTable[CGHI] = &Simulator::Evaluate_CGHI; EvalTable[LARL] = &Simulator::Evaluate_LARL; EvalTable[LGFI] = &Simulator::Evaluate_LGFI; EvalTable[BRCL] = &Simulator::Evaluate_BRCL; EvalTable[BRASL] = &Simulator::Evaluate_BRASL; EvalTable[XIHF] = &Simulator::Evaluate_XIHF; EvalTable[XILF] = &Simulator::Evaluate_XILF; EvalTable[IIHF] = &Simulator::Evaluate_IIHF; EvalTable[IILF] = &Simulator::Evaluate_IILF; EvalTable[NIHF] = &Simulator::Evaluate_NIHF; EvalTable[NILF] = &Simulator::Evaluate_NILF; EvalTable[OIHF] = &Simulator::Evaluate_OIHF; EvalTable[OILF] = &Simulator::Evaluate_OILF; EvalTable[LLIHF] = &Simulator::Evaluate_LLIHF; EvalTable[LLILF] = &Simulator::Evaluate_LLILF; EvalTable[MSGFI] = &Simulator::Evaluate_MSGFI; EvalTable[MSFI] = &Simulator::Evaluate_MSFI; EvalTable[SLGFI] = &Simulator::Evaluate_SLGFI; EvalTable[SLFI] = &Simulator::Evaluate_SLFI; EvalTable[AGFI] = &Simulator::Evaluate_AGFI; EvalTable[AFI] = &Simulator::Evaluate_AFI; EvalTable[ALGFI] = &Simulator::Evaluate_ALGFI; EvalTable[ALFI] = &Simulator::Evaluate_ALFI; EvalTable[CGFI] = &Simulator::Evaluate_CGFI; EvalTable[CFI] = &Simulator::Evaluate_CFI; EvalTable[CLGFI] = &Simulator::Evaluate_CLGFI; EvalTable[CLFI] = &Simulator::Evaluate_CLFI; EvalTable[LLHRL] = &Simulator::Evaluate_LLHRL; EvalTable[LGHRL] = &Simulator::Evaluate_LGHRL; EvalTable[LHRL] = &Simulator::Evaluate_LHRL; EvalTable[LLGHRL] = &Simulator::Evaluate_LLGHRL; EvalTable[STHRL] = &Simulator::Evaluate_STHRL; EvalTable[LGRL] = &Simulator::Evaluate_LGRL; EvalTable[STGRL] = &Simulator::Evaluate_STGRL; EvalTable[LGFRL] = &Simulator::Evaluate_LGFRL; EvalTable[LRL] = &Simulator::Evaluate_LRL; EvalTable[LLGFRL] = &Simulator::Evaluate_LLGFRL; EvalTable[STRL] = &Simulator::Evaluate_STRL; EvalTable[EXRL] = &Simulator::Evaluate_EXRL; EvalTable[PFDRL] = &Simulator::Evaluate_PFDRL; EvalTable[CGHRL] = &Simulator::Evaluate_CGHRL; EvalTable[CHRL] = &Simulator::Evaluate_CHRL; EvalTable[CGRL] = &Simulator::Evaluate_CGRL; EvalTable[CGFRL] = &Simulator::Evaluate_CGFRL; EvalTable[ECTG] = &Simulator::Evaluate_ECTG; EvalTable[CSST] = &Simulator::Evaluate_CSST; EvalTable[LPD] = &Simulator::Evaluate_LPD; EvalTable[LPDG] = &Simulator::Evaluate_LPDG; EvalTable[BRCTH] = &Simulator::Evaluate_BRCTH; EvalTable[AIH] = &Simulator::Evaluate_AIH; EvalTable[ALSIH] = &Simulator::Evaluate_ALSIH; EvalTable[ALSIHN] = &Simulator::Evaluate_ALSIHN; EvalTable[CIH] = &Simulator::Evaluate_CIH; EvalTable[STCK] = &Simulator::Evaluate_STCK; EvalTable[CFC] = &Simulator::Evaluate_CFC; EvalTable[IPM] = &Simulator::Evaluate_IPM; EvalTable[HSCH] = &Simulator::Evaluate_HSCH; EvalTable[MSCH] = &Simulator::Evaluate_MSCH; EvalTable[SSCH] = &Simulator::Evaluate_SSCH; EvalTable[STSCH] = &Simulator::Evaluate_STSCH; EvalTable[TSCH] = &Simulator::Evaluate_TSCH; EvalTable[TPI] = &Simulator::Evaluate_TPI; EvalTable[SAL] = &Simulator::Evaluate_SAL; EvalTable[RSCH] = &Simulator::Evaluate_RSCH; EvalTable[STCRW] = &Simulator::Evaluate_STCRW; EvalTable[STCPS] = &Simulator::Evaluate_STCPS; EvalTable[RCHP] = &Simulator::Evaluate_RCHP; EvalTable[SCHM] = &Simulator::Evaluate_SCHM; EvalTable[CKSM] = &Simulator::Evaluate_CKSM; EvalTable[SAR] = &Simulator::Evaluate_SAR; EvalTable[EAR] = &Simulator::Evaluate_EAR; EvalTable[MSR] = &Simulator::Evaluate_MSR; EvalTable[MVST] = &Simulator::Evaluate_MVST; EvalTable[CUSE] = &Simulator::Evaluate_CUSE; EvalTable[SRST] = &Simulator::Evaluate_SRST; EvalTable[XSCH] = &Simulator::Evaluate_XSCH; EvalTable[STCKE] = &Simulator::Evaluate_STCKE; EvalTable[STCKF] = &Simulator::Evaluate_STCKF; EvalTable[SRNM] = &Simulator::Evaluate_SRNM; EvalTable[STFPC] = &Simulator::Evaluate_STFPC; EvalTable[LFPC] = &Simulator::Evaluate_LFPC; EvalTable[TRE] = &Simulator::Evaluate_TRE; EvalTable[CUUTF] = &Simulator::Evaluate_CUUTF; EvalTable[CUTFU] = &Simulator::Evaluate_CUTFU; EvalTable[STFLE] = &Simulator::Evaluate_STFLE; EvalTable[SRNMB] = &Simulator::Evaluate_SRNMB; EvalTable[SRNMT] = &Simulator::Evaluate_SRNMT; EvalTable[LFAS] = &Simulator::Evaluate_LFAS; EvalTable[PPA] = &Simulator::Evaluate_PPA; EvalTable[ETND] = &Simulator::Evaluate_ETND; EvalTable[TEND] = &Simulator::Evaluate_TEND; EvalTable[NIAI] = &Simulator::Evaluate_NIAI; EvalTable[TABORT] = &Simulator::Evaluate_TABORT; EvalTable[TRAP4] = &Simulator::Evaluate_TRAP4; EvalTable[LPEBR] = &Simulator::Evaluate_LPEBR; EvalTable[LNEBR] = &Simulator::Evaluate_LNEBR; EvalTable[LTEBR] = &Simulator::Evaluate_LTEBR; EvalTable[LCEBR] = &Simulator::Evaluate_LCEBR; EvalTable[LDEBR] = &Simulator::Evaluate_LDEBR; EvalTable[LXDBR] = &Simulator::Evaluate_LXDBR; EvalTable[LXEBR] = &Simulator::Evaluate_LXEBR; EvalTable[MXDBR] = &Simulator::Evaluate_MXDBR; EvalTable[KEBR] = &Simulator::Evaluate_KEBR; EvalTable[CEBR] = &Simulator::Evaluate_CEBR; EvalTable[AEBR] = &Simulator::Evaluate_AEBR; EvalTable[SEBR] = &Simulator::Evaluate_SEBR; EvalTable[MDEBR] = &Simulator::Evaluate_MDEBR; EvalTable[DEBR] = &Simulator::Evaluate_DEBR; EvalTable[MAEBR] = &Simulator::Evaluate_MAEBR; EvalTable[MSEBR] = &Simulator::Evaluate_MSEBR; EvalTable[LPDBR] = &Simulator::Evaluate_LPDBR; EvalTable[LNDBR] = &Simulator::Evaluate_LNDBR; EvalTable[LTDBR] = &Simulator::Evaluate_LTDBR; EvalTable[LCDBR] = &Simulator::Evaluate_LCDBR; EvalTable[SQEBR] = &Simulator::Evaluate_SQEBR; EvalTable[SQDBR] = &Simulator::Evaluate_SQDBR; EvalTable[SQXBR] = &Simulator::Evaluate_SQXBR; EvalTable[MEEBR] = &Simulator::Evaluate_MEEBR; EvalTable[KDBR] = &Simulator::Evaluate_KDBR; EvalTable[CDBR] = &Simulator::Evaluate_CDBR; EvalTable[ADBR] = &Simulator::Evaluate_ADBR; EvalTable[SDBR] = &Simulator::Evaluate_SDBR; EvalTable[MDBR] = &Simulator::Evaluate_MDBR; EvalTable[DDBR] = &Simulator::Evaluate_DDBR; EvalTable[MADBR] = &Simulator::Evaluate_MADBR; EvalTable[MSDBR] = &Simulator::Evaluate_MSDBR; EvalTable[LPXBR] = &Simulator::Evaluate_LPXBR; EvalTable[LNXBR] = &Simulator::Evaluate_LNXBR; EvalTable[LTXBR] = &Simulator::Evaluate_LTXBR; EvalTable[LCXBR] = &Simulator::Evaluate_LCXBR; EvalTable[LEDBRA] = &Simulator::Evaluate_LEDBRA; EvalTable[LDXBRA] = &Simulator::Evaluate_LDXBRA; EvalTable[LEXBRA] = &Simulator::Evaluate_LEXBRA; EvalTable[FIXBRA] = &Simulator::Evaluate_FIXBRA; EvalTable[KXBR] = &Simulator::Evaluate_KXBR; EvalTable[CXBR] = &Simulator::Evaluate_CXBR; EvalTable[AXBR] = &Simulator::Evaluate_AXBR; EvalTable[SXBR] = &Simulator::Evaluate_SXBR; EvalTable[MXBR] = &Simulator::Evaluate_MXBR; EvalTable[DXBR] = &Simulator::Evaluate_DXBR; EvalTable[TBEDR] = &Simulator::Evaluate_TBEDR; EvalTable[TBDR] = &Simulator::Evaluate_TBDR; EvalTable[DIEBR] = &Simulator::Evaluate_DIEBR; EvalTable[FIEBRA] = &Simulator::Evaluate_FIEBRA; EvalTable[THDER] = &Simulator::Evaluate_THDER; EvalTable[THDR] = &Simulator::Evaluate_THDR; EvalTable[DIDBR] = &Simulator::Evaluate_DIDBR; EvalTable[FIDBRA] = &Simulator::Evaluate_FIDBRA; EvalTable[LXR] = &Simulator::Evaluate_LXR; EvalTable[LPDFR] = &Simulator::Evaluate_LPDFR; EvalTable[LNDFR] = &Simulator::Evaluate_LNDFR; EvalTable[LCDFR] = &Simulator::Evaluate_LCDFR; EvalTable[LZER] = &Simulator::Evaluate_LZER; EvalTable[LZDR] = &Simulator::Evaluate_LZDR; EvalTable[LZXR] = &Simulator::Evaluate_LZXR; EvalTable[SFPC] = &Simulator::Evaluate_SFPC; EvalTable[SFASR] = &Simulator::Evaluate_SFASR; EvalTable[EFPC] = &Simulator::Evaluate_EFPC; EvalTable[CELFBR] = &Simulator::Evaluate_CELFBR; EvalTable[CDLFBR] = &Simulator::Evaluate_CDLFBR; EvalTable[CXLFBR] = &Simulator::Evaluate_CXLFBR; EvalTable[CEFBRA] = &Simulator::Evaluate_CEFBRA; EvalTable[CDFBRA] = &Simulator::Evaluate_CDFBRA; EvalTable[CXFBRA] = &Simulator::Evaluate_CXFBRA; EvalTable[CFEBRA] = &Simulator::Evaluate_CFEBRA; EvalTable[CFDBRA] = &Simulator::Evaluate_CFDBRA; EvalTable[CFXBRA] = &Simulator::Evaluate_CFXBRA; EvalTable[CLFEBR] = &Simulator::Evaluate_CLFEBR; EvalTable[CLFDBR] = &Simulator::Evaluate_CLFDBR; EvalTable[CLFXBR] = &Simulator::Evaluate_CLFXBR; EvalTable[CELGBR] = &Simulator::Evaluate_CELGBR; EvalTable[CDLGBR] = &Simulator::Evaluate_CDLGBR; EvalTable[CXLGBR] = &Simulator::Evaluate_CXLGBR; EvalTable[CEGBRA] = &Simulator::Evaluate_CEGBRA; EvalTable[CDGBRA] = &Simulator::Evaluate_CDGBRA; EvalTable[CXGBRA] = &Simulator::Evaluate_CXGBRA; EvalTable[CGEBRA] = &Simulator::Evaluate_CGEBRA; EvalTable[CGDBRA] = &Simulator::Evaluate_CGDBRA; EvalTable[CGXBRA] = &Simulator::Evaluate_CGXBRA; EvalTable[CLGEBR] = &Simulator::Evaluate_CLGEBR; EvalTable[CLGDBR] = &Simulator::Evaluate_CLGDBR; EvalTable[CFER] = &Simulator::Evaluate_CFER; EvalTable[CFDR] = &Simulator::Evaluate_CFDR; EvalTable[CFXR] = &Simulator::Evaluate_CFXR; EvalTable[LDGR] = &Simulator::Evaluate_LDGR; EvalTable[CGER] = &Simulator::Evaluate_CGER; EvalTable[CGDR] = &Simulator::Evaluate_CGDR; EvalTable[CGXR] = &Simulator::Evaluate_CGXR; EvalTable[LGDR] = &Simulator::Evaluate_LGDR; EvalTable[MDTR] = &Simulator::Evaluate_MDTR; EvalTable[MDTRA] = &Simulator::Evaluate_MDTRA; EvalTable[DDTRA] = &Simulator::Evaluate_DDTRA; EvalTable[ADTRA] = &Simulator::Evaluate_ADTRA; EvalTable[SDTRA] = &Simulator::Evaluate_SDTRA; EvalTable[LDETR] = &Simulator::Evaluate_LDETR; EvalTable[LEDTR] = &Simulator::Evaluate_LEDTR; EvalTable[LTDTR] = &Simulator::Evaluate_LTDTR; EvalTable[FIDTR] = &Simulator::Evaluate_FIDTR; EvalTable[MXTRA] = &Simulator::Evaluate_MXTRA; EvalTable[DXTRA] = &Simulator::Evaluate_DXTRA; EvalTable[AXTRA] = &Simulator::Evaluate_AXTRA; EvalTable[SXTRA] = &Simulator::Evaluate_SXTRA; EvalTable[LXDTR] = &Simulator::Evaluate_LXDTR; EvalTable[LDXTR] = &Simulator::Evaluate_LDXTR; EvalTable[LTXTR] = &Simulator::Evaluate_LTXTR; EvalTable[FIXTR] = &Simulator::Evaluate_FIXTR; EvalTable[KDTR] = &Simulator::Evaluate_KDTR; EvalTable[CGDTRA] = &Simulator::Evaluate_CGDTRA; EvalTable[CUDTR] = &Simulator::Evaluate_CUDTR; EvalTable[CDTR] = &Simulator::Evaluate_CDTR; EvalTable[EEDTR] = &Simulator::Evaluate_EEDTR; EvalTable[ESDTR] = &Simulator::Evaluate_ESDTR; EvalTable[KXTR] = &Simulator::Evaluate_KXTR; EvalTable[CGXTRA] = &Simulator::Evaluate_CGXTRA; EvalTable[CUXTR] = &Simulator::Evaluate_CUXTR; EvalTable[CSXTR] = &Simulator::Evaluate_CSXTR; EvalTable[CXTR] = &Simulator::Evaluate_CXTR; EvalTable[EEXTR] = &Simulator::Evaluate_EEXTR; EvalTable[ESXTR] = &Simulator::Evaluate_ESXTR; EvalTable[CDGTRA] = &Simulator::Evaluate_CDGTRA; EvalTable[CDUTR] = &Simulator::Evaluate_CDUTR; EvalTable[CDSTR] = &Simulator::Evaluate_CDSTR; EvalTable[CEDTR] = &Simulator::Evaluate_CEDTR; EvalTable[QADTR] = &Simulator::Evaluate_QADTR; EvalTable[IEDTR] = &Simulator::Evaluate_IEDTR; EvalTable[RRDTR] = &Simulator::Evaluate_RRDTR; EvalTable[CXGTRA] = &Simulator::Evaluate_CXGTRA; EvalTable[CXUTR] = &Simulator::Evaluate_CXUTR; EvalTable[CXSTR] = &Simulator::Evaluate_CXSTR; EvalTable[CEXTR] = &Simulator::Evaluate_CEXTR; EvalTable[QAXTR] = &Simulator::Evaluate_QAXTR; EvalTable[IEXTR] = &Simulator::Evaluate_IEXTR; EvalTable[RRXTR] = &Simulator::Evaluate_RRXTR; EvalTable[LPGR] = &Simulator::Evaluate_LPGR; EvalTable[LNGR] = &Simulator::Evaluate_LNGR; EvalTable[LTGR] = &Simulator::Evaluate_LTGR; EvalTable[LCGR] = &Simulator::Evaluate_LCGR; EvalTable[LGR] = &Simulator::Evaluate_LGR; EvalTable[LGBR] = &Simulator::Evaluate_LGBR; EvalTable[LGHR] = &Simulator::Evaluate_LGHR; EvalTable[AGR] = &Simulator::Evaluate_AGR; EvalTable[SGR] = &Simulator::Evaluate_SGR; EvalTable[ALGR] = &Simulator::Evaluate_ALGR; EvalTable[SLGR] = &Simulator::Evaluate_SLGR; EvalTable[MSGR] = &Simulator::Evaluate_MSGR; EvalTable[DSGR] = &Simulator::Evaluate_DSGR; EvalTable[LRVGR] = &Simulator::Evaluate_LRVGR; EvalTable[LPGFR] = &Simulator::Evaluate_LPGFR; EvalTable[LNGFR] = &Simulator::Evaluate_LNGFR; EvalTable[LTGFR] = &Simulator::Evaluate_LTGFR; EvalTable[LCGFR] = &Simulator::Evaluate_LCGFR; EvalTable[LGFR] = &Simulator::Evaluate_LGFR; EvalTable[LLGFR] = &Simulator::Evaluate_LLGFR; EvalTable[LLGTR] = &Simulator::Evaluate_LLGTR; EvalTable[AGFR] = &Simulator::Evaluate_AGFR; EvalTable[SGFR] = &Simulator::Evaluate_SGFR; EvalTable[ALGFR] = &Simulator::Evaluate_ALGFR; EvalTable[SLGFR] = &Simulator::Evaluate_SLGFR; EvalTable[MSGFR] = &Simulator::Evaluate_MSGFR; EvalTable[DSGFR] = &Simulator::Evaluate_DSGFR; EvalTable[KMAC] = &Simulator::Evaluate_KMAC; EvalTable[LRVR] = &Simulator::Evaluate_LRVR; EvalTable[CGR] = &Simulator::Evaluate_CGR; EvalTable[CLGR] = &Simulator::Evaluate_CLGR; EvalTable[LBR] = &Simulator::Evaluate_LBR; EvalTable[LHR] = &Simulator::Evaluate_LHR; EvalTable[KMF] = &Simulator::Evaluate_KMF; EvalTable[KMO] = &Simulator::Evaluate_KMO; EvalTable[PCC] = &Simulator::Evaluate_PCC; EvalTable[KMCTR] = &Simulator::Evaluate_KMCTR; EvalTable[KM] = &Simulator::Evaluate_KM; EvalTable[KMC] = &Simulator::Evaluate_KMC; EvalTable[CGFR] = &Simulator::Evaluate_CGFR; EvalTable[KIMD] = &Simulator::Evaluate_KIMD; EvalTable[KLMD] = &Simulator::Evaluate_KLMD; EvalTable[CFDTR] = &Simulator::Evaluate_CFDTR; EvalTable[CLGDTR] = &Simulator::Evaluate_CLGDTR; EvalTable[CLFDTR] = &Simulator::Evaluate_CLFDTR; EvalTable[BCTGR] = &Simulator::Evaluate_BCTGR; EvalTable[CFXTR] = &Simulator::Evaluate_CFXTR; EvalTable[CLFXTR] = &Simulator::Evaluate_CLFXTR; EvalTable[CDFTR] = &Simulator::Evaluate_CDFTR; EvalTable[CDLGTR] = &Simulator::Evaluate_CDLGTR; EvalTable[CDLFTR] = &Simulator::Evaluate_CDLFTR; EvalTable[CXFTR] = &Simulator::Evaluate_CXFTR; EvalTable[CXLGTR] = &Simulator::Evaluate_CXLGTR; EvalTable[CXLFTR] = &Simulator::Evaluate_CXLFTR; EvalTable[CGRT] = &Simulator::Evaluate_CGRT; EvalTable[NGR] = &Simulator::Evaluate_NGR; EvalTable[OGR] = &Simulator::Evaluate_OGR; EvalTable[XGR] = &Simulator::Evaluate_XGR; EvalTable[FLOGR] = &Simulator::Evaluate_FLOGR; EvalTable[LLGCR] = &Simulator::Evaluate_LLGCR; EvalTable[LLGHR] = &Simulator::Evaluate_LLGHR; EvalTable[MLGR] = &Simulator::Evaluate_MLGR; EvalTable[DLGR] = &Simulator::Evaluate_DLGR; EvalTable[ALCGR] = &Simulator::Evaluate_ALCGR; EvalTable[SLBGR] = &Simulator::Evaluate_SLBGR; EvalTable[EPSW] = &Simulator::Evaluate_EPSW; EvalTable[TRTT] = &Simulator::Evaluate_TRTT; EvalTable[TRTO] = &Simulator::Evaluate_TRTO; EvalTable[TROT] = &Simulator::Evaluate_TROT; EvalTable[TROO] = &Simulator::Evaluate_TROO; EvalTable[LLCR] = &Simulator::Evaluate_LLCR; EvalTable[LLHR] = &Simulator::Evaluate_LLHR; EvalTable[MLR] = &Simulator::Evaluate_MLR; EvalTable[DLR] = &Simulator::Evaluate_DLR; EvalTable[ALCR] = &Simulator::Evaluate_ALCR; EvalTable[SLBR] = &Simulator::Evaluate_SLBR; EvalTable[CU14] = &Simulator::Evaluate_CU14; EvalTable[CU24] = &Simulator::Evaluate_CU24; EvalTable[CU41] = &Simulator::Evaluate_CU41; EvalTable[CU42] = &Simulator::Evaluate_CU42; EvalTable[TRTRE] = &Simulator::Evaluate_TRTRE; EvalTable[SRSTU] = &Simulator::Evaluate_SRSTU; EvalTable[TRTE] = &Simulator::Evaluate_TRTE; EvalTable[AHHHR] = &Simulator::Evaluate_AHHHR; EvalTable[SHHHR] = &Simulator::Evaluate_SHHHR; EvalTable[ALHHHR] = &Simulator::Evaluate_ALHHHR; EvalTable[SLHHHR] = &Simulator::Evaluate_SLHHHR; EvalTable[CHHR] = &Simulator::Evaluate_CHHR; EvalTable[AHHLR] = &Simulator::Evaluate_AHHLR; EvalTable[SHHLR] = &Simulator::Evaluate_SHHLR; EvalTable[ALHHLR] = &Simulator::Evaluate_ALHHLR; EvalTable[SLHHLR] = &Simulator::Evaluate_SLHHLR; EvalTable[CHLR] = &Simulator::Evaluate_CHLR; EvalTable[POPCNT_Z] = &Simulator::Evaluate_POPCNT_Z; EvalTable[LOCGR] = &Simulator::Evaluate_LOCGR; EvalTable[NGRK] = &Simulator::Evaluate_NGRK; EvalTable[OGRK] = &Simulator::Evaluate_OGRK; EvalTable[XGRK] = &Simulator::Evaluate_XGRK; EvalTable[AGRK] = &Simulator::Evaluate_AGRK; EvalTable[SGRK] = &Simulator::Evaluate_SGRK; EvalTable[ALGRK] = &Simulator::Evaluate_ALGRK; EvalTable[SLGRK] = &Simulator::Evaluate_SLGRK; EvalTable[LOCR] = &Simulator::Evaluate_LOCR; EvalTable[NRK] = &Simulator::Evaluate_NRK; EvalTable[ORK] = &Simulator::Evaluate_ORK; EvalTable[XRK] = &Simulator::Evaluate_XRK; EvalTable[ARK] = &Simulator::Evaluate_ARK; EvalTable[SRK] = &Simulator::Evaluate_SRK; EvalTable[ALRK] = &Simulator::Evaluate_ALRK; EvalTable[SLRK] = &Simulator::Evaluate_SLRK; EvalTable[LTG] = &Simulator::Evaluate_LTG; EvalTable[LG] = &Simulator::Evaluate_LG; EvalTable[CVBY] = &Simulator::Evaluate_CVBY; EvalTable[AG] = &Simulator::Evaluate_AG; EvalTable[SG] = &Simulator::Evaluate_SG; EvalTable[ALG] = &Simulator::Evaluate_ALG; EvalTable[SLG] = &Simulator::Evaluate_SLG; EvalTable[MSG] = &Simulator::Evaluate_MSG; EvalTable[DSG] = &Simulator::Evaluate_DSG; EvalTable[CVBG] = &Simulator::Evaluate_CVBG; EvalTable[LRVG] = &Simulator::Evaluate_LRVG; EvalTable[LT] = &Simulator::Evaluate_LT; EvalTable[LGF] = &Simulator::Evaluate_LGF; EvalTable[LGH] = &Simulator::Evaluate_LGH; EvalTable[LLGF] = &Simulator::Evaluate_LLGF; EvalTable[LLGT] = &Simulator::Evaluate_LLGT; EvalTable[AGF] = &Simulator::Evaluate_AGF; EvalTable[SGF] = &Simulator::Evaluate_SGF; EvalTable[ALGF] = &Simulator::Evaluate_ALGF; EvalTable[SLGF] = &Simulator::Evaluate_SLGF; EvalTable[MSGF] = &Simulator::Evaluate_MSGF; EvalTable[DSGF] = &Simulator::Evaluate_DSGF; EvalTable[LRV] = &Simulator::Evaluate_LRV; EvalTable[LRVH] = &Simulator::Evaluate_LRVH; EvalTable[CG] = &Simulator::Evaluate_CG; EvalTable[CLG] = &Simulator::Evaluate_CLG; EvalTable[STG] = &Simulator::Evaluate_STG; EvalTable[NTSTG] = &Simulator::Evaluate_NTSTG; EvalTable[CVDY] = &Simulator::Evaluate_CVDY; EvalTable[CVDG] = &Simulator::Evaluate_CVDG; EvalTable[STRVG] = &Simulator::Evaluate_STRVG; EvalTable[CGF] = &Simulator::Evaluate_CGF; EvalTable[CLGF] = &Simulator::Evaluate_CLGF; EvalTable[LTGF] = &Simulator::Evaluate_LTGF; EvalTable[CGH] = &Simulator::Evaluate_CGH; EvalTable[PFD] = &Simulator::Evaluate_PFD; EvalTable[STRV] = &Simulator::Evaluate_STRV; EvalTable[STRVH] = &Simulator::Evaluate_STRVH; EvalTable[BCTG] = &Simulator::Evaluate_BCTG; EvalTable[STY] = &Simulator::Evaluate_STY; EvalTable[MSY] = &Simulator::Evaluate_MSY; EvalTable[NY] = &Simulator::Evaluate_NY; EvalTable[CLY] = &Simulator::Evaluate_CLY; EvalTable[OY] = &Simulator::Evaluate_OY; EvalTable[XY] = &Simulator::Evaluate_XY; EvalTable[LY] = &Simulator::Evaluate_LY; EvalTable[CY] = &Simulator::Evaluate_CY; EvalTable[AY] = &Simulator::Evaluate_AY; EvalTable[SY] = &Simulator::Evaluate_SY; EvalTable[MFY] = &Simulator::Evaluate_MFY; EvalTable[ALY] = &Simulator::Evaluate_ALY; EvalTable[SLY] = &Simulator::Evaluate_SLY; EvalTable[STHY] = &Simulator::Evaluate_STHY; EvalTable[LAY] = &Simulator::Evaluate_LAY; EvalTable[STCY] = &Simulator::Evaluate_STCY; EvalTable[ICY] = &Simulator::Evaluate_ICY; EvalTable[LAEY] = &Simulator::Evaluate_LAEY; EvalTable[LB] = &Simulator::Evaluate_LB; EvalTable[LGB] = &Simulator::Evaluate_LGB; EvalTable[LHY] = &Simulator::Evaluate_LHY; EvalTable[CHY] = &Simulator::Evaluate_CHY; EvalTable[AHY] = &Simulator::Evaluate_AHY; EvalTable[SHY] = &Simulator::Evaluate_SHY; EvalTable[MHY] = &Simulator::Evaluate_MHY; EvalTable[NG] = &Simulator::Evaluate_NG; EvalTable[OG] = &Simulator::Evaluate_OG; EvalTable[XG] = &Simulator::Evaluate_XG; EvalTable[LGAT] = &Simulator::Evaluate_LGAT; EvalTable[MLG] = &Simulator::Evaluate_MLG; EvalTable[DLG] = &Simulator::Evaluate_DLG; EvalTable[ALCG] = &Simulator::Evaluate_ALCG; EvalTable[SLBG] = &Simulator::Evaluate_SLBG; EvalTable[STPQ] = &Simulator::Evaluate_STPQ; EvalTable[LPQ] = &Simulator::Evaluate_LPQ; EvalTable[LLGC] = &Simulator::Evaluate_LLGC; EvalTable[LLGH] = &Simulator::Evaluate_LLGH; EvalTable[LLC] = &Simulator::Evaluate_LLC; EvalTable[LLH] = &Simulator::Evaluate_LLH; EvalTable[ML] = &Simulator::Evaluate_ML; EvalTable[DL] = &Simulator::Evaluate_DL; EvalTable[ALC] = &Simulator::Evaluate_ALC; EvalTable[SLB] = &Simulator::Evaluate_SLB; EvalTable[LLGTAT] = &Simulator::Evaluate_LLGTAT; EvalTable[LLGFAT] = &Simulator::Evaluate_LLGFAT; EvalTable[LAT] = &Simulator::Evaluate_LAT; EvalTable[LBH] = &Simulator::Evaluate_LBH; EvalTable[LLCH] = &Simulator::Evaluate_LLCH; EvalTable[STCH] = &Simulator::Evaluate_STCH; EvalTable[LHH] = &Simulator::Evaluate_LHH; EvalTable[LLHH] = &Simulator::Evaluate_LLHH; EvalTable[STHH] = &Simulator::Evaluate_STHH; EvalTable[LFHAT] = &Simulator::Evaluate_LFHAT; EvalTable[LFH] = &Simulator::Evaluate_LFH; EvalTable[STFH] = &Simulator::Evaluate_STFH; EvalTable[CHF] = &Simulator::Evaluate_CHF; EvalTable[MVCDK] = &Simulator::Evaluate_MVCDK; EvalTable[MVHHI] = &Simulator::Evaluate_MVHHI; EvalTable[MVGHI] = &Simulator::Evaluate_MVGHI; EvalTable[MVHI] = &Simulator::Evaluate_MVHI; EvalTable[CHHSI] = &Simulator::Evaluate_CHHSI; EvalTable[CGHSI] = &Simulator::Evaluate_CGHSI; EvalTable[CHSI] = &Simulator::Evaluate_CHSI; EvalTable[CLFHSI] = &Simulator::Evaluate_CLFHSI; EvalTable[TBEGIN] = &Simulator::Evaluate_TBEGIN; EvalTable[TBEGINC] = &Simulator::Evaluate_TBEGINC; EvalTable[LMG] = &Simulator::Evaluate_LMG; EvalTable[SRAG] = &Simulator::Evaluate_SRAG; EvalTable[SLAG] = &Simulator::Evaluate_SLAG; EvalTable[SRLG] = &Simulator::Evaluate_SRLG; EvalTable[SLLG] = &Simulator::Evaluate_SLLG; EvalTable[CSY] = &Simulator::Evaluate_CSY; EvalTable[RLLG] = &Simulator::Evaluate_RLLG; EvalTable[RLL] = &Simulator::Evaluate_RLL; EvalTable[STMG] = &Simulator::Evaluate_STMG; EvalTable[STMH] = &Simulator::Evaluate_STMH; EvalTable[STCMH] = &Simulator::Evaluate_STCMH; EvalTable[STCMY] = &Simulator::Evaluate_STCMY; EvalTable[CDSY] = &Simulator::Evaluate_CDSY; EvalTable[CDSG] = &Simulator::Evaluate_CDSG; EvalTable[BXHG] = &Simulator::Evaluate_BXHG; EvalTable[BXLEG] = &Simulator::Evaluate_BXLEG; EvalTable[ECAG] = &Simulator::Evaluate_ECAG; EvalTable[TMY] = &Simulator::Evaluate_TMY; EvalTable[MVIY] = &Simulator::Evaluate_MVIY; EvalTable[NIY] = &Simulator::Evaluate_NIY; EvalTable[CLIY] = &Simulator::Evaluate_CLIY; EvalTable[OIY] = &Simulator::Evaluate_OIY; EvalTable[XIY] = &Simulator::Evaluate_XIY; EvalTable[ASI] = &Simulator::Evaluate_ASI; EvalTable[ALSI] = &Simulator::Evaluate_ALSI; EvalTable[AGSI] = &Simulator::Evaluate_AGSI; EvalTable[ALGSI] = &Simulator::Evaluate_ALGSI; EvalTable[ICMH] = &Simulator::Evaluate_ICMH; EvalTable[ICMY] = &Simulator::Evaluate_ICMY; EvalTable[MVCLU] = &Simulator::Evaluate_MVCLU; EvalTable[CLCLU] = &Simulator::Evaluate_CLCLU; EvalTable[STMY] = &Simulator::Evaluate_STMY; EvalTable[LMH] = &Simulator::Evaluate_LMH; EvalTable[LMY] = &Simulator::Evaluate_LMY; EvalTable[TP] = &Simulator::Evaluate_TP; EvalTable[SRAK] = &Simulator::Evaluate_SRAK; EvalTable[SLAK] = &Simulator::Evaluate_SLAK; EvalTable[SRLK] = &Simulator::Evaluate_SRLK; EvalTable[SLLK] = &Simulator::Evaluate_SLLK; EvalTable[LOCG] = &Simulator::Evaluate_LOCG; EvalTable[STOCG] = &Simulator::Evaluate_STOCG; EvalTable[LANG] = &Simulator::Evaluate_LANG; EvalTable[LAOG] = &Simulator::Evaluate_LAOG; EvalTable[LAXG] = &Simulator::Evaluate_LAXG; EvalTable[LAAG] = &Simulator::Evaluate_LAAG; EvalTable[LAALG] = &Simulator::Evaluate_LAALG; EvalTable[LOC] = &Simulator::Evaluate_LOC; EvalTable[STOC] = &Simulator::Evaluate_STOC; EvalTable[LAN] = &Simulator::Evaluate_LAN; EvalTable[LAO] = &Simulator::Evaluate_LAO; EvalTable[LAX] = &Simulator::Evaluate_LAX; EvalTable[LAA] = &Simulator::Evaluate_LAA; EvalTable[LAAL] = &Simulator::Evaluate_LAAL; EvalTable[BRXHG] = &Simulator::Evaluate_BRXHG; EvalTable[BRXLG] = &Simulator::Evaluate_BRXLG; EvalTable[RISBLG] = &Simulator::Evaluate_RISBLG; EvalTable[RNSBG] = &Simulator::Evaluate_RNSBG; EvalTable[RISBG] = &Simulator::Evaluate_RISBG; EvalTable[ROSBG] = &Simulator::Evaluate_ROSBG; EvalTable[RXSBG] = &Simulator::Evaluate_RXSBG; EvalTable[RISBGN] = &Simulator::Evaluate_RISBGN; EvalTable[RISBHG] = &Simulator::Evaluate_RISBHG; EvalTable[CGRJ] = &Simulator::Evaluate_CGRJ; EvalTable[CGIT] = &Simulator::Evaluate_CGIT; EvalTable[CIT] = &Simulator::Evaluate_CIT; EvalTable[CLFIT] = &Simulator::Evaluate_CLFIT; EvalTable[CGIJ] = &Simulator::Evaluate_CGIJ; EvalTable[CIJ] = &Simulator::Evaluate_CIJ; EvalTable[AHIK] = &Simulator::Evaluate_AHIK; EvalTable[AGHIK] = &Simulator::Evaluate_AGHIK; EvalTable[ALHSIK] = &Simulator::Evaluate_ALHSIK; EvalTable[ALGHSIK] = &Simulator::Evaluate_ALGHSIK; EvalTable[CGRB] = &Simulator::Evaluate_CGRB; EvalTable[CGIB] = &Simulator::Evaluate_CGIB; EvalTable[CIB] = &Simulator::Evaluate_CIB; EvalTable[LDEB] = &Simulator::Evaluate_LDEB; EvalTable[LXDB] = &Simulator::Evaluate_LXDB; EvalTable[LXEB] = &Simulator::Evaluate_LXEB; EvalTable[MXDB] = &Simulator::Evaluate_MXDB; EvalTable[KEB] = &Simulator::Evaluate_KEB; EvalTable[CEB] = &Simulator::Evaluate_CEB; EvalTable[AEB] = &Simulator::Evaluate_AEB; EvalTable[SEB] = &Simulator::Evaluate_SEB; EvalTable[MDEB] = &Simulator::Evaluate_MDEB; EvalTable[DEB] = &Simulator::Evaluate_DEB; EvalTable[MAEB] = &Simulator::Evaluate_MAEB; EvalTable[MSEB] = &Simulator::Evaluate_MSEB; EvalTable[TCEB] = &Simulator::Evaluate_TCEB; EvalTable[TCDB] = &Simulator::Evaluate_TCDB; EvalTable[TCXB] = &Simulator::Evaluate_TCXB; EvalTable[SQEB] = &Simulator::Evaluate_SQEB; EvalTable[SQDB] = &Simulator::Evaluate_SQDB; EvalTable[MEEB] = &Simulator::Evaluate_MEEB; EvalTable[KDB] = &Simulator::Evaluate_KDB; EvalTable[CDB] = &Simulator::Evaluate_CDB; EvalTable[ADB] = &Simulator::Evaluate_ADB; EvalTable[SDB] = &Simulator::Evaluate_SDB; EvalTable[MDB] = &Simulator::Evaluate_MDB; EvalTable[DDB] = &Simulator::Evaluate_DDB; EvalTable[MADB] = &Simulator::Evaluate_MADB; EvalTable[MSDB] = &Simulator::Evaluate_MSDB; EvalTable[SLDT] = &Simulator::Evaluate_SLDT; EvalTable[SRDT] = &Simulator::Evaluate_SRDT; EvalTable[SLXT] = &Simulator::Evaluate_SLXT; EvalTable[SRXT] = &Simulator::Evaluate_SRXT; EvalTable[TDCET] = &Simulator::Evaluate_TDCET; EvalTable[TDGET] = &Simulator::Evaluate_TDGET; EvalTable[TDCDT] = &Simulator::Evaluate_TDCDT; EvalTable[TDGDT] = &Simulator::Evaluate_TDGDT; EvalTable[TDCXT] = &Simulator::Evaluate_TDCXT; EvalTable[TDGXT] = &Simulator::Evaluate_TDGXT; EvalTable[LEY] = &Simulator::Evaluate_LEY; EvalTable[LDY] = &Simulator::Evaluate_LDY; EvalTable[STEY] = &Simulator::Evaluate_STEY; EvalTable[STDY] = &Simulator::Evaluate_STDY; EvalTable[CZDT] = &Simulator::Evaluate_CZDT; EvalTable[CZXT] = &Simulator::Evaluate_CZXT; EvalTable[CDZT] = &Simulator::Evaluate_CDZT; EvalTable[CXZT] = &Simulator::Evaluate_CXZT; } // NOLINT Simulator::Simulator(Isolate* isolate) : isolate_(isolate) { i_cache_ = isolate_->simulator_i_cache(); if (i_cache_ == NULL) { i_cache_ = new base::CustomMatcherHashMap(&ICacheMatch); isolate_->set_simulator_i_cache(i_cache_); } Initialize(isolate); // Set up simulator support first. Some of this information is needed to // setup the architecture state. #if V8_TARGET_ARCH_S390X size_t stack_size = FLAG_sim_stack_size * KB; #else size_t stack_size = MB; // allocate 1MB for stack #endif stack_size += 2 * stack_protection_size_; stack_ = reinterpret_cast(malloc(stack_size)); pc_modified_ = false; icount_ = 0; break_pc_ = NULL; break_instr_ = 0; // make sure our register type can hold exactly 4/8 bytes #ifdef V8_TARGET_ARCH_S390X DCHECK(sizeof(intptr_t) == 8); #else DCHECK(sizeof(intptr_t) == 4); #endif // Set up architecture state. // All registers are initialized to zero to start with. for (int i = 0; i < kNumGPRs; i++) { registers_[i] = 0; } condition_reg_ = 0; special_reg_pc_ = 0; // Initializing FP registers. for (int i = 0; i < kNumFPRs; i++) { fp_registers_[i] = 0.0; } // The sp is initialized to point to the bottom (high address) of the // allocated stack area. To be safe in potential stack underflows we leave // some buffer below. registers_[sp] = reinterpret_cast(stack_) + stack_size - stack_protection_size_; last_debugger_input_ = NULL; } Simulator::~Simulator() { free(stack_); } // When the generated code calls an external reference we need to catch that in // the simulator. The external reference will be a function compiled for the // host architecture. We need to call that function instead of trying to // execute it with the simulator. We do that by redirecting the external // reference to a svc (Supervisor Call) instruction that is handled by // the simulator. We write the original destination of the jump just at a known // offset from the svc instruction so the simulator knows what to call. class Redirection { public: Redirection(Isolate* isolate, void* external_function, ExternalReference::Type type) : external_function_(external_function), // we use TRAP4 here (0xBF22) #if V8_TARGET_LITTLE_ENDIAN swi_instruction_(0x1000FFB2), #else swi_instruction_(0xB2FF0000 | kCallRtRedirected), #endif type_(type), next_(NULL) { next_ = isolate->simulator_redirection(); Simulator::current(isolate)->FlushICache( isolate->simulator_i_cache(), reinterpret_cast(&swi_instruction_), sizeof(FourByteInstr)); isolate->set_simulator_redirection(this); if (ABI_USES_FUNCTION_DESCRIPTORS) { function_descriptor_[0] = reinterpret_cast(&swi_instruction_); function_descriptor_[1] = 0; function_descriptor_[2] = 0; } } void* address() { if (ABI_USES_FUNCTION_DESCRIPTORS) { return reinterpret_cast(function_descriptor_); } else { return reinterpret_cast(&swi_instruction_); } } void* external_function() { return external_function_; } ExternalReference::Type type() { return type_; } static Redirection* Get(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* current = isolate->simulator_redirection(); for (; current != NULL; current = current->next_) { if (current->external_function_ == external_function) { DCHECK_EQ(current->type(), type); return current; } } return new Redirection(isolate, external_function, type); } static Redirection* FromSwiInstruction(Instruction* swi_instruction) { char* addr_of_swi = reinterpret_cast(swi_instruction); char* addr_of_redirection = addr_of_swi - offsetof(Redirection, swi_instruction_); return reinterpret_cast(addr_of_redirection); } static Redirection* FromAddress(void* address) { int delta = ABI_USES_FUNCTION_DESCRIPTORS ? offsetof(Redirection, function_descriptor_) : offsetof(Redirection, swi_instruction_); char* addr_of_redirection = reinterpret_cast(address) - delta; return reinterpret_cast(addr_of_redirection); } static void* ReverseRedirection(intptr_t reg) { Redirection* redirection = FromAddress(reinterpret_cast(reg)); return redirection->external_function(); } static void DeleteChain(Redirection* redirection) { while (redirection != nullptr) { Redirection* next = redirection->next_; delete redirection; redirection = next; } } private: void* external_function_; uint32_t swi_instruction_; ExternalReference::Type type_; Redirection* next_; intptr_t function_descriptor_[3]; }; // static void Simulator::TearDown(base::CustomMatcherHashMap* i_cache, Redirection* first) { Redirection::DeleteChain(first); if (i_cache != nullptr) { for (base::HashMap::Entry* entry = i_cache->Start(); entry != nullptr; entry = i_cache->Next(entry)) { delete static_cast(entry->value); } delete i_cache; } } void* Simulator::RedirectExternalReference(Isolate* isolate, void* external_function, ExternalReference::Type type) { Redirection* redirection = Redirection::Get(isolate, external_function, type); return redirection->address(); } // Get the active Simulator for the current thread. Simulator* Simulator::current(Isolate* isolate) { v8::internal::Isolate::PerIsolateThreadData* isolate_data = isolate->FindOrAllocatePerThreadDataForThisThread(); DCHECK(isolate_data != NULL); Simulator* sim = isolate_data->simulator(); if (sim == NULL) { // TODO(146): delete the simulator object when a thread/isolate goes away. sim = new Simulator(isolate); isolate_data->set_simulator(sim); } return sim; } // Sets the register in the architecture state. void Simulator::set_register(int reg, uint64_t value) { DCHECK((reg >= 0) && (reg < kNumGPRs)); registers_[reg] = value; } // Get the register from the architecture state. uint64_t Simulator::get_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return registers_[reg]; } template T Simulator::get_low_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] & 0xFFFFFFFF); } template T Simulator::get_high_register(int reg) const { DCHECK((reg >= 0) && (reg < kNumGPRs)); // Stupid code added to avoid bug in GCC. // See: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949 if (reg >= kNumGPRs) return 0; // End stupid code. return static_cast(registers_[reg] >> 32); } void Simulator::set_low_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value); uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val >> 32 << 32) | shifted_val; registers_[reg] = result; } void Simulator::set_high_register(int reg, uint32_t value) { uint64_t shifted_val = static_cast(value) << 32; uint64_t orig_val = static_cast(registers_[reg]); uint64_t result = (orig_val & 0xFFFFFFFF) | shifted_val; registers_[reg] = result; } double Simulator::get_double_from_register_pair(int reg) { DCHECK((reg >= 0) && (reg < kNumGPRs) && ((reg % 2) == 0)); double dm_val = 0.0; #if 0 && !V8_TARGET_ARCH_S390X // doesn't make sense in 64bit mode // Read the bits from the unsigned integer register_[] array // into the double precision floating point value and return it. char buffer[sizeof(fp_registers_[0])]; memcpy(buffer, ®isters_[reg], 2 * sizeof(registers_[0])); memcpy(&dm_val, buffer, 2 * sizeof(registers_[0])); #endif return (dm_val); } // Raw access to the PC register. void Simulator::set_pc(intptr_t value) { pc_modified_ = true; special_reg_pc_ = value; } bool Simulator::has_bad_pc() const { return ((special_reg_pc_ == bad_lr) || (special_reg_pc_ == end_sim_pc)); } // Raw access to the PC register without the special adjustment when reading. intptr_t Simulator::get_pc() const { return special_reg_pc_; } // Runtime FP routines take: // - two double arguments // - one double argument and zero or one integer arguments. // All are consructed here from d1, d2 and r2. void Simulator::GetFpArgs(double* x, double* y, intptr_t* z) { *x = get_double_from_d_register(0); *y = get_double_from_d_register(2); *z = get_register(2); } // The return value is in d0. void Simulator::SetFpResult(const double& result) { set_d_register_from_double(0, result); } void Simulator::TrashCallerSaveRegisters() { // We don't trash the registers with the return value. #if 0 // A good idea to trash volatile registers, needs to be done registers_[2] = 0x50Bad4U; registers_[3] = 0x50Bad4U; registers_[12] = 0x50Bad4U; #endif } uint32_t Simulator::ReadWU(intptr_t addr, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); return *ptr; } int64_t Simulator::ReadW64(intptr_t addr, Instruction* instr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } int32_t Simulator::ReadW(intptr_t addr, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteW(intptr_t addr, uint32_t value, Instruction* instr) { uint32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteW(intptr_t addr, int32_t value, Instruction* instr) { int32_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint16_t Simulator::ReadHU(intptr_t addr, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); return *ptr; } int16_t Simulator::ReadH(intptr_t addr, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteH(intptr_t addr, uint16_t value, Instruction* instr) { uint16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } void Simulator::WriteH(intptr_t addr, int16_t value, Instruction* instr) { int16_t* ptr = reinterpret_cast(addr); *ptr = value; return; } uint8_t Simulator::ReadBU(intptr_t addr) { uint8_t* ptr = reinterpret_cast(addr); return *ptr; } int8_t Simulator::ReadB(intptr_t addr) { int8_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteB(intptr_t addr, uint8_t value) { uint8_t* ptr = reinterpret_cast(addr); *ptr = value; } void Simulator::WriteB(intptr_t addr, int8_t value) { int8_t* ptr = reinterpret_cast(addr); *ptr = value; } int64_t Simulator::ReadDW(intptr_t addr) { int64_t* ptr = reinterpret_cast(addr); return *ptr; } void Simulator::WriteDW(intptr_t addr, int64_t value) { int64_t* ptr = reinterpret_cast(addr); *ptr = value; return; } /** * Reads a double value from memory at given address. */ double Simulator::ReadDouble(intptr_t addr) { double* ptr = reinterpret_cast(addr); return *ptr; } // Returns the limit of the stack area to enable checking for stack overflows. uintptr_t Simulator::StackLimit(uintptr_t c_limit) const { // The simulator uses a separate JS stack. If we have exhausted the C stack, // we also drop down the JS limit to reflect the exhaustion on the JS stack. if (GetCurrentStackPosition() < c_limit) { return reinterpret_cast(get_sp()); } // Otherwise the limit is the JS stack. Leave a safety margin to prevent // overrunning the stack when pushing values. return reinterpret_cast(stack_) + stack_protection_size_; } // Unsupported instructions use Format to print an error and stop execution. void Simulator::Format(Instruction* instr, const char* format) { PrintF("Simulator found unsupported instruction:\n 0x%08" V8PRIxPTR ": %s\n", reinterpret_cast(instr), format); UNIMPLEMENTED(); } // Calculate C flag value for additions. bool Simulator::CarryFrom(int32_t left, int32_t right, int32_t carry) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); uint32_t urest = 0xffffffffU - uleft; return (uright > urest) || (carry && (((uright + 1) > urest) || (uright > (urest - 1)))); } // Calculate C flag value for subtractions. bool Simulator::BorrowFrom(int32_t left, int32_t right) { uint32_t uleft = static_cast(left); uint32_t uright = static_cast(right); return (uright > uleft); } // Calculate V flag value for additions and subtractions. template bool Simulator::OverflowFromSigned(T1 alu_out, T1 left, T1 right, bool addition) { bool overflow; if (addition) { // operands have the same sign overflow = ((left >= 0 && right >= 0) || (left < 0 && right < 0)) // and operands and result have different sign && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } else { // operands have different signs overflow = ((left < 0 && right >= 0) || (left >= 0 && right < 0)) // and first operand and result have different signs && ((left < 0 && alu_out >= 0) || (left >= 0 && alu_out < 0)); } return overflow; } #if V8_TARGET_ARCH_S390X static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { *x = reinterpret_cast(pair->x); *y = reinterpret_cast(pair->y); } #else static void decodeObjectPair(ObjectPair* pair, intptr_t* x, intptr_t* y) { #if V8_TARGET_BIG_ENDIAN *x = static_cast(*pair >> 32); *y = static_cast(*pair); #else *x = static_cast(*pair); *y = static_cast(*pair >> 32); #endif } #endif // Calls into the V8 runtime. typedef intptr_t (*SimulatorRuntimeCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectPair (*SimulatorRuntimePairCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); typedef ObjectTriple (*SimulatorRuntimeTripleCall)(intptr_t arg0, intptr_t arg1, intptr_t arg2, intptr_t arg3, intptr_t arg4, intptr_t arg5); // These prototypes handle the four types of FP calls. typedef int (*SimulatorRuntimeCompareCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPFPCall)(double darg0, double darg1); typedef double (*SimulatorRuntimeFPCall)(double darg0); typedef double (*SimulatorRuntimeFPIntCall)(double darg0, intptr_t arg0); // This signature supports direct call in to API function native callback // (refer to InvocationCallback in v8.h). typedef void (*SimulatorRuntimeDirectApiCall)(intptr_t arg0); typedef void (*SimulatorRuntimeProfilingApiCall)(intptr_t arg0, void* arg1); // This signature supports direct call to accessor getter callback. typedef void (*SimulatorRuntimeDirectGetterCall)(intptr_t arg0, intptr_t arg1); typedef void (*SimulatorRuntimeProfilingGetterCall)(intptr_t arg0, intptr_t arg1, void* arg2); // Software interrupt instructions are used by the simulator to call into the // C-based V8 runtime. void Simulator::SoftwareInterrupt(Instruction* instr) { int svc = instr->SvcValue(); switch (svc) { case kCallRtRedirected: { // Check if stack is aligned. Error if not aligned is reported below to // include information on the function called. bool stack_aligned = (get_register(sp) & (::v8::internal::FLAG_sim_stack_alignment - 1)) == 0; Redirection* redirection = Redirection::FromSwiInstruction(instr); const int kArgCount = 6; int arg0_regnum = 2; intptr_t result_buffer = 0; bool uses_result_buffer = redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE || (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR && !ABI_RETURNS_OBJECTPAIR_IN_REGS); if (uses_result_buffer) { result_buffer = get_register(r2); arg0_regnum++; } intptr_t arg[kArgCount]; for (int i = 0; i < kArgCount - 1; i++) { arg[i] = get_register(arg0_regnum + i); } intptr_t* stack_pointer = reinterpret_cast(get_register(sp)); arg[5] = stack_pointer[kCalleeRegisterSaveAreaSize / kPointerSize]; bool fp_call = (redirection->type() == ExternalReference::BUILTIN_FP_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_COMPARE_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_CALL) || (redirection->type() == ExternalReference::BUILTIN_FP_INT_CALL); // Place the return address on the stack, making the call GC safe. *reinterpret_cast(get_register(sp) + kStackFrameRASlot * kPointerSize) = get_register(r14); intptr_t external = reinterpret_cast(redirection->external_function()); if (fp_call) { double dval0, dval1; // one or two double parameters intptr_t ival; // zero or one integer parameters int iresult = 0; // integer return value double dresult = 0; // double return value GetFpArgs(&dval0, &dval1, &ival); if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall generic_target = reinterpret_cast(external); switch (redirection->type()) { case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Call to host function at %p with args %f, %f", static_cast(FUNCTION_ADDR(generic_target)), dval0, dval1); break; case ExternalReference::BUILTIN_FP_CALL: PrintF("Call to host function at %p with arg %f", static_cast(FUNCTION_ADDR(generic_target)), dval0); break; case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Call to host function at %p with args %f, %" V8PRIdPTR, static_cast(FUNCTION_ADDR(generic_target)), dval0, ival); break; default: UNREACHABLE(); break; } if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: { SimulatorRuntimeCompareCall target = reinterpret_cast(external); iresult = target(dval0, dval1); set_register(r2, iresult); break; } case ExternalReference::BUILTIN_FP_FP_CALL: { SimulatorRuntimeFPFPCall target = reinterpret_cast(external); dresult = target(dval0, dval1); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_CALL: { SimulatorRuntimeFPCall target = reinterpret_cast(external); dresult = target(dval0); SetFpResult(dresult); break; } case ExternalReference::BUILTIN_FP_INT_CALL: { SimulatorRuntimeFPIntCall target = reinterpret_cast(external); dresult = target(dval0, ival); SetFpResult(dresult); break; } default: UNREACHABLE(); break; } if (::v8::internal::FLAG_trace_sim || !stack_aligned) { switch (redirection->type()) { case ExternalReference::BUILTIN_COMPARE_CALL: PrintF("Returned %08x\n", iresult); break; case ExternalReference::BUILTIN_FP_FP_CALL: case ExternalReference::BUILTIN_FP_CALL: case ExternalReference::BUILTIN_FP_INT_CALL: PrintF("Returned %f\n", dresult); break; default: UNREACHABLE(); break; } } } else if (redirection->type() == ExternalReference::DIRECT_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR, reinterpret_cast(external), arg[0]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectApiCall target = reinterpret_cast(external); target(arg[0]); } else if (redirection->type() == ExternalReference::PROFILING_API_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingApiCall target = reinterpret_cast(external); target(arg[0], Redirection::ReverseRedirection(arg[1])); } else if (redirection->type() == ExternalReference::DIRECT_GETTER_CALL) { // See callers of MacroAssembler::CallApiFunctionAndReturn for // explanation of register usage. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeDirectGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1]); } else if (redirection->type() == ExternalReference::PROFILING_GETTER_CALL) { if (::v8::internal::FLAG_trace_sim || !stack_aligned) { PrintF("Call to host function at %p args %08" V8PRIxPTR " %08" V8PRIxPTR " %08" V8PRIxPTR, reinterpret_cast(external), arg[0], arg[1], arg[2]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); SimulatorRuntimeProfilingGetterCall target = reinterpret_cast(external); if (!ABI_PASSES_HANDLES_IN_REGS) { arg[0] = *(reinterpret_cast(arg[0])); } target(arg[0], arg[1], Redirection::ReverseRedirection(arg[2])); } else { // builtin call. if (::v8::internal::FLAG_trace_sim || !stack_aligned) { SimulatorRuntimeCall target = reinterpret_cast(external); PrintF( "Call to host function at %p,\n" "\t\t\t\targs %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR, static_cast(FUNCTION_ADDR(target)), arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (!stack_aligned) { PrintF(" with unaligned stack %08" V8PRIxPTR "\n", static_cast(get_register(sp))); } PrintF("\n"); } CHECK(stack_aligned); if (redirection->type() == ExternalReference::BUILTIN_CALL_TRIPLE) { SimulatorRuntimeTripleCall target = reinterpret_cast(external); ObjectTriple result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", reinterpret_cast(result.x), reinterpret_cast(result.y), reinterpret_cast(result.z)); } memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectTriple)); set_register(r2, result_buffer); } else { if (redirection->type() == ExternalReference::BUILTIN_CALL_PAIR) { SimulatorRuntimePairCall target = reinterpret_cast(external); ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); intptr_t x; intptr_t y; decodeObjectPair(&result, &x, &y); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned {%08" V8PRIxPTR ", %08" V8PRIxPTR "}\n", x, y); } if (ABI_RETURNS_OBJECTPAIR_IN_REGS) { set_register(r2, x); set_register(r3, y); } else { memcpy(reinterpret_cast(result_buffer), &result, sizeof(ObjectPair)); set_register(r2, result_buffer); } } else { DCHECK(redirection->type() == ExternalReference::BUILTIN_CALL); SimulatorRuntimeCall target = reinterpret_cast(external); intptr_t result = target(arg[0], arg[1], arg[2], arg[3], arg[4], arg[5]); if (::v8::internal::FLAG_trace_sim) { PrintF("Returned %08" V8PRIxPTR "\n", result); } set_register(r2, result); } } // #if !V8_TARGET_ARCH_S390X // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL); // SimulatorRuntimeCall target = // reinterpret_cast(external); // int64_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // int32_t lo_res = static_cast(result); // int32_t hi_res = static_cast(result >> 32); // #if !V8_TARGET_LITTLE_ENDIAN // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", hi_res); // } // set_register(r2, hi_res); // set_register(r3, lo_res); // #else // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08x\n", lo_res); // } // set_register(r2, lo_res); // set_register(r3, hi_res); // #endif // #else // if (redirection->type() == ExternalReference::BUILTIN_CALL) { // SimulatorRuntimeCall target = // reinterpret_cast(external); // intptr_t result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], // arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR "\n", result); // } // set_register(r2, result); // } else { // DCHECK(redirection->type() == // ExternalReference::BUILTIN_CALL_PAIR); // SimulatorRuntimePairCall target = // reinterpret_cast(external); // ObjectPair result = target(arg[0], arg[1], arg[2], arg[3], // arg[4], arg[5]); // if (::v8::internal::FLAG_trace_sim) { // PrintF("Returned %08" V8PRIxPTR ", %08" V8PRIxPTR "\n", // result.x, result.y); // } // #if ABI_RETURNS_OBJECTPAIR_IN_REGS // set_register(r2, result.x); // set_register(r3, result.y); // #else // memcpy(reinterpret_cast(result_buffer), &result, // sizeof(ObjectPair)); // #endif // } // #endif } int64_t saved_lr = *reinterpret_cast( get_register(sp) + kStackFrameRASlot * kPointerSize); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On zLinux-31, the saved_lr might be tagged with a high bit of 1. // Cleanse it before proceeding with simulation. saved_lr &= 0x7FFFFFFF; #endif set_pc(saved_lr); break; } case kBreakpoint: { S390Debugger dbg(this); dbg.Debug(); break; } // stop uses all codes greater than 1 << 23. default: { if (svc >= (1 << 23)) { uint32_t code = svc & kStopCodeMask; if (isWatchedStop(code)) { IncreaseStopCounter(code); } // Stop if it is enabled, otherwise go on jumping over the stop // and the message address. if (isEnabledStop(code)) { S390Debugger dbg(this); dbg.Stop(instr); } else { set_pc(get_pc() + sizeof(FourByteInstr) + kPointerSize); } } else { // This is not a valid svc code. UNREACHABLE(); break; } } } } // Stop helper functions. bool Simulator::isStopInstruction(Instruction* instr) { return (instr->Bits(27, 24) == 0xF) && (instr->SvcValue() >= kStopCode); } bool Simulator::isWatchedStop(uint32_t code) { DCHECK(code <= kMaxStopCode); return code < kNumOfWatchedStops; } bool Simulator::isEnabledStop(uint32_t code) { DCHECK(code <= kMaxStopCode); // Unwatched stops are always enabled. return !isWatchedStop(code) || !(watched_stops_[code].count & kStopDisabledBit); } void Simulator::EnableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (!isEnabledStop(code)) { watched_stops_[code].count &= ~kStopDisabledBit; } } void Simulator::DisableStop(uint32_t code) { DCHECK(isWatchedStop(code)); if (isEnabledStop(code)) { watched_stops_[code].count |= kStopDisabledBit; } } void Simulator::IncreaseStopCounter(uint32_t code) { DCHECK(code <= kMaxStopCode); DCHECK(isWatchedStop(code)); if ((watched_stops_[code].count & ~(1 << 31)) == 0x7fffffff) { PrintF( "Stop counter for code %i has overflowed.\n" "Enabling this code and reseting the counter to 0.\n", code); watched_stops_[code].count = 0; EnableStop(code); } else { watched_stops_[code].count++; } } // Print a stop status. void Simulator::PrintStopInfo(uint32_t code) { DCHECK(code <= kMaxStopCode); if (!isWatchedStop(code)) { PrintF("Stop not watched."); } else { const char* state = isEnabledStop(code) ? "Enabled" : "Disabled"; int32_t count = watched_stops_[code].count & ~kStopDisabledBit; // Don't print the state of unused breakpoints. if (count != 0) { if (watched_stops_[code].desc) { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i, \t%s\n", code, code, state, count, watched_stops_[code].desc); } else { PrintF("stop %i - 0x%x: \t%s, \tcounter = %i\n", code, code, state, count); } } } } // Method for checking overflow on signed addition: // Test src1 and src2 have opposite sign, // (1) No overflow if they have opposite sign // (2) Test the result and one of the operands have opposite sign // (a) No overflow if they don't have opposite sign // (b) Overflow if opposite #define CheckOverflowForIntAdd(src1, src2, type) \ OverflowFromSigned(src1 + src2, src1, src2, true); #define CheckOverflowForIntSub(src1, src2, type) \ OverflowFromSigned(src1 - src2, src1, src2, false); // Method for checking overflow on unsigned addtion #define CheckOverflowForUIntAdd(src1, src2) \ ((src1) + (src2) < (src1) || (src1) + (src2) < (src2)) // Method for checking overflow on unsigned subtraction #define CheckOverflowForUIntSub(src1, src2) ((src1) - (src2) > (src1)) // Method for checking overflow on multiplication #define CheckOverflowForMul(src1, src2) (((src1) * (src2)) / (src2) != (src1)) // Method for checking overflow on shift right #define CheckOverflowForShiftRight(src1, src2) \ (((src1) >> (src2)) << (src2) != (src1)) // Method for checking overflow on shift left #define CheckOverflowForShiftLeft(src1, src2) \ (((src1) << (src2)) >> (src2) != (src1)) // S390 Decode and simulate helpers bool Simulator::DecodeTwoByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); switch (op) { // RR format instructions case AR: case SR: case MR: case DR: case OR: case NR: case XR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); bool isOF = false; switch (op) { case AR: isOF = CheckOverflowForIntAdd(r1_val, r2_val, int32_t); r1_val += r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case SR: isOF = CheckOverflowForIntSub(r1_val, r2_val, int32_t); r1_val -= r2_val; SetS390ConditionCode(r1_val, 0); SetS390OverflowCode(isOF); break; case OR: r1_val |= r2_val; SetS390BitWiseConditionCode(r1_val); break; case NR: r1_val &= r2_val; SetS390BitWiseConditionCode(r1_val); break; case XR: r1_val ^= r2_val; SetS390BitWiseConditionCode(r1_val); break; case MR: { DCHECK(r1 % 2 == 0); r1_val = get_low_register(r1 + 1); int64_t product = static_cast(r1_val) * static_cast(r2_val); int32_t high_bits = product >> 32; r1_val = high_bits; int32_t low_bits = product & 0x00000000FFFFFFFF; set_low_register(r1, high_bits); set_low_register(r1 + 1, low_bits); break; } case DR: { // reg-reg pair should be even-odd pair, assert r1 is an even register DCHECK(r1 % 2 == 0); // leftmost 32 bits of the dividend are in r1 // rightmost 32 bits of the dividend are in r1+1 // get the signed value from r1 int64_t dividend = static_cast(r1_val) << 32; // get unsigned value from r1+1 // avoid addition with sign-extended r1+1 value dividend += get_low_register(r1 + 1); int32_t remainder = dividend % r2_val; int32_t quotient = dividend / r2_val; r1_val = remainder; set_low_register(r1, remainder); set_low_register(r1 + 1, quotient); break; // reg pair } default: UNREACHABLE(); break; } set_low_register(r1, r1_val); break; } case LR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); set_low_register(r1, get_low_register(r2)); break; } case LDR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int64_t r2_val = get_d_register(r2); set_d_register(r1, r2_val); break; } case CR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r1_val = get_low_register(r1); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case CLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); SetS390ConditionCode(r1_val, r2_val); break; } case BCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); if (TestConditionCode(Condition(r1))) { intptr_t r2_val = get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, but is ignored by the // hardware. Cleanse the top bit before jumping to it, unless it's one // of the special PCs if (r2_val != bad_lr && r2_val != end_sim_pc) r2_val &= 0x7FFFFFFF; #endif set_pc(r2_val); } break; } case LTR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); SetS390ConditionCode(r2_val, 0); set_low_register(r1, r2_val); break; } case ALR: case SLR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); uint32_t r1_val = get_low_register(r1); uint32_t r2_val = get_low_register(r2); uint32_t alu_out = 0; bool isOF = false; if (ALR == op) { alu_out = r1_val + r2_val; isOF = CheckOverflowForUIntAdd(r1_val, r2_val); } else if (SLR == op) { alu_out = r1_val - r2_val; isOF = CheckOverflowForUIntSub(r1_val, r2_val); } else { UNREACHABLE(); } set_low_register(r1, alu_out); SetS390ConditionCodeCarry(alu_out, isOF); break; } case LNR: { // Load Negative (32) RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); r2_val = (r2_val >= 0) ? -r2_val : r2_val; // If pos, then negate it. set_low_register(r1, r2_val); condition_reg_ = (r2_val == 0) ? CC_EQ : CC_LT; // CC0 - result is zero // CC1 - result is negative break; } case BASR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); intptr_t link_addr = get_pc() + 2; // If R2 is zero, the BASR does not branch. int64_t r2_val = (r2 == 0) ? link_addr : get_register(r2); #if (!V8_TARGET_ARCH_S390X && V8_HOST_ARCH_S390) // On 31-bit, the top most bit may be 0 or 1, which can cause issues // for stackwalker. The top bit should either be cleanse before being // pushed onto the stack, or during stack walking when dereferenced. // For simulator, we'll take the worst case scenario and always tag // the high bit, to flush out more problems. link_addr |= 0x80000000; #endif set_register(r1, link_addr); set_pc(r2_val); break; } case LCR: { RRInstruction* rrinst = reinterpret_cast(instr); int r1 = rrinst->R1Value(); int r2 = rrinst->R2Value(); int32_t r2_val = get_low_register(r2); int32_t original_r2_val = r2_val; r2_val = ~r2_val; r2_val = r2_val + 1; set_low_register(r1, r2_val); SetS390ConditionCode(r2_val, 0); // Checks for overflow where r2_val = -2147483648. // Cannot do int comparison due to GCC 4.8 bug on x86. // Detect INT_MIN alternatively, as it is the only value where both // original and result are negative due to overflow. if (r2_val < 0 && original_r2_val < 0) { SetS390OverflowCode(true); } break; } case BKPT: { set_pc(get_pc() + 2); S390Debugger dbg(this); dbg.Debug(); break; } default: UNREACHABLE(); return false; break; } return true; } // Decode routine for four-byte instructions bool Simulator::DecodeFourByte(Instruction* instr) { Opcode op = instr->S390OpcodeValue(); // Pre-cast instruction to various types RREInstruction* rreInst = reinterpret_cast(instr); SIInstruction* siInstr = reinterpret_cast(instr); switch (op) { case POPCNT_Z: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); int64_t r1_val = 0; uint8_t* r2_val_ptr = reinterpret_cast(&r2_val); uint8_t* r1_val_ptr = reinterpret_cast(&r1_val); for (int i = 0; i < 8; i++) { uint32_t x = static_cast(r2_val_ptr[i]); #if defined(__GNUC__) r1_val_ptr[i] = __builtin_popcount(x); #else #error unsupport __builtin_popcount #endif } set_register(r1, static_cast(r1_val)); break; } case LLGFR: { int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int32_t r2_val = get_low_register(r2); uint64_t r2_finalval = (static_cast(r2_val) & 0x00000000ffffffff); set_register(r1, r2_finalval); break; } case EX: { RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int b2 = rxinst->B2Value(); int x2 = rxinst->X2Value(); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); intptr_t d2_val = rxinst->D2Value(); int32_t r1_val = get_low_register(r1); SixByteInstr the_instr = Instruction::InstructionBits( reinterpret_cast(b2_val + x2_val + d2_val)); int length = Instruction::InstructionLength( reinterpret_cast(b2_val + x2_val + d2_val)); char new_instr_buf[8]; char* addr = reinterpret_cast(&new_instr_buf[0]); the_instr |= static_cast(r1_val & 0xff) << (8 * length - 16); Instruction::SetInstructionBits( reinterpret_cast(addr), static_cast(the_instr)); ExecuteInstruction(reinterpret_cast(addr), false); break; } case LGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); set_register(r1, get_register(r2)); break; } case LDGR: { // Load FPR from GPR (L <- 64) uint64_t int_val = get_register(rreInst->R2Value()); // double double_val = bit_cast(int_val); // set_d_register_from_double(rreInst->R1Value(), double_val); set_d_register(rreInst->R1Value(), int_val); break; } case LGDR: { // Load GPR from FPR (64 <- L) int64_t double_val = get_d_register(rreInst->R2Value()); set_register(rreInst->R1Value(), double_val); break; } case LTGR: { // Load Register (64) int r1 = rreInst->R1Value(); int r2 = rreInst->R2Value(); int64_t r2_val = get_register(r2); SetS390ConditionCode(r2_val, 0); set_register(r1, get_register(r2)); break; } case LZDR: { int r1 = rreInst->R1Value(); set_d_register_from_double(r1, 0.0); break; } case LTEBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); float fr2_val = get_float32_from_d_register(r2); SetS390ConditionCode(fr2_val, 0.0); set_d_register(r1, r2_val); break; } case LTDBR: { RREInstruction* rreinst = reinterpret_cast(instr); int r1 = rreinst->R1Value(); int r2 = rreinst->R2Value(); int64_t r2_val = get_d_register(r2); SetS390ConditionCode(bit_cast(r2_val), 0.0); set_d_register(r1, r2_val); break; } case CGR: { // Compare (64) int64_t r1_val = get_register(rreInst->R1Value()); int64_t r2_val = get_register(rreInst->R2Value()); SetS390ConditionCode(r1_val, r2_val); break; } case CLGR: { // Compare Logical (64) uint64_t r1_val = static_cast(get_register(rreInst->R1Value())); uint64_t r2_val = static_cast(get_register(rreInst->R2Value())); SetS390ConditionCode(r1_val, r2_val); break; } case LH: { // Load Halfword RXInstruction* rxinst = reinterpret_cast(instr); int r1 = rxinst->R1Value(); int x2 = rxinst->X2Value(); int b2 = rxinst->B2Value(); int64_t x2_val = (x2 == 0) ? 0 : get_register(x2); int64_t b2_val = (b2 == 0) ? 0 : get_register(b2); intptr_t d2_val = rxinst->D2Value(); intptr_t mem_addr = x2_val + b2_val + d2_val; int32_t result = static_cast(ReadH(mem_addr, instr)); set_low_register(r1, result); break; } case LHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int i = riinst->I2Value(); set_low_register(r1, i); break; } case LGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = riinst->I2Value(); set_register(r1, i); break; } case CHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int16_t i = riinst->I2Value(); int32_t r1_val = get_low_register(r1); SetS390ConditionCode(r1_val, i); break; } case CGHI: { RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t i = static_cast(riinst->I2Value()); int64_t r1_val = get_register(r1); SetS390ConditionCode(r1_val, i); break; } case BRAS: { // Branch Relative and Save RILInstruction* rilInstr = reinterpret_cast(instr); int r1 = rilInstr->R1Value(); intptr_t d2 = rilInstr->I2Value(); intptr_t pc = get_pc(); // Set PC of next instruction to register set_register(r1, pc + sizeof(FourByteInstr)); // Update PC to branch target set_pc(pc + d2 * 2); break; } case BRC: { // Branch Relative on Condition RIInstruction* riinst = reinterpret_cast(instr); int m1 = riinst->M1Value(); if (TestConditionCode((Condition)m1)) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BRCT: case BRCTG: { // Branch On Count (32/64). RIInstruction* riinst = reinterpret_cast(instr); int r1 = riinst->R1Value(); int64_t value = (op == BRCT) ? get_low_register(r1) : get_register(r1); if (BRCT == op) set_low_register(r1, --value); else set_register(r1, --value); // Branch if value != 0 if (value != 0) { intptr_t offset = riinst->I2Value() * 2; set_pc(get_pc() + offset); } break; } case BXH: { RSInstruction* rsinst = reinterpret_cast(instr); int r1 = rsinst->R1Value(); int r3 = rsinst->R3Value(); int b2 = rsinst->B2Value(); int d2 = rsinst->D2Value(); // r1_val is the first operand, r3_val is the increment int32_t r1_val = r1 == 0 ? 0 : get_register(r1); int32_t r3_val = r2 == 0 ? 0 : get_register(r3); intptr_t b2_val = b2 == 0 ? 0 : get_register(b2); intptr_t branch_address = b2_val + d2; // increment r1_val r1_val += r3_val; // if the increment is even, then it designates a pair of registers // and the contents of the even and odd registers of the pair are used as // the increment and compare value respectively. If the increment is odd, // the increment itself is used as both the increment and compare value int32_t compare_val = r3 % 2 == 0 ? get_register(r3 + 1) : r3_val; if (r1_val > compare_val) { // branch to address if r1_val is greater than compare value set_pc(branch_address); } // update contents of register in r1 with the new incremented value set_register(r1, r1_val); break; } case IIHH: case IIHL: case IILH: case IILL: { UNIMPLEMENTED(); break; } case STM: case LM: { // Store Multiple 32-bits. RSInstruction* rsinstr = reinterpret_cast(instr); int r1 = rsinstr->R1Value(); int r3 = rsinstr->R3Value(); int rb = rsinstr->B2Value(); int offset = rsinstr->D2Value(); // Regs roll around if r3 is less than r1. // Artifically increase r3 by 16 so we can calculate // the number of regs stored properly. if (r3 < r1) r3 += 16; int32_t rb_val = (rb == 0) ? 0 : get_low_register(rb); // Store each register in ascending order. for (int i = 0; i <= r3 - r1; i++) { if (op == STM) { int32_t value = get_low_register((r1 + i) % 16); WriteW(rb_val + offset + 4 * i, value, instr); } else if (op == LM) { int32_t value = ReadW(rb_val + offset + 4 * i, instr); set_low_register((r1 + i) % 16, value); } } break; } case SLL: case SRL: { RSInstruction* rsInstr = reinterpret_cast(instr); int r1 = rsInstr->R1Value(); int b2 = rsInstr->B2Value(); intptr_t d2 = rsInstr->D2Value(); // only takes rightmost 6bits int64_t b2_val = b2 == 0 ? 0 : get_register(b2); int shiftBits = (b2_val + d2) & 0x3F; uint32_t r1_val = get_low_register