Tue, 26 Aug 2014 15:04:20 +0200
8055954: Do not parallelize class installation
Reviewed-by: jlaskey, sundar
src/jdk/nashorn/internal/runtime/Context.java | file | annotate | diff | comparison | revisions |
1.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Tue Aug 26 11:45:36 2014 +0200 1.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Tue Aug 26 15:04:20 2014 +0200 1.3 @@ -163,39 +163,26 @@ 1.4 1.5 @Override 1.6 public void initialize(final Collection<Class<?>> classes, final Source source, final Object[] constants) { 1.7 - // do these in parallel, this significantly reduces class installation overhead 1.8 - // however - it still means that every thread needs a separate doPrivileged 1.9 - final Global global = currentGlobal.get(); 1.10 - classes.parallelStream().forEach( 1.11 - new Consumer<Class<?>>() { 1.12 + try { 1.13 + AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { 1.14 @Override 1.15 - public void accept(final Class<?> clazz) { 1.16 - // Global threadlocal may be needed by StructureLoader during in field lookup. 1.17 - currentGlobal.set(global); 1.18 - try { 1.19 - AccessController.doPrivileged(new PrivilegedExceptionAction<Void>() { 1.20 - @Override 1.21 - public Void run() { 1.22 - try { 1.23 - //use reflection to write source and constants table to installed classes 1.24 - final Field sourceField = clazz.getDeclaredField(SOURCE.symbolName()); 1.25 - sourceField.setAccessible(true); 1.26 - sourceField.set(null, source); 1.27 + public Void run() throws Exception { 1.28 + for (final Class<?> clazz : classes) { 1.29 + //use reflection to write source and constants table to installed classes 1.30 + final Field sourceField = clazz.getDeclaredField(SOURCE.symbolName()); 1.31 + sourceField.setAccessible(true); 1.32 + sourceField.set(null, source); 1.33 1.34 - final Field constantsField = clazz.getDeclaredField(CONSTANTS.symbolName()); 1.35 - constantsField.setAccessible(true); 1.36 - constantsField.set(null, constants); 1.37 - } catch (final IllegalAccessException | NoSuchFieldException e) { 1.38 - throw new RuntimeException(e); 1.39 - } 1.40 - return null; 1.41 - } 1.42 - }); 1.43 - } catch (final PrivilegedActionException e) { 1.44 - throw new RuntimeException(e); 1.45 + final Field constantsField = clazz.getDeclaredField(CONSTANTS.symbolName()); 1.46 + constantsField.setAccessible(true); 1.47 + constantsField.set(null, constants); 1.48 } 1.49 + return null; 1.50 } 1.51 }); 1.52 + } catch (final PrivilegedActionException e) { 1.53 + throw new RuntimeException(e); 1.54 + } 1.55 } 1.56 1.57 @Override