comparison src/share/vm/ci/ciField.cpp @ 6275:957c266d8bc5

Merge with http://hg.openjdk.java.net/hsx/hsx24/hotspot/
author Doug Simon <doug.simon@oracle.com>
date Tue, 21 Aug 2012 10:39:19 +0200
parents 532be189cf09 aa07e41a9f80
children e522a00b91aa
comparison
equal deleted inserted replaced
5891:fd8832ae511d 6275:957c266d8bc5
1 /* 1 /*
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
65 // This adds at most one step to the binary search, an amount which 65 // This adds at most one step to the binary search, an amount which
66 // decreases for complex compilation tasks. 66 // decreases for complex compilation tasks.
67 67
68 // ------------------------------------------------------------------ 68 // ------------------------------------------------------------------
69 // ciField::ciField 69 // ciField::ciField
70 ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with(NULL) { 70 ciField::ciField(ciInstanceKlass* klass, int index): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
71 ASSERT_IN_VM; 71 ASSERT_IN_VM;
72 CompilerThread *thread = CompilerThread::current(); 72 CompilerThread *thread = CompilerThread::current();
73 73
74 assert(ciObjectFactory::is_initialized(), "not a shared field"); 74 assert(ciObjectFactory::is_initialized(), "not a shared field");
75 75
141 141
142 assert(canonical_holder == field_desc.field_holder(), "just checking"); 142 assert(canonical_holder == field_desc.field_holder(), "just checking");
143 initialize_from(&field_desc); 143 initialize_from(&field_desc);
144 } 144 }
145 145
146 ciField::ciField(fieldDescriptor *fd): _known_to_link_with(NULL) { 146 ciField::ciField(fieldDescriptor *fd): _known_to_link_with_put(NULL), _known_to_link_with_get(NULL) {
147 ASSERT_IN_VM; 147 ASSERT_IN_VM;
148 148
149 _cp_index = -1; 149 _cp_index = -1;
150 150
151 // Get the field's name, signature, and type. 151 // Get the field's name, signature, and type.
313 // Can a specific access to this field be made without causing 313 // Can a specific access to this field be made without causing
314 // link errors? 314 // link errors?
315 bool ciField::will_link(ciInstanceKlass* accessing_klass, 315 bool ciField::will_link(ciInstanceKlass* accessing_klass,
316 Bytecodes::Code bc) { 316 Bytecodes::Code bc) {
317 VM_ENTRY_MARK; 317 VM_ENTRY_MARK;
318 assert(bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic ||
319 bc == Bytecodes::_getfield || bc == Bytecodes::_putfield,
320 "unexpected bytecode");
321
318 if (_offset == -1) { 322 if (_offset == -1) {
319 // at creation we couldn't link to our holder so we need to 323 // at creation we couldn't link to our holder so we need to
320 // maintain that stance, otherwise there's no safe way to use this 324 // maintain that stance, otherwise there's no safe way to use this
321 // ciField. 325 // ciField.
322 return false; 326 return false;
323 } 327 }
324 328
325 if (_known_to_link_with == accessing_klass) { 329 // Check for static/nonstatic mismatch
326 return true; 330 bool is_static = (bc == Bytecodes::_getstatic || bc == Bytecodes::_putstatic);
331 if (is_static != this->is_static()) {
332 return false;
333 }
334
335 // Get and put can have different accessibility rules
336 bool is_put = (bc == Bytecodes::_putfield || bc == Bytecodes::_putstatic);
337 if (is_put) {
338 if (_known_to_link_with_put == accessing_klass) {
339 return true;
340 }
341 } else {
342 if (_known_to_link_with_get == accessing_klass) {
343 return true;
344 }
327 } 345 }
328 346
329 FieldAccessInfo result; 347 FieldAccessInfo result;
330 constantPoolHandle c_pool(THREAD, 348 constantPoolHandle c_pool(THREAD,
331 accessing_klass->get_instanceKlass()->constants()); 349 accessing_klass->get_instanceKlass()->constants());
332 LinkResolver::resolve_field(result, c_pool, _cp_index, 350 LinkResolver::resolve_field(result, c_pool, _cp_index,
333 Bytecodes::java_code(bc), 351 Bytecodes::java_code(bc),
334 true, false, KILL_COMPILE_ON_FATAL_(false)); 352 true, false, KILL_COMPILE_ON_FATAL_(false));
335 353
336 // update the hit-cache, unless there is a problem with memory scoping: 354 // update the hit-cache, unless there is a problem with memory scoping:
337 if (accessing_klass->is_shared() || !is_shared()) 355 if (accessing_klass->is_shared() || !is_shared()) {
338 _known_to_link_with = accessing_klass; 356 if (is_put) {
357 _known_to_link_with_put = accessing_klass;
358 } else {
359 _known_to_link_with_get = accessing_klass;
360 }
361 }
339 362
340 return true; 363 return true;
341 } 364 }
342 365
343 // ------------------------------------------------------------------ 366 // ------------------------------------------------------------------