
jvm
kong-kong
记录流水账
展开
-
add esp,8
test1函数int test1(int a, int b) { return a + b;}汇编00A83CE3 mov eax,dword ptr [b] 00A83CE6 push eax 00A83CE7 mov ecx,dword ptr [a] 00A83CEA push ecx 00A83CEB call test1 (0A811DBh) 00A83CF0 add原创 2022-03-20 12:30:13 · 1395 阅读 · 0 评论 -
Class.forName底层原理
ClassClass.forNamepublic static Class<?> forName(String name, boolean initialize, ClassLoader loader) throws ClassNotFoundException { Class<?> caller = null; SecurityManager sm =原创 2022-02-12 20:23:13 · 1132 阅读 · 0 评论 -
进入老年代阈值
初始_tenuring_thresholdproduct(uintx, MaxTenuringThreshold, 15, \ "Maximum value for tenuring threshold")DefNewGenerationDefNewGeneration::DefNewGeneration(ReservedSpace rs, si原创 2022-02-05 16:09:33 · 480 阅读 · 0 评论 -
新生代_buttom、_top、_end、_saved_mark_word
save_marks()为_saved_mark_word变量赋值为碰撞指针的_top的值genCollectedHeap.cppsave_marks()genCollectedHeap.cpp:480 调用GenCollectedHeap::save_marks()openjdk12void GenCollectedHeap::save_marks() { _young_gen->save_marks(); _old_gen->save_marks();}openj原创 2022-02-05 14:47:59 · 828 阅读 · 0 评论 -
copy_to_survivor_space
copy_to_survivor_spacedefNewGeneration.cpp784copy_to_survivor_spaceoop DefNewGeneration::copy_to_survivor_space(oop old) { assert(is_in_reserved(old) && !old->is_forwarded(), "shouldn't be scavenging this oop"); size_t s = old-&原创 2022-02-05 14:19:48 · 1013 阅读 · 0 评论 -
MutexLocker ml(Heap_lock);
常见写法jvm源码有很多这种类型写法的代码MutexLocker ml(Heap_lock);ObjectWaiter node(Self);等这里以MutexLocker举例MutexLocker ml(Heap_lock);MutexLockerclass MutexLocker: StackObj { private: Monitor * _mutex; public: MutexLocker(Monitor * mutex) { // MutexLocker ml(He原创 2022-02-04 20:57:06 · 410 阅读 · 0 评论 -
垃圾回收之collection_attempt_is_safe
DefNewGeneration::collectvoid DefNewGeneration::collect(bool full, bool clear_all_soft_refs, // todo soft size_t size, bool is_tlab) { ...... /原创 2022-01-28 17:09:29 · 498 阅读 · 0 评论 -
IDEA查看虚拟机字节码插件
ASM Bytecode Outline使用选择类 -> Code -> Show Bytecode outlinejclasslibView -> Show Bytecode With Jclasslib原创 2022-01-12 17:35:12 · 530 阅读 · 0 评论 -
InstanceKlass
InstanceKlassallocate_instance_klassInstanceKlass* InstanceKlass::allocate_instance_klass( ClassLoaderData* loader_data, int vtable_len,原创 2022-01-11 19:08:14 · 591 阅读 · 0 评论 -
字节码分析 i++ 和 ++i
场景1i++public int increment1() { int i = 0; i++; return i;}字节码0 iconst_01 istore_12 iinc 1 by 15 iload_16 ireturn++ipublic int increment2() { int i = 0; ++i; return i;}字节码0 iconst_01 istore_12 iinc 1 by 15 iload_1原创 2022-01-04 19:58:22 · 381 阅读 · 0 评论 -
内存类型(MemoryType)
MemoryTypeenum MemoryType { // Memory type by sub systems. It occupies lower byte. mtJavaHeap = 0x00, // Java heap java堆 mtClass = 0x01, // memory class for Java classes mtThread = 0x02, // memory for thread obje原创 2021-11-28 01:05:52 · 2248 阅读 · 0 评论 -
jvm类型
基本类型typedef signed char jbyte;typedef int jint;typedef jint jsize;typedef long jlong;typedef unsigned char jboolean;typedef unsigned short jchar;typedef short jshort;typedef float jfloat;typedef double j原创 2021-11-28 01:06:05 · 183 阅读 · 0 评论 -
堆内存分配
堆内存分配genCollectedHeap.cpp:334HeapWord* GenCollectedHeap::mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded) { return collector_policy()->mem_allocate_work(size, false /* is_tlab */, gc_overhead_limit_was_exceeded); // 根据策略来分配原创 2021-11-27 16:31:01 · 583 阅读 · 0 评论 -
pthread_cond_signal例子
//// Created by kongqi on 2021-11-24.//#include "mythreadsignal.h"#include<pthread.h>#include <iostream>#include<unistd.h>#include <iostream>using namespace std;pthread_mutex_t mutexm2 = PTHREAD_MUTEX_INITIALIZER;/*初始化互斥原创 2021-11-24 22:01:32 · 732 阅读 · 0 评论 -
Atomic
Atomic::xchg替换把exchange_value的值,存到*dest去可以理解 dest = exchange_value (当然这个操作有可能会失败)返回的是原值,也就是最初的dest的值inline int Atomic::xchg (int exchange_value, volatile int* dest) { __asm__ volatile ( "xchgl (%2),%0" : "=r" (exchange_value)原创 2021-11-23 21:37:21 · 443 阅读 · 0 评论 -
LockSupport中的park与unpark底层实现
park()void Parker::park(bool isAbsolute, jlong time) { // Ideally we'd do something useful while spinning, such 理想情况下,我们会在旋转时做一些有用的事情,例如 // as calling unpackTime(). 作为调用 unpackTime() // Optional fast-path check: 可选的快速路径检查: // Return immediatel原创 2021-11-23 21:25:40 · 612 阅读 · 0 评论 -
初始化vtable和itable
InstanceKlass::link_class_implvtable和itable是在链接阶段初始化if (!this_oop()->is_shared()) { ResourceMark rm(THREAD); klassVtable* kv = this_oop->vtable(); // 初始化vtable kv->initialize_vtable(true, CHECK_false); klassItable* ki = this_oop->原创 2021-11-20 23:31:02 · 476 阅读 · 0 评论 -
invoke*各种指令(比如invokevitual等)
基础数据INamepublic interface IName { public String getName();}AApublic class AA implements IName{ @Override public String getName() { return "AA"; } public static void staticFun(){ System.out.println(); }}Main原创 2021-11-20 22:59:50 · 876 阅读 · 0 评论 -
vtable演示
初始数据AApublic class AA { public static final int PAGE = 20; private int num = 10; public void name(){ System.out.println("AA"); } public void add() { }}BBpublic class BB extends AA{ public void name(){原创 2021-11-20 11:54:18 · 604 阅读 · 0 评论 -
Symbol源文件
symbol.hppclass ClassLoaderData;// We separate the fields in SymbolBase from Symbol::_body so that// Symbol::size(int) can correctly calculate the space needed.class SymbolBase : public MetaspaceObj { public: ATOMIC_SHORT_PAIR( volatile short _原创 2021-11-15 20:47:17 · 731 阅读 · 0 评论 -
hsdb基本操作
consolewindows菜单下的consoleuniversescanoops扫描指定内存区间,类的类型scanoops 0x000000076b180000 0x000000076fc00000 java.lang.Stringinspect查看某个类的信息原创 2021-11-15 18:34:35 · 1250 阅读 · 0 评论 -
ConstantPool结构
结构图 本图来自揭秘Java虚拟机(JVM设计原理与实现)数据存放源码putvoid slot_at_put(int which, CPSlot s) const { assert(is_within_bounds(which), "index out of bounds"); assert(s.value() != 0, "Caught something"); *(intptr_t*)&base()[which] = s.val原创 2021-11-14 23:22:53 · 828 阅读 · 0 评论 -
thread.hpp之is_lock_owned
thread.cppis_lock_ownedbool Thread::is_lock_owned(address adr) const { return on_local_stack(adr);}thread.hppon_local_stackbool on_local_stack(address adr) const { // 在(_stack_base-_stack_size) 和 _stack_base 之间 /* QQQ this has knowledge o原创 2021-11-12 00:18:12 · 446 阅读 · 0 评论 -
反射之getMethods、getDeclaredMethods
getDeclaredMethodspublicOnly = falsepublic Method[] getDeclaredMethods() throws SecurityException { checkMemberAccess(Member.DECLARED, Reflection.getCallerClass(), true); return copyMethods(privateGetDeclaredMethods(false)); }getMet原创 2021-11-09 00:27:20 · 412 阅读 · 0 评论 -
String对象指令
例子1从指令看出new String(“hello1”),这个创建了2个对象public void anew(){ String str = new String("hello1");}指令 0 new #14 <java/lang/String> // 第2个对象 3 dup 4 ldc #15 <hello1> // 第1个对象 6 invokespecial #16 <java/lang/String.<init>>原创 2021-11-07 22:54:59 · 240 阅读 · 0 评论 -
DefNewGeneration
defNewGeneration.hppclass DefNewGeneration: public Generation {.................}defNewGeneration.cpp构造函数DefNewGeneration::DefNewGeneration(ReservedSpace rs, size_t initial_size,原创 2021-11-03 18:54:54 · 259 阅读 · 0 评论 -
ubuntu14编译openjdk8
https://blog.youkuaiyun.com/w57685321/article/details/106326558/原创 2021-10-23 13:23:16 · 265 阅读 · 0 评论 -
ubuntu21,clion调试openjdk12源码
编译jdksudo bash configure --with-debug-level=slowdebug --with-target-bits=64 --disable-warnings-as-errors --enable-dtrace --with-jvm-variants=server参数说明--with-boot-jdk:指定Bootstrap JDK路径--with-debug-level:编译级别,可选值为release、fastdebug、slowdebug和optimized,默原创 2021-10-17 01:11:06 · 653 阅读 · 0 评论 -
getClass
demoGetClassDemo demo = new GetClassDemo();Class clazz = demo.getClass(); // 初始化的classSystem.out.println("clazz="+clazz);Objectnative方法public final native Class<?> getClass();openjdk8\jdk\src\share\native\java\lang\Object.cJNIEXPORT jclass原创 2021-10-15 20:38:47 · 212 阅读 · 0 评论 -
make_local之(thread->active_handles()->allocate_handle)
make_localopenjdk8\hotspot\src\share\vm\runtime\jniHandles.cppjobject JNIHandles::make_local(JNIEnv* env, oop obj) { if (obj == NULL) { return NULL; // ignore null handles } else { JavaThread* thread = JavaThread::thread_from_j原创 2021-10-15 20:38:00 · 321 阅读 · 0 评论 -
pthread相关函数
pthread_getpecific和pthread_setspecific是实现同一个线程中不同函数间共享数据的一种很好的方式#include <pthread.h>int pthread_setspecific(pthread_key_t key, const void *value);void *pthread_getspecific(pthread_key_t key);os::thread_local_storage_at_puthotspot\src\os\linux\原创 2021-10-15 20:37:00 · 405 阅读 · 0 评论 -
SymbolTable
SymbolTable::new_symbolsopenjdk8\hotspot\src\share\vm\classfile\symbolTable.hppstatic void new_symbols(ClassLoaderData* loader_data, constantPoolHandle cp, int names_count, const char** name, int* lengt原创 2021-10-15 20:35:41 · 666 阅读 · 0 评论 -
HandleArea::allocate_handle
HandleArea::allocate_handleopenjdk8\hotspot\src\share\vm\runtime\handles.cpp调用的是real_allocate_handle(obj)oop* HandleArea::allocate_handle(oop obj) { assert(_handle_mark_nesting > 1, "memory leak: allocating handle outside HandleMark"); assert(_no原创 2021-10-15 20:34:29 · 301 阅读 · 0 评论 -
Symbol
Symbol::Symbol(symbol.cppSymbol::Symbol(const u1* name, int length, int refcount) { _refcount = refcount; //引用数量 _length = length; // 长度 _identity_hash = os::random(); //hash for (int i = 0; i < _length; i++) { byte_at_put(i, name[i]); //原创 2021-10-14 20:55:42 · 254 阅读 · 0 评论 -
String.intern源码
前言以JDK8为例来分析String.javapublic native String intern();String.copenjdk8\openjdk\jdk\src\share\native\java\lang\String.c#include "jvm.h"#include "java_lang_String.h"JNIEXPORT jobject JNICALLJava_java_lang_String_intern(JNIEnv *env, job.原创 2021-05-15 22:22:33 · 515 阅读 · 0 评论 -
jvm虚拟机指令
https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-6.html原创 2021-04-15 23:04:17 · 353 阅读 · 0 评论 -
ClassFile - Attributes - Code
TheCodeAttributeTheCodeattribute is a variable-length attribute in theattributestable of amethod_infostructure (§4.6). ACodeattribute contains the Java Virtual Machine instructions and auxiliary information for a method, including an instance i...原创 2021-04-15 22:55:51 · 292 阅读 · 0 评论 -
ClassFile之Attributes
AttributesAttributesare used in theClassFile,field_info,method_info, andCode_attributestructures of theclassfile format (§4.1,§4.5,§4.6,§4.7.3).All attributes have the following general format:attribute_info { u2 attribute_name_inde...翻译 2021-04-15 11:12:50 · 391 阅读 · 0 评论 -
ClassFile之Methods
MethodsEach method, including each instance initialization method (§2.9) and the class or interface initialization method (§2.9), is described by amethod_infostructure.No two methods in oneclassfile may have the same name and descriptor (§4.3.3)...翻译 2021-04-15 10:53:45 · 319 阅读 · 0 评论 -
ClassFile之Fields
Each field is described by afield_infostructure.No two fields in oneclassfile may have the same name and descriptor (§4.3.2).The structure has the following format:field_info { u2 access_flags; u2 name_index; ...翻译 2021-04-15 10:28:48 · 325 阅读 · 0 评论