Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6131613
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:59:49+00:00 2026-05-23T16:59:49+00:00

We are writing a byte-code for a high-level compiled language, and after a bit

  • 0

We are writing a byte-code for a high-level compiled language, and after a bit of profiling and optimization, it became clear that the current largest performance overhead is the switch statement we’re using to jump to the byte-code cases.

We investigated pulling out the address of each case label and storing it in the stream of byte-code itself, rather than the instruction ID that we usually switch on. If we do that, we can skip the jump table, and directly jump to the location of code of the currently executing instruction. This works fantastically in GCC, however, MSVC doesn’t seem to support a feature like this.

We attempted to use inline assembly to grab the address of the labels (and to jump to them), and it works, however, using inline assembly causes the entire function to be avoided by the MSVC optimizer.

Is there a way to allow the optimizer to still run over the code? Unfortunately, we can’t extract the inline assembly into another function other than the one that the labels were made in, since there’s no way to reference a label for another function even in inline assembly. Any thoughts or ideas? Your input is much appreciated, thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T16:59:50+00:00Added an answer on May 23, 2026 at 4:59 pm

    The only way of doing this in MSVC is by using inline assembly (which basically buggers you for x64):

    int _tmain(int argc, _TCHAR* argv[])
    {
    case_1:
        void* p;
        __asm{ mov [p],offset case_1 }
        printf("0x%p\n",p);
        return 0;
    }
    

    If you plan on doing something like this, then the best way would be to write the whole interpreter in assembly then link that in to the main binary via the linker (this is what LuaJIT did, and it is the main reason the VM is so blindingly fast, when its not running JIT’ed code that is).

    LuaJIT is open-source, so you might pick up some tips from it if you go that route. Alternatively you might want to look into the source of forth (whose creator developed the principle you’re trying to use), if there is an MSVC build you can see how they accomplished it, else you’re stuck with GCC (which isn’t a bad thing, it works on all major platforms).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

After writing code that can be boiled down to the following: var size=-1; var
What could help me in helping writing highly compact(least byte code count) programs in
Writing documentation in html requires some code examples. What to do with characters that
I always seem to encounter this dilemma when writing low level code for MCU's.
I am writing code that compares 2 bytes which represent integers. I want to
I'm writing some C++ code that will have to send data over TCP/IP. I
I'm writing code that runs on Google App Engine (Java). What I'm trying to
A common mistake when writing code that reads text from a stream in Java
I'm writing an application that needs to verify HMAC-SHA256 checksums. The code I currently
I am writing a code that reads data from a http connection and stores

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.