|
25 | 25 | */
|
26 | 26 | package com.oracle.graal.python.runtime;
|
27 | 27 |
|
28 |
| -import static com.oracle.graal.python.annotations.PythonOS.PLATFORM_DARWIN; |
29 |
| -import static com.oracle.graal.python.annotations.PythonOS.PLATFORM_WIN32; |
30 | 28 | import static com.oracle.graal.python.PythonLanguage.getPythonOS;
|
31 | 29 | import static com.oracle.graal.python.PythonLanguage.throwIfUnsupported;
|
| 30 | +import static com.oracle.graal.python.annotations.PythonOS.PLATFORM_DARWIN; |
| 31 | +import static com.oracle.graal.python.annotations.PythonOS.PLATFORM_WIN32; |
32 | 32 | import static com.oracle.graal.python.builtins.modules.SysModuleBuiltins.T_CACHE_TAG;
|
33 | 33 | import static com.oracle.graal.python.builtins.modules.SysModuleBuiltins.T__MULTIARCH;
|
34 | 34 | import static com.oracle.graal.python.builtins.modules.io.IONodes.T_CLOSED;
|
|
75 | 75 | import java.nio.file.LinkOption;
|
76 | 76 | import java.security.NoSuchAlgorithmException;
|
77 | 77 | import java.security.SecureRandom;
|
78 |
| -import java.security.Security; |
79 | 78 | import java.text.MessageFormat;
|
80 | 79 | import java.util.ArrayDeque;
|
81 | 80 | import java.util.ArrayList;
|
|
102 | 101 | import org.graalvm.options.OptionKey;
|
103 | 102 |
|
104 | 103 | import com.oracle.graal.python.PythonLanguage;
|
| 104 | +import com.oracle.graal.python.annotations.PythonOS; |
105 | 105 | import com.oracle.graal.python.builtins.Python3Core;
|
106 | 106 | import com.oracle.graal.python.builtins.PythonBuiltinClassType;
|
107 |
| -import com.oracle.graal.python.annotations.PythonOS; |
108 | 107 | import com.oracle.graal.python.builtins.modules.MathGuards;
|
109 | 108 | import com.oracle.graal.python.builtins.modules.ctypes.CtypesModuleBuiltins.CtypesThreadState;
|
110 | 109 | import com.oracle.graal.python.builtins.objects.PNone;
|
@@ -1511,13 +1510,14 @@ public SecureRandom getSecureRandom() {
|
1511 | 1510 | assert !env.isPreInitialization();
|
1512 | 1511 | if (secureRandom == null) {
|
1513 | 1512 | CompilerDirectives.transferToInterpreterAndInvalidate();
|
1514 |
| - if (Security.getAlgorithms("SecureRandom").contains("NATIVEPRNGNONBLOCKING")) { |
1515 |
| - try { |
1516 |
| - secureRandom = SecureRandom.getInstance("NATIVEPRNGNONBLOCKING"); |
1517 |
| - } catch (NoSuchAlgorithmException e) { |
1518 |
| - throw CompilerDirectives.shouldNotReachHere(e); |
1519 |
| - } |
1520 |
| - } else { |
| 1513 | + /* |
| 1514 | + * Be careful with what we initialize here. Doing stuff likes Security.getAlgorithms may |
| 1515 | + * eagerly initialize bouncycastle and bloat the heap. Run the heap:post-startup |
| 1516 | + * benchmark when making changes. |
| 1517 | + */ |
| 1518 | + try { |
| 1519 | + secureRandom = SecureRandom.getInstance("NATIVEPRNGNONBLOCKING"); |
| 1520 | + } catch (NoSuchAlgorithmException e) { |
1521 | 1521 | secureRandom = new SecureRandom();
|
1522 | 1522 | }
|
1523 | 1523 | }
|
|
0 commit comments