Mercurial > hg > truffle
comparison src/share/vm/interpreter/rewriter.cpp @ 1660:083fde3b838e
6964498: JSR 292 invokedynamic sites need local bootstrap methods
Summary: Add JVM_CONSTANT_InvokeDynamic records to constant pool to determine per-instruction BSMs.
Reviewed-by: twisti
author | jrose |
---|---|
date | Thu, 15 Jul 2010 18:40:45 -0700 |
parents | 136b78722a08 |
children | 2d26b0046e0d f95d63e2154a |
comparison
equal
deleted
inserted
replaced
1649:a528509c992b | 1660:083fde3b838e |
---|---|
30 // Also computes a CP map (original_index -> new_index). | 30 // Also computes a CP map (original_index -> new_index). |
31 // Marks entries in CP which require additional processing. | 31 // Marks entries in CP which require additional processing. |
32 void Rewriter::compute_index_maps() { | 32 void Rewriter::compute_index_maps() { |
33 const int length = _pool->length(); | 33 const int length = _pool->length(); |
34 init_cp_map(length); | 34 init_cp_map(length); |
35 jint tag_mask = 0; | |
35 for (int i = 0; i < length; i++) { | 36 for (int i = 0; i < length; i++) { |
36 int tag = _pool->tag_at(i).value(); | 37 int tag = _pool->tag_at(i).value(); |
38 tag_mask |= (1 << tag); | |
37 switch (tag) { | 39 switch (tag) { |
38 case JVM_CONSTANT_InterfaceMethodref: | 40 case JVM_CONSTANT_InterfaceMethodref: |
39 case JVM_CONSTANT_Fieldref : // fall through | 41 case JVM_CONSTANT_Fieldref : // fall through |
40 case JVM_CONSTANT_Methodref : // fall through | 42 case JVM_CONSTANT_Methodref : // fall through |
41 case JVM_CONSTANT_MethodHandle : // fall through | 43 case JVM_CONSTANT_MethodHandle : // fall through |
42 case JVM_CONSTANT_MethodType : // fall through | 44 case JVM_CONSTANT_MethodType : // fall through |
45 case JVM_CONSTANT_InvokeDynamic : // fall through | |
43 add_cp_cache_entry(i); | 46 add_cp_cache_entry(i); |
44 break; | 47 break; |
45 } | 48 } |
46 } | 49 } |
47 | 50 |
48 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1), | 51 guarantee((int)_cp_cache_map.length()-1 <= (int)((u2)-1), |
49 "all cp cache indexes fit in a u2"); | 52 "all cp cache indexes fit in a u2"); |
53 | |
54 _have_invoke_dynamic = ((tag_mask & (1 << JVM_CONSTANT_InvokeDynamic)) != 0); | |
50 } | 55 } |
51 | 56 |
52 | 57 |
53 // Creates a constant pool cache given a CPC map | 58 // Creates a constant pool cache given a CPC map |
54 // This creates the constant pool cache initially in a state | 59 // This creates the constant pool cache initially in a state |
57 void Rewriter::make_constant_pool_cache(TRAPS) { | 62 void Rewriter::make_constant_pool_cache(TRAPS) { |
58 const int length = _cp_cache_map.length(); | 63 const int length = _cp_cache_map.length(); |
59 constantPoolCacheOop cache = | 64 constantPoolCacheOop cache = |
60 oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK); | 65 oopFactory::new_constantPoolCache(length, methodOopDesc::IsUnsafeConc, CHECK); |
61 cache->initialize(_cp_cache_map); | 66 cache->initialize(_cp_cache_map); |
67 | |
68 // Don't bother to the next pass if there is no JVM_CONSTANT_InvokeDynamic. | |
69 if (_have_invoke_dynamic) { | |
70 for (int i = 0; i < length; i++) { | |
71 int pool_index = cp_cache_entry_pool_index(i); | |
72 if (pool_index >= 0 && | |
73 _pool->tag_at(pool_index).is_invoke_dynamic()) { | |
74 int bsm_index = _pool->invoke_dynamic_bootstrap_method_ref_index_at(pool_index); | |
75 if (bsm_index != 0) { | |
76 assert(_pool->tag_at(bsm_index).is_method_handle(), "must be a MH constant"); | |
77 // There is a CP cache entry holding the BSM for these calls. | |
78 int bsm_cache_index = cp_entry_to_cp_cache(bsm_index); | |
79 cache->entry_at(i)->initialize_bootstrap_method_index_in_cache(bsm_cache_index); | |
80 } else { | |
81 // There is no CP cache entry holding the BSM for these calls. | |
82 // We will need to look for a class-global BSM, later. | |
83 guarantee(AllowTransitionalJSR292, ""); | |
84 } | |
85 } | |
86 } | |
87 } | |
88 | |
62 _pool->set_cache(cache); | 89 _pool->set_cache(cache); |
63 cache->set_constant_pool(_pool()); | 90 cache->set_constant_pool(_pool()); |
64 } | 91 } |
65 | 92 |
66 | 93 |