Which File contains the Bytecode Instruction Set of the OpenJDK 8 - bytecode

i am new to openJDK8, i want to locate the file(s) where the bytecode instruction set is present which is used to generate the bytecode of a source .java file.
Secondly i need basic knowledge of the bytecode generation and execution process.
i am a research student and working on openJDK bytecode. Can you please guide?

The question seems to be conflating/mixing a number of different things. If you are creating a new bytecode there's several things you need to do.
Specify/define the bytecode
Modify the compiler to generate that bytecode
Modify the runtime to understand that bytecode
The Java bytecodes are specified in the Java Virtual Machine Specification. If you need to define a new one, you need to specify it to a similar degree, though you don't have to publish it there.
The part of Java SDK that is responsible from taking Java source code and producing Java bytecode is the Java compiler (javac). The source code for OpenJDK's javac is available here. The source code for Eclipse's Java Compiler is also available, but I don't know where.
Once you have the java compiler generating your custom bytecode, you have to teach the JVM how to interpret it.
The OpenJDK VM (hotspot) has several components that handle executing the bytecode. There's more than one interpreter (that reads and executes bytecode) and multiple Just-In-Time optimizing compilers that read the bytecode and (possibly) compile it into machine code before executing it. The source code for all of them is part of the hotspot. You probably just want to limit yourself to the interpreter and disable the compilers for initial work. If so, this set of notes explain how the hotspot interpreter works.

Related

when does the compiler compile the code into machine code?

As far as I know, the compiler compiles the code by converting it to a language that a computer can understand which is the machine language and this is done before running the code.
So, does the compiler compile my code each time I write a character in the file?
And if so, does it check the whole code? Or just the line that updated.
An important part to this question is the type of programming language(PL) we are talking about. Generally speaking, I would categorize PL into 3 groups:
Traditional PLs. Ex: C, C++, Rust
The compiler compiles the code into machine language when you hit the "build" button or the "run" button.
It doesn't compile every time you change the code, but a code linter does continuously observe your code and check it for errors.
Another note, when you change part of the code and compile it, the compiler doesn't recompile everything. It usually only recompile the current assembly file (or module or whatever you call them).
It is also important to note that a lot of modern IDEs, compile when you save the files.
There is also the hot reload feature. It is a smart compiler feature that can swap certain parts of the code while it is running.
Interpreted PLs Ex: python, JS and PHP
Those languages never get compiled; Rather, they get interpreted or translated into native code on the fly and in-memory when you run them.
Those languages usually employee a cache to accelerate the subsequent code execution.
Intermediary Code PL. Ex: Kotlin, java, C#
Have 2 stages of compilation:
Build time compilation.
Just in time (run-time) compilation.
Build time compilation converts the code into intermediary language (IL) machine code, which is special to the run-time.
This code only understood by the run time like Java runtime or dot net runtime
The second compilation happens when the programs get installed or ran for the first time. This is called just in time compilation (JIT)
The run-time convert the code into native code specific to the run-time OS.

How can I inspect x86/x64 code generated by V8 from WebAssembly?

https://webassembly.studio/ allows inspection of WebAssembly (WASM) files and the corresponding SpiderMonkey-generated x86 code. I'd like to similarly inspect instructions generated by V8's WASM compilers (Liftoff and TurboFan).
I'm entirely unfamiliar with V8's codebase/API (I compiled & linked it and followed some tutorials, though). There seems to be a v8::CompiledWasmModule class available, but it does not seem to expose access to generated x86/x64 instructions by either Liftoff or TurboFan.
WebAssembly - adding a new opcode describes the process of adding a WASM opcode to V8. Seemingly appropriate functions for WASM compilation/execution are available in the mentioned classes. Though, these seem rather deeply layered within the V8 codebase and would be difficult to access were I to link V8 as a library. Also, I'm unsure if this corresponds to Liftoff or TurboFan.
Could anybody familiar with the V8 codebase give me some pointers as to how I can access Liftoff and/or TurboFan's WebAssembly compilation module, as to obtain x86/x64 code?
To inspect generated code, you can run the d8 shell with the --print-wasm-code flag. You'll need either a debug build, or a release build with the v8_enable_disassembler = true GN arg.
There's no existing way to retrieve generated code via V8's API; so if that's what you want, then you'd have to add it. Keep in mind that V8 is not designed to be a standalone compiler, which means generated code assumes that it's going to run "inside V8", so if you wanted to use it for anything else, you'd have to make significant modifications.

What happens when we run a julia-lang script?

In my understanding, julia is a script language with a JIT compiler. But in java, you can find *.class files; In python, you can find *.pyc files. This means java and python need first convert its language to bytecode, then using VM to run this bytecode. However, I can not find the bytecode files for julia like *.jlc. Any ideas?
Actually there is functionality to dump the LLVM bitcode in Julia:
See jl_dump_bitcode.
Thanks to Isiah for pointing out that it is possible to use code_llvm to read the bitcode in the interpreter.
Note that in julia_trampoline this function is used, depending on a build_path option. However this does not seem like an end-user interface to me.
In contrast to other JIT-based software like NodeJS (V8), it is however technically possible to dump the LLVM bitcode.
This is covered in the manual: http://docs.julialang.org/en/release-0.5/devdocs/eval/
Leah Hanson has written an excellent article here on the 5 steps Julia performs to get from Julia code to native Assembly code:

Java bytecode libraries

Could anybody explain what is the bytecode libraries? For example, some Hibernate 3.5 book tells me that Hibernate uses javaassit or CGLib bytecode libraries. For what this libraries exists? Thank you.
When you write a Java app, you have to compile with a compiler (e.g. javac) first. Some classfiles (*.class) are generated. There is the bytecode. The class file is a binary file that can be executed by a Java Virtual Machine.
You may want to read a classfile, modify a classfile (eg. for instrumentation) or create (generate) a completely new classfile. If you want to do this, a good library can make it easier. You don't have to care about the exact structure and many constants (e.g. opcodes).
CGLib homepage says that Hibernate "Uses cglib to generate proxies for persistent classes."

What is happening when you set a compilation path?

I understand it is somehow making a connection so that a compiler when envokes connects a source code to whatever libraries that it needs to.
But what is going on a more technical level, or better put what do I need to know in order to confidentally compile code.
I'm working with C++ and MinGW, and have started to look into build files and stuff for Sublime Text 2 (Have learned mostly under unix, or Java + eclipse so far). But what I don't understand what is adding a compiler to your path do for you?
Do I need to add it for every folder I want to compile from? Or is it system wide? I'm really learning this stuff for the first time, we we're never showed how to set up development environments or even deploy code on other systems.
You probably mean include paths and library paths in the compiler:
include paths: where the compiler will look for headers; and
library paths: where the linker, invoked by the compiler, will look for binary libraries to finish building your project.
If that is the case, look here for a gentle explanation.
Basically, what is happening is that the compiler looks in certain places for symbols defined by the operating system and other libraries installed system-wide.
In addition to those paths, you need to tell the compiler where to find the symbols defined in your own project.
You may also mean something related to installing the compiler itself or configuring the editor to use it.
In that case, what is happening is that you need to tell the build system where to find the executable for the compiler.
Basically, what is probably happening is that your editor wants to know where the compiler is so that it can provide real time feedback on your code. Adding the compiler to the system path will usually, but not always, solve your problem.
In more detail:
A C++ build is a rather complex tool chain, involving determining dependencies, preprocessing, compiling, and linking. There are tools that automate that tool chain, and those tools are in turn wrapped into the functionality of modern IDEs like Eclipse, Visual C++, or Sublime Text 2. You many need to tell your editor where to find the tools it uses to provide you with those services.

Resources