Mercurial > hg > graal-compiler
comparison src/share/vm/graal/graalCodeInstaller.cpp @ 15046:5c71dcf0915d
use hotspot static stubs for call sites
author | Tom Rodriguez <tom.rodriguez@oracle.com> |
---|---|
date | Wed, 09 Apr 2014 16:33:37 -0700 |
parents | db4254246f9a |
children | f24d578e63a9 |
comparison
equal
deleted
inserted
replaced
15045:0286888f792b | 15046:5c71dcf0915d |
---|---|
20 * or visit www.oracle.com if you need additional information or have any | 20 * or visit www.oracle.com if you need additional information or have any |
21 * questions. | 21 * questions. |
22 */ | 22 */ |
23 | 23 |
24 #include "precompiled.hpp" | 24 #include "precompiled.hpp" |
25 #include "code/compiledIC.hpp" | |
25 #include "compiler/compileBroker.hpp" | 26 #include "compiler/compileBroker.hpp" |
26 #include "compiler/disassembler.hpp" | 27 #include "compiler/disassembler.hpp" |
27 #include "runtime/javaCalls.hpp" | 28 #include "runtime/javaCalls.hpp" |
28 #include "graal/graalEnv.hpp" | 29 #include "graal/graalEnv.hpp" |
29 #include "graal/graalCompiler.hpp" | 30 #include "graal/graalCompiler.hpp" |
472 #endif | 473 #endif |
473 | 474 |
474 _next_call_type = INVOKE_INVALID; | 475 _next_call_type = INVOKE_INVALID; |
475 } | 476 } |
476 | 477 |
478 int CodeInstaller::estimate_stub_entries() { | |
479 // Estimate the number of static call stubs that might be emitted. | |
480 int static_call_stubs = 0; | |
481 for (int i = 0; i < _sites->length(); i++) { | |
482 oop site = ((objArrayOop) (_sites))->obj_at(i); | |
483 if (site->is_a(CompilationResult_Mark::klass())) { | |
484 oop id_obj = CompilationResult_Mark::id(site); | |
485 if (id_obj != NULL) { | |
486 assert(java_lang_boxing_object::is_instance(id_obj, T_INT), "Integer id expected"); | |
487 jint id = id_obj->int_field(java_lang_boxing_object::value_offset_in_bytes(T_INT)); | |
488 if (id == INVOKESTATIC || id == INVOKESPECIAL) { | |
489 static_call_stubs++; | |
490 } | |
491 } | |
492 } | |
493 } | |
494 return static_call_stubs; | |
495 } | |
496 | |
477 // perform data and call relocation on the CodeBuffer | 497 // perform data and call relocation on the CodeBuffer |
478 bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { | 498 bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { |
479 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); | 499 int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); |
480 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); | 500 char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); |
481 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); | 501 buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); |
482 buffer.initialize_stubs_size(256); | 502 // Allocate enough space in the stub section for the static call |
503 // stubs. Stubs have extra relocs but they are managed by the stub | |
504 // section itself so they don't need to be accounted for in the | |
505 // locs_buffer above. | |
506 buffer.initialize_stubs_size(estimate_stub_entries() * CompiledStaticCall::to_interp_stub_size()); | |
483 buffer.initialize_consts_size(_constants_size); | 507 buffer.initialize_consts_size(_constants_size); |
484 | 508 |
485 _debug_recorder = new DebugInformationRecorder(_oop_recorder); | 509 _debug_recorder = new DebugInformationRecorder(_oop_recorder); |
486 _debug_recorder->set_oopmaps(new OopMapSet()); | 510 _debug_recorder->set_oopmaps(new OopMapSet()); |
487 | 511 |
776 assert(hotspot_method != NULL, "unexpected JavaMethod"); | 800 assert(hotspot_method != NULL, "unexpected JavaMethod"); |
777 assert(debug_info != NULL, "debug info expected"); | 801 assert(debug_info != NULL, "debug info expected"); |
778 | 802 |
779 TRACE_graal_3("method call"); | 803 TRACE_graal_3("method call"); |
780 CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset); | 804 CodeInstaller::pd_relocate_JavaMethod(hotspot_method, pc_offset); |
805 if (_next_call_type == INVOKESTATIC || _next_call_type == INVOKESPECIAL) { | |
806 // Need a static call stub for transitions from compiled to interpreted. | |
807 CompiledStaticCall::emit_to_interp_stub(buffer, _instructions->start() + pc_offset); | |
808 } | |
781 } | 809 } |
782 | 810 |
783 _next_call_type = INVOKE_INVALID; | 811 _next_call_type = INVOKE_INVALID; |
784 | 812 |
785 if (debug_info != NULL) { | 813 if (debug_info != NULL) { |