什么是跳表? [英] What is a jump table?

查看:92
本文介绍了什么是跳表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人能解释一个跳转表的机制和为什么会在嵌入式系统需要?

Can someone explain the mechanics of a jump table and why is would be needed in embedded systems?

推荐答案

一个跳转表可以是一个指针数组功能或机器code跳转指令的数组。如果你有一个相对静态的功能集(比如系统呼叫或一类的虚函数),那么你可以创建这个表一次,并使用一个简单的索引数组调用的函数。这将意味着检索指针和调用功能或根据所用表的类型跳跃到机器code

A jump table can be either an array of pointers to functions or an array of machine code jump instructions. If you have a relatively static set of functions (such as system calls or virtual functions for a class) then you can create this table once and call the functions using a simple index into the array. This would mean retrieving the pointer and calling a function or jumping to the machine code depending on the type of table used.

在嵌入式编程这样做的好处是:

The benefits of doing this in embedded programming are:


  1. 指数比机器code或指针存取效率更高,所以在约束环境内存节约潜力。

  2. 对于任何特定功能的指数将保持稳定,只改变功能需要换出函数指针。

如果不花费你的访问表的性能一点点,但这绝不逊于其它任何虚函数调用更糟。

If does cost you a tiny bit of performance for accessing the table, but this is no worse than any other virtual function call.

这篇关于什么是跳表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆