< prev index next >

src/share/vm/shark/sharkIntrinsics.cpp

Print this page
rev 12711 : 8181292: Backport Rename internal Unsafe.compare methods from 10 to 9
Reviewed-by: psandoz, dholmes, thartmann
Contributed-by: ron.pressler@oracle.com, claes.redestad@oracle.com
   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2009 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


  49   case vmIntrinsics::_dsqrt:
  50   case vmIntrinsics::_dlog:
  51   case vmIntrinsics::_dlog10:
  52   case vmIntrinsics::_dpow:
  53   case vmIntrinsics::_dexp:
  54     return true;
  55 
  56     // java.lang.Object
  57   case vmIntrinsics::_getClass:
  58     return true;
  59 
  60     // java.lang.System
  61   case vmIntrinsics::_currentTimeMillis:
  62     return true;
  63 
  64     // java.lang.Thread
  65   case vmIntrinsics::_currentThread:
  66     return true;
  67 
  68     // Unsafe
  69   case vmIntrinsics::_compareAndSwapInt:
  70     return true;
  71 
  72   default:
  73     if (SharkPerformanceWarnings) {
  74       warning(
  75         "unhandled intrinsic vmIntrinsic::%s",
  76         vmIntrinsics::name_at(target->intrinsic_id()));
  77     }
  78   }
  79   return false;
  80 }
  81 
  82 void SharkIntrinsics::inline_intrinsic(ciMethod *target, SharkState *state) {
  83   SharkIntrinsics intrinsic(state, target);
  84   intrinsic.do_intrinsic();
  85 }
  86 
  87 void SharkIntrinsics::do_intrinsic() {
  88   switch (target()->intrinsic_id()) {
  89     // java.lang.Math


 123   case vmIntrinsics::_dexp:
 124     do_Math_1to1(builder()->exp());
 125     break;
 126 
 127     // java.lang.Object
 128   case vmIntrinsics::_getClass:
 129     do_Object_getClass();
 130     break;
 131 
 132     // java.lang.System
 133   case vmIntrinsics::_currentTimeMillis:
 134     do_System_currentTimeMillis();
 135     break;
 136 
 137     // java.lang.Thread
 138   case vmIntrinsics::_currentThread:
 139     do_Thread_currentThread();
 140     break;
 141 
 142     // Unsafe
 143   case vmIntrinsics::_compareAndSwapInt:
 144     do_Unsafe_compareAndSwapInt();
 145     break;
 146 
 147   default:
 148     ShouldNotReachHere();
 149   }
 150 }
 151 
 152 void SharkIntrinsics::do_Math_minmax(ICmpInst::Predicate p) {
 153   // Pop the arguments
 154   SharkValue *sb = state()->pop();
 155   SharkValue *sa = state()->pop();
 156   Value *a = sa->jint_value();
 157   Value *b = sb->jint_value();
 158 
 159   // Perform the test
 160   BasicBlock *ip       = builder()->GetBlockInsertionPoint();
 161   BasicBlock *return_a = builder()->CreateBlock(ip, "return_a");
 162   BasicBlock *return_b = builder()->CreateBlock(ip, "return_b");
 163   BasicBlock *done     = builder()->CreateBlock(ip, "done");
 164 


 224 }
 225 
 226 void SharkIntrinsics::do_System_currentTimeMillis() {
 227   state()->push(
 228     SharkValue::create_jlong(
 229       builder()->CreateCall(builder()->current_time_millis()),
 230       false));
 231   state()->push(NULL);
 232 }
 233 
 234 void SharkIntrinsics::do_Thread_currentThread() {
 235   state()->push(
 236     SharkValue::create_jobject(
 237       builder()->CreateValueOfStructEntry(
 238         thread(), JavaThread::threadObj_offset(),
 239         SharkType::oop_type(),
 240         "threadObj"),
 241       true));
 242 }
 243 
 244 void SharkIntrinsics::do_Unsafe_compareAndSwapInt() {
 245   // Pop the arguments
 246   Value *x      = state()->pop()->jint_value();
 247   Value *e      = state()->pop()->jint_value();
 248   SharkValue *empty = state()->pop();
 249   assert(empty == NULL, "should be");
 250   Value *offset = state()->pop()->jlong_value();
 251   Value *object = state()->pop()->jobject_value();
 252   Value *unsafe = state()->pop()->jobject_value();
 253 
 254   // Convert the offset
 255   offset = builder()->CreateCall(
 256     builder()->unsafe_field_offset_to_byte_offset(),
 257     offset);
 258 
 259   // Locate the field
 260   Value *addr = builder()->CreateIntToPtr(
 261     builder()->CreateAdd(
 262       builder()->CreatePtrToInt(object, SharkType::intptr_type()),
 263       builder()->CreateIntCast(offset, SharkType::intptr_type(), true)),
 264     PointerType::getUnqual(SharkType::jint_type()),
   1 /*
   2  * Copyright (c) 1999, 2017, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2009 Red Hat, Inc.
   4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   5  *
   6  * This code is free software; you can redistribute it and/or modify it
   7  * under the terms of the GNU General Public License version 2 only, as
   8  * published by the Free Software Foundation.
   9  *
  10  * This code is distributed in the hope that it will be useful, but WITHOUT
  11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13  * version 2 for more details (a copy is included in the LICENSE file that
  14  * accompanied this code).
  15  *
  16  * You should have received a copy of the GNU General Public License version
  17  * 2 along with this work; if not, write to the Free Software Foundation,
  18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  19  *
  20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  21  * or visit www.oracle.com if you need additional information or have any
  22  * questions.


  49   case vmIntrinsics::_dsqrt:
  50   case vmIntrinsics::_dlog:
  51   case vmIntrinsics::_dlog10:
  52   case vmIntrinsics::_dpow:
  53   case vmIntrinsics::_dexp:
  54     return true;
  55 
  56     // java.lang.Object
  57   case vmIntrinsics::_getClass:
  58     return true;
  59 
  60     // java.lang.System
  61   case vmIntrinsics::_currentTimeMillis:
  62     return true;
  63 
  64     // java.lang.Thread
  65   case vmIntrinsics::_currentThread:
  66     return true;
  67 
  68     // Unsafe
  69   case vmIntrinsics::_compareAndSetInt:
  70     return true;
  71 
  72   default:
  73     if (SharkPerformanceWarnings) {
  74       warning(
  75         "unhandled intrinsic vmIntrinsic::%s",
  76         vmIntrinsics::name_at(target->intrinsic_id()));
  77     }
  78   }
  79   return false;
  80 }
  81 
  82 void SharkIntrinsics::inline_intrinsic(ciMethod *target, SharkState *state) {
  83   SharkIntrinsics intrinsic(state, target);
  84   intrinsic.do_intrinsic();
  85 }
  86 
  87 void SharkIntrinsics::do_intrinsic() {
  88   switch (target()->intrinsic_id()) {
  89     // java.lang.Math


 123   case vmIntrinsics::_dexp:
 124     do_Math_1to1(builder()->exp());
 125     break;
 126 
 127     // java.lang.Object
 128   case vmIntrinsics::_getClass:
 129     do_Object_getClass();
 130     break;
 131 
 132     // java.lang.System
 133   case vmIntrinsics::_currentTimeMillis:
 134     do_System_currentTimeMillis();
 135     break;
 136 
 137     // java.lang.Thread
 138   case vmIntrinsics::_currentThread:
 139     do_Thread_currentThread();
 140     break;
 141 
 142     // Unsafe
 143   case vmIntrinsics::_compareAndSetInt:
 144     do_Unsafe_compareAndSetInt();
 145     break;
 146 
 147   default:
 148     ShouldNotReachHere();
 149   }
 150 }
 151 
 152 void SharkIntrinsics::do_Math_minmax(ICmpInst::Predicate p) {
 153   // Pop the arguments
 154   SharkValue *sb = state()->pop();
 155   SharkValue *sa = state()->pop();
 156   Value *a = sa->jint_value();
 157   Value *b = sb->jint_value();
 158 
 159   // Perform the test
 160   BasicBlock *ip       = builder()->GetBlockInsertionPoint();
 161   BasicBlock *return_a = builder()->CreateBlock(ip, "return_a");
 162   BasicBlock *return_b = builder()->CreateBlock(ip, "return_b");
 163   BasicBlock *done     = builder()->CreateBlock(ip, "done");
 164 


 224 }
 225 
 226 void SharkIntrinsics::do_System_currentTimeMillis() {
 227   state()->push(
 228     SharkValue::create_jlong(
 229       builder()->CreateCall(builder()->current_time_millis()),
 230       false));
 231   state()->push(NULL);
 232 }
 233 
 234 void SharkIntrinsics::do_Thread_currentThread() {
 235   state()->push(
 236     SharkValue::create_jobject(
 237       builder()->CreateValueOfStructEntry(
 238         thread(), JavaThread::threadObj_offset(),
 239         SharkType::oop_type(),
 240         "threadObj"),
 241       true));
 242 }
 243 
 244 void SharkIntrinsics::do_Unsafe_compareAndSetInt() {
 245   // Pop the arguments
 246   Value *x      = state()->pop()->jint_value();
 247   Value *e      = state()->pop()->jint_value();
 248   SharkValue *empty = state()->pop();
 249   assert(empty == NULL, "should be");
 250   Value *offset = state()->pop()->jlong_value();
 251   Value *object = state()->pop()->jobject_value();
 252   Value *unsafe = state()->pop()->jobject_value();
 253 
 254   // Convert the offset
 255   offset = builder()->CreateCall(
 256     builder()->unsafe_field_offset_to_byte_offset(),
 257     offset);
 258 
 259   // Locate the field
 260   Value *addr = builder()->CreateIntToPtr(
 261     builder()->CreateAdd(
 262       builder()->CreatePtrToInt(object, SharkType::intptr_type()),
 263       builder()->CreateIntCast(offset, SharkType::intptr_type(), true)),
 264     PointerType::getUnqual(SharkType::jint_type()),
< prev index next >