hotspot/src/share/vm/jvmci/jvmciCompilerToVM.cpp
changeset 35606 d873b64009cc
parent 35499 b79827ea1b9f
parent 35593 c733fd198e6e
child 35913 928548a43408
equal deleted inserted replaced
35536:8bc68eee47dd 35606:d873b64009cc
   148 HeapWord** CompilerToVM::Data::_heap_top_addr;
   148 HeapWord** CompilerToVM::Data::_heap_top_addr;
   149 
   149 
   150 jbyte* CompilerToVM::Data::cardtable_start_address;
   150 jbyte* CompilerToVM::Data::cardtable_start_address;
   151 int CompilerToVM::Data::cardtable_shift;
   151 int CompilerToVM::Data::cardtable_shift;
   152 
   152 
       
   153 int CompilerToVM::Data::vm_page_size;
       
   154 
   153 void CompilerToVM::Data::initialize() {
   155 void CompilerToVM::Data::initialize() {
   154   InstanceKlass_vtable_start_offset = InstanceKlass::vtable_start_offset();
   156   InstanceKlass_vtable_start_offset = InstanceKlass::vtable_start_offset();
   155   InstanceKlass_vtable_length_offset = InstanceKlass::vtable_length_offset() * HeapWordSize;
   157   InstanceKlass_vtable_length_offset = InstanceKlass::vtable_length_offset() * HeapWordSize;
   156 
   158 
   157   Method_extra_stack_entries = Method::extra_stack_entries();
   159   Method_extra_stack_entries = Method::extra_stack_entries();
   197     break;
   199     break;
   198   default:
   200   default:
   199     ShouldNotReachHere();
   201     ShouldNotReachHere();
   200     break;
   202     break;
   201   }
   203   }
       
   204 
       
   205   vm_page_size = os::vm_page_size();
   202 }
   206 }
   203 
   207 
   204 /**
   208 /**
   205  * We put all jvmciHotSpotVM values in an array so we can read them easily from Java.
   209  * We put all jvmciHotSpotVM values in an array so we can read them easily from Java.
   206  */
   210  */
   833   HotSpotMetaData::set_exceptionBytes(metadata_handle, exceptionArrayOop());
   837   HotSpotMetaData::set_exceptionBytes(metadata_handle, exceptionArrayOop());
   834 
   838 
   835   return result;
   839   return result;
   836 C2V_END
   840 C2V_END
   837 
   841 
   838 C2V_VMENTRY(void, notifyCompilationStatistics, (JNIEnv *jniEnv, jobject, jint id, jobject hotspot_method, jboolean osr, jint processedBytecodes, jlong time, jlong timeUnitsPerSecond, jobject installed_code))
       
   839   JVMCICompiler* compiler = JVMCICompiler::instance(CHECK);
       
   840   CompilerStatistics* stats = compiler->stats();
       
   841 
       
   842   elapsedTimer timer = elapsedTimer(time, timeUnitsPerSecond);
       
   843   if (osr) {
       
   844     stats->_osr.update(timer, processedBytecodes);
       
   845   } else {
       
   846     stats->_standard.update(timer, processedBytecodes);
       
   847   }
       
   848   Handle installed_code_handle = JNIHandles::resolve(installed_code);
       
   849   if (installed_code_handle->is_a(HotSpotInstalledCode::klass())) {
       
   850     stats->_nmethods_size += HotSpotInstalledCode::size(installed_code_handle);
       
   851     stats->_nmethods_code_size += HotSpotInstalledCode::codeSize(installed_code_handle);
       
   852   }
       
   853 
       
   854   if (CITimeEach) {
       
   855     methodHandle method = CompilerToVM::asMethod(hotspot_method);
       
   856     float bytes_per_sec = 1.0 * processedBytecodes / timer.seconds();
       
   857     tty->print_cr("%3d   seconds: %f bytes/sec: %f (bytes %d)",
       
   858                   id, timer.seconds(), bytes_per_sec, processedBytecodes);
       
   859   }
       
   860 C2V_END
       
   861 
       
   862 C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject))
   842 C2V_VMENTRY(void, resetCompilationStatistics, (JNIEnv *jniEnv, jobject))
   863   JVMCICompiler* compiler = JVMCICompiler::instance(CHECK);
   843   JVMCICompiler* compiler = JVMCICompiler::instance(CHECK);
   864   CompilerStatistics* stats = compiler->stats();
   844   CompilerStatistics* stats = compiler->stats();
   865   stats->_standard.reset();
   845   stats->_standard.reset();
   866   stats->_osr.reset();
   846   stats->_osr.reset();
   896   if (cb->is_nmethod()) {
   876   if (cb->is_nmethod()) {
   897     nmethod* nm = (nmethod*) cb;
   877     nmethod* nm = (nmethod*) cb;
   898     if (!nm->is_alive()) {
   878     if (!nm->is_alive()) {
   899       return NULL;
   879       return NULL;
   900     }
   880     }
   901     Disassembler::decode(nm, &st);
   881   }
   902   } else {
   882   Disassembler::decode(cb, &st);
   903     Disassembler::decode(cb, &st);
       
   904   }
       
   905   if (st.size() <= 0) {
   883   if (st.size() <= 0) {
   906     return NULL;
   884     return NULL;
   907   }
   885   }
   908 
   886 
   909   Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL);
   887   Handle result = java_lang_String::create_from_platform_dependent_str(st.as_string(), CHECK_NULL);
  1389     }
  1367     }
  1390   }
  1368   }
  1391   THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Invalid profile data position %d", position));
  1369   THROW_MSG_0(vmSymbols::java_lang_IllegalArgumentException(), err_msg("Invalid profile data position %d", position));
  1392 C2V_END
  1370 C2V_END
  1393 
  1371 
       
  1372 C2V_VMENTRY(int, interpreterFrameSize, (JNIEnv*, jobject, jobject bytecode_frame_handle))
       
  1373   if (bytecode_frame_handle == NULL) {
       
  1374     THROW_0(vmSymbols::java_lang_NullPointerException());
       
  1375   }
       
  1376 
       
  1377   oop top_bytecode_frame = JNIHandles::resolve_non_null(bytecode_frame_handle);
       
  1378   oop bytecode_frame = top_bytecode_frame;
       
  1379   int size = 0;
       
  1380   int callee_parameters = 0;
       
  1381   int callee_locals = 0;
       
  1382   Method* method = getMethodFromHotSpotMethod(BytecodePosition::method(bytecode_frame));
       
  1383   int extra_args = method->max_stack() - BytecodeFrame::numStack(bytecode_frame);
       
  1384 
       
  1385   while (bytecode_frame != NULL) {
       
  1386     int locks = BytecodeFrame::numLocks(bytecode_frame);
       
  1387     int temps = BytecodeFrame::numStack(bytecode_frame);
       
  1388     bool is_top_frame = (bytecode_frame == top_bytecode_frame);
       
  1389     Method* method = getMethodFromHotSpotMethod(BytecodePosition::method(bytecode_frame));
       
  1390 
       
  1391     int frame_size = BytesPerWord * Interpreter::size_activation(method->max_stack(),
       
  1392                                                                  temps + callee_parameters,
       
  1393                                                                  extra_args,
       
  1394                                                                  locks,
       
  1395                                                                  callee_parameters,
       
  1396                                                                  callee_locals,
       
  1397                                                                  is_top_frame);
       
  1398     size += frame_size;
       
  1399 
       
  1400     callee_parameters = method->size_of_parameters();
       
  1401     callee_locals = method->max_locals();
       
  1402     extra_args = 0;
       
  1403     bytecode_frame = BytecodePosition::caller(bytecode_frame);
       
  1404   }
       
  1405   return size + Deoptimization::last_frame_adjust(0, callee_locals) * BytesPerWord;
       
  1406 C2V_END
       
  1407 
  1394 
  1408 
  1395 #define CC (char*)  /*cast a literal from (const char*)*/
  1409 #define CC (char*)  /*cast a literal from (const char*)*/
  1396 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
  1410 #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f))
  1397 
  1411 
  1398 #define STRING                "Ljava/lang/String;"
  1412 #define STRING                "Ljava/lang/String;"
  1399 #define OBJECT                "Ljava/lang/Object;"
  1413 #define OBJECT                "Ljava/lang/Object;"
  1400 #define CLASS                 "Ljava/lang/Class;"
  1414 #define CLASS                 "Ljava/lang/Class;"
  1401 #define STACK_TRACE_ELEMENT   "Ljava/lang/StackTraceElement;"
  1415 #define STACK_TRACE_ELEMENT   "Ljava/lang/StackTraceElement;"
  1402 #define INSTALLED_CODE        "Ljdk/vm/ci/code/InstalledCode;"
  1416 #define INSTALLED_CODE        "Ljdk/vm/ci/code/InstalledCode;"
  1403 #define TARGET_DESCRIPTION    "Ljdk/vm/ci/code/TargetDescription;"
  1417 #define TARGET_DESCRIPTION    "Ljdk/vm/ci/code/TargetDescription;"
       
  1418 #define BYTECODE_FRAME        "Ljdk/vm/ci/code/BytecodeFrame;"
  1404 #define RESOLVED_METHOD       "Ljdk/vm/ci/meta/ResolvedJavaMethod;"
  1419 #define RESOLVED_METHOD       "Ljdk/vm/ci/meta/ResolvedJavaMethod;"
  1405 #define HS_RESOLVED_METHOD    "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;"
  1420 #define HS_RESOLVED_METHOD    "Ljdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl;"
  1406 #define HS_RESOLVED_KLASS     "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;"
  1421 #define HS_RESOLVED_KLASS     "Ljdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl;"
  1407 #define HS_CONSTANT_POOL      "Ljdk/vm/ci/hotspot/HotSpotConstantPool;"
  1422 #define HS_CONSTANT_POOL      "Ljdk/vm/ci/hotspot/HotSpotConstantPool;"
  1408 #define HS_COMPILED_CODE      "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;"
  1423 #define HS_COMPILED_CODE      "Ljdk/vm/ci/hotspot/HotSpotCompiledCode;"
  1448   {CC"getConstantPool",                              CC"(Ljava/lang/Object;J)"HS_CONSTANT_POOL,                                        FN_PTR(getConstantPool)},
  1463   {CC"getConstantPool",                              CC"(Ljava/lang/Object;J)"HS_CONSTANT_POOL,                                        FN_PTR(getConstantPool)},
  1449   {CC"getResolvedJavaType",                          CC"(Ljava/lang/Object;JZ)"HS_RESOLVED_KLASS,                                      FN_PTR(getResolvedJavaType)},
  1464   {CC"getResolvedJavaType",                          CC"(Ljava/lang/Object;JZ)"HS_RESOLVED_KLASS,                                      FN_PTR(getResolvedJavaType)},
  1450   {CC"initializeConfiguration",                      CC"("HS_CONFIG")J",                                                               FN_PTR(initializeConfiguration)},
  1465   {CC"initializeConfiguration",                      CC"("HS_CONFIG")J",                                                               FN_PTR(initializeConfiguration)},
  1451   {CC"installCode",                                  CC"("TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG")I",   FN_PTR(installCode)},
  1466   {CC"installCode",                                  CC"("TARGET_DESCRIPTION HS_COMPILED_CODE INSTALLED_CODE HS_SPECULATION_LOG")I",   FN_PTR(installCode)},
  1452   {CC"getMetadata",                                  CC"("TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA")I",                         FN_PTR(getMetadata)},
  1467   {CC"getMetadata",                                  CC"("TARGET_DESCRIPTION HS_COMPILED_CODE HS_METADATA")I",                         FN_PTR(getMetadata)},
  1453   {CC"notifyCompilationStatistics",                  CC"(I"HS_RESOLVED_METHOD"ZIJJ"INSTALLED_CODE")V",                                 FN_PTR(notifyCompilationStatistics)},
       
  1454   {CC"resetCompilationStatistics",                   CC"()V",                                                                          FN_PTR(resetCompilationStatistics)},
  1468   {CC"resetCompilationStatistics",                   CC"()V",                                                                          FN_PTR(resetCompilationStatistics)},
  1455   {CC"disassembleCodeBlob",                          CC"("INSTALLED_CODE")"STRING,                                                     FN_PTR(disassembleCodeBlob)},
  1469   {CC"disassembleCodeBlob",                          CC"("INSTALLED_CODE")"STRING,                                                     FN_PTR(disassembleCodeBlob)},
  1456   {CC"executeInstalledCode",                         CC"(["OBJECT INSTALLED_CODE")"OBJECT,                                             FN_PTR(executeInstalledCode)},
  1470   {CC"executeInstalledCode",                         CC"(["OBJECT INSTALLED_CODE")"OBJECT,                                             FN_PTR(executeInstalledCode)},
  1457   {CC"getLineNumberTable",                           CC"("HS_RESOLVED_METHOD")[J",                                                     FN_PTR(getLineNumberTable)},
  1471   {CC"getLineNumberTable",                           CC"("HS_RESOLVED_METHOD")[J",                                                     FN_PTR(getLineNumberTable)},
  1458   {CC"getLocalVariableTableStart",                   CC"("HS_RESOLVED_METHOD")J",                                                      FN_PTR(getLocalVariableTableStart)},
  1472   {CC"getLocalVariableTableStart",                   CC"("HS_RESOLVED_METHOD")J",                                                      FN_PTR(getLocalVariableTableStart)},
  1469   {CC"materializeVirtualObjects",                    CC"("HS_STACK_FRAME_REF"Z)V",                                                     FN_PTR(materializeVirtualObjects)},
  1483   {CC"materializeVirtualObjects",                    CC"("HS_STACK_FRAME_REF"Z)V",                                                     FN_PTR(materializeVirtualObjects)},
  1470   {CC"shouldDebugNonSafepoints",                     CC"()Z",                                                                          FN_PTR(shouldDebugNonSafepoints)},
  1484   {CC"shouldDebugNonSafepoints",                     CC"()Z",                                                                          FN_PTR(shouldDebugNonSafepoints)},
  1471   {CC"writeDebugOutput",                             CC"([BII)V",                                                                      FN_PTR(writeDebugOutput)},
  1485   {CC"writeDebugOutput",                             CC"([BII)V",                                                                      FN_PTR(writeDebugOutput)},
  1472   {CC"flushDebugOutput",                             CC"()V",                                                                          FN_PTR(flushDebugOutput)},
  1486   {CC"flushDebugOutput",                             CC"()V",                                                                          FN_PTR(flushDebugOutput)},
  1473   {CC"methodDataProfileDataSize",                    CC"(JI)I",                                                                        FN_PTR(methodDataProfileDataSize)},
  1487   {CC"methodDataProfileDataSize",                    CC"(JI)I",                                                                        FN_PTR(methodDataProfileDataSize)},
       
  1488   {CC"interpreterFrameSize",                         CC"("BYTECODE_FRAME")I",                                                          FN_PTR(interpreterFrameSize)},
  1474 };
  1489 };
  1475 
  1490 
  1476 int CompilerToVM::methods_count() {
  1491 int CompilerToVM::methods_count() {
  1477   return sizeof(methods) / sizeof(JNINativeMethod);
  1492   return sizeof(methods) / sizeof(JNINativeMethod);
  1478 }
  1493 }