Skip to content

[UDFS] Remove legacy x86 asm string-length paths in favor of shared C/C++ implementation#277

Draft
Copilot wants to merge 12 commits into
udf-devfrom
copilot/udfs-compare-assembly-c-code-performance
Draft

[UDFS] Remove legacy x86 asm string-length paths in favor of shared C/C++ implementation#277
Copilot wants to merge 12 commits into
udf-devfrom
copilot/udfs-compare-assembly-c-code-performance

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 19, 2026

  • Reset HEAD to pre-merge commit (remove old merge commit from local branch)
  • Rebased copilot commits (Initial plan, [UDFS] remove legacy x86 asm, [UDFS] Remove all inline assembly, fix: review feedback, fix: USHORT cast precedence) onto origin/udf-dev, skipping the two pre-existing Gleb Lamm refactoring commits that are superseded by udf-dev
  • Resolved all Sys_spec_lib.cpp conflicts by keeping udf-dev's version (udf-dev already removed those functions; equivalent changes were auto-applied to string_lib.cpp where the functions now live)
  • The rebased tree state is functionally identical to the old merge-commit state — only a trailing newline difference in Sys_spec_lib.cpp
  • Push updated branch (fast-forward commit syncing tree to rebased state)

Copilot AI changed the title [WIP] Analyze performance of assembly versus C/C++ code [UDFS] Remove legacy x86 asm string-length paths in favor of shared C/C++ implementation Apr 19, 2026
Copilot AI requested a review from Zero3K20 April 19, 2026 03:08
Agent-Logs-Url: https://github.com/Zero3K20/reactos/sessions/9391a902-dd88-4c82-bf33-9e94fdacb804

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR modernizes the UDFS driver’s debug/breakpoint and “touch” helpers by removing legacy x86 inline-asm code paths and standardizing on shared C/C++ implementations.

Changes:

  • Replaced x86 __asm int 3 / INT3 usage with __debugbreak() in multiple debug/bounds-check paths.
  • Removed x86 inline-asm implementations for “touch” helpers, keeping a single C implementation.
  • Removed x86 inline-asm “string length scan” implementations, keeping the generic C loop.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
drivers/filesystems/udfs/udf_dbg.h Uses __debugbreak() for breakpoints; drops x86 asm UDFTouch() path in favor of a single C implementation.
drivers/filesystems/udfs/Include/mem_tools.cpp Drops x86 asm DbgTouch() path in favor of a single C implementation.
drivers/filesystems/udfs/Include/mem_tools.h Replaces inline-asm INT3 breakpoints in debug/bounds-check helpers with __debugbreak().
drivers/filesystems/udfs/Include/string_lib.cpp Removes x86 asm string-length scanning, leaving the generic loop.
drivers/filesystems/udfs/Include/Sys_spec_lib.cpp Removes x86 asm string-length scanning, leaving the generic loop.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread drivers/filesystems/udfs/Include/string_lib.cpp Outdated
Comment thread drivers/filesystems/udfs/Include/Sys_spec_lib.cpp Outdated
Comment thread drivers/filesystems/udfs/Include/Sys_spec_lib.cpp Outdated
Comment thread drivers/filesystems/udfs/Include/mem_tools.cpp Outdated
Comment thread drivers/filesystems/udfs/udf_dbg.h Outdated
Comment thread drivers/filesystems/udfs/Include/string_lib.cpp Outdated
@Zero3K20
Copy link
Copy Markdown
Owner

@copilot apply changes based on the comments in this thread

Copilot AI and others added 2 commits April 19, 2026 04:21
Copy link
Copy Markdown
Author

Copilot AI commented Apr 19, 2026

@copilot apply changes based on the comments in this thread

Applied all six review suggestions in commit 66f773c7, with a follow-up cast-precedence fix in a68deb76:

  • DbgTouch() (mem_tools.cpp): read through volatile UCHAR* into a volatile UCHAR a so the load cannot be eliminated by the optimizer.
  • UDFTouch() (udf_dbg.h): read through volatile UCHAR* to guarantee the memory access is emitted.
  • Four NUL-terminator scan loops in string_lib.cpp and Sys_spec_lib.cpp: widened loop counter from USHORT to ULONG, added i < (MAXUSHORT / sizeof(WCHAR)) upper-bound guard to prevent wraparound infinite loops, and added correctly parenthesised (USHORT) casts on Length/MaximumLength assignments.

@Zero3K20 Zero3K20 changed the base branch from write to udf-dev April 27, 2026 06:58
@Zero3K20
Copy link
Copy Markdown
Owner

@copilot Please fix the conflicts.

…mance

Resolve conflicts:
- Sys_spec_lib.cpp: removed commented-out block (base branch refactored, kept new functions)
- udf_dbg.h: keep __debugbreak() over legacy __asm int 3 (our PR change)

Co-authored-by: Zero3K20 <258969903+Zero3K20@users.noreply.github.com>
Copy link
Copy Markdown
Author

Copilot AI commented Apr 27, 2026

@copilot Please fix the conflicts.

Resolved in merge commit 4059a000. All 23 conflicted files were addressed:

  • Non-PR files (cleanup, close, create, env_spec, etc.): took the base branch (udf-dev) version
  • udf_dbg.h: kept our __debugbreak() macro over the reverted __asm int 3 from the base branch
  • Sys_spec_lib.cpp: base branch removed MyAppendUnicodeToString_ / MyInitUnicodeString entirely as part of its refactoring, so the commented-out block from our branch was dropped accordingly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[UDFS] Is the assembly being used in its code actually faster than the C/C++ code that is after the else line?

4 participants