Mercurial > hg > release > icedtea6-1.11
changeset 1939:25ad23f47dfd
Merge
author | Andrew John Hughes <ahughes@redhat.com> |
---|---|
date | Wed, 24 Feb 2010 17:45:42 +0000 |
parents | be32f963a8b7 (current diff) 2b86a59d4446 (diff) |
children | cba544e79a99 |
files | ChangeLog Makefile.am |
diffstat | 47 files changed, 966 insertions(+), 1504 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Feb 24 17:44:36 2010 +0000 +++ b/ChangeLog Wed Feb 24 17:45:42 2010 +0000 @@ -26,6 +26,116 @@ BOOT_DIR conditional (pulse-java-class.stamp now depends on the appropriate bootstrap target). +2010-02-23 Gary Benson <gbenson@redhat.com> + + * ports/hotspot/make/linux/makefiles/shark.make: Whitespace fixes. + * ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp: Likewise. + * ports/hotspot/src/share/vm/includeDB_shark: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBlock.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBlock.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBuilder.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBuilder.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCacheDecache.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkContext.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkContext.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkFunction.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkFunction.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInliner.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInliner.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkIntrinsics.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInvariants.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkMemoryManager.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkNativeWrapper.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkRuntime.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkRuntime.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStack.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStack.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkState.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkState.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStateScanner.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStateScanner.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkValue.hpp: Likewise. + +2010-02-23 Gary Benson <gbenson@redhat.com> + + * ports/hotspot/src/share/vm/shark/sharkBlock.cpp: Reformatted + with trailing opening braces to match upstream HotSpot. + * ports/hotspot/src/share/vm/shark/sharkBlock.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBuilder.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkBuilder.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCacheDecache.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCodeBuffer.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCompiler.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkConstant.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkConstant.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkContext.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkContext.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkEntry.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkFunction.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkFunction.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInliner.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkIntrinsics.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkIntrinsics.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInvariants.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkInvariants.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkMemoryManager.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkMemoryManager.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkNativeWrapper.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkRuntime.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkRuntime.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStack.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStack.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkState.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkState.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStateScanner.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkStateScanner.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkType.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkValue.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkValue.hpp: Likewise. + +2010-02-23 Deepak Bhole <dbhole@redhat.com> + + * Makefile.am: Provide JDK_UPDATE_VERSION when compiling the plugin + * plugin/icedteanp/IcedTeaNPPlugin.cc: Use JDK_UPDATE_VERSION to set the + jpi version. + +2010-02-23 Gary Benson <gbenson@redhat.com> + + * ports/hotspot/make/linux/makefiles/shark.make: Update copyright. + * ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp: Likewise. + * ports/hotspot/src/share/vm/shark/sharkContext.hpp: Likewise. + +2010-02-23 Gary Benson <gbenson@redhat.com> + + * ports/hotspot/make/linux/makefiles/shark.make: Comment fix. + +2010-02-22 Deepak Bhole <dbhole@redhat.com> + + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java: Centralized + and increased timeouts to give slow-loading applets enough time to load. + +2010-02-21 Xerxes RĂ„nby <xerxes@zafena.se> + + * ports/hotspot/src/share/vm/shark/sharkCompiler.cpp + (MCPU): Explicitly defined for use by LLVM command line parser. + (MAttrs): Likewise. + (SharkCompiler::SharkCompiler): Create the JIT using LLVM EngineBuilder + in order to explicitly set MCPU and MAttrs when using LLVM 2.7. + * ports/hotspot/src/share/vm/shark/llvmHeaders.hpp: + Include llvm/ExecutionEngine/JIT.h for LLVM 2.7 to make sure the + JIT are linked in. + 2010-02-21 Andrew John Hughes <ahughes@redhat.com> * Makefile.am:
--- a/Makefile.am Wed Feb 24 17:44:36 2010 +0000 +++ b/Makefile.am Wed Feb 24 17:45:42 2010 +0000 @@ -1605,6 +1605,7 @@ mkdir -p $(NPPLUGIN_DIR) && \ cd $(NPPLUGIN_DIR) && \ $(CXX) $(CXXFLAGS) \ + -DJDK_UPDATE_VERSION="\"$(JDK_UPDATE_VERSION)\"" \ -DPLUGIN_VERSION="\"$(PLUGIN_VERSION)\"" \ -DMOZILLA_VERSION_COLLAPSED="$(MOZILLA_VERSION_COLLAPSED)" \ $(GLIB_CFLAGS) \
--- a/plugin/icedteanp/IcedTeaNPPlugin.cc Wed Feb 24 17:44:36 2010 +0000 +++ b/plugin/icedteanp/IcedTeaNPPlugin.cc Wed Feb 24 17:45:42 2010 +0000 @@ -107,7 +107,7 @@ "application/x-java-applet;version=1.4.2:class,jar:IcedTea;" \ "application/x-java-applet;version=1.5:class,jar:IcedTea;" \ "application/x-java-applet;version=1.6:class,jar:IcedTea;" \ - "application/x-java-applet;jpi-version=1.6.0_00:class,jar:IcedTea;" \ + "application/x-java-applet;jpi-version=1.6.0_" JDK_UPDATE_VERSION ":class,jar:IcedTea;" \ "application/x-java-bean:class,jar:IcedTea;" \ "application/x-java-bean;version=1.1:class,jar:IcedTea;" \ "application/x-java-bean;version=1.1.1:class,jar:IcedTea;" \ @@ -123,7 +123,7 @@ "application/x-java-bean;version=1.4.2:class,jar:IcedTea;" \ "application/x-java-bean;version=1.5:class,jar:IcedTea;" \ "application/x-java-bean;version=1.6:class,jar:IcedTea;" \ - "application/x-java-bean;jpi-version=1.6.0_00:class,jar:IcedTea;" \ + "application/x-java-bean;jpi-version=1.6.0_" JDK_UPDATE_VERSION ":class,jar:IcedTea;" \ "application/x-java-vm-npruntime::IcedTea;" #define PLUGIN_URL NS_INLINE_PLUGIN_CONTRACTID_PREFIX NS_JVM_MIME_TYPE
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Wed Feb 24 17:44:36 2010 +0000 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Wed Feb 24 17:45:42 2010 +0000 @@ -177,7 +177,7 @@ Applet a; // Wait for panel to come alive - int maxWait = 5000; // wait 5 seconds max for panel to come alive + int maxWait = PluginAppletViewer.APPLET_TIMEOUT; // wait for panel to come alive int wait = 0; while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) { try { @@ -368,6 +368,8 @@ private long handle = 0; private WindowListener windowEventListener = null; private AppletEventListener appletEventListener = null; + + public static final int APPLET_TIMEOUT = 60000; /** * Null constructor to allow instantiation via newInstance() @@ -616,7 +618,7 @@ if (message.startsWith("handle")) { PluginDebug.debug("handle command waiting for applet to complete loading."); - int maxWait = 10000; // wait 10 seconds max for applet to fully load + int maxWait = APPLET_TIMEOUT; // wait for applet to fully load int wait = 0; while (!status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) && (wait < maxWait)) { @@ -663,7 +665,7 @@ if (message.startsWith("width")) { // Wait for panel to come alive - int maxWait = 5000; // wait 5 seconds max for panel to come alive + int maxWait = APPLET_TIMEOUT; // wait for panel to come alive int wait = 0; while (!status.get(identifier).equals(PAV_INIT_STATUS.INIT_COMPLETE) && wait < maxWait) { try { @@ -724,7 +726,7 @@ Object o; // Wait for panel to come alive - int maxWait = 5000; // wait 5 seconds max for panel to come alive + int maxWait = APPLET_TIMEOUT; // wait for panel to come alive int wait = 0; while ((panel == null) || (!((NetxPanel) panel).isAlive() && wait < maxWait)) { try {
--- a/ports/hotspot/make/linux/makefiles/shark.make Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/make/linux/makefiles/shark.make Wed Feb 24 17:45:42 2010 +0000 @@ -1,6 +1,6 @@ # # Copyright 1999-2005 Sun Microsystems, Inc. All Rights Reserved. -# Copyright 2008 Red Hat, Inc. +# Copyright 2008, 2010 Red Hat, Inc. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -20,10 +20,10 @@ # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, # CA 95054 USA or visit www.sun.com if you need additional information or # have any questions. -# +# # -# Sets make macros for making shark version of VM +# Sets make macros for making Shark version of VM TYPE = SHARK
--- a/ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/cpu/zero/vm/shark_globals_zero.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -1,6 +1,6 @@ /* * Copyright 2000-2007 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2008 Red Hat, Inc. + * Copyright 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -20,13 +20,11 @@ * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, * CA 95054 USA or visit www.sun.com if you need additional information or * have any questions. - * + * */ -// -// Sets the default values for platform dependent flags used by the -// Shark compiler. -// +// Set the default values for platform dependent flags used by the +// Shark compiler. See globals.hpp for details of what they do. define_pd_global(bool, BackgroundCompilation, true ); define_pd_global(bool, UseTLAB, true ); @@ -52,7 +50,7 @@ define_pd_global(intx, NewRatio, 12 ); define_pd_global(intx, NewSizeThreadIncrease, 4*K ); define_pd_global(intx, InitialCodeCacheSize, 160*K); -define_pd_global(intx, ReservedCodeCacheSize, 32*M ); +define_pd_global(intx, ReservedCodeCacheSize, 32*M ); define_pd_global(bool, ProfileInterpreter, false); define_pd_global(intx, CodeCacheExpansionSize, 32*K ); define_pd_global(uintx, CodeCacheMinBlockLength, 1 );
--- a/ports/hotspot/src/share/vm/includeDB_shark Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/includeDB_shark Wed Feb 24 17:45:42 2010 +0000 @@ -20,7 +20,7 @@ // Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, // CA 95054 USA or visit www.sun.com if you need additional information or // have any questions. -// +// // // NOTE: DO NOT CHANGE THIS COPYRIGHT TO NEW STYLE - IT WILL BREAK makeDeps!
--- a/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/llvmHeaders.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -44,6 +44,7 @@ #include <llvm/ExecutionEngine/JITMemoryManager.h> #include <llvm/Support/CommandLine.h> #if SHARK_LLVM_VERSION >= 27 +#include <llvm/ExecutionEngine/JIT.h> #include <llvm/ADT/StringMap.h> #include <llvm/Support/Debug.h> #include <llvm/System/Host.h>
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkBlock.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkBlock::parse_bytecode(int start, int limit) -{ +void SharkBlock::parse_bytecode(int start, int limit) { SharkValue *a, *b, *c, *d; int i; @@ -45,7 +44,7 @@ if (SharkTraceBytecodes) tty->print_cr("%4d: %s", bci(), Bytecodes::name(bc())); - + if (has_trap() && trap_bci() == bci()) { do_trap(trap_request()); return; @@ -96,7 +95,7 @@ } } break; - } + } } switch (bc()) { @@ -295,25 +294,25 @@ xpop(); xpop(); break; - case Bytecodes::_swap: + case Bytecodes::_swap: a = xpop(); b = xpop(); xpush(a); xpush(b); - break; + break; case Bytecodes::_dup: a = xpop(); xpush(a); xpush(a); break; - case Bytecodes::_dup_x1: + case Bytecodes::_dup_x1: a = xpop(); b = xpop(); xpush(a); xpush(b); xpush(a); break; - case Bytecodes::_dup_x2: + case Bytecodes::_dup_x2: a = xpop(); b = xpop(); c = xpop(); @@ -322,7 +321,7 @@ xpush(b); xpush(a); break; - case Bytecodes::_dup2: + case Bytecodes::_dup2: a = xpop(); b = xpop(); xpush(b); @@ -395,7 +394,7 @@ do_irem(); break; case Bytecodes::_ineg: - a = pop(); + a = pop(); push(SharkValue::create_jint( builder()->CreateNeg(a->jint_value()), a->zero_checked())); break; @@ -471,7 +470,7 @@ do_lrem(); break; case Bytecodes::_lneg: - a = pop(); + a = pop(); push(SharkValue::create_jlong( builder()->CreateNeg(a->jlong_value()), a->zero_checked())); break; @@ -548,18 +547,18 @@ break; case Bytecodes::_fdiv: b = pop(); - a = pop(); + a = pop(); push(SharkValue::create_jfloat( builder()->CreateFDiv(a->jfloat_value(), b->jfloat_value()))); break; case Bytecodes::_frem: b = pop(); - a = pop(); + a = pop(); push(SharkValue::create_jfloat( builder()->CreateFRem(a->jfloat_value(), b->jfloat_value()))); break; case Bytecodes::_fneg: - a = pop(); + a = pop(); push(SharkValue::create_jfloat( builder()->CreateFNeg(a->jfloat_value()))); break; @@ -584,18 +583,18 @@ break; case Bytecodes::_ddiv: b = pop(); - a = pop(); + a = pop(); push(SharkValue::create_jdouble( builder()->CreateFDiv(a->jdouble_value(), b->jdouble_value()))); break; case Bytecodes::_drem: b = pop(); - a = pop(); + a = pop(); push(SharkValue::create_jdouble( builder()->CreateFRem(a->jdouble_value(), b->jdouble_value()))); break; case Bytecodes::_dneg: - a = pop(); + a = pop(); push(SharkValue::create_jdouble( builder()->CreateFNeg(a->jdouble_value()))); break; @@ -628,7 +627,7 @@ break; case Bytecodes::_i2l: - a = pop(); + a = pop(); push(SharkValue::create_jlong( builder()->CreateIntCast( a->jint_value(), SharkType::jlong_type(), true), a->zero_checked())); @@ -890,18 +889,15 @@ } } -SharkState* SharkBlock::initial_current_state() -{ +SharkState* SharkBlock::initial_current_state() { return entry_state()->copy(); } -int SharkBlock::switch_default_dest() -{ +int SharkBlock::switch_default_dest() { return iter()->get_dest_table(0); } -int SharkBlock::switch_table_length() -{ +int SharkBlock::switch_table_length() { switch(bc()) { case Bytecodes::_tableswitch: return iter()->get_int_table(2) - iter()->get_int_table(1) + 1; @@ -911,11 +907,10 @@ default: ShouldNotReachHere(); - } + } } -int SharkBlock::switch_key(int i) -{ +int SharkBlock::switch_key(int i) { switch(bc()) { case Bytecodes::_tableswitch: return iter()->get_int_table(1) + i; @@ -925,11 +920,10 @@ default: ShouldNotReachHere(); - } + } } -int SharkBlock::switch_dest(int i) -{ +int SharkBlock::switch_dest(int i) { switch(bc()) { case Bytecodes::_tableswitch: return iter()->get_dest_table(i + 3); @@ -939,11 +933,10 @@ default: ShouldNotReachHere(); - } + } } -void SharkBlock::do_div_or_rem(bool is_long, bool is_rem) -{ +void SharkBlock::do_div_or_rem(bool is_long, bool is_rem) { SharkValue *sb = pop(); SharkValue *sa = pop(); @@ -973,7 +966,7 @@ builder()->CreateICmpEQ(a, p), builder()->CreateICmpEQ(b, q)), special_case, general_case); - + builder()->SetInsertPoint(special_case); Value *special_result; if (is_rem) { @@ -1010,8 +1003,7 @@ push(SharkValue::create_jint(result, false)); } -void SharkBlock::do_field_access(bool is_get, bool is_field) -{ +void SharkBlock::do_field_access(bool is_get, bool is_field) { bool will_link; ciField *field = iter()->get_field(will_link); assert(will_link, "typeflow responsibility"); @@ -1041,12 +1033,12 @@ BasicType basic_type = field->type()->basic_type(); const Type *stack_type = SharkType::to_stackType(basic_type); const Type *field_type = SharkType::to_arrayType(basic_type); - + Value *addr = builder()->CreateAddressOfStructEntry( object, in_ByteSize(field->offset_in_bytes()), PointerType::getUnqual(field_type), "addr"); - + // Do the access if (is_get) { Value *field_value = builder()->CreateLoad(addr); @@ -1065,7 +1057,7 @@ field_value, field_type, basic_type != T_CHAR); builder()->CreateStore(field_value, addr); - + if (!field->type()->is_primitive_type()) builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr); @@ -1079,8 +1071,7 @@ push(value); } -void SharkBlock::do_lcmp() -{ +void SharkBlock::do_lcmp() { Value *b = pop()->jlong_value(); Value *a = pop()->jlong_value(); @@ -1111,8 +1102,7 @@ push(SharkValue::create_jint(result, false)); } -void SharkBlock::do_fcmp(bool is_double, bool unordered_is_greater) -{ +void SharkBlock::do_fcmp(bool is_double, bool unordered_is_greater) { Value *a, *b; if (is_double) { b = pop()->jdouble_value(); @@ -1159,137 +1149,110 @@ push(SharkValue::create_jint(result, false)); } -void SharkBlock::emit_IR() -{ +void SharkBlock::emit_IR() { ShouldNotCallThis(); } -SharkState* SharkBlock::entry_state() -{ +SharkState* SharkBlock::entry_state() { ShouldNotCallThis(); } -void SharkBlock::do_zero_check(SharkValue* value) -{ +void SharkBlock::do_zero_check(SharkValue* value) { ShouldNotCallThis(); } -void SharkBlock::maybe_add_backedge_safepoint() -{ +void SharkBlock::maybe_add_backedge_safepoint() { ShouldNotCallThis(); } -bool SharkBlock::has_trap() -{ +bool SharkBlock::has_trap() { return false; } -int SharkBlock::trap_request() -{ +int SharkBlock::trap_request() { ShouldNotCallThis(); } -int SharkBlock::trap_bci() -{ +int SharkBlock::trap_bci() { ShouldNotCallThis(); } -void SharkBlock::do_trap(int trap_request) -{ +void SharkBlock::do_trap(int trap_request) { ShouldNotCallThis(); } -void SharkBlock::do_arraylength() -{ +void SharkBlock::do_arraylength() { ShouldNotCallThis(); } -void SharkBlock::do_aload(BasicType basic_type) -{ +void SharkBlock::do_aload(BasicType basic_type) { ShouldNotCallThis(); } -void SharkBlock::do_astore(BasicType basic_type) -{ +void SharkBlock::do_astore(BasicType basic_type) { ShouldNotCallThis(); } -void SharkBlock::do_return(BasicType type) -{ +void SharkBlock::do_return(BasicType type) { ShouldNotCallThis(); } -void SharkBlock::do_athrow() -{ +void SharkBlock::do_athrow() { ShouldNotCallThis(); } -void SharkBlock::do_goto() -{ +void SharkBlock::do_goto() { ShouldNotCallThis(); } -void SharkBlock::do_jsr() -{ +void SharkBlock::do_jsr() { ShouldNotCallThis(); } -void SharkBlock::do_ret() -{ +void SharkBlock::do_ret() { ShouldNotCallThis(); } -void SharkBlock::do_if(ICmpInst::Predicate p, SharkValue* b, SharkValue* a) -{ +void SharkBlock::do_if(ICmpInst::Predicate p, SharkValue* b, SharkValue* a) { ShouldNotCallThis(); } -void SharkBlock::do_switch() -{ +void SharkBlock::do_switch() { ShouldNotCallThis(); } -void SharkBlock::do_call() -{ +void SharkBlock::do_call() { ShouldNotCallThis(); } -void SharkBlock::do_instance_check() -{ +void SharkBlock::do_instance_check() { ShouldNotCallThis(); } -bool SharkBlock::maybe_do_instanceof_if() -{ +bool SharkBlock::maybe_do_instanceof_if() { ShouldNotCallThis(); } -void SharkBlock::do_new() -{ +void SharkBlock::do_new() { ShouldNotCallThis(); } -void SharkBlock::do_newarray() -{ +void SharkBlock::do_newarray() { ShouldNotCallThis(); } -void SharkBlock::do_anewarray() -{ +void SharkBlock::do_anewarray() { ShouldNotCallThis(); } -void SharkBlock::do_multianewarray() -{ +void SharkBlock::do_multianewarray() { ShouldNotCallThis(); } -void SharkBlock::do_monitorenter() -{ +void SharkBlock::do_monitorenter() { ShouldNotCallThis(); } -void SharkBlock::do_monitorexit() -{ +void SharkBlock::do_monitorexit() { ShouldNotCallThis(); }
--- a/ports/hotspot/src/share/vm/shark/sharkBlock.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkBlock.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -42,45 +42,39 @@ SharkState* _current_state; public: - ciBytecodeStream* iter() - { + ciBytecodeStream* iter() { return &_iter; } - Bytecodes::Code bc() - { + Bytecodes::Code bc() { return iter()->cur_bc(); } - int bci() - { + int bci() { return iter()->cur_bci(); } // Entry state protected: virtual SharkState* entry_state(); - + // Current state private: SharkState* initial_current_state(); - + public: - SharkState* current_state() - { + SharkState* current_state() { if (_current_state == NULL) set_current_state(initial_current_state()); return _current_state; } protected: - void set_current_state(SharkState* current_state) - { + void set_current_state(SharkState* current_state) { _current_state = current_state; } - // Local variables + // Local variables protected: - SharkValue* local(int index) - { + SharkValue* local(int index) { SharkValue *value = current_state()->local(index); assert(value != NULL, "shouldn't be"); assert(value->is_one_word() || @@ -88,8 +82,7 @@ current_state()->local(index + 1) == NULL), "should be"); return value; } - void set_local(int index, SharkValue* value) - { + void set_local(int index, SharkValue* value) { assert(value != NULL, "shouldn't be"); current_state()->set_local(index, value); if (value->is_two_word()) @@ -98,16 +91,13 @@ // Expression stack (raw) protected: - void xpush(SharkValue* value) - { + void xpush(SharkValue* value) { current_state()->push(value); } - SharkValue* xpop() - { + SharkValue* xpop() { return current_state()->pop(); } - SharkValue* xstack(int slot) - { + SharkValue* xstack(int slot) { SharkValue *value = current_state()->stack(slot); assert(value != NULL, "shouldn't be"); assert(value->is_one_word() || @@ -115,22 +105,19 @@ current_state()->stack(slot - 1) == NULL), "should be"); return value; } - int xstack_depth() - { + int xstack_depth() { return current_state()->stack_depth(); } // Expression stack (cooked) protected: - void push(SharkValue* value) - { + void push(SharkValue* value) { assert(value != NULL, "shouldn't be"); xpush(value); if (value->is_two_word()) xpush(NULL); } - SharkValue* pop() - { + SharkValue* pop() { int size = current_state()->stack(0) == NULL ? 2 : 1; if (size == 2) xpop(); @@ -138,8 +125,7 @@ assert(value && value->size() == size, "should be"); return value; } - SharkValue* pop_result(BasicType type) - { + SharkValue* pop_result(BasicType type) { SharkValue *result = pop(); #ifdef ASSERT @@ -176,17 +162,14 @@ // Zero checking protected: - void check_null(SharkValue* object) - { + void check_null(SharkValue* object) { zero_check(object); } - void check_divide_by_zero(SharkValue* value) - { + void check_divide_by_zero(SharkValue* value) { zero_check(value); } private: - void zero_check(SharkValue* value) - { + void zero_check(SharkValue* value) { if (!value->zero_checked()) do_zero_check(value); } @@ -213,40 +196,32 @@ // *div and *rem private: - void do_idiv() - { + void do_idiv() { do_div_or_rem(false, false); } - void do_irem() - { + void do_irem() { do_div_or_rem(false, true); } - void do_ldiv() - { + void do_ldiv() { do_div_or_rem(true, false); } - void do_lrem() - { + void do_lrem() { do_div_or_rem(true, true); } - void do_div_or_rem(bool is_long, bool is_rem); + void do_div_or_rem(bool is_long, bool is_rem); // get* and put* private: - void do_getstatic() - { + void do_getstatic() { do_field_access(true, false); } - void do_getfield() - { + void do_getfield() { do_field_access(true, true); } - void do_putstatic() - { + void do_putstatic() { do_field_access(false, false); } - void do_putfield() - { + void do_putfield() { do_field_access(false, true); } void do_field_access(bool is_get, bool is_field); @@ -282,7 +257,7 @@ int switch_dest(int i); virtual void do_switch(); - + // invoke* protected: virtual void do_call();
--- a/ports/hotspot/src/share/vm/shark/sharkBuilder.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkBuilder.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -30,24 +30,21 @@ SharkBuilder::SharkBuilder(SharkCodeBuffer* code_buffer) : IRBuilder<>(SharkContext::current()), - _code_buffer(code_buffer) -{ + _code_buffer(code_buffer) { } // Helpers for accessing structures Value* SharkBuilder::CreateAddressOfStructEntry(Value* base, ByteSize offset, const Type* type, - const char* name) -{ + const char* name) { return CreateBitCast(CreateStructGEP(base, in_bytes(offset)), type, name); } LoadInst* SharkBuilder::CreateValueOfStructEntry(Value* base, ByteSize offset, const Type* type, - const char* name) -{ + const char* name) { return CreateLoad( CreateAddressOfStructEntry( base, offset, PointerType::getUnqual(type)), @@ -56,8 +53,7 @@ // Helpers for accessing arrays -LoadInst* SharkBuilder::CreateArrayLength(Value* arrayoop) -{ +LoadInst* SharkBuilder::CreateArrayLength(Value* arrayoop) { return CreateValueOfStructEntry( arrayoop, in_ByteSize(arrayOopDesc::length_offset_in_bytes()), SharkType::jint_type(), "length"); @@ -68,8 +64,7 @@ int element_bytes, ByteSize base_offset, Value* index, - const char* name) -{ + const char* name) { Value* offset = CreateIntCast(index, SharkType::intptr_type(), false); if (element_bytes != 1) offset = CreateShl( @@ -88,8 +83,7 @@ BasicType basic_type, ByteSize base_offset, Value* index, - const char* name) -{ + const char* name) { return CreateArrayAddress( arrayoop, SharkType::to_arrayType(basic_type), @@ -100,8 +94,7 @@ Value* SharkBuilder::CreateArrayAddress(Value* arrayoop, BasicType basic_type, Value* index, - const char* name) -{ + const char* name) { return CreateArrayAddress( arrayoop, basic_type, in_ByteSize(arrayOopDesc::base_offset_in_bytes(basic_type)), @@ -110,8 +103,7 @@ // Helpers for creating intrinsics and external functions. -const Type* SharkBuilder::make_type(char type, bool void_ok) -{ +const Type* SharkBuilder::make_type(char type, bool void_ok) { switch (type) { // Primitive types case 'c': @@ -135,7 +127,7 @@ case 'F': case 'D': return PointerType::getUnqual(make_type(tolower(type), false)); - + // VM objects case 'T': return SharkType::thread_type(); @@ -157,8 +149,7 @@ } const FunctionType* SharkBuilder::make_ftype(const char* params, - const char* ret) -{ + const char* ret) { std::vector<const Type*> param_types; for (const char* c = params; *c; c++) param_types.push_back(make_type(*c, false)); @@ -178,8 +169,7 @@ // obscure them were they visible. Value* SharkBuilder::make_function(const char* name, const char* params, - const char* ret) -{ + const char* ret) { return SharkContext::current().get_external(name, make_ftype(params, ret)); } @@ -189,8 +179,7 @@ // __kernel_dmb on ARM which is accessed via an absolute address. Value* SharkBuilder::make_function(address func, const char* params, - const char* ret) -{ + const char* ret) { return CreateIntToPtr( LLVMValue::intptr_constant((intptr_t) func), PointerType::getUnqual(make_ftype(params, ret))); @@ -198,168 +187,137 @@ // VM calls -Value* SharkBuilder::find_exception_handler() -{ +Value* SharkBuilder::find_exception_handler() { return make_function( (address) SharkRuntime::find_exception_handler, "TIi", "i"); } -Value* SharkBuilder::monitorenter() -{ +Value* SharkBuilder::monitorenter() { return make_function((address) SharkRuntime::monitorenter, "TM", "v"); } -Value* SharkBuilder::monitorexit() -{ +Value* SharkBuilder::monitorexit() { return make_function((address) SharkRuntime::monitorexit, "TM", "v"); } -Value* SharkBuilder::new_instance() -{ +Value* SharkBuilder::new_instance() { return make_function((address) SharkRuntime::new_instance, "Ti", "v"); } -Value* SharkBuilder::newarray() -{ +Value* SharkBuilder::newarray() { return make_function((address) SharkRuntime::newarray, "Tii", "v"); } -Value* SharkBuilder::anewarray() -{ +Value* SharkBuilder::anewarray() { return make_function((address) SharkRuntime::anewarray, "Tii", "v"); } -Value* SharkBuilder::multianewarray() -{ +Value* SharkBuilder::multianewarray() { return make_function((address) SharkRuntime::multianewarray, "TiiI", "v"); } -Value* SharkBuilder::register_finalizer() -{ +Value* SharkBuilder::register_finalizer() { return make_function((address) SharkRuntime::register_finalizer, "TO", "v"); } -Value* SharkBuilder::safepoint() -{ +Value* SharkBuilder::safepoint() { return make_function((address) SafepointSynchronize::block, "T", "v"); } -Value* SharkBuilder::throw_ArrayIndexOutOfBoundsException() -{ +Value* SharkBuilder::throw_ArrayIndexOutOfBoundsException() { return make_function( (address) SharkRuntime::throw_ArrayIndexOutOfBoundsException, "TCii", "v"); } -Value* SharkBuilder::throw_NullPointerException() -{ +Value* SharkBuilder::throw_NullPointerException() { return make_function( (address) SharkRuntime::throw_NullPointerException, "TCi", "v"); } // High-level non-VM calls -Value* SharkBuilder::f2i() -{ +Value* SharkBuilder::f2i() { return make_function((address) SharedRuntime::f2i, "f", "i"); } -Value* SharkBuilder::f2l() -{ +Value* SharkBuilder::f2l() { return make_function((address) SharedRuntime::f2l, "f", "l"); } -Value* SharkBuilder::d2i() -{ +Value* SharkBuilder::d2i() { return make_function((address) SharedRuntime::d2i, "d", "i"); } -Value* SharkBuilder::d2l() -{ +Value* SharkBuilder::d2l() { return make_function((address) SharedRuntime::d2l, "d", "l"); } -Value* SharkBuilder::is_subtype_of() -{ +Value* SharkBuilder::is_subtype_of() { return make_function((address) SharkRuntime::is_subtype_of, "OO", "c"); } -Value* SharkBuilder::current_time_millis() -{ +Value* SharkBuilder::current_time_millis() { return make_function((address) os::javaTimeMillis, "", "l"); } -Value* SharkBuilder::sin() -{ +Value* SharkBuilder::sin() { return make_function("llvm.sin.f64", "d", "d"); } -Value* SharkBuilder::cos() -{ +Value* SharkBuilder::cos() { return make_function("llvm.cos.f64", "d", "d"); } -Value* SharkBuilder::tan() -{ +Value* SharkBuilder::tan() { return make_function((address) ::tan, "d", "d"); } -Value* SharkBuilder::atan2() -{ +Value* SharkBuilder::atan2() { return make_function((address) ::atan2, "dd", "d"); } -Value* SharkBuilder::sqrt() -{ +Value* SharkBuilder::sqrt() { return make_function("llvm.sqrt.f64", "d", "d"); } -Value* SharkBuilder::log() -{ +Value* SharkBuilder::log() { return make_function("llvm.log.f64", "d", "d"); } -Value* SharkBuilder::log10() -{ +Value* SharkBuilder::log10() { return make_function("llvm.log10.f64", "d", "d"); } -Value* SharkBuilder::pow() -{ +Value* SharkBuilder::pow() { return make_function("llvm.pow.f64", "dd", "d"); } -Value* SharkBuilder::exp() -{ +Value* SharkBuilder::exp() { return make_function("llvm.exp.f64", "d", "d"); } -Value* SharkBuilder::fabs() -{ +Value* SharkBuilder::fabs() { return make_function((address) ::fabs, "d", "d"); } -Value* SharkBuilder::unsafe_field_offset_to_byte_offset() -{ +Value* SharkBuilder::unsafe_field_offset_to_byte_offset() { extern jlong Unsafe_field_offset_to_byte_offset(jlong field_offset); return make_function((address) Unsafe_field_offset_to_byte_offset, "l", "l"); } -Value* SharkBuilder::osr_migration_end() -{ +Value* SharkBuilder::osr_migration_end() { return make_function((address) SharedRuntime::OSR_migration_end, "C", "v"); } // Uncommon trap -Value* SharkBuilder::uncommon_trap() -{ +Value* SharkBuilder::uncommon_trap() { return make_function((address) SharkRuntime::uncommon_trap, "Ti", "v"); } // Native-Java transition. -Value* SharkBuilder::check_special_condition_for_native_trans() -{ +Value* SharkBuilder::check_special_condition_for_native_trans() { return make_function( (address) JavaThread::check_special_condition_for_native_trans, "T", "v"); @@ -383,14 +341,12 @@ // perform these operations without delegating to a function. #ifdef ARM -static jint zero_cmpxchg_int(volatile jint *ptr, jint oldval, jint newval) -{ +static jint zero_cmpxchg_int(volatile jint *ptr, jint oldval, jint newval) { return Atomic::cmpxchg(newval, ptr, oldval); } #endif // ARM -Value* SharkBuilder::cmpxchg_int() -{ +Value* SharkBuilder::cmpxchg_int() { return make_function( #ifdef ARM (address) zero_cmpxchg_int, @@ -403,14 +359,12 @@ #ifdef ARM static intptr_t zero_cmpxchg_ptr(volatile intptr_t* ptr, intptr_t oldval, - intptr_t newval) -{ + intptr_t newval) { return Atomic::cmpxchg_ptr(newval, ptr, oldval); } #endif // ARM -Value* SharkBuilder::cmpxchg_ptr() -{ +Value* SharkBuilder::cmpxchg_ptr() { return make_function( #ifdef ARM (address) zero_cmpxchg_ptr, @@ -420,8 +374,7 @@ "Xxx", "x"); } -Value* SharkBuilder::memory_barrier() -{ +Value* SharkBuilder::memory_barrier() { return make_function( #ifdef ARM (address) 0xffff0fa0, // __kernel_dmb @@ -431,23 +384,19 @@ "11111", "v"); } -Value* SharkBuilder::memset() -{ +Value* SharkBuilder::memset() { return make_function("llvm.memset.i32", "Ccii", "v"); } -Value* SharkBuilder::unimplemented() -{ +Value* SharkBuilder::unimplemented() { return make_function((address) report_unimplemented, "Ci", "v"); } -Value* SharkBuilder::should_not_reach_here() -{ +Value* SharkBuilder::should_not_reach_here() { return make_function((address) report_should_not_reach_here, "Ci", "v"); } -Value* SharkBuilder::dump() -{ +Value* SharkBuilder::dump() { return make_function((address) SharkRuntime::dump, "Cx", "v"); } @@ -455,20 +404,17 @@ CallInst* SharkBuilder::CreateCmpxchgInt(Value* exchange_value, Value* dst, - Value* compare_value) -{ + Value* compare_value) { return CreateCall3(cmpxchg_int(), dst, compare_value, exchange_value); } CallInst* SharkBuilder::CreateCmpxchgPtr(Value* exchange_value, Value* dst, - Value* compare_value) -{ + Value* compare_value) { return CreateCall3(cmpxchg_ptr(), dst, compare_value, exchange_value); } -CallInst *SharkBuilder::CreateMemoryBarrier(int flags) -{ +CallInst *SharkBuilder::CreateMemoryBarrier(int flags) { Value *args[] = { LLVMValue::bit_constant((flags & BARRIER_LOADLOAD) ? 1 : 0), LLVMValue::bit_constant((flags & BARRIER_LOADSTORE) ? 1 : 0), @@ -482,13 +428,11 @@ CallInst* SharkBuilder::CreateMemset(Value* dst, Value* value, Value* len, - Value* align) -{ + Value* align) { return CreateCall4(memset(), dst, value, len, align); } -CallInst* SharkBuilder::CreateUnimplemented(const char* file, int line) -{ +CallInst* SharkBuilder::CreateUnimplemented(const char* file, int line) { return CreateCall2( unimplemented(), CreateIntToPtr( @@ -497,8 +441,7 @@ LLVMValue::jint_constant(line)); } -CallInst* SharkBuilder::CreateShouldNotReachHere(const char* file, int line) -{ +CallInst* SharkBuilder::CreateShouldNotReachHere(const char* file, int line) { return CreateCall2( should_not_reach_here(), CreateIntToPtr( @@ -508,8 +451,7 @@ } #ifndef PRODUCT -CallInst* SharkBuilder::CreateDump(Value* value) -{ +CallInst* SharkBuilder::CreateDump(Value* value) { const char *name; if (value->hasName()) // XXX this leaks, but it's only debug code @@ -535,8 +477,7 @@ // HotSpot memory barriers -void SharkBuilder::CreateUpdateBarrierSet(BarrierSet* bs, Value* field) -{ +void SharkBuilder::CreateUpdateBarrierSet(BarrierSet* bs, Value* field) { if (bs->kind() != BarrierSet::CardTableModRef) Unimplemented(); @@ -554,15 +495,13 @@ // Helpers for accessing the code buffer -Value* SharkBuilder::code_buffer_address(int offset) -{ +Value* SharkBuilder::code_buffer_address(int offset) { return CreateAdd( code_buffer()->base_pc(), LLVMValue::intptr_constant(offset)); } -Value* SharkBuilder::CreateInlineOop(jobject object, const char* name) -{ +Value* SharkBuilder::CreateInlineOop(jobject object, const char* name) { return CreateLoad( CreateIntToPtr( code_buffer_address(code_buffer()->inline_oop(object)), @@ -572,8 +511,7 @@ // Helpers for creating basic blocks. -BasicBlock* SharkBuilder::GetBlockInsertionPoint() const -{ +BasicBlock* SharkBuilder::GetBlockInsertionPoint() const { BasicBlock *cur = GetInsertBlock(); // BasicBlock::Create takes an insertBefore argument, so @@ -594,8 +532,7 @@ return iter; } -BasicBlock* SharkBuilder::CreateBlock(BasicBlock* ip, const char* name) const -{ +BasicBlock* SharkBuilder::CreateBlock(BasicBlock* ip, const char* name) const { return BasicBlock::Create( SharkContext::current(), name, GetInsertBlock()->getParent(), ip); -} +}
--- a/ports/hotspot/src/share/vm/shark/sharkBuilder.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkBuilder.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -34,8 +34,7 @@ SharkCodeBuffer* _code_buffer; protected: - SharkCodeBuffer* code_buffer() const - { + SharkCodeBuffer* code_buffer() const { return _code_buffer; } @@ -150,7 +149,7 @@ llvm::Value* memset(); llvm::Value* unimplemented(); llvm::Value* should_not_reach_here(); - llvm::Value* dump(); + llvm::Value* dump(); // Public interface to low-level non-VM calls. public: @@ -165,10 +164,10 @@ llvm::Value* value, llvm::Value* len, llvm::Value* align); - llvm::CallInst* CreateUnimplemented(const char* file, int line); - llvm::CallInst* CreateShouldNotReachHere(const char* file, int line); + llvm::CallInst* CreateUnimplemented(const char* file, int line); + llvm::CallInst* CreateShouldNotReachHere(const char* file, int line); NOT_PRODUCT(llvm::CallInst* CreateDump(llvm::Value* value)); - + // Flags for CreateMemoryBarrier. public: enum BarrierFlags { @@ -186,8 +185,7 @@ public: llvm::Value* code_buffer_address(int offset); llvm::Value* CreateInlineOop(jobject object, const char* name = ""); - llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") - { + llvm::Value* CreateInlineOop(ciObject* object, const char* name = "") { return CreateInlineOop(object->encoding(), name); }
--- a/ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCacheDecache.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkDecacher::start_frame() -{ +void SharkDecacher::start_frame() { // Start recording the debug information _pc_offset = code_buffer()->create_unique_offset(); _oopmap = new OopMap( @@ -38,8 +37,7 @@ debug_info()->add_safepoint(pc_offset(), oopmap()); } -void SharkDecacher::start_stack(int stack_depth) -{ +void SharkDecacher::start_stack(int stack_depth) { // Create the array we'll record our stack slots in _exparray = new GrowableArray<ScopeValue*>(stack_depth); @@ -53,8 +51,7 @@ void SharkDecacher::process_stack_slot(int index, SharkValue** addr, - int offset) -{ + int offset) { SharkValue *value = *addr; // Write the value to the frame if necessary @@ -76,14 +73,12 @@ } } -void SharkDecacher::start_monitors(int num_monitors) -{ +void SharkDecacher::start_monitors(int num_monitors) { // Create the array we'll record our monitors in _monarray = new GrowableArray<MonitorValue*>(num_monitors); } -void SharkDecacher::process_monitor(int index, int box_offset, int obj_offset) -{ +void SharkDecacher::process_monitor(int index, int box_offset, int obj_offset) { oopmap()->set_oop(slot2reg(obj_offset)); monarray()->append(new MonitorValue( @@ -91,8 +86,7 @@ slot2loc(box_offset, Location::normal))); } -void SharkDecacher::process_oop_tmp_slot(Value** value, int offset) -{ +void SharkDecacher::process_oop_tmp_slot(Value** value, int offset) { // Decache the temporary oop slot if (*value) { write_value_to_frame( @@ -104,34 +98,30 @@ } } -void SharkDecacher::process_method_slot(Value** value, int offset) -{ +void SharkDecacher::process_method_slot(Value** value, int offset) { // Decache the method pointer write_value_to_frame( SharkType::methodOop_type(), *value, offset); - oopmap()->set_oop(slot2reg(offset)); + oopmap()->set_oop(slot2reg(offset)); } -void SharkDecacher::process_pc_slot(int offset) -{ +void SharkDecacher::process_pc_slot(int offset) { // Record the PC builder()->CreateStore( builder()->code_buffer_address(pc_offset()), stack()->slot_addr(offset)); } - -void SharkDecacher::start_locals() -{ + +void SharkDecacher::start_locals() { // Create the array we'll record our local variables in _locarray = new GrowableArray<ScopeValue*>(max_locals());} void SharkDecacher::process_local_slot(int index, SharkValue** addr, - int offset) -{ + int offset) { SharkValue *value = *addr; // Write the value to the frame if necessary @@ -153,8 +143,7 @@ } } -void SharkDecacher::end_frame() -{ +void SharkDecacher::end_frame() { // Record the scope debug_info()->describe_scope( pc_offset(), @@ -170,8 +159,7 @@ void SharkCacher::process_stack_slot(int index, SharkValue** addr, - int offset) -{ + int offset) { SharkValue *value = *addr; // Read the value from the frame if necessary @@ -187,8 +175,7 @@ void SharkOSREntryCacher::process_monitor(int index, int box_offset, - int obj_offset) -{ + int obj_offset) { // Copy the monitor from the OSR buffer to the frame int src_offset = max_locals() + index * 2; builder()->CreateStore( @@ -201,29 +188,25 @@ stack()->slot_addr(obj_offset, SharkType::oop_type())); } -void SharkCacher::process_oop_tmp_slot(Value** value, int offset) -{ +void SharkCacher::process_oop_tmp_slot(Value** value, int offset) { // Cache the temporary oop if (*value) *value = read_value_from_frame(SharkType::oop_type(), offset); } -void SharkCacher::process_method_slot(Value** value, int offset) -{ +void SharkCacher::process_method_slot(Value** value, int offset) { // Cache the method pointer *value = read_value_from_frame(SharkType::methodOop_type(), offset); } -void SharkFunctionEntryCacher::process_method_slot(Value** value, int offset) -{ +void SharkFunctionEntryCacher::process_method_slot(Value** value, int offset) { // "Cache" the method pointer *value = method(); } void SharkCacher::process_local_slot(int index, SharkValue** addr, - int offset) -{ + int offset) { SharkValue *value = *addr; // Read the value from the frame if necessary @@ -238,8 +221,7 @@ } Value* SharkOSREntryCacher::CreateAddressOfOSRBufEntry(int offset, - const Type* type) -{ + const Type* type) { Value *result = builder()->CreateStructGEP(osr_buf(), offset); if (type != SharkType::intptr_type()) result = builder()->CreateBitCast(result, PointerType::getUnqual(type)); @@ -248,8 +230,7 @@ void SharkOSREntryCacher::process_local_slot(int index, SharkValue** addr, - int offset) -{ + int offset) { SharkValue *value = *addr; // Read the value from the OSR buffer if necessary @@ -266,12 +247,10 @@ void SharkDecacher::write_value_to_frame(const Type* type, Value* value, - int offset) -{ + int offset) { builder()->CreateStore(value, stack()->slot_addr(offset, type)); } -Value* SharkCacher::read_value_from_frame(const Type* type, int offset) -{ +Value* SharkCacher::read_value_from_frame(const Type* type, int offset) { return builder()->CreateLoad(stack()->slot_addr(offset, type)); }
--- a/ports/hotspot/src/share/vm/shark/sharkCacheDecache.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCacheDecache.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -44,8 +44,7 @@ // Helper protected: - static int adjusted_offset(SharkValue* value, int offset) - { + static int adjusted_offset(SharkValue* value, int offset) { if (value->is_two_word()) offset--; return offset; @@ -59,10 +58,9 @@ private: int _bci; - + protected: - int bci() const - { + int bci() const { return _bci; } @@ -74,24 +72,19 @@ GrowableArray<ScopeValue*>* _locarray; private: - int pc_offset() const - { + int pc_offset() const { return _pc_offset; } - OopMap* oopmap() const - { + OopMap* oopmap() const { return _oopmap; } - GrowableArray<ScopeValue*>* exparray() const - { + GrowableArray<ScopeValue*>* exparray() const { return _exparray; } - GrowableArray<MonitorValue*>* monarray() const - { + GrowableArray<MonitorValue*>* monarray() const { return _monarray; } - GrowableArray<ScopeValue*>* locarray() const - { + GrowableArray<ScopeValue*>* locarray() const { return _locarray; } @@ -108,7 +101,7 @@ void process_oop_tmp_slot(llvm::Value** value, int offset); void process_method_slot(llvm::Value** value, int offset); void process_pc_slot(int offset); - + void start_locals(); void process_local_slot(int index, SharkValue** value, int offset); @@ -116,24 +109,19 @@ // oopmap and debuginfo helpers private: - static int oopmap_slot_munge(int offset) - { + static int oopmap_slot_munge(int offset) { return SharkStack::oopmap_slot_munge(offset); } - static VMReg slot2reg(int offset) - { + static VMReg slot2reg(int offset) { return SharkStack::slot2reg(offset); } - static Location slot2loc(int offset, Location::Type type) - { + static Location slot2loc(int offset, Location::Type type) { return Location::new_stk_loc(type, offset * wordSize); } - static LocationValue* slot2lv(int offset, Location::Type type) - { + static LocationValue* slot2lv(int offset, Location::Type type) { return new LocationValue(slot2loc(offset, type)); } - static Location::Type location_type(SharkValue** addr, bool maybe_two_word) - { + static Location::Type location_type(SharkValue** addr, bool maybe_two_word) { // low addresses this end // Type 32-bit 64-bit // ---------------------------------------------------- @@ -143,7 +131,7 @@ // stack[3] local[0] jint normal normal // // high addresses this end - + SharkValue *value = *addr; if (value) { if (value->is_jobject()) @@ -179,8 +167,7 @@ virtual bool stack_slot_needs_oopmap(int index, SharkValue* value) = 0; virtual bool stack_slot_needs_debuginfo(int index, SharkValue* value) = 0; - static Location::Type stack_location_type(int index, SharkValue** addr) - { + static Location::Type stack_location_type(int index, SharkValue** addr) { return location_type(addr, *addr == NULL); } @@ -190,8 +177,7 @@ virtual bool local_slot_needs_oopmap(int index, SharkValue* value) = 0; virtual bool local_slot_needs_debuginfo(int index, SharkValue* value) = 0; - static Location::Type local_location_type(int index, SharkValue** addr) - { + static Location::Type local_location_type(int index, SharkValue** addr) { return location_type(addr, index > 0); } @@ -211,38 +197,31 @@ ciMethod* _callee; protected: - ciMethod* callee() const - { + ciMethod* callee() const { return _callee; } // Stack slot helpers protected: - bool stack_slot_needs_write(int index, SharkValue* value) - { + bool stack_slot_needs_write(int index, SharkValue* value) { return value && (index < callee()->arg_size() || value->is_jobject()); } - bool stack_slot_needs_oopmap(int index, SharkValue* value) - { + bool stack_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject() && index >= callee()->arg_size(); } - bool stack_slot_needs_debuginfo(int index, SharkValue* value) - { + bool stack_slot_needs_debuginfo(int index, SharkValue* value) { return index >= callee()->arg_size(); } // Local slot helpers protected: - bool local_slot_needs_write(int index, SharkValue* value) - { + bool local_slot_needs_write(int index, SharkValue* value) { return value && value->is_jobject(); } - bool local_slot_needs_oopmap(int index, SharkValue* value) - { + bool local_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject(); } - bool local_slot_needs_debuginfo(int index, SharkValue* value) - { + bool local_slot_needs_debuginfo(int index, SharkValue* value) { return true; } }; @@ -254,31 +233,25 @@ // Stack slot helpers protected: - bool stack_slot_needs_write(int index, SharkValue* value) - { + bool stack_slot_needs_write(int index, SharkValue* value) { return value && value->is_jobject(); } - bool stack_slot_needs_oopmap(int index, SharkValue* value) - { + bool stack_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject(); } - bool stack_slot_needs_debuginfo(int index, SharkValue* value) - { + bool stack_slot_needs_debuginfo(int index, SharkValue* value) { return true; } // Local slot helpers protected: - bool local_slot_needs_write(int index, SharkValue* value) - { + bool local_slot_needs_write(int index, SharkValue* value) { return value && value->is_jobject(); } - bool local_slot_needs_oopmap(int index, SharkValue* value) - { + bool local_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject(); } - bool local_slot_needs_debuginfo(int index, SharkValue* value) - { + bool local_slot_needs_debuginfo(int index, SharkValue* value) { return true; } }; @@ -290,31 +263,25 @@ // Stack slot helpers protected: - bool stack_slot_needs_write(int index, SharkValue* value) - { + bool stack_slot_needs_write(int index, SharkValue* value) { return value != NULL; } - bool stack_slot_needs_oopmap(int index, SharkValue* value) - { + bool stack_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject(); } - bool stack_slot_needs_debuginfo(int index, SharkValue* value) - { + bool stack_slot_needs_debuginfo(int index, SharkValue* value) { return true; } // Local slot helpers protected: - bool local_slot_needs_write(int index, SharkValue* value) - { + bool local_slot_needs_write(int index, SharkValue* value) { return value != NULL; } - bool local_slot_needs_oopmap(int index, SharkValue* value) - { + bool local_slot_needs_oopmap(int index, SharkValue* value) { return value && value->is_jobject(); } - bool local_slot_needs_debuginfo(int index, SharkValue* value) - { + bool local_slot_needs_debuginfo(int index, SharkValue* value) { return true; } }; @@ -339,8 +306,7 @@ // Local slot helper protected: - virtual bool local_slot_needs_read(int index, SharkValue* value) - { + virtual bool local_slot_needs_read(int index, SharkValue* value) { return value && value->is_jobject(); } @@ -358,15 +324,13 @@ ciMethod* _callee; protected: - ciMethod* callee() const - { + ciMethod* callee() const { return _callee; } // Stack slot helper protected: - bool stack_slot_needs_read(int index, SharkValue* value) - { + bool stack_slot_needs_read(int index, SharkValue* value) { return value && (index < callee()->return_type()->size() || value->is_jobject()); } @@ -379,8 +343,7 @@ // Stack slot helper protected: - bool stack_slot_needs_read(int index, SharkValue* value) - { + bool stack_slot_needs_read(int index, SharkValue* value) { return value && value->is_jobject(); } }; @@ -394,8 +357,7 @@ llvm::Value* _method; private: - llvm::Value* method() const - { + llvm::Value* method() const { return _method; } @@ -405,15 +367,13 @@ // Stack slot helper protected: - bool stack_slot_needs_read(int index, SharkValue* value) - { + bool stack_slot_needs_read(int index, SharkValue* value) { ShouldNotReachHere(); // entry block shouldn't have stack } // Local slot helper protected: - bool local_slot_needs_read(int index, SharkValue* value) - { + bool local_slot_needs_read(int index, SharkValue* value) { return value != NULL; } }; @@ -442,8 +402,7 @@ llvm::Value* _osr_buf; private: - llvm::Value* osr_buf() const - { + llvm::Value* osr_buf() const { return _osr_buf; }
--- a/ports/hotspot/src/share/vm/shark/sharkCodeBuffer.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCodeBuffer.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -33,18 +33,15 @@ llvm::Value* _base_pc; private: - MacroAssembler* masm() const - { + MacroAssembler* masm() const { return _masm; } public: - llvm::Value* base_pc() const - { + llvm::Value* base_pc() const { return _base_pc; } - void set_base_pc(llvm::Value* base_pc) - { + void set_base_pc(llvm::Value* base_pc) { assert(_base_pc == NULL, "only do this once"); _base_pc = base_pc; } @@ -53,8 +50,7 @@ // This buffer will have been relocated by the time the method // is installed, so you can't inline the result in code. public: - void* malloc(size_t size) const - { + void* malloc(size_t size) const { masm()->align(BytesPerWord); void *result = masm()->pc(); masm()->advance(size); @@ -63,8 +59,7 @@ // Create a unique offset in the buffer. public: - int create_unique_offset() const - { + int create_unique_offset() const { int offset = masm()->offset(); masm()->advance(1); return offset; @@ -72,8 +67,7 @@ // Inline an oop into the buffer and return its offset. public: - int inline_oop(jobject object) const - { + int inline_oop(jobject object) const { masm()->align(BytesPerWord); int offset = masm()->offset(); masm()->store_oop(object);
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -1,6 +1,6 @@ /* * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2008, 2009 Red Hat, Inc. + * Copyright 2008, 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,15 +30,25 @@ using namespace llvm; +#if SHARK_LLVM_VERSION >= 27 +namespace { + cl::opt<std::string> + MCPU("mcpu"); + + cl::list<std::string> + MAttrs("mattr", + cl::CommaSeparated); +} +#endif + SharkCompiler::SharkCompiler() - : AbstractCompiler() -{ + : AbstractCompiler() { // Create the lock to protect the memory manager and execution engine _execution_engine_lock = new Monitor(Mutex::leaf, "SharkExecutionEngineLock"); MutexLocker locker(execution_engine_lock()); // Make LLVM safe for multithreading - if (!llvm_start_multithreaded()) + if (!llvm_start_multithreaded()) fatal("llvm_start_multithreaded() failed"); // Initialize the native target @@ -77,9 +87,24 @@ cl::ParseCommandLineOptions(args.size() - 1, (char **) &args[0]); // Create the JIT - _execution_engine = ExecutionEngine::createJIT( - _normal_context->module(), - NULL, memory_manager(), CodeGenOpt::Default); + std::string ErrorMsg; + + EngineBuilder builder(_normal_context->module()); + builder.setMCPU(MCPU); + builder.setMAttrs(MAttrs); + builder.setJITMemoryManager(memory_manager()); + builder.setEngineKind(EngineKind::JIT); + builder.setErrorStr(&ErrorMsg); + _execution_engine = builder.create(); + + if (!execution_engine()) { + if (!ErrorMsg.empty()) + printf("Error while creating Shark JIT: %s\n",ErrorMsg.c_str()); + else + printf("Unknown error while creating Shark JIT\n"); + exit(1); + } + execution_engine()->addModule( _native_context->module()); #else @@ -94,13 +119,13 @@ mark_initialized(); } -void SharkCompiler::initialize() -{ +void SharkCompiler::initialize() { ShouldNotCallThis(); } -void SharkCompiler::compile_method(ciEnv* env, ciMethod* target, int entry_bci) -{ +void SharkCompiler::compile_method(ciEnv* env, + ciMethod* target, + int entry_bci) { assert(is_initialized(), "should be"); ResourceMark rm; const char *name = methodname( @@ -136,7 +161,7 @@ // Emit the entry point SharkEntry *entry = (SharkEntry *) cb.malloc(sizeof(SharkEntry)); - + // Build the LLVM IR for the method Function *function = SharkFunction::build(env, &builder, flow, name); @@ -157,7 +182,7 @@ ExceptionHandlerTable handler_table; ImplicitExceptionTable inc_table; - + env->register_method(target, entry_bci, &offsets, @@ -176,8 +201,7 @@ nmethod* SharkCompiler::generate_native_wrapper(MacroAssembler* masm, methodHandle target, BasicType* arg_types, - BasicType return_type) -{ + BasicType return_type) { assert(is_initialized(), "should be"); ResourceMark rm; const char *name = methodname( @@ -210,8 +234,7 @@ void SharkCompiler::generate_native_code(SharkEntry* entry, Function* function, - const char* name) -{ + const char* name) { // Print the LLVM bitcode, if requested if (SharkPrintBitcodeOf != NULL) { if (!fnmatch(SharkPrintBitcodeOf, name, 0)) @@ -232,7 +255,7 @@ llvm::DebugFlag = true; } else { - llvm::SetCurrentDebugType(""); + llvm::SetCurrentDebugType(""); llvm::DebugFlag = false; } #else @@ -268,8 +291,7 @@ } } -void SharkCompiler::free_compiled_method(address code) -{ +void SharkCompiler::free_compiled_method(address code) { // This method may only be called when the VM is at a safepoint. // All _thread_in_vm threads will be waiting for the safepoint to // finish with the exception of the VM thread, so we can consider @@ -282,8 +304,7 @@ entry->context()->push_to_free_queue(entry->function()); } -void SharkCompiler::free_queued_methods() -{ +void SharkCompiler::free_queued_methods() { // The free queue is protected by the execution engine lock assert(execution_engine_lock()->owned_by_self(), "should be"); @@ -293,12 +314,11 @@ break; execution_engine()->freeMachineCodeForFunction(function); - function->eraseFromParent(); + function->eraseFromParent(); } } -const char* SharkCompiler::methodname(const char* klass, const char* method) -{ +const char* SharkCompiler::methodname(const char* klass, const char* method) { char *buf = NEW_RESOURCE_ARRAY(char, strlen(klass) + 2 + strlen(method) + 1); char *dst = buf;
--- a/ports/hotspot/src/share/vm/shark/sharkCompiler.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkCompiler.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -67,8 +67,7 @@ SharkContext* _native_context; public: - SharkContext* context() const - { + SharkContext* context() const { if (JavaThread::current()->is_Compiler_thread()) { return _normal_context; } @@ -89,25 +88,21 @@ llvm::ExecutionEngine* _execution_engine; private: - Monitor* execution_engine_lock() const - { + Monitor* execution_engine_lock() const { return _execution_engine_lock; } - SharkMemoryManager* memory_manager() const - { + SharkMemoryManager* memory_manager() const { assert(execution_engine_lock()->owned_by_self(), "should be"); return _memory_manager; } - llvm::ExecutionEngine* execution_engine() const - { + llvm::ExecutionEngine* execution_engine() const { assert(execution_engine_lock()->owned_by_self(), "should be"); return _execution_engine; } // Global access public: - static SharkCompiler* compiler() - { + static SharkCompiler* compiler() { AbstractCompiler *compiler = CompileBroker::compiler(CompLevel_fast_compile); assert(compiler->is_shark() && compiler->is_initialized(), "should be");
--- a/ports/hotspot/src/share/vm/shark/sharkConstant.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkConstant.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -SharkConstant* SharkConstant::for_ldc(ciBytecodeStream *iter) -{ +SharkConstant* SharkConstant::for_ldc(ciBytecodeStream *iter) { ciConstant constant = iter->get_constant(); ciType *type = NULL; if (constant.basic_type() == T_OBJECT) { @@ -42,8 +41,7 @@ return new SharkConstant(constant, type); } -SharkConstant* SharkConstant::for_field(ciBytecodeStream *iter) -{ +SharkConstant* SharkConstant::for_field(ciBytecodeStream *iter) { bool will_link; ciField *field = iter->get_field(will_link); assert(will_link, "typeflow responsibility"); @@ -51,8 +49,7 @@ return new SharkConstant(field->constant_value(), field->type()); } -SharkConstant::SharkConstant(ciConstant constant, ciType *type) -{ +SharkConstant::SharkConstant(ciConstant constant, ciType *type) { SharkValue *value = NULL; switch (constant.basic_type()) {
--- a/ports/hotspot/src/share/vm/shark/sharkConstant.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkConstant.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -40,24 +40,20 @@ bool _is_two_word; public: - bool is_loaded() const - { + bool is_loaded() const { return _is_loaded; } - bool is_nonzero() const - { + bool is_nonzero() const { assert(is_loaded(), "should be"); return _is_nonzero; } - bool is_two_word() const - { + bool is_two_word() const { assert(is_loaded(), "should be"); return _is_two_word; } public: - SharkValue* value(SharkBuilder* builder) - { + SharkValue* value(SharkBuilder* builder) { assert(is_loaded(), "should be"); if (_value == NULL) { _value = SharkValue::create_generic(
--- a/ports/hotspot/src/share/vm/shark/sharkContext.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkContext.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -30,8 +30,7 @@ SharkContext::SharkContext(const char* name) : LLVMContext(), - _free_queue(NULL) -{ + _free_queue(NULL) { // Create a module to build our functions into _module = new Module(name, *this); @@ -93,7 +92,7 @@ _to_stackType[i] = jint_type(); _to_arrayType[i] = jbyte_type(); break; - + case T_BYTE: _to_stackType[i] = jint_type(); _to_arrayType[i] = jbyte_type(); @@ -157,23 +156,19 @@ SharkFreeQueueItem* _next; public: - llvm::Function* function() const - { + llvm::Function* function() const { return _function; } - SharkFreeQueueItem* next() const - { + SharkFreeQueueItem* next() const { return _next; } }; -void SharkContext::push_to_free_queue(Function* function) -{ +void SharkContext::push_to_free_queue(Function* function) { _free_queue = new SharkFreeQueueItem(function, _free_queue); } -Function* SharkContext::pop_from_free_queue() -{ +Function* SharkContext::pop_from_free_queue() { if (_free_queue == NULL) return NULL;
--- a/ports/hotspot/src/share/vm/shark/sharkContext.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkContext.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -1,6 +1,6 @@ /* * Copyright 1999-2007 Sun Microsystems, Inc. All Rights Reserved. - * Copyright 2009 Red Hat, Inc. + * Copyright 2009, 2010 Red Hat, Inc. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,32 +41,28 @@ #else private: #endif - llvm::Module* module() const - { + llvm::Module* module() const { return _module; } // Get this thread's SharkContext public: - static SharkContext& current() - { + static SharkContext& current() { return *SharkCompiler::compiler()->context(); } // Module accessors public: #if SHARK_LLVM_VERSION < 27 - llvm::ModuleProvider* module_provider() const - { + llvm::ModuleProvider* module_provider() const { return new llvm::ExistingModuleProvider(module()); } #endif - void add_function(llvm::Function* function) const - { + void add_function(llvm::Function* function) const { module()->getFunctionList().push_back(function); } - llvm::Constant* get_external(const char* name, const llvm::FunctionType* sig) - { + llvm::Constant* get_external(const char* name, + const llvm::FunctionType* sig) { return module()->getOrInsertFunction(name, sig); } @@ -82,40 +78,31 @@ const llvm::Type* _jdouble_type; public: - const llvm::Type* void_type() const - { + const llvm::Type* void_type() const { return _void_type; } - const llvm::IntegerType* bit_type() const - { + const llvm::IntegerType* bit_type() const { return _bit_type; } - const llvm::IntegerType* jbyte_type() const - { + const llvm::IntegerType* jbyte_type() const { return _jbyte_type; } - const llvm::IntegerType* jshort_type() const - { + const llvm::IntegerType* jshort_type() const { return _jshort_type; } - const llvm::IntegerType* jint_type() const - { + const llvm::IntegerType* jint_type() const { return _jint_type; } - const llvm::IntegerType* jlong_type() const - { + const llvm::IntegerType* jlong_type() const { return _jlong_type; } - const llvm::Type* jfloat_type() const - { + const llvm::Type* jfloat_type() const { return _jfloat_type; } - const llvm::Type* jdouble_type() const - { + const llvm::Type* jdouble_type() const { return _jdouble_type; } - const llvm::IntegerType* intptr_type() const - { + const llvm::IntegerType* intptr_type() const { return LP64_ONLY(jlong_type()) NOT_LP64(jint_type()); } @@ -134,48 +121,37 @@ const llvm::FunctionType* _osr_entry_point_type; public: - const llvm::PointerType* itableOffsetEntry_type() const - { + const llvm::PointerType* itableOffsetEntry_type() const { return _itableOffsetEntry_type; } - const llvm::PointerType* jniEnv_type() const - { + const llvm::PointerType* jniEnv_type() const { return _jniEnv_type; } - const llvm::PointerType* jniHandleBlock_type() const - { + const llvm::PointerType* jniHandleBlock_type() const { return _jniHandleBlock_type; } - const llvm::PointerType* klass_type() const - { + const llvm::PointerType* klass_type() const { return _klass_type; } - const llvm::PointerType* methodOop_type() const - { + const llvm::PointerType* methodOop_type() const { return _methodOop_type; } - const llvm::ArrayType* monitor_type() const - { + const llvm::ArrayType* monitor_type() const { return _monitor_type; } - const llvm::PointerType* oop_type() const - { + const llvm::PointerType* oop_type() const { return _oop_type; } - const llvm::PointerType* thread_type() const - { + const llvm::PointerType* thread_type() const { return _thread_type; } - const llvm::PointerType* zeroStack_type() const - { + const llvm::PointerType* zeroStack_type() const { return _zeroStack_type; } - const llvm::FunctionType* entry_point_type() const - { + const llvm::FunctionType* entry_point_type() const { return _entry_point_type; } - const llvm::FunctionType* osr_entry_point_type() const - { + const llvm::FunctionType* osr_entry_point_type() const { return _osr_entry_point_type; } @@ -186,21 +162,18 @@ private: const llvm::Type* map_type(const llvm::Type* const* table, - BasicType type) const - { + BasicType type) const { assert(type >= 0 && type < T_CONFLICT, "unhandled type"); const llvm::Type* result = table[type]; assert(type != NULL, "unhandled type"); return result; } - + public: - const llvm::Type* to_stackType(BasicType type) const - { + const llvm::Type* to_stackType(BasicType type) const { return map_type(_to_stackType, type); } - const llvm::Type* to_arrayType(BasicType type) const - { + const llvm::Type* to_arrayType(BasicType type) const { return map_type(_to_arrayType, type); }
--- a/ports/hotspot/src/share/vm/shark/sharkEntry.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkEntry.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -32,34 +32,27 @@ llvm::Function* _function; public: - address code_start() const - { + address code_start() const { return entry_point(); } - address code_limit() const - { + address code_limit() const { return _code_limit; } - SharkContext* context() const - { + SharkContext* context() const { return _context; } - llvm::Function* function() const - { + llvm::Function* function() const { return _function; } public: - void set_code_limit(address code_limit) - { + void set_code_limit(address code_limit) { _code_limit = code_limit; } - void set_context(SharkContext* context) - { + void set_context(SharkContext* context) { _context = context; } - void set_function(llvm::Function* function) - { + void set_function(llvm::Function* function) { _function = function; } };
--- a/ports/hotspot/src/share/vm/shark/sharkFunction.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkFunction.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkFunction::initialize(const char *name) -{ +void SharkFunction::initialize(const char *name) { // Create the function _function = Function::Create( entry_point_type(), @@ -98,10 +97,10 @@ SharkTopLevelBlock *locker = new SharkTopLevelBlock(this, start_block->ciblock()); locker->add_incoming(entry_state); - + set_block_insertion_point(start_block->entry_block()); locker->acquire_method_lock(); - + entry_state = locker->current_state(); } } @@ -134,8 +133,7 @@ _bci(block->bci()), _state(block->current_state()->copy()), _check_block(builder()->GetInsertBlock()), - _continue_block(function()->CreateBlock("not_zero")) - { + _continue_block(function()->CreateBlock("not_zero")) { builder()->SetInsertPoint(continue_block()); } @@ -146,55 +144,45 @@ SharkState* _state; BasicBlock* _check_block; BasicBlock* _continue_block; - + public: - SharkTopLevelBlock* block() const - { + SharkTopLevelBlock* block() const { return _block; } - SharkValue* value() const - { + SharkValue* value() const { return _value; } - int bci() const - { + int bci() const { return _bci; - } - SharkState* state() const - { + } + SharkState* state() const { return _state; - } - BasicBlock* check_block() const - { + } + BasicBlock* check_block() const { return _check_block; } - BasicBlock* continue_block() const - { + BasicBlock* continue_block() const { return _continue_block; } public: - SharkFunction* function() const - { + SharkFunction* function() const { return block()->function(); } public: - void process() const - { + void process() const { builder()->SetInsertPoint(check_block()); block()->do_deferred_zero_check(value(), bci(), state(), continue_block()); } }; void SharkFunction::add_deferred_zero_check(SharkTopLevelBlock* block, - SharkValue* value) -{ + SharkValue* value) { deferred_zero_checks()->append(new DeferredZeroCheck(block, value)); } -void SharkFunction::do_deferred_zero_checks() -{ +void SharkFunction::do_deferred_zero_checks() { for (int i = 0; i < deferred_zero_checks()->length(); i++) deferred_zero_checks()->at(i)->process(); }
--- a/ports/hotspot/src/share/vm/shark/sharkFunction.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkFunction.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,13 +28,12 @@ class SharkFunction : public SharkTargetInvariants { friend class SharkStackWithNormalFrame; - + public: static llvm::Function* build(ciEnv* env, SharkBuilder* builder, ciTypeFlow* flow, - const char* name) - { + const char* name) { SharkFunction function(env, builder, flow, name); return function.function(); } @@ -56,38 +55,31 @@ SharkStack* _stack; public: - llvm::Function* function() const - { + llvm::Function* function() const { return _function; } - int block_count() const - { + int block_count() const { return flow()->block_count(); } - SharkTopLevelBlock* block(int i) const - { + SharkTopLevelBlock* block(int i) const { assert(i < block_count(), "should be"); return _blocks[i]; } - GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() - { + GrowableArray<DeferredZeroCheck*>* deferred_zero_checks() { return &_deferred_zero_checks; } - SharkStack* stack() const - { + SharkStack* stack() const { return _stack; } // On-stack replacement private: - bool is_osr() const - { + bool is_osr() const { return flow()->is_osr_flow(); } - const llvm::FunctionType* entry_point_type() const - { + const llvm::FunctionType* entry_point_type() const { if (is_osr()) - return SharkType::osr_entry_point_type(); + return SharkType::osr_entry_point_type(); else return SharkType::entry_point_type(); } @@ -96,18 +88,15 @@ private: llvm::BasicBlock* _block_insertion_point; - void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) - { + void set_block_insertion_point(llvm::BasicBlock* block_insertion_point) { _block_insertion_point = block_insertion_point; } - llvm::BasicBlock* block_insertion_point() const - { + llvm::BasicBlock* block_insertion_point() const { return _block_insertion_point; } public: - llvm::BasicBlock* CreateBlock(const char* name = "") const - { + llvm::BasicBlock* CreateBlock(const char* name = "") const { return llvm::BasicBlock::Create( SharkContext::current(), name, function(), block_insertion_point()); }
--- a/ports/hotspot/src/share/vm/shark/sharkInliner.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkInliner.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -33,8 +33,7 @@ SharkInlineBlock(ciMethod* target, SharkState* state) : SharkBlock(state, target), _outer_state(state), - _entry_state(new SharkState(this)) - { + _entry_state(new SharkState(this)) { for (int i = target->max_locals() - 1; i >= 0; i--) { SharkValue *value = NULL; if (i < target->arg_size()) @@ -48,24 +47,20 @@ SharkState* _entry_state; private: - SharkState* outer_state() - { + SharkState* outer_state() { return _outer_state; } - SharkState* entry_state() - { + SharkState* entry_state() { return _entry_state; } public: - void emit_IR() - { + void emit_IR() { parse_bytecode(0, target()->code_size()); } private: - void do_return(BasicType type) - { + void do_return(BasicType type) { if (type != T_VOID) { SharkValue *result = pop_result(type); outer_state()->push(result); @@ -86,35 +81,29 @@ ciBytecodeStream _iter; SharkState* _entry_state; ciMethod* _target; - + public: - ciBytecodeStream* iter() - { + ciBytecodeStream* iter() { return &_iter; } - SharkState* entry_state() const - { + SharkState* entry_state() const { return _entry_state; } - ciMethod* target() const - { + ciMethod* target() const { return _target; } public: - Bytecodes::Code bc() - { + Bytecodes::Code bc() { return iter()->cur_bc(); } - int max_locals() const - { + int max_locals() const { return target()->max_locals(); } - int max_stack() const - { + int max_stack() const { return target()->max_stack(); } - + // Inlinability check public: bool is_inlinable(); @@ -122,16 +111,13 @@ private: void initialize_for_check(); - bool do_getstatic() - { + bool do_getstatic() { return do_field_access(true, false); } - bool do_getfield() - { + bool do_getfield() { return do_field_access(true, true); } - bool do_putfield() - { + bool do_putfield() { return do_field_access(false, true); } bool do_field_access(bool is_get, bool is_field); @@ -141,17 +127,14 @@ bool* _locals; public: - bool* local_addr(int index) const - { + bool* local_addr(int index) const { assert(index >= 0 && index < max_locals(), "bad local variable index"); return &_locals[index]; } - bool local(int index) const - { + bool local(int index) const { return *local_addr(index); } - void set_local(int index, bool value) - { + void set_local(int index, bool value) { *local_addr(index) = value; } @@ -161,50 +144,42 @@ bool* _sp; public: - int stack_depth() const - { + int stack_depth() const { return _sp - _stack; } - bool* stack_addr(int slot) const - { + bool* stack_addr(int slot) const { assert(slot >= 0 && slot < stack_depth(), "bad stack slot"); return &_sp[-(slot + 1)]; } - void push(bool value) - { + void push(bool value) { assert(stack_depth() < max_stack(), "stack overrun"); *(_sp++) = value; } - bool pop() - { + bool pop() { assert(stack_depth() > 0, "stack underrun"); return *(--_sp); } // Methods for two-word locals public: - void push_pair_local(int index) - { + void push_pair_local(int index) { push(local(index)); push(local(index + 1)); } - void pop_pair_local(int index) - { + void pop_pair_local(int index) { set_local(index + 1, pop()); set_local(index, pop()); } // Code generation public: - void do_inline() - { + void do_inline() { (new SharkInlineBlock(target(), entry_state()))->emit_IR(); } }; // Quick checks so we can bail out before doing too much -bool SharkInliner::may_be_inlinable(ciMethod *target) -{ +bool SharkInliner::may_be_inlinable(ciMethod *target) { // We can't inline native methods if (target->is_native()) return false; @@ -252,8 +227,7 @@ // check eliminator to strip the checks. To do that, we need to // walk through the method, tracking which values are and are not // zero-checked. -bool SharkInlinerHelper::is_inlinable() -{ +bool SharkInlinerHelper::is_inlinable() { ResourceMark rm; initialize_for_check(); @@ -285,7 +259,7 @@ case Bytecodes::_lconst_0: push(false); push(false); - break; + break; case Bytecodes::_lconst_1: push(true); push(false); @@ -428,25 +402,25 @@ pop(); pop(); break; - case Bytecodes::_swap: + case Bytecodes::_swap: a = pop(); b = pop(); push(a); push(b); - break; + break; case Bytecodes::_dup: a = pop(); push(a); push(a); break; - case Bytecodes::_dup_x1: + case Bytecodes::_dup_x1: a = pop(); b = pop(); push(a); push(b); push(a); break; - case Bytecodes::_dup_x2: + case Bytecodes::_dup_x2: a = pop(); b = pop(); c = pop(); @@ -455,7 +429,7 @@ push(b); push(a); break; - case Bytecodes::_dup2: + case Bytecodes::_dup2: a = pop(); b = pop(); push(b); @@ -525,7 +499,7 @@ break; case Bytecodes::_ineg: break; - + case Bytecodes::_ladd: case Bytecodes::_lsub: case Bytecodes::_lmul: @@ -610,7 +584,7 @@ pop(); push(false); break; - + case Bytecodes::_dcmpl: case Bytecodes::_dcmpg: pop(); @@ -693,8 +667,7 @@ return true; } -void SharkInlinerHelper::initialize_for_check() -{ +void SharkInlinerHelper::initialize_for_check() { _locals = NEW_RESOURCE_ARRAY(bool, max_locals()); _stack = NEW_RESOURCE_ARRAY(bool, max_stack()); @@ -708,8 +681,7 @@ _sp = _stack; } -bool SharkInlinerHelper::do_field_access(bool is_get, bool is_field) -{ +bool SharkInlinerHelper::do_field_access(bool is_get, bool is_field) { assert(is_get || is_field, "can't inline putstatic"); // If the holder isn't linked then there isn't a lot we can do @@ -760,8 +732,7 @@ return true; } -bool SharkInliner::attempt_inline(ciMethod *target, SharkState *state) -{ +bool SharkInliner::attempt_inline(ciMethod *target, SharkState *state) { if (SharkIntrinsics::is_intrinsic(target)) { SharkIntrinsics::inline_intrinsic(target, state); return true;
--- a/ports/hotspot/src/share/vm/shark/sharkInliner.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkInliner.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -26,7 +26,7 @@ class SharkInliner : public AllStatic { public: static bool attempt_inline(ciMethod* target, SharkState* state); - + private: static bool may_be_inlinable(ciMethod* target); };
--- a/ports/hotspot/src/share/vm/shark/sharkIntrinsics.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkIntrinsics.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -bool SharkIntrinsics::is_intrinsic(ciMethod *target) -{ +bool SharkIntrinsics::is_intrinsic(ciMethod *target) { switch (target->intrinsic_id()) { case vmIntrinsics::_none: return false; @@ -75,14 +74,12 @@ return false; } -void SharkIntrinsics::inline_intrinsic(ciMethod *target, SharkState *state) -{ +void SharkIntrinsics::inline_intrinsic(ciMethod *target, SharkState *state) { SharkIntrinsics intrinsic(state, target); intrinsic.do_intrinsic(); } -void SharkIntrinsics::do_intrinsic() -{ +void SharkIntrinsics::do_intrinsic() { switch (target()->intrinsic_id()) { // java.lang.Math case vmIntrinsics::_min: @@ -136,7 +133,7 @@ case vmIntrinsics::_currentThread: do_Thread_currentThread(); break; - + // sun.misc.Unsafe case vmIntrinsics::_compareAndSwapInt: do_Unsafe_compareAndSwapInt(); @@ -147,13 +144,12 @@ } } -void SharkIntrinsics::do_Math_minmax(ICmpInst::Predicate p) -{ +void SharkIntrinsics::do_Math_minmax(ICmpInst::Predicate p) { // Pop the arguments SharkValue *sb = state()->pop(); SharkValue *sa = state()->pop(); Value *a = sa->jint_value(); - Value *b = sb->jint_value(); + Value *b = sb->jint_value(); // Perform the test BasicBlock *ip = builder()->GetBlockInsertionPoint(); @@ -181,8 +177,7 @@ sa->zero_checked() && sb->zero_checked())); } -void SharkIntrinsics::do_Math_1to1(Value *function) -{ +void SharkIntrinsics::do_Math_1to1(Value *function) { SharkValue *empty = state()->pop(); assert(empty == NULL, "should be"); state()->push( @@ -192,8 +187,7 @@ state()->push(NULL); } -void SharkIntrinsics::do_Math_2to1(Value *function) -{ +void SharkIntrinsics::do_Math_2to1(Value *function) { SharkValue *empty = state()->pop(); assert(empty == NULL, "should be"); Value *y = state()->pop()->jdouble_value(); @@ -207,8 +201,7 @@ state()->push(NULL); } -void SharkIntrinsics::do_Object_getClass() -{ +void SharkIntrinsics::do_Object_getClass() { Value *klass = builder()->CreateValueOfStructEntry( state()->pop()->jobject_value(), in_ByteSize(oopDesc::klass_offset_in_bytes()), @@ -231,8 +224,7 @@ true)); } -void SharkIntrinsics::do_System_currentTimeMillis() -{ +void SharkIntrinsics::do_System_currentTimeMillis() { state()->push( SharkValue::create_jlong( builder()->CreateCall(builder()->current_time_millis()), @@ -240,8 +232,7 @@ state()->push(NULL); } -void SharkIntrinsics::do_Thread_currentThread() -{ +void SharkIntrinsics::do_Thread_currentThread() { state()->push( SharkValue::create_jobject( builder()->CreateValueOfStructEntry( @@ -251,8 +242,7 @@ true)); } -void SharkIntrinsics::do_Unsafe_compareAndSwapInt() -{ +void SharkIntrinsics::do_Unsafe_compareAndSwapInt() { // Pop the arguments Value *x = state()->pop()->jint_value(); Value *e = state()->pop()->jint_value();
--- a/ports/hotspot/src/share/vm/shark/sharkIntrinsics.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkIntrinsics.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -36,8 +36,7 @@ SharkState* _state; private: - SharkState* state() const - { + SharkState* state() const { return _state; }
--- a/ports/hotspot/src/share/vm/shark/sharkInvariants.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkInvariants.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -26,8 +26,7 @@ #include "incls/_precompiled.incl" #include "incls/_sharkInvariants.cpp.incl" -int SharkTargetInvariants::count_monitors() -{ +int SharkTargetInvariants::count_monitors() { int result = 0; if (is_synchronized() || target()->has_monitor_bytecodes()) { for (int i = 0; i < flow()->block_count(); i++) {
--- a/ports/hotspot/src/share/vm/shark/sharkInvariants.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkInvariants.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -56,16 +56,14 @@ // Accessing this directly is kind of ugly, so it's private. Add // new accessors below if you need something from it. private: - ciEnv* env() const - { + ciEnv* env() const { assert(_env != NULL, "env not available"); return _env; } // The SharkBuilder that is used to build LLVM IR. protected: - SharkBuilder* builder() const - { + SharkBuilder* builder() const { return _builder; } @@ -74,36 +72,30 @@ // so a setter is required. Assertions are used to enforce // invariance. protected: - llvm::Value* thread() const - { + llvm::Value* thread() const { assert(_thread != NULL, "thread not available"); return _thread; } - void set_thread(llvm::Value* thread) - { + void set_thread(llvm::Value* thread) { assert(_thread == NULL, "thread already set"); _thread = thread; } - + // Objects that handle various aspects of the compilation. protected: - DebugInformationRecorder* debug_info() const - { + DebugInformationRecorder* debug_info() const { return env()->debug_info(); } - Dependencies* dependencies() const - { + Dependencies* dependencies() const { return env()->dependencies(); } - SharkCodeBuffer* code_buffer() const - { + SharkCodeBuffer* code_buffer() const { return builder()->code_buffer(); } // That well-known class... protected: - ciInstanceKlass* java_lang_Object_klass() const - { + ciInstanceKlass* java_lang_Object_klass() const { return env()->Object_klass(); } }; @@ -138,43 +130,35 @@ // The method being compiled. protected: - ciMethod* target() const - { + ciMethod* target() const { return _target; } // Typeflow analysis of the method being compiled. protected: - ciTypeFlow* flow() const - { + ciTypeFlow* flow() const { assert(_flow != NULL, "typeflow not available"); return _flow; } // Properties of the method. protected: - int max_locals() const - { + int max_locals() const { return target()->max_locals(); } - int max_stack() const - { + int max_stack() const { return target()->max_stack(); } - int max_monitors() const - { + int max_monitors() const { return _max_monitors; } - int arg_size() const - { + int arg_size() const { return target()->arg_size(); } - bool is_static() const - { + bool is_static() const { return target()->is_static(); } - bool is_synchronized() const - { + bool is_synchronized() const { return target()->is_synchronized(); } };
--- a/ports/hotspot/src/share/vm/shark/sharkMemoryManager.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkMemoryManager.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,33 +28,28 @@ using namespace llvm; -void SharkMemoryManager::AllocateGOT() -{ +void SharkMemoryManager::AllocateGOT() { mm()->AllocateGOT(); } -unsigned char* SharkMemoryManager::getGOTBase() const -{ +unsigned char* SharkMemoryManager::getGOTBase() const { return mm()->getGOTBase(); } unsigned char* SharkMemoryManager::allocateStub(const GlobalValue* F, unsigned StubSize, - unsigned Alignment) -{ + unsigned Alignment) { return mm()->allocateStub(F, StubSize, Alignment); } unsigned char* SharkMemoryManager::startFunctionBody(const Function* F, - uintptr_t& ActualSize) -{ + uintptr_t& ActualSize) { return mm()->startFunctionBody(F, ActualSize); } void SharkMemoryManager::endFunctionBody(const Function* F, unsigned char* FunctionStart, - unsigned char* FunctionEnd) -{ + unsigned char* FunctionEnd) { mm()->endFunctionBody(F, FunctionStart, FunctionEnd); SharkEntry *entry = get_entry_for_function(F); @@ -63,71 +58,59 @@ } unsigned char* SharkMemoryManager::startExceptionTable(const Function* F, - uintptr_t& ActualSize) -{ + uintptr_t& ActualSize) { return mm()->startExceptionTable(F, ActualSize); } void SharkMemoryManager::endExceptionTable(const Function* F, unsigned char* TableStart, unsigned char* TableEnd, - unsigned char* FrameRegister) -{ + unsigned char* FrameRegister) { mm()->endExceptionTable(F, TableStart, TableEnd, FrameRegister); } -void SharkMemoryManager::setMemoryWritable() -{ +void SharkMemoryManager::setMemoryWritable() { mm()->setMemoryWritable(); } -void SharkMemoryManager::setMemoryExecutable() -{ +void SharkMemoryManager::setMemoryExecutable() { mm()->setMemoryExecutable(); } #if SHARK_LLVM_VERSION >= 27 -void SharkMemoryManager::deallocateExceptionTable(void *ptr) -{ +void SharkMemoryManager::deallocateExceptionTable(void *ptr) { mm()->deallocateExceptionTable(ptr); } -void SharkMemoryManager::deallocateFunctionBody(void *ptr) -{ +void SharkMemoryManager::deallocateFunctionBody(void *ptr) { mm()->deallocateFunctionBody(ptr); } #else -void SharkMemoryManager::deallocateMemForFunction(const Function* F) -{ +void SharkMemoryManager::deallocateMemForFunction(const Function* F) { return mm()->deallocateMemForFunction(F); } #endif uint8_t* SharkMemoryManager::allocateGlobal(uintptr_t Size, - unsigned int Alignment) -{ + unsigned int Alignment) { return mm()->allocateGlobal(Size, Alignment); } #if SHARK_LLVM_VERSION < 27 -void* SharkMemoryManager::getDlsymTable() const -{ +void* SharkMemoryManager::getDlsymTable() const { return mm()->getDlsymTable(); } -void SharkMemoryManager::SetDlsymTable(void *ptr) -{ +void SharkMemoryManager::SetDlsymTable(void *ptr) { mm()->SetDlsymTable(ptr); } #endif -void SharkMemoryManager::setPoisonMemory(bool poison) -{ +void SharkMemoryManager::setPoisonMemory(bool poison) { mm()->setPoisonMemory(poison); } unsigned char *SharkMemoryManager::allocateSpace(intptr_t Size, - unsigned int Alignment) -{ + unsigned int Alignment) { return mm()->allocateSpace(Size, Alignment); }
--- a/ports/hotspot/src/share/vm/shark/sharkMemoryManager.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkMemoryManager.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -36,8 +36,7 @@ llvm::JITMemoryManager* _mm; private: - llvm::JITMemoryManager* mm() const - { + llvm::JITMemoryManager* mm() const { return _mm; } @@ -45,12 +44,11 @@ std::map<const llvm::Function*, SharkEntry*> _entry_map; public: - void set_entry_for_function(const llvm::Function* function, SharkEntry* entry) - { + void set_entry_for_function(const llvm::Function* function, + SharkEntry* entry) { _entry_map[function] = entry; } - SharkEntry* get_entry_for_function(const llvm::Function* function) - { + SharkEntry* get_entry_for_function(const llvm::Function* function) { return _entry_map[function]; } @@ -86,5 +84,5 @@ void deallocateMemForFunction(const llvm::Function* F); #endif unsigned char *allocateSpace(intptr_t Size, - unsigned int Alignment); + unsigned int Alignment); };
--- a/ports/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkNativeWrapper.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkNativeWrapper::initialize(const char *name) -{ +void SharkNativeWrapper::initialize(const char *name) { // Create the function _function = Function::Create( SharkType::entry_point_type(), @@ -144,8 +143,8 @@ builder()->CreateBr(merge); builder()->SetInsertPoint(not_null); - builder()->CreateBr(merge); - + builder()->CreateBr(merge); + builder()->SetInsertPoint(merge); phi = builder()->CreatePHI(box_type, "boxed_object"); phi->addIncoming(ConstantPointerNull::get(box_type), null); @@ -173,7 +172,7 @@ param_types.push_back(param_type); param_values.push_back( builder()->CreateLoad(stack()->slot_addr(adjusted_offset, param_type))); - } + } } // The oopmap is now complete, and everything is written @@ -255,7 +254,7 @@ thread_state, LLVMValue::jint_constant(0)), do_safepoint, safepointed); - + builder()->SetInsertPoint(do_safepoint); builder()->CreateCall( builder()->check_special_condition_for_native_trans(), thread); @@ -312,7 +311,7 @@ // Reset handle block CreateResetHandleBlock(); - // Unlock if necessary. + // Unlock if necessary. if (is_synchronized()) Unimplemented(); @@ -330,7 +329,7 @@ case T_BYTE: needs_cast = true; break; - + case T_CHAR: case T_SHORT: needs_cast = true; @@ -343,7 +342,7 @@ } builder()->CreateStore( - result, + result, builder()->CreateIntToPtr( result_addr, PointerType::getUnqual(SharkType::to_stackType(result_type))));
--- a/ports/hotspot/src/share/vm/shark/sharkNativeWrapper.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkNativeWrapper.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -25,14 +25,13 @@ class SharkNativeWrapper : public SharkCompileInvariants { friend class SharkStackWithNativeFrame; - + public: static SharkNativeWrapper* build(SharkBuilder* builder, methodHandle target, const char* name, BasicType* arg_types, - BasicType return_type) - { + BasicType return_type) { return new SharkNativeWrapper(builder, target, name, @@ -68,106 +67,87 @@ // The method being compiled. protected: - methodHandle target() const - { + methodHandle target() const { return _target; } // Properties of the method. protected: - int arg_size() const - { + int arg_size() const { return target()->size_of_parameters(); } - BasicType arg_type(int i) const - { + BasicType arg_type(int i) const { return _arg_types[i]; } - BasicType return_type() const - { + BasicType return_type() const { return _return_type; } - bool is_static() const - { + bool is_static() const { return target()->is_static(); } - bool is_synchronized() const - { + bool is_synchronized() const { return target()->is_synchronized(); } - bool is_returning_oop() const - { + bool is_returning_oop() const { return target()->is_returning_oop(); } // The LLVM function we are building. public: - llvm::Function* function() const - { + llvm::Function* function() const { return _function; } // The Zero stack and our frame on it. protected: - SharkStack* stack() const - { + SharkStack* stack() const { return _stack; } // Temporary oop storage. protected: - llvm::Value* oop_tmp_slot() const - { + llvm::Value* oop_tmp_slot() const { assert(is_static() || is_returning_oop(), "should be"); return _oop_tmp_slot; } // Information required by nmethod::new_native_nmethod(). public: - int frame_size() const - { + int frame_size() const { return stack()->oopmap_frame_size(); } - ByteSize receiver_offset() const - { + ByteSize receiver_offset() const { return in_ByteSize(_receiver_slot_offset * wordSize); } - ByteSize lock_offset() const - { + ByteSize lock_offset() const { return in_ByteSize(_lock_slot_offset * wordSize); } - OopMapSet* oop_maps() const - { + OopMapSet* oop_maps() const { return _oop_maps; } // Helpers. private: - llvm::BasicBlock* CreateBlock(const char* name = "") const - { + llvm::BasicBlock* CreateBlock(const char* name = "") const { return llvm::BasicBlock::Create(SharkContext::current(), name, function()); } - llvm::Value* thread_state_address() const - { + llvm::Value* thread_state_address() const { return builder()->CreateAddressOfStructEntry( thread(), JavaThread::thread_state_offset(), llvm::PointerType::getUnqual(SharkType::jint_type()), "thread_state_address"); } - llvm::Value* pending_exception_address() const - { + llvm::Value* pending_exception_address() const { return builder()->CreateAddressOfStructEntry( thread(), Thread::pending_exception_offset(), llvm::PointerType::getUnqual(SharkType::oop_type()), "pending_exception_address"); } - void CreateSetThreadState(JavaThreadState state) const - { + void CreateSetThreadState(JavaThreadState state) const { builder()->CreateStore( LLVMValue::jint_constant(state), thread_state_address()); } - void CreateWriteMemorySerializePage() const - { + void CreateWriteMemorySerializePage() const { builder()->CreateStore( LLVMValue::jint_constant(1), builder()->CreateIntToPtr( @@ -181,8 +161,7 @@ LLVMValue::intptr_constant(os::get_serialize_page_mask()))), llvm::PointerType::getUnqual(SharkType::jint_type()))); } - void CreateResetHandleBlock() const - { + void CreateResetHandleBlock() const { llvm::Value *active_handles = builder()->CreateValueOfStructEntry( thread(), JavaThread::active_handles_offset(), @@ -196,8 +175,7 @@ llvm::PointerType::getUnqual(SharkType::intptr_type()), "top")); } - llvm::LoadInst* CreateLoadPendingException() const - { + llvm::LoadInst* CreateLoadPendingException() const { return builder()->CreateLoad( pending_exception_address(), "pending_exception"); }
--- a/ports/hotspot/src/share/vm/shark/sharkRuntime.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkRuntime.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -31,7 +31,6 @@ JRT_ENTRY(int, SharkRuntime::find_exception_handler(JavaThread* thread, int* indexes, int num_indexes)) -{ constantPoolHandle pool(thread, method(thread)->constants()); KlassHandle exc_klass(thread, ((oop) tos_at(thread, 0))->klass()); @@ -47,16 +46,14 @@ } return -1; -} JRT_END JRT_ENTRY(void, SharkRuntime::monitorenter(JavaThread* thread, BasicObjectLock* lock)) -{ if (PrintBiasedLockingStatistics) Atomic::inc(BiasedLocking::slow_path_entry_count_addr()); - Handle object(thread, lock->obj()); + Handle object(thread, lock->obj()); assert(Universe::heap()->is_in_reserved_or_null(object()), "should be"); if (UseBiasedLocking) { // Retry fast entry if bias is revoked to avoid unnecessary inflation @@ -65,31 +62,27 @@ ObjectSynchronizer::slow_enter(object, lock->lock(), CHECK); } assert(Universe::heap()->is_in_reserved_or_null(lock->obj()), "should be"); -} JRT_END JRT_ENTRY(void, SharkRuntime::monitorexit(JavaThread* thread, BasicObjectLock* lock)) -{ - Handle object(thread, lock->obj()); + Handle object(thread, lock->obj()); assert(Universe::heap()->is_in_reserved_or_null(object()), "should be"); if (lock == NULL || object()->is_unlocked()) { THROW(vmSymbols::java_lang_IllegalMonitorStateException()); } ObjectSynchronizer::slow_exit(object(), lock->lock(), thread); -} JRT_END - + JRT_ENTRY(void, SharkRuntime::new_instance(JavaThread* thread, int index)) -{ klassOop k_oop = method(thread)->constants()->klass_at(index, CHECK); instanceKlassHandle klass(THREAD, k_oop); - + // Make sure we are not instantiating an abstract klass klass->check_valid_for_instantiation(true, CHECK); // Make sure klass is initialized - klass->initialize(CHECK); + klass->initialize(CHECK); // At this point the class may not be fully initialized // because of recursive initialization. If it is fully @@ -106,47 +99,38 @@ // If we have a breakpoint, then we don't rewrite // because the _breakpoint bytecode would be lost. oop obj = klass->allocate_instance(CHECK); - thread->set_vm_result(obj); -} + thread->set_vm_result(obj); JRT_END JRT_ENTRY(void, SharkRuntime::newarray(JavaThread* thread, BasicType type, int size)) -{ oop obj = oopFactory::new_typeArray(type, size, CHECK); thread->set_vm_result(obj); -} JRT_END JRT_ENTRY(void, SharkRuntime::anewarray(JavaThread* thread, int index, int size)) -{ klassOop klass = method(thread)->constants()->klass_at(index, CHECK); objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK); thread->set_vm_result(obj); -} JRT_END JRT_ENTRY(void, SharkRuntime::multianewarray(JavaThread* thread, int index, int ndims, int* dims)) -{ klassOop klass = method(thread)->constants()->klass_at(index, CHECK); oop obj = arrayKlass::cast(klass)->multi_allocate(ndims, dims, CHECK); thread->set_vm_result(obj); -} JRT_END JRT_ENTRY(void, SharkRuntime::register_finalizer(JavaThread* thread, oop object)) -{ assert(object->is_oop(), "should be"); assert(object->klass()->klass_part()->has_finalizer(), "should have"); instanceKlass::register_finalizer(instanceOop(object), CHECK); -} JRT_END JRT_ENTRY(void, SharkRuntime::throw_ArrayIndexOutOfBoundsException( @@ -154,32 +138,27 @@ const char* file, int line, int index)) -{ char msg[jintAsStringSize]; snprintf(msg, sizeof(msg), "%d", index); Exceptions::_throw_msg( - thread, file, line, + thread, file, line, vmSymbols::java_lang_ArrayIndexOutOfBoundsException(), msg); -} JRT_END JRT_ENTRY(void, SharkRuntime::throw_NullPointerException(JavaThread* thread, const char* file, int line)) -{ Exceptions::_throw_msg( - thread, file, line, + thread, file, line, vmSymbols::java_lang_NullPointerException(), ""); -} JRT_END // Non-VM calls // Nothing in these must ever GC! -void SharkRuntime::dump(const char *name, intptr_t value) -{ +void SharkRuntime::dump(const char *name, intptr_t value) { oop valueOop = (oop) value; tty->print("%s = ", name); if (valueOop->is_oop(true)) @@ -191,13 +170,11 @@ tty->print_cr(""); } -bool SharkRuntime::is_subtype_of(klassOop check_klass, klassOop object_klass) -{ +bool SharkRuntime::is_subtype_of(klassOop check_klass, klassOop object_klass) { return object_klass->klass_part()->is_subtype_of(check_klass); } -void SharkRuntime::uncommon_trap(JavaThread* thread, int trap_request) -{ +void SharkRuntime::uncommon_trap(JavaThread* thread, int trap_request) { // In C2, uncommon_trap_blob creates a frame, so all the various // deoptimization functions expect to find the frame of the method // being deopted one frame down on the stack. Create a dummy frame @@ -224,7 +201,7 @@ // Push another dummy frame thread->push_zero_frame(FakeStubFrame::build(stack)); - + // Fill in the skeleton frames thread->set_last_Java_frame(); Deoptimization::unpack_frames(thread, Deoptimization::Unpack_uncommon_trap); @@ -233,7 +210,7 @@ // Pop our dummy frame thread->pop_zero_frame(); - // Jump into the interpreter + // Jump into the interpreter #ifdef CC_INTERP CppInterpreter::main_loop(number_of_frames - 1, thread); #else @@ -241,8 +218,7 @@ #endif // CC_INTERP } -FakeStubFrame* FakeStubFrame::build(ZeroStack* stack) -{ +FakeStubFrame* FakeStubFrame::build(ZeroStack* stack) { if (header_words > stack->available_words()) { Unimplemented(); }
--- a/ports/hotspot/src/share/vm/shark/sharkRuntime.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkRuntime.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -53,30 +53,25 @@ // Helpers for VM calls private: - static const SharkFrame* last_frame(JavaThread *thread) - { + static const SharkFrame* last_frame(JavaThread *thread) { return thread->last_frame().zero_sharkframe(); } - static methodOop method(JavaThread *thread) - { + static methodOop method(JavaThread *thread) { return last_frame(thread)->method(); } - static address bcp(JavaThread *thread, int bci) - { + static address bcp(JavaThread *thread, int bci) { return method(thread)->code_base() + bci; } - static int two_byte_index(JavaThread *thread, int bci) - { + static int two_byte_index(JavaThread *thread, int bci) { return Bytes::get_Java_u2(bcp(thread, bci) + 1); } - static intptr_t tos_at(JavaThread *thread, int offset) - { + static intptr_t tos_at(JavaThread *thread, int offset) { return *(thread->zero_stack()->sp() + offset); - } + } // Non-VM calls public: static void dump(const char *name, intptr_t value); - static bool is_subtype_of(klassOop check_klass, klassOop object_klass); + static bool is_subtype_of(klassOop check_klass, klassOop object_klass); static void uncommon_trap(JavaThread* thread, int trap_request); };
--- a/ports/hotspot/src/share/vm/shark/sharkStack.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkStack.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkStack::initialize(Value* method) -{ +void SharkStack::initialize(Value* method) { bool setup_sp_and_method = (method != NULL); int locals_words = max_locals(); @@ -62,7 +61,7 @@ offset += stack_words; // Monitors - _monitors_slots_offset = offset; + _monitors_slots_offset = offset; offset += monitor_words; // Temporary oop slot @@ -87,7 +86,7 @@ Value *fp = slot_addr(offset++); // Local variables - _locals_slots_offset = offset; + _locals_slots_offset = offset; offset += locals_words; // Push the frame @@ -104,11 +103,10 @@ // update. Overflows here are problematic as we haven't yet // created a frame, so it's not clear how to report the error. // http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=249 -void SharkStack::CreateHardStackOverflowCheck(Value* sp) -{ +void SharkStack::CreateHardStackOverflowCheck(Value* sp) { BasicBlock *overflow = CreateBlock("stack_overflow"); BasicBlock *no_overflow = CreateBlock("no_overflow"); - + builder()->CreateCondBr( builder()->CreateICmpULT(sp, stack_base()), overflow, no_overflow); @@ -117,19 +115,17 @@ builder()->CreateUnimplemented(__FILE__, __LINE__); builder()->CreateUnreachable(); - builder()->SetInsertPoint(no_overflow); + builder()->SetInsertPoint(no_overflow); } // Check that a stack overflow is not imminent, throwing a // StackOverflowError if it is while we still have the stack // in which to do so. -void SharkStack::CreateSoftStackOverflowCheck(Value* sp) -{ +void SharkStack::CreateSoftStackOverflowCheck(Value* sp) { // XXX see CppInterpreter::stack_overflow_imminent } -Value* SharkStack::CreatePopFrame(int result_slots) -{ +Value* SharkStack::CreatePopFrame(int result_slots) { assert(result_slots >= 0 && result_slots <= 2, "should be"); int locals_to_pop = max_locals() - result_slots; @@ -149,8 +145,7 @@ Value* SharkStack::slot_addr(int offset, const Type* type, - const char* name) const -{ + const char* name) const { bool needs_cast = type && type != SharkType::intptr_type(); Value* result = builder()->CreateStructGEP( @@ -166,20 +161,17 @@ // The bits that differentiate stacks with normal and native frames on top SharkStack* SharkStack::CreateBuildAndPushFrame(SharkFunction* function, - Value* method) -{ + Value* method) { return new SharkStackWithNormalFrame(function, method); } SharkStack* SharkStack::CreateBuildAndPushFrame(SharkNativeWrapper* wrapper, - Value* method) -{ + Value* method) { return new SharkStackWithNativeFrame(wrapper, method); } SharkStackWithNormalFrame::SharkStackWithNormalFrame(SharkFunction* function, Value* method) - : SharkStack(function), _function(function) -{ + : SharkStack(function), _function(function) { // For normal frames, the stack pointer and the method slot will // be set during each decache, so it is not necessary to do them // at the time the frame is created. However, we set them for @@ -188,52 +180,41 @@ } SharkStackWithNativeFrame::SharkStackWithNativeFrame(SharkNativeWrapper* wrp, Value* method) - : SharkStack(wrp), _wrapper(wrp) -{ + : SharkStack(wrp), _wrapper(wrp) { initialize(method); } -int SharkStackWithNormalFrame::arg_size() const -{ +int SharkStackWithNormalFrame::arg_size() const { return function()->arg_size(); } -int SharkStackWithNativeFrame::arg_size() const -{ +int SharkStackWithNativeFrame::arg_size() const { return wrapper()->arg_size(); } -int SharkStackWithNormalFrame::max_locals() const -{ +int SharkStackWithNormalFrame::max_locals() const { return function()->max_locals(); } -int SharkStackWithNativeFrame::max_locals() const -{ +int SharkStackWithNativeFrame::max_locals() const { return wrapper()->arg_size(); } -int SharkStackWithNormalFrame::max_stack() const -{ +int SharkStackWithNormalFrame::max_stack() const { return function()->max_stack(); } -int SharkStackWithNativeFrame::max_stack() const -{ +int SharkStackWithNativeFrame::max_stack() const { return 0; } -int SharkStackWithNormalFrame::max_monitors() const -{ +int SharkStackWithNormalFrame::max_monitors() const { return function()->max_monitors(); } -int SharkStackWithNativeFrame::max_monitors() const -{ +int SharkStackWithNativeFrame::max_monitors() const { return wrapper()->is_synchronized() ? 1 : 0; } -BasicBlock* SharkStackWithNormalFrame::CreateBlock(const char* name) const -{ +BasicBlock* SharkStackWithNormalFrame::CreateBlock(const char* name) const { return function()->CreateBlock(name); } -BasicBlock* SharkStackWithNativeFrame::CreateBlock(const char* name) const -{ +BasicBlock* SharkStackWithNativeFrame::CreateBlock(const char* name) const { return wrapper()->CreateBlock(name); }
--- a/ports/hotspot/src/share/vm/shark/sharkStack.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkStack.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -56,35 +56,31 @@ // BasicBlock creation protected: virtual llvm::BasicBlock* CreateBlock(const char* name = "") const = 0; - + // Interface with the Zero stack private: - llvm::Value* zero_stack() const - { + llvm::Value* zero_stack() const { return builder()->CreateAddressOfStructEntry( thread(), JavaThread::zero_stack_offset(), SharkType::zeroStack_type(), "zero_stack"); } - llvm::Value* stack_base() const - { + llvm::Value* stack_base() const { return builder()->CreateValueOfStructEntry( zero_stack(), ZeroStack::base_offset(), SharkType::intptr_type(), "stack_base"); } - llvm::Value* stack_pointer_addr() const - { + llvm::Value* stack_pointer_addr() const { return builder()->CreateAddressOfStructEntry( zero_stack(), ZeroStack::sp_offset(), llvm::PointerType::getUnqual(SharkType::intptr_type()), "stack_pointer_addr"); } - llvm::Value* frame_pointer_addr() const - { + llvm::Value* frame_pointer_addr() const { return builder()->CreateAddressOfStructEntry( thread(), JavaThread::top_zero_frame_offset(), @@ -93,28 +89,23 @@ } public: - llvm::LoadInst* CreateLoadStackPointer(const char *name = "") - { + llvm::LoadInst* CreateLoadStackPointer(const char *name = "") { return builder()->CreateLoad(stack_pointer_addr(), name); } - llvm::StoreInst* CreateStoreStackPointer(llvm::Value* value) - { + llvm::StoreInst* CreateStoreStackPointer(llvm::Value* value) { return builder()->CreateStore(value, stack_pointer_addr()); } - llvm::LoadInst* CreateLoadFramePointer(const char *name = "") - { + llvm::LoadInst* CreateLoadFramePointer(const char *name = "") { return builder()->CreateLoad(frame_pointer_addr(), name); } - llvm::StoreInst* CreateStoreFramePointer(llvm::Value* value) - { + llvm::StoreInst* CreateStoreFramePointer(llvm::Value* value) { return builder()->CreateStore(value, frame_pointer_addr()); } - llvm::Value* CreatePopFrame(int result_slots); + llvm::Value* CreatePopFrame(int result_slots); // Interface with the frame anchor private: - llvm::Value* frame_anchor_addr() const - { + llvm::Value* frame_anchor_addr() const { return builder()->CreateAddressOfStructEntry( thread(), JavaThread::last_Java_sp_offset(), @@ -123,13 +114,11 @@ } public: - llvm::StoreInst* CreateSetLastJavaFrame() - { + llvm::StoreInst* CreateSetLastJavaFrame() { return builder()->CreateStore( CreateLoadFramePointer(), frame_anchor_addr()); } - llvm::StoreInst* CreateResetLastJavaFrame() - { + llvm::StoreInst* CreateResetLastJavaFrame() { return builder()->CreateStore( LLVMValue::intptr_constant(0), frame_anchor_addr()); } @@ -141,12 +130,10 @@ int _stack_slots_offset; public: - int extended_frame_size() const - { + int extended_frame_size() const { return _extended_frame_size; } - int oopmap_frame_size() const - { + int oopmap_frame_size() const { return extended_frame_size() - arg_size(); } @@ -159,39 +146,31 @@ int _locals_slots_offset; public: - int stack_slots_offset() const - { + int stack_slots_offset() const { return _stack_slots_offset; } - int oop_tmp_slot_offset() const - { + int oop_tmp_slot_offset() const { return _oop_tmp_slot_offset; } - int method_slot_offset() const - { + int method_slot_offset() const { return _method_slot_offset; } - int pc_slot_offset() const - { + int pc_slot_offset() const { return _pc_slot_offset; } - int locals_slots_offset() const - { + int locals_slots_offset() const { return _locals_slots_offset; } - int monitor_offset(int index) const - { + int monitor_offset(int index) const { assert(index >= 0 && index < max_monitors(), "invalid monitor index"); return _monitors_slots_offset + (max_monitors() - 1 - index) * frame::interpreter_frame_monitor_size(); } - int monitor_object_offset(int index) const - { + int monitor_object_offset(int index) const { return monitor_offset(index) + (BasicObjectLock::obj_offset_in_bytes() >> LogBytesPerWord); } - int monitor_header_offset(int index) const - { + int monitor_header_offset(int index) const { return monitor_offset(index) + ((BasicObjectLock::lock_offset_in_bytes() + BasicLock::displaced_header_offset_in_bytes()) >> LogBytesPerWord); @@ -202,37 +181,32 @@ llvm::Value* slot_addr(int offset, const llvm::Type* type = NULL, const char* name = "") const; - - llvm::Value* monitor_addr(int index) const - { + + llvm::Value* monitor_addr(int index) const { return slot_addr( monitor_offset(index), SharkType::monitor_type(), "monitor"); } - llvm::Value* monitor_object_addr(int index) const - { + llvm::Value* monitor_object_addr(int index) const { return slot_addr( monitor_object_offset(index), SharkType::oop_type(), "object_addr"); } - llvm::Value* monitor_header_addr(int index) const - { + llvm::Value* monitor_header_addr(int index) const { return slot_addr( monitor_header_offset(index), SharkType::intptr_type(), "displaced_header_addr"); - } + } // oopmap helpers public: - static int oopmap_slot_munge(int offset) - { + static int oopmap_slot_munge(int offset) { return offset << (LogBytesPerWord - LogBytesPerInt); } - static VMReg slot2reg(int offset) - { + static VMReg slot2reg(int offset) { return VMRegImpl::stack2reg(oopmap_slot_munge(offset)); } }; @@ -247,8 +221,7 @@ SharkFunction* _function; private: - SharkFunction* function() const - { + SharkFunction* function() const { return _function; } @@ -274,8 +247,7 @@ SharkNativeWrapper* _wrapper; private: - SharkNativeWrapper* wrapper() const - { + SharkNativeWrapper* wrapper() const { return _wrapper; }
--- a/ports/hotspot/src/share/vm/shark/sharkState.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkState.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkState::initialize(const SharkState *state) -{ +void SharkState::initialize(const SharkState *state) { _locals = NEW_RESOURCE_ARRAY(SharkValue*, max_locals()); _stack = NEW_RESOURCE_ARRAY(SharkValue*, max_stack()); @@ -51,13 +50,12 @@ value = value->clone(); push(value); } - } + } set_num_monitors(state ? state->num_monitors() : 0); } -bool SharkState::equal_to(SharkState *other) -{ +bool SharkState::equal_to(SharkState *other) { if (target() != other->target()) return false; @@ -120,8 +118,7 @@ void SharkState::merge(SharkState* other, BasicBlock* other_block, - BasicBlock* this_block) -{ + BasicBlock* this_block) { // Method Value *this_method = this->method(); Value *other_method = other->method(); @@ -178,8 +175,7 @@ set_has_safepointed(this->has_safepointed() && other->has_safepointed()); } -void SharkState::replace_all(SharkValue* old_value, SharkValue* new_value) -{ +void SharkState::replace_all(SharkValue* old_value, SharkValue* new_value) { // Local variables for (int i = 0; i < max_locals(); i++) { if (local(i) == old_value) @@ -195,8 +191,7 @@ SharkNormalEntryState::SharkNormalEntryState(SharkTopLevelBlock* block, Value* method) - : SharkState(block) -{ + : SharkState(block) { assert(!block->stack_depth_at_entry(), "entry block shouldn't have stack"); // Local variables @@ -216,11 +211,11 @@ } value = SharkValue::create_generic(type, NULL, i == 0 && !is_static()); break; - + case ciTypeFlow::StateVector::T_NULL: value = SharkValue::null(); break; - + case ciTypeFlow::StateVector::T_BOTTOM: break; @@ -233,14 +228,13 @@ } set_local(i, value); } - SharkNormalEntryCacher(block->function(), method).scan(this); + SharkNormalEntryCacher(block->function(), method).scan(this); } SharkOSREntryState::SharkOSREntryState(SharkTopLevelBlock* block, Value* method, Value* osr_buf) - : SharkState(block) -{ + : SharkState(block) { assert(!block->stack_depth_at_entry(), "entry block shouldn't have stack"); set_num_monitors(block->ciblock()->monitor_count()); @@ -258,7 +252,7 @@ case T_ARRAY: value = SharkValue::create_generic(type, NULL, false); break; - + case ciTypeFlow::StateVector::T_NULL: value = SharkValue::null(); break; @@ -279,8 +273,7 @@ } SharkPHIState::SharkPHIState(SharkTopLevelBlock* block) - : SharkState(block), _block(block) -{ + : SharkState(block), _block(block) { BasicBlock *saved_insert_point = builder()->GetInsertBlock(); builder()->SetInsertPoint(block->entry_block()); char name[18]; @@ -364,13 +357,12 @@ // Monitors set_num_monitors(block->ciblock()->monitor_count()); - builder()->SetInsertPoint(saved_insert_point); + builder()->SetInsertPoint(saved_insert_point); } -void SharkPHIState::add_incoming(SharkState* incoming_state) -{ +void SharkPHIState::add_incoming(SharkState* incoming_state) { BasicBlock *predecessor = builder()->GetInsertBlock(); - + // Method ((PHINode *) method())->addIncoming(incoming_state->method(), predecessor); @@ -387,11 +379,11 @@ assert((stack(i) == NULL) == (incoming_state->stack(i) == NULL), "oops"); if (stack(i)) stack(i)->addIncoming(incoming_state->stack(i), predecessor); - } + } // Monitors assert(num_monitors() == incoming_state->num_monitors(), "should be"); // Temporary oop slot - assert(oop_tmp() == incoming_state->oop_tmp(), "should be"); + assert(oop_tmp() == incoming_state->oop_tmp(), "should be"); }
--- a/ports/hotspot/src/share/vm/shark/sharkState.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkState.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -51,102 +51,83 @@ // Method public: - llvm::Value** method_addr() - { + llvm::Value** method_addr() { return &_method; } - llvm::Value* method() const - { + llvm::Value* method() const { return _method; } protected: - void set_method(llvm::Value* method) - { + void set_method(llvm::Value* method) { _method = method; } // Local variables public: - SharkValue** local_addr(int index) const - { + SharkValue** local_addr(int index) const { assert(index >= 0 && index < max_locals(), "bad local variable index"); return &_locals[index]; } - SharkValue* local(int index) const - { + SharkValue* local(int index) const { return *local_addr(index); } - void set_local(int index, SharkValue* value) - { + void set_local(int index, SharkValue* value) { *local_addr(index) = value; } // Expression stack public: - SharkValue** stack_addr(int slot) const - { + SharkValue** stack_addr(int slot) const { assert(slot >= 0 && slot < stack_depth(), "bad stack slot"); return &_sp[-(slot + 1)]; } - SharkValue* stack(int slot) const - { + SharkValue* stack(int slot) const { return *stack_addr(slot); } protected: - void set_stack(int slot, SharkValue* value) - { + void set_stack(int slot, SharkValue* value) { *stack_addr(slot) = value; } public: - int stack_depth() const - { + int stack_depth() const { return _sp - _stack; } - void push(SharkValue* value) - { + void push(SharkValue* value) { assert(stack_depth() < max_stack(), "stack overrun"); *(_sp++) = value; } - SharkValue* pop() - { + SharkValue* pop() { assert(stack_depth() > 0, "stack underrun"); return *(--_sp); } // Monitors public: - int num_monitors() const - { + int num_monitors() const { return _num_monitors; } - void set_num_monitors(int num_monitors) - { + void set_num_monitors(int num_monitors) { _num_monitors = num_monitors; } // Temporary oop slot public: - llvm::Value** oop_tmp_addr() - { + llvm::Value** oop_tmp_addr() { return &_oop_tmp; } - llvm::Value* oop_tmp() const - { + llvm::Value* oop_tmp() const { return _oop_tmp; } - void set_oop_tmp(llvm::Value* oop_tmp) - { + void set_oop_tmp(llvm::Value* oop_tmp) { _oop_tmp = oop_tmp; } // Safepointed status public: - bool has_safepointed() const - { + bool has_safepointed() const { return _has_safepointed; } - void set_has_safepointed(bool has_safepointed) - { + void set_has_safepointed(bool has_safepointed) { _has_safepointed = has_safepointed; } @@ -156,8 +137,7 @@ // Copy and merge public: - SharkState* copy() const - { + SharkState* copy() const { return new SharkState(this); } void merge(SharkState* other, @@ -199,11 +179,10 @@ SharkTopLevelBlock* _block; private: - SharkTopLevelBlock* block() const - { + SharkTopLevelBlock* block() const { return _block; } public: - void add_incoming(SharkState* incoming_state); + void add_incoming(SharkState* incoming_state); };
--- a/ports/hotspot/src/share/vm/shark/sharkStateScanner.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkStateScanner.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkStateScanner::scan(SharkState* state) -{ +void SharkStateScanner::scan(SharkState* state) { start_frame(); // Expression stack @@ -77,8 +76,7 @@ } #ifndef PRODUCT -void SharkStateScanner::stack_integrity_checks(SharkState* state) -{ +void SharkStateScanner::stack_integrity_checks(SharkState* state) { for (int i = 0; i < state->stack_depth(); i++) { if (state->stack(i)) { if (state->stack(i)->is_two_word()) @@ -89,14 +87,13 @@ } } } - -void SharkStateScanner::locals_integrity_checks(SharkState* state) -{ + +void SharkStateScanner::locals_integrity_checks(SharkState* state) { for (int i = 0; i < max_locals(); i++) { if (state->local(i)) { if (state->local(i)->is_two_word()) assert(state->local(i + 1) == NULL, "should be"); } - } + } } #endif // !PRODUCT
--- a/ports/hotspot/src/share/vm/shark/sharkStateScanner.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkStateScanner.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -34,8 +34,7 @@ SharkStack* _stack; protected: - SharkStack* stack() const - { + SharkStack* stack() const { return _stack; } @@ -62,7 +61,7 @@ virtual void process_method_slot(llvm::Value** value, int offset) {} virtual void process_pc_slot(int offset) {} virtual void end_frame_header() {} - + virtual void start_locals() {} virtual void process_local_slot(int index, SharkValue** value, int offset) {} virtual void end_locals() {}
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -28,8 +28,7 @@ using namespace llvm; -void SharkTopLevelBlock::scan_for_traps() -{ +void SharkTopLevelBlock::scan_for_traps() { // If typeflow found a trap then don't scan past it int limit_bci = ciblock()->has_trap() ? ciblock()->trap_bci() : limit(); @@ -55,7 +54,7 @@ return; } break; - + case Bytecodes::_getfield: case Bytecodes::_getstatic: case Bytecodes::_putfield: @@ -116,7 +115,7 @@ break; } } - + // Trap if typeflow trapped (and we didn't before) if (ciblock()->has_trap()) { set_trap( @@ -128,8 +127,7 @@ } } -SharkState* SharkTopLevelBlock::entry_state() -{ +SharkState* SharkTopLevelBlock::entry_state() { if (_entry_state == NULL) { assert(needs_phis(), "should do"); _entry_state = new SharkPHIState(this); @@ -137,8 +135,7 @@ return _entry_state; } -void SharkTopLevelBlock::add_incoming(SharkState* incoming_state) -{ +void SharkTopLevelBlock::add_incoming(SharkState* incoming_state) { if (needs_phis()) { ((SharkPHIState *) entry_state())->add_incoming(incoming_state); } @@ -151,8 +148,7 @@ } void SharkTopLevelBlock::enter(SharkTopLevelBlock* predecessor, - bool is_exception) -{ + bool is_exception) { // This block requires phis: // - if it is entered more than once // - if it is an exception handler, because in which @@ -181,9 +177,8 @@ } } } - -void SharkTopLevelBlock::initialize() -{ + +void SharkTopLevelBlock::initialize() { char name[28]; snprintf(name, sizeof(name), "bci_%d%s", @@ -191,15 +186,13 @@ _entry_block = function()->CreateBlock(name); } -void SharkTopLevelBlock::decache_for_Java_call(ciMethod *callee) -{ +void SharkTopLevelBlock::decache_for_Java_call(ciMethod *callee) { SharkJavaCallDecacher(function(), bci(), callee).scan(current_state()); for (int i = 0; i < callee->arg_size(); i++) xpop(); } -void SharkTopLevelBlock::cache_after_Java_call(ciMethod *callee) -{ +void SharkTopLevelBlock::cache_after_Java_call(ciMethod *callee) { if (callee->return_type()->size()) { ciType *type; switch (callee->return_type()->basic_type()) { @@ -219,23 +212,19 @@ SharkJavaCallCacher(function(), callee).scan(current_state()); } -void SharkTopLevelBlock::decache_for_VM_call() -{ +void SharkTopLevelBlock::decache_for_VM_call() { SharkVMCallDecacher(function(), bci()).scan(current_state()); } -void SharkTopLevelBlock::cache_after_VM_call() -{ +void SharkTopLevelBlock::cache_after_VM_call() { SharkVMCallCacher(function()).scan(current_state()); } -void SharkTopLevelBlock::decache_for_trap() -{ +void SharkTopLevelBlock::decache_for_trap() { SharkTrapDecacher(function(), bci()).scan(current_state()); } -void SharkTopLevelBlock::emit_IR() -{ +void SharkTopLevelBlock::emit_IR() { builder()->SetInsertPoint(entry_block()); // Parse the bytecode @@ -247,8 +236,7 @@ do_branch(ciTypeFlow::FALL_THROUGH); } -SharkTopLevelBlock* SharkTopLevelBlock::bci_successor(int bci) const -{ +SharkTopLevelBlock* SharkTopLevelBlock::bci_successor(int bci) const { // XXX now with Linear Search Technology (tm) for (int i = 0; i < num_successors(); i++) { ciTypeFlow::Block *successor = ciblock()->successors()->at(i); @@ -258,8 +246,7 @@ ShouldNotReachHere(); } -void SharkTopLevelBlock::do_zero_check(SharkValue *value) -{ +void SharkTopLevelBlock::do_zero_check(SharkValue *value) { if (value->is_phi() && value->as_phi()->all_incomers_zero_checked()) { function()->add_deferred_zero_check(this, value); } @@ -278,21 +265,19 @@ void SharkTopLevelBlock::do_deferred_zero_check(SharkValue* value, int bci, SharkState* saved_state, - BasicBlock* continue_block) -{ + BasicBlock* continue_block) { if (value->as_phi()->all_incomers_zero_checked()) { builder()->CreateBr(continue_block); } else { iter()->force_bci(start()); - set_current_state(saved_state); + set_current_state(saved_state); zero_check_value(value, continue_block); } } void SharkTopLevelBlock::zero_check_value(SharkValue* value, - BasicBlock* continue_block) -{ + BasicBlock* continue_block) { BasicBlock *zero_block = builder()->CreateBlock(continue_block, "zero"); Value *a, *b; @@ -333,15 +318,14 @@ } else { builder()->CreateUnimplemented(__FILE__, __LINE__); - } + } Value *pending_exception = get_pending_exception(); clear_pending_exception(); handle_exception(pending_exception, EX_CHECK_FULL); } -void SharkTopLevelBlock::check_bounds(SharkValue* array, SharkValue* index) -{ +void SharkTopLevelBlock::check_bounds(SharkValue* array, SharkValue* index) { BasicBlock *out_of_bounds = function()->CreateBlock("out_of_bounds"); BasicBlock *in_bounds = function()->CreateBlock("in_bounds"); @@ -367,13 +351,12 @@ clear_pending_exception(); handle_exception(pending_exception, EX_CHECK_FULL); - set_current_state(saved_state); + set_current_state(saved_state); builder()->SetInsertPoint(in_bounds); } -void SharkTopLevelBlock::check_pending_exception(int action) -{ +void SharkTopLevelBlock::check_pending_exception(int action) { assert(action & EAM_CHECK, "should be"); BasicBlock *exception = function()->CreateBlock("exception"); @@ -394,14 +377,13 @@ action ^= EAM_MONITOR_FUDGE; } clear_pending_exception(); - handle_exception(pending_exception, action); + handle_exception(pending_exception, action); set_current_state(saved_state); builder()->SetInsertPoint(no_exception); } -void SharkTopLevelBlock::handle_exception(Value* exception, int action) -{ +void SharkTopLevelBlock::handle_exception(Value* exception, int action) { if (action & EAM_HANDLE && num_exceptions() != 0) { // Clear the stack and push the exception onto it. // We do this now to protect it across the VM call @@ -479,8 +461,7 @@ handle_return(T_VOID, exception); } -void SharkTopLevelBlock::maybe_add_safepoint() -{ +void SharkTopLevelBlock::maybe_add_safepoint() { if (current_state()->has_safepointed()) return; @@ -505,7 +486,7 @@ builder()->SetInsertPoint(do_safepoint); call_vm(builder()->safepoint(), EX_CHECK_FULL); - BasicBlock *safepointed_block = builder()->GetInsertBlock(); + BasicBlock *safepointed_block = builder()->GetInsertBlock(); builder()->CreateBr(safepointed); builder()->SetInsertPoint(safepointed); @@ -514,8 +495,7 @@ current_state()->set_has_safepointed(true); } -void SharkTopLevelBlock::maybe_add_backedge_safepoint() -{ +void SharkTopLevelBlock::maybe_add_backedge_safepoint() { if (current_state()->has_safepointed()) return; @@ -527,23 +507,21 @@ } } -bool SharkTopLevelBlock::can_reach(SharkTopLevelBlock* other) -{ +bool SharkTopLevelBlock::can_reach(SharkTopLevelBlock* other) { for (int i = 0; i < function()->block_count(); i++) function()->block(i)->_can_reach_visited = false; return can_reach_helper(other); } -bool SharkTopLevelBlock::can_reach_helper(SharkTopLevelBlock* other) -{ +bool SharkTopLevelBlock::can_reach_helper(SharkTopLevelBlock* other) { if (this == other) return true; if (_can_reach_visited) return false; _can_reach_visited = true; - + if (!has_trap()) { for (int i = 0; i < num_successors(); i++) { if (successor(i)->can_reach_helper(other)) @@ -559,8 +537,7 @@ return false; } -void SharkTopLevelBlock::do_trap(int trap_request) -{ +void SharkTopLevelBlock::do_trap(int trap_request) { decache_for_trap(); builder()->CreateCall2( builder()->uncommon_trap(), @@ -569,8 +546,7 @@ builder()->CreateRetVoid(); } -void SharkTopLevelBlock::call_register_finalizer(Value *receiver) -{ +void SharkTopLevelBlock::call_register_finalizer(Value *receiver) { BasicBlock *orig_block = builder()->GetInsertBlock(); SharkState *orig_state = current_state()->copy(); @@ -582,7 +558,7 @@ in_ByteSize(oopDesc::klass_offset_in_bytes()), SharkType::oop_type(), "klass"); - + Value *klass_part = builder()->CreateAddressOfStructEntry( klass, in_ByteSize(klassOopDesc::klass_part_offset_in_bytes()), @@ -605,15 +581,14 @@ builder()->SetInsertPoint(do_call); call_vm(builder()->register_finalizer(), receiver, EX_CHECK_FULL); - BasicBlock *branch_block = builder()->GetInsertBlock(); + BasicBlock *branch_block = builder()->GetInsertBlock(); builder()->CreateBr(done); builder()->SetInsertPoint(done); current_state()->merge(orig_state, orig_block, branch_block); } -void SharkTopLevelBlock::handle_return(BasicType type, Value* exception) -{ +void SharkTopLevelBlock::handle_return(BasicType type, Value* exception) { assert (exception == NULL || type == T_VOID, "exception OR result, please"); if (num_monitors()) { @@ -650,16 +625,14 @@ builder()->CreateRetVoid(); } -void SharkTopLevelBlock::do_arraylength() -{ +void SharkTopLevelBlock::do_arraylength() { SharkValue *array = pop(); check_null(array); Value *length = builder()->CreateArrayLength(array->jarray_value()); push(SharkValue::create_jint(length, false)); } -void SharkTopLevelBlock::do_aload(BasicType basic_type) -{ +void SharkTopLevelBlock::do_aload(BasicType basic_type) { SharkValue *index = pop(); SharkValue *array = pop(); @@ -699,7 +672,7 @@ case T_DOUBLE: push(SharkValue::create_jdouble(value)); break; - + case T_OBJECT: push(SharkValue::create_generic(element_type, value, false)); break; @@ -710,8 +683,7 @@ } } -void SharkTopLevelBlock::do_astore(BasicType basic_type) -{ +void SharkTopLevelBlock::do_astore(BasicType basic_type) { SharkValue *svalue = pop(); SharkValue *index = pop(); SharkValue *array = pop(); @@ -769,34 +741,29 @@ builder()->CreateUpdateBarrierSet(oopDesc::bs(), addr); } -void SharkTopLevelBlock::do_return(BasicType type) -{ +void SharkTopLevelBlock::do_return(BasicType type) { if (target()->intrinsic_id() == vmIntrinsics::_Object_init) call_register_finalizer(local(0)->jobject_value()); maybe_add_safepoint(); handle_return(type, NULL); } -void SharkTopLevelBlock::do_athrow() -{ +void SharkTopLevelBlock::do_athrow() { SharkValue *exception = pop(); check_null(exception); handle_exception(exception->jobject_value(), EX_CHECK_FULL); } -void SharkTopLevelBlock::do_goto() -{ +void SharkTopLevelBlock::do_goto() { do_branch(ciTypeFlow::GOTO_TARGET); } -void SharkTopLevelBlock::do_jsr() -{ +void SharkTopLevelBlock::do_jsr() { push(SharkValue::address_constant(iter()->next_bci())); do_branch(ciTypeFlow::GOTO_TARGET); } -void SharkTopLevelBlock::do_ret() -{ +void SharkTopLevelBlock::do_ret() { assert(local(iter()->get_index())->address_value() == successor(ciTypeFlow::GOTO_TARGET)->start(), "should be"); do_branch(ciTypeFlow::GOTO_TARGET); @@ -809,8 +776,7 @@ // do_switch // handle_exception -void SharkTopLevelBlock::do_branch(int successor_index) -{ +void SharkTopLevelBlock::do_branch(int successor_index) { SharkTopLevelBlock *dest = successor(successor_index); builder()->CreateBr(dest->entry_block()); dest->add_incoming(current_state()); @@ -818,8 +784,7 @@ void SharkTopLevelBlock::do_if(ICmpInst::Predicate p, SharkValue* b, - SharkValue* a) -{ + SharkValue* a) { Value *llvm_a, *llvm_b; if (a->is_jobject()) { llvm_a = a->intptr_value(builder()); @@ -836,8 +801,7 @@ Value* b, Value* a, SharkState* if_taken_state, - SharkState* not_taken_state) -{ + SharkState* not_taken_state) { SharkTopLevelBlock *if_taken = successor(ciTypeFlow::IF_TAKEN); SharkTopLevelBlock *not_taken = successor(ciTypeFlow::IF_NOT_TAKEN); @@ -849,8 +813,7 @@ not_taken->add_incoming(not_taken_state); } -void SharkTopLevelBlock::do_switch() -{ +void SharkTopLevelBlock::do_switch() { int len = switch_table_length(); SharkTopLevelBlock *dest_block = successor(ciTypeFlow::SWITCH_DEFAULT); @@ -865,7 +828,7 @@ switchinst->addCase( LLVMValue::jint_constant(switch_key(i)), dest_block->entry_block()); - dest_block->add_incoming(current_state()); + dest_block->add_incoming(current_state()); } } } @@ -873,8 +836,7 @@ ciMethod* SharkTopLevelBlock::improve_virtual_call(ciMethod* caller, ciInstanceKlass* klass, ciMethod* dest_method, - ciType* receiver_type) -{ + ciType* receiver_type) { // If the method is obviously final then we are already done if (dest_method->can_be_statically_bound()) return dest_method; @@ -899,7 +861,7 @@ } // Attempt to find a monomorphic target for this call using - // class heirachy analysis. + // class heirachy analysis. ciInstanceKlass *calling_klass = caller->holder(); ciMethod* monomorphic_target = dest_method->find_monomorphic_target(calling_klass, klass, actual_receiver); @@ -942,8 +904,7 @@ return NULL; } -Value *SharkTopLevelBlock::get_direct_callee(ciMethod* method) -{ +Value *SharkTopLevelBlock::get_direct_callee(ciMethod* method) { return builder()->CreateBitCast( builder()->CreateInlineOop(method), SharkType::methodOop_type(), @@ -951,8 +912,7 @@ } Value *SharkTopLevelBlock::get_virtual_callee(SharkValue* receiver, - int vtable_index) -{ + int vtable_index) { Value *klass = builder()->CreateValueOfStructEntry( receiver->jobject_value(), in_ByteSize(oopDesc::klass_offset_in_bytes()), @@ -970,8 +930,7 @@ } Value* SharkTopLevelBlock::get_interface_callee(SharkValue *receiver, - ciMethod* method) -{ + ciMethod* method) { BasicBlock *loop = function()->CreateBlock("loop"); BasicBlock *got_null = function()->CreateBlock("got_null"); BasicBlock *not_null = function()->CreateBlock("not_null"); @@ -1041,7 +1000,7 @@ builder()->SetInsertPoint(got_null); builder()->CreateUnimplemented(__FILE__, __LINE__); builder()->CreateUnreachable(); - + builder()->SetInsertPoint(not_null); builder()->CreateCondBr( builder()->CreateICmpEQ(itable_iklass, iklass), @@ -1078,10 +1037,9 @@ itableMethodEntry::method_offset_in_bytes())), PointerType::getUnqual(SharkType::methodOop_type())), "callee"); -} +} -void SharkTopLevelBlock::do_call() -{ +void SharkTopLevelBlock::do_call() { // Set frequently used booleans bool is_static = bc() == Bytecodes::_invokestatic; bool is_virtual = bc() == Bytecodes::_invokevirtual; @@ -1184,8 +1142,7 @@ } bool SharkTopLevelBlock::static_subtype_check(ciKlass* check_klass, - ciKlass* object_klass) -{ + ciKlass* object_klass) { // If the class we're checking against is java.lang.Object // then this is a no brainer. Apparently this can happen // in reflective code... @@ -1208,9 +1165,8 @@ return false; } - -void SharkTopLevelBlock::do_instance_check() -{ + +void SharkTopLevelBlock::do_instance_check() { // Get the class we're checking against bool will_link; ciKlass *check_klass = iter()->get_klass(will_link); @@ -1233,9 +1189,8 @@ else do_trapping_instance_check(check_klass); } - -bool SharkTopLevelBlock::maybe_do_instanceof_if() -{ + +bool SharkTopLevelBlock::maybe_do_instanceof_if() { // Get the class we're checking against bool will_link; ciKlass *check_klass = iter()->get_klass(will_link); @@ -1247,7 +1202,7 @@ // Keep a copy of the object we're checking SharkValue *old_object = xstack(0); - + // Get the class of the object we're checking ciKlass *object_klass = old_object->type()->as_klass(); @@ -1297,8 +1252,7 @@ return true; } -void SharkTopLevelBlock::do_full_instance_check(ciKlass* klass) -{ +void SharkTopLevelBlock::do_full_instance_check(ciKlass* klass) { BasicBlock *not_null = function()->CreateBlock("not_null"); BasicBlock *subtype_check = function()->CreateBlock("subtype_check"); BasicBlock *is_instance = function()->CreateBlock("is_instance"); @@ -1314,7 +1268,7 @@ // Pop the object off the stack Value *object = pop()->jobject_value(); - + // Null objects aren't instances of anything builder()->CreateCondBr( builder()->CreateICmpEQ(object, LLVMValue::null()), @@ -1360,7 +1314,7 @@ LLVMValue::jint_constant(IC_NOT_INSTANCE), not_instance); BasicBlock *nonnull_block = builder()->GetInsertBlock(); builder()->CreateBr(merge2); - + // Second merge builder()->SetInsertPoint(merge2); PHINode *result = builder()->CreatePHI( @@ -1395,8 +1349,7 @@ } } -void SharkTopLevelBlock::do_trapping_instance_check(ciKlass* klass) -{ +void SharkTopLevelBlock::do_trapping_instance_check(ciKlass* klass) { BasicBlock *not_null = function()->CreateBlock("not_null"); BasicBlock *is_null = function()->CreateBlock("null"); @@ -1418,7 +1371,7 @@ builder()->SetInsertPoint(is_null); set_current_state(saved_state); if (bc() == Bytecodes::_checkcast) { - push(SharkValue::create_generic(klass, pop()->jobject_value(), false)); + push(SharkValue::create_generic(klass, pop()->jobject_value(), false)); } else { pop(); @@ -1426,8 +1379,7 @@ } } -void SharkTopLevelBlock::do_new() -{ +void SharkTopLevelBlock::do_new() { bool will_link; ciInstanceKlass* klass = iter()->get_klass(will_link)->as_instance_klass(); assert(will_link, "typeflow responsibility"); @@ -1443,7 +1395,7 @@ BasicBlock *push_object = NULL; SharkState *fast_state = NULL; - + Value *tlab_object = NULL; Value *heap_object = NULL; Value *fast_object = NULL; @@ -1496,7 +1448,7 @@ // Heap allocation Value *top_addr = builder()->CreateIntToPtr( - LLVMValue::intptr_constant((intptr_t) Universe::heap()->top_addr()), + LLVMValue::intptr_constant((intptr_t) Universe::heap()->top_addr()), PointerType::getUnqual(SharkType::intptr_type()), "top_addr"); @@ -1603,8 +1555,7 @@ push(SharkValue::create_jobject(object, true)); } -void SharkTopLevelBlock::do_newarray() -{ +void SharkTopLevelBlock::do_newarray() { BasicType type = (BasicType) iter()->get_index(); call_vm( @@ -1617,8 +1568,7 @@ push(SharkValue::create_generic(array_klass, get_vm_result(), true)); } -void SharkTopLevelBlock::do_anewarray() -{ +void SharkTopLevelBlock::do_anewarray() { bool will_link; ciKlass *klass = iter()->get_klass(will_link); assert(will_link, "typeflow responsibility"); @@ -1637,8 +1587,7 @@ push(SharkValue::create_generic(array_klass, get_vm_result(), true)); } -void SharkTopLevelBlock::do_multianewarray() -{ +void SharkTopLevelBlock::do_multianewarray() { bool will_link; ciArrayKlass *array_klass = iter()->get_klass(will_link)->as_array_klass(); assert(will_link, "typeflow responsibility"); @@ -1673,8 +1622,7 @@ push(SharkValue::create_generic(array_klass, get_vm_result(), true)); } -void SharkTopLevelBlock::acquire_method_lock() -{ +void SharkTopLevelBlock::acquire_method_lock() { Value *lockee; if (target()->is_static()) lockee = builder()->CreateInlineOop(target()->holder()->java_mirror()); @@ -1685,21 +1633,18 @@ acquire_lock(lockee, EX_CHECK_NO_CATCH); } -void SharkTopLevelBlock::do_monitorenter() -{ +void SharkTopLevelBlock::do_monitorenter() { SharkValue *lockee = pop(); check_null(lockee); acquire_lock(lockee->jobject_value(), EX_CHECK_FULL); } -void SharkTopLevelBlock::do_monitorexit() -{ +void SharkTopLevelBlock::do_monitorexit() { pop(); // don't need this (monitors are block structured) release_lock(EX_CHECK_FULL); } -void SharkTopLevelBlock::acquire_lock(Value *lockee, int exception_action) -{ +void SharkTopLevelBlock::acquire_lock(Value *lockee, int exception_action) { BasicBlock *try_recursive = function()->CreateBlock("try_recursive"); BasicBlock *got_recursive = function()->CreateBlock("got_recursive"); BasicBlock *not_recursive = function()->CreateBlock("not_recursive"); @@ -1776,15 +1721,14 @@ builder()->monitorenter(), monitor_addr, exception_action | EAM_MONITOR_FUDGE); BasicBlock *acquired_slow = builder()->GetInsertBlock(); - builder()->CreateBr(lock_acquired); + builder()->CreateBr(lock_acquired); // All done builder()->SetInsertPoint(lock_acquired); current_state()->merge(fast_state, acquired_fast, acquired_slow); } -void SharkTopLevelBlock::release_lock(int exception_action) -{ +void SharkTopLevelBlock::release_lock(int exception_action) { BasicBlock *not_recursive = function()->CreateBlock("not_recursive"); BasicBlock *released_fast = function()->CreateBlock("released_fast"); BasicBlock *slow_path = function()->CreateBlock("slow_path"); @@ -1822,13 +1766,13 @@ // Create an edge for the state merge builder()->SetInsertPoint(released_fast); SharkState *fast_state = current_state()->copy(); - builder()->CreateBr(lock_released); + builder()->CreateBr(lock_released); // Need to drop into the runtime to release this one builder()->SetInsertPoint(slow_path); call_vm(builder()->monitorexit(), monitor_addr, exception_action); BasicBlock *released_slow = builder()->GetInsertBlock(); - builder()->CreateBr(lock_released); + builder()->CreateBr(lock_released); // All done builder()->SetInsertPoint(lock_released);
--- a/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkTopLevelBlock.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -40,70 +40,55 @@ ciTypeFlow::Block* _ciblock; public: - SharkFunction* function() const - { + SharkFunction* function() const { return _function; } - ciTypeFlow::Block* ciblock() const - { + ciTypeFlow::Block* ciblock() const { return _ciblock; } // Function properties public: - SharkStack* stack() const - { + SharkStack* stack() const { return function()->stack(); } - + // Typeflow properties public: - int index() const - { + int index() const { return ciblock()->pre_order(); } - bool is_backedge_copy() const - { + bool is_backedge_copy() const { return ciblock()->is_backedge_copy(); } - int stack_depth_at_entry() const - { + int stack_depth_at_entry() const { return ciblock()->stack_size(); } - ciType* local_type_at_entry(int index) const - { + ciType* local_type_at_entry(int index) const { return ciblock()->local_type_at(index); } - ciType* stack_type_at_entry(int slot) const - { + ciType* stack_type_at_entry(int slot) const { return ciblock()->stack_type_at(slot); - } - int start() const - { + } + int start() const { return ciblock()->start(); } - int limit() const - { + int limit() const { return ciblock()->limit(); } - bool falls_through() const - { + bool falls_through() const { return ciblock()->control() == ciBlock::fall_through_bci; } - int num_exceptions() const - { + int num_exceptions() const { return ciblock()->exceptions()->length(); } - SharkTopLevelBlock* exception(int index) const - { + SharkTopLevelBlock* exception(int index) const { return function()->block(ciblock()->exceptions()->at(index)->pre_order()); } - int num_successors() const - { + int num_successors() const { return ciblock()->successors()->length(); } - SharkTopLevelBlock* successor(int index) const - { + SharkTopLevelBlock* successor(int index) const { return function()->block(ciblock()->successors()->at(index)->pre_order()); } SharkTopLevelBlock* bci_successor(int bci) const; @@ -114,8 +99,7 @@ int _trap_request; int _trap_bci; - void set_trap(int trap_request, int trap_bci) - { + void set_trap(int trap_request, int trap_bci) { assert(!has_trap(), "shouldn't have"); _has_trap = true; _trap_request = trap_request; @@ -123,17 +107,14 @@ } private: - bool has_trap() - { + bool has_trap() { return _has_trap; } - int trap_request() - { + int trap_request() { assert(has_trap(), "should have"); return _trap_request; } - int trap_bci() - { + int trap_bci() { assert(has_trap(), "should have"); return _trap_bci; } @@ -147,12 +128,10 @@ bool _needs_phis; public: - bool entered() const - { + bool entered() const { return _entered; } - bool needs_phis() const - { + bool needs_phis() const { return _needs_phis; } @@ -160,8 +139,7 @@ void enter(SharkTopLevelBlock* predecessor, bool is_exception); public: - void enter() - { + void enter() { enter(NULL, false); } @@ -175,8 +153,7 @@ llvm::BasicBlock* _entry_block; public: - llvm::BasicBlock* entry_block() const - { + llvm::BasicBlock* entry_block() const { return _entry_block; } @@ -188,21 +165,18 @@ // Method public: - llvm::Value* method() - { + llvm::Value* method() { return current_state()->method(); } // Temporary oop storage public: - void set_oop_tmp(llvm::Value* value) - { + void set_oop_tmp(llvm::Value* value) { assert(value, "value must be non-NULL (will be reset by get_oop_tmp)"); assert(!current_state()->oop_tmp(), "oop_tmp gets and sets must match"); current_state()->set_oop_tmp(value); } - llvm::Value* get_oop_tmp() - { + llvm::Value* get_oop_tmp() { llvm::Value* value = current_state()->oop_tmp(); assert(value, "oop_tmp gets and sets must match"); current_state()->set_oop_tmp(NULL); @@ -219,12 +193,10 @@ // Monitors private: - int num_monitors() - { + int num_monitors() { return current_state()->num_monitors(); } - int set_num_monitors(int num_monitors) - { + int set_num_monitors(int num_monitors) { current_state()->set_num_monitors(num_monitors); } @@ -248,20 +220,17 @@ llvm::BasicBlock* continue_block); // Exceptions private: - llvm::Value* pending_exception_address() const - { + llvm::Value* pending_exception_address() const { return builder()->CreateAddressOfStructEntry( thread(), Thread::pending_exception_offset(), llvm::PointerType::getUnqual(SharkType::oop_type()), "pending_exception_addr"); } - llvm::LoadInst* get_pending_exception() const - { + llvm::LoadInst* get_pending_exception() const { return builder()->CreateLoad( pending_exception_address(), "pending_exception"); } - void clear_pending_exception() const - { + void clear_pending_exception() const { builder()->CreateStore(LLVMValue::null(), pending_exception_address()); } public: @@ -284,8 +253,7 @@ llvm::CallInst* call_vm(llvm::Value* callee, llvm::Value** args_start, llvm::Value** args_end, - int exception_action) - { + int exception_action) { decache_for_VM_call(); stack()->CreateSetLastJavaFrame(); llvm::CallInst *res = builder()->CreateCall(callee, args_start, args_end); @@ -300,23 +268,20 @@ public: llvm::CallInst* call_vm(llvm::Value* callee, - int exception_action) - { + int exception_action) { llvm::Value *args[] = {thread()}; return call_vm(callee, args, args + 1, exception_action); } llvm::CallInst* call_vm(llvm::Value* callee, llvm::Value* arg1, - int exception_action) - { + int exception_action) { llvm::Value *args[] = {thread(), arg1}; return call_vm(callee, args, args + 2, exception_action); } llvm::CallInst* call_vm(llvm::Value* callee, llvm::Value* arg1, llvm::Value* arg2, - int exception_action) - { + int exception_action) { llvm::Value *args[] = {thread(), arg1, arg2}; return call_vm(callee, args, args + 3, exception_action); } @@ -324,16 +289,14 @@ llvm::Value* arg1, llvm::Value* arg2, llvm::Value* arg3, - int exception_action) - { + int exception_action) { llvm::Value *args[] = {thread(), arg1, arg2, arg3}; return call_vm(callee, args, args + 4, exception_action); } // VM call oop return handling private: - llvm::LoadInst* get_vm_result() const - { + llvm::LoadInst* get_vm_result() const { llvm::Value *addr = builder()->CreateAddressOfStructEntry( thread(), JavaThread::vm_result_offset(), llvm::PointerType::getUnqual(SharkType::oop_type()),
--- a/ports/hotspot/src/share/vm/shark/sharkType.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkType.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -25,113 +25,88 @@ class SharkType : public AllStatic { private: - static SharkContext& context() - { + static SharkContext& context() { return SharkContext::current(); } // Basic types public: - static const llvm::Type* void_type() - { + static const llvm::Type* void_type() { return context().void_type(); } - static const llvm::IntegerType* bit_type() - { + static const llvm::IntegerType* bit_type() { return context().bit_type(); } - static const llvm::IntegerType* jbyte_type() - { + static const llvm::IntegerType* jbyte_type() { return context().jbyte_type(); } - static const llvm::IntegerType* jshort_type() - { + static const llvm::IntegerType* jshort_type() { return context().jshort_type(); } - static const llvm::IntegerType* jint_type() - { + static const llvm::IntegerType* jint_type() { return context().jint_type(); } - static const llvm::IntegerType* jlong_type() - { + static const llvm::IntegerType* jlong_type() { return context().jlong_type(); } - static const llvm::Type* jfloat_type() - { + static const llvm::Type* jfloat_type() { return context().jfloat_type(); } - static const llvm::Type* jdouble_type() - { + static const llvm::Type* jdouble_type() { return context().jdouble_type(); } - static const llvm::IntegerType* intptr_type() - { + static const llvm::IntegerType* intptr_type() { return context().intptr_type(); } // Compound types public: - static const llvm::PointerType* itableOffsetEntry_type() - { + static const llvm::PointerType* itableOffsetEntry_type() { return context().itableOffsetEntry_type(); } - static const llvm::PointerType* jniEnv_type() - { + static const llvm::PointerType* jniEnv_type() { return context().jniEnv_type(); } - static const llvm::PointerType* jniHandleBlock_type() - { + static const llvm::PointerType* jniHandleBlock_type() { return context().jniHandleBlock_type(); } - static const llvm::PointerType* klass_type() - { + static const llvm::PointerType* klass_type() { return context().klass_type(); } - static const llvm::PointerType* methodOop_type() - { + static const llvm::PointerType* methodOop_type() { return context().methodOop_type(); } - static const llvm::ArrayType* monitor_type() - { + static const llvm::ArrayType* monitor_type() { return context().monitor_type(); } - static const llvm::PointerType* oop_type() - { + static const llvm::PointerType* oop_type() { return context().oop_type(); } - static const llvm::PointerType* thread_type() - { + static const llvm::PointerType* thread_type() { return context().thread_type(); } - static const llvm::PointerType* zeroStack_type() - { + static const llvm::PointerType* zeroStack_type() { return context().zeroStack_type(); } - static const llvm::FunctionType* entry_point_type() - { + static const llvm::FunctionType* entry_point_type() { return context().entry_point_type(); } - static const llvm::FunctionType* osr_entry_point_type() - { + static const llvm::FunctionType* osr_entry_point_type() { return context().osr_entry_point_type(); } // Mappings public: - static const llvm::Type* to_stackType(BasicType type) - { + static const llvm::Type* to_stackType(BasicType type) { return context().to_stackType(type); } - static const llvm::Type* to_stackType(ciType* type) - { + static const llvm::Type* to_stackType(ciType* type) { return to_stackType(type->basic_type()); } - static const llvm::Type* to_arrayType(BasicType type) - { + static const llvm::Type* to_arrayType(BasicType type) { return context().to_arrayType(type); } - static const llvm::Type* to_arrayType(ciType* type) - { + static const llvm::Type* to_arrayType(ciType* type) { return to_arrayType(type->basic_type()); } };
--- a/ports/hotspot/src/share/vm/shark/sharkValue.cpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkValue.cpp Wed Feb 24 17:45:42 2010 +0000 @@ -30,242 +30,192 @@ // Cloning -SharkValue* SharkNormalValue::clone() const -{ +SharkValue* SharkNormalValue::clone() const { return SharkValue::create_generic(type(), generic_value(), zero_checked()); } -SharkValue* SharkPHIValue::clone() const -{ +SharkValue* SharkPHIValue::clone() const { return SharkValue::create_phi(type(), (PHINode *) generic_value(), this); } -SharkValue* SharkAddressValue::clone() const -{ +SharkValue* SharkAddressValue::clone() const { return SharkValue::address_constant(address_value()); } // Casting -bool SharkValue::is_phi() const -{ +bool SharkValue::is_phi() const { return false; } -bool SharkPHIValue::is_phi() const -{ +bool SharkPHIValue::is_phi() const { return true; } -SharkPHIValue* SharkValue::as_phi() -{ +SharkPHIValue* SharkValue::as_phi() { ShouldNotCallThis(); } -SharkPHIValue* SharkPHIValue::as_phi() -{ +SharkPHIValue* SharkPHIValue::as_phi() { return this; } // Comparison -bool SharkNormalValue::equal_to(SharkValue *other) const -{ +bool SharkNormalValue::equal_to(SharkValue *other) const { return (this->type() == other->type() && this->generic_value() == other->generic_value() && this->zero_checked() == other->zero_checked()); } -bool SharkAddressValue::equal_to(SharkValue *other) const -{ +bool SharkAddressValue::equal_to(SharkValue *other) const { return (this->address_value() == other->address_value()); } // Type access -ciType* SharkValue::type() const -{ +ciType* SharkValue::type() const { ShouldNotCallThis(); } -ciType* SharkNormalValue::type() const -{ +ciType* SharkNormalValue::type() const { return _type; } -BasicType SharkNormalValue::basic_type() const -{ +BasicType SharkNormalValue::basic_type() const { return type()->basic_type(); } -BasicType SharkAddressValue::basic_type() const -{ +BasicType SharkAddressValue::basic_type() const { return T_ADDRESS; } -int SharkNormalValue::size() const -{ +int SharkNormalValue::size() const { return type()->size(); } -int SharkAddressValue::size() const -{ +int SharkAddressValue::size() const { return 1; } -bool SharkValue::is_jint() const -{ +bool SharkValue::is_jint() const { return false; } -bool SharkValue::is_jlong() const -{ +bool SharkValue::is_jlong() const { return false; } -bool SharkValue::is_jfloat() const -{ +bool SharkValue::is_jfloat() const { return false; } -bool SharkValue::is_jdouble() const -{ +bool SharkValue::is_jdouble() const { return false; } -bool SharkValue::is_jobject() const -{ +bool SharkValue::is_jobject() const { return false; } -bool SharkValue::is_jarray() const -{ +bool SharkValue::is_jarray() const { return false; } -bool SharkValue::is_address() const -{ +bool SharkValue::is_address() const { return false; } -bool SharkNormalValue::is_jint() const -{ +bool SharkNormalValue::is_jint() const { return llvm_value()->getType() == SharkType::jint_type(); } -bool SharkNormalValue::is_jlong() const -{ +bool SharkNormalValue::is_jlong() const { return llvm_value()->getType() == SharkType::jlong_type(); } -bool SharkNormalValue::is_jfloat() const -{ +bool SharkNormalValue::is_jfloat() const { return llvm_value()->getType() == SharkType::jfloat_type(); } -bool SharkNormalValue::is_jdouble() const -{ +bool SharkNormalValue::is_jdouble() const { return llvm_value()->getType() == SharkType::jdouble_type(); } -bool SharkNormalValue::is_jobject() const -{ +bool SharkNormalValue::is_jobject() const { return llvm_value()->getType() == SharkType::oop_type(); } -bool SharkNormalValue::is_jarray() const -{ +bool SharkNormalValue::is_jarray() const { return basic_type() == T_ARRAY; } -bool SharkAddressValue::is_address() const -{ +bool SharkAddressValue::is_address() const { return true; } // Typed conversions from SharkValues -Value* SharkValue::jint_value() const -{ +Value* SharkValue::jint_value() const { ShouldNotCallThis(); } -Value* SharkValue::jlong_value() const -{ +Value* SharkValue::jlong_value() const { ShouldNotCallThis(); } -Value* SharkValue::jfloat_value() const -{ +Value* SharkValue::jfloat_value() const { ShouldNotCallThis(); } -Value* SharkValue::jdouble_value() const -{ +Value* SharkValue::jdouble_value() const { ShouldNotCallThis(); } -Value* SharkValue::jobject_value() const -{ +Value* SharkValue::jobject_value() const { ShouldNotCallThis(); } -Value* SharkValue::jarray_value() const -{ +Value* SharkValue::jarray_value() const { ShouldNotCallThis(); } -int SharkValue::address_value() const -{ +int SharkValue::address_value() const { ShouldNotCallThis(); } -Value* SharkNormalValue::jint_value() const -{ +Value* SharkNormalValue::jint_value() const { assert(is_jint(), "should be"); return llvm_value(); } -Value* SharkNormalValue::jlong_value() const -{ +Value* SharkNormalValue::jlong_value() const { assert(is_jlong(), "should be"); return llvm_value(); } -Value* SharkNormalValue::jfloat_value() const -{ +Value* SharkNormalValue::jfloat_value() const { assert(is_jfloat(), "should be"); return llvm_value(); } -Value* SharkNormalValue::jdouble_value() const -{ +Value* SharkNormalValue::jdouble_value() const { assert(is_jdouble(), "should be"); return llvm_value(); } -Value* SharkNormalValue::jobject_value() const -{ +Value* SharkNormalValue::jobject_value() const { assert(is_jobject(), "should be"); return llvm_value(); } -Value* SharkNormalValue::jarray_value() const -{ +Value* SharkNormalValue::jarray_value() const { // XXX assert(is_jarray(), "should be"); // XXX http://icedtea.classpath.org/bugzilla/show_bug.cgi?id=324 assert(is_jobject(), "should be"); return llvm_value(); } -int SharkAddressValue::address_value() const -{ +int SharkAddressValue::address_value() const { return _bci; } // Type-losing conversions -- use with care! -Value* SharkNormalValue::generic_value() const -{ +Value* SharkNormalValue::generic_value() const { return llvm_value(); } -Value* SharkAddressValue::generic_value() const -{ +Value* SharkAddressValue::generic_value() const { return LLVMValue::intptr_constant(address_value()); } -Value* SharkValue::intptr_value(SharkBuilder* builder) const -{ +Value* SharkValue::intptr_value(SharkBuilder* builder) const { ShouldNotCallThis(); } -Value* SharkNormalValue::intptr_value(SharkBuilder* builder) const -{ +Value* SharkNormalValue::intptr_value(SharkBuilder* builder) const { return builder->CreatePtrToInt(jobject_value(), SharkType::intptr_type()); } // Phi-style stuff for SharkPHIState::add_incoming -void SharkValue::addIncoming(SharkValue *value, BasicBlock* block) -{ +void SharkValue::addIncoming(SharkValue *value, BasicBlock* block) { ShouldNotCallThis(); } -void SharkPHIValue::addIncoming(SharkValue *value, BasicBlock* block) -{ +void SharkPHIValue::addIncoming(SharkValue *value, BasicBlock* block) { assert(!is_clone(), "shouldn't be"); ((llvm::PHINode *) generic_value())->addIncoming( value->generic_value(), block); if (!value->zero_checked()) _all_incomers_zero_checked = false; } -void SharkAddressValue::addIncoming(SharkValue *value, BasicBlock* block) -{ +void SharkAddressValue::addIncoming(SharkValue *value, BasicBlock* block) { assert(this->equal_to(value), "should be"); } @@ -275,8 +225,7 @@ SharkValue* other, BasicBlock* other_block, BasicBlock* this_block, - const char* name) -{ + const char* name) { assert(type() == other->type(), "should be"); assert(zero_checked() == other->zero_checked(), "should be"); @@ -289,28 +238,23 @@ SharkValue* other, BasicBlock* other_block, BasicBlock* this_block, - const char* name) -{ + const char* name) { assert(this->equal_to(other), "should be"); return this; } // Repeated null and divide-by-zero check removal -bool SharkValue::zero_checked() const -{ +bool SharkValue::zero_checked() const { ShouldNotCallThis(); } -void SharkValue::set_zero_checked(bool zero_checked) -{ +void SharkValue::set_zero_checked(bool zero_checked) { ShouldNotCallThis(); } -bool SharkNormalValue::zero_checked() const -{ +bool SharkNormalValue::zero_checked() const { return _zero_checked; } -void SharkNormalValue::set_zero_checked(bool zero_checked) -{ +void SharkNormalValue::set_zero_checked(bool zero_checked) { _zero_checked = zero_checked; }
--- a/ports/hotspot/src/share/vm/shark/sharkValue.hpp Wed Feb 24 17:44:36 2010 +0000 +++ b/ports/hotspot/src/share/vm/shark/sharkValue.hpp Wed Feb 24 17:45:42 2010 +0000 @@ -25,7 +25,7 @@ // Items on the stack and in local variables are tracked using // SharkValue objects. -// +// // All SharkValues are one of two core types, SharkNormalValue // and SharkAddressValue, but no code outside this file should // ever refer to those directly. The split is because of the @@ -34,7 +34,7 @@ // popped by ret only exist at compile time. Having separate // classes for these allows us to check that our jsr handling // is correct, via assertions. -// +// // There is one more type, SharkPHIValue, which is a subclass // of SharkNormalValue with a couple of extra methods. Use of // SharkPHIValue outside of this file is acceptable, so long @@ -75,12 +75,10 @@ virtual int size() const = 0; - bool is_one_word() const - { + bool is_one_word() const { return size() == 1; } - bool is_two_word() const - { + bool is_two_word() const { return size() == 2; } @@ -96,52 +94,42 @@ // Typed conversion to SharkValues public: - static SharkValue* create_jint(llvm::Value* value, bool zero_checked) - { + static SharkValue* create_jint(llvm::Value* value, bool zero_checked) { assert(value->getType() == SharkType::jint_type(), "should be"); return create_generic(ciType::make(T_INT), value, zero_checked); } - static SharkValue* create_jlong(llvm::Value* value, bool zero_checked) - { + static SharkValue* create_jlong(llvm::Value* value, bool zero_checked) { assert(value->getType() == SharkType::jlong_type(), "should be"); return create_generic(ciType::make(T_LONG), value, zero_checked); } - static SharkValue* create_jfloat(llvm::Value* value) - { + static SharkValue* create_jfloat(llvm::Value* value) { assert(value->getType() == SharkType::jfloat_type(), "should be"); return create_generic(ciType::make(T_FLOAT), value, false); } - static SharkValue* create_jdouble(llvm::Value* value) - { + static SharkValue* create_jdouble(llvm::Value* value) { assert(value->getType() == SharkType::jdouble_type(), "should be"); return create_generic(ciType::make(T_DOUBLE), value, false); } - static SharkValue* create_jobject(llvm::Value* value, bool zero_checked) - { + static SharkValue* create_jobject(llvm::Value* value, bool zero_checked) { assert(value->getType() == SharkType::oop_type(), "should be"); return create_generic(ciType::make(T_OBJECT), value, zero_checked); } // Typed conversion from constants of various types public: - static SharkValue* jint_constant(jint value) - { + static SharkValue* jint_constant(jint value) { return create_jint(LLVMValue::jint_constant(value), value != 0); } - static SharkValue* jlong_constant(jlong value) - { + static SharkValue* jlong_constant(jlong value) { return create_jlong(LLVMValue::jlong_constant(value), value != 0); } - static SharkValue* jfloat_constant(jfloat value) - { + static SharkValue* jfloat_constant(jfloat value) { return create_jfloat(LLVMValue::jfloat_constant(value)); } - static SharkValue* jdouble_constant(jdouble value) - { + static SharkValue* jdouble_constant(jdouble value) { return create_jdouble(LLVMValue::jdouble_constant(value)); } - static SharkValue* null() - { + static SharkValue* null() { return create_jobject(LLVMValue::null(), false); } static inline SharkValue* address_constant(int bci); @@ -175,7 +163,7 @@ class SharkNormalValue : public SharkValue { friend class SharkValue; - + protected: SharkNormalValue(ciType* type, llvm::Value* value, bool zero_checked) : _type(type), _llvm_value(value), _zero_checked(zero_checked) {} @@ -186,8 +174,7 @@ bool _zero_checked; private: - llvm::Value* llvm_value() const - { + llvm::Value* llvm_value() const { return _llvm_value; } @@ -255,18 +242,15 @@ bool _all_incomers_zero_checked; private: - const SharkPHIValue* parent() const - { + const SharkPHIValue* parent() const { return _parent; } - bool is_clone() const - { + bool is_clone() const { return parent() != NULL; } public: - bool all_incomers_zero_checked() const - { + bool all_incomers_zero_checked() const { if (is_clone()) return parent()->all_incomers_zero_checked(); @@ -306,7 +290,7 @@ bool equal_to(SharkValue* other) const; // Type access - public: + public: BasicType basic_type() const; int size() const; bool is_address() const; @@ -333,19 +317,16 @@ inline SharkValue* SharkValue::create_generic(ciType* type, llvm::Value* value, - bool zero_checked) -{ + bool zero_checked) { return new SharkNormalValue(type, value, zero_checked); } inline SharkValue* SharkValue::create_phi(ciType* type, llvm::PHINode* phi, - const SharkPHIValue* parent) -{ + const SharkPHIValue* parent) { return new SharkPHIValue(type, phi, parent); } -inline SharkValue* SharkValue::address_constant(int bci) -{ +inline SharkValue* SharkValue::address_constant(int bci) { return new SharkAddressValue(bci); }