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 70257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:42:09+00:00 2026-05-10T19:42:09+00:00

The deceptively simple foundation of dynamic code generation within a C/C++ framework has already

  • 0

The deceptively simple foundation of dynamic code generation within a C/C++ framework has already been covered in another question. Are there any gentle introductions into topic with code examples?

My eyes are starting to bleed staring at highly intricate open source JIT compilers when my needs are much more modest.

Are there good texts on the subject that don’t assume a doctorate in computer science? I’m looking for well worn patterns, things to watch out for, performance considerations, etc. Electronic or tree-based resources can be equally valuable. You can assume a working knowledge of (not just x86) assembly language.

  • 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. 2026-05-10T19:42:09+00:00Added an answer on May 10, 2026 at 7:42 pm

    Well a pattern I’ve used in emulators goes something like this:

    typedef void (*code_ptr)(); unsigned long instruction_pointer = entry_point; std::map<unsigned long, code_ptr> code_map;   void execute_block() {     code_ptr f;     std::map<unsigned long, void *>::iterator it = code_map.find(instruction_pointer);     if(it != code_map.end()) {         f = it->second     } else {         f = generate_code_block();         code_map[instruction_pointer] = f;     }     f();     instruction_pointer = update_instruction_pointer(); }  void execute() {     while(true) {         execute_block();     } } 

    This is a simplification, but the idea is there. Basically, every time the engine is asked to execute a ‘basic block’ (usually a everything up to next flow control op or whole function in possible), it will look it up to see if it has already been created. If so, execute it, else create it, add it and then execute.

    rinse repeat 🙂

    As for the code generation, that gets a little complicated, but the idea is to emit a proper ‘function’ which does the work of your basic block in the context of your VM.

    EDIT: note that I haven’t demonstrated any optimizations either, but you asked for a ‘gentle introduction’

    EDIT 2: I forgot to mention one of the most immediately productive speed ups you can implement with this pattern. Basically, if you never remove a block from your tree (you can work around it if you do but it is way simpler if you never do), then you can ‘chain’ blocks together to avoid lookups. Here’s the concept. Whenever you return from f() and are about to do the ‘update_instruction_pointer’, if the block you just executed ended in either a call, unconditional jump, or didn’t end in flow control at all, then you can ‘fixup’ its ret instruction with a direct jmp to the next block it’ll execute (cause it’ll always be the same one) if you have already emited it. This makes it so you are executing more and more often in the VM and less and less in the ‘execute_block’ function.

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

Sidebar

Ask A Question

Stats

  • Questions 121k
  • Answers 121k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Use table.put(key, val); to add a new key/value pair or… May 12, 2026 at 12:33 am
  • Editorial Team
    Editorial Team added an answer I re-read the question, here is a function that would… May 12, 2026 at 12:33 am
  • Editorial Team
    Editorial Team added an answer You could try including the compiler file version in your… May 12, 2026 at 12:33 am

Related Questions

I'm trying to increase the timeout on all sessions. The site is hosted with
Here we go down the subjective alley .. Lately, I have been adding a
If I have a nested ListView, and I'm calling a related table in LinQ,
I have a deceptively simple scenario, and I want a simple solution, but it's

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.