void SwitchIRBuilder::SetProfiledInstruction(IR::Instr * instr, Js::ProfileId profileId) { m_profiledSwitchInstr = instr; m_switchOptBuildBail = true; //don't optimize if the switch expression is not an Integer (obtained via dynamic profiling data of the BeginSwitch opcode) bool hasProfile = m_profiledSwitchInstr->IsProfiledInstr() && m_profiledSwitchInstr->m_func->HasProfileInfo(); if (hasProfile) { const ValueType valueType(m_profiledSwitchInstr->m_func->GetReadOnlyProfileInfo()->GetSwitchProfileInfo(profileId)); instr->AsProfiledInstr()->u.FldInfo().valueType = valueType; m_switchIntDynProfile = valueType.IsLikelyTaggedInt(); m_switchStrDynProfile = valueType.IsLikelyString(); if (PHASE_TESTTRACE1(Js::SwitchOptPhase)) { char valueTypeStr[VALUE_TYPE_MAX_STRING_SIZE]; valueType.ToString(valueTypeStr); #if ENABLE_DEBUG_CONFIG_OPTIONS char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE]; #endif PHASE_PRINT_TESTTRACE1(Js::SwitchOptPhase, _u("Func %s, Switch %d: Expression Type : %S\n"), m_profiledSwitchInstr->m_func->GetDebugNumberSet(debugStringBuffer), m_profiledSwitchInstr->AsProfiledInstr()->u.profileId, valueTypeStr); } } }
void CodeGenWorkItem::OnWorkItemProcessFail(NativeCodeGenerator* codeGen) { if (!isAllocationCommitted && this->allocation != nullptr && this->allocation->allocation != nullptr) { #if DBG this->allocation->allocation->isNotExecutableBecauseOOM = true; #endif #if PDATA_ENABLED & defined(_WIN32) if (this->entryPointInfo) { XDataAllocation * xdataAllocation = this->entryPointInfo->GetNativeEntryPointData()->GetXDataInfo(); if (xdataAllocation) { void* functionTable = xdataAllocation->functionTable; if (functionTable) { if (!DelayDeletingFunctionTable::AddEntry(functionTable)) { PHASE_PRINT_TESTTRACE1(Js::XDataPhase, _u("OnWorkItemProcessFail: Failed to add to slist, table: %llx\n"), functionTable); DelayDeletingFunctionTable::DeleteFunctionTable(functionTable); } } } } #endif codeGen->FreeNativeCodeGenAllocation(this->allocation->allocation->address); } }
void SwitchIRBuilder::BuildBailOnNotString() { if (!m_switchOptBuildBail) { return; } m_adapter->ConvertToBailOut(m_profiledSwitchInstr, IR::BailOutExpectingString); m_switchOptBuildBail = false; // falsify this to avoid generating extra BailOuts when optimization is done again on the same switch statement #if ENABLE_DEBUG_CONFIG_OPTIONS char16 debugStringBuffer[MAX_FUNCTION_BODY_DEBUG_STRING_SIZE]; #endif PHASE_PRINT_TESTTRACE1(Js::SwitchOptPhase, _u("Func %s, Switch %d:Optimized for Strings\n"), m_profiledSwitchInstr->m_func->GetDebugNumberSet(debugStringBuffer), m_profiledSwitchInstr->AsProfiledInstr()->u.profileId); }