Mercurial > hg > truffle
changeset 10541:9599e1a01812
Merge.
author | Thomas Wuerthinger <thomas.wuerthinger@oracle.com> |
---|---|
date | Wed, 26 Jun 2013 15:22:21 +0200 |
parents | 0ba44a5a8420 (diff) 2faa1e7ef4f3 (current diff) |
children | 554f67e4ff3f 6eb8d63cea34 |
files | |
diffstat | 16 files changed, 60 insertions(+), 43 deletions(-) [+] |
line wrap: on
line diff
--- a/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.api.meta/src/com/oracle/graal/api/meta/MetaAccessProvider.java Wed Jun 26 15:22:21 2013 +0200 @@ -90,10 +90,11 @@ * * @param base the base address from which the value is read * @param displacement the displacement within the object in bytes + * @param compressedPointer whether this is a read of a compressed or an uncompressed pointer * @return the read value encapsulated in a {@link Constant} object, or {@code null} if the * value cannot be read. */ - Constant readUnsafeConstant(Kind kind, Object base, long displacement); + Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressedPointer); /** * Determines if a given foreign call is side-effect free. Deoptimization cannot return
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVM.java Wed Jun 26 15:22:21 2013 +0200 @@ -144,7 +144,7 @@ // Must be kept in sync with enum in graalEnv.hpp public enum CodeInstallResult { - OK, DEPENDENCIES_FAILED, CACHE_FULL + OK, DEPENDENCIES_FAILED, CACHE_FULL, CODE_TOO_LARGE } /** @@ -222,6 +222,8 @@ String getFileName(HotSpotResolvedJavaType method); + Object readUnsafeUncompressedPointer(Object o, long displacement); + /** * Invalidates the profiling information and restarts profiling upon the next invocation. *
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/bridge/CompilerToVMImpl.java Wed Jun 26 15:22:21 2013 +0200 @@ -173,6 +173,9 @@ public native void invalidateInstalledCode(HotSpotInstalledCode hotspotInstalledCode); @Override + public native Object readUnsafeUncompressedPointer(Object o, long displacement); + + @Override public Object executeCompiledMethod(Object arg1, Object arg2, Object arg3, HotSpotInstalledCode hotspotInstalledCode) throws InvalidInstalledCodeException { return executeCompiledMethodIntrinsic(arg1, arg2, arg3, hotspotInstalledCode); }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotResolvedJavaField.java Wed Jun 26 15:22:21 2013 +0200 @@ -200,12 +200,12 @@ if (receiver == null) { assert Modifier.isStatic(flags); if (holder.isInitialized()) { - return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset); + return graalRuntime().getRuntime().readUnsafeConstant(getKind(), holder.mirror(), offset, true); } return null; } else { assert !Modifier.isStatic(flags); - return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset); + return graalRuntime().getRuntime().readUnsafeConstant(getKind(), receiver.asObject(), offset, true); } }
--- a/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.hotspot/src/com/oracle/graal/hotspot/meta/HotSpotRuntime.java Wed Jun 26 15:22:21 2013 +0200 @@ -1113,7 +1113,7 @@ } @Override - public Constant readUnsafeConstant(Kind kind, Object base, long displacement) { + public Constant readUnsafeConstant(Kind kind, Object base, long displacement, boolean compressedPointer) { switch (kind) { case Boolean: return Constant.forBoolean(base == null ? unsafe.getByte(displacement) != 0 : unsafe.getBoolean(base, displacement)); @@ -1131,8 +1131,15 @@ return Constant.forFloat(base == null ? unsafe.getFloat(displacement) : unsafe.getFloat(base, displacement)); case Double: return Constant.forDouble(base == null ? unsafe.getDouble(displacement) : unsafe.getDouble(base, displacement)); - case Object: - return Constant.forObject(unsafe.getObject(base, displacement)); + case Object: { + Object o = null; + if (compressedPointer) { + o = unsafe.getObject(base, displacement); + } else { + o = this.getGraalRuntime().getCompilerToVM().readUnsafeUncompressedPointer(base, displacement); + } + return Constant.forObject(o); + } default: throw GraalInternalError.shouldNotReachHere(); }
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/FloatingReadNode.java Wed Jun 26 15:22:21 2013 +0200 @@ -57,7 +57,7 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - return ReadNode.canonicalizeRead(this, location(), object(), tool); + return ReadNode.canonicalizeRead(this, location(), object(), tool, compress()); } @Override
--- a/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.nodes/src/com/oracle/graal/nodes/extended/ReadNode.java Wed Jun 26 15:22:21 2013 +0200 @@ -62,7 +62,7 @@ @Override public ValueNode canonical(CanonicalizerTool tool) { - return canonicalizeRead(this, location(), object(), tool); + return canonicalizeRead(this, location(), object(), tool, compress()); } @Override @@ -70,7 +70,7 @@ return graph().unique(new FloatingReadNode(object(), location(), lastLocationAccess, stamp(), getGuard(), getWriteBarrierType(), compress())); } - public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool) { + public static ValueNode canonicalizeRead(ValueNode read, LocationNode location, ValueNode object, CanonicalizerTool tool, boolean compressedPointer) { MetaAccessProvider runtime = tool.runtime(); if (read.usages().count() == 0) { // Read without usages can be savely removed. @@ -83,7 +83,7 @@ if (object.kind() == Kind.Object) { Object base = object.asConstant().asObject(); if (base != null) { - Constant constant = tool.runtime().readUnsafeConstant(kind, base, displacement); + Constant constant = tool.runtime().readUnsafeConstant(kind, base, displacement, compressedPointer); if (constant != null) { return ConstantNode.forConstant(constant, runtime, read.graph()); } @@ -91,7 +91,7 @@ } else if (object.kind() == Kind.Long || object.kind().getStackKind() == Kind.Int) { long base = object.asConstant().asLong(); if (base != 0L) { - Constant constant = tool.runtime().readUnsafeConstant(kind, null, base + displacement); + Constant constant = tool.runtime().readUnsafeConstant(kind, null, base + displacement, compressedPointer); if (constant != null) { return ConstantNode.forConstant(constant, runtime, read.graph()); }
--- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Jun 26 12:16:38 2013 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCompilerImpl.java Wed Jun 26 15:22:21 2013 +0200 @@ -66,7 +66,7 @@ private static final Class[] SKIPPED_EXCEPTION_CLASSES = new Class[]{SlowPathException.class, UnexpectedResultException.class, ArithmeticException.class}; public static final OptimisticOptimizations Optimizations = OptimisticOptimizations.ALL.remove(OptimisticOptimizations.Optimization.UseExceptionProbability, - OptimisticOptimizations.Optimization.RemoveNeverExecutedCode); + OptimisticOptimizations.Optimization.RemoveNeverExecutedCode, OptimisticOptimizations.Optimization.UseTypeCheckedInlining, OptimisticOptimizations.Optimization.UseTypeCheckHints); public TruffleCompilerImpl() { this.runtime = Graal.getRequiredCapability(GraalCodeCacheProvider.class);
--- a/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/cpu/x86/vm/templateInterpreter_x86_64.cpp Wed Jun 26 15:22:21 2013 +0200 @@ -904,13 +904,6 @@ // we need to align the outgoing SP for compiled code. __ movptr(r11, rsp); - // Ensure compiled code always sees stack at proper alignment - __ andptr(rsp, -16); - - // push the return address and misalign the stack that youngest frame always sees - // as far as the placement of the call instruction - __ push(rax); - // Move first object argument from interpreter calling convention to compiled // code calling convention. __ movq(j_rarg0, Address(r11, Interpreter::stackElementSize*4)); @@ -932,11 +925,22 @@ Label invalid_nmethod; __ jcc(Assembler::zero, invalid_nmethod); + // Ensure compiled code always sees stack at proper alignment + __ andptr(rsp, -16); + + // push the return address and misalign the stack that youngest frame always sees + // as far as the placement of the call instruction + __ push(rax); + // Perform a tail call to the verified entry point of the nmethod. __ jmp(Address(j_rarg3, nmethod::verified_entry_point_offset())); __ bind(invalid_nmethod); + // pop return address, reset last_sp to NULL + __ empty_expression_stack(); + __ restore_bcp(); // rsi must be correct for exception handler (was destroyed) + __ restore_locals(); // make sure locals pointer is correct as well (was destroyed) __ call_VM(noreg, CAST_FROM_FN_PTR(address, InterpreterRuntime::throw_InvalidInstalledCodeException)); // the call_VM checks for exception, so we should never return here. __ should_not_reach_here();
--- a/src/share/vm/graal/graalCodeInstaller.cpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.cpp Wed Jun 26 15:22:21 2013 +0200 @@ -369,7 +369,10 @@ { No_Safepoint_Verifier no_safepoint; initialize_fields(JNIHandles::resolve(compiled_code_obj)); - initialize_buffer(buffer); + if (!initialize_buffer(buffer)) { + result = GraalEnv::code_too_large; + return; + } process_exception_handlers(); } @@ -427,7 +430,7 @@ } // perform data and call relocation on the CodeBuffer -void CodeInstaller::initialize_buffer(CodeBuffer& buffer) { +bool CodeInstaller::initialize_buffer(CodeBuffer& buffer) { int locs_buffer_size = _sites->length() * (relocInfo::length_limit + sizeof(relocInfo)); char* locs_buffer = NEW_RESOURCE_ARRAY(char, locs_buffer_size); buffer.insts()->initialize_shared_locs((relocInfo*)locs_buffer, locs_buffer_size / sizeof(relocInfo)); @@ -443,8 +446,12 @@ _constants = buffer.consts(); // copy the code into the newly created CodeBuffer + address end_pc = _instructions->start() + _code_size; + if (!_instructions->allocates2(end_pc)) { + return false; + } memcpy(_instructions->start(), _code->base(T_BYTE), _code_size); - _instructions->set_end(_instructions->start() + _code_size); + _instructions->set_end(end_pc); for (int i = 0; i < _sites->length(); i++) { oop site=((objArrayOop) (_sites))->obj_at(i); @@ -486,6 +493,7 @@ } } #endif + return true; } void CodeInstaller::assumption_MethodContents(Handle assumption) {
--- a/src/share/vm/graal/graalCodeInstaller.hpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/graal/graalCodeInstaller.hpp Wed Jun 26 15:22:21 2013 +0200 @@ -94,7 +94,7 @@ void initialize_assumptions(oop target_method); // perform data and call relocation on the CodeBuffer - void initialize_buffer(CodeBuffer& buffer); + bool initialize_buffer(CodeBuffer& buffer); void assumption_MethodContents(Handle assumption); void assumption_NoFinalizableSubclass(Handle assumption);
--- a/src/share/vm/graal/graalCompilerToVM.cpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/graal/graalCompilerToVM.cpp Wed Jun 26 15:22:21 2013 +0200 @@ -1168,6 +1168,13 @@ C2V_END +C2V_VMENTRY(jobject, readUnsafeUncompressedPointer, (JNIEnv *env, jobject, jobject o, jlong offset)) + oop resolved_o = JNIHandles::resolve(o); + jlong address = offset + (jlong)resolved_o; + return JNIHandles::make_local(*((oop*)address)); +C2V_END + + #define CC (char*) /*cast a literal from (const char*)*/ #define FN_PTR(f) CAST_FROM_FN_PTR(void*, &(c2v_ ## f)) @@ -1246,6 +1253,7 @@ {CC"getFileName", CC"("HS_RESOLVED_JAVA_TYPE")"STRING, FN_PTR(getFileName)}, {CC"reprofile", CC"("METASPACE_METHOD")V", FN_PTR(reprofile)}, {CC"invalidateInstalledCode", CC"("HS_INSTALLED_CODE")V", FN_PTR(invalidateInstalledCode)}, + {CC"readUnsafeUncompressedPointer", CC"("OBJECT"J)"OBJECT, FN_PTR(readUnsafeUncompressedPointer)}, }; int CompilerToVM_methods_count() {
--- a/src/share/vm/graal/graalEnv.hpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/graal/graalEnv.hpp Wed Jun 26 15:22:21 2013 +0200 @@ -62,7 +62,8 @@ enum CodeInstallResult { ok, dependencies_failed, - cache_full + cache_full, + code_too_large }; // Look up a klass by name from a particular class loader (the accessor's).
--- a/src/share/vm/graal/graalGlobals.hpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/graal/graalGlobals.hpp Wed Jun 26 15:22:21 2013 +0200 @@ -64,7 +64,7 @@ develop(bool, GraalUseFastNewObjectArray, true, \ "Use fast inlined object array allocation") \ \ - develop(intx, GraalNMethodSizeLimit, (64*K)*wordSize, \ + product(intx, GraalNMethodSizeLimit, (80*K)*wordSize, \ "Maximum size of a compiled method.") \ \ notproduct(bool, GraalPrintSimpleStubs, false, \
--- a/src/share/vm/runtime/sharedRuntime.cpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/runtime/sharedRuntime.cpp Wed Jun 26 15:22:21 2013 +0200 @@ -83,7 +83,6 @@ #endif // Shared stub locations -RuntimeStub* SharedRuntime::_deoptimized_installed_code_blob; RuntimeStub* SharedRuntime::_wrong_method_blob; RuntimeStub* SharedRuntime::_ic_miss_blob; RuntimeStub* SharedRuntime::_resolve_opt_virtual_call_blob; @@ -102,7 +101,6 @@ //----------------------------generate_stubs----------------------------------- void SharedRuntime::generate_stubs() { - _deoptimized_installed_code_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_deoptimized_installed_code), "deoptimized_installed_code"); _wrong_method_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method), "wrong_method_stub"); _ic_miss_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::handle_wrong_method_ic_miss), "ic_miss_stub"); _resolve_opt_virtual_call_blob = generate_resolve_blob(CAST_FROM_FN_PTR(address, SharedRuntime::resolve_opt_virtual_call_C), "resolve_opt_virtual_call"); @@ -1367,12 +1365,6 @@ return callee_method->verified_code_entry(); JRT_END -// Installed code has been deoptimized -JRT_BLOCK_ENTRY(address, SharedRuntime::handle_deoptimized_installed_code(JavaThread* thread)) - JavaThread* THREAD = thread; - ThreadInVMfromJava tiv(THREAD); - THROW_(vmSymbols::com_oracle_graal_api_code_InvalidInstalledCodeException(), NULL); -JRT_END // Handle call site that has been made non-entrant JRT_BLOCK_ENTRY(address, SharedRuntime::handle_wrong_method(JavaThread* thread))
--- a/src/share/vm/runtime/sharedRuntime.hpp Wed Jun 26 12:16:38 2013 +0200 +++ b/src/share/vm/runtime/sharedRuntime.hpp Wed Jun 26 15:22:21 2013 +0200 @@ -55,7 +55,6 @@ // Shared stub locations - static RuntimeStub* _deoptimized_installed_code_blob; static RuntimeStub* _wrong_method_blob; static RuntimeStub* _ic_miss_blob; static RuntimeStub* _resolve_opt_virtual_call_blob; @@ -211,11 +210,6 @@ return _wrong_method_blob->entry_point(); } - static address get_deoptimized_installed_code_stub() { - assert(_deoptimized_installed_code_blob!= NULL, "oops"); - return _deoptimized_installed_code_blob->entry_point(); - } - #ifdef COMPILER2 static void generate_uncommon_trap_blob(void); static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; } @@ -493,9 +487,6 @@ static address handle_wrong_method(JavaThread* thread); static address handle_wrong_method_ic_miss(JavaThread* thread); - // handle deoptimized installed code - static address handle_deoptimized_installed_code(JavaThread* thread); - #ifndef PRODUCT // Collect and print inline cache miss statistics