static __inline void __declspec(noreturn) run_runtime(char * runtime, char * const cmdline) { char path[MAX_PATH]; STARTUPINFO stinfo; PROCESS_INFORMATION procinfo; DWORD retcode; if (SearchPath(NULL, runtime, ".exe", MAX_PATH, path, &runtime) == 0) { HANDLE errh; DWORD numwritten; errh = GetStdHandle(STD_ERROR_HANDLE); WriteFile(errh, msg_and_length("Cannot exec "), &numwritten, NULL); WriteFile(errh, runtime, strlen(runtime), &numwritten, NULL); WriteFile(errh, msg_and_length("\r\n"), &numwritten, NULL); ExitProcess(2); #if _MSC_VER >= 1200 __assume(0); /* Not reached */ #endif } /* Need to ignore ctrl-C and ctrl-break, otherwise we'll die and take the underlying OCaml program with us! */ SetConsoleCtrlHandler(ctrl_handler, TRUE); stinfo.cb = sizeof(stinfo); stinfo.lpReserved = NULL; stinfo.lpDesktop = NULL; stinfo.lpTitle = NULL; stinfo.dwFlags = 0; stinfo.cbReserved2 = 0; stinfo.lpReserved2 = NULL; if (!CreateProcess(path, cmdline, NULL, NULL, TRUE, 0, NULL, NULL, &stinfo, &procinfo)) { HANDLE errh; DWORD numwritten; errh = GetStdHandle(STD_ERROR_HANDLE); WriteFile(errh, msg_and_length("Cannot exec "), &numwritten, NULL); WriteFile(errh, runtime, strlen(runtime), &numwritten, NULL); WriteFile(errh, msg_and_length("\r\n"), &numwritten, NULL); ExitProcess(2); #if _MSC_VER >= 1200 __assume(0); /* Not reached */ #endif } CloseHandle(procinfo.hThread); WaitForSingleObject(procinfo.hProcess , INFINITE); GetExitCodeProcess(procinfo.hProcess , &retcode); CloseHandle(procinfo.hProcess); ExitProcess(retcode); #if _MSC_VER >= 1200 __assume(0); /* Not reached */ #endif }
int object_restore_pure_size(int *object_descriptor, BYTESTREAMRESTOREPROC bsrp) { assert(bsrp != NULL); int total = 0; if (object_descriptor == NULL) return 0; while (object_descriptor[0] != FE_EOO) { switch (object_descriptor[0]) { case FE_BASIC: _restore_binary(NULL, object_descriptor[1], bsrp); total += object_descriptor[1]; break; case FE_ASZ: while (bsrp()) total++; total++; // '\0' always occupy space break; case FE_WSZ: while (_restore_word(bsrp)) { total += 2; } total += 2; break; case FE_TRACE: total += object_restore_pure_size((int *)(object_descriptor[1]), bsrp); break; default: assert(false); __assume(0); } } return total; }
JavascriptError* JavascriptError::MapError(ScriptContext* scriptContext, ErrorTypeEnum errorType, IErrorInfo * perrinfo /*= nullptr*/, RestrictedErrorStrings * proerrstr /*= nullptr*/) { switch (errorType) { case kjstError: return CreateError(scriptContext, perrinfo, proerrstr); case kjstTypeError: return CreateTypeError(scriptContext, perrinfo, proerrstr); case kjstRangeError: return CreateRangeError(scriptContext, perrinfo, proerrstr); case kjstSyntaxError: return CreateSyntaxError(scriptContext, perrinfo, proerrstr); case kjstReferenceError: return CreateReferenceError(scriptContext, perrinfo, proerrstr); case kjstURIError: return CreateURIError(scriptContext, perrinfo, proerrstr); #ifdef ENABLE_PROJECTION case kjstWinRTError: if (scriptContext->GetConfig()->IsWinRTEnabled()) { return scriptContext->GetHostScriptContext()->CreateWinRTError(perrinfo, proerrstr); } else { return CreateError(scriptContext, perrinfo, proerrstr); } break; #endif default: AssertMsg(FALSE, "Invalid error type"); __assume(false); }; }
void GSRendererDX9::Draw(GSTexture* rt, GSTexture* ds, GSTextureCache::Source* tex) { switch(m_vt.m_primclass) { case GS_POINT_CLASS: m_topology = D3DPT_POINTLIST; m_perfmon.Put(GSPerfMon::Prim, m_count); break; case GS_LINE_CLASS: m_topology = D3DPT_LINELIST; m_perfmon.Put(GSPerfMon::Prim, m_count / 2); break; case GS_TRIANGLE_CLASS: case GS_SPRITE_CLASS: m_topology = D3DPT_TRIANGLELIST; m_perfmon.Put(GSPerfMon::Prim, m_count / 3); break; default: __assume(0); } (*(GSDevice9*)m_dev)->SetRenderState(D3DRS_SHADEMODE, PRIM->IIP ? D3DSHADE_GOURAUD : D3DSHADE_FLAT); // TODO __super::Draw(rt, ds, tex); }
// AllocFileLine //------------------------------------------------------------------------------ void * AllocFileLine( size_t size, size_t alignment, const char * file, int line ) { void * mem( nullptr ); #if defined( SMALL_BLOCK_ALLOCATOR_ENABLED ) mem = SmallBlockAllocator::Alloc( size, alignment ); if ( mem == nullptr ) #endif { #if defined( __LINUX__ ) || defined( __APPLE__ ) VERIFY( posix_memalign( &mem, alignment, size ) == 0 ); #else mem = _aligned_malloc( size, alignment ); __assume( mem ); #endif #ifdef MEM_FILL_NEW_ALLOCATIONS MemDebug::FillMem( mem, size, MemDebug::MEM_FILL_NEW_ALLOCATION_PATTERN ); #endif } MEMTRACKER_ALLOC( mem, size, file, line ); (void)file; (void)line; // TODO: strip args in release return mem; }
void Echo::Update(int index, int sign, DWORD modifiers) { switch (index) { case TITLE: fx_active[BASS_FX_DX8_ECHO] = sign > 0; EnableEffect(BASS_FX_DX8_ECHO, fx_active[BASS_FX_DX8_ECHO]); break; case WET_DRY_MIX: UpdateProperty(fx_echo.fWetDryMix, sign, modifiers, 10, time_step, 0, 100); break; case FEEDBACK: UpdateProperty(fx_echo.fFeedback, sign, modifiers, 10, time_step, 0, 100); break; case LEFT_DELAY: UpdateProperty(fx_echo.fLeftDelay, sign, modifiers, 10, time_step, 1, 2000); break; case RIGHT_DELAY: UpdateProperty(fx_echo.fRightDelay, sign, modifiers, 10, time_step, 1, 2000); break; case PAN_DELAY: fx_echo.lPanDelay = !fx_echo.lPanDelay; break; default: __assume(0); } UpdateEffect(BASS_FX_DX8_ECHO); }
void AsmJsEncoder::ReadOpTemplate<Js::SmallLayout>( OpCodeAsmJs op ) { switch( op ) { #define DEF2(x, op, func) PROCESS_ENCODE_##x(op, func) #define DEF3(x, op, func, y) PROCESS_ENCODE_##x(op, func, y) #define DEF2_WMS(x, op, func) PROCESS_ENCODE_##x##_COMMON(op, func, _Small) #define DEF3_WMS(x, op, func, y) PROCESS_ENCODE_##x##_COMMON(op, func, y, _Small) #define DEF4_WMS(x, op, func, y, t) PROCESS_ENCODE_##x##_COMMON(op, func, y, _Small, t) #define EXDEF2(x, op, func) PROCESS_ENCODE_##x(op, func) #define EXDEF3(x, op, func, y) PROCESS_ENCODE_##x(op, func, y) #define EXDEF2_WMS(x, op, func) PROCESS_ENCODE_##x##_COMMON(op, func, _Small) #define EXDEF3_WMS(x, op, func, y) PROCESS_ENCODE_##x##_COMMON(op, func, y, _Small) #define EXDEF4_WMS(x, op, func, y, t) PROCESS_ENCODE_##x##_COMMON(op, func, y, _Small, t) #include "AsmJsEncoderHandler.inl" default: // Help the C++ optimizer by declaring that the cases we // have above are sufficient #if DBG_DUMP Output::Print( _u("Dispatch to bad opcode : %s\n"), OpCodeUtilAsmJs::GetOpCodeName(op)); Output::Flush(); #endif Assert( false ); __assume( false ); }; }
PtrType get() const { #ifdef _MSC_VER __assume(pointer != NULL); #endif return pointer; }
bool operator()(const CChannelInfo *pChannel1,const CChannelInfo *pChannel2) { int Cmp; switch (m_Type) { case SORT_SPACE: Cmp=pChannel1->GetSpace()-pChannel2->GetSpace(); break; case SORT_CHANNELINDEX: Cmp=pChannel1->GetChannelIndex()-pChannel2->GetChannelIndex(); break; case SORT_CHANNELNO: Cmp=pChannel1->GetChannelNo()-pChannel2->GetChannelNo(); break; case SORT_PHYSICALCHANNEL: Cmp=pChannel1->GetPhysicalChannel()-pChannel2->GetPhysicalChannel(); break; case SORT_NAME: Cmp=::lstrcmpi(pChannel1->GetName(),pChannel2->GetName()); if (Cmp==0) Cmp=::lstrcmp(pChannel1->GetName(),pChannel2->GetName()); break; case SORT_NETWORKID: Cmp=pChannel1->GetNetworkID()-pChannel2->GetNetworkID(); break; case SORT_SERVICEID: Cmp=pChannel1->GetServiceID()-pChannel2->GetServiceID(); break; default: __assume(0); } return m_fDescending?Cmp>0:Cmp<0; }
void EventOut::putEvent( FLOAT value, UINT16 voice ) { for( UINT16 target=0; target<numTargets_; target++) { FLOAT modulation = modulation_[ target*numVoices_ + voice ]; EventTarget* data = &operator[]( target ); Module* targetModule = data->target_; ASSERT( targetModule ); __assume( adapter_[ target ] < 3 ); switch( adapter_[ target ] ) { case NO_ADAPTER: targetModule->setParameter( data->inputId_, value, modulation, voice ); break; case MONO_TO_POLY: for( UINT16 i=0; i<numVoices_; i++ ) { targetModule->setParameter( data->inputId_, value, modulation, i ); } break; case POLY_TO_MONO: targetModule->setParameter( data->inputId_, value, modulation, 0 ); break; } } }
void SineOscil::setParameter( UINT16 paramId, FLOAT value, FLOAT modulation, INT16 voice ) { voice = min( numVoices_-1, voice ); __assume( paramId < 4 ); switch( paramId ) { case PARAM_FREQUENCY: if( voice >= 0 ) { FLOAT freq; if( modulation < 0 ) { double pitch = Utils::freq2pitch( value ); pitch = ( pitch - 60 ) * modulation + 60; freq = (FLOAT)Utils::pitch2freq( pitch ); } else { freq = ( value - 261.62557f ) * modulation + 261.62557f; } freq_[ voice ] = freq; setIncrement( voice ); } break; case PARAM_AMPLITUDE: if( voice >= 0 ) amplitude_[ voice ] = value * modulation; break; case PARAM_TUNING: setTuning( value ); break; case PARAM_FINETUNING: setFineTuning( value ); break; } }
void GSRasterizer::DrawTriangle(const GSVertexSW* vertices, const GSVector4i& scissor) { GSVertexSW v[3]; GSVector4 aabb = vertices[0].p.yyyy(vertices[1].p); GSVector4 bccb = vertices[1].p.yyyy(vertices[2].p).xzzx(); int i = (aabb > bccb).mask() & 7; v[0] = vertices[s_abc[i][0]]; v[1] = vertices[s_abc[i][1]]; v[2] = vertices[s_abc[i][2]]; aabb = v[0].p.yyyy(v[1].p); bccb = v[1].p.yyyy(v[2].p).xzzx(); i = (aabb == bccb).mask() & 7; switch(i) { case 0: // a < b < c DrawTriangleTopBottom(v, scissor); break; case 1: // a == b < c DrawTriangleBottom(v, scissor); break; case 4: // a < b == c DrawTriangleTop(v, scissor); break; case 7: // a == b == c break; default: __assume(0); } }
void Chorus::Update(int index, int sign, DWORD modifiers) { switch (index) { case TITLE: fx_active[BASS_FX_DX8_CHORUS] = sign > 0; EnableEffect(BASS_FX_DX8_CHORUS, fx_active[BASS_FX_DX8_CHORUS]); break; case WET_DRY_MIX: UpdateProperty(fx_chorus.fWetDryMix, sign, modifiers, 10, time_step, 0, 100); break; case DEPTH: UpdateProperty(fx_chorus.fDepth, sign, modifiers, 10, time_step, 0, 100); break; case FEEDBACK: UpdateProperty(fx_chorus.fFeedback, sign, modifiers, 10, time_step, -99, 99); break; case FREQUENCY: UpdateProperty(fx_chorus.fFrequency, sign, modifiers, 100, time_step, 0, 10); break; case WAVEFORM: fx_chorus.lWaveform = !fx_chorus.lWaveform; break; case DELAY: UpdateProperty(fx_chorus.fDelay, sign, modifiers, 100, time_step, 0, 20); break; case PHASE: fx_chorus.lPhase = (fx_chorus.lPhase + 5 + sign) % 5; break; default: __assume(0); } UpdateEffect(BASS_FX_DX8_CHORUS); }
void Chorus::Print(int index, HANDLE hOut, COORD pos, DWORD flags) { switch (index) { case TITLE: PrintTitle(hOut, fx_active[BASS_FX_DX8_CHORUS], flags, " ON", "OFF"); break; case WET_DRY_MIX: PrintItemFloat(hOut, pos, flags, "Wet/Dry: % 6.1f%%", fx_chorus.fWetDryMix); break; case DEPTH: PrintItemFloat(hOut, pos, flags, "Depth: % 6.1f%%", fx_chorus.fDepth); break; case FEEDBACK: PrintItemFloat(hOut, pos, flags, "Feedback: % 6.1f%%", fx_chorus.fFeedback); break; case FREQUENCY: PrintItemFloat(hOut, pos, flags, "Freq: %5.2fHz", fx_chorus.fFrequency); break; case WAVEFORM: PrintItemString(hOut, pos, flags, "Waveform: %8s", waveform[fx_chorus.lWaveform]); break; case DELAY: PrintItemFloat(hOut, pos, flags, "Delay: %6.2fms", fx_chorus.fDelay); break; case PHASE: PrintItemString(hOut, pos, flags, "L/R Phase: %7s", phase[fx_chorus.lPhase]); break; default: __assume(0); } }
void Echo::Print(int index, HANDLE hOut, COORD pos, DWORD flags) { switch (index) { case TITLE: PrintTitle(hOut, fx_active[BASS_FX_DX8_ECHO], flags, " ON", "OFF"); break; case WET_DRY_MIX: PrintItemFloat(hOut, pos, flags, "Wet/Dry: % 6.1f%%", fx_echo.fWetDryMix); break; case FEEDBACK: PrintItemFloat(hOut, pos, flags, "Feedback: % 6.1f%%", fx_echo.fFeedback); break; case LEFT_DELAY: PrintItemFloat(hOut, pos, flags, "L Delay: %7.2fms", fx_echo.fLeftDelay); break; case RIGHT_DELAY: PrintItemFloat(hOut, pos, flags, "R Delay: %7.2fms", fx_echo.fRightDelay); break; case PAN_DELAY: PrintItemBool(hOut, pos, flags, "Pan Delay: ", fx_echo.lPanDelay != 0); break; default: __assume(0); } }
void NczPlayerManager::ClientActive ( SourceSdk::edict_t* pEntity ) { const int index ( Helpers::IndexOfEdict ( pEntity ) ); LoggerAssert ( index ); PlayerHandler& ph ( FullHandlersList[ index ] ); if( ph.status == SlotStatus::INVALID ) // Bots don't call ClientConnect { ph.playerClass = new NczPlayer ( index ); __assume ( ph.playerClass != nullptr ); ph.playerClass->m_playerinfo = ( SourceSdk::IPlayerInfo * )SourceSdk::InterfacesProxy::Call_GetPlayerInfo ( ph.playerClass->m_edict ); LoggerAssert ( ph.playerClass->m_playerinfo ); #undef GetClassName if( strcmp ( pEntity->GetClassName (), "player" ) == 0 ) ph.status = SlotStatus::TV; else ph.status = SlotStatus::BOT; } else { LoggerAssert ( ph.status == SlotStatus::PLAYER_CONNECTING ); ph.status = SlotStatus::PLAYER_CONNECTED; ph.playerClass->m_playerinfo = ( SourceSdk::IPlayerInfo * )SourceSdk::InterfacesProxy::Call_GetPlayerInfo ( ph.playerClass->m_edict ); LoggerAssert ( ph.playerClass->m_playerinfo ); } if( index > m_max_index ) m_max_index = index; PlayerHandler::first = ( &FullHandlersList[ 1 ] ); PlayerHandler::last = ( &FullHandlersList[ m_max_index ] ); BaseSystem::ManageSystems (); }
T VerifyNot(T actual, U error) { if (actual != error) return actual; volatile ULONG err = ::GetLastError(); __debugbreak(); __assume(0); }
void do_work(value_type* v, size_t n) { size_t i; __assume_aligned(v, 64); __assume(n%16 == 0); for(i=0; i<n; ++i) { v[i] += 1.2; } }
// converts a NT Path to a more familiar (and user mode friendly) path // we can pass to createfile std::wstring NTPathToDosPath(LPCWSTR ntPath) { std::wstring dosPath; static const WCHAR backSlash = L'\\'; dosPath.reserve(MAX_PATH); // if it's a relative path // add on the path to the drivers directory if(PathIsRelativeW(ntPath)) { static const WCHAR driverString[] = L"drivers/"; WCHAR buf[MAX_PATH] = {0}; GetSystemDirectory(buf, MAX_PATH - (ARRAYSIZE(driverString) + 1)); PathAppend(buf, driverString); dosPath = buf; dosPath += ntPath; } else { // otherwise check for various prefixes static const WCHAR* sysRoot = L"\\systemroot\\"; const std::wstring& windir = GetWindowsDirectoryString(); // find the first slash on the windir path const WCHAR* startOfWindirPath = PathSkipRoot(windir.c_str()) - 1; static const WCHAR* dosDevSymLink = L"\\??\\"; // lowercase the input string std::transform(ntPath, ntPath + wcslen(ntPath) + 1, std::back_inserter(dosPath), std::ptr_fun(towlower)); std::wstring::size_type pos = 0; // if the prefix is systemroot if((pos = dosPath.find(sysRoot)) != std::wstring::npos) { // replace the first and last slashes with percent signs dosPath[0] = dosPath[11] = L'%'; // add in a backslash after the last percent dosPath.insert(12, 1, backSlash); // expand the systemroot environment string std::vector<WCHAR> temp(ExpandEnvironmentStrings(dosPath.c_str(), NULL, 0)); ExpandEnvironmentStrings(dosPath.c_str(), &temp[0], temp.size()); temp.pop_back(); // remove the terminating NULL dosPath.assign(temp.begin(), temp.end()); } // if the prefix is the dos device symlink, just remove it else if((pos = dosPath.find(dosDevSymLink)) != std::wstring::npos) { dosPath.erase(0, 4); } // if the prefix is the start of the windows path // add on the drive else if((pos = dosPath.find(startOfWindirPath)) != std::wstring::npos) { // insert the drive and the colon dosPath.insert(0, windir, 0, 2); } // else leave it alone else __assume(0); } return dosPath; }
static LRESULT CALLBACK captureFrameCallback(HWND captureWindow, VIDEOHDR *videoHeader) { MMCapture *capture = (MMCapture*)capGetUserData(captureWindow); __assume(capture); if(capture->saveVideoFrame(videoHeader)) { return capture->getReceiver().captureFrameCallback(*capture,capture->m_imagePr); } else { return S_OK; } }
void AsmJsByteCodeDumper::DumpAsmTypedArr(OpCodeAsmJs op, const unaligned T * data, FunctionBody * dumpFunction, ByteCodeReader& reader) { wchar_t* heapTag = nullptr; wchar_t valueTag = 'I'; switch (data->ViewType) { case ArrayBufferView::TYPE_INT8: heapTag = L"HEAP8"; valueTag = 'I'; break; case ArrayBufferView::TYPE_UINT8: heapTag = L"HEAPU8"; valueTag = 'U'; break; case ArrayBufferView::TYPE_INT16: heapTag = L"HEAP16"; valueTag = 'I'; break; case ArrayBufferView::TYPE_UINT16: heapTag = L"HEAPU16"; valueTag = 'U'; break; case ArrayBufferView::TYPE_INT32: heapTag = L"HEAP32"; valueTag = 'I'; break; case ArrayBufferView::TYPE_UINT32: heapTag = L"HEAPU32"; valueTag = 'U'; break; case ArrayBufferView::TYPE_FLOAT32: heapTag = L"HEAPF32"; valueTag = 'F'; break; case ArrayBufferView::TYPE_FLOAT64: heapTag = L"HEAPF64"; valueTag = 'D'; break; default: Assert(false); __assume(false); break; } switch (op) { case OpCodeAsmJs::LdArr: Output::Print(L"%c%d = %s[I%d]", valueTag, data->Value, heapTag, data->SlotIndex); break; case OpCodeAsmJs::LdArrConst: Output::Print(L"%c%d = %s[%d]", valueTag, data->Value, heapTag, data->SlotIndex); break; case OpCodeAsmJs::StArr: Output::Print(L"%s[I%d] = %c%d", heapTag, data->SlotIndex, valueTag, data->Value); break; case OpCodeAsmJs::StArrConst: Output::Print(L"%s[%d] = %c%d", heapTag, data->SlotIndex, valueTag, data->Value); break; default: Assert(false); __assume(false); break; } }
[[noreturn]] inline void unreachable() { #ifdef _MSC_VER __assume(0); #elif __GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 5 // GCC >= 4.5 __builtin_unreachable(); #else std::abort(); #endif }
// also can restore object_descriptor, if it isn't NULL. void object_restore(__int8 *instance, int *object_descriptor, BYTESTREAMRESTOREPROC bsrp) { assert(instance != NULL); int field_type = 0; int field_size = 0; __int8 *newinstance = NULL; int *new_object_descriptor = NULL; while ((field_type = _restore_dword(bsrp)) != FE_EOO) { __int16 w = 0; if (object_descriptor != NULL) { *object_descriptor++ = field_type; } switch (field_type) { case FE_BASIC: field_size = _restore_dword(bsrp); if (object_descriptor != NULL) { *object_descriptor++ = field_size; } _restore_binary(instance, field_size, bsrp); instance += field_size; break; case FE_ASZ: while (*instance++ = bsrp()); break; case FE_WSZ: while (w = _restore_word(bsrp)) { *(__int16 *)instance = w; instance += 2; } break; case FE_EMBED: case FE_TRACE: _restore_dword(bsrp); // ignored newinstance = new __int8[object_restore_size(bsrp)]; new_object_descriptor = NULL; if (object_descriptor != NULL) { new_object_descriptor = new int[object_restore_odsize(bsrp)]; } object_restore(newinstance, new_object_descriptor, bsrp); *(int *)instance = (int)newinstance; if (object_descriptor++ != NULL) { *object_descriptor = (int)new_object_descriptor; } instance += 4; object_descriptor++; break; default: assert(false); __assume(0); } } }
static LRESULT CALLBACK captureWaveStreamCallback(HWND captureWindow, WAVEHDR *audioHeader) { MMCapture *capture = (MMCapture*)capGetUserData(captureWindow); __assume(capture); if(capture->m_captureBlocked) { return S_OK; } LRESULT result = capture->getReceiver().captureWaveStreamCallback(*capture,audioHeader); if(capture->m_playAudio) { capture->saveAudioFrame(audioHeader); } return result; }
void ConfigFlagsTable::PrintUsageString() { Output::Print(_u("List of Phases:\n")); for(int i = 0; i < PhaseCount; i++) { if (i % 4 == 0) { Output::Print(_u("\n ")); } Output::Print(_u("%-40ls "), PhaseNames[i]); } Output::Print(_u("\n\nList of flags:\n\n")); for(int i = 0; i < FlagCount; i++) { Output::Print(_u("%60ls "), FlagNames[i]); switch(GetFlagType(Flag(i))) { case InvalidFlagType: break; case FlagString: Output::Print(_u("[:String] ")); break; case FlagPhases: Output::Print(_u("[:Phase] ")); break; case FlagNumber: Output::Print(_u("[:Number] ")); break; case FlagBoolean: Output::Print(_u(" ")); break; case FlagNumberSet: Output::Print(_u("[:NumberSet] ")); break; case FlagNumberPairSet: Output::Print(_u("[:NumberPairSet] ")); break; case FlagNumberTrioSet: Output::Print(_u("[:NumberTrioSet] ")); break; case FlagNumberRange: Output::Print(_u("[:NumberRange] ")); break; default: Assert(false); __assume(false); } Output::Print(_u("%ls\n"), FlagDescriptions[i]); } }
// CHECK-LABEL: @test1 int test1(int *a, int i) { // CHECK: store i32* %a, i32** [[A_ADDR:%.+]], align // CHECK: [[A:%.+]] = load i32** [[A_ADDR]] // CHECK: [[CMP:%.+]] = icmp ne i32* [[A]], null // CHECK: call void @llvm.assume(i1 [[CMP]]) #ifdef _MSC_VER __assume(a != 0) #else __builtin_assume(a != 0); #endif // Nothing is generated for an assume with side effects... // CHECK-NOT: load i32** %i.addr // CHECK-NOT: call void @llvm.assume #ifdef _MSC_VER __assume(++i != 0) #else __builtin_assume(++i != 0); #endif return a[0]; }
bool ProbeContainer::FetchTmpRegCount(Js::FunctionBody * functionBody, Js::ByteCodeReader * reader, int atOffset, uint32 *pTmpRegCount, Js::OpCode *pOp) { Assert(pTmpRegCount); Assert(pOp); Js::LayoutSize layoutSize; reader->SetCurrentOffset(atOffset); *pOp = reader->ReadOp(layoutSize); if (*pOp == Js::OpCode::Break) { // User might have put breakpoint on the skipped or target statement, get the original opcode; if (functionBody->ProbeAtOffset(atOffset, pOp)) { if (Js::OpCodeUtil::IsPrefixOpcode(*pOp)) { *pOp = reader->ReadPrefixedOp(layoutSize, *pOp); } } } if (*pOp == Js::OpCode::EmitTmpRegCount) { switch (layoutSize) { case Js::SmallLayout: { const unaligned Js::OpLayoutReg1_Small * playout = reader->Reg1_Small(); *pTmpRegCount = (uint32)playout->R0; } break; case Js::MediumLayout: { const unaligned Js::OpLayoutReg1_Medium * playout = reader->Reg1_Medium(); *pTmpRegCount = (uint32)playout->R0; } break; case Js::LargeLayout: { const unaligned Js::OpLayoutReg1_Large * playout = reader->Reg1_Large(); *pTmpRegCount = (uint32)playout->R0; } break; default: Assert(false); __assume(false); } return true; } return false; }
const char* toString(Direction val) { switch (val) { case Direction::AUTO: return "auto"; case Direction::UP: return "up"; case Direction::DOWN: return "down"; } #if (!defined (_MSCVER) && !defined (_MSC_VER)) __builtin_unreachable(); #else // The MSVC __assume() optimizer hint is similar, though not identical, to __builtin_unreachable() __assume(0); #endif }
// CHECK-LABEL: @test1 int test1(int *a, int i) { // CHECK: store i32* %a, i32** [[A_ADDR:%.+]], align // CHECK: [[A:%.+]] = load i32*, i32** [[A_ADDR]] // CHECK: [[CMP:%.+]] = icmp ne i32* [[A]], null // CHECK: call void @llvm.assume(i1 [[CMP]]) // CHECK: [[CALL:%.+]] = call i32 @isconst() // CHECK: [[BOOL:%.+]] = icmp ne i32 [[CALL]], 0 // CHECK: call void @llvm.assume(i1 [[BOOL]]) // CHECK: [[CALLPURE:%.+]] = call i32 @ispure() // CHECK: [[BOOLPURE:%.+]] = icmp ne i32 [[CALLPURE]], 0 // CHECK: call void @llvm.assume(i1 [[BOOLPURE]]) #ifdef _MSC_VER __assume(a != 0) __assume(isconst()); __assume(ispure()); #else __builtin_assume(a != 0); __builtin_assume(isconst()); __builtin_assume(ispure()); #endif // Nothing is generated for an assume with side effects... // CHECK-NOT: load i32*, i32** %i.addr // CHECK-NOT: call void @llvm.assume // CHECK-NOT: call i32 @nonconst() #ifdef _MSC_VER __assume(++i != 0) __assume(nonconst()); #else __builtin_assume(++i != 0); __builtin_assume(nonconst()); #endif return a[0]; }
void __declspec(noreturn) __cdecl headerentry() #endif { char truename[MAX_PATH]; char * cmdline = GetCommandLine(); char * runtime_path; HANDLE h; GetModuleFileName(NULL, truename, sizeof(truename)); h = CreateFile(truename, GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, NULL); if (h == INVALID_HANDLE_VALUE || (runtime_path = read_runtime_path(h)) == NULL) { HANDLE errh; DWORD numwritten; errh = GetStdHandle(STD_ERROR_HANDLE); WriteFile(errh, truename, strlen(truename), &numwritten, NULL); WriteFile(errh, msg_and_length(" not found or is not a bytecode executable file\r\n"), &numwritten, NULL); ExitProcess(2); #if _MSC_VER >= 1200 __assume(0); /* Not reached */ #endif } CloseHandle(h); run_runtime(runtime_path , cmdline); #if _MSC_VER >= 1200 __assume(0); /* Not reached */ #endif #ifdef __MINGW32__ return 0; #endif }