< prev index next >

src/hotspot/share/interpreter/linkResolver.hpp

Print this page

172     _current_method = current_method;
173   }
174 
175   // Case where we just find the method and don't check access against the current class, used by JavaCalls
176   LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) :
177     LinkInfo(resolved_klass, name, signature, nullptr, AccessCheck::skip, LoaderConstraintCheck::skip,
178              JVM_CONSTANT_Invalid) {}
179 
180   // accessors
181   Symbol* name() const                  { return _name; }
182   Symbol* signature() const             { return _signature; }
183   Klass* resolved_klass() const         { return _resolved_klass; }
184   Klass* current_klass() const          { return _current_klass; }
185   Method* current_method() const        { return _current_method(); }
186   constantTag tag() const               { return _tag; }
187   bool check_access() const             { return _check_access; }
188   bool check_loader_constraints() const { return _check_loader_constraints; }
189   void         print()  PRODUCT_RETURN;
190 };
191 






192 // Link information for getfield/putfield & getstatic/putstatic bytecodes
193 // is represented using a fieldDescriptor.
194 
195 // The LinkResolver is used to resolve constant-pool references at run-time.
196 // It does all necessary link-time checks & throws exceptions if necessary.
197 
198 class LinkResolver: AllStatic {
199   friend class klassVtable;
200   friend class klassItable;
201 
202  private:
203 
204   static Method* lookup_method_in_klasses(const LinkInfo& link_info,
205                                           bool checkpolymorphism,
206                                           bool in_imethod_resolve);
207   static Method* lookup_method_in_interfaces(const LinkInfo& link_info);
208 
209   static Method* lookup_polymorphic_method(const LinkInfo& link_info,
210                                            Handle *appendix_result_or_null, TRAPS);
211  JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()

250                                                  Klass* recv_klass,
251                                                  bool check_null_and_abstract,
252                                                  bool is_abstract_interpretation, TRAPS);
253 
254   static bool resolve_previously_linked_invokehandle(CallInfo& result,
255                                                      const LinkInfo& link_info,
256                                                      const constantPoolHandle& pool,
257                                                      int index, TRAPS);
258 
259   static void check_field_accessability(Klass* ref_klass,
260                                         Klass* resolved_klass,
261                                         Klass* sel_klass,
262                                         const fieldDescriptor& fd, TRAPS);
263   static void check_method_accessability(Klass* ref_klass,
264                                          Klass* resolved_klass,
265                                          Klass* sel_klass,
266                                          const methodHandle& sel_method, TRAPS);
267 
268   // runtime resolving from constant pool
269   static void resolve_invokestatic   (CallInfo& result,
270                                       const constantPoolHandle& pool, int index, TRAPS);
271   static void resolve_invokespecial  (CallInfo& result, Handle recv,
272                                       const constantPoolHandle& pool, int index, TRAPS);
273   static void resolve_invokevirtual  (CallInfo& result, Handle recv,
274                                       const constantPoolHandle& pool, int index, TRAPS);
275   static void resolve_invokeinterface(CallInfo& result, Handle recv,
276                                       const constantPoolHandle& pool, int index, TRAPS);
277   static void resolve_invokedynamic  (CallInfo& result,
278                                       const constantPoolHandle& pool, int index, TRAPS);
279   static void resolve_invokehandle   (CallInfo& result,
280                                       const constantPoolHandle& pool, int index, TRAPS);
281  public:
282   // constant pool resolving
283   static void check_klass_accessibility(Klass* ref_klass, Klass* sel_klass, TRAPS);
284 
285   // static resolving calls (will not run any Java code);
286   // used only from Bytecode_invoke::static_target
287   static Method* resolve_method_statically(Bytecodes::Code code,
288                                            const constantPoolHandle& pool,
289                                            int index, TRAPS);
290 
291   static void resolve_continuation_enter(CallInfo& callinfo, TRAPS);
292 
293   static void resolve_field_access(fieldDescriptor& result,
294                                    const constantPoolHandle& pool,
295                                    int index,
296                                    const methodHandle& method,
297                                    Bytecodes::Code byte,
298                                    bool initialize_class, TRAPS);
299   static void resolve_field_access(fieldDescriptor& result,
300                                    const constantPoolHandle& pool,
301                                    int index,
302                                    const methodHandle& method,
303                                    Bytecodes::Code byte, TRAPS) {
304     resolve_field_access(result, pool, index, method, byte,
305                          /* initialize_class*/true, THREAD);
306   }
307   static void resolve_field(fieldDescriptor& result, const LinkInfo& link_info,
308                             Bytecodes::Code access_kind,
309                             bool initialize_class, TRAPS);
310 
311   static void resolve_static_call   (CallInfo& result,
312                                      const LinkInfo& link_info,
313                                      bool initialize_klass, TRAPS);
314   static void resolve_special_call  (CallInfo& result,
315                                      Handle recv,
316                                      const LinkInfo& link_info,
317                                      TRAPS);
318   static void resolve_virtual_call  (CallInfo& result, Handle recv, Klass* recv_klass,
319                                      const LinkInfo& link_info,
320                                      bool check_null_and_abstract, TRAPS);
321   static void resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass,
322                                      const LinkInfo& link_info,
323                                      bool check_null_and_abstract, TRAPS);
324   static void resolve_handle_call   (CallInfo& result,
325                                      const LinkInfo& link_info, TRAPS);
326   static void resolve_dynamic_call  (CallInfo& result,
327                                      BootstrapInfo& bootstrap_specifier, TRAPS);
328 
329   static void cds_resolve_virtual_call  (CallInfo& result, const LinkInfo& link_info, TRAPS);
330   static void cds_resolve_interface_call(CallInfo& result, const LinkInfo& link_info, TRAPS);
331   static void cds_resolve_special_call  (CallInfo& result, const LinkInfo& link_info, TRAPS);
332 
333   // same as above for compile-time resolution; but returns null handle instead of throwing

335   static Method* resolve_virtual_call_or_null(Klass* receiver_klass,
336                                               const LinkInfo& link_info);
337   static Method* resolve_interface_call_or_null(Klass* receiver_klass,
338                                                 const LinkInfo& link_info);
339   static Method* resolve_static_call_or_null(const LinkInfo& link_info);
340   static Method* resolve_special_call_or_null(const LinkInfo& link_info);
341 
342   static int vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method);
343 
344   // same as above for compile-time resolution; returns vtable_index if current_klass if linked
345   static int resolve_virtual_vtable_index  (Klass* receiver_klass,
346                                             const LinkInfo& link_info);
347 
348   // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful)
349   static Method* linktime_resolve_virtual_method_or_null  (const LinkInfo& link_info);
350   static Method* linktime_resolve_interface_method_or_null(const LinkInfo& link_info);
351 
352   // runtime resolving from constant pool
353   static void resolve_invoke(CallInfo& result, Handle recv,
354                              const constantPoolHandle& pool, int index,
355                              Bytecodes::Code byte, TRAPS);





356 
357   // runtime resolving from attached method
358   static void resolve_invoke(CallInfo& result, Handle& recv,
359                              const methodHandle& attached_method,
360                              Bytecodes::Code byte, TRAPS);
361 
362   // Only resolved method known.
363   static void throw_abstract_method_error(const methodHandle& resolved_method, TRAPS) {
364     throw_abstract_method_error(resolved_method, methodHandle(), nullptr, CHECK);
365   }
366   // Resolved method and receiver klass know.
367   static void throw_abstract_method_error(const methodHandle& resolved_method, Klass *recv_klass, TRAPS) {
368     throw_abstract_method_error(resolved_method, methodHandle(), recv_klass, CHECK);
369   }
370   // Selected method is abstract.
371   static void throw_abstract_method_error(const methodHandle& resolved_method,
372                                           const methodHandle& selected_method,
373                                           Klass *recv_klass, TRAPS);
374 };
375 #endif // SHARE_INTERPRETER_LINKRESOLVER_HPP

172     _current_method = current_method;
173   }
174 
175   // Case where we just find the method and don't check access against the current class, used by JavaCalls
176   LinkInfo(Klass* resolved_klass, Symbol*name, Symbol* signature) :
177     LinkInfo(resolved_klass, name, signature, nullptr, AccessCheck::skip, LoaderConstraintCheck::skip,
178              JVM_CONSTANT_Invalid) {}
179 
180   // accessors
181   Symbol* name() const                  { return _name; }
182   Symbol* signature() const             { return _signature; }
183   Klass* resolved_klass() const         { return _resolved_klass; }
184   Klass* current_klass() const          { return _current_klass; }
185   Method* current_method() const        { return _current_method(); }
186   constantTag tag() const               { return _tag; }
187   bool check_access() const             { return _check_access; }
188   bool check_loader_constraints() const { return _check_loader_constraints; }
189   void         print()  PRODUCT_RETURN;
190 };
191 
192 enum class StaticMode : uint8_t {
193   dont_initialize_klass,
194   initialize_klass,
195   initialize_klass_preemptable
196 };
197 
198 // Link information for getfield/putfield & getstatic/putstatic bytecodes
199 // is represented using a fieldDescriptor.
200 
201 // The LinkResolver is used to resolve constant-pool references at run-time.
202 // It does all necessary link-time checks & throws exceptions if necessary.
203 
204 class LinkResolver: AllStatic {
205   friend class klassVtable;
206   friend class klassItable;
207 
208  private:
209 
210   static Method* lookup_method_in_klasses(const LinkInfo& link_info,
211                                           bool checkpolymorphism,
212                                           bool in_imethod_resolve);
213   static Method* lookup_method_in_interfaces(const LinkInfo& link_info);
214 
215   static Method* lookup_polymorphic_method(const LinkInfo& link_info,
216                                            Handle *appendix_result_or_null, TRAPS);
217  JVMCI_ONLY(public:) // Needed for CompilerToVM.resolveMethod()

256                                                  Klass* recv_klass,
257                                                  bool check_null_and_abstract,
258                                                  bool is_abstract_interpretation, TRAPS);
259 
260   static bool resolve_previously_linked_invokehandle(CallInfo& result,
261                                                      const LinkInfo& link_info,
262                                                      const constantPoolHandle& pool,
263                                                      int index, TRAPS);
264 
265   static void check_field_accessability(Klass* ref_klass,
266                                         Klass* resolved_klass,
267                                         Klass* sel_klass,
268                                         const fieldDescriptor& fd, TRAPS);
269   static void check_method_accessability(Klass* ref_klass,
270                                          Klass* resolved_klass,
271                                          Klass* sel_klass,
272                                          const methodHandle& sel_method, TRAPS);
273 
274   // runtime resolving from constant pool
275   static void resolve_invokestatic   (CallInfo& result,
276                                       const constantPoolHandle& pool, int index, StaticMode mode, TRAPS);
277   static void resolve_invokespecial  (CallInfo& result, Handle recv,
278                                       const constantPoolHandle& pool, int index, TRAPS);
279   static void resolve_invokevirtual  (CallInfo& result, Handle recv,
280                                       const constantPoolHandle& pool, int index, TRAPS);
281   static void resolve_invokeinterface(CallInfo& result, Handle recv,
282                                       const constantPoolHandle& pool, int index, TRAPS);
283   static void resolve_invokedynamic  (CallInfo& result,
284                                       const constantPoolHandle& pool, int index, TRAPS);
285   static void resolve_invokehandle   (CallInfo& result,
286                                       const constantPoolHandle& pool, int index, TRAPS);
287  public:
288   // constant pool resolving
289   static void check_klass_accessibility(Klass* ref_klass, Klass* sel_klass, TRAPS);
290 
291   // static resolving calls (will not run any Java code);
292   // used only from Bytecode_invoke::static_target
293   static Method* resolve_method_statically(Bytecodes::Code code,
294                                            const constantPoolHandle& pool,
295                                            int index, TRAPS);
296 
297   static void resolve_continuation_enter(CallInfo& callinfo, TRAPS);
298 
299   static void resolve_field_access(fieldDescriptor& result,
300                                    const constantPoolHandle& pool,
301                                    int index,
302                                    const methodHandle& method,
303                                    Bytecodes::Code byte,
304                                    StaticMode mode, TRAPS);
305   static void resolve_field_access(fieldDescriptor& result,
306                                    const constantPoolHandle& pool,
307                                    int index,
308                                    const methodHandle& method,
309                                    Bytecodes::Code byte, TRAPS) {
310     resolve_field_access(result, pool, index, method, byte,
311                          StaticMode::initialize_klass, THREAD);
312   }
313   static void resolve_field(fieldDescriptor& result, const LinkInfo& link_info,
314                             Bytecodes::Code access_kind,
315                             StaticMode mode, TRAPS);
316 
317   static void resolve_static_call   (CallInfo& result,
318                                      const LinkInfo& link_info,
319                                      StaticMode mode, TRAPS);
320   static void resolve_special_call  (CallInfo& result,
321                                      Handle recv,
322                                      const LinkInfo& link_info,
323                                      TRAPS);
324   static void resolve_virtual_call  (CallInfo& result, Handle recv, Klass* recv_klass,
325                                      const LinkInfo& link_info,
326                                      bool check_null_and_abstract, TRAPS);
327   static void resolve_interface_call(CallInfo& result, Handle recv, Klass* recv_klass,
328                                      const LinkInfo& link_info,
329                                      bool check_null_and_abstract, TRAPS);
330   static void resolve_handle_call   (CallInfo& result,
331                                      const LinkInfo& link_info, TRAPS);
332   static void resolve_dynamic_call  (CallInfo& result,
333                                      BootstrapInfo& bootstrap_specifier, TRAPS);
334 
335   static void cds_resolve_virtual_call  (CallInfo& result, const LinkInfo& link_info, TRAPS);
336   static void cds_resolve_interface_call(CallInfo& result, const LinkInfo& link_info, TRAPS);
337   static void cds_resolve_special_call  (CallInfo& result, const LinkInfo& link_info, TRAPS);
338 
339   // same as above for compile-time resolution; but returns null handle instead of throwing

341   static Method* resolve_virtual_call_or_null(Klass* receiver_klass,
342                                               const LinkInfo& link_info);
343   static Method* resolve_interface_call_or_null(Klass* receiver_klass,
344                                                 const LinkInfo& link_info);
345   static Method* resolve_static_call_or_null(const LinkInfo& link_info);
346   static Method* resolve_special_call_or_null(const LinkInfo& link_info);
347 
348   static int vtable_index_of_interface_method(Klass* klass, const methodHandle& resolved_method);
349 
350   // same as above for compile-time resolution; returns vtable_index if current_klass if linked
351   static int resolve_virtual_vtable_index  (Klass* receiver_klass,
352                                             const LinkInfo& link_info);
353 
354   // static resolving for compiler (does not throw exceptions, returns null handle if unsuccessful)
355   static Method* linktime_resolve_virtual_method_or_null  (const LinkInfo& link_info);
356   static Method* linktime_resolve_interface_method_or_null(const LinkInfo& link_info);
357 
358   // runtime resolving from constant pool
359   static void resolve_invoke(CallInfo& result, Handle recv,
360                              const constantPoolHandle& pool, int index,
361                              Bytecodes::Code byte, StaticMode static_mode, TRAPS);
362   static void resolve_invoke(CallInfo& result, Handle recv,
363                              const constantPoolHandle& pool, int index,
364                              Bytecodes::Code byte, TRAPS) {
365     resolve_invoke(result, recv, pool, index, byte, StaticMode::initialize_klass, THREAD);
366   }
367 
368   // runtime resolving from attached method
369   static void resolve_invoke(CallInfo& result, Handle& recv,
370                              const methodHandle& attached_method,
371                              Bytecodes::Code byte, TRAPS);
372 
373   // Only resolved method known.
374   static void throw_abstract_method_error(const methodHandle& resolved_method, TRAPS) {
375     throw_abstract_method_error(resolved_method, methodHandle(), nullptr, CHECK);
376   }
377   // Resolved method and receiver klass know.
378   static void throw_abstract_method_error(const methodHandle& resolved_method, Klass *recv_klass, TRAPS) {
379     throw_abstract_method_error(resolved_method, methodHandle(), recv_klass, CHECK);
380   }
381   // Selected method is abstract.
382   static void throw_abstract_method_error(const methodHandle& resolved_method,
383                                           const methodHandle& selected_method,
384                                           Klass *recv_klass, TRAPS);
385 };
386 #endif // SHARE_INTERPRETER_LINKRESOLVER_HPP
< prev index next >