324 } else if (type->is_instance_klass()) {
325 type_is_also_shared = type->as_instance_klass()->is_shared();
326 } else {
327 // Currently there is no 'shared' query for array types.
328 type_is_also_shared = !ciObjectFactory::is_initialized();
329 }
330 if (!type_is_also_shared)
331 return type; // Bummer.
332 }
333 _type = type;
334 return type;
335 }
336
337
338 // ------------------------------------------------------------------
339 // ciField::will_link
340 //
341 // Can a specific access to this field be made without causing
342 // link errors?
343 bool ciField::will_link(ciInstanceKlass* accessing_klass,
344 Bytecodes::Code bc) {
345 VM_ENTRY_MARK;
346 assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
347 bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
348 "unexpected bytecode");
349
350 if (_offset == -1) {
351 // at creation we couldn't link to our holder so we need to
352 // maintain that stance, otherwise there's no safe way to use this
353 // ciField.
354 return false;
355 }
356
357 // Check for static/nonstatic mismatch
358 bool is_static = (bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic);
359 if (is_static != this->is_static()) {
360 return false;
361 }
362
363 // Get and put can have different accessibility rules
364 bool is_put = (bc == Bytecodes::_putfield || bc == Bytecodes::_putstatic);
365 if (is_put) {
366 if (_known_to_link_with_put == accessing_klass) {
367 return true;
368 }
369 } else {
370 if (_known_to_link_with_get == accessing_klass) {
371 return true;
372 }
373 }
374
375 LinkInfo link_info(_holder->get_instanceKlass(),
376 _name->get_symbol(), _signature->get_symbol(),
377 accessing_klass->get_Klass());
378 fieldDescriptor result;
379 LinkResolver::resolve_field(result, link_info, bc, false, KILL_COMPILE_ON_FATAL_(false));
380
381 // update the hit-cache, unless there is a problem with memory scoping:
382 if (accessing_klass->is_shared() || !is_shared()) {
383 if (is_put) {
384 _known_to_link_with_put = accessing_klass;
385 } else {
386 _known_to_link_with_get = accessing_klass;
387 }
388 }
389
390 return true;
391 }
392
393 // ------------------------------------------------------------------
394 // ciField::print
395 void ciField::print() {
396 tty->print("<ciField name=");
397 _holder->print_name();
|
324 } else if (type->is_instance_klass()) {
325 type_is_also_shared = type->as_instance_klass()->is_shared();
326 } else {
327 // Currently there is no 'shared' query for array types.
328 type_is_also_shared = !ciObjectFactory::is_initialized();
329 }
330 if (!type_is_also_shared)
331 return type; // Bummer.
332 }
333 _type = type;
334 return type;
335 }
336
337
338 // ------------------------------------------------------------------
339 // ciField::will_link
340 //
341 // Can a specific access to this field be made without causing
342 // link errors?
343 bool ciField::will_link(ciInstanceKlass* accessing_klass,
344 ciMethod* accessing_method,
345 Bytecodes::Code bc) {
346 VM_ENTRY_MARK;
347 assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
348 bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
349 "unexpected bytecode");
350
351 if (_offset == -1) {
352 // at creation we couldn't link to our holder so we need to
353 // maintain that stance, otherwise there's no safe way to use this
354 // ciField.
355 return false;
356 }
357
358 // Check for static/nonstatic mismatch
359 bool is_static = (bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic);
360 if (is_static != this->is_static()) {
361 return false;
362 }
363
364 // Get and put can have different accessibility rules
365 bool is_put = (bc == Bytecodes::_putfield || bc == Bytecodes::_putstatic);
366 if (is_put) {
367 if (_known_to_link_with_put == accessing_klass) {
368 return true;
369 }
370 } else {
371 if (_known_to_link_with_get == accessing_klass) {
372 return true;
373 }
374 }
375
376 LinkInfo link_info(_holder->get_instanceKlass(),
377 _name->get_symbol(), _signature->get_symbol(),
378 accessing_klass->get_Klass(), accessing_method->get_Method());
379 fieldDescriptor result;
380 LinkResolver::resolve_field(result, link_info, bc, false, KILL_COMPILE_ON_FATAL_(false));
381
382 // update the hit-cache, unless there is a problem with memory scoping:
383 if (accessing_klass->is_shared() || !is_shared()) {
384 if (is_put) {
385 _known_to_link_with_put = accessing_klass;
386 } else {
387 _known_to_link_with_get = accessing_klass;
388 }
389 }
390
391 return true;
392 }
393
394 // ------------------------------------------------------------------
395 // ciField::print
396 void ciField::print() {
397 tty->print("<ciField name=");
398 _holder->print_name();
|