Mercurial > hg > graal-jvmci-8
comparison src/share/vm/ci/ciField.cpp @ 6151:e778c29768e6
7152811: Issues in client compiler
Reviewed-by: kvn, jrose
author | never |
---|---|
date | Wed, 04 Apr 2012 20:44:38 -0700 |
parents | ddd894528dbc |
children | aa07e41a9f80 |
comparison
equal
deleted
inserted
replaced
6150:1e76463170b3 | 6151:e778c29768e6 |
---|---|
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 if (_known_to_link_with_get == accessing_klass) { | |
342 return true; | |
343 } | |
327 } | 344 } |
328 | 345 |
329 FieldAccessInfo result; | 346 FieldAccessInfo result; |
330 constantPoolHandle c_pool(THREAD, | 347 constantPoolHandle c_pool(THREAD, |
331 accessing_klass->get_instanceKlass()->constants()); | 348 accessing_klass->get_instanceKlass()->constants()); |
332 LinkResolver::resolve_field(result, c_pool, _cp_index, | 349 LinkResolver::resolve_field(result, c_pool, _cp_index, |
333 Bytecodes::java_code(bc), | 350 Bytecodes::java_code(bc), |
334 true, false, KILL_COMPILE_ON_FATAL_(false)); | 351 true, false, KILL_COMPILE_ON_FATAL_(false)); |
335 | 352 |
336 // update the hit-cache, unless there is a problem with memory scoping: | 353 // update the hit-cache, unless there is a problem with memory scoping: |
337 if (accessing_klass->is_shared() || !is_shared()) | 354 if (accessing_klass->is_shared() || !is_shared()) { |
338 _known_to_link_with = accessing_klass; | 355 if (is_put) { |
356 _known_to_link_with_put = accessing_klass; | |
357 } else { | |
358 _known_to_link_with_get = accessing_klass; | |
359 } | |
360 } | |
339 | 361 |
340 return true; | 362 return true; |
341 } | 363 } |
342 | 364 |
343 // ------------------------------------------------------------------ | 365 // ------------------------------------------------------------------ |