1 /*
2 * Copyright 1997-2009 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
304 #ifdef _LP64
305 intptr_t NativeMovConstReg::data() const {
306 return data64(addr_at(sethi_offset), long_at(add_offset));
307 }
308 #else
309 intptr_t NativeMovConstReg::data() const {
310 return data32(long_at(sethi_offset), long_at(add_offset));
311 }
312 #endif
313
314
315 void NativeMovConstReg::set_data(intptr_t x) {
316 #ifdef _LP64
317 set_data64_sethi(addr_at(sethi_offset), x);
318 #else
319 set_long_at(sethi_offset, set_data32_sethi( long_at(sethi_offset), x));
320 #endif
321 set_long_at(add_offset, set_data32_simm13( long_at(add_offset), x));
322
323 // also store the value into an oop_Relocation cell, if any
324 CodeBlob* nm = CodeCache::find_blob(instruction_address());
325 if (nm != NULL) {
326 RelocIterator iter(nm, instruction_address(), next_instruction_address());
327 oop* oop_addr = NULL;
328 while (iter.next()) {
329 if (iter.type() == relocInfo::oop_type) {
330 oop_Relocation *r = iter.oop_reloc();
331 if (oop_addr == NULL) {
332 oop_addr = r->oop_addr();
333 *oop_addr = (oop)x;
334 } else {
335 assert(oop_addr == r->oop_addr(), "must be only one set-oop here");
336 }
337 }
338 }
339 }
340 }
341
342
343 // Code for unit testing implementation of NativeMovConstReg class
344 void NativeMovConstReg::test() {
345 #ifdef ASSERT
413
414
415 int NativeMovConstRegPatching::data() const {
416 #ifdef _LP64
417 return data64(addr_at(sethi_offset), long_at(add_offset));
418 #else
419 return data32(long_at(sethi_offset), long_at(add_offset));
420 #endif
421 }
422
423
424 void NativeMovConstRegPatching::set_data(int x) {
425 #ifdef _LP64
426 set_data64_sethi(addr_at(sethi_offset), x);
427 #else
428 set_long_at(sethi_offset, set_data32_sethi(long_at(sethi_offset), x));
429 #endif
430 set_long_at(add_offset, set_data32_simm13(long_at(add_offset), x));
431
432 // also store the value into an oop_Relocation cell, if any
433 CodeBlob* nm = CodeCache::find_blob(instruction_address());
434 if (nm != NULL) {
435 RelocIterator iter(nm, instruction_address(), next_instruction_address());
436 oop* oop_addr = NULL;
437 while (iter.next()) {
438 if (iter.type() == relocInfo::oop_type) {
439 oop_Relocation *r = iter.oop_reloc();
440 if (oop_addr == NULL) {
441 oop_addr = r->oop_addr();
442 *oop_addr = (oop)x;
443 } else {
444 assert(oop_addr == r->oop_addr(), "must be only one set-oop here");
445 }
446 }
447 }
448 }
449 }
450
451
452 // Code for unit testing implementation of NativeMovConstRegPatching class
453 void NativeMovConstRegPatching::test() {
454 #ifdef ASSERT
|
1 /*
2 * Copyright 1997-2010 Sun Microsystems, Inc. All Rights Reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
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
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
304 #ifdef _LP64
305 intptr_t NativeMovConstReg::data() const {
306 return data64(addr_at(sethi_offset), long_at(add_offset));
307 }
308 #else
309 intptr_t NativeMovConstReg::data() const {
310 return data32(long_at(sethi_offset), long_at(add_offset));
311 }
312 #endif
313
314
315 void NativeMovConstReg::set_data(intptr_t x) {
316 #ifdef _LP64
317 set_data64_sethi(addr_at(sethi_offset), x);
318 #else
319 set_long_at(sethi_offset, set_data32_sethi( long_at(sethi_offset), x));
320 #endif
321 set_long_at(add_offset, set_data32_simm13( long_at(add_offset), x));
322
323 // also store the value into an oop_Relocation cell, if any
324 CodeBlob* cb = CodeCache::find_blob(instruction_address());
325 if (cb != NULL) {
326 nmethod* nm = cb->as_nmethod_or_null();
327 assert(nm, "must be");
328 RelocIterator iter(nm, instruction_address(), next_instruction_address());
329 oop* oop_addr = NULL;
330 while (iter.next()) {
331 if (iter.type() == relocInfo::oop_type) {
332 oop_Relocation *r = iter.oop_reloc();
333 if (oop_addr == NULL) {
334 oop_addr = r->oop_addr();
335 *oop_addr = (oop)x;
336 } else {
337 assert(oop_addr == r->oop_addr(), "must be only one set-oop here");
338 }
339 }
340 }
341 }
342 }
343
344
345 // Code for unit testing implementation of NativeMovConstReg class
346 void NativeMovConstReg::test() {
347 #ifdef ASSERT
415
416
417 int NativeMovConstRegPatching::data() const {
418 #ifdef _LP64
419 return data64(addr_at(sethi_offset), long_at(add_offset));
420 #else
421 return data32(long_at(sethi_offset), long_at(add_offset));
422 #endif
423 }
424
425
426 void NativeMovConstRegPatching::set_data(int x) {
427 #ifdef _LP64
428 set_data64_sethi(addr_at(sethi_offset), x);
429 #else
430 set_long_at(sethi_offset, set_data32_sethi(long_at(sethi_offset), x));
431 #endif
432 set_long_at(add_offset, set_data32_simm13(long_at(add_offset), x));
433
434 // also store the value into an oop_Relocation cell, if any
435 CodeBlob* cb = CodeCache::find_blob(instruction_address());
436 if (cb != NULL) {
437 nmethod* nm = cb->as_nmethod_or_null();
438 assert(nm, "must be");
439 RelocIterator iter(nm, instruction_address(), next_instruction_address());
440 oop* oop_addr = NULL;
441 while (iter.next()) {
442 if (iter.type() == relocInfo::oop_type) {
443 oop_Relocation *r = iter.oop_reloc();
444 if (oop_addr == NULL) {
445 oop_addr = r->oop_addr();
446 *oop_addr = (oop)x;
447 } else {
448 assert(oop_addr == r->oop_addr(), "must be only one set-oop here");
449 }
450 }
451 }
452 }
453 }
454
455
456 // Code for unit testing implementation of NativeMovConstRegPatching class
457 void NativeMovConstRegPatching::test() {
458 #ifdef ASSERT
|