hotspot/src/share/vm/shark/sharkCompiler.cpp

Print this page


   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2008, 2009, 2010 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.
  23  *


 201   ExceptionHandlerTable handler_table;
 202   ImplicitExceptionTable inc_table;
 203 
 204   env->register_method(target,
 205                        entry_bci,
 206                        &offsets,
 207                        0,
 208                        &hscb,
 209                        0,
 210                        &oopmaps,
 211                        &handler_table,
 212                        &inc_table,
 213                        this,
 214                        env->comp_level(),
 215                        false,
 216                        false);
 217 }
 218 
 219 nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm,
 220                                                 methodHandle    target,

 221                                                 BasicType*      arg_types,
 222                                                 BasicType       return_type) {
 223   assert(is_initialized(), "should be");
 224   ResourceMark rm;
 225   const char *name = methodname(
 226     target->klass_name()->as_utf8(), target->name()->as_utf8());
 227 
 228   // Create the code buffer and builder
 229   SharkCodeBuffer cb(masm);
 230   SharkBuilder builder(&cb);
 231 
 232   // Emit the entry point
 233   SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
 234 
 235   // Build the LLVM IR for the method
 236   SharkNativeWrapper *wrapper = SharkNativeWrapper::build(
 237     &builder, target, name, arg_types, return_type);
 238 
 239   // Generate native code
 240   generate_native_code(entry, wrapper->function(), name);
 241 
 242   // Return the nmethod for installation in the VM
 243   return nmethod::new_native_nmethod(target,

 244                                      masm->code(),
 245                                      0,
 246                                      0,
 247                                      wrapper->frame_size(),
 248                                      wrapper->receiver_offset(),
 249                                      wrapper->lock_offset(),
 250                                      wrapper->oop_maps());
 251 }
 252 
 253 void SharkCompiler::generate_native_code(SharkEntry* entry,
 254                                          Function*   function,
 255                                          const char* name) {
 256   // Print the LLVM bitcode, if requested
 257   if (SharkPrintBitcodeOf != NULL) {
 258     if (!fnmatch(SharkPrintBitcodeOf, name, 0))
 259       function->dump();
 260   }
 261 
 262   // Compile to native code
 263   address code = NULL;


   1 /*
   2  * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
   3  * Copyright 2008, 2009, 2010, 2011 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.
  23  *


 201   ExceptionHandlerTable handler_table;
 202   ImplicitExceptionTable inc_table;
 203 
 204   env->register_method(target,
 205                        entry_bci,
 206                        &offsets,
 207                        0,
 208                        &hscb,
 209                        0,
 210                        &oopmaps,
 211                        &handler_table,
 212                        &inc_table,
 213                        this,
 214                        env->comp_level(),
 215                        false,
 216                        false);
 217 }
 218 
 219 nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm,
 220                                                 methodHandle    target,
 221                                                 int             compile_id,
 222                                                 BasicType*      arg_types,
 223                                                 BasicType       return_type) {
 224   assert(is_initialized(), "should be");
 225   ResourceMark rm;
 226   const char *name = methodname(
 227     target->klass_name()->as_utf8(), target->name()->as_utf8());
 228 
 229   // Create the code buffer and builder
 230   SharkCodeBuffer cb(masm);
 231   SharkBuilder builder(&cb);
 232 
 233   // Emit the entry point
 234   SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry));
 235 
 236   // Build the LLVM IR for the method
 237   SharkNativeWrapper *wrapper = SharkNativeWrapper::build(
 238     &builder, target, name, arg_types, return_type);
 239 
 240   // Generate native code
 241   generate_native_code(entry, wrapper->function(), name);
 242 
 243   // Return the nmethod for installation in the VM
 244   return nmethod::new_native_nmethod(target,
 245                                      compile_id,
 246                                      masm->code(),
 247                                      0,
 248                                      0,
 249                                      wrapper->frame_size(),
 250                                      wrapper->receiver_offset(),
 251                                      wrapper->lock_offset(),
 252                                      wrapper->oop_maps());
 253 }
 254 
 255 void SharkCompiler::generate_native_code(SharkEntry* entry,
 256                                          Function*   function,
 257                                          const char* name) {
 258   // Print the LLVM bitcode, if requested
 259   if (SharkPrintBitcodeOf != NULL) {
 260     if (!fnmatch(SharkPrintBitcodeOf, name, 0))
 261       function->dump();
 262   }
 263 
 264   // Compile to native code
 265   address code = NULL;