Skip to content
Permalink
Browse files

Merge

  • Loading branch information
AlanBateman committed Nov 14, 2019
2 parents 68405c7 + 2b0c16a commit 54ef49439dcefdda494bc1f36b58b09053cad9b4
Showing with 2,833 additions and 259 deletions.
  1. +2 −0 .gitignore
  2. +4 −0 microbenchmarks/loom/.gitignore
  3. +5 −2 microbenchmarks/loom/run_perf.sh
  4. +146 −0 microbenchmarks/loom/src/main/java/org/openjdk/benchmarks/cont/FreezeAndThaw.java
  5. +14 −1 src/hotspot/cpu/x86/c1_LIRAssembler_x86.cpp
  6. +1 −0 src/hotspot/cpu/x86/c1_MacroAssembler_x86.cpp
  7. +216 −0 src/hotspot/cpu/x86/continuationChunk_x86.inline.hpp
  8. +272 −4 src/hotspot/cpu/x86/continuation_x86.inline.hpp
  9. +2 −1 src/hotspot/cpu/x86/frame_x86.inline.hpp
  10. +2 −19 src/hotspot/cpu/x86/gc/g1/g1BarrierSetAssembler_x86.cpp
  11. +4 −3 src/hotspot/cpu/x86/interp_masm_x86.cpp
  12. +17 −1 src/hotspot/cpu/x86/macroAssembler_x86.cpp
  13. +3 −0 src/hotspot/cpu/x86/macroAssembler_x86.hpp
  14. +2 −2 src/hotspot/cpu/x86/sharedRuntime_x86_64.cpp
  15. +1 −0 src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
  16. +5 −0 src/hotspot/cpu/x86/templateInterpreterGenerator_x86.cpp
  17. +9 −0 src/hotspot/cpu/x86/templateTable_x86.cpp
  18. +2 −0 src/hotspot/share/c1/c1_Runtime1.cpp
  19. +31 −10 src/hotspot/share/classfile/javaClasses.cpp
  20. +42 −9 src/hotspot/share/classfile/javaClasses.hpp
  21. +56 −0 src/hotspot/share/classfile/javaClasses.inline.hpp
  22. +1 −0 src/hotspot/share/classfile/systemDictionary.hpp
  23. +8 −1 src/hotspot/share/classfile/vmSymbols.hpp
  24. +8 −0 src/hotspot/share/code/codeCache.cpp
  25. +3 −0 src/hotspot/share/code/codeCache.hpp
  26. +0 −8 src/hotspot/share/code/compiledMethod.cpp
  27. +0 −2 src/hotspot/share/code/compiledMethod.hpp
  28. +36 −3 src/hotspot/share/code/nmethod.cpp
  29. +5 −1 src/hotspot/share/code/nmethod.hpp
  30. +2 −0 src/hotspot/share/gc/epsilon/epsilonHeap.hpp
  31. +1 −0 src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp
  32. +4 −0 src/hotspot/share/gc/g1/g1CollectedHeap.cpp
  33. +2 −1 src/hotspot/share/gc/g1/g1CollectedHeap.hpp
  34. +1 −1 src/hotspot/share/gc/g1/g1CollectedHeap.inline.hpp
  35. +3 −0 src/hotspot/share/gc/g1/g1ConcurrentMark.cpp
  36. +5 −0 src/hotspot/share/gc/g1/g1FullCollector.cpp
  37. +4 −2 src/hotspot/share/gc/parallel/parallelScavengeHeap.hpp
  38. +1 −1 src/hotspot/share/gc/parallel/parallelScavengeHeap.inline.hpp
  39. +4 −0 src/hotspot/share/gc/parallel/psMarkSweep.cpp
  40. +4 −0 src/hotspot/share/gc/parallel/psParallelCompact.cpp
  41. +15 −0 src/hotspot/share/gc/shared/barrierSet.cpp
  42. +1 −6 src/hotspot/share/gc/shared/barrierSet.hpp
  43. +46 −5 src/hotspot/share/gc/shared/barrierSetNMethod.cpp
  44. +9 −4 src/hotspot/share/gc/shared/barrierSetNMethod.hpp
  45. +59 −0 src/hotspot/share/gc/shared/collectedHeap.cpp
  46. +6 −0 src/hotspot/share/gc/shared/collectedHeap.hpp
  47. +0 −4 src/hotspot/share/gc/shared/gcBehaviours.cpp
  48. +24 −0 src/hotspot/share/gc/shared/gcVMOperations.cpp
  49. +10 −0 src/hotspot/share/gc/shared/gcVMOperations.hpp
  50. +9 −1 src/hotspot/share/gc/shared/genCollectedHeap.cpp
  51. +3 −1 src/hotspot/share/gc/shared/genCollectedHeap.hpp
  52. +8 −1 src/hotspot/share/gc/shared/memAllocator.cpp
  53. +9 −0 src/hotspot/share/gc/shared/memAllocator.hpp
  54. +3 −0 src/hotspot/share/gc/shenandoah/shenandoahHeap.hpp
  55. +4 −0 src/hotspot/share/gc/z/zCollectedHeap.cpp
  56. +1 −0 src/hotspot/share/gc/z/zCollectedHeap.hpp
  57. +5 −0 src/hotspot/share/gc/z/zHeap.cpp
  58. +3 −0 src/hotspot/share/gc/z/zHeap.hpp
  59. +39 −0 src/hotspot/share/jfr/metadata/metadata.xml
  60. +1 −0 src/hotspot/share/jvmci/vmStructs_jvmci.cpp
  61. +1 −0 src/hotspot/share/memory/iterator.cpp
  62. +4 −0 src/hotspot/share/memory/iterator.inline.hpp
  63. +4 −0 src/hotspot/share/memory/metaspaceShared.cpp
  64. +3 −0 src/hotspot/share/memory/universe.cpp
  65. +10 −1 src/hotspot/share/oops/instanceClassLoaderKlass.hpp
  66. +4 −6 src/hotspot/share/oops/instanceKlass.cpp
  67. +29 −23 src/hotspot/share/oops/instanceKlass.hpp
  68. +63 −0 src/hotspot/share/oops/instanceStackChunkKlass.cpp
  69. +108 −0 src/hotspot/share/oops/instanceStackChunkKlass.hpp
  70. +86 −0 src/hotspot/share/oops/instanceStackChunkKlass.inline.hpp
  71. +2 −1 src/hotspot/share/oops/klass.hpp
  72. +1 −0 src/hotspot/share/oops/oopsHierarchy.hpp
  73. +13 −2 src/hotspot/share/opto/macro.cpp
  74. +1,078 −113 src/hotspot/share/runtime/continuation.cpp
  75. +30 −3 src/hotspot/share/runtime/continuation.hpp
  76. +47 −0 src/hotspot/share/runtime/continuation.inline.hpp
  77. +2 −0 src/hotspot/share/runtime/deoptimization.cpp
  78. +6 −2 src/hotspot/share/runtime/frame.cpp
  79. +1 −1 src/hotspot/share/runtime/frame.inline.hpp
  80. +3 −0 src/hotspot/share/runtime/globals.hpp
  81. +5 −3 src/hotspot/share/runtime/registerMap.hpp
  82. +7 −1 src/hotspot/share/runtime/stackValue.cpp
  83. +1 −1 src/hotspot/share/runtime/stackValue.hpp
  84. +3 −1 src/hotspot/share/runtime/sweeper.cpp
  85. +4 −0 src/hotspot/share/runtime/thread.cpp
  86. +23 −0 src/hotspot/share/runtime/thread.hpp
  87. +1 −0 src/hotspot/share/runtime/vmOperations.hpp
  88. +3 −0 src/hotspot/share/runtime/vmStructs.cpp
  89. +5 −2 src/java.base/share/classes/java/lang/Continuation.java
  90. +39 −0 src/java.base/share/classes/jdk/internal/misc/StackChunk.java
  91. +28 −0 src/jdk.jfr/share/conf/jfr/default.jfc
  92. +28 −0 src/jdk.jfr/share/conf/jfr/profile.jfc
  93. +7 −5 test/jdk/java/lang/Continuation/Basic.java
  94. +1 −0 test/jdk/java/lang/Continuation/TEST.properties
@@ -13,3 +13,5 @@ test/nashorn/lib
NashornProfile.txt
**/JTreport/**
**/JTwork/**
/src/utils/hsdis/build/
/microbenchmarks/loom/target/
@@ -0,0 +1,4 @@
/.factorypath
/.classpath
/.project
/.settings/
@@ -37,5 +37,8 @@ run_benchmark() {
echo
}

run_benchmark justYield 5 10 15 20 25 30
run_benchmark justContinue 105 110 112 115 120 125 130
run_benchmark baseline 1000
run_benchmark yieldAndContinue 1000

# run_benchmark justYield 5 10 15 20 25 30
# run_benchmark justContinue 105 110 112 115 120 125 130
@@ -0,0 +1,146 @@
/*
* Copyright (c) 2018, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package org.openjdk.benchmarks.cont;

import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*;

@BenchmarkMode(Mode.AverageTime)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
@State(Scope.Thread)
@Warmup(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Measurement(iterations = 5, time = 1, timeUnit = TimeUnit.SECONDS)
@Fork(1)
public class FreezeAndThaw {
static final ContinuationScope SCOPE = new ContinuationScope() { };

static class Arg {
volatile int field;
}

/**
* A recursive task that optionally yields when the stack gets to a specific
* depth. If continued after yielding, it runs to completion.
*/
static class Yielder implements Runnable {
private final int paramCount;
private final int maxDepth;
private final boolean yieldAtLimit;

private Yielder(int paramCount, int maxDepth, boolean yieldAtLimit) {
if (paramCount < 1 || paramCount > 3)
throw new IllegalArgumentException();
this.paramCount = paramCount;
this.maxDepth = maxDepth;
this.yieldAtLimit = yieldAtLimit;
}

@Override
public void run() {
switch (paramCount) {
case 1: run1(maxDepth); break;
case 2: run2(maxDepth, new Arg()); break;
case 3: run3(maxDepth, new Arg(), new Arg()); break;
default: throw new Error("should not happen");
}
}

private void run1(int depth) {
if (depth > 0) {
run1(depth - 1);
} if (depth == 0) {
if (yieldAtLimit) Continuation.yield(SCOPE);
}
}

private void run2(int depth, Arg arg2) {
if (depth > 0) {
run2(depth - 1, arg2);
} if (depth == 0) {
if (yieldAtLimit) Continuation.yield(SCOPE);
} else {
// never executed
arg2.field = 0;
}
}

private void run3(int depth, Arg arg2, Arg arg3) {
if (depth > 0) {
run3(depth - 1, arg2, arg3);
} if (depth == 0) {
if (yieldAtLimit) {
Continuation.yield(SCOPE);
}
} else {
// never executed
arg2.field = 0;
arg3.field = 0;
}
}

static Continuation continuation(int paramCount, int maxDepth,
boolean yieldAtLimit) {
Runnable task = new Yielder(paramCount, maxDepth, yieldAtLimit);
return new Continuation(SCOPE, 2000, task);
}
}

@Param({"1", "2", "3"})
public int paramCount;

@Param({"5", "10", "20", "100"})
public int stackDepth;

Continuation cont;
Continuation cont0;

@Setup(Level.Invocation)
public void setup() {
// System.out.println("pc = " + paramCount + " sd = " + stackDepth);
cont = Yielder.continuation(paramCount, stackDepth, true);
cont0 = Yielder.continuation(paramCount, stackDepth, false);
}

/**
* Creates and runs a continuation that yields at a given stack depth.
*/
@Benchmark
public void baseline() {
// Continuation cont0 = Yielder.continuation(paramCount, stackDepth, false);
cont0.run();
assert cont0.isDone();
}

/**
* Creates and runs a continuation that yields at a given stack depth.
*/
@Benchmark
public void yieldAndContinue() {
// Continuation cont = Yielder.continuation(paramCount, stackDepth, true);
cont.run();
assert !cont.isDone();
cont.run();
assert cont.isDone();
}
}
@@ -466,7 +466,7 @@ int LIR_Assembler::emit_unwind_handler() {

// Fetch the exception from TLS and clear out exception related thread state
Register thread = NOT_LP64(rsi) LP64_ONLY(r15_thread);
NOT_LP64(__ get_thread(rsi));
NOT_LP64(__ get_thread(thread));
__ movptr(rax, Address(thread, JavaThread::exception_oop_offset()));
__ movptr(Address(thread, JavaThread::exception_oop_offset()), (intptr_t)NULL_WORD);
__ movptr(Address(thread, JavaThread::exception_pc_offset()), (intptr_t)NULL_WORD);
@@ -484,6 +484,8 @@ int LIR_Assembler::emit_unwind_handler() {
stub = new MonitorExitStub(FrameMap::rax_opr, true, 0);
__ unlock_object(rdi, rsi, rax, *stub->entry());
__ bind(*stub->continuation());
NOT_LP64(__ get_thread(thread);)
__ dec_held_monitor_count(thread);
}

if (compilation()->env()->dtrace_method_probes()) {
@@ -3530,6 +3532,17 @@ void LIR_Assembler::emit_lock(LIR_OpLock* op) {
Unimplemented();
}
__ bind(*op->stub()->continuation());

NOT_LP64(Register scratch = op->scratch_opr()->as_register();)
Register thread = LP64_ONLY(r15_thread) NOT_LP64(scratch);
NOT_LP64(__ get_thread(thread);)
if (op->code() == lir_lock) {
__ inc_held_monitor_count(thread);
} else if (op->code() == lir_unlock) {
__ dec_held_monitor_count(thread);
} else {
Unimplemented();
}
}


@@ -98,6 +98,7 @@ int C1_MacroAssembler::lock_object(Register hdr, Register obj, Register disp_hdr
jcc(Assembler::notZero, slow_case);
// done
bind(done);

return null_check_offset;
}

0 comments on commit 54ef494

Please sign in to comment.
You can’t perform that action at this time.