自修改代码 on the fly 动态编译 即时编译 字节码
https://zh.wikipedia.org/wiki/自修改代码
自修改代码(Self-modifying code)是指程序在运行期间(Run time)修改自身指令。可能的用途有:病毒利用此方法逃避杀毒软件的查杀,反静态分析,反盗版[1] ,单片机程序升级。
在暂存存储器中执行代码的计算机,可修改内存中的代码段,以往这种方法常被黑客用来制造病毒(参见:EICAR 测试病毒),现今许多操作系统及CPU提供限制程序修改代码段的方法。还可用于程序保护,增加软件破解人员的静态分析难度[2]。
Java SE 6 提供Java Compiler API,和Java的反射(Reflection)机制结合在一起,即可使Java程序在运行时产生新类(Class),替换旧类。
https://en.wikipedia.org/wiki/Self-modifying_code
In computer science, self-modifying code is code that alters its own instructions while it is executing – usually to reduce the instruction path length and improve performance or simply to reduce otherwise repetitively similar code, thus simplifying maintenance. Self-modification is an alternative to the method of "flag setting" and conditional program branching, used primarily to reduce the number of times a condition needs to be tested. The term is usually only applied to code where the self-modification is intentional, not in situations where code accidentally modifies itself due to an error such as a buffer overflow.
The method is frequently used for conditionally invoking test/debugging code without requiring additional computational overhead for every input/output cycle.
The modifications may be performed:
- only during initialization – based on input parameters (when the process is more commonly described as software 'configuration' and is somewhat analogous, in hardware terms, to setting jumpers for printed circuit boards). Alteration of program entry pointers is an equivalent indirect method of self-modification, but requiring the co-existence of one or more alternative instruction paths, increasing the program size.
- throughout execution ("on the fly") – based on particular program states that have been reached during the execution
In either case, the modifications may be performed directly to the machine code instructions themselves, by overlaying new instructions over the existing ones (for example: altering a compare and branch to an unconditional branch or alternatively a 'NOP').
https://zh.wikipedia.org/wiki/動態編譯
动态编译是某些程式语言在执行时用来增进效能的方法。尽管这技术源于Self[来源请求],但使用此技术最为人所知的是Java。此技术可以做到一些只在执行时才能完成的最佳化。使用动态编译的执行环境一开始执行速度较慢,之后,完成大部分的编译和再编译后,会执行得比非动态编译程式快很多。因为初始化时的效能延迟,动态编译不适用于一些情况。在许多实作中,一些可以在编译时期做的最佳化被延到执行时期才编译,导致不必要的效能降低。即时编译是一种动态编译的形式。
一个非常近似的技术是递增式编译。递增式编译器用于POP-2、POP-11、一些Lisp的版本,如Maclisp和最少一种版本的ML语言(Poplog ML)。这需要编程语言的编译器成为执行环境的一部分作为要件以实作。如此便得以在任何时候从终端、从档案、或从执行中程式所建造数据结构中读取源码。然后,转成机器码区块或函数(有可能取代之前同名的函数),之后可立即被程式使用。因为执行中对互动开发和测试的速度的要求,编译后的机器码所做的最佳化程度不如标准“批次编译器”。然而,递增式编译过的程式跑起来通常比同一个程式的一般解译版本还快。递增式编译因而能够同时提供编译和解译语言优点。 为了增加可移植性,递增式编译通常采两步骤。第一个步骤会编译到中间、与平台独立的语言,然后再到机器码。在这个例子中,移植只须改变“后端”编译器。不同于动态编译,递增式编译在程式执行后不会做更进一步的最佳化。
https://en.wikipedia.org/wiki/Dynamic_compilation
Dynamic compilation is a process used by some programming language implementations to gain performance during program execution. Although the technique originated in Self,[citation needed] the best-known language that uses this technique is Java. Since the machine code emitted by a dynamic compiler is constructed and optimized at program runtime, the use of dynamic compilation enables optimizations for efficiency not available to compiled programs except through code duplication or metaprogramming.
Runtime environments using dynamic compilation typically have programs run slowly for the first few minutes, and then after that, most of the compilation and recompilation is done and it runs quickly. Due to this initial performance lag, dynamic compilation is undesirable in certain cases. In most implementations of dynamic compilation, some optimizations that could be done at the initial compile time are delayed until further compilation at run-time, causing further unnecessary slowdowns. Just-in-time compilation is a form of dynamic compilation.
https://zh.wikipedia.org/wiki/即時編譯
即时编译(英语:Just-in-time compilation,缩写:JIT)[1][2],又译及时编译[3]、实时编译[4],动态编译的一种形式,是一种提高程序运行效率的方法。通常,程序有两种运行方式:静态编译与动态解释。静态编译的程序在执行前全部被翻译为机器码,而解释执行的则是一句一句边运行边翻译。
即时编译器则混合了这二者,一句一句编译源代码,但是会将翻译过的代码缓存起来以降低性能损耗。相对于静态编译代码,即时编译的代码可以处理延迟绑定并增强安全性。
即时编译器有两种类型,一是字节码翻译,二是动态编译翻译。
微软的.NET Framework[5][6],还有绝大多数的Java实现[7],都依赖即时编译以提供高速的代码执行。Mozilla Firefox使用的JavaScript引擎SpiderMonkey也用到了JIT的技术。Ruby的第三方实现Rubinius和Python的第三方实现PyPy也都通过JIT来明显改善了解释器的性能。
https://en.wikipedia.org/wiki/Just-in-time_compilation
In computing, just-in-time (JIT) compilation (also dynamic translation or run-time compilations)[1] is a way of executing computer code that involves compilation during execution of a program – at run time – rather than prior to execution.[2] Most often, this consists of source code or more commonly bytecode translation to machine code, which is then executed directly. A system implementing a JIT compiler typically continuously analyses the code being executed and identifies parts of the code where the speedup gained from compilation or recompilation would outweigh the overhead of compiling that code.
JIT compilation is a combination of the two traditional approaches to translation to machine code – ahead-of-time compilation (AOT), and interpretation – and combines some advantages and drawbacks of both.[2] Roughly, JIT compilation combines the speed of compiled code with the flexibility of interpretation, with the overhead of an interpreter and the additional overhead of compiling (not just interpreting). JIT compilation is a form of dynamic compilation, and allows adaptive optimization such as dynamic recompilation and microarchitecture-specific speedups[nb 1][3] – thus, in theory, JIT compilation can yield faster execution than static compilation[clarification needed]. Interpretation and JIT compilation are particularly suited for dynamic programming languages, as the runtime system can handle late-bound data types and enforce security guarantees.
https://zh.wikipedia.org/wiki/字节码
字节码(英语:Bytecode)通常指的是已经经过编译,但与特定机器代码无关,需要解释器转译后才能成为机器代码的中间代码。字节码通常不像源码一样可以让人阅读,而是编码后的数值常量、引用、指令等构成的序列。
字节码主要为了实现特定软件运行和软件环境、与硬件环境无关。字节码的实现方式是通过编译器和虚拟机。编译器将源码编译成字节码,特定平台上的虚拟机将字节码转译为可以直接运行的指令。字节码的典型应用为Java bytecode。
https://en.wikipedia.org/wiki/Bytecode
A bytecode program may be executed by parsing and directly executing the instructions, one at a time. This kind of bytecode interpreter is very portable. Some systems, called dynamic translators, or just-in-time (JIT) compilers, translate bytecode into machine code as necessary at runtime. This makes the virtual machine hardware-specific but doesn't lose the portability of the bytecode. For example, Java and Smalltalk code is typically stored in bytecode format, which is typically then JIT compiled to translate the bytecode to machine code before execution. This introduces a delay before a program is run, when the bytecode is compiled to native machine code, but improves execution speed considerably compared to interpreting source code directly, normally by around an order of magnitude (10x).[3]
Because of its performance advantage, today many language implementations execute a program in two phases, first compiling the source code into bytecode, and then passing the bytecode to the virtual machine. There are bytecode based virtual machines of this sort for Java, Raku, Python, PHP,[nb 1] Tcl, mawk and Forth (however, Forth is seldom compiled via bytecodes in this way, and its virtual machine is more generic instead). The implementation of Perl and Ruby 1.8 instead work by walking an abstract syntax tree representation derived from the source code.
More recently, the authors of V8[4] and Dart[5] have challenged the notion that intermediate bytecode is needed for fast and efficient VM implementation. Both of these language implementations currently do direct JIT compiling from source code to machine code with no bytecode intermediary.[6]
https://mp.weixin.qq.com/s/ynOcSNUr0VjpoQDETseKPg
Java 字节码(Bytecode)技术详解
自修改代码 on the fly 动态编译 即时编译 字节码的更多相关文章
- Java的动态编译、动态加载、字节码操作
想起来之前做的一个项目:那时候是把需要的源代码通过文件流输出到一个.java文件里,然后调用sun的Comipler接口动态编译成.class文件,然后再用专门写的一个class loader加载这个 ...
- 深挖JDK动态代理(二):JDK动态生成后的字节码分析
接上一篇文章深挖JDK动态代理(一)我们来分析一下JDK生成动态的代理类究竟是个什么东西 1. 将生成的代理类编程一个class文件,通过以下方法 public static void transCl ...
- JDK动态代理和CGLIB字节码增强
一.JDK动态代理 Java 在 java.lang.reflect 包中有自己的代理支持,该类(Proxy.java)用于动态生成代理类,只需传入目标接口.目标接口的类加载器以及 Invocatio ...
- java编译过程(字节码编译和即时编译)
Javac编译与JIT编译 简介: 编译包括两种情况: 1,源码编译成字节码 2,字节码编译成本地机器码(符合本地系统专属的指令) 解释执行也包括两种情况: 1,源码解释执行 2,字节码解释执行 解释 ...
- 实现把C语言编译成java字节码的编译器 一个将C语言编译成java字节码的实例
- Android使用Gradle命令动态传参完成打包,不需要修改代码
不得不说,Gradle很强大,有人会问Gradle是什么?这里也不细讲,在我认为他就是一个构建神器.Gradle 提供了: 一个像 Ant 一样的非常灵活的通用构建工具 一种可切换的, 像 Maven ...
- [原创]ASM动态修改JAVA函数之函数字节码初探
ASM是非常强大的JAVA字节码生成和修改工具,具有性能优异.文档齐全.比较易用等优点.官方网站:http://asm.ow2.org/ 要想熟练的使用ASM,需要对java字节码有一定的了解,本文重 ...
- spring boot修改代码后无需重启设置,在开发时实现热部署
Spring Boot在开发时实现热部署(开发时修改文件保存后自动重启应用)(spring-boot-devtools) 热部署是什么 大家都知道在项目开发过程中,常常会改动页面数据或者修改数据结构, ...
- 【synchronized锁】通过synchronized锁 反编译查看字节码指令分析synchronized关键字修饰方法与代码块的区别
前提: 首先要铺垫几个前置的知识: Java中的锁如sychronize锁是对象锁,Java对象头中具有标识位,当对象锁升级为重量级锁时,重量级锁的标识位会指向监视器monitor, 而每个Java对 ...
随机推荐
- easyui中刷新列表
<table class="crud-content-info" id="showProductDialogFormstandrad"> </ ...
- idea中快捷键换成熟悉的celipse中快捷键
打开idea,找到菜单栏的file,点击打开,找到settings,打开 用key做关键词搜索keymap 找到之后点击打开,右侧就会显示快捷键界面,可以点击查看每一项 4 默认为defaul ...
- Vue从零开发SPA项目
所谓SPA(single page web application),就是单页面项目的意思. vue的亮点就是我们只需要关注数据的变化,下面演示一下从零开始创建一个独立项目,并且能自定义路由,提交表单 ...
- python实现贴吧顶贴机器人
前言------百度贴吧流量如何?全球最大的中文社区,虽然比不上阿里,腾讯! 此文章仅供交流学习.建议机器人用小号操作,切勿用作商业用途! 测试版本:python 3.7 64位火狐浏览器firefo ...
- 使用sqlmap
实验环境要求: 1.安装win7或win10的笔记本或PC电脑一台,硬盘100GB,内存8GB 2.安装VMware Workstation 14以上 总体目标:基于centos7搭建dvwa web ...
- Scanner详解
java.util.Scanner 是 Java5 的新特征,我们可以通过 Scanner 类来获取用户的输入 1)public static void main(String[] args) { S ...
- Eclipse 使用svn时出现 “Previous operation has not finished; run 'cleanup' if it was interrupted“问题
在执行svn操作的时候出现了下面的问题 commit -m "" E:/eclipse/workplace/BRobotAPP/blockly/googleDemo/blockly ...
- Elasticsearch分页解决方案
一.命令的方式做分页 1.常见的分页方式:from+size elasticsearch默认采用的分页方式是from+size的形式,但是在深度分页的情况下,这种使用方式的效率是非常低的,比如from ...
- Spark算子使用
一.spark的算子分类 转换算子和行动算子 转换算子:在使用的时候,spark是不会真正执行,直到需要行动算子之后才会执行.在spark中每一个算子在计算之后就会产生一个新的RDD. 二.在编写sp ...
- 使用Python实现的4种快速排序算法
快速排序算法,总体来说就是选一个基准值,把小于基准值的分一拨,把大于基准值的分到另一拨,然后递归. 有区别的是,分区算法有差异,最直接的是,选个基准值,定义两个列表(小值分区less和大值分区grea ...