Fri, 14 Nov 2014 10:03:48 -0800
Merge
1.1 --- a/docs/source/EvalFile.java Wed Nov 12 13:47:23 2014 -0800 1.2 +++ b/docs/source/EvalFile.java Fri Nov 14 10:03:48 2014 -0800 1.3 @@ -29,14 +29,16 @@ 1.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 1.5 */ 1.6 1.7 -import javax.script.*; 1.8 +import javax.script.ScriptEngine; 1.9 +import javax.script.ScriptEngineManager; 1.10 1.11 +@SuppressWarnings("javadoc") 1.12 public class EvalFile { 1.13 - public static void main(String[] args) throws Exception { 1.14 + public static void main(final String[] args) throws Exception { 1.15 // create a script engine manager 1.16 - ScriptEngineManager factory = new ScriptEngineManager(); 1.17 + final ScriptEngineManager factory = new ScriptEngineManager(); 1.18 // create JavaScript engine 1.19 - ScriptEngine engine = factory.getEngineByName("nashorn"); 1.20 + final ScriptEngine engine = factory.getEngineByName("nashorn"); 1.21 // evaluate JavaScript code from given file - specified by first argument 1.22 engine.eval(new java.io.FileReader(args[0])); 1.23 }
2.1 --- a/docs/source/EvalScript.java Wed Nov 12 13:47:23 2014 -0800 2.2 +++ b/docs/source/EvalScript.java Fri Nov 14 10:03:48 2014 -0800 2.3 @@ -29,14 +29,16 @@ 2.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 2.5 */ 2.6 2.7 -import javax.script.*; 2.8 +import javax.script.ScriptEngine; 2.9 +import javax.script.ScriptEngineManager; 2.10 2.11 +@SuppressWarnings("javadoc") 2.12 public class EvalScript { 2.13 - public static void main(String[] args) throws Exception { 2.14 + public static void main(final String[] args) throws Exception { 2.15 // create a script engine manager 2.16 - ScriptEngineManager factory = new ScriptEngineManager(); 2.17 + final ScriptEngineManager factory = new ScriptEngineManager(); 2.18 // create a JavaScript engine 2.19 - ScriptEngine engine = factory.getEngineByName("nashorn"); 2.20 + final ScriptEngine engine = factory.getEngineByName("nashorn"); 2.21 // evaluate JavaScript code from String 2.22 engine.eval("print('Hello, World')"); 2.23 }
3.1 --- a/docs/source/InvokeScriptFunction.java Wed Nov 12 13:47:23 2014 -0800 3.2 +++ b/docs/source/InvokeScriptFunction.java Fri Nov 14 10:03:48 2014 -0800 3.3 @@ -29,22 +29,25 @@ 3.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 3.5 */ 3.6 3.7 -import javax.script.*; 3.8 +import javax.script.Invocable; 3.9 +import javax.script.ScriptEngine; 3.10 +import javax.script.ScriptEngineManager; 3.11 3.12 +@SuppressWarnings("javadoc") 3.13 public class InvokeScriptFunction { 3.14 - public static void main(String[] args) throws Exception { 3.15 - ScriptEngineManager manager = new ScriptEngineManager(); 3.16 - ScriptEngine engine = manager.getEngineByName("nashorn"); 3.17 + public static void main(final String[] args) throws Exception { 3.18 + final ScriptEngineManager manager = new ScriptEngineManager(); 3.19 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 3.20 3.21 // JavaScript code in a String 3.22 - String script = "function hello(name) { print('Hello, ' + name); }"; 3.23 + final String script = "function hello(name) { print('Hello, ' + name); }"; 3.24 // evaluate script 3.25 engine.eval(script); 3.26 3.27 // javax.script.Invocable is an optional interface. 3.28 // Check whether your script engine implements or not! 3.29 // Note that the JavaScript engine implements Invocable interface. 3.30 - Invocable inv = (Invocable) engine; 3.31 + final Invocable inv = (Invocable) engine; 3.32 3.33 // invoke the global function named "hello" 3.34 inv.invokeFunction("hello", "Scripting!!" );
4.1 --- a/docs/source/InvokeScriptMethod.java Wed Nov 12 13:47:23 2014 -0800 4.2 +++ b/docs/source/InvokeScriptMethod.java Fri Nov 14 10:03:48 2014 -0800 4.3 @@ -29,26 +29,29 @@ 4.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 4.5 */ 4.6 4.7 -import javax.script.*; 4.8 +import javax.script.Invocable; 4.9 +import javax.script.ScriptEngine; 4.10 +import javax.script.ScriptEngineManager; 4.11 4.12 +@SuppressWarnings("javadoc") 4.13 public class InvokeScriptMethod { 4.14 - public static void main(String[] args) throws Exception { 4.15 - ScriptEngineManager manager = new ScriptEngineManager(); 4.16 - ScriptEngine engine = manager.getEngineByName("nashorn"); 4.17 + public static void main(final String[] args) throws Exception { 4.18 + final ScriptEngineManager manager = new ScriptEngineManager(); 4.19 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 4.20 4.21 // JavaScript code in a String. This code defines a script object 'obj' 4.22 // with one method called 'hello'. 4.23 - String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }"; 4.24 + final String script = "var obj = new Object(); obj.hello = function(name) { print('Hello, ' + name); }"; 4.25 // evaluate script 4.26 engine.eval(script); 4.27 4.28 // javax.script.Invocable is an optional interface. 4.29 // Check whether your script engine implements or not! 4.30 // Note that the JavaScript engine implements Invocable interface. 4.31 - Invocable inv = (Invocable) engine; 4.32 + final Invocable inv = (Invocable) engine; 4.33 4.34 // get script object on which we want to call the method 4.35 - Object obj = engine.get("obj"); 4.36 + final Object obj = engine.get("obj"); 4.37 4.38 // invoke the method named "hello" on the script object "obj" 4.39 inv.invokeMethod(obj, "hello", "Script Method !!" );
5.1 --- a/docs/source/MultiScopes.java Wed Nov 12 13:47:23 2014 -0800 5.2 +++ b/docs/source/MultiScopes.java Fri Nov 14 10:03:48 2014 -0800 5.3 @@ -29,12 +29,17 @@ 5.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 5.5 */ 5.6 5.7 -import javax.script.*; 5.8 +import javax.script.Bindings; 5.9 +import javax.script.ScriptContext; 5.10 +import javax.script.ScriptEngine; 5.11 +import javax.script.ScriptEngineManager; 5.12 +import javax.script.SimpleScriptContext; 5.13 5.14 +@SuppressWarnings("javadoc") 5.15 public class MultiScopes { 5.16 - public static void main(String[] args) throws Exception { 5.17 - ScriptEngineManager manager = new ScriptEngineManager(); 5.18 - ScriptEngine engine = manager.getEngineByName("nashorn"); 5.19 + public static void main(final String[] args) throws Exception { 5.20 + final ScriptEngineManager manager = new ScriptEngineManager(); 5.21 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 5.22 5.23 engine.put("x", "hello"); 5.24 // print global variable "x" 5.25 @@ -42,9 +47,9 @@ 5.26 // the above line prints "hello" 5.27 5.28 // Now, pass a different script context 5.29 - ScriptContext newContext = new SimpleScriptContext(); 5.30 + final ScriptContext newContext = new SimpleScriptContext(); 5.31 newContext.setBindings(engine.createBindings(), ScriptContext.ENGINE_SCOPE); 5.32 - Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); 5.33 + final Bindings engineScope = newContext.getBindings(ScriptContext.ENGINE_SCOPE); 5.34 5.35 // add new variable "x" to the new engineScope 5.36 engineScope.put("x", "world");
6.1 --- a/docs/source/RunnableImpl.java Wed Nov 12 13:47:23 2014 -0800 6.2 +++ b/docs/source/RunnableImpl.java Fri Nov 14 10:03:48 2014 -0800 6.3 @@ -29,28 +29,31 @@ 6.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 6.5 */ 6.6 6.7 -import javax.script.*; 6.8 +import javax.script.Invocable; 6.9 +import javax.script.ScriptEngine; 6.10 +import javax.script.ScriptEngineManager; 6.11 6.12 +@SuppressWarnings("javadoc") 6.13 public class RunnableImpl { 6.14 - public static void main(String[] args) throws Exception { 6.15 - ScriptEngineManager manager = new ScriptEngineManager(); 6.16 - ScriptEngine engine = manager.getEngineByName("nashorn"); 6.17 + public static void main(final String[] args) throws Exception { 6.18 + final ScriptEngineManager manager = new ScriptEngineManager(); 6.19 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 6.20 6.21 // JavaScript code in a String 6.22 - String script = "function run() { print('run called'); }"; 6.23 + final String script = "function run() { print('run called'); }"; 6.24 6.25 // evaluate script 6.26 engine.eval(script); 6.27 6.28 - Invocable inv = (Invocable) engine; 6.29 + final Invocable inv = (Invocable) engine; 6.30 6.31 // get Runnable interface object from engine. This interface methods 6.32 // are implemented by script functions with the matching name. 6.33 - Runnable r = inv.getInterface(Runnable.class); 6.34 + final Runnable r = inv.getInterface(Runnable.class); 6.35 6.36 // start a new thread that runs the script implemented 6.37 // runnable interface 6.38 - Thread th = new Thread(r); 6.39 + final Thread th = new Thread(r); 6.40 th.start(); 6.41 th.join(); 6.42 }
7.1 --- a/docs/source/RunnableImplObject.java Wed Nov 12 13:47:23 2014 -0800 7.2 +++ b/docs/source/RunnableImplObject.java Fri Nov 14 10:03:48 2014 -0800 7.3 @@ -29,31 +29,34 @@ 7.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 7.5 */ 7.6 7.7 -import javax.script.*; 7.8 +import javax.script.Invocable; 7.9 +import javax.script.ScriptEngine; 7.10 +import javax.script.ScriptEngineManager; 7.11 7.12 +@SuppressWarnings("javadoc") 7.13 public class RunnableImplObject { 7.14 - public static void main(String[] args) throws Exception { 7.15 - ScriptEngineManager manager = new ScriptEngineManager(); 7.16 - ScriptEngine engine = manager.getEngineByName("nashorn"); 7.17 + public static void main(final String[] args) throws Exception { 7.18 + final ScriptEngineManager manager = new ScriptEngineManager(); 7.19 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 7.20 7.21 // JavaScript code in a String 7.22 - String script = "var obj = new Object(); obj.run = function() { print('run method called'); }"; 7.23 + final String script = "var obj = new Object(); obj.run = function() { print('run method called'); }"; 7.24 7.25 // evaluate script 7.26 engine.eval(script); 7.27 7.28 // get script object on which we want to implement the interface with 7.29 - Object obj = engine.get("obj"); 7.30 + final Object obj = engine.get("obj"); 7.31 7.32 - Invocable inv = (Invocable) engine; 7.33 + final Invocable inv = (Invocable) engine; 7.34 7.35 // get Runnable interface object from engine. This interface methods 7.36 // are implemented by script methods of object 'obj' 7.37 - Runnable r = inv.getInterface(obj, Runnable.class); 7.38 + final Runnable r = inv.getInterface(obj, Runnable.class); 7.39 7.40 // start a new thread that runs the script implemented 7.41 // runnable interface 7.42 - Thread th = new Thread(r); 7.43 + final Thread th = new Thread(r); 7.44 th.start(); 7.45 th.join(); 7.46 }
8.1 --- a/docs/source/ScriptVars.java Wed Nov 12 13:47:23 2014 -0800 8.2 +++ b/docs/source/ScriptVars.java Fri Nov 14 10:03:48 2014 -0800 8.3 @@ -29,15 +29,17 @@ 8.4 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 8.5 */ 8.6 8.7 -import javax.script.*; 8.8 -import java.io.*; 8.9 +import java.io.File; 8.10 +import javax.script.ScriptEngine; 8.11 +import javax.script.ScriptEngineManager; 8.12 8.13 +@SuppressWarnings("javadoc") 8.14 public class ScriptVars { 8.15 - public static void main(String[] args) throws Exception { 8.16 - ScriptEngineManager manager = new ScriptEngineManager(); 8.17 - ScriptEngine engine = manager.getEngineByName("nashorn"); 8.18 + public static void main(final String[] args) throws Exception { 8.19 + final ScriptEngineManager manager = new ScriptEngineManager(); 8.20 + final ScriptEngine engine = manager.getEngineByName("nashorn"); 8.21 8.22 - File f = new File("test.txt"); 8.23 + final File f = new File("test.txt"); 8.24 // expose File object as variable to script 8.25 engine.put("file", f); 8.26
9.1 --- a/make/build.xml Wed Nov 12 13:47:23 2014 -0800 9.2 +++ b/make/build.xml Fri Nov 14 10:03:48 2014 -0800 9.3 @@ -155,6 +155,7 @@ 9.4 <fileset dir="${src.dir}/jdk/nashorn/tools/resources/"/> 9.5 </copy> 9.6 <copy file="${src.dir}/jdk/internal/dynalink/support/messages.properties" todir="${build.classes.dir}/jdk/internal/dynalink/support"/> 9.7 + <copy file="${src.dir}/jdk/nashorn/internal/codegen/anchor.properties" todir="${build.classes.dir}/jdk/nashorn/internal/codegen"/> 9.8 9.9 <echo message="full=${nashorn.fullversion}" file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties"/> 9.10 <echo file="${build.classes.dir}/jdk/nashorn/internal/runtime/resources/version.properties" append="true">${line.separator}</echo>
10.1 --- a/src/jdk/internal/dynalink/DynamicLinkerFactory.java Wed Nov 12 13:47:23 2014 -0800 10.2 +++ b/src/jdk/internal/dynalink/DynamicLinkerFactory.java Fri Nov 14 10:03:48 2014 -0800 10.3 @@ -97,6 +97,7 @@ 10.4 import jdk.internal.dynalink.linker.GuardingDynamicLinker; 10.5 import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; 10.6 import jdk.internal.dynalink.linker.LinkRequest; 10.7 +import jdk.internal.dynalink.linker.MethodTypeConversionStrategy; 10.8 import jdk.internal.dynalink.support.AutoDiscovery; 10.9 import jdk.internal.dynalink.support.BottomGuardingDynamicLinker; 10.10 import jdk.internal.dynalink.support.ClassLoaderGetterContextProvider; 10.11 @@ -105,6 +106,7 @@ 10.12 import jdk.internal.dynalink.support.DefaultPrelinkFilter; 10.13 import jdk.internal.dynalink.support.LinkerServicesImpl; 10.14 import jdk.internal.dynalink.support.TypeConverterFactory; 10.15 +import jdk.internal.dynalink.support.TypeUtilities; 10.16 10.17 /** 10.18 * A factory class for creating {@link DynamicLinker}s. The most usual dynamic linker is a linker that is a composition 10.19 @@ -115,7 +117,6 @@ 10.20 * @author Attila Szegedi 10.21 */ 10.22 public class DynamicLinkerFactory { 10.23 - 10.24 /** 10.25 * Default value for {@link #setUnstableRelinkThreshold(int) unstable relink threshold}. 10.26 */ 10.27 @@ -130,6 +131,7 @@ 10.28 private boolean syncOnRelink = false; 10.29 private int unstableRelinkThreshold = DEFAULT_UNSTABLE_RELINK_THRESHOLD; 10.30 private GuardedInvocationFilter prelinkFilter; 10.31 + private MethodTypeConversionStrategy autoConversionStrategy; 10.32 10.33 /** 10.34 * Sets the class loader for automatic discovery of available linkers. If not set explicitly, then the thread 10.35 @@ -259,6 +261,29 @@ 10.36 } 10.37 10.38 /** 10.39 + * Sets an object representing the conversion strategy for automatic type conversions. After 10.40 + * {@link TypeConverterFactory#asType(java.lang.invoke.MethodHandle, java.lang.invoke.MethodType)} has 10.41 + * applied all custom conversions to a method handle, it still needs to effect 10.42 + * {@link TypeUtilities#isMethodInvocationConvertible(Class, Class) method invocation conversions} that 10.43 + * can usually be automatically applied as per 10.44 + * {@link java.lang.invoke.MethodHandle#asType(java.lang.invoke.MethodType)}. 10.45 + * However, sometimes language runtimes will want to customize even those conversions for their own call 10.46 + * sites. A typical example is allowing unboxing of null return values, which is by default prohibited by 10.47 + * ordinary {@code MethodHandles.asType}. In this case, a language runtime can install its own custom 10.48 + * automatic conversion strategy, that can deal with null values. Note that when the strategy's 10.49 + * {@link MethodTypeConversionStrategy#asType(java.lang.invoke.MethodHandle, java.lang.invoke.MethodType)} 10.50 + * is invoked, the custom language conversions will already have been applied to the method handle, so by 10.51 + * design the difference between the handle's current method type and the desired final type will always 10.52 + * only be ones that can be subjected to method invocation conversions. The strategy also doesn't need to 10.53 + * invoke a final {@code MethodHandle.asType()} as the converter factory will do that as the final step. 10.54 + * @param autoConversionStrategy the strategy for applying method invocation conversions for the linker 10.55 + * created by this factory. 10.56 + */ 10.57 + public void setAutoConversionStrategy(final MethodTypeConversionStrategy autoConversionStrategy) { 10.58 + this.autoConversionStrategy = autoConversionStrategy; 10.59 + } 10.60 + 10.61 + /** 10.62 * Creates a new dynamic linker consisting of all the prioritized, autodiscovered, and fallback linkers as well as 10.63 * the pre-link filter. 10.64 * 10.65 @@ -324,8 +349,9 @@ 10.66 prelinkFilter = new DefaultPrelinkFilter(); 10.67 } 10.68 10.69 - return new DynamicLinker(new LinkerServicesImpl(new TypeConverterFactory(typeConverters), composite), 10.70 - prelinkFilter, runtimeContextArgCount, syncOnRelink, unstableRelinkThreshold); 10.71 + return new DynamicLinker(new LinkerServicesImpl(new TypeConverterFactory(typeConverters, 10.72 + autoConversionStrategy), composite), prelinkFilter, runtimeContextArgCount, syncOnRelink, 10.73 + unstableRelinkThreshold); 10.74 } 10.75 10.76 private static ClassLoader getThreadContextClassLoader() {
11.1 --- a/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Wed Nov 12 13:47:23 2014 -0800 11.2 +++ b/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Fri Nov 14 10:03:48 2014 -0800 11.3 @@ -287,10 +287,21 @@ 11.4 */ 11.5 private static SingleDynamicMethod createDynamicMethod(final AccessibleObject m) { 11.6 if(CallerSensitiveDetector.isCallerSensitive(m)) { 11.7 + // Method has @CallerSensitive annotation 11.8 return new CallerSensitiveDynamicMethod(m); 11.9 } 11.10 + // Method has no @CallerSensitive annotation 11.11 + final MethodHandle mh; 11.12 + try { 11.13 + mh = unreflectSafely(m); 11.14 + } catch (final IllegalAccessError e) { 11.15 + // java.lang.invoke can in some case conservatively treat as caller sensitive methods that aren't 11.16 + // marked with the annotation. In this case, we'll fall back to treating it as caller sensitive. 11.17 + return new CallerSensitiveDynamicMethod(m); 11.18 + } 11.19 + // Proceed with non-caller sensitive 11.20 final Member member = (Member)m; 11.21 - return new SimpleDynamicMethod(unreflectSafely(m), member.getDeclaringClass(), member.getName(), m instanceof Constructor); 11.22 + return new SimpleDynamicMethod(mh, member.getDeclaringClass(), member.getName(), m instanceof Constructor); 11.23 } 11.24 11.25 /**
12.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 12.2 +++ b/src/jdk/internal/dynalink/linker/MethodTypeConversionStrategy.java Fri Nov 14 10:03:48 2014 -0800 12.3 @@ -0,0 +1,100 @@ 12.4 +/* 12.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 12.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 12.7 + * 12.8 + * This code is free software; you can redistribute it and/or modify it 12.9 + * under the terms of the GNU General Public License version 2 only, as 12.10 + * published by the Free Software Foundation. Oracle designates this 12.11 + * particular file as subject to the "Classpath" exception as provided 12.12 + * by Oracle in the LICENSE file that accompanied this code. 12.13 + * 12.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 12.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12.17 + * version 2 for more details (a copy is included in the LICENSE file that 12.18 + * accompanied this code). 12.19 + * 12.20 + * You should have received a copy of the GNU General Public License version 12.21 + * 2 along with this work; if not, write to the Free Software Foundation, 12.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 12.23 + * 12.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 12.25 + * or visit www.oracle.com if you need additional information or have any 12.26 + * questions. 12.27 + */ 12.28 + 12.29 +/* 12.30 + * This file is available under and governed by the GNU General Public 12.31 + * License version 2 only, as published by the Free Software Foundation. 12.32 + * However, the following notice accompanied the original version of this 12.33 + * file, and Oracle licenses the original version of this file under the BSD 12.34 + * license: 12.35 + */ 12.36 +/* 12.37 + Copyright 2014 Attila Szegedi 12.38 + 12.39 + Licensed under both the Apache License, Version 2.0 (the "Apache License") 12.40 + and the BSD License (the "BSD License"), with licensee being free to 12.41 + choose either of the two at their discretion. 12.42 + 12.43 + You may not use this file except in compliance with either the Apache 12.44 + License or the BSD License. 12.45 + 12.46 + If you choose to use this file in compliance with the Apache License, the 12.47 + following notice applies to you: 12.48 + 12.49 + You may obtain a copy of the Apache License at 12.50 + 12.51 + http://www.apache.org/licenses/LICENSE-2.0 12.52 + 12.53 + Unless required by applicable law or agreed to in writing, software 12.54 + distributed under the License is distributed on an "AS IS" BASIS, 12.55 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 12.56 + implied. See the License for the specific language governing 12.57 + permissions and limitations under the License. 12.58 + 12.59 + If you choose to use this file in compliance with the BSD License, the 12.60 + following notice applies to you: 12.61 + 12.62 + Redistribution and use in source and binary forms, with or without 12.63 + modification, are permitted provided that the following conditions are 12.64 + met: 12.65 + * Redistributions of source code must retain the above copyright 12.66 + notice, this list of conditions and the following disclaimer. 12.67 + * Redistributions in binary form must reproduce the above copyright 12.68 + notice, this list of conditions and the following disclaimer in the 12.69 + documentation and/or other materials provided with the distribution. 12.70 + * Neither the name of the copyright holder nor the names of 12.71 + contributors may be used to endorse or promote products derived from 12.72 + this software without specific prior written permission. 12.73 + 12.74 + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 12.75 + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 12.76 + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 12.77 + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER 12.78 + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 12.79 + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 12.80 + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 12.81 + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 12.82 + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 12.83 + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 12.84 + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 12.85 +*/ 12.86 + 12.87 +package jdk.internal.dynalink.linker; 12.88 + 12.89 +import java.lang.invoke.MethodHandle; 12.90 +import java.lang.invoke.MethodType; 12.91 + 12.92 +/** 12.93 + * Interface for objects representing a strategy for converting a method handle to a new type. 12.94 + */ 12.95 +public interface MethodTypeConversionStrategy { 12.96 + /** 12.97 + * Converts a method handle to a new type. 12.98 + * @param target target method handle 12.99 + * @param newType new type 12.100 + * @return target converted to the new type. 12.101 + */ 12.102 + public MethodHandle asType(final MethodHandle target, final MethodType newType); 12.103 +}
13.1 --- a/src/jdk/internal/dynalink/support/TypeConverterFactory.java Wed Nov 12 13:47:23 2014 -0800 13.2 +++ b/src/jdk/internal/dynalink/support/TypeConverterFactory.java Fri Nov 14 10:03:48 2014 -0800 13.3 @@ -97,6 +97,7 @@ 13.4 import jdk.internal.dynalink.linker.GuardedTypeConversion; 13.5 import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; 13.6 import jdk.internal.dynalink.linker.LinkerServices; 13.7 +import jdk.internal.dynalink.linker.MethodTypeConversionStrategy; 13.8 13.9 /** 13.10 * A factory for type converters. This class is the main implementation behind the 13.11 @@ -109,6 +110,7 @@ 13.12 13.13 private final GuardingTypeConverterFactory[] factories; 13.14 private final ConversionComparator[] comparators; 13.15 + private final MethodTypeConversionStrategy autoConversionStrategy; 13.16 13.17 private final ClassValue<ClassMap<MethodHandle>> converterMap = new ClassValue<ClassMap<MethodHandle>>() { 13.18 @Override 13.19 @@ -177,8 +179,24 @@ 13.20 * Creates a new type converter factory from the available {@link GuardingTypeConverterFactory} instances. 13.21 * 13.22 * @param factories the {@link GuardingTypeConverterFactory} instances to compose. 13.23 + * @param autoConversionStrategy conversion strategy for automatic type conversions. After 13.24 + * {@link #asType(java.lang.invoke.MethodHandle, java.lang.invoke.MethodType)} has applied all custom 13.25 + * conversions to a method handle, it still needs to effect 13.26 + * {@link TypeUtilities#isMethodInvocationConvertible(Class, Class) method invocation conversions} that 13.27 + * can usually be automatically applied as per 13.28 + * {@link java.lang.invoke.MethodHandle#asType(java.lang.invoke.MethodType)}. 13.29 + * However, sometimes language runtimes will want to customize even those conversions for their own call 13.30 + * sites. A typical example is allowing unboxing of null return values, which is by default prohibited by 13.31 + * ordinary {@code MethodHandles.asType}. In this case, a language runtime can install its own custom 13.32 + * automatic conversion strategy, that can deal with null values. Note that when the strategy's 13.33 + * {@link MethodTypeConversionStrategy#asType(java.lang.invoke.MethodHandle, java.lang.invoke.MethodType)} 13.34 + * is invoked, the custom language conversions will already have been applied to the method handle, so by 13.35 + * design the difference between the handle's current method type and the desired final type will always 13.36 + * only be ones that can be subjected to method invocation conversions. Can be null, in which case no 13.37 + * custom strategy is employed. 13.38 */ 13.39 - public TypeConverterFactory(final Iterable<? extends GuardingTypeConverterFactory> factories) { 13.40 + public TypeConverterFactory(final Iterable<? extends GuardingTypeConverterFactory> factories, 13.41 + final MethodTypeConversionStrategy autoConversionStrategy) { 13.42 final List<GuardingTypeConverterFactory> l = new LinkedList<>(); 13.43 final List<ConversionComparator> c = new LinkedList<>(); 13.44 for(final GuardingTypeConverterFactory factory: factories) { 13.45 @@ -189,20 +207,24 @@ 13.46 } 13.47 this.factories = l.toArray(new GuardingTypeConverterFactory[l.size()]); 13.48 this.comparators = c.toArray(new ConversionComparator[c.size()]); 13.49 - 13.50 + this.autoConversionStrategy = autoConversionStrategy; 13.51 } 13.52 13.53 /** 13.54 * Similar to {@link MethodHandle#asType(MethodType)} except it also hooks in method handles produced by 13.55 * {@link GuardingTypeConverterFactory} implementations, providing for language-specific type coercing of 13.56 - * parameters. It will apply {@link MethodHandle#asType(MethodType)} for all primitive-to-primitive, 13.57 - * wrapper-to-primitive, primitive-to-wrapper conversions as well as for all upcasts. For all other conversions, 13.58 - * it'll insert {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)} with composite filters 13.59 - * provided by {@link GuardingTypeConverterFactory} implementations. 13.60 + * parameters. For all conversions that are not a JLS method invocation conversion it'll insert 13.61 + * {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)} with composite filters 13.62 + * provided by {@link GuardingTypeConverterFactory} implementations. For the remaining JLS method invocation 13.63 + * conversions, it will invoke {@link MethodTypeConversionStrategy#asType(MethodHandle, MethodType)} first 13.64 + * if an automatic conversion strategy was specified in the 13.65 + * {@link #TypeConverterFactory(Iterable, MethodTypeConversionStrategy) constructor}, and finally apply 13.66 + * {@link MethodHandle#asType(MethodType)} for any remaining conversions. 13.67 * 13.68 * @param handle target method handle 13.69 * @param fromType the types of source arguments 13.70 - * @return a method handle that is a suitable combination of {@link MethodHandle#asType(MethodType)} and 13.71 + * @return a method handle that is a suitable combination of {@link MethodHandle#asType(MethodType)}, 13.72 + * {@link MethodTypeConversionStrategy#asType(MethodHandle, MethodType)}, and 13.73 * {@link MethodHandles#filterArguments(MethodHandle, int, MethodHandle...)} with 13.74 * {@link GuardingTypeConverterFactory} produced type converters as filters. 13.75 */ 13.76 @@ -246,8 +268,12 @@ 13.77 } 13.78 } 13.79 13.80 - // Take care of automatic conversions 13.81 - return newHandle.asType(fromType); 13.82 + // Give change to automatic conversion strategy, if one is present. 13.83 + final MethodHandle autoConvertedHandle = 13.84 + autoConversionStrategy != null ? autoConversionStrategy.asType(newHandle, fromType) : newHandle; 13.85 + 13.86 + // Do a final asType for any conversions that remain. 13.87 + return autoConvertedHandle.asType(fromType); 13.88 } 13.89 13.90 private static MethodHandle applyConverters(final MethodHandle handle, final int pos, final List<MethodHandle> converters) {
14.1 --- a/src/jdk/internal/dynalink/support/TypeUtilities.java Wed Nov 12 13:47:23 2014 -0800 14.2 +++ b/src/jdk/internal/dynalink/support/TypeUtilities.java Fri Nov 14 10:03:48 2014 -0800 14.3 @@ -520,4 +520,13 @@ 14.4 public static Class<?> getWrapperType(final Class<?> primitiveType) { 14.5 return WRAPPER_TYPES.get(primitiveType); 14.6 } 14.7 + 14.8 + /** 14.9 + * Returns true if the passed type is a wrapper for a primitive type. 14.10 + * @param type the examined type 14.11 + * @return true if the passed type is a wrapper for a primitive type. 14.12 + */ 14.13 + public static boolean isWrapperType(final Class<?> type) { 14.14 + return PRIMITIVE_TYPES.containsKey(type); 14.15 + } 14.16 }
15.1 --- a/src/jdk/nashorn/internal/AssertsEnabled.java Wed Nov 12 13:47:23 2014 -0800 15.2 +++ b/src/jdk/nashorn/internal/AssertsEnabled.java Fri Nov 14 10:03:48 2014 -0800 15.3 @@ -27,8 +27,8 @@ 15.4 15.5 /** 15.6 * Class that exposes the current state of asserts. 15.7 - * 15.8 */ 15.9 +@SuppressWarnings("all") 15.10 public final class AssertsEnabled { 15.11 private static boolean assertsEnabled = false; 15.12 static {
16.1 --- a/src/jdk/nashorn/internal/codegen/ApplySpecialization.java Wed Nov 12 13:47:23 2014 -0800 16.2 +++ b/src/jdk/nashorn/internal/codegen/ApplySpecialization.java Fri Nov 14 10:03:48 2014 -0800 16.3 @@ -29,6 +29,7 @@ 16.4 import static jdk.nashorn.internal.codegen.CompilerConstants.EXPLODED_ARGUMENT_PREFIX; 16.5 16.6 import java.lang.invoke.MethodType; 16.7 +import java.net.URL; 16.8 import java.util.ArrayDeque; 16.9 import java.util.ArrayList; 16.10 import java.util.Deque; 16.11 @@ -93,6 +94,8 @@ 16.12 16.13 private final Deque<List<IdentNode>> explodedArguments = new ArrayDeque<>(); 16.14 16.15 + private final Deque<MethodType> callSiteTypes = new ArrayDeque<>(); 16.16 + 16.17 private static final String ARGUMENTS = ARGUMENTS_VAR.symbolName(); 16.18 16.19 /** 16.20 @@ -118,86 +121,113 @@ 16.21 return context.getLogger(this.getClass()); 16.22 } 16.23 16.24 + @SuppressWarnings("serial") 16.25 + private static class TransformFailedException extends RuntimeException { 16.26 + TransformFailedException(final FunctionNode fn, final String message) { 16.27 + super(massageURL(fn.getSource().getURL()) + '.' + fn.getName() + " => " + message, null, false, false); 16.28 + } 16.29 + } 16.30 + 16.31 + @SuppressWarnings("serial") 16.32 + private static class AppliesFoundException extends RuntimeException { 16.33 + AppliesFoundException() { 16.34 + super("applies_found", null, false, false); 16.35 + } 16.36 + } 16.37 + 16.38 + private static final AppliesFoundException HAS_APPLIES = new AppliesFoundException(); 16.39 + 16.40 + private boolean hasApplies(final FunctionNode functionNode) { 16.41 + try { 16.42 + functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 16.43 + @Override 16.44 + public boolean enterFunctionNode(final FunctionNode fn) { 16.45 + return fn == functionNode; 16.46 + } 16.47 + 16.48 + @Override 16.49 + public boolean enterCallNode(final CallNode callNode) { 16.50 + if (isApply(callNode)) { 16.51 + throw HAS_APPLIES; 16.52 + } 16.53 + return true; 16.54 + } 16.55 + }); 16.56 + } catch (final AppliesFoundException e) { 16.57 + return true; 16.58 + } 16.59 + 16.60 + log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); 16.61 + return false; // no applies 16.62 + } 16.63 + 16.64 /** 16.65 * Arguments may only be used as args to the apply. Everything else is disqualified 16.66 * We cannot control arguments if they escape from the method and go into an unknown 16.67 * scope, thus we are conservative and treat any access to arguments outside the 16.68 * apply call as a case of "we cannot apply the optimization". 16.69 - * 16.70 - * @return true if arguments escape 16.71 */ 16.72 - private boolean argumentsEscape(final FunctionNode functionNode) { 16.73 - 16.74 - @SuppressWarnings("serial") 16.75 - final UnsupportedOperationException uoe = new UnsupportedOperationException() { 16.76 - @Override 16.77 - public synchronized Throwable fillInStackTrace() { 16.78 - return null; 16.79 - } 16.80 - }; 16.81 + private static void checkValidTransform(final FunctionNode functionNode) { 16.82 16.83 final Set<Expression> argumentsFound = new HashSet<>(); 16.84 final Deque<Set<Expression>> stack = new ArrayDeque<>(); 16.85 + 16.86 //ensure that arguments is only passed as arg to apply 16.87 - try { 16.88 - functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 16.89 - private boolean isCurrentArg(final Expression expr) { 16.90 - return !stack.isEmpty() && stack.peek().contains(expr); //args to current apply call 16.91 - } 16.92 + functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { 16.93 16.94 - private boolean isArguments(final Expression expr) { 16.95 - if (expr instanceof IdentNode && ARGUMENTS.equals(((IdentNode)expr).getName())) { 16.96 - argumentsFound.add(expr); 16.97 + private boolean isCurrentArg(final Expression expr) { 16.98 + return !stack.isEmpty() && stack.peek().contains(expr); //args to current apply call 16.99 + } 16.100 + 16.101 + private boolean isArguments(final Expression expr) { 16.102 + if (expr instanceof IdentNode && ARGUMENTS.equals(((IdentNode)expr).getName())) { 16.103 + argumentsFound.add(expr); 16.104 + return true; 16.105 + } 16.106 + return false; 16.107 + } 16.108 + 16.109 + private boolean isParam(final String name) { 16.110 + for (final IdentNode param : functionNode.getParameters()) { 16.111 + if (param.getName().equals(name)) { 16.112 return true; 16.113 } 16.114 - return false; 16.115 } 16.116 + return false; 16.117 + } 16.118 16.119 - private boolean isParam(final String name) { 16.120 - for (final IdentNode param : functionNode.getParameters()) { 16.121 - if (param.getName().equals(name)) { 16.122 - return true; 16.123 - } 16.124 + @Override 16.125 + public Node leaveIdentNode(final IdentNode identNode) { 16.126 + if (isParam(identNode.getName())) { 16.127 + throw new TransformFailedException(lc.getCurrentFunction(), "parameter: " + identNode.getName()); 16.128 + } 16.129 + // it's OK if 'argument' occurs as the current argument of an apply 16.130 + if (isArguments(identNode) && !isCurrentArg(identNode)) { 16.131 + throw new TransformFailedException(lc.getCurrentFunction(), "is 'arguments': " + identNode.getName()); 16.132 + } 16.133 + return identNode; 16.134 + } 16.135 + 16.136 + @Override 16.137 + public boolean enterCallNode(final CallNode callNode) { 16.138 + final Set<Expression> callArgs = new HashSet<>(); 16.139 + if (isApply(callNode)) { 16.140 + final List<Expression> argList = callNode.getArgs(); 16.141 + if (argList.size() != 2 || !isArguments(argList.get(argList.size() - 1))) { 16.142 + throw new TransformFailedException(lc.getCurrentFunction(), "argument pattern not matched: " + argList); 16.143 } 16.144 - return false; 16.145 + callArgs.addAll(callNode.getArgs()); 16.146 } 16.147 + stack.push(callArgs); 16.148 + return true; 16.149 + } 16.150 16.151 - @Override 16.152 - public Node leaveIdentNode(final IdentNode identNode) { 16.153 - if (isParam(identNode.getName()) || isArguments(identNode) && !isCurrentArg(identNode)) { 16.154 - throw uoe; //avoid filling in stack trace 16.155 - } 16.156 - return identNode; 16.157 - } 16.158 - 16.159 - @Override 16.160 - public boolean enterCallNode(final CallNode callNode) { 16.161 - final Set<Expression> callArgs = new HashSet<>(); 16.162 - if (isApply(callNode)) { 16.163 - final List<Expression> argList = callNode.getArgs(); 16.164 - if (argList.size() != 2 || !isArguments(argList.get(argList.size() - 1))) { 16.165 - throw new UnsupportedOperationException(); 16.166 - } 16.167 - callArgs.addAll(callNode.getArgs()); 16.168 - } 16.169 - stack.push(callArgs); 16.170 - return true; 16.171 - } 16.172 - 16.173 - @Override 16.174 - public Node leaveCallNode(final CallNode callNode) { 16.175 - stack.pop(); 16.176 - return callNode; 16.177 - } 16.178 - }); 16.179 - } catch (final UnsupportedOperationException e) { 16.180 - if (!argumentsFound.isEmpty()) { 16.181 - log.fine("'arguments' is used but escapes, or is reassigned in '" + functionNode.getName() + "'. Aborting"); 16.182 + @Override 16.183 + public Node leaveCallNode(final CallNode callNode) { 16.184 + stack.pop(); 16.185 + return callNode; 16.186 } 16.187 - return true; //bad 16.188 - } 16.189 - 16.190 - return false; 16.191 + }); 16.192 } 16.193 16.194 @Override 16.195 @@ -224,12 +254,14 @@ 16.196 16.197 final CallNode newCallNode = callNode.setArgs(newArgs).setIsApplyToCall(); 16.198 16.199 - log.fine("Transformed ", 16.200 - callNode, 16.201 - " from apply to call => ", 16.202 - newCallNode, 16.203 - " in ", 16.204 - DebugLogger.quote(lc.getCurrentFunction().getName())); 16.205 + if (log.isEnabled()) { 16.206 + log.fine("Transformed ", 16.207 + callNode, 16.208 + " from apply to call => ", 16.209 + newCallNode, 16.210 + " in ", 16.211 + DebugLogger.quote(lc.getCurrentFunction().getName())); 16.212 + } 16.213 16.214 return newCallNode; 16.215 } 16.216 @@ -237,12 +269,12 @@ 16.217 return callNode; 16.218 } 16.219 16.220 - private boolean pushExplodedArgs(final FunctionNode functionNode) { 16.221 + private void pushExplodedArgs(final FunctionNode functionNode) { 16.222 int start = 0; 16.223 16.224 final MethodType actualCallSiteType = compiler.getCallSiteType(functionNode); 16.225 if (actualCallSiteType == null) { 16.226 - return false; 16.227 + throw new TransformFailedException(lc.getCurrentFunction(), "No callsite type"); 16.228 } 16.229 assert actualCallSiteType.parameterType(actualCallSiteType.parameterCount() - 1) != Object[].class : "error vararg callsite passed to apply2call " + functionNode.getName() + " " + actualCallSiteType; 16.230 16.231 @@ -264,8 +296,8 @@ 16.232 } 16.233 } 16.234 16.235 + callSiteTypes.push(actualCallSiteType); 16.236 explodedArguments.push(newParams); 16.237 - return true; 16.238 } 16.239 16.240 @Override 16.241 @@ -288,11 +320,30 @@ 16.242 return false; 16.243 } 16.244 16.245 - if (argumentsEscape(functionNode)) { 16.246 + if (!hasApplies(functionNode)) { 16.247 return false; 16.248 } 16.249 16.250 - return pushExplodedArgs(functionNode); 16.251 + if (log.isEnabled()) { 16.252 + log.info("Trying to specialize apply to call in '", 16.253 + functionNode.getName(), 16.254 + "' params=", 16.255 + functionNode.getParameters(), 16.256 + " id=", 16.257 + functionNode.getId(), 16.258 + " source=", 16.259 + massageURL(functionNode.getSource().getURL())); 16.260 + } 16.261 + 16.262 + try { 16.263 + checkValidTransform(functionNode); 16.264 + pushExplodedArgs(functionNode); 16.265 + } catch (final TransformFailedException e) { 16.266 + log.info("Failure: ", e.getMessage()); 16.267 + return false; 16.268 + } 16.269 + 16.270 + return true; 16.271 } 16.272 16.273 /** 16.274 @@ -300,8 +351,8 @@ 16.275 * @return true if successful, false otherwise 16.276 */ 16.277 @Override 16.278 - public Node leaveFunctionNode(final FunctionNode functionNode0) { 16.279 - FunctionNode newFunctionNode = functionNode0; 16.280 + public Node leaveFunctionNode(final FunctionNode functionNode) { 16.281 + FunctionNode newFunctionNode = functionNode; 16.282 final String functionName = newFunctionNode.getName(); 16.283 16.284 if (changed.contains(newFunctionNode.getId())) { 16.285 @@ -310,17 +361,18 @@ 16.286 setParameters(lc, explodedArguments.peek()); 16.287 16.288 if (log.isEnabled()) { 16.289 - log.info("Successfully specialized apply to call in '", 16.290 + log.info("Success: ", 16.291 + massageURL(newFunctionNode.getSource().getURL()), 16.292 + '.', 16.293 functionName, 16.294 - " params=", 16.295 - explodedArguments.peek(), 16.296 "' id=", 16.297 newFunctionNode.getId(), 16.298 - " source=", 16.299 - newFunctionNode.getSource().getURL()); 16.300 + " params=", 16.301 + callSiteTypes.peek()); 16.302 } 16.303 } 16.304 16.305 + callSiteTypes.pop(); 16.306 explodedArguments.pop(); 16.307 16.308 return newFunctionNode.setState(lc, CompilationState.BUILTINS_TRANSFORMED); 16.309 @@ -331,4 +383,15 @@ 16.310 return f instanceof AccessNode && "apply".equals(((AccessNode)f).getProperty()); 16.311 } 16.312 16.313 + private static String massageURL(final URL url) { 16.314 + if (url == null) { 16.315 + return "<null>"; 16.316 + } 16.317 + final String str = url.toString(); 16.318 + final int slash = str.lastIndexOf('/'); 16.319 + if (slash == -1) { 16.320 + return str; 16.321 + } 16.322 + return str.substring(slash + 1); 16.323 + } 16.324 }
17.1 --- a/src/jdk/nashorn/internal/codegen/CodeGenerator.java Wed Nov 12 13:47:23 2014 -0800 17.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGenerator.java Fri Nov 14 10:03:48 2014 -0800 17.3 @@ -615,7 +615,6 @@ 17.4 17.5 static final TypeBounds UNBOUNDED = new TypeBounds(Type.UNKNOWN, Type.OBJECT); 17.6 static final TypeBounds INT = exact(Type.INT); 17.7 - static final TypeBounds NUMBER = exact(Type.NUMBER); 17.8 static final TypeBounds OBJECT = exact(Type.OBJECT); 17.9 static final TypeBounds BOOLEAN = exact(Type.BOOLEAN); 17.10 17.11 @@ -3569,7 +3568,8 @@ 17.12 operandBounds = new TypeBounds(binaryNode.getType(), Type.OBJECT); 17.13 } else { 17.14 // Non-optimistic, non-FP +. Allow it to overflow. 17.15 - operandBounds = new TypeBounds(binaryNode.getWidestOperandType(), Type.OBJECT); 17.16 + operandBounds = new TypeBounds(Type.narrowest(binaryNode.getWidestOperandType(), resultBounds.widest), 17.17 + Type.OBJECT); 17.18 forceConversionSeparation = binaryNode.getWidestOperationType().narrowerThan(resultBounds.widest); 17.19 } 17.20 loadBinaryOperands(binaryNode.lhs(), binaryNode.rhs(), operandBounds, false, forceConversionSeparation); 17.21 @@ -3856,12 +3856,8 @@ 17.22 operandBounds = numericBounds; 17.23 } else { 17.24 final boolean isOptimistic = isValid(getProgramPoint()); 17.25 - if(isOptimistic) { 17.26 + if(isOptimistic || node.isTokenType(TokenType.DIV) || node.isTokenType(TokenType.MOD)) { 17.27 operandBounds = new TypeBounds(node.getType(), Type.NUMBER); 17.28 - } else if(node.isTokenType(TokenType.DIV) || node.isTokenType(TokenType.MOD)) { 17.29 - // Non-optimistic division must always take double arguments as its result must also be 17.30 - // double. 17.31 - operandBounds = TypeBounds.NUMBER; 17.32 } else { 17.33 // Non-optimistic, non-FP subtraction or multiplication. Allow them to overflow. 17.34 operandBounds = new TypeBounds(Type.narrowest(node.getWidestOperandType(), 17.35 @@ -3897,7 +3893,7 @@ 17.36 17.37 private static boolean isRhsZero(final BinaryNode binaryNode) { 17.38 final Expression rhs = binaryNode.rhs(); 17.39 - return rhs instanceof LiteralNode && INT_ZERO.equals(((LiteralNode)rhs).getValue()); 17.40 + return rhs instanceof LiteralNode && INT_ZERO.equals(((LiteralNode<?>)rhs).getValue()); 17.41 } 17.42 17.43 private void loadBIT_XOR(final BinaryNode binaryNode) {
18.1 --- a/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java Wed Nov 12 13:47:23 2014 -0800 18.2 +++ b/src/jdk/nashorn/internal/codegen/CodeGeneratorLexicalContext.java Fri Nov 14 10:03:48 2014 -0800 18.3 @@ -31,7 +31,6 @@ 18.4 import java.util.Deque; 18.5 import java.util.HashMap; 18.6 import java.util.Map; 18.7 - 18.8 import jdk.nashorn.internal.IntDeque; 18.9 import jdk.nashorn.internal.codegen.types.Type; 18.10 import jdk.nashorn.internal.ir.Block; 18.11 @@ -250,7 +249,7 @@ 18.12 static Type getTypeForSlotDescriptor(final char typeDesc) { 18.13 // Recognizing both lowercase and uppercase as we're using both to signify symbol boundaries; see 18.14 // MethodEmitter.markSymbolBoundariesInLvarTypesDescriptor(). 18.15 - switch(typeDesc) { 18.16 + switch (typeDesc) { 18.17 case 'I': 18.18 case 'i': 18.19 return Type.INT;
19.1 --- a/src/jdk/nashorn/internal/codegen/Compiler.java Wed Nov 12 13:47:23 2014 -0800 19.2 +++ b/src/jdk/nashorn/internal/codegen/Compiler.java Fri Nov 14 10:03:48 2014 -0800 19.3 @@ -389,6 +389,7 @@ 19.4 * @param continuationEntryPoints continuation entry points for restof method 19.5 * @param runtimeScope runtime scope for recompilation type lookup in {@code TypeEvaluator} 19.6 */ 19.7 + @SuppressWarnings("unused") 19.8 public Compiler( 19.9 final Context context, 19.10 final ScriptEnvironment env,
20.1 --- a/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Wed Nov 12 13:47:23 2014 -0800 20.2 +++ b/src/jdk/nashorn/internal/codegen/LocalVariableTypesCalculator.java Fri Nov 14 10:03:48 2014 -0800 20.3 @@ -28,7 +28,6 @@ 20.4 import static jdk.nashorn.internal.codegen.CompilerConstants.RETURN; 20.5 import static jdk.nashorn.internal.ir.Expression.isAlwaysFalse; 20.6 import static jdk.nashorn.internal.ir.Expression.isAlwaysTrue; 20.7 - 20.8 import java.util.ArrayDeque; 20.9 import java.util.ArrayList; 20.10 import java.util.Collections; 20.11 @@ -236,12 +235,12 @@ 20.12 private byte conversions; 20.13 20.14 void recordConversion(final LvarType from, final LvarType to) { 20.15 - switch(from) { 20.16 + switch (from) { 20.17 case UNDEFINED: 20.18 return; 20.19 case INT: 20.20 case BOOLEAN: 20.21 - switch(to) { 20.22 + switch (to) { 20.23 case LONG: 20.24 recordConversion(I2L); 20.25 return; 20.26 @@ -256,7 +255,7 @@ 20.27 return; 20.28 } 20.29 case LONG: 20.30 - switch(to) { 20.31 + switch (to) { 20.32 case DOUBLE: 20.33 recordConversion(L2D); 20.34 return; 20.35 @@ -1425,6 +1424,7 @@ 20.36 * @param symbol the symbol representing the variable 20.37 * @param type the type 20.38 */ 20.39 + @SuppressWarnings("unused") 20.40 private void setType(final Symbol symbol, final LvarType type) { 20.41 if(getLocalVariableTypeOrNull(symbol) == type) { 20.42 return;
21.1 --- a/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Wed Nov 12 13:47:23 2014 -0800 21.2 +++ b/src/jdk/nashorn/internal/codegen/OptimisticTypesPersistence.java Fri Nov 14 10:03:48 2014 -0800 21.3 @@ -33,6 +33,8 @@ 21.4 import java.io.FileOutputStream; 21.5 import java.io.IOException; 21.6 import java.io.InputStream; 21.7 +import java.io.PrintWriter; 21.8 +import java.io.StringWriter; 21.9 import java.net.URL; 21.10 import java.nio.file.Files; 21.11 import java.nio.file.Path; 21.12 @@ -221,11 +223,37 @@ 21.13 private static void reportError(final String msg, final File file, final Exception e) { 21.14 final long now = System.currentTimeMillis(); 21.15 if(now - lastReportedError > ERROR_REPORT_THRESHOLD) { 21.16 - getLogger().warning(String.format("Failed to %s %s", msg, file), e); 21.17 + reportError(String.format("Failed to %s %s", msg, file), e); 21.18 lastReportedError = now; 21.19 } 21.20 } 21.21 21.22 + /** 21.23 + * Logs an error message with warning severity (reasoning being that we're reporting an error that'll disable the 21.24 + * type info cache, but it's only logged as a warning because that doesn't prevent Nashorn from running, it just 21.25 + * disables a performance-enhancing cache). 21.26 + * @param msg the message to log 21.27 + * @param e the exception that represents the error. 21.28 + */ 21.29 + private static void reportError(final String msg, final Exception e) { 21.30 + getLogger().warning(msg, "\n", exceptionToString(e)); 21.31 + } 21.32 + 21.33 + /** 21.34 + * A helper that prints an exception stack trace into a string. We have to do this as if we just pass the exception 21.35 + * to {@link DebugLogger#warning(Object...)}, it will only log the exception message and not the stack, making 21.36 + * problems harder to diagnose. 21.37 + * @param e the exception 21.38 + * @return the string representation of {@link Exception#printStackTrace()} output. 21.39 + */ 21.40 + private static String exceptionToString(final Exception e) { 21.41 + final StringWriter sw = new StringWriter(); 21.42 + final PrintWriter pw = new PrintWriter(sw, false); 21.43 + e.printStackTrace(pw); 21.44 + pw.flush(); 21.45 + return sw.toString(); 21.46 + } 21.47 + 21.48 private static File createBaseCacheDir() { 21.49 if(MAX_FILES == 0 || Options.getBooleanProperty("nashorn.typeInfo.disabled")) { 21.50 return null; 21.51 @@ -233,7 +261,7 @@ 21.52 try { 21.53 return createBaseCacheDirPrivileged(); 21.54 } catch(final Exception e) { 21.55 - getLogger().warning("Failed to create cache dir", e); 21.56 + reportError("Failed to create cache dir", e); 21.57 return null; 21.58 } 21.59 } 21.60 @@ -267,7 +295,7 @@ 21.61 try { 21.62 return createCacheDirPrivileged(baseDir); 21.63 } catch(final Exception e) { 21.64 - getLogger().warning("Failed to create cache dir", e); 21.65 + reportError("Failed to create cache dir", e); 21.66 return null; 21.67 } 21.68 } 21.69 @@ -280,7 +308,7 @@ 21.70 try { 21.71 versionDirName = getVersionDirName(); 21.72 } catch(final Exception e) { 21.73 - getLogger().warning("Failed to calculate version dir name", e); 21.74 + reportError("Failed to calculate version dir name", e); 21.75 return null; 21.76 } 21.77 final File versionDir = new File(baseDir, versionDirName); 21.78 @@ -323,10 +351,17 @@ 21.79 * per-code-version directory. Normally, this will create the SHA-1 digest of the nashorn.jar. In case the classpath 21.80 * for nashorn is local directory (e.g. during development), this will create the string "dev-" followed by the 21.81 * timestamp of the most recent .class file. 21.82 - * @return 21.83 + * 21.84 + * @return digest of currently running nashorn 21.85 + * @throws Exception if digest could not be created 21.86 */ 21.87 - private static String getVersionDirName() throws Exception { 21.88 - final URL url = OptimisticTypesPersistence.class.getResource(""); 21.89 + public static String getVersionDirName() throws Exception { 21.90 + // NOTE: getResource("") won't work if the JAR file doesn't have directory entries (and JAR files in JDK distro 21.91 + // don't, or at least it's a bad idea counting on it). Alternatively, we could've tried 21.92 + // getResource("OptimisticTypesPersistence.class") but behavior of getResource with regard to its willingness 21.93 + // to hand out URLs to .class files is also unspecified. Therefore, the most robust way to obtain an URL to our 21.94 + // package is to have a small non-class anchor file and start out from its URL. 21.95 + final URL url = OptimisticTypesPersistence.class.getResource("anchor.properties"); 21.96 final String protocol = url.getProtocol(); 21.97 if (protocol.equals("jar")) { 21.98 // Normal deployment: nashorn.jar
22.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 22.2 +++ b/src/jdk/nashorn/internal/codegen/anchor.properties Fri Nov 14 10:03:48 2014 -0800 22.3 @@ -0,0 +1,27 @@ 22.4 +# 22.5 +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 22.6 +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 22.7 +# 22.8 +# This code is free software; you can redistribute it and/or modify it 22.9 +# under the terms of the GNU General Public License version 2 only, as 22.10 +# published by the Free Software Foundation. Oracle designates this 22.11 +# particular file as subject to the "Classpath" exception as provided 22.12 +# by Oracle in the LICENSE file that accompanied this code. 22.13 +# 22.14 +# This code is distributed in the hope that it will be useful, but WITHOUT 22.15 +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 22.16 +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 22.17 +# version 2 for more details (a copy is included in the LICENSE file that 22.18 +# accompanied this code). 22.19 +# 22.20 +# You should have received a copy of the GNU General Public License version 22.21 +# 2 along with this work; if not, write to the Free Software Foundation, 22.22 +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22.23 +# 22.24 +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22.25 +# or visit www.oracle.com if you need additional information or have any 22.26 +# questions. 22.27 +# 22.28 + 22.29 + 22.30 +# This file exists only so OptimisticTypesPersistence.getVersionDirName() can take its URL.
23.1 --- a/src/jdk/nashorn/internal/codegen/types/IntType.java Wed Nov 12 13:47:23 2014 -0800 23.2 +++ b/src/jdk/nashorn/internal/codegen/types/IntType.java Fri Nov 14 10:03:48 2014 -0800 23.3 @@ -55,6 +55,7 @@ 23.4 23.5 import jdk.internal.org.objectweb.asm.MethodVisitor; 23.6 import jdk.nashorn.internal.codegen.CompilerConstants; 23.7 +import jdk.nashorn.internal.runtime.JSType; 23.8 23.9 /** 23.10 * Type class: INT 23.11 @@ -230,19 +231,21 @@ 23.12 23.13 @Override 23.14 public Type div(final MethodVisitor method, final int programPoint) { 23.15 - // Never perform non-optimistic integer division in JavaScript. 23.16 - assert programPoint != INVALID_PROGRAM_POINT; 23.17 - 23.18 - method.visitInvokeDynamicInsn("idiv", "(II)I", MATHBOOTSTRAP, programPoint); 23.19 + if (programPoint == INVALID_PROGRAM_POINT) { 23.20 + JSType.DIV_ZERO.invoke(method); 23.21 + } else { 23.22 + method.visitInvokeDynamicInsn("idiv", "(II)I", MATHBOOTSTRAP, programPoint); 23.23 + } 23.24 return INT; 23.25 } 23.26 23.27 @Override 23.28 public Type rem(final MethodVisitor method, final int programPoint) { 23.29 - // Never perform non-optimistic integer remainder in JavaScript. 23.30 - assert programPoint != INVALID_PROGRAM_POINT; 23.31 - 23.32 - method.visitInvokeDynamicInsn("irem", "(II)I", MATHBOOTSTRAP, programPoint); 23.33 + if (programPoint == INVALID_PROGRAM_POINT) { 23.34 + JSType.REM_ZERO.invoke(method); 23.35 + } else { 23.36 + method.visitInvokeDynamicInsn("irem", "(II)I", MATHBOOTSTRAP, programPoint); 23.37 + } 23.38 return INT; 23.39 } 23.40
24.1 --- a/src/jdk/nashorn/internal/codegen/types/LongType.java Wed Nov 12 13:47:23 2014 -0800 24.2 +++ b/src/jdk/nashorn/internal/codegen/types/LongType.java Fri Nov 14 10:03:48 2014 -0800 24.3 @@ -170,19 +170,21 @@ 24.4 24.5 @Override 24.6 public Type div(final MethodVisitor method, final int programPoint) { 24.7 - // Never perform non-optimistic integer division in JavaScript. 24.8 - assert programPoint != INVALID_PROGRAM_POINT; 24.9 - 24.10 - method.visitInvokeDynamicInsn("ldiv", "(JJ)J", MATHBOOTSTRAP, programPoint); 24.11 + if (programPoint == INVALID_PROGRAM_POINT) { 24.12 + JSType.DIV_ZERO_LONG.invoke(method); 24.13 + } else { 24.14 + method.visitInvokeDynamicInsn("ldiv", "(JJ)J", MATHBOOTSTRAP, programPoint); 24.15 + } 24.16 return LONG; 24.17 } 24.18 24.19 @Override 24.20 public Type rem(final MethodVisitor method, final int programPoint) { 24.21 - // Never perform non-optimistic integer remainder in JavaScript. 24.22 - assert programPoint != INVALID_PROGRAM_POINT; 24.23 - 24.24 - method.visitInvokeDynamicInsn("lrem", "(JJ)J", MATHBOOTSTRAP, programPoint); 24.25 + if (programPoint == INVALID_PROGRAM_POINT) { 24.26 + JSType.REM_ZERO_LONG.invoke(method); 24.27 + } else { 24.28 + method.visitInvokeDynamicInsn("lrem", "(JJ)J", MATHBOOTSTRAP, programPoint); 24.29 + } 24.30 return LONG; 24.31 } 24.32
25.1 --- a/src/jdk/nashorn/internal/codegen/types/Type.java Wed Nov 12 13:47:23 2014 -0800 25.2 +++ b/src/jdk/nashorn/internal/codegen/types/Type.java Fri Nov 14 10:03:48 2014 -0800 25.3 @@ -356,7 +356,7 @@ 25.4 final int pp = input.readInt(); 25.5 final int typeChar = input.readByte(); 25.6 final Type type; 25.7 - switch(typeChar) { 25.8 + switch (typeChar) { 25.9 case 'L': type = Type.OBJECT; break; 25.10 case 'D': type = Type.NUMBER; break; 25.11 case 'J': type = Type.LONG; break; 25.12 @@ -376,13 +376,13 @@ 25.13 } 25.14 25.15 private static jdk.internal.org.objectweb.asm.Type lookupInternalType(final Class<?> type) { 25.16 - final Map<Class<?>, jdk.internal.org.objectweb.asm.Type> cache = INTERNAL_TYPE_CACHE; 25.17 - jdk.internal.org.objectweb.asm.Type itype = cache.get(type); 25.18 + final Map<Class<?>, jdk.internal.org.objectweb.asm.Type> c = INTERNAL_TYPE_CACHE; 25.19 + jdk.internal.org.objectweb.asm.Type itype = c.get(type); 25.20 if (itype != null) { 25.21 return itype; 25.22 } 25.23 itype = jdk.internal.org.objectweb.asm.Type.getType(type); 25.24 - cache.put(type, itype); 25.25 + c.put(type, itype); 25.26 return itype; 25.27 } 25.28 25.29 @@ -1155,6 +1155,10 @@ 25.30 return type; 25.31 } 25.32 25.33 + /** 25.34 + * Read resolve 25.35 + * @return resolved type 25.36 + */ 25.37 protected final Object readResolve() { 25.38 return Type.typeFor(clazz); 25.39 }
26.1 --- a/src/jdk/nashorn/internal/ir/BinaryNode.java Wed Nov 12 13:47:23 2014 -0800 26.2 +++ b/src/jdk/nashorn/internal/ir/BinaryNode.java Fri Nov 14 10:03:48 2014 -0800 26.3 @@ -264,6 +264,10 @@ 26.4 case COMMARIGHT: { 26.5 return rhs.getType(localVariableTypes); 26.6 } 26.7 + case AND: 26.8 + case OR:{ 26.9 + return Type.widestReturnType(lhs.getType(localVariableTypes), rhs.getType(localVariableTypes)); 26.10 + } 26.11 default: 26.12 if (isComparison()) { 26.13 return Type.BOOLEAN;
27.1 --- a/src/jdk/nashorn/internal/objects/ArrayBufferView.java Wed Nov 12 13:47:23 2014 -0800 27.2 +++ b/src/jdk/nashorn/internal/objects/ArrayBufferView.java Fri Nov 14 10:03:48 2014 -0800 27.3 @@ -28,7 +28,6 @@ 27.4 import static jdk.nashorn.internal.runtime.ECMAErrors.rangeError; 27.5 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 27.6 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT; 27.7 - 27.8 import java.nio.ByteBuffer; 27.9 import java.nio.ByteOrder; 27.10 import jdk.internal.dynalink.CallSiteDescriptor; 27.11 @@ -44,6 +43,9 @@ 27.12 import jdk.nashorn.internal.runtime.arrays.ArrayData; 27.13 import jdk.nashorn.internal.runtime.arrays.TypedArrayData; 27.14 27.15 +/** 27.16 + * ArrayBufferView, es6 class or TypedArray implementation 27.17 + */ 27.18 @ScriptClass("ArrayBufferView") 27.19 public abstract class ArrayBufferView extends ScriptObject { 27.20 private final NativeArrayBuffer buffer; 27.21 @@ -71,6 +73,13 @@ 27.22 setArray(data); 27.23 } 27.24 27.25 + /** 27.26 + * Constructor 27.27 + * 27.28 + * @param buffer underlying NativeArrayBuffer 27.29 + * @param byteOffset byte offset for buffer 27.30 + * @param elementLength element length in bytes 27.31 + */ 27.32 protected ArrayBufferView(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength) { 27.33 this(buffer, byteOffset, elementLength, Global.instance()); 27.34 } 27.35 @@ -89,22 +98,42 @@ 27.36 return factory().bytesPerElement; 27.37 } 27.38 27.39 + /** 27.40 + * Buffer getter as per spec 27.41 + * @param self ArrayBufferView instance 27.42 + * @return buffer 27.43 + */ 27.44 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) 27.45 public static Object buffer(final Object self) { 27.46 return ((ArrayBufferView)self).buffer; 27.47 } 27.48 27.49 + /** 27.50 + * Buffer offset getter as per spec 27.51 + * @param self ArrayBufferView instance 27.52 + * @return buffer offset 27.53 + */ 27.54 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) 27.55 public static int byteOffset(final Object self) { 27.56 return ((ArrayBufferView)self).byteOffset; 27.57 } 27.58 27.59 + /** 27.60 + * Byte length getter as per spec 27.61 + * @param self ArrayBufferView instance 27.62 + * @return array buffer view length in bytes 27.63 + */ 27.64 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) 27.65 public static int byteLength(final Object self) { 27.66 final ArrayBufferView view = (ArrayBufferView)self; 27.67 return ((TypedArrayData<?>)view.getArray()).getElementLength() * view.bytesPerElement(); 27.68 } 27.69 27.70 + /** 27.71 + * Length getter as per spec 27.72 + * @param self ArrayBufferView instance 27.73 + * @return length in elements 27.74 + */ 27.75 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) 27.76 public static int length(final Object self) { 27.77 return ((ArrayBufferView)self).elementLength(); 27.78 @@ -119,15 +148,29 @@ 27.79 return ((TypedArrayData<?>)getArray()).getElementLength(); 27.80 } 27.81 27.82 + /** 27.83 + * Factory class for byte ArrayBufferViews 27.84 + */ 27.85 protected static abstract class Factory { 27.86 final int bytesPerElement; 27.87 final int maxElementLength; 27.88 27.89 + /** 27.90 + * Constructor 27.91 + * 27.92 + * @param bytesPerElement number of bytes per element for this buffer 27.93 + */ 27.94 public Factory(final int bytesPerElement) { 27.95 this.bytesPerElement = bytesPerElement; 27.96 this.maxElementLength = Integer.MAX_VALUE / bytesPerElement; 27.97 } 27.98 27.99 + /** 27.100 + * Factory method 27.101 + * 27.102 + * @param elementLength number of elements 27.103 + * @return new ArrayBufferView 27.104 + */ 27.105 public final ArrayBufferView construct(final int elementLength) { 27.106 if (elementLength > maxElementLength) { 27.107 throw rangeError("inappropriate.array.buffer.length", JSType.toString(elementLength)); 27.108 @@ -135,15 +178,47 @@ 27.109 return construct(new NativeArrayBuffer(elementLength * bytesPerElement), 0, elementLength); 27.110 } 27.111 27.112 - public abstract ArrayBufferView construct(NativeArrayBuffer buffer, int byteOffset, int elementLength); 27.113 + /** 27.114 + * Factory method 27.115 + * 27.116 + * @param buffer underlying buffer 27.117 + * @param byteOffset byte offset 27.118 + * @param elementLength number of elements 27.119 + * 27.120 + * @return new ArrayBufferView 27.121 + */ 27.122 + public abstract ArrayBufferView construct(final NativeArrayBuffer buffer, final int byteOffset, final int elementLength); 27.123 27.124 - public abstract TypedArrayData<?> createArrayData(ByteBuffer nb, int start, int end); 27.125 + /** 27.126 + * Factory method for array data 27.127 + * 27.128 + * @param nb underlying nativebuffer 27.129 + * @param start start element 27.130 + * @param end end element 27.131 + * 27.132 + * @return new array data 27.133 + */ 27.134 + public abstract TypedArrayData<?> createArrayData(final ByteBuffer nb, final int start, final int end); 27.135 27.136 + /** 27.137 + * Get the class name for this type of buffer 27.138 + * 27.139 + * @return class name 27.140 + */ 27.141 public abstract String getClassName(); 27.142 } 27.143 27.144 + /** 27.145 + * Get the factor for this kind of buffer 27.146 + * @return Factory 27.147 + */ 27.148 protected abstract Factory factory(); 27.149 27.150 + /** 27.151 + * Get the prototype for this ArrayBufferView 27.152 + * @param global global instance 27.153 + * @return prototype 27.154 + */ 27.155 protected abstract ScriptObject getPrototype(final Global global); 27.156 27.157 @Override 27.158 @@ -151,10 +226,23 @@ 27.159 return factory().getClassName(); 27.160 } 27.161 27.162 + /** 27.163 + * Check if this array contains floats 27.164 + * @return true if float array (or double) 27.165 + */ 27.166 protected boolean isFloatArray() { 27.167 return false; 27.168 } 27.169 27.170 + /** 27.171 + * Inheritable constructor implementation 27.172 + * 27.173 + * @param newObj is this a new constructor 27.174 + * @param args arguments 27.175 + * @param factory factory 27.176 + * 27.177 + * @return new ArrayBufferView 27.178 + */ 27.179 protected static ArrayBufferView constructorImpl(final boolean newObj, final Object[] args, final Factory factory) { 27.180 final Object arg0 = args.length != 0 ? args[0] : 0; 27.181 final ArrayBufferView dest; 27.182 @@ -200,6 +288,15 @@ 27.183 return dest; 27.184 } 27.185 27.186 + /** 27.187 + * Inheritable implementation of set, if no efficient implementation is available 27.188 + * 27.189 + * @param self ArrayBufferView instance 27.190 + * @param array array 27.191 + * @param offset0 array offset 27.192 + * 27.193 + * @return result of setter 27.194 + */ 27.195 protected static Object setImpl(final Object self, final Object array, final Object offset0) { 27.196 final ArrayBufferView dest = (ArrayBufferView)self; 27.197 final int length; 27.198 @@ -244,6 +341,15 @@ 27.199 return (int)(length & Integer.MAX_VALUE); 27.200 } 27.201 27.202 + /** 27.203 + * Implementation of subarray if no efficient override exists 27.204 + * 27.205 + * @param self ArrayBufferView instance 27.206 + * @param begin0 begin index 27.207 + * @param end0 end index 27.208 + * 27.209 + * @return sub array 27.210 + */ 27.211 protected static ScriptObject subarrayImpl(final Object self, final Object begin0, final Object end0) { 27.212 final ArrayBufferView arrayView = (ArrayBufferView)self; 27.213 final int byteOffset = arrayView.byteOffset;
28.1 --- a/src/jdk/nashorn/internal/objects/Global.java Wed Nov 12 13:47:23 2014 -0800 28.2 +++ b/src/jdk/nashorn/internal/objects/Global.java Fri Nov 14 10:03:48 2014 -0800 28.3 @@ -29,6 +29,7 @@ 28.4 import static jdk.nashorn.internal.runtime.ECMAErrors.referenceError; 28.5 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 28.6 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 28.7 + 28.8 import java.io.IOException; 28.9 import java.io.PrintWriter; 28.10 import java.lang.invoke.MethodHandle; 28.11 @@ -41,7 +42,6 @@ 28.12 import java.util.Map; 28.13 import java.util.concurrent.Callable; 28.14 import java.util.concurrent.ConcurrentHashMap; 28.15 -import java.util.concurrent.atomic.AtomicReference; 28.16 import javax.script.ScriptContext; 28.17 import javax.script.ScriptEngine; 28.18 import jdk.internal.dynalink.linker.GuardedInvocation; 28.19 @@ -54,7 +54,6 @@ 28.20 import jdk.nashorn.internal.objects.annotations.ScriptClass; 28.21 import jdk.nashorn.internal.runtime.ConsString; 28.22 import jdk.nashorn.internal.runtime.Context; 28.23 -import jdk.nashorn.internal.runtime.GlobalConstants; 28.24 import jdk.nashorn.internal.runtime.GlobalFunctions; 28.25 import jdk.nashorn.internal.runtime.JSType; 28.26 import jdk.nashorn.internal.runtime.NativeJavaPackage; 28.27 @@ -438,9 +437,6 @@ 28.28 this.scontext = scontext; 28.29 } 28.30 28.31 - // global constants for this global - they can be replaced with MethodHandle.constant until invalidated 28.32 - private static AtomicReference<GlobalConstants> gcsInstance = new AtomicReference<>(); 28.33 - 28.34 @Override 28.35 protected Context getContext() { 28.36 return context; 28.37 @@ -470,11 +466,6 @@ 28.38 super(checkAndGetMap(context)); 28.39 this.context = context; 28.40 this.setIsScope(); 28.41 - //we can only share one instance of Global constants between globals, or we consume way too much 28.42 - //memory - this is good enough for most programs 28.43 - while (gcsInstance.get() == null) { 28.44 - gcsInstance.compareAndSet(null, new GlobalConstants(context.getLogger(GlobalConstants.class))); 28.45 - } 28.46 } 28.47 28.48 /** 28.49 @@ -493,15 +484,6 @@ 28.50 } 28.51 28.52 /** 28.53 - * Return the global constants map for fields that 28.54 - * can be accessed as MethodHandle.constant 28.55 - * @return constant map 28.56 - */ 28.57 - public static GlobalConstants getConstants() { 28.58 - return gcsInstance.get(); 28.59 - } 28.60 - 28.61 - /** 28.62 * Check if we have a Global instance 28.63 * @return true if one exists 28.64 */
29.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Wed Nov 12 13:47:23 2014 -0800 29.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Fri Nov 14 10:03:48 2014 -0800 29.3 @@ -35,7 +35,6 @@ 29.4 import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.CALLSITE_STRICT; 29.5 29.6 import java.lang.invoke.MethodHandle; 29.7 -import java.lang.invoke.SwitchPoint; 29.8 import java.util.ArrayList; 29.9 import java.util.Arrays; 29.10 import java.util.Collections; 29.11 @@ -93,17 +92,6 @@ 29.12 private static final Object CALL_CMP = new Object(); 29.13 private static final Object TO_LOCALE_STRING = new Object(); 29.14 29.15 - private SwitchPoint lengthMadeNotWritableSwitchPoint; 29.16 - private PushLinkLogic pushLinkLogic; 29.17 - private PopLinkLogic popLinkLogic; 29.18 - private ConcatLinkLogic concatLinkLogic; 29.19 - 29.20 - /** 29.21 - * Index for the modification SwitchPoint that triggers when length 29.22 - * becomes not writable 29.23 - */ 29.24 - private static final int LENGTH_NOT_WRITABLE_SWITCHPOINT = 0; 29.25 - 29.26 /* 29.27 * Constructors. 29.28 */ 29.29 @@ -271,12 +259,83 @@ 29.30 @Override 29.31 public Object getLength() { 29.32 final long length = JSType.toUint32(getArray().length()); 29.33 - if(length < Integer.MAX_VALUE) { 29.34 + if (length < Integer.MAX_VALUE) { 29.35 return (int)length; 29.36 } 29.37 return length; 29.38 } 29.39 29.40 + private boolean defineLength(final long oldLen, final PropertyDescriptor oldLenDesc, final PropertyDescriptor desc, final boolean reject) { 29.41 + // Step 3a 29.42 + if (!desc.has(VALUE)) { 29.43 + return super.defineOwnProperty("length", desc, reject); 29.44 + } 29.45 + 29.46 + // Step 3b 29.47 + final PropertyDescriptor newLenDesc = desc; 29.48 + 29.49 + // Step 3c and 3d - get new length and convert to long 29.50 + final long newLen = NativeArray.validLength(newLenDesc.getValue(), true); 29.51 + 29.52 + // Step 3e 29.53 + newLenDesc.setValue(newLen); 29.54 + 29.55 + // Step 3f 29.56 + // increasing array length - just need to set new length value (and attributes if any) and return 29.57 + if (newLen >= oldLen) { 29.58 + return super.defineOwnProperty("length", newLenDesc, reject); 29.59 + } 29.60 + 29.61 + // Step 3g 29.62 + if (!oldLenDesc.isWritable()) { 29.63 + if (reject) { 29.64 + throw typeError("property.not.writable", "length", ScriptRuntime.safeToString(this)); 29.65 + } 29.66 + return false; 29.67 + } 29.68 + 29.69 + // Step 3h and 3i 29.70 + final boolean newWritable = !newLenDesc.has(WRITABLE) || newLenDesc.isWritable(); 29.71 + if (!newWritable) { 29.72 + newLenDesc.setWritable(true); 29.73 + } 29.74 + 29.75 + // Step 3j and 3k 29.76 + final boolean succeeded = super.defineOwnProperty("length", newLenDesc, reject); 29.77 + if (!succeeded) { 29.78 + return false; 29.79 + } 29.80 + 29.81 + // Step 3l 29.82 + // make sure that length is set till the point we can delete the old elements 29.83 + long o = oldLen; 29.84 + while (newLen < o) { 29.85 + o--; 29.86 + final boolean deleteSucceeded = delete(o, false); 29.87 + if (!deleteSucceeded) { 29.88 + newLenDesc.setValue(o + 1); 29.89 + if (!newWritable) { 29.90 + newLenDesc.setWritable(false); 29.91 + } 29.92 + super.defineOwnProperty("length", newLenDesc, false); 29.93 + if (reject) { 29.94 + throw typeError("property.not.writable", "length", ScriptRuntime.safeToString(this)); 29.95 + } 29.96 + return false; 29.97 + } 29.98 + } 29.99 + 29.100 + // Step 3m 29.101 + if (!newWritable) { 29.102 + // make 'length' property not writable 29.103 + final ScriptObject newDesc = Global.newEmptyInstance(); 29.104 + newDesc.set(WRITABLE, false, 0); 29.105 + return super.defineOwnProperty("length", newDesc, false); 29.106 + } 29.107 + 29.108 + return true; 29.109 + } 29.110 + 29.111 /** 29.112 * ECMA 15.4.5.1 [[DefineOwnProperty]] ( P, Desc, Throw ) 29.113 */ 29.114 @@ -290,82 +349,16 @@ 29.115 29.116 // Step 2 29.117 // get old length and convert to long 29.118 - long oldLen = NativeArray.validLength(oldLenDesc.getValue(), true); 29.119 + final long oldLen = NativeArray.validLength(oldLenDesc.getValue(), true); 29.120 29.121 // Step 3 29.122 if ("length".equals(key)) { 29.123 // check for length being made non-writable 29.124 + final boolean result = defineLength(oldLen, oldLenDesc, desc, reject); 29.125 if (desc.has(WRITABLE) && !desc.isWritable()) { 29.126 setIsLengthNotWritable(); 29.127 } 29.128 - 29.129 - // Step 3a 29.130 - if (!desc.has(VALUE)) { 29.131 - return super.defineOwnProperty("length", desc, reject); 29.132 - } 29.133 - 29.134 - // Step 3b 29.135 - final PropertyDescriptor newLenDesc = desc; 29.136 - 29.137 - // Step 3c and 3d - get new length and convert to long 29.138 - final long newLen = NativeArray.validLength(newLenDesc.getValue(), true); 29.139 - 29.140 - // Step 3e 29.141 - newLenDesc.setValue(newLen); 29.142 - 29.143 - // Step 3f 29.144 - // increasing array length - just need to set new length value (and attributes if any) and return 29.145 - if (newLen >= oldLen) { 29.146 - return super.defineOwnProperty("length", newLenDesc, reject); 29.147 - } 29.148 - 29.149 - // Step 3g 29.150 - if (!oldLenDesc.isWritable()) { 29.151 - if (reject) { 29.152 - throw typeError("property.not.writable", "length", ScriptRuntime.safeToString(this)); 29.153 - } 29.154 - return false; 29.155 - } 29.156 - 29.157 - // Step 3h and 3i 29.158 - final boolean newWritable = !newLenDesc.has(WRITABLE) || newLenDesc.isWritable(); 29.159 - if (!newWritable) { 29.160 - newLenDesc.setWritable(true); 29.161 - } 29.162 - 29.163 - // Step 3j and 3k 29.164 - final boolean succeeded = super.defineOwnProperty("length", newLenDesc, reject); 29.165 - if (!succeeded) { 29.166 - return false; 29.167 - } 29.168 - 29.169 - // Step 3l 29.170 - // make sure that length is set till the point we can delete the old elements 29.171 - while (newLen < oldLen) { 29.172 - oldLen--; 29.173 - final boolean deleteSucceeded = delete(oldLen, false); 29.174 - if (!deleteSucceeded) { 29.175 - newLenDesc.setValue(oldLen + 1); 29.176 - if (!newWritable) { 29.177 - newLenDesc.setWritable(false); 29.178 - } 29.179 - super.defineOwnProperty("length", newLenDesc, false); 29.180 - if (reject) { 29.181 - throw typeError("property.not.writable", "length", ScriptRuntime.safeToString(this)); 29.182 - } 29.183 - return false; 29.184 - } 29.185 - } 29.186 - 29.187 - // Step 3m 29.188 - if (!newWritable) { 29.189 - // make 'length' property not writable 29.190 - final ScriptObject newDesc = Global.newEmptyInstance(); 29.191 - newDesc.set(WRITABLE, false, 0); 29.192 - return super.defineOwnProperty("length", newDesc, false); 29.193 - } 29.194 - 29.195 - return true; 29.196 + return result; 29.197 } 29.198 29.199 // Step 4a 29.200 @@ -441,23 +434,7 @@ 29.201 @Override 29.202 public void setIsLengthNotWritable() { 29.203 super.setIsLengthNotWritable(); 29.204 - /* 29.205 - * Switchpoints are created lazily. If we link any push or pop site, 29.206 - * we need to create the "length made not writable" switchpoint, if it 29.207 - * doesn't exist. 29.208 - * 29.209 - * If the switchpoint already exists, we will find it here, and invalidate 29.210 - * it, invalidating all previous callsites that use it. 29.211 - * 29.212 - * If the switchpoint doesn't exist, no push/pop has been linked so far, 29.213 - * because that would create it too. We invalidate it immediately and the 29.214 - * check link logic for all future callsites will fail immediately at link 29.215 - * time 29.216 - */ 29.217 - if (lengthMadeNotWritableSwitchPoint == null) { 29.218 - lengthMadeNotWritableSwitchPoint = new SwitchPoint(); 29.219 - } 29.220 - SwitchPoint.invalidateAll(new SwitchPoint[] { lengthMadeNotWritableSwitchPoint }); 29.221 + setArray(ArrayData.setIsLengthNotWritable(getArray())); 29.222 } 29.223 29.224 /** 29.225 @@ -494,7 +471,7 @@ 29.226 @Setter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_CONFIGURABLE) 29.227 public static void length(final Object self, final Object length) { 29.228 if (isArray(self)) { 29.229 - ((ScriptObject) self).setLength(validLength(length, true)); 29.230 + ((ScriptObject)self).setLength(validLength(length, true)); 29.231 } 29.232 } 29.233 29.234 @@ -1306,10 +1283,13 @@ 29.235 // Get only non-missing elements. Missing elements go at the end 29.236 // of the sorted array. So, just don't copy these to sort input. 29.237 final ArrayList<Object> src = new ArrayList<>(); 29.238 - for (long i = 0; i < len; i = array.nextIndex(i)) { 29.239 - if (array.has((int) i)) { 29.240 - src.add(array.getObject((int) i)); 29.241 + 29.242 + for (final Iterator<Long> iter = array.indexIterator(); iter.hasNext(); ) { 29.243 + final long index = iter.next(); 29.244 + if (index >= len) { 29.245 + break; 29.246 } 29.247 + src.add(array.getObject((int)index)); 29.248 } 29.249 29.250 final Object[] sorted = sort(src.toArray(), comparefn); 29.251 @@ -1767,11 +1747,11 @@ 29.252 @Override 29.253 public SpecializedFunction.LinkLogic getLinkLogic(final Class<? extends LinkLogic> clazz) { 29.254 if (clazz == PushLinkLogic.class) { 29.255 - return pushLinkLogic == null ? new PushLinkLogic(this) : pushLinkLogic; 29.256 + return PushLinkLogic.INSTANCE; 29.257 } else if (clazz == PopLinkLogic.class) { 29.258 - return popLinkLogic == null ? new PopLinkLogic(this) : pushLinkLogic; 29.259 + return PopLinkLogic.INSTANCE; 29.260 } else if (clazz == ConcatLinkLogic.class) { 29.261 - return concatLinkLogic == null ? new ConcatLinkLogic(this) : concatLinkLogic; 29.262 + return ConcatLinkLogic.INSTANCE; 29.263 } 29.264 return null; 29.265 } 29.266 @@ -1787,21 +1767,7 @@ 29.267 * modification switchpoint which is touched when length is written. 29.268 */ 29.269 private static abstract class ArrayLinkLogic extends SpecializedFunction.LinkLogic { 29.270 - private final NativeArray array; 29.271 - 29.272 - protected ArrayLinkLogic(final NativeArray array) { 29.273 - this.array = array; 29.274 - } 29.275 - 29.276 - private SwitchPoint getSwitchPoint() { 29.277 - return array.lengthMadeNotWritableSwitchPoint; 29.278 - } 29.279 - 29.280 - private SwitchPoint newSwitchPoint() { 29.281 - assert array.lengthMadeNotWritableSwitchPoint == null; 29.282 - final SwitchPoint sp = new SwitchPoint(); 29.283 - array.lengthMadeNotWritableSwitchPoint = sp; 29.284 - return sp; 29.285 + protected ArrayLinkLogic() { 29.286 } 29.287 29.288 protected static ContinuousArrayData getContinuousArrayData(final Object self) { 29.289 @@ -1822,68 +1788,13 @@ 29.290 public Class<? extends Throwable> getRelinkException() { 29.291 return ClassCastException.class; 29.292 } 29.293 - 29.294 - @Override 29.295 - public boolean hasModificationSwitchPoints() { 29.296 - return getSwitchPoint() != null; 29.297 - } 29.298 - 29.299 - @Override 29.300 - public boolean hasModificationSwitchPoint(final int index) { 29.301 - assert index == LENGTH_NOT_WRITABLE_SWITCHPOINT; 29.302 - return hasModificationSwitchPoints(); 29.303 - } 29.304 - 29.305 - @Override 29.306 - public SwitchPoint getOrCreateModificationSwitchPoint(final int index) { 29.307 - assert index == LENGTH_NOT_WRITABLE_SWITCHPOINT; 29.308 - SwitchPoint sp = getSwitchPoint(); 29.309 - if (sp == null) { 29.310 - sp = newSwitchPoint(); 29.311 - } 29.312 - return sp; 29.313 - } 29.314 - 29.315 - @Override 29.316 - public SwitchPoint[] getOrCreateModificationSwitchPoints() { 29.317 - return new SwitchPoint[] { getOrCreateModificationSwitchPoint(LENGTH_NOT_WRITABLE_SWITCHPOINT) }; 29.318 - } 29.319 - 29.320 - @Override 29.321 - public void invalidateModificationSwitchPoint(final int index) { 29.322 - assert index == LENGTH_NOT_WRITABLE_SWITCHPOINT; 29.323 - invalidateModificationSwitchPoints(); 29.324 - } 29.325 - 29.326 - @Override 29.327 - public void invalidateModificationSwitchPoints() { 29.328 - final SwitchPoint sp = getSwitchPoint(); 29.329 - assert sp != null : "trying to invalidate non-existant modified SwitchPoint"; 29.330 - if (!sp.hasBeenInvalidated()) { 29.331 - SwitchPoint.invalidateAll(new SwitchPoint[] { sp }); 29.332 - } 29.333 - } 29.334 - 29.335 - @Override 29.336 - public boolean hasInvalidatedModificationSwitchPoint(final int index) { 29.337 - assert index == LENGTH_NOT_WRITABLE_SWITCHPOINT; 29.338 - return hasInvalidatedModificationSwitchPoints(); 29.339 - } 29.340 - 29.341 - @Override 29.342 - public boolean hasInvalidatedModificationSwitchPoints() { 29.343 - final SwitchPoint sp = getSwitchPoint(); 29.344 - return sp != null && !sp.hasBeenInvalidated(); 29.345 - } 29.346 } 29.347 29.348 /** 29.349 * This is linker logic for optimistic concatenations 29.350 */ 29.351 private static final class ConcatLinkLogic extends ArrayLinkLogic { 29.352 - private ConcatLinkLogic(final NativeArray array) { 29.353 - super(array); 29.354 - } 29.355 + private static final LinkLogic INSTANCE = new ConcatLinkLogic(); 29.356 29.357 @Override 29.358 public boolean canLink(final Object self, final CallSiteDescriptor desc, final LinkRequest request) { 29.359 @@ -1915,9 +1826,7 @@ 29.360 * This is linker logic for optimistic pushes 29.361 */ 29.362 private static final class PushLinkLogic extends ArrayLinkLogic { 29.363 - private PushLinkLogic(final NativeArray array) { 29.364 - super(array); 29.365 - } 29.366 + private static final LinkLogic INSTANCE = new PushLinkLogic(); 29.367 29.368 @Override 29.369 public boolean canLink(final Object self, final CallSiteDescriptor desc, final LinkRequest request) { 29.370 @@ -1929,9 +1838,7 @@ 29.371 * This is linker logic for optimistic pops 29.372 */ 29.373 private static final class PopLinkLogic extends ArrayLinkLogic { 29.374 - private PopLinkLogic(final NativeArray array) { 29.375 - super(array); 29.376 - } 29.377 + private static final LinkLogic INSTANCE = new PopLinkLogic(); 29.378 29.379 /** 29.380 * We need to check if we are dealing with a continuous non empty array data here,
30.1 --- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Wed Nov 12 13:47:23 2014 -0800 30.2 +++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Fri Nov 14 10:03:48 2014 -0800 30.3 @@ -26,7 +26,6 @@ 30.4 package jdk.nashorn.internal.objects; 30.5 30.6 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 30.7 - 30.8 import java.nio.ByteBuffer; 30.9 import jdk.nashorn.internal.objects.annotations.Attribute; 30.10 import jdk.nashorn.internal.objects.annotations.Constructor; 30.11 @@ -34,6 +33,7 @@ 30.12 import jdk.nashorn.internal.objects.annotations.Getter; 30.13 import jdk.nashorn.internal.objects.annotations.ScriptClass; 30.14 import jdk.nashorn.internal.objects.annotations.SpecializedFunction; 30.15 +import jdk.nashorn.internal.objects.annotations.Where; 30.16 import jdk.nashorn.internal.runtime.JSType; 30.17 import jdk.nashorn.internal.runtime.PropertyMap; 30.18 import jdk.nashorn.internal.runtime.ScriptObject; 30.19 @@ -138,6 +138,19 @@ 30.20 } 30.21 30.22 /** 30.23 + * Returns true if an object is an ArrayBufferView 30.24 + * 30.25 + * @param self self 30.26 + * @param obj object to check 30.27 + * 30.28 + * @return true if obj is an ArrayBufferView 30.29 + */ 30.30 + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 30.31 + public static boolean isView(final Object self, final Object obj) { 30.32 + return obj instanceof ArrayBufferView; 30.33 + } 30.34 + 30.35 + /** 30.36 * Slice function 30.37 * @param self native array buffer 30.38 * @param begin0 start byte index
31.1 --- a/src/jdk/nashorn/internal/objects/NativeDebug.java Wed Nov 12 13:47:23 2014 -0800 31.2 +++ b/src/jdk/nashorn/internal/objects/NativeDebug.java Fri Nov 14 10:03:48 2014 -0800 31.3 @@ -39,6 +39,7 @@ 31.4 import jdk.nashorn.internal.runtime.PropertyMap; 31.5 import jdk.nashorn.internal.runtime.ScriptFunction; 31.6 import jdk.nashorn.internal.runtime.ScriptObject; 31.7 +import jdk.nashorn.internal.runtime.ScriptRuntime; 31.8 import jdk.nashorn.internal.runtime.events.RuntimeEvent; 31.9 import jdk.nashorn.internal.runtime.linker.LinkerCallSite; 31.10 import jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor; 31.11 @@ -66,6 +67,36 @@ 31.12 } 31.13 31.14 /** 31.15 + * Return the ArrayData class for this ScriptObject 31.16 + * @param self self 31.17 + * @param obj script object to check 31.18 + * @return ArrayData class, or undefined if no ArrayData is present 31.19 + */ 31.20 + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 31.21 + public static Object getArrayDataClass(final Object self, final Object obj) { 31.22 + try { 31.23 + return ((ScriptObject)obj).getArray().getClass(); 31.24 + } catch (final ClassCastException e) { 31.25 + return ScriptRuntime.UNDEFINED; 31.26 + } 31.27 + } 31.28 + 31.29 + /** 31.30 + * Return the ArrayData for this ScriptObject 31.31 + * @param self self 31.32 + * @param obj script object to check 31.33 + * @return ArrayData, ArrayDatas have toString methods, return Undefined if data missing 31.34 + */ 31.35 + @Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR) 31.36 + public static Object getArrayData(final Object self, final Object obj) { 31.37 + try { 31.38 + return ((ScriptObject)obj).getArray(); 31.39 + } catch (final ClassCastException e) { 31.40 + return ScriptRuntime.UNDEFINED; 31.41 + } 31.42 + } 31.43 + 31.44 + /** 31.45 * Nashorn extension: get context, context utility 31.46 * 31.47 * @param self self reference
32.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Wed Nov 12 13:47:23 2014 -0800 32.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Fri Nov 14 10:03:48 2014 -0800 32.3 @@ -29,6 +29,7 @@ 32.4 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 32.5 import static jdk.nashorn.internal.runtime.JSType.isRepresentableAsInt; 32.6 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 32.7 + 32.8 import java.lang.invoke.MethodHandle; 32.9 import java.lang.invoke.MethodHandles; 32.10 import java.lang.invoke.MethodType; 32.11 @@ -572,7 +573,7 @@ 32.12 try { 32.13 return ((CharSequence)self).charAt(pos); 32.14 } catch (final IndexOutOfBoundsException e) { 32.15 - throw new ClassCastException(); 32.16 + throw new ClassCastException(); //invalid char, out of bounds, force relink 32.17 } 32.18 } 32.19 32.20 @@ -1380,7 +1381,6 @@ 32.21 * sequence and that we are in range 32.22 */ 32.23 private static final class CharCodeAtLinkLogic extends SpecializedFunction.LinkLogic { 32.24 - 32.25 private static final CharCodeAtLinkLogic INSTANCE = new CharCodeAtLinkLogic(); 32.26 32.27 @Override 32.28 @@ -1389,7 +1389,7 @@ 32.29 //check that it's a char sequence or throw cce 32.30 final CharSequence cs = (CharSequence)self; 32.31 //check that the index, representable as an int, is inside the array 32.32 - final int intIndex = JSType.toInteger(request.getArguments()[1]); 32.33 + final int intIndex = JSType.toInteger(request.getArguments()[2]); 32.34 return intIndex >= 0 && intIndex < cs.length(); //can link 32.35 } catch (final ClassCastException | IndexOutOfBoundsException e) { 32.36 //fallthru
33.1 --- a/src/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java Wed Nov 12 13:47:23 2014 -0800 33.2 +++ b/src/jdk/nashorn/internal/objects/annotations/SpecializedFunction.java Fri Nov 14 10:03:48 2014 -0800 33.3 @@ -30,7 +30,6 @@ 33.4 import java.lang.annotation.RetentionPolicy; 33.5 import java.lang.annotation.Target; 33.6 import java.lang.invoke.MethodHandle; 33.7 -import java.lang.invoke.SwitchPoint; 33.8 import jdk.internal.dynalink.CallSiteDescriptor; 33.9 import jdk.internal.dynalink.linker.LinkRequest; 33.10 import jdk.nashorn.internal.runtime.ScriptFunction; 33.11 @@ -62,10 +61,6 @@ 33.12 */ 33.13 public static final LinkLogic EMPTY_INSTANCE = new Empty(); 33.14 33.15 - private static final SwitchPoint[] INVALIDATED_SWITCHPOINTS = new SwitchPoint[0]; 33.16 - 33.17 - private SwitchPoint[] modificationSwitchPoints; //cache 33.18 - 33.19 /** Empty link logic class - allow all linking, no guards */ 33.20 private static final class Empty extends LinkLogic { 33.21 @Override 33.22 @@ -167,92 +162,6 @@ 33.23 } 33.24 33.25 /** 33.26 - * Return the modification SwitchPoint of a particular index from this OptimisticBuiltins 33.27 - * If none exists, one is created and that one is return. 33.28 - * 33.29 - * The implementor must map indexes to specific SwitchPoints for specific events and keep 33.30 - * track of what they mean, for example NativeArray.LENGTH_NOT_WRITABLE_SWITCHPOINT 33.31 - * might be a useful index mapping 33.32 - * 33.33 - * @param index index for SwitchPoint to get or create 33.34 - * @return modification SwitchPoint of particular index for the receiver 33.35 - */ 33.36 - public SwitchPoint getOrCreateModificationSwitchPoint(final int index) { 33.37 - return null; 33.38 - } 33.39 - 33.40 - /** 33.41 - * Return the modification SwitchPoint from this OptimisticBuiltins. If none 33.42 - * exists, one is created and that one is return. 33.43 - * 33.44 - * @return modification SwitchPoint for the receiver 33.45 - */ 33.46 - public SwitchPoint[] getOrCreateModificationSwitchPoints() { 33.47 - return null; 33.48 - } 33.49 - 33.50 - /** 33.51 - * Hook to invalidate a modification SwitchPoint by index. 33.52 - * 33.53 - * @param index index for SwitchPoint to invalidate 33.54 - */ 33.55 - public void invalidateModificationSwitchPoint(final int index) { 33.56 - //empty 33.57 - } 33.58 - 33.59 - /** 33.60 - * Hook to invalidate all modification SwitchPoints for a receiver 33.61 - */ 33.62 - public void invalidateModificationSwitchPoints() { 33.63 - //empty 33.64 - } 33.65 - 33.66 - /** 33.67 - * Check whether the receiver has an invalidated modification SwitchPoint. 33.68 - * 33.69 - * @param index index for the modification SwitchPoint 33.70 - * @return true if the particular SwitchPoint at the index is invalidated 33.71 - */ 33.72 - public boolean hasInvalidatedModificationSwitchPoint(final int index) { 33.73 - return false; 33.74 - } 33.75 - 33.76 - /** 33.77 - * Check whether at least one of the modification SwitchPoints has been 33.78 - * invalidated 33.79 - * @return true if one of the SwitchPoints has been invalidated 33.80 - */ 33.81 - public boolean hasInvalidatedModificationSwitchPoints() { 33.82 - return false; 33.83 - } 33.84 - 33.85 - /** 33.86 - * Check whether this OptimisticBuiltins has a SwitchPoints of particular 33.87 - * index. 33.88 - * 33.89 - * As creation overhead for a SwitchPoint is non-zero, we have to create them lazily instead of, 33.90 - * e.g. in the constructor of every subclass. 33.91 - * 33.92 - * @param index index for the modification SwitchPoint 33.93 - * @return true if a modification SwitchPoint exists, no matter if it has been invalidated or not 33.94 - */ 33.95 - public boolean hasModificationSwitchPoint(final int index) { 33.96 - return false; 33.97 - } 33.98 - 33.99 - /** 33.100 - * Check whether this OptimisticBuiltins has SwitchPoints. 33.101 - * 33.102 - * As creation overhead for a SwitchPoint is non-zero, we have to create them lazily instead of, 33.103 - * e.g. in the constructor of every subclass. 33.104 - * 33.105 - * @return true if a modification SwitchPoint exists, no matter if it has been invalidated or not 33.106 - */ 33.107 - public boolean hasModificationSwitchPoints() { 33.108 - return false; 33.109 - } 33.110 - 33.111 - /** 33.112 * Check, given a link request and a receiver, if this specialization 33.113 * fits This is used by the linker in {@link ScriptFunction} to figure 33.114 * out if an optimistic builtin can be linked when first discovered 33.115 @@ -265,47 +174,9 @@ 33.116 * pick a non specialized target 33.117 */ 33.118 public boolean checkLinkable(final Object self, final CallSiteDescriptor desc, final LinkRequest request) { 33.119 - // no matter what the modification switchpoints are, if any of them are invalidated, 33.120 - // we can't link. Side effect is that if it's the first time we see this callsite, 33.121 - // we have to create the SwitchPoint(s) so future modification switchpoint invalidations 33.122 - // relink it 33.123 - final SwitchPoint[] sps = getOrCreateModificationSwitchPoints(self); 33.124 - if (sps == INVALIDATED_SWITCHPOINTS) { 33.125 - // nope, can't do the fast link as this assumption 33.126 - // has been invalidated already, e.g. length of an 33.127 - // array set to not writable 33.128 - return false; 33.129 - } 33.130 - modificationSwitchPoints = sps; //cache 33.131 - 33.132 // check the link guard, if it says we can link, go ahead 33.133 return canLink(self, desc, request); 33.134 } 33.135 - 33.136 - private SwitchPoint[] getOrCreateModificationSwitchPoints(final Object self) { 33.137 - final SwitchPoint[] sps = getOrCreateModificationSwitchPoints(); //ask for all my switchpoints 33.138 - if (sps != null) { //switchpoint exists, but some may be invalidated 33.139 - for (final SwitchPoint sp : sps) { 33.140 - if (sp.hasBeenInvalidated()) { 33.141 - return INVALIDATED_SWITCHPOINTS; 33.142 - } 33.143 - } 33.144 - } 33.145 - return sps; 33.146 - } 33.147 - 33.148 - /** 33.149 - * Get the cached modification switchpoints. Only possible to do after a link 33.150 - * check call has been performed, one that has answered "true", or you will get the 33.151 - * wrong information. 33.152 - * 33.153 - * Should be used only from {@link ScriptFunction#findCallMethod} 33.154 - * 33.155 - * @return cached modification switchpoints for this callsite, null if none 33.156 - */ 33.157 - public SwitchPoint[] getModificationSwitchPoints() { 33.158 - return modificationSwitchPoints == null ? null : modificationSwitchPoints.clone(); 33.159 - } 33.160 } 33.161 33.162 /**
34.1 --- a/src/jdk/nashorn/internal/runtime/CodeStore.java Wed Nov 12 13:47:23 2014 -0800 34.2 +++ b/src/jdk/nashorn/internal/runtime/CodeStore.java Fri Nov 14 10:03:48 2014 -0800 34.3 @@ -41,6 +41,7 @@ 34.4 import java.util.Iterator; 34.5 import java.util.Map; 34.6 import java.util.ServiceLoader; 34.7 +import jdk.nashorn.internal.codegen.OptimisticTypesPersistence; 34.8 import jdk.nashorn.internal.codegen.types.Type; 34.9 import jdk.nashorn.internal.runtime.logging.DebugLogger; 34.10 import jdk.nashorn.internal.runtime.logging.Loggable; 34.11 @@ -102,7 +103,7 @@ 34.12 } catch (final AccessControlException e) { 34.13 context.getLogger(CodeStore.class).warning("failed to load code store provider ", e); 34.14 } 34.15 - final CodeStore store = new DirectoryCodeStore(); 34.16 + final CodeStore store = new DirectoryCodeStore(context); 34.17 store.initLogger(context); 34.18 return store; 34.19 } 34.20 @@ -210,32 +211,34 @@ 34.21 /** 34.22 * Constructor 34.23 * 34.24 + * @param context the current context 34.25 * @throws IOException if there are read/write problems with the cache and cache directory 34.26 */ 34.27 - public DirectoryCodeStore() throws IOException { 34.28 - this(Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache"), false, DEFAULT_MIN_SIZE); 34.29 + public DirectoryCodeStore(final Context context) throws IOException { 34.30 + this(context, Options.getStringProperty("nashorn.persistent.code.cache", "nashorn_code_cache"), false, DEFAULT_MIN_SIZE); 34.31 } 34.32 34.33 /** 34.34 * Constructor 34.35 * 34.36 + * @param context the current context 34.37 * @param path directory to store code in 34.38 * @param readOnly is this a read only code store 34.39 * @param minSize minimum file size for caching scripts 34.40 * @throws IOException if there are read/write problems with the cache and cache directory 34.41 */ 34.42 - public DirectoryCodeStore(final String path, final boolean readOnly, final int minSize) throws IOException { 34.43 - this.dir = checkDirectory(path, readOnly); 34.44 + public DirectoryCodeStore(final Context context, final String path, final boolean readOnly, final int minSize) throws IOException { 34.45 + this.dir = checkDirectory(path, context.getEnv(), readOnly); 34.46 this.readOnly = readOnly; 34.47 this.minSize = minSize; 34.48 } 34.49 34.50 - private static File checkDirectory(final String path, final boolean readOnly) throws IOException { 34.51 + private static File checkDirectory(final String path, final ScriptEnvironment env, final boolean readOnly) throws IOException { 34.52 try { 34.53 return AccessController.doPrivileged(new PrivilegedExceptionAction<File>() { 34.54 @Override 34.55 public File run() throws IOException { 34.56 - final File dir = new File(path).getAbsoluteFile(); 34.57 + final File dir = new File(path, getVersionDir(env)).getAbsoluteFile(); 34.58 if (readOnly) { 34.59 if (!dir.exists() || !dir.isDirectory()) { 34.60 throw new IOException("Not a directory: " + dir.getPath()); 34.61 @@ -257,6 +260,15 @@ 34.62 } 34.63 } 34.64 34.65 + private static String getVersionDir(final ScriptEnvironment env) throws IOException { 34.66 + try { 34.67 + final String versionDir = OptimisticTypesPersistence.getVersionDirName(); 34.68 + return env._optimistic_types ? versionDir + "_opt" : versionDir; 34.69 + } catch (final Exception e) { 34.70 + throw new IOException(e); 34.71 + } 34.72 + } 34.73 + 34.74 @Override 34.75 public StoredScript load(final Source source, final String functionKey) { 34.76 if (source.getLength() < minSize) {
35.1 --- a/src/jdk/nashorn/internal/runtime/CompiledFunction.java Wed Nov 12 13:47:23 2014 -0800 35.2 +++ b/src/jdk/nashorn/internal/runtime/CompiledFunction.java Fri Nov 14 10:03:48 2014 -0800 35.3 @@ -27,16 +27,17 @@ 35.4 import static jdk.nashorn.internal.lookup.Lookup.MH; 35.5 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT; 35.6 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.isValid; 35.7 - 35.8 import java.lang.invoke.CallSite; 35.9 import java.lang.invoke.MethodHandle; 35.10 import java.lang.invoke.MethodHandles; 35.11 import java.lang.invoke.MethodType; 35.12 import java.lang.invoke.MutableCallSite; 35.13 import java.lang.invoke.SwitchPoint; 35.14 +import java.util.ArrayList; 35.15 import java.util.Collection; 35.16 import java.util.Collections; 35.17 import java.util.Iterator; 35.18 +import java.util.List; 35.19 import java.util.Map; 35.20 import java.util.TreeMap; 35.21 import java.util.function.Supplier; 35.22 @@ -727,34 +728,58 @@ 35.23 * @param ipp 35.24 * @return string describing the ipp map 35.25 */ 35.26 - private static String toStringInvalidations(final Map<Integer, Type> ipp) { 35.27 + private static List<String> toStringInvalidations(final Map<Integer, Type> ipp) { 35.28 if (ipp == null) { 35.29 - return ""; 35.30 + return Collections.emptyList(); 35.31 } 35.32 35.33 - final StringBuilder sb = new StringBuilder(); 35.34 + final List<String> list = new ArrayList<>(); 35.35 35.36 for (final Iterator<Map.Entry<Integer, Type>> iter = ipp.entrySet().iterator(); iter.hasNext(); ) { 35.37 final Map.Entry<Integer, Type> entry = iter.next(); 35.38 final char bct = entry.getValue().getBytecodeStackType(); 35.39 + final String type; 35.40 35.41 + switch (entry.getValue().getBytecodeStackType()) { 35.42 + case 'A': 35.43 + type = "object"; 35.44 + break; 35.45 + case 'I': 35.46 + type = "int"; 35.47 + break; 35.48 + case 'J': 35.49 + type = "long"; 35.50 + break; 35.51 + case 'D': 35.52 + type = "double"; 35.53 + break; 35.54 + default: 35.55 + type = String.valueOf(bct); 35.56 + break; 35.57 + } 35.58 + 35.59 + final StringBuilder sb = new StringBuilder(); 35.60 sb.append('['). 35.61 + append("program point: "). 35.62 append(entry.getKey()). 35.63 - append("->"). 35.64 - append(bct == 'A' ? 'O' : bct). 35.65 + append(" -> "). 35.66 + append(type). 35.67 append(']'); 35.68 35.69 - if (iter.hasNext()) { 35.70 - sb.append(' '); 35.71 - } 35.72 + list.add(sb.toString()); 35.73 } 35.74 35.75 - return sb.toString(); 35.76 + return list; 35.77 } 35.78 35.79 private void logRecompile(final String reason, final FunctionNode fn, final MethodType type, final Map<Integer, Type> ipp) { 35.80 if (log.isEnabled()) { 35.81 - log.info(reason, DebugLogger.quote(fn.getName()), " signature: ", type, " ", toStringInvalidations(ipp)); 35.82 + log.info(reason, DebugLogger.quote(fn.getName()), " signature: ", type); 35.83 + log.indent(); 35.84 + for (final String str : toStringInvalidations(ipp)) { 35.85 + log.fine(str); 35.86 + } 35.87 + log.unindent(); 35.88 } 35.89 } 35.90 35.91 @@ -770,14 +795,21 @@ 35.92 */ 35.93 private synchronized MethodHandle handleRewriteException(final OptimismInfo oldOptInfo, final RewriteException re) { 35.94 if (log.isEnabled()) { 35.95 - log.info(new RecompilationEvent(Level.INFO, re, re.getReturnValueNonDestructive()), "RewriteException ", re.getMessageShort()); 35.96 + log.info( 35.97 + new RecompilationEvent( 35.98 + Level.INFO, 35.99 + re, 35.100 + re.getReturnValueNonDestructive()), 35.101 + "caught RewriteException ", 35.102 + re.getMessageShort()); 35.103 + log.indent(); 35.104 } 35.105 35.106 final MethodType type = type(); 35.107 35.108 // Compiler needs a call site type as its input, which always has a callee parameter, so we must add it if 35.109 // this function doesn't have a callee parameter. 35.110 - final MethodType callSiteType = type.parameterType(0) == ScriptFunction.class ? 35.111 + final MethodType ct = type.parameterType(0) == ScriptFunction.class ? 35.112 type : 35.113 type.insertParameterTypes(0, ScriptFunction.class); 35.114 final OptimismInfo currentOptInfo = optimismInfo; 35.115 @@ -788,44 +820,44 @@ 35.116 final OptimismInfo effectiveOptInfo = currentOptInfo != null ? currentOptInfo : oldOptInfo; 35.117 FunctionNode fn = effectiveOptInfo.reparse(); 35.118 final boolean serialized = effectiveOptInfo.isSerialized(); 35.119 - final Compiler compiler = effectiveOptInfo.getCompiler(fn, callSiteType, re); //set to non rest-of 35.120 + final Compiler compiler = effectiveOptInfo.getCompiler(fn, ct, re); //set to non rest-of 35.121 35.122 if (!shouldRecompile) { 35.123 // It didn't necessarily recompile, e.g. for an outer invocation of a recursive function if we already 35.124 // recompiled a deoptimized version for an inner invocation. 35.125 // We still need to do the rest of from the beginning 35.126 - logRecompile("Rest-of compilation [STANDALONE] ", fn, callSiteType, effectiveOptInfo.invalidatedProgramPoints); 35.127 + logRecompile("Rest-of compilation [STANDALONE] ", fn, ct, effectiveOptInfo.invalidatedProgramPoints); 35.128 return restOfHandle(effectiveOptInfo, compiler.compile(fn, serialized ? CompilationPhases.COMPILE_SERIALIZED_RESTOF : CompilationPhases.COMPILE_ALL_RESTOF), currentOptInfo != null); 35.129 } 35.130 35.131 - logRecompile("Deoptimizing recompilation (up to bytecode) ", fn, callSiteType, effectiveOptInfo.invalidatedProgramPoints); 35.132 + logRecompile("Deoptimizing recompilation (up to bytecode) ", fn, ct, effectiveOptInfo.invalidatedProgramPoints); 35.133 fn = compiler.compile(fn, serialized ? CompilationPhases.RECOMPILE_SERIALIZED_UPTO_BYTECODE : CompilationPhases.COMPILE_UPTO_BYTECODE); 35.134 - log.info("Reusable IR generated"); 35.135 + log.fine("Reusable IR generated"); 35.136 35.137 // compile the rest of the function, and install it 35.138 log.info("Generating and installing bytecode from reusable IR..."); 35.139 - logRecompile("Rest-of compilation [CODE PIPELINE REUSE] ", fn, callSiteType, effectiveOptInfo.invalidatedProgramPoints); 35.140 + logRecompile("Rest-of compilation [CODE PIPELINE REUSE] ", fn, ct, effectiveOptInfo.invalidatedProgramPoints); 35.141 final FunctionNode normalFn = compiler.compile(fn, CompilationPhases.GENERATE_BYTECODE_AND_INSTALL); 35.142 35.143 if (effectiveOptInfo.data.usePersistentCodeCache()) { 35.144 final RecompilableScriptFunctionData data = effectiveOptInfo.data; 35.145 final int functionNodeId = data.getFunctionNodeId(); 35.146 - final TypeMap typeMap = data.typeMap(callSiteType); 35.147 + final TypeMap typeMap = data.typeMap(ct); 35.148 final Type[] paramTypes = typeMap == null ? null : typeMap.getParameterTypes(functionNodeId); 35.149 final String cacheKey = CodeStore.getCacheKey(functionNodeId, paramTypes); 35.150 compiler.persistClassInfo(cacheKey, normalFn); 35.151 } 35.152 35.153 - log.info("Done."); 35.154 - 35.155 final boolean canBeDeoptimized = normalFn.canBeDeoptimized(); 35.156 35.157 if (log.isEnabled()) { 35.158 - log.info("Recompiled '", fn.getName(), "' (", Debug.id(this), ") ", canBeDeoptimized ? " can still be deoptimized." : " is completely deoptimized."); 35.159 + log.unindent(); 35.160 + log.info("Done."); 35.161 + 35.162 + log.info("Recompiled '", fn.getName(), "' (", Debug.id(this), ") ", canBeDeoptimized ? "can still be deoptimized." : " is completely deoptimized."); 35.163 + log.finest("Looking up invoker..."); 35.164 } 35.165 35.166 - log.info("Looking up invoker..."); 35.167 - 35.168 final MethodHandle newInvoker = effectiveOptInfo.data.lookup(fn); 35.169 invoker = newInvoker.asType(type.changeReturnType(newInvoker.type().returnType())); 35.170 constructor = null; // Will be regenerated when needed
36.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Wed Nov 12 13:47:23 2014 -0800 36.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Fri Nov 14 10:03:48 2014 -0800 36.3 @@ -33,6 +33,7 @@ 36.4 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 36.5 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 36.6 import static jdk.nashorn.internal.runtime.Source.sourceFor; 36.7 + 36.8 import java.io.File; 36.9 import java.io.IOException; 36.10 import java.io.PrintWriter; 36.11 @@ -60,6 +61,7 @@ 36.12 import java.util.LinkedHashMap; 36.13 import java.util.Map; 36.14 import java.util.concurrent.atomic.AtomicLong; 36.15 +import java.util.concurrent.atomic.AtomicReference; 36.16 import java.util.function.Consumer; 36.17 import java.util.function.Supplier; 36.18 import java.util.logging.Level; 36.19 @@ -262,6 +264,10 @@ 36.20 // persistent code store 36.21 private CodeStore codeStore; 36.22 36.23 + // A factory for linking global properties as constant method handles. It is created when the first Global 36.24 + // is created, and invalidated forever once the second global is created. 36.25 + private final AtomicReference<GlobalConstants> globalConstantsRef = new AtomicReference<>(); 36.26 + 36.27 /** 36.28 * Get the current global scope 36.29 * @return the current global scope 36.30 @@ -293,7 +299,10 @@ 36.31 assert getGlobal() != global; 36.32 //same code can be cached between globals, then we need to invalidate method handle constants 36.33 if (global != null) { 36.34 - Global.getConstants().invalidateAll(); 36.35 + final GlobalConstants globalConstants = getContext(global).getGlobalConstants(); 36.36 + if (globalConstants != null) { 36.37 + globalConstants.invalidateAll(); 36.38 + } 36.39 } 36.40 currentGlobal.set(global); 36.41 } 36.42 @@ -529,6 +538,15 @@ 36.43 } 36.44 36.45 /** 36.46 + * Returns the factory for constant method handles for global properties. The returned factory can be 36.47 + * invalidated if this Context has more than one Global. 36.48 + * @return the factory for constant method handles for global properties. 36.49 + */ 36.50 + GlobalConstants getGlobalConstants() { 36.51 + return globalConstantsRef.get(); 36.52 + } 36.53 + 36.54 + /** 36.55 * Get the error manager for this context 36.56 * @return error manger 36.57 */ 36.58 @@ -1016,9 +1034,32 @@ 36.59 * @return the global script object 36.60 */ 36.61 public Global newGlobal() { 36.62 + createOrInvalidateGlobalConstants(); 36.63 return new Global(this); 36.64 } 36.65 36.66 + private void createOrInvalidateGlobalConstants() { 36.67 + for (;;) { 36.68 + final GlobalConstants currentGlobalConstants = getGlobalConstants(); 36.69 + if (currentGlobalConstants != null) { 36.70 + // Subsequent invocation; we're creating our second or later Global. GlobalConstants is not safe to use 36.71 + // with more than one Global, as the constant method handle linkages it creates create a coupling 36.72 + // between the Global and the call sites in the compiled code. 36.73 + currentGlobalConstants.invalidateForever(); 36.74 + return; 36.75 + } 36.76 + final GlobalConstants newGlobalConstants = new GlobalConstants(getLogger(GlobalConstants.class)); 36.77 + if (globalConstantsRef.compareAndSet(null, newGlobalConstants)) { 36.78 + // First invocation; we're creating the first Global in this Context. Create the GlobalConstants object 36.79 + // for this Context. 36.80 + return; 36.81 + } 36.82 + 36.83 + // If we reach here, then we started out as the first invocation, but another concurrent invocation won the 36.84 + // CAS race. We'll just let the loop repeat and invalidate the CAS race winner. 36.85 + } 36.86 + } 36.87 + 36.88 /** 36.89 * Initialize given global scope object. 36.90 * 36.91 @@ -1057,12 +1098,19 @@ 36.92 * @return current global's context 36.93 */ 36.94 static Context getContextTrusted() { 36.95 - return ((ScriptObject)Context.getGlobal()).getContext(); 36.96 + return getContext(getGlobal()); 36.97 } 36.98 36.99 static Context getContextTrustedOrNull() { 36.100 final Global global = Context.getGlobal(); 36.101 - return global == null ? null : ((ScriptObject)global).getContext(); 36.102 + return global == null ? null : getContext(global); 36.103 + } 36.104 + 36.105 + private static Context getContext(final Global global) { 36.106 + // We can't invoke Global.getContext() directly, as it's a protected override, and Global isn't in our package. 36.107 + // In order to access the method, we must cast it to ScriptObject first (which is in our package) and then let 36.108 + // virtual invocation do its thing. 36.109 + return ((ScriptObject)global).getContext(); 36.110 } 36.111 36.112 /** 36.113 @@ -1150,9 +1198,8 @@ 36.114 36.115 StoredScript storedScript = null; 36.116 FunctionNode functionNode = null; 36.117 - // We only use the code store here if optimistic types are disabled. With optimistic types, 36.118 - // code is stored per function in RecompilableScriptFunctionData. 36.119 - // TODO: This should really be triggered by lazy compilation, not optimistic types. 36.120 + // We only use the code store here if optimistic types are disabled. With optimistic types, initial compilation 36.121 + // just creates a thin wrapper, and actual code is stored per function in RecompilableScriptFunctionData. 36.122 final boolean useCodeStore = env._persistent_cache && !env._parse_only && !env._optimistic_types; 36.123 final String cacheKey = useCodeStore ? CodeStore.getCacheKey(0, null) : null; 36.124
37.1 --- a/src/jdk/nashorn/internal/runtime/GlobalConstants.java Wed Nov 12 13:47:23 2014 -0800 37.2 +++ b/src/jdk/nashorn/internal/runtime/GlobalConstants.java Fri Nov 14 10:03:48 2014 -0800 37.3 @@ -31,12 +31,14 @@ 37.4 import static jdk.nashorn.internal.runtime.UnwarrantedOptimismException.INVALID_PROGRAM_POINT; 37.5 import static jdk.nashorn.internal.runtime.linker.NashornCallSiteDescriptor.getProgramPoint; 37.6 import static jdk.nashorn.internal.runtime.logging.DebugLogger.quote; 37.7 + 37.8 import java.lang.invoke.MethodHandle; 37.9 import java.lang.invoke.MethodHandles; 37.10 import java.lang.invoke.SwitchPoint; 37.11 import java.util.Arrays; 37.12 import java.util.HashMap; 37.13 import java.util.Map; 37.14 +import java.util.concurrent.atomic.AtomicBoolean; 37.15 import java.util.logging.Level; 37.16 import jdk.internal.dynalink.CallSiteDescriptor; 37.17 import jdk.internal.dynalink.DynamicLinker; 37.18 @@ -50,7 +52,7 @@ 37.19 import jdk.nashorn.internal.runtime.logging.Logger; 37.20 37.21 /** 37.22 - * Each global owns one of these. This is basically table of accessors 37.23 + * Each context owns one of these. This is basically table of accessors 37.24 * for global properties. A global constant is evaluated to a MethodHandle.constant 37.25 * for faster access and to avoid walking to proto chain looking for it. 37.26 * 37.27 @@ -67,12 +69,19 @@ 37.28 * reregister the switchpoint. Set twice or more - don't try again forever, or we'd 37.29 * just end up relinking our way into megamorphisism. 37.30 * 37.31 + * Also it has to be noted that this kind of linking creates a coupling between a Global 37.32 + * and the call sites in compiled code belonging to the Context. For this reason, the 37.33 + * linkage becomes incorrect as soon as the Context has more than one Global. The 37.34 + * {@link #invalidateForever()} is invoked by the Context to invalidate all linkages and 37.35 + * turn off the functionality of this object as soon as the Context's {@link Context#newGlobal()} is invoked 37.36 + * for second time. 37.37 + * 37.38 * We can extend this to ScriptObjects in general (GLOBAL_ONLY=false), which requires 37.39 * a receiver guard on the constant getter, but it currently leaks memory and its benefits 37.40 * have not yet been investigated property. 37.41 * 37.42 - * As long as all Globals share the same constant instance, we need synchronization 37.43 - * whenever we access the instance. 37.44 + * As long as all Globals in a Context share the same GlobalConstants instance, we need synchronization 37.45 + * whenever we access it. 37.46 */ 37.47 @Logger(name="const") 37.48 public final class GlobalConstants implements Loggable { 37.49 @@ -82,7 +91,7 @@ 37.50 * Script objects require a receiver guard, which is memory intensive, so this is currently 37.51 * disabled. We might implement a weak reference based approach to this later. 37.52 */ 37.53 - private static final boolean GLOBAL_ONLY = true; 37.54 + public static final boolean GLOBAL_ONLY = true; 37.55 37.56 private static final MethodHandles.Lookup LOOKUP = MethodHandles.lookup(); 37.57 37.58 @@ -98,6 +107,8 @@ 37.59 */ 37.60 private final Map<String, Access> map = new HashMap<>(); 37.61 37.62 + private final AtomicBoolean invalidatedForever = new AtomicBoolean(false); 37.63 + 37.64 /** 37.65 * Constructor - used only by global 37.66 * @param log logger, or null if none 37.67 @@ -216,10 +227,34 @@ 37.68 * the same class for a new global, but the builtins and global scoped variables 37.69 * will have changed. 37.70 */ 37.71 - public synchronized void invalidateAll() { 37.72 - log.info("New global created - invalidating all constant callsites without increasing invocation count."); 37.73 - for (final Access acc : map.values()) { 37.74 - acc.invalidateUncounted(); 37.75 + public void invalidateAll() { 37.76 + if (!invalidatedForever.get()) { 37.77 + log.info("New global created - invalidating all constant callsites without increasing invocation count."); 37.78 + synchronized (this) { 37.79 + for (final Access acc : map.values()) { 37.80 + acc.invalidateUncounted(); 37.81 + } 37.82 + } 37.83 + } 37.84 + } 37.85 + 37.86 + /** 37.87 + * To avoid an expensive global guard "is this the same global", similar to the 37.88 + * receiver guard on the ScriptObject level, we invalidate all getters when the 37.89 + * second Global is created by the Context owning this instance. After this 37.90 + * method is invoked, this GlobalConstants instance will both invalidate all the 37.91 + * switch points it produced, and it will stop handing out new method handles 37.92 + * altogether. 37.93 + */ 37.94 + public void invalidateForever() { 37.95 + if (invalidatedForever.compareAndSet(false, true)) { 37.96 + log.info("New global created - invalidating all constant callsites."); 37.97 + synchronized (this) { 37.98 + for (final Access acc : map.values()) { 37.99 + acc.invalidateForever(); 37.100 + } 37.101 + map.clear(); 37.102 + } 37.103 } 37.104 } 37.105 37.106 @@ -251,7 +286,7 @@ 37.107 return obj; 37.108 } 37.109 37.110 - private synchronized Access getOrCreateSwitchPoint(final String name) { 37.111 + private Access getOrCreateSwitchPoint(final String name) { 37.112 Access acc = map.get(name); 37.113 if (acc != null) { 37.114 return acc; 37.115 @@ -267,9 +302,13 @@ 37.116 * @param name name of property 37.117 */ 37.118 void delete(final String name) { 37.119 - final Access acc = map.get(name); 37.120 - if (acc != null) { 37.121 - acc.invalidateForever(); 37.122 + if (!invalidatedForever.get()) { 37.123 + synchronized (this) { 37.124 + final Access acc = map.get(name); 37.125 + if (acc != null) { 37.126 + acc.invalidateForever(); 37.127 + } 37.128 + } 37.129 } 37.130 } 37.131 37.132 @@ -313,45 +352,45 @@ 37.133 * 37.134 * @return null if failed to set up constant linkage 37.135 */ 37.136 - synchronized GuardedInvocation findSetMethod(final FindProperty find, final ScriptObject receiver, final GuardedInvocation inv, final CallSiteDescriptor desc, final LinkRequest request) { 37.137 - if (GLOBAL_ONLY && !isGlobalSetter(receiver, find)) { 37.138 + GuardedInvocation findSetMethod(final FindProperty find, final ScriptObject receiver, final GuardedInvocation inv, final CallSiteDescriptor desc, final LinkRequest request) { 37.139 + if (invalidatedForever.get() || (GLOBAL_ONLY && !isGlobalSetter(receiver, find))) { 37.140 return null; 37.141 } 37.142 37.143 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); 37.144 37.145 - final Access acc = getOrCreateSwitchPoint(name); 37.146 + synchronized (this) { 37.147 + final Access acc = getOrCreateSwitchPoint(name); 37.148 37.149 - if (log.isEnabled()) { 37.150 - log.fine("Trying to link constant SETTER ", acc); 37.151 + if (log.isEnabled()) { 37.152 + log.fine("Trying to link constant SETTER ", acc); 37.153 + } 37.154 + 37.155 + if (!acc.mayRetry() || invalidatedForever.get()) { 37.156 + if (log.isEnabled()) { 37.157 + log.fine("*** SET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation()); 37.158 + } 37.159 + return null; 37.160 + } 37.161 + 37.162 + if (acc.hasBeenInvalidated()) { 37.163 + log.info("New chance for " + acc); 37.164 + acc.newSwitchPoint(); 37.165 + } 37.166 + 37.167 + assert !acc.hasBeenInvalidated(); 37.168 + 37.169 + // if we haven't given up on this symbol, add a switchpoint invalidation filter to the receiver parameter 37.170 + final MethodHandle target = inv.getInvocation(); 37.171 + final Class<?> receiverType = target.type().parameterType(0); 37.172 + final MethodHandle boundInvalidator = MH.bindTo(INVALIDATE_SP, this); 37.173 + final MethodHandle invalidator = MH.asType(boundInvalidator, boundInvalidator.type().changeParameterType(0, receiverType).changeReturnType(receiverType)); 37.174 + final MethodHandle mh = MH.filterArguments(inv.getInvocation(), 0, MH.insertArguments(invalidator, 1, acc)); 37.175 + 37.176 + assert inv.getSwitchPoints() == null : Arrays.asList(inv.getSwitchPoints()); 37.177 + log.info("Linked setter " + quote(name) + " " + acc.getSwitchPoint()); 37.178 + return new GuardedInvocation(mh, inv.getGuard(), acc.getSwitchPoint(), inv.getException()); 37.179 } 37.180 - 37.181 - if (!acc.mayRetry()) { 37.182 - if (log.isEnabled()) { 37.183 - log.fine("*** SET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation()); 37.184 - } 37.185 - return null; 37.186 - } 37.187 - 37.188 - assert acc.mayRetry(); 37.189 - 37.190 - if (acc.hasBeenInvalidated()) { 37.191 - log.info("New chance for " + acc); 37.192 - acc.newSwitchPoint(); 37.193 - } 37.194 - 37.195 - assert !acc.hasBeenInvalidated(); 37.196 - 37.197 - // if we haven't given up on this symbol, add a switchpoint invalidation filter to the receiver parameter 37.198 - final MethodHandle target = inv.getInvocation(); 37.199 - final Class<?> receiverType = target.type().parameterType(0); 37.200 - final MethodHandle boundInvalidator = MH.bindTo(INVALIDATE_SP, this); 37.201 - final MethodHandle invalidator = MH.asType(boundInvalidator, boundInvalidator.type().changeParameterType(0, receiverType).changeReturnType(receiverType)); 37.202 - final MethodHandle mh = MH.filterArguments(inv.getInvocation(), 0, MH.insertArguments(invalidator, 1, acc)); 37.203 - 37.204 - assert inv.getSwitchPoints() == null : Arrays.asList(inv.getSwitchPoints()); 37.205 - log.info("Linked setter " + quote(name) + " " + acc.getSwitchPoint()); 37.206 - return new GuardedInvocation(mh, inv.getGuard(), acc.getSwitchPoint(), inv.getException()); 37.207 } 37.208 37.209 /** 37.210 @@ -380,11 +419,11 @@ 37.211 * 37.212 * @return resulting getter, or null if failed to create constant 37.213 */ 37.214 - synchronized GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) { 37.215 + GuardedInvocation findGetMethod(final FindProperty find, final ScriptObject receiver, final CallSiteDescriptor desc) { 37.216 // Only use constant getter for fast scope access, because the receiver may change between invocations 37.217 // for slow-scope and non-scope callsites. 37.218 // Also return null for user accessor properties as they may have side effects. 37.219 - if (!NashornCallSiteDescriptor.isFastScope(desc) 37.220 + if (invalidatedForever.get() || !NashornCallSiteDescriptor.isFastScope(desc) 37.221 || (GLOBAL_ONLY && !find.getOwner().isGlobal()) 37.222 || find.getProperty() instanceof UserAccessorProperty) { 37.223 return null; 37.224 @@ -395,51 +434,53 @@ 37.225 final Class<?> retType = desc.getMethodType().returnType(); 37.226 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); 37.227 37.228 - final Access acc = getOrCreateSwitchPoint(name); 37.229 + synchronized (this) { 37.230 + final Access acc = getOrCreateSwitchPoint(name); 37.231 37.232 - log.fine("Starting to look up object value " + name); 37.233 - final Object c = find.getObjectValue(); 37.234 + log.fine("Starting to look up object value " + name); 37.235 + final Object c = find.getObjectValue(); 37.236 37.237 - if (log.isEnabled()) { 37.238 - log.fine("Trying to link constant GETTER " + acc + " value = " + c); 37.239 + if (log.isEnabled()) { 37.240 + log.fine("Trying to link constant GETTER " + acc + " value = " + c); 37.241 + } 37.242 + 37.243 + if (acc.hasBeenInvalidated() || acc.guardFailed() || invalidatedForever.get()) { 37.244 + if (log.isEnabled()) { 37.245 + log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation()); 37.246 + } 37.247 + return null; 37.248 + } 37.249 + 37.250 + final MethodHandle cmh = constantGetter(c); 37.251 + 37.252 + MethodHandle mh; 37.253 + MethodHandle guard; 37.254 + 37.255 + if (isOptimistic) { 37.256 + if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) { 37.257 + //widen return type - this is pessimistic, so it will always work 37.258 + mh = MH.asType(cmh, cmh.type().changeReturnType(retType)); 37.259 + } else { 37.260 + //immediately invalidate - we asked for a too wide constant as a narrower one 37.261 + mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class); 37.262 + } 37.263 + } else { 37.264 + //pessimistic return type filter 37.265 + mh = Lookup.filterReturnType(cmh, retType); 37.266 + } 37.267 + 37.268 + if (find.getOwner().isGlobal()) { 37.269 + guard = null; 37.270 + } else { 37.271 + guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver); 37.272 + } 37.273 + 37.274 + if (log.isEnabled()) { 37.275 + log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint()); 37.276 + mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc); 37.277 + } 37.278 + 37.279 + return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null); 37.280 } 37.281 - 37.282 - if (acc.hasBeenInvalidated() || acc.guardFailed()) { 37.283 - if (log.isEnabled()) { 37.284 - log.info("*** GET: Giving up on " + quote(name) + " - retry count has exceeded " + DynamicLinker.getLinkedCallSiteLocation()); 37.285 - } 37.286 - return null; 37.287 - } 37.288 - 37.289 - final MethodHandle cmh = constantGetter(c); 37.290 - 37.291 - MethodHandle mh; 37.292 - MethodHandle guard; 37.293 - 37.294 - if (isOptimistic) { 37.295 - if (JSType.getAccessorTypeIndex(cmh.type().returnType()) <= JSType.getAccessorTypeIndex(retType)) { 37.296 - //widen return type - this is pessimistic, so it will always work 37.297 - mh = MH.asType(cmh, cmh.type().changeReturnType(retType)); 37.298 - } else { 37.299 - //immediately invalidate - we asked for a too wide constant as a narrower one 37.300 - mh = MH.dropArguments(MH.insertArguments(JSType.THROW_UNWARRANTED.methodHandle(), 0, c, programPoint), 0, Object.class); 37.301 - } 37.302 - } else { 37.303 - //pessimistic return type filter 37.304 - mh = Lookup.filterReturnType(cmh, retType); 37.305 - } 37.306 - 37.307 - if (find.getOwner().isGlobal()) { 37.308 - guard = null; 37.309 - } else { 37.310 - guard = MH.insertArguments(RECEIVER_GUARD, 0, acc, receiver); 37.311 - } 37.312 - 37.313 - if (log.isEnabled()) { 37.314 - log.info("Linked getter " + quote(name) + " as MethodHandle.constant() -> " + c + " " + acc.getSwitchPoint()); 37.315 - mh = MethodHandleFactory.addDebugPrintout(log, Level.FINE, mh, "get const " + acc); 37.316 - } 37.317 - 37.318 - return new GuardedInvocation(mh, guard, acc.getSwitchPoint(), null); 37.319 } 37.320 }
38.1 --- a/src/jdk/nashorn/internal/runtime/JSType.java Wed Nov 12 13:47:23 2014 -0800 38.2 +++ b/src/jdk/nashorn/internal/runtime/JSType.java Fri Nov 14 10:03:48 2014 -0800 38.3 @@ -150,6 +150,12 @@ 38.4 /** Div exact wrapper for potentially integer division that turns into float point */ 38.5 public static final Call DIV_EXACT = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", int.class, int.class, int.class, int.class); 38.6 38.7 + /** Div zero wrapper for integer division that handles (0/0)|0 == 0 */ 38.8 + public static final Call DIV_ZERO = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", int.class, int.class, int.class); 38.9 + 38.10 + /** Mod zero wrapper for integer division that handles (0%0)|0 == 0 */ 38.11 + public static final Call REM_ZERO = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", int.class, int.class, int.class); 38.12 + 38.13 /** Mod exact wrapper for potentially integer remainders that turns into float point */ 38.14 public static final Call REM_EXACT = staticCall(JSTYPE_LOOKUP, JSType.class, "remExact", int.class, int.class, int.class, int.class); 38.15 38.16 @@ -174,6 +180,12 @@ 38.17 /** Div exact wrapper for potentially integer division that turns into float point */ 38.18 public static final Call DIV_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divExact", long.class, long.class, long.class, int.class); 38.19 38.20 + /** Div zero wrapper for long division that handles (0/0) >>> 0 == 0 */ 38.21 + public static final Call DIV_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "divZero", long.class, long.class, long.class); 38.22 + 38.23 + /** Mod zero wrapper for long division that handles (0%0) >>> 0 == 0 */ 38.24 + public static final Call REM_ZERO_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "remZero", long.class, long.class, long.class); 38.25 + 38.26 /** Mod exact wrapper for potentially integer remainders that turns into float point */ 38.27 public static final Call REM_EXACT_LONG = staticCall(JSTYPE_LOOKUP, JSType.class, "remExact", long.class, long.class, long.class, int.class); 38.28 38.29 @@ -1486,6 +1498,28 @@ 38.30 } 38.31 38.32 /** 38.33 + * Implements int division but allows {@code x / 0} to be represented as 0. Basically equivalent to 38.34 + * {@code (x / y)|0} JavaScript expression (division of two ints coerced to int). 38.35 + * @param x the dividend 38.36 + * @param y the divisor 38.37 + * @return the result 38.38 + */ 38.39 + public static int divZero(final int x, final int y) { 38.40 + return y == 0 ? 0 : x / y; 38.41 + } 38.42 + 38.43 + /** 38.44 + * Implements int remainder but allows {@code x % 0} to be represented as 0. Basically equivalent to 38.45 + * {@code (x % y)|0} JavaScript expression (remainder of two ints coerced to int). 38.46 + * @param x the dividend 38.47 + * @param y the divisor 38.48 + * @return the remainder 38.49 + */ 38.50 + public static int remZero(final int x, final int y) { 38.51 + return y == 0 ? 0 : x % y; 38.52 + } 38.53 + 38.54 + /** 38.55 * Wrapper for modExact. Throws UnwarrantedOptimismException if the modulo can't be represented as int. 38.56 * 38.57 * @param x first term 38.58 @@ -1529,6 +1563,28 @@ 38.59 } 38.60 38.61 /** 38.62 + * Implements long division but allows {@code x / 0} to be represented as 0. Useful when division of two longs 38.63 + * is coerced to long. 38.64 + * @param x the dividend 38.65 + * @param y the divisor 38.66 + * @return the result 38.67 + */ 38.68 + public static long divZero(final long x, final long y) { 38.69 + return y == 0L ? 0L : x / y; 38.70 + } 38.71 + 38.72 + /** 38.73 + * Implements long remainder but allows {@code x % 0} to be represented as 0. Useful when remainder of two longs 38.74 + * is coerced to long. 38.75 + * @param x the dividend 38.76 + * @param y the divisor 38.77 + * @return the remainder 38.78 + */ 38.79 + public static long remZero(final long x, final long y) { 38.80 + return y == 0L ? 0L : x % y; 38.81 + } 38.82 + 38.83 + /** 38.84 * Wrapper for modExact. Throws UnwarrantedOptimismException if the modulo can't be represented as int. 38.85 * 38.86 * @param x first term
39.1 --- a/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Wed Nov 12 13:47:23 2014 -0800 39.2 +++ b/src/jdk/nashorn/internal/runtime/RecompilableScriptFunctionData.java Fri Nov 14 10:03:48 2014 -0800 39.3 @@ -26,7 +26,6 @@ 39.4 package jdk.nashorn.internal.runtime; 39.5 39.6 import static jdk.nashorn.internal.lookup.Lookup.MH; 39.7 - 39.8 import java.io.IOException; 39.9 import java.lang.invoke.MethodHandle; 39.10 import java.lang.invoke.MethodHandles; 39.11 @@ -475,6 +474,7 @@ 39.12 * @return either the existing map, or a loaded map from the persistent type info cache, or a new empty map if 39.13 * neither an existing map or a persistent cached type info is available. 39.14 */ 39.15 + @SuppressWarnings("unused") 39.16 private static Map<Integer, Type> getEffectiveInvalidatedProgramPoints( 39.17 final Map<Integer, Type> invalidatedProgramPoints, final Object typeInformationFile) { 39.18 if(invalidatedProgramPoints != null) { 39.19 @@ -619,20 +619,25 @@ 39.20 return f; 39.21 } 39.22 39.23 - MethodHandle lookup(final FunctionInitializer fnInit) { 39.24 + private void logLookup(final boolean shouldLog, final MethodType targetType) { 39.25 + if (shouldLog && log.isEnabled()) { 39.26 + log.info("Looking up ", DebugLogger.quote(functionName), " type=", targetType); 39.27 + } 39.28 + } 39.29 + 39.30 + private MethodHandle lookup(final FunctionInitializer fnInit, final boolean shouldLog) { 39.31 final MethodType type = fnInit.getMethodType(); 39.32 + logLookup(shouldLog, type); 39.33 return lookupCodeMethod(fnInit.getCode(), type); 39.34 } 39.35 39.36 MethodHandle lookup(final FunctionNode fn) { 39.37 final MethodType type = new FunctionSignature(fn).getMethodType(); 39.38 + logLookup(true, type); 39.39 return lookupCodeMethod(fn.getCompileUnit().getCode(), type); 39.40 } 39.41 39.42 MethodHandle lookupCodeMethod(final Class<?> codeClass, final MethodType targetType) { 39.43 - if (log.isEnabled()) { 39.44 - log.info("Looking up ", DebugLogger.quote(functionName), " type=", targetType); 39.45 - } 39.46 return MH.findStatic(LOOKUP, codeClass, functionName, targetType); 39.47 } 39.48 39.49 @@ -648,7 +653,7 @@ 39.50 if(!code.isEmpty()) { 39.51 throw new IllegalStateException(name); 39.52 } 39.53 - addCode(lookup(initializer), null, null, initializer.getFlags()); 39.54 + addCode(lookup(initializer, true), null, null, initializer.getFlags()); 39.55 } 39.56 39.57 private CompiledFunction addCode(final MethodHandle target, final Map<Integer, Type> invalidatedProgramPoints, 39.58 @@ -670,10 +675,10 @@ 39.59 */ 39.60 private CompiledFunction addCode(final FunctionInitializer fnInit, final MethodType callSiteType) { 39.61 if (isVariableArity()) { 39.62 - return addCode(lookup(fnInit), fnInit.getInvalidatedProgramPoints(), callSiteType, fnInit.getFlags()); 39.63 + return addCode(lookup(fnInit, true), fnInit.getInvalidatedProgramPoints(), callSiteType, fnInit.getFlags()); 39.64 } 39.65 39.66 - final MethodHandle handle = lookup(fnInit); 39.67 + final MethodHandle handle = lookup(fnInit, true); 39.68 final MethodType fromType = handle.type(); 39.69 MethodType toType = needsCallee(fromType) ? callSiteType.changeParameterType(0, ScriptFunction.class) : callSiteType.dropParameterTypes(0, 1); 39.70 toType = toType.changeReturnType(fromType.returnType()); 39.71 @@ -698,7 +703,7 @@ 39.72 toType = toType.dropParameterTypes(fromCount, toCount); 39.73 } 39.74 39.75 - return addCode(lookup(fnInit).asType(toType), fnInit.getInvalidatedProgramPoints(), callSiteType, fnInit.getFlags()); 39.76 + return addCode(lookup(fnInit, false).asType(toType), fnInit.getInvalidatedProgramPoints(), callSiteType, fnInit.getFlags()); 39.77 } 39.78 39.79 /** 39.80 @@ -727,7 +732,7 @@ 39.81 39.82 assert existingBest != null; 39.83 //we are calling a vararg method with real args 39.84 - boolean applyToCall = existingBest.isVarArg() && !CompiledFunction.isVarArgsType(callSiteType); 39.85 + boolean varArgWithRealArgs = existingBest.isVarArg() && !CompiledFunction.isVarArgsType(callSiteType); 39.86 39.87 //if the best one is an apply to call, it has to match the callsite exactly 39.88 //or we need to regenerate 39.89 @@ -736,14 +741,16 @@ 39.90 if (best != null) { 39.91 return best; 39.92 } 39.93 - applyToCall = true; 39.94 + varArgWithRealArgs = true; 39.95 } 39.96 39.97 - if (applyToCall) { 39.98 + if (varArgWithRealArgs) { 39.99 + // special case: we had an apply to call, but we failed to make it fit. 39.100 + // Try to generate a specialized one for this callsite. It may 39.101 + // be another apply to call specialization, or it may not, but whatever 39.102 + // it is, it is a specialization that is guaranteed to fit 39.103 final FunctionInitializer fnInit = compileTypeSpecialization(callSiteType, runtimeScope, false); 39.104 - if ((fnInit.getFlags() & FunctionNode.HAS_APPLY_TO_CALL_SPECIALIZATION) != 0) { //did the specialization work 39.105 - existingBest = addCode(fnInit, callSiteType); 39.106 - } 39.107 + existingBest = addCode(fnInit, callSiteType); 39.108 } 39.109 39.110 return existingBest;
40.1 --- a/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java Wed Nov 12 13:47:23 2014 -0800 40.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptEnvironment.java Fri Nov 14 10:03:48 2014 -0800 40.3 @@ -212,6 +212,7 @@ 40.4 * @param out output print writer 40.5 * @param err error print writer 40.6 */ 40.7 + @SuppressWarnings("unused") 40.8 public ScriptEnvironment(final Options options, final PrintWriter out, final PrintWriter err) { 40.9 this.out = out; 40.10 this.err = err;
41.1 --- a/src/jdk/nashorn/internal/runtime/ScriptFunction.java Wed Nov 12 13:47:23 2014 -0800 41.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptFunction.java Fri Nov 14 10:03:48 2014 -0800 41.3 @@ -603,16 +603,6 @@ 41.4 log.info("Linking optimistic builtin function: '", name, "' args=", Arrays.toString(request.getArguments()), " desc=", desc); 41.5 } 41.6 41.7 - final SwitchPoint[] msps = linkLogic.getModificationSwitchPoints(); 41.8 - if (msps != null) { 41.9 - for (final SwitchPoint sp : msps) { 41.10 - if (sp != null) { 41.11 - assert !sp.hasBeenInvalidated(); 41.12 - sps.add(sp); 41.13 - } 41.14 - } 41.15 - } 41.16 - 41.17 exceptionGuard = linkLogic.getRelinkException(); 41.18 41.19 break;
42.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Wed Nov 12 13:47:23 2014 -0800 42.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Fri Nov 14 10:03:48 2014 -0800 42.3 @@ -47,6 +47,7 @@ 42.4 import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.getArrayIndex; 42.5 import static jdk.nashorn.internal.runtime.arrays.ArrayIndex.isValidArrayIndex; 42.6 import static jdk.nashorn.internal.runtime.linker.NashornGuards.explicitInstanceOfCheck; 42.7 + 42.8 import java.lang.invoke.MethodHandle; 42.9 import java.lang.invoke.MethodHandles; 42.10 import java.lang.invoke.MethodType; 42.11 @@ -509,6 +510,13 @@ 42.12 } 42.13 } 42.14 42.15 + private void invalidateGlobalConstant(final String key) { 42.16 + final GlobalConstants globalConstants = getGlobalConstants(); 42.17 + if (globalConstants != null) { 42.18 + globalConstants.delete(key); 42.19 + } 42.20 + } 42.21 + 42.22 /** 42.23 * ECMA 8.12.9 [[DefineOwnProperty]] (P, Desc, Throw) 42.24 * 42.25 @@ -524,6 +532,8 @@ 42.26 final Object current = getOwnPropertyDescriptor(key); 42.27 final String name = JSType.toString(key); 42.28 42.29 + invalidateGlobalConstant(key); 42.30 + 42.31 if (current == UNDEFINED) { 42.32 if (isExtensible()) { 42.33 // add a new own property 42.34 @@ -922,7 +932,8 @@ 42.35 if (property instanceof UserAccessorProperty) { 42.36 ((UserAccessorProperty)property).setAccessors(this, getMap(), null); 42.37 } 42.38 - Global.getConstants().delete(property.getKey()); 42.39 + 42.40 + invalidateGlobalConstant(property.getKey()); 42.41 return true; 42.42 } 42.43 } 42.44 @@ -1348,12 +1359,9 @@ 42.45 final PropertyMap selfMap = this.getMap(); 42.46 42.47 final ArrayData array = getArray(); 42.48 - final long length = array.length(); 42.49 - 42.50 - for (long i = 0; i < length; i = array.nextIndex(i)) { 42.51 - if (array.has((int)i)) { 42.52 - keys.add(JSType.toString(i)); 42.53 - } 42.54 + 42.55 + for (final Iterator<Long> iter = array.indexIterator(); iter.hasNext(); ) { 42.56 + keys.add(JSType.toString(iter.next().longValue())); 42.57 } 42.58 42.59 for (final Property property : selfMap.getProperties()) { 42.60 @@ -1512,12 +1520,12 @@ 42.61 * 42.62 * @return {@code true} if 'length' property is non-writable 42.63 */ 42.64 - public final boolean isLengthNotWritable() { 42.65 + public boolean isLengthNotWritable() { 42.66 return (flags & IS_LENGTH_NOT_WRITABLE) != 0; 42.67 } 42.68 42.69 /** 42.70 - * Flag this object as having non-writable length property 42.71 + * Flag this object as having non-writable length property. 42.72 */ 42.73 public void setIsLengthNotWritable() { 42.74 flags |= IS_LENGTH_NOT_WRITABLE; 42.75 @@ -1983,9 +1991,12 @@ 42.76 } 42.77 } 42.78 42.79 - final GuardedInvocation cinv = Global.getConstants().findGetMethod(find, this, desc); 42.80 - if (cinv != null) { 42.81 - return cinv; 42.82 + final GlobalConstants globalConstants = getGlobalConstants(); 42.83 + if (globalConstants != null) { 42.84 + final GuardedInvocation cinv = globalConstants.findGetMethod(find, this, desc); 42.85 + if (cinv != null) { 42.86 + return cinv; 42.87 + } 42.88 } 42.89 42.90 final Class<?> returnType = desc.getMethodType().returnType(); 42.91 @@ -2183,14 +2194,22 @@ 42.92 42.93 final GuardedInvocation inv = new SetMethodCreator(this, find, desc, request).createGuardedInvocation(findBuiltinSwitchPoint(name)); 42.94 42.95 - final GuardedInvocation cinv = Global.getConstants().findSetMethod(find, this, inv, desc, request); 42.96 - if (cinv != null) { 42.97 - return cinv; 42.98 + final GlobalConstants globalConstants = getGlobalConstants(); 42.99 + if (globalConstants != null) { 42.100 + final GuardedInvocation cinv = globalConstants.findSetMethod(find, this, inv, desc, request); 42.101 + if (cinv != null) { 42.102 + return cinv; 42.103 + } 42.104 } 42.105 42.106 return inv; 42.107 } 42.108 42.109 + private GlobalConstants getGlobalConstants() { 42.110 + // Avoid hitting getContext() which might be costly for a non-Global unless needed. 42.111 + return GlobalConstants.GLOBAL_ONLY && !isGlobal() ? null : getContext().getGlobalConstants(); 42.112 + } 42.113 + 42.114 private GuardedInvocation createEmptySetMethod(final CallSiteDescriptor desc, final boolean explicitInstanceOfCheck, final String strictErrorMessage, final boolean canBeFastScope) { 42.115 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); 42.116 if (NashornCallSiteDescriptor.isStrict(desc)) { 42.117 @@ -3137,6 +3156,8 @@ 42.118 public final void setObject(final FindProperty find, final int callSiteFlags, final String key, final Object value) { 42.119 FindProperty f = find; 42.120 42.121 + invalidateGlobalConstant(key); 42.122 + 42.123 if (f != null && f.isInherited() && !(f.getProperty() instanceof UserAccessorProperty)) { 42.124 final boolean isScope = NashornCallSiteDescriptor.isScopeFlag(callSiteFlags); 42.125 // If the start object of the find is not this object it means the property was found inside a 42.126 @@ -3162,7 +3183,6 @@ 42.127 if (NashornCallSiteDescriptor.isStrictFlag(callSiteFlags)) { 42.128 throw typeError("property.not.writable", key, ScriptRuntime.safeToString(this)); 42.129 } 42.130 - 42.131 return; 42.132 } 42.133 42.134 @@ -3573,7 +3593,6 @@ 42.135 } 42.136 return false; 42.137 } 42.138 - 42.139 return deleteObject(JSType.toObject(key), strict); 42.140 } 42.141
43.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Wed Nov 12 13:47:23 2014 -0800 43.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayData.java Fri Nov 14 10:03:48 2014 -0800 43.3 @@ -30,6 +30,9 @@ 43.4 import java.lang.invoke.MethodHandles; 43.5 import java.lang.reflect.Array; 43.6 import java.nio.ByteBuffer; 43.7 +import java.util.ArrayList; 43.8 +import java.util.Iterator; 43.9 +import java.util.List; 43.10 import jdk.internal.dynalink.CallSiteDescriptor; 43.11 import jdk.internal.dynalink.linker.GuardedInvocation; 43.12 import jdk.internal.dynalink.linker.LinkRequest; 43.13 @@ -56,6 +59,21 @@ 43.14 public static final ArrayData EMPTY_ARRAY = new UntouchedArrayData(); 43.15 43.16 /** 43.17 + * Length of the array data. Not necessarily length of the wrapped array. 43.18 + * This is private to ensure that no one in a subclass is able to touch the length 43.19 + * without going through {@link setLength}. This is used to implement 43.20 + * {@link LengthNotWritableFilter}s, ensuring that there are no ways past 43.21 + * a {@link setLength} function replaced by a nop 43.22 + */ 43.23 + private long length; 43.24 + 43.25 + /** 43.26 + * Method handle to throw an {@link UnwarrantedOptimismException} when getting an element 43.27 + * of the wrong type 43.28 + */ 43.29 + protected static final CompilerConstants.Call THROW_UNWARRANTED = staticCall(MethodHandles.lookup(), ArrayData.class, "throwUnwarranted", void.class, ArrayData.class, int.class, int.class); 43.30 + 43.31 + /** 43.32 * Immutable empty array to get ScriptObjects started. 43.33 * Use the same array and convert it to mutable as soon as it is modified 43.34 */ 43.35 @@ -82,7 +100,7 @@ 43.36 43.37 @Override 43.38 public ContinuousArrayData copy() { 43.39 - return new UntouchedArrayData((int)length); 43.40 + return new UntouchedArrayData((int)length()); 43.41 } 43.42 43.43 @Override 43.44 @@ -98,6 +116,10 @@ 43.45 @Override 43.46 public ArrayData ensure(final long safeIndex) { 43.47 if (safeIndex > 0L) { 43.48 + if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH) { 43.49 + return new SparseArrayData(this, safeIndex + 1); 43.50 + } 43.51 + //known to fit in int 43.52 return toRealArrayData((int)safeIndex).ensure(safeIndex); 43.53 } 43.54 return this; 43.55 @@ -109,6 +131,16 @@ 43.56 } 43.57 43.58 @Override 43.59 + public ArrayData delete(final int index) { 43.60 + return new DeletedRangeArrayFilter(this, index, index); 43.61 + } 43.62 + 43.63 + @Override 43.64 + public ArrayData delete(final long fromIndex, final long toIndex) { 43.65 + return new DeletedRangeArrayFilter(this, fromIndex, toIndex); 43.66 + } 43.67 + 43.68 + @Override 43.69 public void shiftLeft(final int by) { 43.70 //nop, always empty or we wouldn't be of this class 43.71 } 43.72 @@ -169,16 +201,6 @@ 43.73 } 43.74 43.75 @Override 43.76 - public ArrayData delete(final int index) { 43.77 - return new DeletedRangeArrayFilter(this, index, index); 43.78 - } 43.79 - 43.80 - @Override 43.81 - public ArrayData delete(final long fromIndex, final long toIndex) { 43.82 - return new DeletedRangeArrayFilter(this, fromIndex, toIndex); 43.83 - } 43.84 - 43.85 - @Override 43.86 public Object pop() { 43.87 return ScriptRuntime.UNDEFINED; 43.88 } 43.89 @@ -227,17 +249,6 @@ 43.90 }; 43.91 43.92 /** 43.93 - * Length of the array data. Not necessarily length of the wrapped array. 43.94 - */ 43.95 - protected long length; 43.96 - 43.97 - /** 43.98 - * Method handle to throw an {@link UnwarrantedOptimismException} when getting an element 43.99 - * of the wrong type 43.100 - */ 43.101 - protected static final CompilerConstants.Call THROW_UNWARRANTED = staticCall(MethodHandles.lookup(), ArrayData.class, "throwUnwarranted", void.class, ArrayData.class, int.class, int.class); 43.102 - 43.103 - /** 43.104 * Constructor 43.105 * @param length Virtual length of the array. 43.106 */ 43.107 @@ -390,6 +401,16 @@ 43.108 } 43.109 43.110 /** 43.111 + * Prevent this array from having its length reset 43.112 + * 43.113 + * @param underlying the underlying ArrayDAta to wrap in the non extensible filter 43.114 + * @return new array data, filtered 43.115 + */ 43.116 + public static final ArrayData setIsLengthNotWritable(final ArrayData underlying) { 43.117 + return new LengthNotWritableFilter(underlying); 43.118 + } 43.119 + 43.120 + /** 43.121 * Return the length of the array data. This may differ from the actual 43.122 * length of the array this wraps as length may be set or gotten as any 43.123 * other JavaScript Property 43.124 @@ -442,6 +463,22 @@ 43.125 } 43.126 43.127 /** 43.128 + * Increase length by 1 43.129 + * @return the new length, not the old one (i.e. pre-increment) 43.130 + */ 43.131 + protected final long increaseLength() { 43.132 + return ++this.length; 43.133 + } 43.134 + 43.135 + /** 43.136 + * Decrease length by 1. 43.137 + * @return the new length, not the old one (i.e. pre-decrement) 43.138 + */ 43.139 + protected final long decreaseLength() { 43.140 + return --this.length; 43.141 + } 43.142 + 43.143 + /** 43.144 * Shift the array data left 43.145 * 43.146 * TODO: explore start at an index and not at zero, to make these operations 43.147 @@ -450,7 +487,7 @@ 43.148 * 43.149 * @param by offset to shift 43.150 */ 43.151 - public abstract void shiftLeft(int by); 43.152 + public abstract void shiftLeft(final int by); 43.153 43.154 /** 43.155 * Shift the array right 43.156 @@ -459,7 +496,7 @@ 43.157 43.158 * @return New arraydata (or same) 43.159 */ 43.160 - public abstract ArrayData shiftRight(int by); 43.161 + public abstract ArrayData shiftRight(final int by); 43.162 43.163 /** 43.164 * Ensure that the given index exists and won't fail subsequent 43.165 @@ -467,7 +504,7 @@ 43.166 * @param safeIndex the index to ensure wont go out of bounds 43.167 * @return new array data (or same) 43.168 */ 43.169 - public abstract ArrayData ensure(long safeIndex); 43.170 + public abstract ArrayData ensure(final long safeIndex); 43.171 43.172 /** 43.173 * Shrink the array to a new length, may or may not retain the 43.174 @@ -477,7 +514,7 @@ 43.175 * 43.176 * @return new array data (or same) 43.177 */ 43.178 - public abstract ArrayData shrink(long newLength); 43.179 + public abstract ArrayData shrink(final long newLength); 43.180 43.181 /** 43.182 * Set an object value at a given index 43.183 @@ -487,7 +524,7 @@ 43.184 * @param strict are we in strict mode 43.185 * @return new array data (or same) 43.186 */ 43.187 - public abstract ArrayData set(int index, Object value, boolean strict); 43.188 + public abstract ArrayData set(final int index, final Object value, final boolean strict); 43.189 43.190 /** 43.191 * Set an int value at a given index 43.192 @@ -497,7 +534,7 @@ 43.193 * @param strict are we in strict mode 43.194 * @return new array data (or same) 43.195 */ 43.196 - public abstract ArrayData set(int index, int value, boolean strict); 43.197 + public abstract ArrayData set(final int index, final int value, final boolean strict); 43.198 43.199 /** 43.200 * Set a long value at a given index 43.201 @@ -507,7 +544,7 @@ 43.202 * @param strict are we in strict mode 43.203 * @return new array data (or same) 43.204 */ 43.205 - public abstract ArrayData set(int index, long value, boolean strict); 43.206 + public abstract ArrayData set(final int index, final long value, final boolean strict); 43.207 43.208 /** 43.209 * Set an double value at a given index 43.210 @@ -517,7 +554,7 @@ 43.211 * @param strict are we in strict mode 43.212 * @return new array data (or same) 43.213 */ 43.214 - public abstract ArrayData set(int index, double value, boolean strict); 43.215 + public abstract ArrayData set(final int index, final double value, final boolean strict); 43.216 43.217 /** 43.218 * Set an empty value at a given index. Should only affect Object array. 43.219 @@ -548,7 +585,7 @@ 43.220 * @param index the index 43.221 * @return the value 43.222 */ 43.223 - public abstract int getInt(int index); 43.224 + public abstract int getInt(final int index); 43.225 43.226 /** 43.227 * Returns the optimistic type of this array data. Basically, when an array data object needs to throw an 43.228 @@ -577,7 +614,7 @@ 43.229 * @param index the index 43.230 * @return the value 43.231 */ 43.232 - public abstract long getLong(int index); 43.233 + public abstract long getLong(final int index); 43.234 43.235 /** 43.236 * Get optimistic long - default is that it's impossible. Overridden 43.237 @@ -597,7 +634,7 @@ 43.238 * @param index the index 43.239 * @return the value 43.240 */ 43.241 - public abstract double getDouble(int index); 43.242 + public abstract double getDouble(final int index); 43.243 43.244 /** 43.245 * Get optimistic double - default is that it's impossible. Overridden 43.246 @@ -617,14 +654,14 @@ 43.247 * @param index the index 43.248 * @return the value 43.249 */ 43.250 - public abstract Object getObject(int index); 43.251 + public abstract Object getObject(final int index); 43.252 43.253 /** 43.254 * Tests to see if an entry exists (avoids boxing.) 43.255 * @param index the index 43.256 * @return true if entry exists 43.257 */ 43.258 - public abstract boolean has(int index); 43.259 + public abstract boolean has(final int index); 43.260 43.261 /** 43.262 * Returns if element at specific index can be deleted or not. 43.263 @@ -670,7 +707,7 @@ 43.264 * @param index the index 43.265 * @return new array data (or same) 43.266 */ 43.267 - public abstract ArrayData delete(int index); 43.268 + public abstract ArrayData delete(final int index); 43.269 43.270 /** 43.271 * Delete a given range from this array; 43.272 @@ -680,7 +717,7 @@ 43.273 * 43.274 * @return new ArrayData after deletion 43.275 */ 43.276 - public abstract ArrayData delete(long fromIndex, long toIndex); 43.277 + public abstract ArrayData delete(final long fromIndex, final long toIndex); 43.278 43.279 /** 43.280 * Convert the ArrayData to one with a different element type 43.281 @@ -690,7 +727,7 @@ 43.282 * @param type new element type 43.283 * @return new array data 43.284 */ 43.285 - public abstract ArrayData convert(Class<?> type); 43.286 + public abstract ArrayData convert(final Class<?> type); 43.287 43.288 /** 43.289 * Push an array of items to the end of the array 43.290 @@ -774,7 +811,7 @@ 43.291 * @param to end index + 1 43.292 * @return new array data 43.293 */ 43.294 - public abstract ArrayData slice(long from, long to); 43.295 + public abstract ArrayData slice(final long from, final long to); 43.296 43.297 /** 43.298 * Fast splice operation. This just modifies the array according to the number of 43.299 @@ -819,6 +856,34 @@ 43.300 } 43.301 43.302 /** 43.303 + * Return a list of keys in the array for the iterators 43.304 + * @return iterator key list 43.305 + */ 43.306 + protected List<Long> computeIteratorKeys() { 43.307 + final List<Long> keys = new ArrayList<>(); 43.308 + 43.309 + final long len = length(); 43.310 + for (long i = 0L; i < len; i = nextIndex(i)) { 43.311 + if (has((int)i)) { 43.312 + keys.add(i); 43.313 + } 43.314 + } 43.315 + 43.316 + return keys; 43.317 + } 43.318 + 43.319 + /** 43.320 + * Return an iterator that goes through all indexes of elements 43.321 + * in this array. This includes those after array.length if 43.322 + * they exist 43.323 + * 43.324 + * @return iterator 43.325 + */ 43.326 + public Iterator<Long> indexIterator() { 43.327 + return computeIteratorKeys().iterator(); 43.328 + } 43.329 + 43.330 + /** 43.331 * Exponential growth function for array size when in 43.332 * need of resizing. 43.333 * 43.334 @@ -837,7 +902,7 @@ 43.335 * 43.336 * @return the next index 43.337 */ 43.338 - public long nextIndex(final long index) { 43.339 + long nextIndex(final long index) { 43.340 return index + 1; 43.341 } 43.342
44.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 44.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 44.3 @@ -39,7 +39,7 @@ 44.4 protected ArrayData underlying; 44.5 44.6 ArrayFilter(final ArrayData underlying) { 44.7 - super(underlying.length); 44.8 + super(underlying.length()); 44.9 this.underlying = underlying; 44.10 } 44.11 44.12 @@ -70,62 +70,55 @@ 44.13 @Override 44.14 public void shiftLeft(final int by) { 44.15 underlying.shiftLeft(by); 44.16 - setLength(underlying.length); 44.17 + setLength(underlying.length()); 44.18 } 44.19 44.20 @Override 44.21 public ArrayData shiftRight(final int by) { 44.22 underlying = underlying.shiftRight(by); 44.23 - setLength(underlying.length); 44.24 - 44.25 + setLength(underlying.length()); 44.26 return this; 44.27 } 44.28 44.29 @Override 44.30 public ArrayData ensure(final long safeIndex) { 44.31 underlying = underlying.ensure(safeIndex); 44.32 - setLength(underlying.length); 44.33 - 44.34 + setLength(underlying.length()); 44.35 return this; 44.36 } 44.37 44.38 @Override 44.39 public ArrayData shrink(final long newLength) { 44.40 underlying = underlying.shrink(newLength); 44.41 - setLength(underlying.length); 44.42 - 44.43 + setLength(underlying.length()); 44.44 return this; 44.45 } 44.46 44.47 @Override 44.48 public ArrayData set(final int index, final Object value, final boolean strict) { 44.49 underlying = underlying.set(index, value, strict); 44.50 - setLength(underlying.length); 44.51 - 44.52 + setLength(underlying.length()); 44.53 return this; 44.54 } 44.55 44.56 @Override 44.57 public ArrayData set(final int index, final int value, final boolean strict) { 44.58 underlying = underlying.set(index, value, strict); 44.59 - setLength(underlying.length); 44.60 - 44.61 + setLength(underlying.length()); 44.62 return this; 44.63 } 44.64 44.65 @Override 44.66 public ArrayData set(final int index, final long value, final boolean strict) { 44.67 underlying = underlying.set(index, value, strict); 44.68 - setLength(underlying.length); 44.69 - 44.70 + setLength(underlying.length()); 44.71 return this; 44.72 } 44.73 44.74 @Override 44.75 public ArrayData set(final int index, final double value, final boolean strict) { 44.76 underlying = underlying.set(index, value, strict); 44.77 - setLength(underlying.length); 44.78 - 44.79 + setLength(underlying.length()); 44.80 return this; 44.81 } 44.82 44.83 @@ -189,29 +182,28 @@ 44.84 @Override 44.85 public ArrayData delete(final int index) { 44.86 underlying = underlying.delete(index); 44.87 - setLength(underlying.length); 44.88 + setLength(underlying.length()); 44.89 return this; 44.90 } 44.91 44.92 @Override 44.93 public ArrayData delete(final long from, final long to) { 44.94 underlying = underlying.delete(from, to); 44.95 - setLength(underlying.length); 44.96 + setLength(underlying.length()); 44.97 return this; 44.98 } 44.99 44.100 @Override 44.101 public ArrayData convert(final Class<?> type) { 44.102 underlying = underlying.convert(type); 44.103 - setLength(underlying.length); 44.104 + setLength(underlying.length()); 44.105 return this; 44.106 } 44.107 44.108 @Override 44.109 public Object pop() { 44.110 final Object value = underlying.pop(); 44.111 - setLength(underlying.length); 44.112 - 44.113 + setLength(underlying.length()); 44.114 return value; 44.115 } 44.116
45.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Wed Nov 12 13:47:23 2014 -0800 45.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ContinuousArrayData.java Fri Nov 14 10:03:48 2014 -0800 45.3 @@ -65,7 +65,7 @@ 45.4 * @return true if we don't need to do any array reallocation to fit an element at index 45.5 */ 45.6 public final boolean hasRoomFor(final int index) { 45.7 - return has(index) || (index == length && ensure(index) == this); 45.8 + return has(index) || (index == length() && ensure(index) == this); 45.9 } 45.10 45.11 /** 45.12 @@ -73,7 +73,7 @@ 45.13 * @return true if empty 45.14 */ 45.15 public boolean isEmpty() { 45.16 - return length == 0L; 45.17 + return length() == 0L; 45.18 } 45.19 45.20 /**
46.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 46.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 46.3 @@ -38,8 +38,7 @@ 46.4 46.5 DeletedArrayFilter(final ArrayData underlying) { 46.6 super(underlying); 46.7 - 46.8 - this.deleted = new BitVector(underlying.length); 46.9 + this.deleted = new BitVector(underlying.length()); 46.10 } 46.11 46.12 @Override 46.13 @@ -79,25 +78,24 @@ 46.14 @Override 46.15 public void shiftLeft(final int by) { 46.16 super.shiftLeft(by); 46.17 - deleted.shiftLeft(by, length); 46.18 + deleted.shiftLeft(by, length()); 46.19 } 46.20 46.21 @Override 46.22 public ArrayData shiftRight(final int by) { 46.23 super.shiftRight(by); 46.24 - deleted.shiftRight(by, length); 46.25 - 46.26 + deleted.shiftRight(by, length()); 46.27 return this; 46.28 } 46.29 46.30 @Override 46.31 public ArrayData ensure(final long safeIndex) { 46.32 - if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length) { 46.33 + if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length()) { 46.34 return new SparseArrayData(this, safeIndex + 1); 46.35 } 46.36 46.37 super.ensure(safeIndex); 46.38 - deleted.resize(length); 46.39 + deleted.resize(length()); 46.40 46.41 return this; 46.42 } 46.43 @@ -105,36 +103,31 @@ 46.44 @Override 46.45 public ArrayData shrink(final long newLength) { 46.46 super.shrink(newLength); 46.47 - deleted.resize(length); 46.48 - 46.49 + deleted.resize(length()); 46.50 return this; 46.51 } 46.52 46.53 @Override 46.54 public ArrayData set(final int index, final Object value, final boolean strict) { 46.55 deleted.clear(ArrayIndex.toLongIndex(index)); 46.56 - 46.57 return super.set(index, value, strict); 46.58 } 46.59 46.60 @Override 46.61 public ArrayData set(final int index, final int value, final boolean strict) { 46.62 deleted.clear(ArrayIndex.toLongIndex(index)); 46.63 - 46.64 return super.set(index, value, strict); 46.65 } 46.66 46.67 @Override 46.68 public ArrayData set(final int index, final long value, final boolean strict) { 46.69 deleted.clear(ArrayIndex.toLongIndex(index)); 46.70 - 46.71 return super.set(index, value, strict); 46.72 } 46.73 46.74 @Override 46.75 public ArrayData set(final int index, final double value, final boolean strict) { 46.76 deleted.clear(ArrayIndex.toLongIndex(index)); 46.77 - 46.78 return super.set(index, value, strict); 46.79 } 46.80 46.81 @@ -146,7 +139,7 @@ 46.82 @Override 46.83 public ArrayData delete(final int index) { 46.84 final long longIndex = ArrayIndex.toLongIndex(index); 46.85 - assert longIndex >= 0 && longIndex < length; 46.86 + assert longIndex >= 0 && longIndex < length(); 46.87 deleted.set(longIndex); 46.88 underlying.setEmpty(index); 46.89 return this; 46.90 @@ -154,7 +147,7 @@ 46.91 46.92 @Override 46.93 public ArrayData delete(final long fromIndex, final long toIndex) { 46.94 - assert fromIndex >= 0 && fromIndex <= toIndex && toIndex < length; 46.95 + assert fromIndex >= 0 && fromIndex <= toIndex && toIndex < length(); 46.96 deleted.setRange(fromIndex, toIndex + 1); 46.97 underlying.setEmpty(fromIndex, toIndex); 46.98 return this; 46.99 @@ -162,7 +155,7 @@ 46.100 46.101 @Override 46.102 public Object pop() { 46.103 - final long index = length - 1; 46.104 + final long index = length() - 1; 46.105 46.106 if (super.has((int)index)) { 46.107 final boolean isDeleted = deleted.isSet(index); 46.108 @@ -179,7 +172,7 @@ 46.109 final ArrayData newArray = underlying.slice(from, to); 46.110 final DeletedArrayFilter newFilter = new DeletedArrayFilter(newArray); 46.111 newFilter.getDeleted().copy(deleted); 46.112 - newFilter.getDeleted().shiftLeft(from, newFilter.length); 46.113 + newFilter.getDeleted().shiftLeft(from, newFilter.length()); 46.114 46.115 return newFilter; 46.116 }
47.1 --- a/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 47.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/DeletedRangeArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 47.3 @@ -42,10 +42,10 @@ 47.4 } 47.5 47.6 private static ArrayData maybeSparse(final ArrayData underlying, final long hi) { 47.7 - if(hi < SparseArrayData.MAX_DENSE_LENGTH || underlying instanceof SparseArrayData) { 47.8 + if (hi < SparseArrayData.MAX_DENSE_LENGTH || underlying instanceof SparseArrayData) { 47.9 return underlying; 47.10 } 47.11 - return new SparseArrayData(underlying, underlying.length); 47.12 + return new SparseArrayData(underlying, underlying.length()); 47.13 } 47.14 47.15 private boolean isEmpty() { 47.16 @@ -93,7 +93,7 @@ 47.17 47.18 @Override 47.19 public ArrayData ensure(final long safeIndex) { 47.20 - if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length) { 47.21 + if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length()) { 47.22 return new SparseArrayData(this, safeIndex + 1); 47.23 } 47.24 47.25 @@ -110,7 +110,7 @@ 47.26 @Override 47.27 public ArrayData shiftRight(final int by) { 47.28 super.shiftRight(by); 47.29 - final long len = length; 47.30 + final long len = length(); 47.31 lo = Math.min(len, lo + by); 47.32 hi = Math.min(len - 1, hi + by); 47.33 47.34 @@ -238,7 +238,7 @@ 47.35 47.36 @Override 47.37 public Object pop() { 47.38 - final int index = (int)length - 1; 47.39 + final int index = (int)length() - 1; 47.40 if (super.has(index)) { 47.41 final boolean isDeleted = isDeleted(index); 47.42 final Object value = super.pop();
48.1 --- a/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 48.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/FrozenArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 48.3 @@ -26,9 +26,9 @@ 48.4 package jdk.nashorn.internal.runtime.arrays; 48.5 48.6 import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; 48.7 - 48.8 import jdk.nashorn.internal.objects.Global; 48.9 import jdk.nashorn.internal.runtime.PropertyDescriptor; 48.10 +import jdk.nashorn.internal.runtime.ScriptRuntime; 48.11 48.12 /** 48.13 * ArrayData after the array has been frozen by Object.freeze call. 48.14 @@ -79,4 +79,15 @@ 48.15 } 48.16 return this; 48.17 } 48.18 + 48.19 + @Override 48.20 + public ArrayData push(final boolean strict, final Object... items) { 48.21 + return this; //nop 48.22 + } 48.23 + 48.24 + @Override 48.25 + public Object pop() { 48.26 + final int len = (int)underlying.length(); 48.27 + return len == 0 ? ScriptRuntime.UNDEFINED : underlying.getObject(len - 1); 48.28 + } 48.29 }
49.1 --- a/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Wed Nov 12 13:47:23 2014 -0800 49.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/IntArrayData.java Fri Nov 14 10:03:48 2014 -0800 49.3 @@ -119,22 +119,24 @@ 49.4 49.5 @Override 49.6 public IntArrayData copy() { 49.7 - return new IntArrayData(array.clone(), (int)length); 49.8 + return new IntArrayData(array.clone(), (int)length()); 49.9 } 49.10 49.11 @Override 49.12 public Object asArrayOfType(final Class<?> componentType) { 49.13 if (componentType == int.class) { 49.14 - return array.length == length ? array.clone() : Arrays.copyOf(array, (int)length); 49.15 + final int len = (int)length(); 49.16 + return array.length == len ? array.clone() : Arrays.copyOf(array, len); 49.17 } 49.18 return super.asArrayOfType(componentType); 49.19 } 49.20 49.21 private Object[] toObjectArray(final boolean trim) { 49.22 - assert length <= array.length : "length exceeds internal array size"; 49.23 - final Object[] oarray = new Object[trim ? (int)length : array.length]; 49.24 + assert length() <= array.length : "length exceeds internal array size"; 49.25 + final int len = (int)length(); 49.26 + final Object[] oarray = new Object[trim ? len : array.length]; 49.27 49.28 - for (int index = 0; index < length; index++) { 49.29 + for (int index = 0; index < len; index++) { 49.30 oarray[index] = Integer.valueOf(array[index]); 49.31 } 49.32 49.33 @@ -142,10 +144,11 @@ 49.34 } 49.35 49.36 private double[] toDoubleArray() { 49.37 - assert length <= array.length : "length exceeds internal array size"; 49.38 + assert length() <= array.length : "length exceeds internal array size"; 49.39 + final int len = (int)length(); 49.40 final double[] darray = new double[array.length]; 49.41 49.42 - for (int index = 0; index < length; index++) { 49.43 + for (int index = 0; index < len; index++) { 49.44 darray[index] = array[index]; 49.45 } 49.46 49.47 @@ -153,10 +156,11 @@ 49.48 } 49.49 49.50 private long[] toLongArray() { 49.51 - assert length <= array.length : "length exceeds internal array size"; 49.52 + assert length() <= array.length : "length exceeds internal array size"; 49.53 + final int len = (int)length(); 49.54 final long[] larray = new long[array.length]; 49.55 49.56 - for (int index = 0; index < length; index++) { 49.57 + for (int index = 0; index < len; index++) { 49.58 larray[index] = array[index]; 49.59 } 49.60 49.61 @@ -164,15 +168,15 @@ 49.62 } 49.63 49.64 private LongArrayData convertToLong() { 49.65 - return new LongArrayData(toLongArray(), (int)length); 49.66 + return new LongArrayData(toLongArray(), (int)length()); 49.67 } 49.68 49.69 private NumberArrayData convertToDouble() { 49.70 - return new NumberArrayData(toDoubleArray(), (int)length); 49.71 + return new NumberArrayData(toDoubleArray(), (int)length()); 49.72 } 49.73 49.74 private ObjectArrayData convertToObject() { 49.75 - return new ObjectArrayData(toObjectArray(false), (int)length); 49.76 + return new ObjectArrayData(toObjectArray(false), (int)length()); 49.77 } 49.78 49.79 @Override 49.80 @@ -196,7 +200,7 @@ 49.81 49.82 @Override 49.83 public ArrayData shiftRight(final int by) { 49.84 - final ArrayData newData = ensure(by + length - 1); 49.85 + final ArrayData newData = ensure(by + length() - 1); 49.86 if (newData != this) { 49.87 newData.shiftRight(by); 49.88 return newData; 49.89 @@ -241,7 +245,7 @@ 49.90 @Override 49.91 public ArrayData set(final int index, final int value, final boolean strict) { 49.92 array[index] = value; 49.93 - setLength(Math.max(index + 1, length)); 49.94 + setLength(Math.max(index + 1, length())); 49.95 49.96 return this; 49.97 } 49.98 @@ -250,7 +254,7 @@ 49.99 public ArrayData set(final int index, final long value, final boolean strict) { 49.100 if (JSType.isRepresentableAsInt(value)) { 49.101 array[index] = JSType.toInt32(value); 49.102 - setLength(Math.max(index + 1, length)); 49.103 + setLength(Math.max(index + 1, length())); 49.104 return this; 49.105 } 49.106 49.107 @@ -261,7 +265,7 @@ 49.108 public ArrayData set(final int index, final double value, final boolean strict) { 49.109 if (JSType.isRepresentableAsInt(value)) { 49.110 array[index] = (int)(long)value; 49.111 - setLength(Math.max(index + 1, length)); 49.112 + setLength(Math.max(index + 1, length())); 49.113 return this; 49.114 } 49.115 49.116 @@ -305,7 +309,7 @@ 49.117 49.118 @Override 49.119 public boolean has(final int index) { 49.120 - return 0 <= index && index < length; 49.121 + return 0 <= index && index < length(); 49.122 } 49.123 49.124 @Override 49.125 @@ -320,11 +324,12 @@ 49.126 49.127 @Override 49.128 public Object pop() { 49.129 - if (length == 0) { 49.130 + final int len = (int)length(); 49.131 + if (len == 0) { 49.132 return ScriptRuntime.UNDEFINED; 49.133 } 49.134 49.135 - final int newLength = (int)length - 1; 49.136 + final int newLength = len - 1; 49.137 final int elem = array[newLength]; 49.138 array[newLength] = 0; 49.139 setLength(newLength); 49.140 @@ -334,12 +339,12 @@ 49.141 49.142 @Override 49.143 public ArrayData slice(final long from, final long to) { 49.144 - return new IntArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)(to - (from < 0 ? from + length : from))); 49.145 + return new IntArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)(to - (from < 0 ? from + length() : from))); 49.146 } 49.147 49.148 @Override 49.149 public final ArrayData push(final boolean strict, final int item) { 49.150 - final long len = length; 49.151 + final long len = length(); 49.152 final ArrayData newData = ensure(len); 49.153 if (newData == this) { 49.154 array[(int)len] = item; 49.155 @@ -350,7 +355,7 @@ 49.156 49.157 @Override 49.158 public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { 49.159 - final long oldLength = length; 49.160 + final long oldLength = length(); 49.161 final long newLength = oldLength - removed + added; 49.162 if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) { 49.163 throw new UnsupportedOperationException(); 49.164 @@ -384,21 +389,21 @@ 49.165 49.166 @Override 49.167 public long fastPush(final int arg) { 49.168 - final int len = (int)length; 49.169 + final int len = (int)length(); 49.170 if (len == array.length) { 49.171 array = Arrays.copyOf(array, nextSize(len)); 49.172 } 49.173 array[len] = arg; 49.174 - return ++length; 49.175 + return increaseLength(); 49.176 } 49.177 49.178 //length must not be zero 49.179 @Override 49.180 public int fastPopInt() { 49.181 - if (length == 0) { 49.182 + if (length() == 0) { 49.183 throw new ClassCastException(); //relink 49.184 } 49.185 - final int newLength = (int)--length; 49.186 + final int newLength = (int)decreaseLength(); 49.187 final int elem = array[newLength]; 49.188 array[newLength] = 0; 49.189 return elem; 49.190 @@ -421,8 +426,8 @@ 49.191 49.192 @Override 49.193 public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { 49.194 - final int otherLength = (int)otherData.length; 49.195 - final int thisLength = (int)length; 49.196 + final int otherLength = (int)otherData.length(); 49.197 + final int thisLength = (int)length(); 49.198 assert otherLength > 0 && thisLength > 0; 49.199 49.200 final int[] otherArray = ((IntArrayData)otherData).array; 49.201 @@ -437,7 +442,7 @@ 49.202 49.203 @Override 49.204 public String toString() { 49.205 - assert length <= array.length : length + " > " + array.length; 49.206 - return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length)); 49.207 + assert length() <= array.length : length() + " > " + array.length; 49.208 + return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length())); 49.209 } 49.210 }
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/LengthNotWritableFilter.java Fri Nov 14 10:03:48 2014 -0800 50.3 @@ -0,0 +1,198 @@ 50.4 +package jdk.nashorn.internal.runtime.arrays; 50.5 + 50.6 +import java.util.Iterator; 50.7 +import java.util.List; 50.8 +import java.util.SortedMap; 50.9 +import java.util.TreeMap; 50.10 +import jdk.nashorn.internal.runtime.JSType; 50.11 +import jdk.nashorn.internal.runtime.ScriptRuntime; 50.12 + 50.13 +/** 50.14 + * Filter to use for ArrayData where the length is not writable. 50.15 + * The default behavior is just to ignore {@link ArrayData#setLength} 50.16 + */ 50.17 +final class LengthNotWritableFilter extends ArrayFilter { 50.18 + private final SortedMap<Long, Object> extraElements; //elements with index >= length 50.19 + 50.20 + /** 50.21 + * Constructor 50.22 + * @param underlying array 50.23 + */ 50.24 + LengthNotWritableFilter(final ArrayData underlying) { 50.25 + this(underlying, new TreeMap<Long, Object>()); 50.26 + } 50.27 + 50.28 + private LengthNotWritableFilter(final ArrayData underlying, final SortedMap<Long, Object> extraElements) { 50.29 + super(underlying); 50.30 + this.extraElements = extraElements; 50.31 + } 50.32 + 50.33 + @Override 50.34 + public ArrayData copy() { 50.35 + return new LengthNotWritableFilter(underlying.copy(), new TreeMap<>(extraElements)); 50.36 + } 50.37 + 50.38 + @Override 50.39 + public boolean has(final int index) { 50.40 + return super.has(index) || extraElements.containsKey((long)index); 50.41 + } 50.42 + 50.43 + /** 50.44 + * Set the length of the data array 50.45 + * 50.46 + * @param length the new length for the data array 50.47 + */ 50.48 + @Override 50.49 + public void setLength(final long length) { 50.50 + //empty - setting length for a LengthNotWritableFilter is always a nop 50.51 + } 50.52 + 50.53 + @Override 50.54 + public ArrayData ensure(final long index) { 50.55 + return this; 50.56 + } 50.57 + 50.58 + @Override 50.59 + public ArrayData slice(final long from, final long to) { 50.60 + //return array[from...to), or array[from...length] if undefined, in this case not as we are an ArrayData 50.61 + return new LengthNotWritableFilter(underlying.slice(from, to), extraElements.subMap(from, to)); 50.62 + } 50.63 + 50.64 + private boolean checkAdd(final long index, final Object value) { 50.65 + if (index >= length()) { 50.66 + extraElements.put(index, value); 50.67 + return true; 50.68 + } 50.69 + return false; 50.70 + } 50.71 + 50.72 + private Object get(final long index) { 50.73 + final Object obj = extraElements.get(index); 50.74 + if (obj == null) { 50.75 + return ScriptRuntime.UNDEFINED; 50.76 + } 50.77 + return obj; 50.78 + } 50.79 + 50.80 + @Override 50.81 + public int getInt(final int index) { 50.82 + if (index >= length()) { 50.83 + return JSType.toInt32(get(index)); 50.84 + } 50.85 + return underlying.getInt(index); 50.86 + } 50.87 + 50.88 + @Override 50.89 + public int getIntOptimistic(final int index, final int programPoint) { 50.90 + if (index >= length()) { 50.91 + return JSType.toInt32Optimistic(get(index), programPoint); 50.92 + } 50.93 + return underlying.getIntOptimistic(index, programPoint); 50.94 + } 50.95 + 50.96 + @Override 50.97 + public long getLong(final int index) { 50.98 + if (index >= length()) { 50.99 + return JSType.toLong(get(index)); 50.100 + } 50.101 + return underlying.getLong(index); 50.102 + } 50.103 + 50.104 + @Override 50.105 + public long getLongOptimistic(final int index, final int programPoint) { 50.106 + if (index >= length()) { 50.107 + return JSType.toLongOptimistic(get(index), programPoint); 50.108 + } 50.109 + return underlying.getLongOptimistic(index, programPoint); 50.110 + } 50.111 + 50.112 + @Override 50.113 + public double getDouble(final int index) { 50.114 + if (index >= length()) { 50.115 + return JSType.toNumber(get(index)); 50.116 + } 50.117 + return underlying.getDouble(index); 50.118 + } 50.119 + 50.120 + @Override 50.121 + public double getDoubleOptimistic(final int index, final int programPoint) { 50.122 + if (index >= length()) { 50.123 + return JSType.toNumberOptimistic(get(index), programPoint); 50.124 + } 50.125 + return underlying.getDoubleOptimistic(index, programPoint); 50.126 + } 50.127 + 50.128 + @Override 50.129 + public Object getObject(final int index) { 50.130 + if (index >= length()) { 50.131 + return get(index); 50.132 + } 50.133 + return underlying.getObject(index); 50.134 + } 50.135 + 50.136 + @Override 50.137 + public ArrayData set(final int index, final Object value, final boolean strict) { 50.138 + if (checkAdd(index, value)) { 50.139 + return this; 50.140 + } 50.141 + underlying = underlying.set(index, value, strict); 50.142 + return this; 50.143 + } 50.144 + 50.145 + @Override 50.146 + public ArrayData set(final int index, final int value, final boolean strict) { 50.147 + if (checkAdd(index, value)) { 50.148 + return this; 50.149 + } 50.150 + underlying = underlying.set(index, value, strict); 50.151 + return this; 50.152 + } 50.153 + 50.154 + @Override 50.155 + public ArrayData set(final int index, final long value, final boolean strict) { 50.156 + if (checkAdd(index, value)) { 50.157 + return this; 50.158 + } 50.159 + underlying = underlying.set(index, value, strict); 50.160 + return this; 50.161 + } 50.162 + 50.163 + @Override 50.164 + public ArrayData set(final int index, final double value, final boolean strict) { 50.165 + if (checkAdd(index, value)) { 50.166 + return this; 50.167 + } 50.168 + underlying = underlying.set(index, value, strict); 50.169 + return this; 50.170 + } 50.171 + 50.172 + @Override 50.173 + public ArrayData delete(final int index) { 50.174 + extraElements.remove(index); 50.175 + underlying = underlying.delete(index); 50.176 + return this; 50.177 + } 50.178 + 50.179 + @Override 50.180 + public ArrayData delete(final long fromIndex, final long toIndex) { 50.181 + for (final Iterator<Long> iter = extraElements.keySet().iterator(); iter.hasNext();) { 50.182 + final long next = iter.next(); 50.183 + if (next >= fromIndex && next <= toIndex) { 50.184 + iter.remove(); 50.185 + } 50.186 + if (next > toIndex) { //ordering guaranteed because TreeSet 50.187 + break; 50.188 + } 50.189 + } 50.190 + underlying = underlying.delete(fromIndex, toIndex); 50.191 + return this; 50.192 + } 50.193 + 50.194 + @Override 50.195 + public Iterator<Long> indexIterator() { 50.196 + final List<Long> keys = computeIteratorKeys(); 50.197 + keys.addAll(extraElements.keySet()); //even if they are outside length this is fine 50.198 + return keys.iterator(); 50.199 + } 50.200 + 50.201 +}
51.1 --- a/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Wed Nov 12 13:47:23 2014 -0800 51.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/LongArrayData.java Fri Nov 14 10:03:48 2014 -0800 51.3 @@ -27,7 +27,6 @@ 51.4 51.5 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall; 51.6 import static jdk.nashorn.internal.lookup.Lookup.MH; 51.7 - 51.8 import java.lang.invoke.MethodHandle; 51.9 import java.lang.invoke.MethodHandles; 51.10 import java.util.Arrays; 51.11 @@ -77,7 +76,7 @@ 51.12 51.13 @Override 51.14 public LongArrayData copy() { 51.15 - return new LongArrayData(array.clone(), (int)length); 51.16 + return new LongArrayData(array.clone(), (int)length()); 51.17 } 51.18 51.19 @Override 51.20 @@ -86,10 +85,11 @@ 51.21 } 51.22 51.23 private Object[] toObjectArray(final boolean trim) { 51.24 - assert length <= array.length : "length exceeds internal array size"; 51.25 - final Object[] oarray = new Object[trim ? (int)length : array.length]; 51.26 + assert length() <= array.length : "length exceeds internal array size"; 51.27 + final int len = (int)length(); 51.28 + final Object[] oarray = new Object[trim ? len : array.length]; 51.29 51.30 - for (int index = 0; index < length; index++) { 51.31 + for (int index = 0; index < len; index++) { 51.32 oarray[index] = Long.valueOf(array[index]); 51.33 } 51.34 51.35 @@ -99,16 +99,18 @@ 51.36 @Override 51.37 public Object asArrayOfType(final Class<?> componentType) { 51.38 if (componentType == long.class) { 51.39 - return array.length == length ? array.clone() : Arrays.copyOf(array, (int)length); 51.40 + final int len = (int)length(); 51.41 + return array.length == len ? array.clone() : Arrays.copyOf(array, len); 51.42 } 51.43 return super.asArrayOfType(componentType); 51.44 } 51.45 51.46 private double[] toDoubleArray() { 51.47 - assert length <= array.length : "length exceeds internal array size"; 51.48 + assert length() <= array.length : "length exceeds internal array size"; 51.49 + final int len = (int)length(); 51.50 final double[] darray = new double[array.length]; 51.51 51.52 - for (int index = 0; index < length; index++) { 51.53 + for (int index = 0; index < len; index++) { 51.54 darray[index] = array[index]; 51.55 } 51.56 51.57 @@ -120,7 +122,7 @@ 51.58 if (type == Integer.class || type == Long.class) { 51.59 return this; 51.60 } 51.61 - final int len = (int)length; 51.62 + final int len = (int)length(); 51.63 if (type == Double.class) { 51.64 return new NumberArrayData(toDoubleArray(), len); 51.65 } 51.66 @@ -134,7 +136,7 @@ 51.67 51.68 @Override 51.69 public ArrayData shiftRight(final int by) { 51.70 - final ArrayData newData = ensure(by + length - 1); 51.71 + final ArrayData newData = ensure(by + length() - 1); 51.72 if (newData != this) { 51.73 newData.shiftRight(by); 51.74 return newData; 51.75 @@ -179,14 +181,14 @@ 51.76 @Override 51.77 public ArrayData set(final int index, final int value, final boolean strict) { 51.78 array[index] = value; 51.79 - setLength(Math.max(index + 1, length)); 51.80 + setLength(Math.max(index + 1, length())); 51.81 return this; 51.82 } 51.83 51.84 @Override 51.85 public ArrayData set(final int index, final long value, final boolean strict) { 51.86 array[index] = value; 51.87 - setLength(Math.max(index + 1, length)); 51.88 + setLength(Math.max(index + 1, length())); 51.89 return this; 51.90 } 51.91 51.92 @@ -194,7 +196,7 @@ 51.93 public ArrayData set(final int index, final double value, final boolean strict) { 51.94 if (JSType.isRepresentableAsLong(value)) { 51.95 array[index] = (long)value; 51.96 - setLength(Math.max(index + 1, length)); 51.97 + setLength(Math.max(index + 1, length())); 51.98 return this; 51.99 } 51.100 return convert(Double.class).set(index, value, strict); 51.101 @@ -265,7 +267,7 @@ 51.102 51.103 @Override 51.104 public boolean has(final int index) { 51.105 - return 0 <= index && index < length; 51.106 + return 0 <= index && index < length(); 51.107 } 51.108 51.109 @Override 51.110 @@ -280,11 +282,12 @@ 51.111 51.112 @Override 51.113 public Object pop() { 51.114 - if (length == 0) { 51.115 + final int len = (int)length(); 51.116 + if (len == 0) { 51.117 return ScriptRuntime.UNDEFINED; 51.118 } 51.119 51.120 - final int newLength = (int)length - 1; 51.121 + final int newLength = len - 1; 51.122 final long elem = array[newLength]; 51.123 array[newLength] = 0; 51.124 setLength(newLength); 51.125 @@ -294,14 +297,14 @@ 51.126 51.127 @Override 51.128 public ArrayData slice(final long from, final long to) { 51.129 - final long start = from < 0 ? from + length : from; 51.130 + final long start = from < 0 ? from + length() : from; 51.131 final long newLength = to - start; 51.132 return new LongArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)newLength); 51.133 } 51.134 51.135 @Override 51.136 public final ArrayData push(final boolean strict, final long item) { 51.137 - final long len = length; 51.138 + final long len = length(); 51.139 final ArrayData newData = ensure(len); 51.140 if (newData == this) { 51.141 array[(int)len] = item; 51.142 @@ -312,7 +315,7 @@ 51.143 51.144 @Override 51.145 public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { 51.146 - final long oldLength = length; 51.147 + final long oldLength = length(); 51.148 final long newLength = oldLength - removed + added; 51.149 if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) { 51.150 throw new UnsupportedOperationException(); 51.151 @@ -345,20 +348,20 @@ 51.152 51.153 @Override 51.154 public long fastPush(final long arg) { 51.155 - final int len = (int)length; 51.156 + final int len = (int)length(); 51.157 if (len == array.length) { 51.158 array = Arrays.copyOf(array, nextSize(len)); 51.159 } 51.160 array[len] = arg; 51.161 - return ++length; 51.162 + return increaseLength(); 51.163 } 51.164 51.165 @Override 51.166 public long fastPopLong() { 51.167 - if (length == 0) { 51.168 - throw new ClassCastException(); 51.169 + if (length() == 0) { 51.170 + throw new ClassCastException(); //undefined result 51.171 } 51.172 - final int newLength = (int)--length; 51.173 + final int newLength = (int)decreaseLength(); 51.174 final long elem = array[newLength]; 51.175 array[newLength] = 0; 51.176 return elem; 51.177 @@ -376,8 +379,8 @@ 51.178 51.179 @Override 51.180 public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { 51.181 - final int otherLength = (int)otherData.length; 51.182 - final int thisLength = (int)length; 51.183 + final int otherLength = (int)otherData.length(); 51.184 + final int thisLength = (int)length(); 51.185 assert otherLength > 0 && thisLength > 0; 51.186 51.187 final long[] otherArray = ((LongArrayData)otherData).array; 51.188 @@ -392,13 +395,14 @@ 51.189 51.190 @Override 51.191 public String toString() { 51.192 - assert length <= array.length : length + " > " + array.length; 51.193 + assert length() <= array.length : length() + " > " + array.length; 51.194 51.195 final StringBuilder sb = new StringBuilder(getClass().getSimpleName()). 51.196 append(": ["); 51.197 - for (int i = 0; i < length; i++) { 51.198 + final int len = (int)length(); 51.199 + for (int i = 0; i < len; i++) { 51.200 sb.append(array[i]).append('L'); //make sure L suffix is on elements, to discriminate this from IntArrayData.toString() 51.201 - if (i + 1 < length) { 51.202 + if (i + 1 < len) { 51.203 sb.append(", "); 51.204 } 51.205 }
52.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 52.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NonExtensibleArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 52.3 @@ -7,13 +7,13 @@ 52.4 /** 52.5 * Filter class that wrap arrays that have been tagged non extensible 52.6 */ 52.7 -public class NonExtensibleArrayFilter extends ArrayFilter { 52.8 +final class NonExtensibleArrayFilter extends ArrayFilter { 52.9 52.10 /** 52.11 * Constructor 52.12 * @param underlying array 52.13 */ 52.14 - public NonExtensibleArrayFilter(final ArrayData underlying) { 52.15 + NonExtensibleArrayFilter(final ArrayData underlying) { 52.16 super(underlying); 52.17 } 52.18
53.1 --- a/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Wed Nov 12 13:47:23 2014 -0800 53.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/NumberArrayData.java Fri Nov 14 10:03:48 2014 -0800 53.3 @@ -28,7 +28,6 @@ 53.4 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall; 53.5 import static jdk.nashorn.internal.lookup.Lookup.MH; 53.6 import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; 53.7 - 53.8 import java.lang.invoke.MethodHandle; 53.9 import java.lang.invoke.MethodHandles; 53.10 import java.util.Arrays; 53.11 @@ -76,7 +75,7 @@ 53.12 53.13 @Override 53.14 public NumberArrayData copy() { 53.15 - return new NumberArrayData(array.clone(), (int)length); 53.16 + return new NumberArrayData(array.clone(), (int)length()); 53.17 } 53.18 53.19 @Override 53.20 @@ -85,10 +84,11 @@ 53.21 } 53.22 53.23 private Object[] toObjectArray(final boolean trim) { 53.24 - assert length <= array.length : "length exceeds internal array size"; 53.25 - final Object[] oarray = new Object[trim ? (int)length : array.length]; 53.26 + assert length() <= array.length : "length exceeds internal array size"; 53.27 + final int len = (int)length(); 53.28 + final Object[] oarray = new Object[trim ? len : array.length]; 53.29 53.30 - for (int index = 0; index < length; index++) { 53.31 + for (int index = 0; index < len; index++) { 53.32 oarray[index] = Double.valueOf(array[index]); 53.33 } 53.34 return oarray; 53.35 @@ -96,8 +96,9 @@ 53.36 53.37 @Override 53.38 public Object asArrayOfType(final Class<?> componentType) { 53.39 - if(componentType == double.class) { 53.40 - return array.length == length ? array.clone() : Arrays.copyOf(array, (int)length); 53.41 + if (componentType == double.class) { 53.42 + final int len = (int)length(); 53.43 + return array.length == len ? array.clone() : Arrays.copyOf(array, len); 53.44 } 53.45 return super.asArrayOfType(componentType); 53.46 } 53.47 @@ -105,7 +106,7 @@ 53.48 @Override 53.49 public ContinuousArrayData convert(final Class<?> type) { 53.50 if (type != Double.class && type != Integer.class && type != Long.class) { 53.51 - final int len = (int)length; 53.52 + final int len = (int)length(); 53.53 return new ObjectArrayData(toObjectArray(false), len); 53.54 } 53.55 return this; 53.56 @@ -118,7 +119,7 @@ 53.57 53.58 @Override 53.59 public ArrayData shiftRight(final int by) { 53.60 - final ArrayData newData = ensure(by + length - 1); 53.61 + final ArrayData newData = ensure(by + length() - 1); 53.62 if (newData != this) { 53.63 newData.shiftRight(by); 53.64 return newData; 53.65 @@ -163,21 +164,21 @@ 53.66 @Override 53.67 public ArrayData set(final int index, final int value, final boolean strict) { 53.68 array[index] = value; 53.69 - setLength(Math.max(index + 1, length)); 53.70 + setLength(Math.max(index + 1, length())); 53.71 return this; 53.72 } 53.73 53.74 @Override 53.75 public ArrayData set(final int index, final long value, final boolean strict) { 53.76 array[index] = value; 53.77 - setLength(Math.max(index + 1, length)); 53.78 + setLength(Math.max(index + 1, length())); 53.79 return this; 53.80 } 53.81 53.82 @Override 53.83 public ArrayData set(final int index, final double value, final boolean strict) { 53.84 array[index] = value; 53.85 - setLength(Math.max(index + 1, length)); 53.86 + setLength(Math.max(index + 1, length())); 53.87 return this; 53.88 } 53.89 53.90 @@ -241,7 +242,7 @@ 53.91 53.92 @Override 53.93 public boolean has(final int index) { 53.94 - return 0 <= index && index < length; 53.95 + return 0 <= index && index < length(); 53.96 } 53.97 53.98 @Override 53.99 @@ -256,11 +257,12 @@ 53.100 53.101 @Override 53.102 public Object pop() { 53.103 - if (length == 0) { 53.104 + final int len = (int)length(); 53.105 + if (len == 0) { 53.106 return UNDEFINED; 53.107 } 53.108 53.109 - final int newLength = (int)length - 1; 53.110 + final int newLength = len - 1; 53.111 final double elem = array[newLength]; 53.112 array[newLength] = 0; 53.113 setLength(newLength); 53.114 @@ -269,14 +271,14 @@ 53.115 53.116 @Override 53.117 public ArrayData slice(final long from, final long to) { 53.118 - final long start = from < 0 ? from + length : from; 53.119 + final long start = from < 0 ? from + length() : from; 53.120 final long newLength = to - start; 53.121 return new NumberArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)newLength); 53.122 } 53.123 53.124 @Override 53.125 public final ArrayData push(final boolean strict, final double item) { 53.126 - final long len = length; 53.127 + final long len = length(); 53.128 final ArrayData newData = ensure(len); 53.129 if (newData == this) { 53.130 array[(int)len] = item; 53.131 @@ -287,7 +289,7 @@ 53.132 53.133 @Override 53.134 public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { 53.135 - final long oldLength = length; 53.136 + final long oldLength = length(); 53.137 final long newLength = oldLength - removed + added; 53.138 if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) { 53.139 throw new UnsupportedOperationException(); 53.140 @@ -325,21 +327,21 @@ 53.141 53.142 @Override 53.143 public long fastPush(final double arg) { 53.144 - final int len = (int)length; 53.145 + final int len = (int)length(); 53.146 if (len == array.length) { 53.147 //note that fastpush never creates spares arrays, there is nothing to gain by that - it will just use even more memory 53.148 array = Arrays.copyOf(array, nextSize(len)); 53.149 } 53.150 array[len] = arg; 53.151 - return ++length; 53.152 + return increaseLength(); 53.153 } 53.154 53.155 @Override 53.156 public double fastPopDouble() { 53.157 - if (length == 0) { 53.158 + if (length() == 0) { 53.159 throw new ClassCastException(); 53.160 } 53.161 - final int newLength = (int)--length; 53.162 + final int newLength = (int)decreaseLength(); 53.163 final double elem = array[newLength]; 53.164 array[newLength] = 0; 53.165 return elem; 53.166 @@ -352,8 +354,8 @@ 53.167 53.168 @Override 53.169 public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { 53.170 - final int otherLength = (int)otherData.length; 53.171 - final int thisLength = (int)length; 53.172 + final int otherLength = (int)otherData.length(); 53.173 + final int thisLength = (int)length(); 53.174 assert otherLength > 0 && thisLength > 0; 53.175 53.176 final double[] otherArray = ((NumberArrayData)otherData).array; 53.177 @@ -368,7 +370,7 @@ 53.178 53.179 @Override 53.180 public String toString() { 53.181 - assert length <= array.length : length + " > " + array.length; 53.182 - return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length)); 53.183 + assert length() <= array.length : length() + " > " + array.length; 53.184 + return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length())); 53.185 } 53.186 }
54.1 --- a/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Wed Nov 12 13:47:23 2014 -0800 54.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/ObjectArrayData.java Fri Nov 14 10:03:48 2014 -0800 54.3 @@ -26,7 +26,6 @@ 54.4 package jdk.nashorn.internal.runtime.arrays; 54.5 54.6 import static jdk.nashorn.internal.codegen.CompilerConstants.specialCall; 54.7 - 54.8 import java.lang.invoke.MethodHandle; 54.9 import java.lang.invoke.MethodHandles; 54.10 import java.util.Arrays; 54.11 @@ -77,16 +76,16 @@ 54.12 54.13 @Override 54.14 public ObjectArrayData copy() { 54.15 - return new ObjectArrayData(array.clone(), (int)length); 54.16 + return new ObjectArrayData(array.clone(), (int)length()); 54.17 } 54.18 54.19 @Override 54.20 public Object[] asObjectArray() { 54.21 - return array.length == length ? array.clone() : asObjectArrayCopy(); 54.22 + return array.length == length() ? array.clone() : asObjectArrayCopy(); 54.23 } 54.24 54.25 private Object[] asObjectArrayCopy() { 54.26 - final long len = length; 54.27 + final long len = length(); 54.28 assert len <= Integer.MAX_VALUE; 54.29 final Object[] copy = new Object[(int)len]; 54.30 System.arraycopy(array, 0, copy, 0, (int)len); 54.31 @@ -105,7 +104,7 @@ 54.32 54.33 @Override 54.34 public ArrayData shiftRight(final int by) { 54.35 - final ArrayData newData = ensure(by + length - 1); 54.36 + final ArrayData newData = ensure(by + length() - 1); 54.37 if (newData != this) { 54.38 newData.shiftRight(by); 54.39 return newData; 54.40 @@ -137,28 +136,28 @@ 54.41 @Override 54.42 public ArrayData set(final int index, final Object value, final boolean strict) { 54.43 array[index] = value; 54.44 - setLength(Math.max(index + 1, length)); 54.45 + setLength(Math.max(index + 1, length())); 54.46 return this; 54.47 } 54.48 54.49 @Override 54.50 public ArrayData set(final int index, final int value, final boolean strict) { 54.51 array[index] = value; 54.52 - setLength(Math.max(index + 1, length)); 54.53 + setLength(Math.max(index + 1, length())); 54.54 return this; 54.55 } 54.56 54.57 @Override 54.58 public ArrayData set(final int index, final long value, final boolean strict) { 54.59 array[index] = value; 54.60 - setLength(Math.max(index + 1, length)); 54.61 + setLength(Math.max(index + 1, length())); 54.62 return this; 54.63 } 54.64 54.65 @Override 54.66 public ArrayData set(final int index, final double value, final boolean strict) { 54.67 array[index] = value; 54.68 - setLength(Math.max(index + 1, length)); 54.69 + setLength(Math.max(index + 1, length())); 54.70 return this; 54.71 } 54.72 54.73 @@ -231,7 +230,7 @@ 54.74 54.75 @Override 54.76 public boolean has(final int index) { 54.77 - return 0 <= index && index < length; 54.78 + return 0 <= index && index < length(); 54.79 } 54.80 54.81 @Override 54.82 @@ -263,20 +262,20 @@ 54.83 54.84 @Override 54.85 public long fastPush(final Object arg) { 54.86 - final int len = (int)length; 54.87 + final int len = (int)length(); 54.88 if (len == array.length) { 54.89 array = Arrays.copyOf(array, nextSize(len)); 54.90 } 54.91 array[len] = arg; 54.92 - return ++length; 54.93 + return increaseLength(); 54.94 } 54.95 54.96 @Override 54.97 public Object fastPopObject() { 54.98 - if (length == 0) { 54.99 + if (length() == 0) { 54.100 return ScriptRuntime.UNDEFINED; 54.101 } 54.102 - final int newLength = (int)--length; 54.103 + final int newLength = (int)decreaseLength(); 54.104 final Object elem = array[newLength]; 54.105 array[newLength] = ScriptRuntime.EMPTY; 54.106 return elem; 54.107 @@ -284,11 +283,11 @@ 54.108 54.109 @Override 54.110 public Object pop() { 54.111 - if (length == 0) { 54.112 + if (length() == 0) { 54.113 return ScriptRuntime.UNDEFINED; 54.114 } 54.115 54.116 - final int newLength = (int)length - 1; 54.117 + final int newLength = (int)length() - 1; 54.118 final Object elem = array[newLength]; 54.119 setEmpty(newLength); 54.120 setLength(newLength); 54.121 @@ -297,14 +296,14 @@ 54.122 54.123 @Override 54.124 public ArrayData slice(final long from, final long to) { 54.125 - final long start = from < 0 ? from + length : from; 54.126 + final long start = from < 0 ? from + length() : from; 54.127 final long newLength = to - start; 54.128 return new ObjectArrayData(Arrays.copyOfRange(array, (int)from, (int)to), (int)newLength); 54.129 } 54.130 54.131 @Override 54.132 public ArrayData push(final boolean strict, final Object item) { 54.133 - final long len = length; 54.134 + final long len = length(); 54.135 final ArrayData newData = ensure(len); 54.136 if (newData == this) { 54.137 array[(int)len] = item; 54.138 @@ -315,7 +314,7 @@ 54.139 54.140 @Override 54.141 public ArrayData fastSplice(final int start, final int removed, final int added) throws UnsupportedOperationException { 54.142 - final long oldLength = length; 54.143 + final long oldLength = length(); 54.144 final long newLength = oldLength - removed + added; 54.145 if (newLength > SparseArrayData.MAX_DENSE_LENGTH && newLength > array.length) { 54.146 throw new UnsupportedOperationException(); 54.147 @@ -343,8 +342,8 @@ 54.148 54.149 @Override 54.150 public ContinuousArrayData fastConcat(final ContinuousArrayData otherData) { 54.151 - final int otherLength = (int)otherData.length; 54.152 - final int thisLength = (int)length; 54.153 + final int otherLength = (int)otherData.length(); 54.154 + final int thisLength = (int)length(); 54.155 assert otherLength > 0 && thisLength > 0; 54.156 54.157 final Object[] otherArray = ((ObjectArrayData)otherData).array; 54.158 @@ -359,7 +358,7 @@ 54.159 54.160 @Override 54.161 public String toString() { 54.162 - assert length <= array.length : length + " > " + array.length; 54.163 - return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length)); 54.164 + assert length() <= array.length : length() + " > " + array.length; 54.165 + return getClass().getSimpleName() + ':' + Arrays.toString(Arrays.copyOf(array, (int)length())); 54.166 } 54.167 }
55.1 --- a/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Wed Nov 12 13:47:23 2014 -0800 55.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/SparseArrayData.java Fri Nov 14 10:03:48 2014 -0800 55.3 @@ -36,7 +36,7 @@ 55.4 * Handle arrays where the index is very large. 55.5 */ 55.6 class SparseArrayData extends ArrayData { 55.7 - static final long MAX_DENSE_LENGTH = 16 * 512 * 1024; 55.8 + static final int MAX_DENSE_LENGTH = 8 * 1024 * 1024; 55.9 55.10 /** Underlying array. */ 55.11 private ArrayData underlying; 55.12 @@ -53,21 +53,21 @@ 55.13 55.14 SparseArrayData(final ArrayData underlying, final long length, final TreeMap<Long, Object> sparseMap) { 55.15 super(length); 55.16 - assert underlying.length <= length; 55.17 + assert underlying.length() <= length; 55.18 this.underlying = underlying; 55.19 - this.maxDenseLength = Math.max(MAX_DENSE_LENGTH, underlying.length); 55.20 + this.maxDenseLength = Math.max(MAX_DENSE_LENGTH, underlying.length()); 55.21 this.sparseMap = sparseMap; 55.22 } 55.23 55.24 @Override 55.25 public ArrayData copy() { 55.26 - return new SparseArrayData(underlying.copy(), length, new TreeMap<>(sparseMap)); 55.27 + return new SparseArrayData(underlying.copy(), length(), new TreeMap<>(sparseMap)); 55.28 } 55.29 55.30 @Override 55.31 public Object[] asObjectArray() { 55.32 - final int len = (int)Math.min(length, Integer.MAX_VALUE); 55.33 - final int underlyingLength = (int)Math.min(len, underlying.length); 55.34 + final int len = (int)Math.min(length(), Integer.MAX_VALUE); 55.35 + final int underlyingLength = (int)Math.min(len, underlying.length()); 55.36 final Object[] objArray = new Object[len]; 55.37 55.38 for (int i = 0; i < underlyingLength; i++) { 55.39 @@ -104,14 +104,15 @@ 55.40 } 55.41 55.42 sparseMap = newSparseMap; 55.43 - setLength(Math.max(length - by, 0)); 55.44 + setLength(Math.max(length() - by, 0)); 55.45 } 55.46 55.47 @Override 55.48 public ArrayData shiftRight(final int by) { 55.49 final TreeMap<Long, Object> newSparseMap = new TreeMap<>(); 55.50 - if (underlying.length + by > maxDenseLength) { 55.51 - for (long i = maxDenseLength - by; i < underlying.length; i++) { 55.52 + final long len = underlying.length(); 55.53 + if (len + by > maxDenseLength) { 55.54 + for (long i = maxDenseLength - by; i < len; i++) { 55.55 if (underlying.has((int) i)) { 55.56 newSparseMap.put(Long.valueOf(i + by), underlying.getObject((int) i)); 55.57 } 55.58 @@ -127,23 +128,23 @@ 55.59 } 55.60 55.61 sparseMap = newSparseMap; 55.62 - setLength(length + by); 55.63 + setLength(length() + by); 55.64 55.65 return this; 55.66 } 55.67 55.68 @Override 55.69 public ArrayData ensure(final long safeIndex) { 55.70 - if (safeIndex < maxDenseLength && underlying.length <= safeIndex) { 55.71 + if (safeIndex < maxDenseLength && underlying.length() <= safeIndex) { 55.72 underlying = underlying.ensure(safeIndex); 55.73 } 55.74 - setLength(Math.max(safeIndex + 1, length)); 55.75 + setLength(Math.max(safeIndex + 1, length())); 55.76 return this; 55.77 } 55.78 55.79 @Override 55.80 public ArrayData shrink(final long newLength) { 55.81 - if (newLength < underlying.length) { 55.82 + if (newLength < underlying.length()) { 55.83 underlying = underlying.shrink(newLength); 55.84 underlying.setLength(newLength); 55.85 sparseMap.clear(); 55.86 @@ -160,11 +161,11 @@ 55.87 if (index >= 0 && index < maxDenseLength) { 55.88 ensure(index); 55.89 underlying = underlying.set(index, value, strict); 55.90 - setLength(Math.max(underlying.length, length)); 55.91 + setLength(Math.max(underlying.length(), length())); 55.92 } else { 55.93 final Long longIndex = indexToKey(index); 55.94 sparseMap.put(longIndex, value); 55.95 - setLength(Math.max(longIndex + 1, length)); 55.96 + setLength(Math.max(longIndex + 1, length())); 55.97 } 55.98 55.99 return this; 55.100 @@ -175,11 +176,11 @@ 55.101 if (index >= 0 && index < maxDenseLength) { 55.102 ensure(index); 55.103 underlying = underlying.set(index, value, strict); 55.104 - setLength(Math.max(underlying.length, length)); 55.105 + setLength(Math.max(underlying.length(), length())); 55.106 } else { 55.107 final Long longIndex = indexToKey(index); 55.108 sparseMap.put(longIndex, value); 55.109 - setLength(Math.max(longIndex + 1, length)); 55.110 + setLength(Math.max(longIndex + 1, length())); 55.111 } 55.112 return this; 55.113 } 55.114 @@ -189,11 +190,11 @@ 55.115 if (index >= 0 && index < maxDenseLength) { 55.116 ensure(index); 55.117 underlying = underlying.set(index, value, strict); 55.118 - setLength(Math.max(underlying.length, length)); 55.119 + setLength(Math.max(underlying.length(), length())); 55.120 } else { 55.121 final Long longIndex = indexToKey(index); 55.122 sparseMap.put(longIndex, value); 55.123 - setLength(Math.max(longIndex + 1, length)); 55.124 + setLength(Math.max(longIndex + 1, length())); 55.125 } 55.126 return this; 55.127 } 55.128 @@ -203,11 +204,11 @@ 55.129 if (index >= 0 && index < maxDenseLength) { 55.130 ensure(index); 55.131 underlying = underlying.set(index, value, strict); 55.132 - setLength(Math.max(underlying.length, length)); 55.133 + setLength(Math.max(underlying.length(), length())); 55.134 } else { 55.135 final Long longIndex = indexToKey(index); 55.136 sparseMap.put(longIndex, value); 55.137 - setLength(Math.max(longIndex + 1, length)); 55.138 + setLength(Math.max(longIndex + 1, length())); 55.139 } 55.140 return this; 55.141 } 55.142 @@ -294,7 +295,7 @@ 55.143 @Override 55.144 public boolean has(final int index) { 55.145 if (index >= 0 && index < maxDenseLength) { 55.146 - return index < underlying.length && underlying.has(index); 55.147 + return index < underlying.length() && underlying.has(index); 55.148 } 55.149 55.150 return sparseMap.containsKey(indexToKey(index)); 55.151 @@ -303,7 +304,7 @@ 55.152 @Override 55.153 public ArrayData delete(final int index) { 55.154 if (index >= 0 && index < maxDenseLength) { 55.155 - if (index < underlying.length) { 55.156 + if (index < underlying.length()) { 55.157 underlying = underlying.delete(index); 55.158 } 55.159 } else { 55.160 @@ -315,8 +316,8 @@ 55.161 55.162 @Override 55.163 public ArrayData delete(final long fromIndex, final long toIndex) { 55.164 - if (fromIndex < maxDenseLength && fromIndex < underlying.length) { 55.165 - underlying = underlying.delete(fromIndex, Math.min(toIndex, underlying.length - 1)); 55.166 + if (fromIndex < maxDenseLength && fromIndex < underlying.length()) { 55.167 + underlying = underlying.delete(fromIndex, Math.min(toIndex, underlying.length() - 1)); 55.168 } 55.169 if (toIndex >= maxDenseLength) { 55.170 sparseMap.subMap(fromIndex, true, toIndex, true).clear(); 55.171 @@ -336,30 +337,34 @@ 55.172 55.173 @Override 55.174 public Object pop() { 55.175 - if (length == 0) { 55.176 + final long len = length(); 55.177 + final long underlyingLen = underlying.length(); 55.178 + if (len == 0) { 55.179 return ScriptRuntime.UNDEFINED; 55.180 } 55.181 - if (length == underlying.length) { 55.182 + if (len == underlyingLen) { 55.183 final Object result = underlying.pop(); 55.184 - setLength(underlying.length); 55.185 + setLength(underlying.length()); 55.186 return result; 55.187 } 55.188 - setLength(length - 1); 55.189 - final Long key = Long.valueOf(length); 55.190 + setLength(len - 1); 55.191 + final Long key = Long.valueOf(len - 1); 55.192 return sparseMap.containsKey(key) ? sparseMap.remove(key) : ScriptRuntime.UNDEFINED; 55.193 } 55.194 55.195 @Override 55.196 public ArrayData slice(final long from, final long to) { 55.197 - assert to <= length; 55.198 - final long start = from < 0 ? (from + length) : from; 55.199 + assert to <= length(); 55.200 + final long start = from < 0 ? (from + length()) : from; 55.201 final long newLength = to - start; 55.202 55.203 + final long underlyingLength = underlying.length(); 55.204 + 55.205 if (start >= 0 && to <= maxDenseLength) { 55.206 - if (newLength <= underlying.length) { 55.207 + if (newLength <= underlyingLength) { 55.208 return underlying.slice(from, to); 55.209 } 55.210 - return underlying.slice(from, to).ensure(newLength - 1).delete(underlying.length, newLength); 55.211 + return underlying.slice(from, to).ensure(newLength - 1).delete(underlyingLength, newLength); 55.212 } 55.213 55.214 ArrayData sliced = EMPTY_ARRAY; 55.215 @@ -369,13 +374,13 @@ 55.216 sliced = sliced.set((int)(i - start), getObject((int)i), false); 55.217 } 55.218 } 55.219 - assert sliced.length == newLength; 55.220 + assert sliced.length() == newLength; 55.221 return sliced; 55.222 } 55.223 55.224 @Override 55.225 public long nextIndex(final long index) { 55.226 - if (index < underlying.length - 1) { 55.227 + if (index < underlying.length() - 1) { 55.228 return underlying.nextIndex(index); 55.229 } 55.230 55.231 @@ -383,6 +388,7 @@ 55.232 if (nextKey != null) { 55.233 return nextKey; 55.234 } 55.235 - return length; 55.236 + 55.237 + return length(); 55.238 } 55.239 }
56.1 --- a/src/jdk/nashorn/internal/runtime/arrays/TypedArrayData.java Wed Nov 12 13:47:23 2014 -0800 56.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/TypedArrayData.java Fri Nov 14 10:03:48 2014 -0800 56.3 @@ -58,7 +58,7 @@ 56.4 * @return element length 56.5 */ 56.6 public final int getElementLength() { 56.7 - return (int)length; 56.8 + return (int)length(); 56.9 } 56.10 56.11 /** 56.12 @@ -119,7 +119,7 @@ 56.13 56.14 @Override 56.15 public final boolean has(final int index) { 56.16 - return 0 <= index && index < length; 56.17 + return 0 <= index && index < length(); 56.18 } 56.19 56.20 @Override
57.1 --- a/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java Wed Nov 12 13:47:23 2014 -0800 57.2 +++ b/src/jdk/nashorn/internal/runtime/arrays/UndefinedArrayFilter.java Fri Nov 14 10:03:48 2014 -0800 57.3 @@ -39,8 +39,7 @@ 57.4 57.5 UndefinedArrayFilter(final ArrayData underlying) { 57.6 super(underlying); 57.7 - 57.8 - this.undefined = new BitVector(underlying.length); 57.9 + this.undefined = new BitVector(underlying.length()); 57.10 } 57.11 57.12 @Override 57.13 @@ -80,25 +79,24 @@ 57.14 @Override 57.15 public void shiftLeft(final int by) { 57.16 super.shiftLeft(by); 57.17 - undefined.shiftLeft(by, length); 57.18 + undefined.shiftLeft(by, length()); 57.19 } 57.20 57.21 @Override 57.22 public ArrayData shiftRight(final int by) { 57.23 super.shiftRight(by); 57.24 - undefined.shiftRight(by, length); 57.25 - 57.26 + undefined.shiftRight(by, length()); 57.27 return this; 57.28 } 57.29 57.30 @Override 57.31 public ArrayData ensure(final long safeIndex) { 57.32 - if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length) { 57.33 + if (safeIndex >= SparseArrayData.MAX_DENSE_LENGTH && safeIndex >= length()) { 57.34 return new SparseArrayData(this, safeIndex + 1); 57.35 } 57.36 57.37 super.ensure(safeIndex); 57.38 - undefined.resize(length); 57.39 + undefined.resize(length()); 57.40 57.41 return this; 57.42 } 57.43 @@ -106,8 +104,7 @@ 57.44 @Override 57.45 public ArrayData shrink(final long newLength) { 57.46 super.shrink(newLength); 57.47 - undefined.resize(length); 57.48 - 57.49 + undefined.resize(length()); 57.50 return this; 57.51 } 57.52 57.53 @@ -216,7 +213,7 @@ 57.54 57.55 @Override 57.56 public Object pop() { 57.57 - final long index = length - 1; 57.58 + final long index = length() - 1; 57.59 57.60 if (super.has((int)index)) { 57.61 final boolean isUndefined = undefined.isSet(index); 57.62 @@ -233,7 +230,7 @@ 57.63 final ArrayData newArray = underlying.slice(from, to); 57.64 final UndefinedArrayFilter newFilter = new UndefinedArrayFilter(newArray); 57.65 newFilter.getUndefined().copy(undefined); 57.66 - newFilter.getUndefined().shiftLeft(from, newFilter.length); 57.67 + newFilter.getUndefined().shiftLeft(from, newFilter.length()); 57.68 57.69 return newFilter; 57.70 }
58.1 --- a/src/jdk/nashorn/internal/runtime/events/RecompilationEvent.java Wed Nov 12 13:47:23 2014 -0800 58.2 +++ b/src/jdk/nashorn/internal/runtime/events/RecompilationEvent.java Fri Nov 14 10:03:48 2014 -0800 58.3 @@ -47,10 +47,9 @@ 58.4 * @param level logging level 58.5 * @param rewriteException rewriteException wrapped by this RuntimEvent 58.6 * @param returnValue rewriteException return value - as we don't want to make 58.7 - * {@link RewriteException#getReturnValueNonDestructive()} public, we pass it as 58.8 + * {@code RewriteException.getReturnValueNonDestructive()} public, we pass it as 58.9 * an extra parameter, rather than querying the getter from another package. 58.10 */ 58.11 - @SuppressWarnings("javadoc") 58.12 public RecompilationEvent(final Level level, final RewriteException rewriteException, final Object returnValue) { 58.13 super(level, rewriteException); 58.14 assert Context.getContext().getLogger(RecompilableScriptFunctionData.class).isEnabled() :
59.1 --- a/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Wed Nov 12 13:47:23 2014 -0800 59.2 +++ b/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java Fri Nov 14 10:03:48 2014 -0800 59.3 @@ -42,6 +42,8 @@ 59.4 import jdk.internal.dynalink.linker.GuardedInvocation; 59.5 import jdk.internal.dynalink.linker.LinkRequest; 59.6 import jdk.internal.dynalink.linker.LinkerServices; 59.7 +import jdk.internal.dynalink.linker.MethodTypeConversionStrategy; 59.8 +import jdk.internal.dynalink.support.TypeUtilities; 59.9 import jdk.nashorn.api.scripting.JSObject; 59.10 import jdk.nashorn.internal.codegen.CompilerConstants.Call; 59.11 import jdk.nashorn.internal.codegen.ObjectClassGenerator; 59.12 @@ -106,6 +108,12 @@ 59.13 return OptimisticReturnFilters.filterOptimisticReturnValue(inv, desc).asType(linkerServices, desc.getMethodType()); 59.14 } 59.15 }); 59.16 + factory.setAutoConversionStrategy(new MethodTypeConversionStrategy() { 59.17 + @Override 59.18 + public MethodHandle asType(final MethodHandle target, final MethodType newType) { 59.19 + return unboxReturnType(target, newType); 59.20 + } 59.21 + }); 59.22 final int relinkThreshold = Options.getIntProperty("nashorn.unstable.relink.threshold", NASHORN_DEFAULT_UNSTABLE_RELINK_THRESHOLD); 59.23 if (relinkThreshold > -1) { 59.24 factory.setUnstableRelinkThreshold(relinkThreshold); 59.25 @@ -420,4 +428,29 @@ 59.26 static GuardedInvocation asTypeSafeReturn(final GuardedInvocation inv, final LinkerServices linkerServices, final CallSiteDescriptor desc) { 59.27 return inv == null ? null : inv.asTypeSafeReturn(linkerServices, desc.getMethodType()); 59.28 } 59.29 + 59.30 + /** 59.31 + * Adapts the return type of the method handle with {@code explicitCastArguments} when it is an unboxing 59.32 + * conversion. This will ensure that nulls are unwrapped to false or 0. 59.33 + * @param target the target method handle 59.34 + * @param newType the desired new type. Note that this method does not adapt the method handle completely to the 59.35 + * new type, it only adapts the return type; this is allowed as per 59.36 + * {@link DynamicLinkerFactory#setAutoConversionStrategy(MethodTypeConversionStrategy)}, which is what this method 59.37 + * is used for. 59.38 + * @return the method handle with adapted return type, if it required an unboxing conversion. 59.39 + */ 59.40 + private static MethodHandle unboxReturnType(final MethodHandle target, final MethodType newType) { 59.41 + final MethodType targetType = target.type(); 59.42 + final Class<?> oldReturnType = targetType.returnType(); 59.43 + if (TypeUtilities.isWrapperType(oldReturnType)) { 59.44 + final Class<?> newReturnType = newType.returnType(); 59.45 + if (newReturnType.isPrimitive()) { 59.46 + // The contract of setAutoConversionStrategy is such that the difference between newType and targetType 59.47 + // can only be JLS method invocation conversions. 59.48 + assert TypeUtilities.isMethodInvocationConvertible(oldReturnType, newReturnType); 59.49 + return MethodHandles.explicitCastArguments(target, targetType.changeReturnType(newReturnType)); 59.50 + } 59.51 + } 59.52 + return target; 59.53 + } 59.54 }
60.1 --- a/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Wed Nov 12 13:47:23 2014 -0800 60.2 +++ b/src/jdk/nashorn/internal/runtime/linker/BrowserJSObjectLinker.java Fri Nov 14 10:03:48 2014 -0800 60.3 @@ -25,8 +25,10 @@ 60.4 60.5 package jdk.nashorn.internal.runtime.linker; 60.6 60.7 -import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.*; 60.8 - 60.9 +import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETMEMBER; 60.10 +import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_GETSLOT; 60.11 +import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETMEMBER; 60.12 +import static jdk.nashorn.internal.runtime.linker.BrowserJSObjectLinker.JSObjectHandles.JSOBJECT_SETSLOT; 60.13 import java.lang.invoke.MethodHandle; 60.14 import java.lang.invoke.MethodHandles; 60.15 import jdk.internal.dynalink.CallSiteDescriptor; 60.16 @@ -114,12 +116,10 @@ 60.17 case "getMethod": 60.18 if (c > 2) { 60.19 return findGetMethod(desc); 60.20 - } else { 60.21 - // For indexed get, we want GuardedInvocation from beans linker and pass it. 60.22 - // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access. 60.23 - final GuardedInvocation beanInv = nashornBeansLinker.getGuardedInvocation(request, linkerServices); 60.24 - return findGetIndexMethod(beanInv); 60.25 } 60.26 + // For indexed get, we want GuardedInvocation from beans linker and pass it. 60.27 + // BrowserJSObjectLinker.get uses this fallback getter for explicit signature method access. 60.28 + return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices)); 60.29 case "setProp": 60.30 case "setElem": 60.31 return c > 2 ? findSetMethod(desc) : findSetIndexMethod(); 60.32 @@ -166,9 +166,8 @@ 60.33 final String name = (String)key; 60.34 if (name.indexOf('(') != -1) { 60.35 return fallback.invokeExact(jsobj, key); 60.36 - } else { 60.37 - return JSOBJECT_GETMEMBER.invokeExact(jsobj, (String)key); 60.38 } 60.39 + return JSOBJECT_GETMEMBER.invokeExact(jsobj, (String)key); 60.40 } 60.41 return null; 60.42 }
61.1 --- a/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Wed Nov 12 13:47:23 2014 -0800 61.2 +++ b/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java Fri Nov 14 10:03:48 2014 -0800 61.3 @@ -120,12 +120,10 @@ 61.4 case "getMethod": 61.5 if (c > 2) { 61.6 return findGetMethod(desc); 61.7 - } else { 61.8 - // For indexed get, we want get GuardedInvocation beans linker and pass it. 61.9 - // JSObjectLinker.get uses this fallback getter for explicit signature method access. 61.10 - final GuardedInvocation beanInv = nashornBeansLinker.getGuardedInvocation(request, linkerServices); 61.11 - return findGetIndexMethod(beanInv); 61.12 } 61.13 + // For indexed get, we want get GuardedInvocation beans linker and pass it. 61.14 + // JSObjectLinker.get uses this fallback getter for explicit signature method access. 61.15 + return findGetIndexMethod(nashornBeansLinker.getGuardedInvocation(request, linkerServices)); 61.16 case "setProp": 61.17 case "setElem": 61.18 return c > 2 ? findSetMethod(desc) : findSetIndexMethod(); 61.19 @@ -192,9 +190,8 @@ 61.20 // get with method name and signature. delegate it to beans linker! 61.21 if (name.indexOf('(') != -1) { 61.22 return fallback.invokeExact(jsobj, key); 61.23 - } else { 61.24 - return ((JSObject)jsobj).getMember(name); 61.25 } 61.26 + return ((JSObject)jsobj).getMember(name); 61.27 } 61.28 return null; 61.29 }
62.1 --- a/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Wed Nov 12 13:47:23 2014 -0800 62.2 +++ b/src/jdk/nashorn/internal/runtime/linker/NashornBeansLinker.java Fri Nov 14 10:03:48 2014 -0800 62.3 @@ -53,15 +53,34 @@ 62.4 // Object type arguments of Java method calls, field set and array set. 62.5 private static final boolean MIRROR_ALWAYS = Options.getBooleanProperty("nashorn.mirror.always", true); 62.6 62.7 - private static final MethodHandle EXPORT_ARGUMENT = new Lookup(MethodHandles.lookup()).findOwnStatic("exportArgument", Object.class, Object.class); 62.8 - private static final MethodHandle EXPORT_NATIVE_ARRAY = new Lookup(MethodHandles.lookup()).findOwnStatic("exportNativeArray", Object.class, NativeArray.class); 62.9 - private static final MethodHandle EXPORT_SCRIPT_OBJECT = new Lookup(MethodHandles.lookup()).findOwnStatic("exportScriptObject", Object.class, ScriptObject.class); 62.10 - private static final MethodHandle IMPORT_RESULT = new Lookup(MethodHandles.lookup()).findOwnStatic("importResult", Object.class, Object.class); 62.11 + private static final MethodHandle EXPORT_ARGUMENT; 62.12 + private static final MethodHandle EXPORT_NATIVE_ARRAY; 62.13 + private static final MethodHandle EXPORT_SCRIPT_OBJECT; 62.14 + private static final MethodHandle IMPORT_RESULT; 62.15 + private static final MethodHandle FILTER_CONSSTRING; 62.16 + 62.17 + static { 62.18 + final Lookup lookup = new Lookup(MethodHandles.lookup()); 62.19 + EXPORT_ARGUMENT = lookup.findOwnStatic("exportArgument", Object.class, Object.class); 62.20 + EXPORT_NATIVE_ARRAY = lookup.findOwnStatic("exportNativeArray", Object.class, NativeArray.class); 62.21 + EXPORT_SCRIPT_OBJECT = lookup.findOwnStatic("exportScriptObject", Object.class, ScriptObject.class); 62.22 + IMPORT_RESULT = lookup.findOwnStatic("importResult", Object.class, Object.class); 62.23 + FILTER_CONSSTRING = lookup.findOwnStatic("consStringFilter", Object.class, Object.class); 62.24 + } 62.25 62.26 private final BeansLinker beansLinker = new BeansLinker(); 62.27 62.28 @Override 62.29 public GuardedInvocation getGuardedInvocation(final LinkRequest linkRequest, final LinkerServices linkerServices) throws Exception { 62.30 + if (linkRequest.getReceiver() instanceof ConsString) { 62.31 + // In order to treat ConsString like a java.lang.String we need a link request with a string receiver. 62.32 + final Object[] arguments = linkRequest.getArguments(); 62.33 + arguments[0] = ""; 62.34 + final LinkRequest forgedLinkRequest = linkRequest.replaceArguments(linkRequest.getCallSiteDescriptor(), arguments); 62.35 + final GuardedInvocation invocation = getGuardedInvocation(beansLinker, forgedLinkRequest, linkerServices); 62.36 + // If an invocation is found we add a filter that makes it work for both Strings and ConsStrings. 62.37 + return invocation == null ? null : invocation.filterArguments(0, FILTER_CONSSTRING); 62.38 + } 62.39 return getGuardedInvocation(beansLinker, linkRequest, linkerServices); 62.40 } 62.41 62.42 @@ -113,6 +132,11 @@ 62.43 return ScriptUtils.unwrap(arg); 62.44 } 62.45 62.46 + @SuppressWarnings("unused") 62.47 + private static Object consStringFilter(final Object arg) { 62.48 + return arg instanceof ConsString ? arg.toString() : arg; 62.49 + } 62.50 + 62.51 private static class NashornBeansLinkerServices implements LinkerServices { 62.52 private final LinkerServices linkerServices; 62.53
63.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java Wed Nov 12 13:47:23 2014 -0800 63.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Analyser.java Fri Nov 14 10:03:48 2014 -0800 63.3 @@ -27,7 +27,6 @@ 63.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isMultiline; 63.5 import static jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode.newAltNode; 63.6 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.isRepeatInfinite; 63.7 - 63.8 import java.util.HashSet; 63.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 63.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 63.11 @@ -53,6 +52,7 @@ 63.12 super(env, chars, p, end); 63.13 } 63.14 63.15 + @SuppressWarnings("unused") 63.16 protected final void compile() { 63.17 if (Config.DEBUG) { 63.18 Config.log.println(new String(chars, getBegin(), getEnd())); 63.19 @@ -76,7 +76,9 @@ 63.20 63.21 root = setupTree(root, 0); 63.22 if (Config.DEBUG_PARSE_TREE) { 63.23 - if (Config.DEBUG_PARSE_TREE_RAW) Config.log.println("<TREE>"); 63.24 + if (Config.DEBUG_PARSE_TREE_RAW) { 63.25 + Config.log.println("<TREE>"); 63.26 + } 63.27 root.verifyTree(new HashSet<Node>(), env.reg.warnings); 63.28 Config.log.println(root + "\n"); 63.29 } 63.30 @@ -94,7 +96,9 @@ 63.31 63.32 regex.clearOptimizeInfo(); 63.33 63.34 - if (!Config.DONT_OPTIMIZE) setOptimizedInfoFromTree(root); 63.35 + if (!Config.DONT_OPTIMIZE) { 63.36 + setOptimizedInfoFromTree(root); 63.37 + } 63.38 63.39 env.memNodes = null; 63.40 63.41 @@ -110,7 +114,9 @@ 63.42 63.43 if (Config.DEBUG_COMPILE) { 63.44 Config.log.println("stack used: " + regex.stackNeeded); 63.45 - if (Config.USE_STRING_TEMPLATES) Config.log.print("templates: " + regex.templateNum + "\n"); 63.46 + if (Config.USE_STRING_TEMPLATES) { 63.47 + Config.log.print("templates: " + regex.templateNum + "\n"); 63.48 + } 63.49 Config.log.println(new ByteCodePrinter(regex).byteCodeListToString()); 63.50 63.51 } // DEBUG_COMPILE 63.52 @@ -136,7 +142,9 @@ 63.53 ConsAltNode can = (ConsAltNode)node; 63.54 do { 63.55 final int v = quantifiersMemoryInfo(can.car); 63.56 - if (v > info) info = v; 63.57 + if (v > info) { 63.58 + info = v; 63.59 + } 63.60 } while ((can = can.cdr) != null); 63.61 break; 63.62 63.63 @@ -182,7 +190,9 @@ 63.64 switch (node.getType()) { 63.65 case NodeType.BREF: 63.66 final BackRefNode br = (BackRefNode)node; 63.67 - if (br.isRecursion()) break; 63.68 + if (br.isRecursion()) { 63.69 + break; 63.70 + } 63.71 63.72 if (br.backRef > env.numMem) { 63.73 throw new ValueException(ERR_INVALID_BACKREF); 63.74 @@ -249,6 +259,9 @@ 63.75 case EncloseType.STOP_BACKTRACK: 63.76 min = getMinMatchLength(en.target); 63.77 break; 63.78 + 63.79 + default: 63.80 + break; 63.81 } // inner switch 63.82 break; 63.83 63.84 @@ -276,7 +289,9 @@ 63.85 ConsAltNode an = (ConsAltNode)node; 63.86 do { 63.87 final int tmax = getMaxMatchLength(an.car); 63.88 - if (max < tmax) max = tmax; 63.89 + if (max < tmax) { 63.90 + max = tmax; 63.91 + } 63.92 } while ((an = an.cdr) != null); 63.93 break; 63.94 63.95 @@ -304,7 +319,9 @@ 63.96 throw new ValueException(ERR_INVALID_BACKREF); 63.97 } 63.98 final int tmax = getMaxMatchLength(env.memNodes[br.backRef]); 63.99 - if (max < tmax) max = tmax; 63.100 + if (max < tmax) { 63.101 + max = tmax; 63.102 + } 63.103 break; 63.104 63.105 case NodeType.QTFR: 63.106 @@ -338,6 +355,9 @@ 63.107 case EncloseType.STOP_BACKTRACK: 63.108 max = getMaxMatchLength(en.target); 63.109 break; 63.110 + 63.111 + default: 63.112 + break; 63.113 } // inner switch 63.114 break; 63.115 63.116 @@ -355,8 +375,8 @@ 63.117 return getCharLengthTree(node, 0); 63.118 } 63.119 63.120 - private int getCharLengthTree(final Node node, int level) { 63.121 - level++; 63.122 + private int getCharLengthTree(final Node node, final int levelp) { 63.123 + final int level = levelp + 1; 63.124 63.125 int len = 0; 63.126 returnCode = 0; 63.127 @@ -366,7 +386,9 @@ 63.128 ConsAltNode ln = (ConsAltNode)node; 63.129 do { 63.130 final int tlen = getCharLengthTree(ln.car, level); 63.131 - if (returnCode == 0) len = MinMaxLen.distanceAdd(len, tlen); 63.132 + if (returnCode == 0) { 63.133 + len = MinMaxLen.distanceAdd(len, tlen); 63.134 + } 63.135 } while (returnCode == 0 && (ln = ln.cdr) != null); 63.136 break; 63.137 63.138 @@ -378,7 +400,9 @@ 63.139 while (returnCode == 0 && (an = an.cdr) != null) { 63.140 final int tlen2 = getCharLengthTree(an.car, level); 63.141 if (returnCode == 0) { 63.142 - if (tlen != tlen2) varLen = true; 63.143 + if (tlen != tlen2) { 63.144 + varLen = true; 63.145 + } 63.146 } 63.147 } 63.148 63.149 @@ -404,7 +428,9 @@ 63.150 final QuantifierNode qn = (QuantifierNode)node; 63.151 if (qn.lower == qn.upper) { 63.152 tlen = getCharLengthTree(qn.target, level); 63.153 - if (returnCode == 0) len = MinMaxLen.distanceMultiply(tlen, qn.lower); 63.154 + if (returnCode == 0) { 63.155 + len = MinMaxLen.distanceMultiply(tlen, qn.lower); 63.156 + } 63.157 } else { 63.158 returnCode = GET_CHAR_LEN_VARLEN; 63.159 } 63.160 @@ -435,6 +461,9 @@ 63.161 case EncloseType.STOP_BACKTRACK: 63.162 len = getCharLengthTree(en.target, level); 63.163 break; 63.164 + 63.165 + default: 63.166 + break; 63.167 } // inner switch 63.168 break; 63.169 63.170 @@ -448,7 +477,9 @@ 63.171 } 63.172 63.173 /* x is not included y ==> 1 : 0 */ 63.174 - private boolean isNotIncluded(Node x, Node y) { 63.175 + private static boolean isNotIncluded(final Node xn, final Node yn) { 63.176 + Node x = xn; 63.177 + Node y = yn; 63.178 Node tmp; 63.179 63.180 // !retry:! 63.181 @@ -492,10 +523,14 @@ 63.182 boolean v = xc.bs.at(i); 63.183 if ((v && !xc.isNot()) || (!v && xc.isNot())) { 63.184 v = yc.bs.at(i); 63.185 - if ((v && !yc.isNot()) || (!v && yc.isNot())) return false; 63.186 + if ((v && !yc.isNot()) || (!v && yc.isNot())) { 63.187 + return false; 63.188 + } 63.189 } 63.190 } 63.191 - if ((xc.mbuf == null && !xc.isNot()) || yc.mbuf == null && !yc.isNot()) return true; 63.192 + if ((xc.mbuf == null && !xc.isNot()) || yc.mbuf == null && !yc.isNot()) { 63.193 + return true; 63.194 + } 63.195 return false; 63.196 // break; not reached 63.197 63.198 @@ -514,7 +549,9 @@ 63.199 63.200 case NodeType.STR: 63.201 final StringNode xs = (StringNode)x; 63.202 - if (xs.length() == 0) break; 63.203 + if (xs.length() == 0) { 63.204 + break; 63.205 + } 63.206 63.207 switch (yType) { 63.208 63.209 @@ -526,13 +563,16 @@ 63.210 case NodeType.STR: 63.211 final StringNode ys = (StringNode)y; 63.212 int len = xs.length(); 63.213 - if (len > ys.length()) len = ys.length(); 63.214 + if (len > ys.length()) { 63.215 + len = ys.length(); 63.216 + } 63.217 if (xs.isAmbig() || ys.isAmbig()) { 63.218 /* tiny version */ 63.219 return false; 63.220 - } else { 63.221 - for (int i=0, p=ys.p, q=xs.p; i<len; i++, p++, q++) { 63.222 - if (ys.chars[p] != xs.chars[q]) return true; 63.223 + } 63.224 + for (int i=0, pt=ys.p, q=xs.p; i<len; i++, pt++, q++) { 63.225 + if (ys.chars[pt] != xs.chars[q]) { 63.226 + return true; 63.227 } 63.228 } 63.229 break; 63.230 @@ -542,6 +582,8 @@ 63.231 } // inner switch 63.232 63.233 break; // case NodeType.STR 63.234 + default: 63.235 + break; 63.236 63.237 } // switch 63.238 63.239 @@ -561,7 +603,9 @@ 63.240 63.241 case NodeType.CTYPE: 63.242 case NodeType.CCLASS: 63.243 - if (!exact) n = node; 63.244 + if (!exact) { 63.245 + n = node; 63.246 + } 63.247 break; 63.248 63.249 case NodeType.LIST: 63.250 @@ -570,7 +614,10 @@ 63.251 63.252 case NodeType.STR: 63.253 final StringNode sn = (StringNode)node; 63.254 - if (sn.end <= sn.p) break; // ??? 63.255 + if (sn.end <= sn.p) 63.256 + { 63.257 + break; // ??? 63.258 + } 63.259 63.260 if (exact && !sn.isRaw() && isIgnoreCase(regex.options)){ 63.261 // nothing 63.262 @@ -605,12 +652,17 @@ 63.263 case EncloseType.STOP_BACKTRACK: 63.264 n = getHeadValueNode(en.target, exact); 63.265 break; 63.266 + 63.267 + default: 63.268 + break; 63.269 } // inner switch 63.270 break; 63.271 63.272 case NodeType.ANCHOR: 63.273 final AnchorNode an = (AnchorNode)node; 63.274 - if (an.type == AnchorType.PREC_READ) n = getHeadValueNode(an.target, exact); 63.275 + if (an.type == AnchorType.PREC_READ) { 63.276 + n = getHeadValueNode(an.target, exact); 63.277 + } 63.278 break; 63.279 63.280 default: 63.281 @@ -622,7 +674,9 @@ 63.282 63.283 // true: invalid 63.284 private boolean checkTypeTree(final Node node, final int typeMask, final int encloseMask, final int anchorMask) { 63.285 - if ((node.getType2Bit() & typeMask) == 0) return true; 63.286 + if ((node.getType2Bit() & typeMask) == 0) { 63.287 + return true; 63.288 + } 63.289 63.290 boolean invalid = false; 63.291 63.292 @@ -641,15 +695,21 @@ 63.293 63.294 case NodeType.ENCLOSE: 63.295 final EncloseNode en = (EncloseNode)node; 63.296 - if ((en.type & encloseMask) == 0) return true; 63.297 + if ((en.type & encloseMask) == 0) { 63.298 + return true; 63.299 + } 63.300 invalid = checkTypeTree(en.target, typeMask, encloseMask, anchorMask); 63.301 break; 63.302 63.303 case NodeType.ANCHOR: 63.304 final AnchorNode an = (AnchorNode)node; 63.305 - if ((an.type & anchorMask) == 0) return true; 63.306 + if ((an.type & anchorMask) == 0) { 63.307 + return true; 63.308 + } 63.309 63.310 - if (an.target != null) invalid = checkTypeTree(an.target, typeMask, encloseMask, anchorMask); 63.311 + if (an.target != null) { 63.312 + invalid = checkTypeTree(an.target, typeMask, encloseMask, anchorMask); 63.313 + } 63.314 break; 63.315 63.316 default: 63.317 @@ -664,7 +724,8 @@ 63.318 (?<=A|B) ==> (?<=A)|(?<=B) 63.319 (?<!A|B) ==> (?<!A)(?<!B) 63.320 */ 63.321 - private Node divideLookBehindAlternatives(Node node) { 63.322 + private Node divideLookBehindAlternatives(final Node nodep) { 63.323 + Node node = nodep; 63.324 final AnchorNode an = (AnchorNode)node; 63.325 final int anchorType = an.type; 63.326 Node head = an.target; 63.327 @@ -699,7 +760,7 @@ 63.328 private Node setupLookBehind(final Node node) { 63.329 final AnchorNode an = (AnchorNode)node; 63.330 final int len = getCharLengthTree(an.target); 63.331 - switch(returnCode) { 63.332 + switch (returnCode) { 63.333 case 0: 63.334 an.charLength = len; 63.335 break; 63.336 @@ -708,14 +769,17 @@ 63.337 case GET_CHAR_LEN_TOP_ALT_VARLEN: 63.338 if (syntax.differentLengthAltLookBehind()) { 63.339 return divideLookBehindAlternatives(node); 63.340 - } else { 63.341 - throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 63.342 } 63.343 + throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 63.344 + default: 63.345 + break; 63.346 } 63.347 return node; 63.348 } 63.349 63.350 - private void nextSetup(Node node, final Node nextNode) { 63.351 + private void nextSetup(final Node nodep, final Node nextNode) { 63.352 + Node node = nodep; 63.353 + 63.354 // retry: 63.355 retry: while(true) { 63.356 63.357 @@ -762,7 +826,7 @@ 63.358 } 63.359 63.360 private void updateStringNodeCaseFoldMultiByte(final StringNode sn) { 63.361 - final char[] chars = sn.chars; 63.362 + final char[] ch = sn.chars; 63.363 final int end = sn.end; 63.364 value = sn.p; 63.365 int sp = 0; 63.366 @@ -770,15 +834,15 @@ 63.367 63.368 while (value < end) { 63.369 final int ovalue = value; 63.370 - buf = EncodingHelper.toLowerCase(chars[value++]); 63.371 + buf = EncodingHelper.toLowerCase(ch[value++]); 63.372 63.373 - if (chars[ovalue] != buf) { 63.374 + if (ch[ovalue] != buf) { 63.375 63.376 char[] sbuf = new char[sn.length() << 1]; 63.377 - System.arraycopy(chars, sn.p, sbuf, 0, ovalue - sn.p); 63.378 + System.arraycopy(ch, sn.p, sbuf, 0, ovalue - sn.p); 63.379 value = ovalue; 63.380 while (value < end) { 63.381 - buf = EncodingHelper.toLowerCase(chars[value++]); 63.382 + buf = EncodingHelper.toLowerCase(ch[value++]); 63.383 if (sp >= sbuf.length) { 63.384 final char[]tmp = new char[sbuf.length << 1]; 63.385 System.arraycopy(sbuf, 0, tmp, 0, sbuf.length); 63.386 @@ -798,8 +862,8 @@ 63.387 updateStringNodeCaseFoldMultiByte(sn); 63.388 } 63.389 63.390 - private Node expandCaseFoldMakeRemString(final char[] chars, final int p, final int end) { 63.391 - final StringNode node = new StringNode(chars, p, end); 63.392 + private Node expandCaseFoldMakeRemString(final char[] ch, final int pp, final int end) { 63.393 + final StringNode node = new StringNode(ch, pp, end); 63.394 63.395 updateStringNodeCaseFold(node); 63.396 node.setAmbig(); 63.397 @@ -807,7 +871,7 @@ 63.398 return node; 63.399 } 63.400 63.401 - private boolean expandCaseFoldStringAlt(final int itemNum, final char[] items, 63.402 + private static boolean expandCaseFoldStringAlt(final int itemNum, final char[] items, 63.403 final char[] chars, final int p, final int slen, final int end, final ObjPtr<Node> node) { 63.404 63.405 ConsAltNode altNode; 63.406 @@ -833,59 +897,68 @@ 63.407 private Node expandCaseFoldString(final Node node) { 63.408 final StringNode sn = (StringNode)node; 63.409 63.410 - if (sn.isAmbig() || sn.length() <= 0) return node; 63.411 + if (sn.isAmbig() || sn.length() <= 0) { 63.412 + return node; 63.413 + } 63.414 63.415 - final char[] chars = sn.chars; 63.416 - int p = sn.p; 63.417 + final char[] chars1 = sn.chars; 63.418 + int pt = sn.p; 63.419 final int end = sn.end; 63.420 int altNum = 1; 63.421 63.422 - ConsAltNode topRoot = null, root = null; 63.423 + ConsAltNode topRoot = null, r = null; 63.424 + @SuppressWarnings("unused") 63.425 final ObjPtr<Node> prevNode = new ObjPtr<Node>(); 63.426 StringNode stringNode = null; 63.427 63.428 - while (p < end) { 63.429 - final char[] items = EncodingHelper.caseFoldCodesByString(regex.caseFoldFlag, chars[p]); 63.430 + while (pt < end) { 63.431 + final char[] items = EncodingHelper.caseFoldCodesByString(regex.caseFoldFlag, chars1[pt]); 63.432 63.433 if (items.length == 0) { 63.434 if (stringNode == null) { 63.435 - if (root == null && prevNode.p != null) { 63.436 - topRoot = root = ConsAltNode.listAdd(null, prevNode.p); 63.437 + if (r == null && prevNode.p != null) { 63.438 + topRoot = r = ConsAltNode.listAdd(null, prevNode.p); 63.439 } 63.440 63.441 prevNode.p = stringNode = new StringNode(); // onig_node_new_str(NULL, NULL); 63.442 63.443 - if (root != null) ConsAltNode.listAdd(root, stringNode); 63.444 + if (r != null) { 63.445 + ConsAltNode.listAdd(r, stringNode); 63.446 + } 63.447 63.448 } 63.449 63.450 - stringNode.cat(chars, p, p + 1); 63.451 + stringNode.cat(chars1, pt, pt + 1); 63.452 } else { 63.453 altNum *= (items.length + 1); 63.454 - if (altNum > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) break; 63.455 - 63.456 - if (root == null && prevNode.p != null) { 63.457 - topRoot = root = ConsAltNode.listAdd(null, prevNode.p); 63.458 + if (altNum > THRESHOLD_CASE_FOLD_ALT_FOR_EXPANSION) { 63.459 + break; 63.460 } 63.461 63.462 - expandCaseFoldStringAlt(items.length, items, chars, p, 1, end, prevNode); 63.463 - if (root != null) ConsAltNode.listAdd(root, prevNode.p); 63.464 + if (r == null && prevNode.p != null) { 63.465 + topRoot = r = ConsAltNode.listAdd(null, prevNode.p); 63.466 + } 63.467 + 63.468 + expandCaseFoldStringAlt(items.length, items, chars1, pt, 1, end, prevNode); 63.469 + if (r != null) { 63.470 + ConsAltNode.listAdd(r, prevNode.p); 63.471 + } 63.472 stringNode = null; 63.473 } 63.474 - p++; 63.475 + pt++; 63.476 } 63.477 63.478 - if (p < end) { 63.479 - final Node srem = expandCaseFoldMakeRemString(chars, p, end); 63.480 + if (pt < end) { 63.481 + final Node srem = expandCaseFoldMakeRemString(chars1, pt, end); 63.482 63.483 - if (prevNode.p != null && root == null) { 63.484 - topRoot = root = ConsAltNode.listAdd(null, prevNode.p); 63.485 + if (prevNode.p != null && r == null) { 63.486 + topRoot = r = ConsAltNode.listAdd(null, prevNode.p); 63.487 } 63.488 63.489 - if (root == null) { 63.490 + if (r == null) { 63.491 prevNode.p = srem; 63.492 } else { 63.493 - ConsAltNode.listAdd(root, srem); 63.494 + ConsAltNode.listAdd(r, srem); 63.495 } 63.496 } 63.497 /* ending */ 63.498 @@ -909,7 +982,10 @@ 63.499 5. find invalid patterns in look-behind. 63.500 6. expand repeated string. 63.501 */ 63.502 - protected final Node setupTree(Node node, int state) { 63.503 + protected final Node setupTree(final Node nodep, final int statep) { 63.504 + Node node = nodep; 63.505 + int state = statep; 63.506 + 63.507 restart: while (true) { 63.508 switch (node.getType()) { 63.509 case NodeType.LIST: 63.510 @@ -958,7 +1034,9 @@ 63.511 final QuantifierNode qn = (QuantifierNode)node; 63.512 Node target = qn.target; 63.513 63.514 - if ((state & IN_REPEAT) != 0) qn.setInRepeat(); 63.515 + if ((state & IN_REPEAT) != 0) { 63.516 + qn.setInRepeat(); 63.517 + } 63.518 63.519 if (isRepeatInfinite(qn.upper) || qn.lower >= 1) { 63.520 final int d = getMinMatchLength(target); 63.521 @@ -966,14 +1044,18 @@ 63.522 qn.targetEmptyInfo = TargetInfo.IS_EMPTY; 63.523 if (Config.USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT) { 63.524 final int info = quantifiersMemoryInfo(target); 63.525 - if (info > 0) qn.targetEmptyInfo = info; 63.526 + if (info > 0) { 63.527 + qn.targetEmptyInfo = info; 63.528 + } 63.529 } // USE_INFINITE_REPEAT_MONOMANIAC_MEM_STATUS_CHECK 63.530 // strange stuff here (turned off) 63.531 } 63.532 } 63.533 63.534 state |= IN_REPEAT; 63.535 - if (qn.lower != qn.upper) state |= IN_VAR_REPEAT; 63.536 + if (qn.lower != qn.upper) { 63.537 + state |= IN_VAR_REPEAT; 63.538 + } 63.539 63.540 target = setupTree(target, state); 63.541 63.542 @@ -1035,11 +1117,16 @@ 63.543 final QuantifierNode tqn = (QuantifierNode)en.target; 63.544 if (isRepeatInfinite(tqn.upper) && tqn.lower <= 1 && tqn.greedy) { 63.545 /* (?>a*), a*+ etc... */ 63.546 - if (tqn.target.isSimple()) en.setStopBtSimpleRepeat(); 63.547 + if (tqn.target.isSimple()) { 63.548 + en.setStopBtSimpleRepeat(); 63.549 + } 63.550 } 63.551 } 63.552 break; 63.553 63.554 + default: 63.555 + break; 63.556 + 63.557 } // inner switch 63.558 break; 63.559 63.560 @@ -1059,7 +1146,9 @@ 63.561 throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 63.562 } 63.563 node = setupLookBehind(node); 63.564 - if (node.getType() != NodeType.ANCHOR) continue restart; 63.565 + if (node.getType() != NodeType.ANCHOR) { 63.566 + continue restart; 63.567 + } 63.568 setupTree(((AnchorNode)node).target, state); 63.569 break; 63.570 63.571 @@ -1068,12 +1157,19 @@ 63.572 throw new SyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 63.573 } 63.574 node = setupLookBehind(node); 63.575 - if (node.getType() != NodeType.ANCHOR) continue restart; 63.576 + if (node.getType() != NodeType.ANCHOR) { 63.577 + continue restart; 63.578 + } 63.579 setupTree(((AnchorNode)node).target, (state | IN_NOT)); 63.580 break; 63.581 63.582 + default: 63.583 + break; 63.584 + 63.585 } // inner switch 63.586 break; 63.587 + default: 63.588 + break; 63.589 } // switch 63.590 return node; 63.591 } // restart: while 63.592 @@ -1191,7 +1287,9 @@ 63.593 opt.expr.copy(nopt.exm); 63.594 } 63.595 opt.expr.reachEnd = false; 63.596 - if (nopt.map.value > 0) opt.map.copy(nopt.map); 63.597 + if (nopt.map.value > 0) { 63.598 + opt.map.copy(nopt.map); 63.599 + } 63.600 break; 63.601 63.602 case AnchorType.PREC_READ_NOT: 63.603 @@ -1199,6 +1297,9 @@ 63.604 case AnchorType.LOOK_BEHIND_NOT: 63.605 break; 63.606 63.607 + default: 63.608 + break; 63.609 + 63.610 } // inner switch 63.611 break; 63.612 } 63.613 @@ -1282,8 +1383,12 @@ 63.614 if (++en.optCount > MAX_NODE_OPT_INFO_REF_COUNT) { 63.615 int min = 0; 63.616 int max = MinMaxLen.INFINITE_DISTANCE; 63.617 - if (en.isMinFixed()) min = en.minLength; 63.618 - if (en.isMaxFixed()) max = en.maxLength; 63.619 + if (en.isMinFixed()) { 63.620 + min = en.minLength; 63.621 + } 63.622 + if (en.isMaxFixed()) { 63.623 + max = en.maxLength; 63.624 + } 63.625 opt.length.set(min, max); 63.626 } else { // USE_SUBEXP_CALL 63.627 optimizeNodeLeft(en.target, opt, oenv); 63.628 @@ -1298,6 +1403,9 @@ 63.629 case EncloseType.STOP_BACKTRACK: 63.630 optimizeNodeLeft(en.target, opt, oenv); 63.631 break; 63.632 + 63.633 + default: 63.634 + break; 63.635 } // inner switch 63.636 break; 63.637 } 63.638 @@ -1307,6 +1415,7 @@ 63.639 } // switch 63.640 } 63.641 63.642 + @SuppressWarnings("unused") 63.643 protected final void setOptimizedInfoFromTree(final Node node) { 63.644 final NodeOptInfo opt = new NodeOptInfo(); 63.645 final OptEnvironment oenv = new OptEnvironment(); 63.646 @@ -1347,7 +1456,9 @@ 63.647 regex.setSubAnchor(opt.map.anchor); 63.648 } else { 63.649 regex.subAnchor |= opt.anchor.leftAnchor & AnchorType.BEGIN_LINE; 63.650 - if (opt.length.max == 0) regex.subAnchor |= opt.anchor.rightAnchor & AnchorType.END_LINE; 63.651 + if (opt.length.max == 0) { 63.652 + regex.subAnchor |= opt.anchor.rightAnchor & AnchorType.END_LINE; 63.653 + } 63.654 } 63.655 63.656 if (Config.DEBUG_COMPILE || Config.DEBUG_MATCH) {
64.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ApplyCaseFold.java Wed Nov 12 13:47:23 2014 -0800 64.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ApplyCaseFold.java Fri Nov 14 10:03:48 2014 -0800 64.3 @@ -24,7 +24,7 @@ 64.4 final class ApplyCaseFold { 64.5 64.6 // i_apply_case_fold 64.7 - public void apply(final int from, final int to, final Object o) { 64.8 + public static void apply(final int from, final int to, final Object o) { 64.9 final ApplyCaseFoldArg arg = (ApplyCaseFoldArg)o; 64.10 64.11 final ScanEnvironment env = arg.env; 64.12 @@ -45,7 +45,9 @@ 64.13 } else { 64.14 if (inCC) { 64.15 if (to >= BitSet.SINGLE_BYTE_SIZE) { 64.16 - if (cc.isNot()) cc.clearNotFlag(); 64.17 + if (cc.isNot()) { 64.18 + cc.clearNotFlag(); 64.19 + } 64.20 cc.addCodeRange(env, to, to); 64.21 } else { 64.22 if (cc.isNot()) {
65.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ApplyCaseFoldArg.java Wed Nov 12 13:47:23 2014 -0800 65.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ApplyCaseFoldArg.java Fri Nov 14 10:03:48 2014 -0800 65.3 @@ -22,6 +22,7 @@ 65.4 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 65.5 import jdk.nashorn.internal.runtime.regexp.joni.ast.ConsAltNode; 65.6 65.7 +@SuppressWarnings("javadoc") 65.8 public final class ApplyCaseFoldArg { 65.9 final ScanEnvironment env; 65.10 final CClassNode cc;
66.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Wed Nov 12 13:47:23 2014 -0800 66.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Fri Nov 14 10:03:48 2014 -0800 66.3 @@ -24,7 +24,6 @@ 66.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; 66.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isMultiline; 66.6 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.isRepeatInfinite; 66.7 - 66.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 66.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 66.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 66.11 @@ -98,15 +97,15 @@ 66.12 } while ((aln = aln.cdr) != null); 66.13 } 66.14 66.15 - private boolean isNeedStrLenOpExact(final int op) { 66.16 + private static boolean isNeedStrLenOpExact(final int op) { 66.17 return op == OPCode.EXACTN || op == OPCode.EXACTN_IC; 66.18 } 66.19 66.20 - private boolean opTemplated(final int op) { 66.21 + private static boolean opTemplated(final int op) { 66.22 return isNeedStrLenOpExact(op); 66.23 } 66.24 66.25 - private int selectStrOpcode(final int strLength, final boolean ignoreCase) { 66.26 + private static int selectStrOpcode(final int strLength, final boolean ignoreCase) { 66.27 int op; 66.28 66.29 if (ignoreCase) { 66.30 @@ -139,7 +138,7 @@ 66.31 compileTree(node); 66.32 66.33 if (emptyInfo != 0) { 66.34 - switch(emptyInfo) { 66.35 + switch (emptyInfo) { 66.36 case TargetInfo.IS_EMPTY: 66.37 addOpcode(OPCode.NULL_CHECK_END); 66.38 break; 66.39 @@ -149,13 +148,15 @@ 66.40 case TargetInfo.IS_EMPTY_REC: 66.41 addOpcode(OPCode.NULL_CHECK_END_MEMST_PUSH); 66.42 break; 66.43 + default: 66.44 + break; 66.45 } // switch 66.46 66.47 addMemNum(savedNumNullCheck); /* NULL CHECK ID */ 66.48 } 66.49 } 66.50 66.51 - private int addCompileStringlength(final char[] chars, final int p, final int strLength, final boolean ignoreCase) { 66.52 + private static int addCompileStringlength(final char[] chars, final int p, final int strLength, final boolean ignoreCase) { 66.53 final int op = selectStrOpcode(strLength, ignoreCase); 66.54 int len = OPSize.OPCODE; 66.55 66.56 @@ -163,7 +164,9 @@ 66.57 // string length, template index, template string pointer 66.58 len += OPSize.LENGTH + OPSize.INDEX + OPSize.INDEX; 66.59 } else { 66.60 - if (isNeedStrLenOpExact(op)) len += OPSize.LENGTH; 66.61 + if (isNeedStrLenOpExact(op)) { 66.62 + len += OPSize.LENGTH; 66.63 + } 66.64 len += strLength; 66.65 } 66.66 return len; 66.67 @@ -187,9 +190,11 @@ 66.68 } 66.69 } 66.70 66.71 - private int compileLengthStringNode(final Node node) { 66.72 + private static int compileLengthStringNode(final Node node) { 66.73 final StringNode sn = (StringNode)node; 66.74 - if (sn.length() <= 0) return 0; 66.75 + if (sn.length() <= 0) { 66.76 + return 0; 66.77 + } 66.78 final boolean ambig = sn.isAmbig(); 66.79 66.80 int p, prev; 66.81 @@ -210,8 +215,10 @@ 66.82 return rlen; 66.83 } 66.84 66.85 - private int compileLengthStringRawNode(final StringNode sn) { 66.86 - if (sn.length() <= 0) return 0; 66.87 + private static int compileLengthStringRawNode(final StringNode sn) { 66.88 + if (sn.length() <= 0) { 66.89 + return 0; 66.90 + } 66.91 return addCompileStringlength(sn.chars, sn.p, sn.length(), false); 66.92 } 66.93 66.94 @@ -220,8 +227,10 @@ 66.95 addInts(mbuf.p, mbuf.used); 66.96 } 66.97 66.98 - private int compileLengthCClassNode(final CClassNode cc) { 66.99 - if (cc.isShare()) return OPSize.OPCODE + OPSize.POINTER; 66.100 + private static int compileLengthCClassNode(final CClassNode cc) { 66.101 + if (cc.isShare()) { 66.102 + return OPSize.OPCODE + OPSize.POINTER; 66.103 + } 66.104 66.105 int len; 66.106 if (cc.mbuf == null) { 66.107 @@ -360,9 +369,8 @@ 66.108 if (qn.greedy && infinite) { 66.109 if (qn.nextHeadExact != null) { 66.110 return OPSize.ANYCHAR_STAR_PEEK_NEXT + tlen * qn.lower; 66.111 - } else { 66.112 - return OPSize.ANYCHAR_STAR + tlen * qn.lower; 66.113 } 66.114 + return OPSize.ANYCHAR_STAR + tlen * qn.lower; 66.115 } 66.116 } 66.117 66.118 @@ -425,14 +433,13 @@ 66.119 final StringNode sn = (StringNode)qn.nextHeadExact; 66.120 addChars(sn.chars, sn.p, 1); 66.121 return; 66.122 + } 66.123 + if (isMultiline(regex.options)) { 66.124 + addOpcode(OPCode.ANYCHAR_ML_STAR); 66.125 } else { 66.126 - if (isMultiline(regex.options)) { 66.127 - addOpcode(OPCode.ANYCHAR_ML_STAR); 66.128 - } else { 66.129 - addOpcode(OPCode.ANYCHAR_STAR); 66.130 - } 66.131 - return; 66.132 + addOpcode(OPCode.ANYCHAR_STAR); 66.133 } 66.134 + return; 66.135 } 66.136 66.137 int modTLen; 66.138 @@ -510,9 +517,8 @@ 66.139 66.140 if (isDynamic(prev ^ node.option)) { 66.141 return OPSize.SET_OPTION_PUSH + OPSize.SET_OPTION + OPSize.FAIL + tlen + OPSize.SET_OPTION; 66.142 - } else { 66.143 - return tlen; 66.144 } 66.145 + return tlen; 66.146 } 66.147 66.148 @Override 66.149 @@ -675,13 +681,15 @@ 66.150 break; 66.151 66.152 case AnchorType.WORD_BEGIN: 66.153 - if (Config.USE_WORD_BEGIN_END) 66.154 + if (Config.USE_WORD_BEGIN_END) { 66.155 addOpcode(OPCode.WORD_BEGIN); 66.156 + } 66.157 break; 66.158 66.159 case AnchorType.WORD_END: 66.160 - if (Config.USE_WORD_BEGIN_END) 66.161 + if (Config.USE_WORD_BEGIN_END) { 66.162 addOpcode(OPCode.WORD_END); 66.163 + } 66.164 break; 66.165 66.166 case AnchorType.PREC_READ: 66.167 @@ -701,7 +709,9 @@ 66.168 addOpcode(OPCode.LOOK_BEHIND); 66.169 if (node.charLength < 0) { 66.170 n = analyser.getCharLengthTree(node.target); 66.171 - if (analyser.returnCode != 0) newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 66.172 + if (analyser.returnCode != 0) { 66.173 + newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 66.174 + } 66.175 } else { 66.176 n = node.charLength; 66.177 } 66.178 @@ -714,7 +724,9 @@ 66.179 addOpcodeRelAddr(OPCode.PUSH_LOOK_BEHIND_NOT, len + OPSize.FAIL_LOOK_BEHIND_NOT); 66.180 if (node.charLength < 0) { 66.181 n = analyser.getCharLengthTree(node.target); 66.182 - if (analyser.returnCode != 0) newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 66.183 + if (analyser.returnCode != 0) { 66.184 + newSyntaxException(ERR_INVALID_LOOK_BEHIND_PATTERN); 66.185 + } 66.186 } else { 66.187 n = node.charLength; 66.188 } 66.189 @@ -796,7 +808,9 @@ 66.190 private void ensure(final int size) { 66.191 if (size >= code.length) { 66.192 int length = code.length << 1; 66.193 - while (length <= size) length <<= 1; 66.194 + while (length <= size) { 66.195 + length <<= 1; 66.196 + } 66.197 final int[]tmp = new int[length]; 66.198 System.arraycopy(code, 0, tmp, 0, code.length); 66.199 code = tmp; 66.200 @@ -829,11 +843,14 @@ 66.201 regex.operands[regex.operandLength++] = o; 66.202 } 66.203 66.204 - private void addChars(final char[] chars, int p ,final int length) { 66.205 + private void addChars(final char[] chars, final int pp ,final int length) { 66.206 ensure(codeLength + length); 66.207 + int p = pp; 66.208 final int end = p + length; 66.209 66.210 - while (p < end) code[codeLength++] = chars[p++]; 66.211 + while (p < end) { 66.212 + code[codeLength++] = chars[p++]; 66.213 + } 66.214 } 66.215 66.216 private void addInts(final int[]ints, final int length) { 66.217 @@ -876,6 +893,9 @@ 66.218 case OPCode.CALL: 66.219 case OPCode.RETURN: // it will appear only with CALL though 66.220 regex.stackNeeded = true; 66.221 + break; 66.222 + default: 66.223 + break; 66.224 } 66.225 } 66.226
67.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Wed Nov 12 13:47:23 2014 -0800 67.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Fri Nov 14 10:03:48 2014 -0800 67.3 @@ -19,6 +19,7 @@ 67.4 */ 67.5 package jdk.nashorn.internal.runtime.regexp.joni; 67.6 67.7 +@SuppressWarnings("javadoc") 67.8 public final class BitSet { 67.9 static final int BITS_PER_BYTE = 8; 67.10 public static final int SINGLE_BYTE_SIZE = (1 << BITS_PER_BYTE); 67.11 @@ -34,7 +35,9 @@ 67.12 final StringBuilder buffer = new StringBuilder(); 67.13 buffer.append("BitSet"); 67.14 for (int i=0; i<SINGLE_BYTE_SIZE; i++) { 67.15 - if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) buffer.append("\n "); 67.16 + if ((i % (SINGLE_BYTE_SIZE / BITS_TO_STRING_WRAP)) == 0) { 67.17 + buffer.append("\n "); 67.18 + } 67.19 buffer.append(at(i) ? "1" : "0"); 67.20 } 67.21 return buffer.toString(); 67.22 @@ -53,44 +56,62 @@ 67.23 } 67.24 67.25 public void clear() { 67.26 - for (int i=0; i<BITSET_SIZE; i++) bits[i]=0; 67.27 + for (int i=0; i<BITSET_SIZE; i++) { 67.28 + bits[i]=0; 67.29 + } 67.30 } 67.31 67.32 public boolean isEmpty() { 67.33 for (int i=0; i<BITSET_SIZE; i++) { 67.34 - if (bits[i] != 0) return false; 67.35 + if (bits[i] != 0) { 67.36 + return false; 67.37 + } 67.38 } 67.39 return true; 67.40 } 67.41 67.42 public void setRange(final int from, final int to) { 67.43 - for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) set(i); 67.44 + for (int i=from; i<=to && i < SINGLE_BYTE_SIZE; i++) { 67.45 + set(i); 67.46 + } 67.47 } 67.48 67.49 public void invert() { 67.50 - for (int i=0; i<BITSET_SIZE; i++) bits[i] = ~bits[i]; 67.51 + for (int i=0; i<BITSET_SIZE; i++) { 67.52 + bits[i] = ~bits[i]; 67.53 + } 67.54 } 67.55 67.56 public void invertTo(final BitSet to) { 67.57 - for (int i=0; i<BITSET_SIZE; i++) to.bits[i] = ~bits[i]; 67.58 + for (int i=0; i<BITSET_SIZE; i++) { 67.59 + to.bits[i] = ~bits[i]; 67.60 + } 67.61 } 67.62 67.63 public void and(final BitSet other) { 67.64 - for (int i=0; i<BITSET_SIZE; i++) bits[i] &= other.bits[i]; 67.65 + for (int i=0; i<BITSET_SIZE; i++) { 67.66 + bits[i] &= other.bits[i]; 67.67 + } 67.68 } 67.69 67.70 public void or(final BitSet other) { 67.71 - for (int i=0; i<BITSET_SIZE; i++) bits[i] |= other.bits[i]; 67.72 + for (int i=0; i<BITSET_SIZE; i++) { 67.73 + bits[i] |= other.bits[i]; 67.74 + } 67.75 } 67.76 67.77 public void copy(final BitSet other) { 67.78 - for (int i=0; i<BITSET_SIZE; i++) bits[i] = other.bits[i]; 67.79 + for (int i=0; i<BITSET_SIZE; i++) { 67.80 + bits[i] = other.bits[i]; 67.81 + } 67.82 } 67.83 67.84 public int numOn() { 67.85 int num = 0; 67.86 for (int i=0; i<SINGLE_BYTE_SIZE; i++) { 67.87 - if (at(i)) num++; 67.88 + if (at(i)) { 67.89 + num++; 67.90 + } 67.91 } 67.92 return num; 67.93 } 67.94 @@ -99,9 +120,12 @@ 67.95 return 1 << (pos % SINGLE_BYTE_SIZE); 67.96 } 67.97 67.98 - private static int log2(int n){ 67.99 + private static int log2(final int np) { 67.100 int log = 0; 67.101 - while ((n >>>= 1) != 0) log++; 67.102 + int n = np; 67.103 + while ((n >>>= 1) != 0) { 67.104 + log++; 67.105 + } 67.106 return log; 67.107 } 67.108
68.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitStatus.java Wed Nov 12 13:47:23 2014 -0800 68.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitStatus.java Fri Nov 14 10:03:48 2014 -0800 68.3 @@ -34,7 +34,8 @@ 68.4 return (n < BIT_STATUS_BITS_NUM ? stats & (1 << n) : (stats & 1)) != 0; 68.5 } 68.6 68.7 - public static int bsOnAt(int stats, final int n) { 68.8 + public static int bsOnAt(final int statsp, final int n) { 68.9 + int stats = statsp; 68.10 if (n < BIT_STATUS_BITS_NUM) { 68.11 stats |= (1 << n); 68.12 } else { 68.13 @@ -43,12 +44,7 @@ 68.14 return stats; 68.15 } 68.16 68.17 - public static int bsOnOff(int v, final int f, final boolean negative) { 68.18 - if (negative) { 68.19 - v &= ~f; 68.20 - } else { 68.21 - v |= f; 68.22 - } 68.23 - return v; 68.24 + public static int bsOnOff(final int v, final int f, final boolean negative) { 68.25 + return negative ? (v & ~f) : (v | f); 68.26 } 68.27 }
69.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Wed Nov 12 13:47:23 2014 -0800 69.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Fri Nov 14 10:03:48 2014 -0800 69.3 @@ -27,10 +27,8 @@ 69.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isNotBol; 69.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isNotEol; 69.6 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isPosixRegion; 69.7 - 69.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 69.9 import jdk.nashorn.internal.runtime.regexp.joni.constants.OPCode; 69.10 -import jdk.nashorn.internal.runtime.regexp.joni.constants.OPSize; 69.11 import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder; 69.12 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 69.13 import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; 69.14 @@ -52,8 +50,8 @@ 69.15 this.code = regex.code; 69.16 } 69.17 69.18 - private boolean stringCmpIC(final int caseFlodFlag, int s1, final IntHolder ps2, final int mbLen, final int textEnd) { 69.19 - 69.20 + private boolean stringCmpIC(final int caseFlodFlag, final int s1p, final IntHolder ps2, final int mbLen, final int textEnd) { 69.21 + int s1 = s1p; 69.22 int s2 = ps2.value; 69.23 final int end1 = s1 + mbLen; 69.24 69.25 @@ -83,12 +81,16 @@ 69.26 Config.log.printf("%4d", (s - str)).print("> \""); 69.27 int q, i; 69.28 for (i=0, q=s; i<7 && q<end && s>=0; i++) { 69.29 - if (q < end) Config.log.print(new String(new char[]{chars[q++]})); 69.30 + if (q < end) { 69.31 + Config.log.print(new String(new char[]{chars[q++]})); 69.32 + } 69.33 } 69.34 - final String str = q < end ? "...\"" : "\""; 69.35 - q += str.length(); 69.36 - Config.log.print(str); 69.37 - for (i=0; i<20-(q-s);i++) Config.log.print(" "); 69.38 + final String string = q < end ? "...\"" : "\""; 69.39 + q += string.length(); 69.40 + Config.log.print(string); 69.41 + for (i=0; i<20-(q-s);i++) { 69.42 + Config.log.print(" "); 69.43 + } 69.44 final StringBuilder sb = new StringBuilder(); 69.45 new ByteCodePrinter(regex).compiledByteCodeToString(sb, ip); 69.46 Config.log.println(sb.toString()); 69.47 @@ -96,28 +98,34 @@ 69.48 } 69.49 69.50 @Override 69.51 - protected final int matchAt(final int range, final int sstart, final int sprev) { 69.52 - this.range = range; 69.53 - this.sstart = sstart; 69.54 - this.sprev = sprev; 69.55 + protected final int matchAt(final int r, final int ss, final int sp) { 69.56 + this.range = r; 69.57 + this.sstart = ss; 69.58 + this.sprev = sp; 69.59 69.60 stk = 0; 69.61 ip = 0; 69.62 69.63 - if (Config.DEBUG_MATCH) debugMatchBegin(); 69.64 + if (Config.DEBUG_MATCH) { 69.65 + debugMatchBegin(); 69.66 + } 69.67 69.68 init(); 69.69 69.70 bestLen = -1; 69.71 - s = sstart; 69.72 + s = ss; 69.73 69.74 - final int[]code = this.code; 69.75 + final int[] c = this.code; 69.76 while (true) { 69.77 - if (Config.DEBUG_MATCH) debugMatchLoop(); 69.78 + if (Config.DEBUG_MATCH) { 69.79 + debugMatchLoop(); 69.80 + } 69.81 69.82 sbegin = s; 69.83 - switch (code[ip++]) { 69.84 - case OPCode.END: if (opEnd()) return finish(); break; 69.85 + switch (c[ip++]) { 69.86 + case OPCode.END: if (opEnd()) { 69.87 + return finish(); 69.88 + } break; 69.89 case OPCode.EXACT1: opExact1(); break; 69.90 case OPCode.EXACT2: opExact2(); continue; 69.91 case OPCode.EXACT3: opExact3(); continue; 69.92 @@ -358,10 +366,14 @@ 69.93 final char[] bs = regex.templates[code[ip++]]; 69.94 int ps = code[ip++]; 69.95 69.96 - while (tlen-- > 0) if (bs[ps++] != chars[s++]) {opFail(); return;} 69.97 + while (tlen-- > 0) { 69.98 + if (bs[ps++] != chars[s++]) {opFail(); return;} 69.99 + } 69.100 69.101 } else { 69.102 - while (tlen-- > 0) if (code[ip++] != chars[s++]) {opFail(); return;} 69.103 + while (tlen-- > 0) { 69.104 + if (code[ip++] != chars[s++]) {opFail(); return;} 69.105 + } 69.106 } 69.107 sprev = s - 1; 69.108 } 69.109 @@ -380,10 +392,14 @@ 69.110 final char[] bs = regex.templates[code[ip++]]; 69.111 int ps = code[ip++]; 69.112 69.113 - while (tlen-- > 0) if (bs[ps++] != EncodingHelper.toLowerCase(chars[s++])) {opFail(); return;} 69.114 + while (tlen-- > 0) { 69.115 + if (bs[ps++] != EncodingHelper.toLowerCase(chars[s++])) {opFail(); return;} 69.116 + } 69.117 } else { 69.118 69.119 - while (tlen-- > 0) if (code[ip++] != EncodingHelper.toLowerCase(chars[s++])) {opFail(); return;} 69.120 + while (tlen-- > 0) { 69.121 + if (code[ip++] != EncodingHelper.toLowerCase(chars[s++])) {opFail(); return;} 69.122 + } 69.123 } 69.124 sprev = s - 1; 69.125 } 69.126 @@ -402,11 +418,15 @@ 69.127 69.128 private boolean isInClassMB() { 69.129 final int tlen = code[ip++]; 69.130 - if (s >= range) return false; 69.131 + if (s >= range) { 69.132 + return false; 69.133 + } 69.134 final int ss = s; 69.135 s++; 69.136 final int c = chars[ss]; 69.137 - if (!EncodingHelper.isInCodeRange(code, ip, c)) return false; 69.138 + if (!EncodingHelper.isInCodeRange(code, ip, c)) { 69.139 + return false; 69.140 + } 69.141 ip += tlen; 69.142 return true; 69.143 } 69.144 @@ -444,7 +464,9 @@ 69.145 final int tlen = code[ip++]; 69.146 69.147 if (!(s + 1 <= range)) { 69.148 - if (s >= range) return false; 69.149 + if (s >= range) { 69.150 + return false; 69.151 + } 69.152 s = end; 69.153 ip += tlen; 69.154 return true; 69.155 @@ -454,7 +476,9 @@ 69.156 s++; 69.157 final int c = chars[ss]; 69.158 69.159 - if (EncodingHelper.isInCodeRange(code, ip, c)) return false; 69.160 + if (EncodingHelper.isInCodeRange(code, ip, c)) { 69.161 + return false; 69.162 + } 69.163 ip += tlen; 69.164 return true; 69.165 } 69.166 @@ -511,10 +535,10 @@ 69.167 } 69.168 69.169 private void opAnyCharStar() { 69.170 - final char[] chars = this.chars; 69.171 + final char[] ch = this.chars; 69.172 while (s < range) { 69.173 pushAlt(ip, s, sprev); 69.174 - if (isNewLine(chars, s, end)) {opFail(); return;} 69.175 + if (isNewLine(ch, s, end)) {opFail(); return;} 69.176 sprev = s; 69.177 s++; 69.178 } 69.179 @@ -532,11 +556,13 @@ 69.180 69.181 private void opAnyCharStarPeekNext() { 69.182 final char c = (char)code[ip]; 69.183 - final char[] chars = this.chars; 69.184 + final char[] ch = this.chars; 69.185 69.186 while (s < range) { 69.187 - final char b = chars[s]; 69.188 - if (c == b) pushAlt(ip + 1, s, sprev); 69.189 + final char b = ch[s]; 69.190 + if (c == b) { 69.191 + pushAlt(ip + 1, s, sprev); 69.192 + } 69.193 if (isNewLine(b)) {opFail(); return;} 69.194 sprev = s; 69.195 s++; 69.196 @@ -547,10 +573,12 @@ 69.197 69.198 private void opAnyCharMLStarPeekNext() { 69.199 final char c = (char)code[ip]; 69.200 - final char[] chars = this.chars; 69.201 + final char[] ch = this.chars; 69.202 69.203 while (s < range) { 69.204 - if (c == chars[s]) pushAlt(ip + 1, s, sprev); 69.205 + if (c == ch[s]) { 69.206 + pushAlt(ip + 1, s, sprev); 69.207 + } 69.208 sprev = s; 69.209 s++; 69.210 } 69.211 @@ -592,29 +620,39 @@ 69.212 69.213 private void opWordBegin() { 69.214 if (s < range && EncodingHelper.isWord(chars[s])) { 69.215 - if (s == str || !EncodingHelper.isWord(chars[sprev])) return; 69.216 + if (s == str || !EncodingHelper.isWord(chars[sprev])) { 69.217 + return; 69.218 + } 69.219 } 69.220 opFail(); 69.221 } 69.222 69.223 private void opWordEnd() { 69.224 if (s != str && EncodingHelper.isWord(chars[sprev])) { 69.225 - if (s == end || !EncodingHelper.isWord(chars[s])) return; 69.226 + if (s == end || !EncodingHelper.isWord(chars[s])) { 69.227 + return; 69.228 + } 69.229 } 69.230 opFail(); 69.231 } 69.232 69.233 private void opBeginBuf() { 69.234 - if (s != str) opFail(); 69.235 + if (s != str) { 69.236 + opFail(); 69.237 + } 69.238 } 69.239 69.240 private void opEndBuf() { 69.241 - if (s != end) opFail(); 69.242 + if (s != end) { 69.243 + opFail(); 69.244 + } 69.245 } 69.246 69.247 private void opBeginLine() { 69.248 if (s == str) { 69.249 - if (isNotBol(msaOptions)) opFail(); 69.250 + if (isNotBol(msaOptions)) { 69.251 + opFail(); 69.252 + } 69.253 return; 69.254 } else if (isNewLine(chars, sprev, end) && s != end) { 69.255 return; 69.256 @@ -626,13 +664,16 @@ 69.257 if (s == end) { 69.258 if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) { 69.259 if (str == end || !isNewLine(chars, sprev, end)) { 69.260 - if (isNotEol(msaOptions)) opFail(); 69.261 + if (isNotEol(msaOptions)) { 69.262 + opFail(); 69.263 + } 69.264 } 69.265 return; 69.266 - } else { 69.267 - if (isNotEol(msaOptions)) opFail(); 69.268 - return; 69.269 } 69.270 + if (isNotEol(msaOptions)) { 69.271 + opFail(); 69.272 + } 69.273 + return; 69.274 } else if (isNewLine(chars, s, end)) { 69.275 return; 69.276 } 69.277 @@ -643,13 +684,16 @@ 69.278 if (s == end) { 69.279 if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) { 69.280 if (str == end || !isNewLine(chars, sprev, end)) { 69.281 - if (isNotEol(msaOptions)) opFail(); 69.282 + if (isNotEol(msaOptions)) { 69.283 + opFail(); 69.284 + } 69.285 } 69.286 return; 69.287 - } else { 69.288 - if (isNotEol(msaOptions)) opFail(); 69.289 - return; 69.290 } 69.291 + if (isNotEol(msaOptions)) { 69.292 + opFail(); 69.293 + } 69.294 + return; 69.295 } else if (isNewLine(chars, s, end) && s + 1 == end) { 69.296 return; 69.297 } 69.298 @@ -657,7 +701,9 @@ 69.299 } 69.300 69.301 private void opBeginPosition() { 69.302 - if (s != msaStart) opFail(); 69.303 + if (s != msaStart) { 69.304 + opFail(); 69.305 + } 69.306 } 69.307 69.308 private void opMemoryStartPush() { 69.309 @@ -726,11 +772,15 @@ 69.310 sprev = s; 69.311 69.312 // STRING_CMP 69.313 - while(n-- > 0) if (chars[pstart++] != chars[s++]) {opFail(); return;} 69.314 + while(n-- > 0) { 69.315 + if (chars[pstart++] != chars[s++]) {opFail(); return;} 69.316 + } 69.317 69.318 // beyond string check 69.319 if (sprev < range) { 69.320 - while (sprev + 1 < s) sprev++; 69.321 + while (sprev + 1 < s) { 69.322 + sprev++; 69.323 + } 69.324 } 69.325 } 69.326 69.327 @@ -764,7 +814,9 @@ 69.328 s = value; 69.329 69.330 // if (sprev < chars.length) 69.331 - while (sprev + 1 < s) sprev++; 69.332 + while (sprev + 1 < s) { 69.333 + sprev++; 69.334 + } 69.335 } 69.336 69.337 private void opBackRefMulti() { 69.338 @@ -773,7 +825,9 @@ 69.339 int i; 69.340 loop:for (i=0; i<tlen; i++) { 69.341 final int mem = code[ip++]; 69.342 - if (backrefInvalid(mem)) continue; 69.343 + if (backrefInvalid(mem)) { 69.344 + continue; 69.345 + } 69.346 69.347 int pstart = backrefStart(mem); 69.348 final int pend = backrefEnd(mem); 69.349 @@ -785,14 +839,18 @@ 69.350 int swork = s; 69.351 69.352 while (n-- > 0) { 69.353 - if (chars[pstart++] != chars[swork++]) continue loop; 69.354 + if (chars[pstart++] != chars[swork++]) { 69.355 + continue loop; 69.356 + } 69.357 } 69.358 69.359 s = swork; 69.360 69.361 // beyond string check 69.362 if (sprev < range) { 69.363 - while (sprev + 1 < s) sprev++; 69.364 + while (sprev + 1 < s) { 69.365 + sprev++; 69.366 + } 69.367 } 69.368 69.369 ip += tlen - i - 1; // * SIZE_MEMNUM (1) 69.370 @@ -807,7 +865,9 @@ 69.371 int i; 69.372 loop:for (i=0; i<tlen; i++) { 69.373 final int mem = code[ip++]; 69.374 - if (backrefInvalid(mem)) continue; 69.375 + if (backrefInvalid(mem)) { 69.376 + continue; 69.377 + } 69.378 69.379 final int pstart = backrefStart(mem); 69.380 final int pend = backrefEnd(mem); 69.381 @@ -818,11 +878,16 @@ 69.382 sprev = s; 69.383 69.384 value = s; 69.385 - if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) continue loop; // STRING_CMP_VALUE_IC 69.386 + if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) 69.387 + { 69.388 + continue loop; // STRING_CMP_VALUE_IC 69.389 + } 69.390 s = value; 69.391 69.392 // if (sprev < chars.length) 69.393 - while (sprev + 1 < s) sprev++; 69.394 + while (sprev + 1 < s) { 69.395 + sprev++; 69.396 + } 69.397 69.398 ip += tlen - i - 1; // * SIZE_MEMNUM (1) 69.399 break; /* success */ 69.400 @@ -830,10 +895,12 @@ 69.401 if (i == tlen) {opFail(); return;} 69.402 } 69.403 69.404 - private boolean memIsInMemp(final int mem, final int num, int memp) { 69.405 - for (int i=0; i<num; i++) { 69.406 + private boolean memIsInMemp(final int mem, final int num, final int mempp) { 69.407 + for (int i=0, memp = mempp; i<num; i++) { 69.408 final int m = code[memp++]; 69.409 - if (mem == m) return true; 69.410 + if (mem == m) { 69.411 + return true; 69.412 + } 69.413 } 69.414 return false; 69.415 } 69.416 @@ -857,7 +924,9 @@ 69.417 if (memIsInMemp(e.getMemNum(), memNum, memp)) { 69.418 final int pstart = e.getMemPStr(); 69.419 if (pend != -1) { 69.420 - if (pend - pstart > end - s) return false; /* or goto next_mem; */ 69.421 + if (pend - pstart > end - s) { 69.422 + return false; /* or goto next_mem; */ 69.423 + } 69.424 int p = pstart; 69.425 69.426 value = s; 69.427 @@ -867,7 +936,9 @@ 69.428 } 69.429 } else { 69.430 while (p < pend) { 69.431 - if (chars[p++] != chars[value++]) return false; /* or goto next_mem; */ 69.432 + if (chars[p++] != chars[value++]) { 69.433 + return false; /* or goto next_mem; */ 69.434 + } 69.435 } 69.436 } 69.437 s = value; 69.438 @@ -893,24 +964,15 @@ 69.439 69.440 sprev = s; 69.441 if (backrefMatchAtNestedLevel(ic != 0, regex.caseFoldFlag, level, tlen, ip)) { // (s) and (end) implicit 69.442 - while (sprev + 1 < s) sprev++; 69.443 + while (sprev + 1 < s) { 69.444 + sprev++; 69.445 + } 69.446 ip += tlen; // * SIZE_MEMNUM 69.447 } else { 69.448 {opFail(); return;} 69.449 } 69.450 } 69.451 69.452 - /* no need: IS_DYNAMIC_OPTION() == 0 */ 69.453 - private void opSetOptionPush() { 69.454 - // option = code[ip++]; // final for now 69.455 - pushAlt(ip, s, sprev); 69.456 - ip += OPSize.SET_OPTION + OPSize.FAIL; 69.457 - } 69.458 - 69.459 - private void opSetOption() { 69.460 - // option = code[ip++]; // final for now 69.461 - } 69.462 - 69.463 private void opNullCheckStart() { 69.464 final int mem = code[ip++]; 69.465 pushNullCheckStart(mem, s); 69.466 @@ -1142,13 +1204,6 @@ 69.467 sprev = EncodingHelper.prevCharHead(str, s); 69.468 } 69.469 69.470 - private void opLookBehindSb() { 69.471 - final int tlen = code[ip++]; 69.472 - s -= tlen; 69.473 - if (s < str) {opFail(); return;} 69.474 - sprev = s == str ? -1 : s - 1; 69.475 - } 69.476 - 69.477 private void opPushLookBehindNot() { 69.478 final int addr = code[ip++]; 69.479 final int tlen = code[ip++];
70.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java Wed Nov 12 13:47:23 2014 -0800 70.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodePrinter.java Fri Nov 14 10:03:48 2014 -0800 70.3 @@ -236,16 +236,17 @@ 70.4 sb.append(new String(code, s, len)); 70.5 } 70.6 70.7 - private void pLenStringFromTemplate(final StringBuilder sb, final int len, final char[] tm, final int idx) { 70.8 + private static void pLenStringFromTemplate(final StringBuilder sb, final int len, final char[] tm, final int idx) { 70.9 sb.append(":T:").append(len).append(":"); 70.10 sb.append(tm, idx, len); 70.11 } 70.12 70.13 - public int compiledByteCodeToString(final StringBuilder sb, int bp) { 70.14 + public int compiledByteCodeToString(final StringBuilder sb, final int bptr) { 70.15 int len, n, mem, addr, scn, cod; 70.16 BitSet bs; 70.17 CClassNode cc; 70.18 int tm, idx; 70.19 + int bp = bptr; 70.20 70.21 sb.append("[").append(OpCodeNames[code[bp]]); 70.22 final int argType = OpCodeArgTypes[code[bp]]; 70.23 @@ -253,6 +254,7 @@ 70.24 if (argType != Arguments.SPECIAL) { 70.25 bp++; 70.26 switch (argType) { 70.27 + default: 70.28 case Arguments.NON: 70.29 break; 70.30 70.31 @@ -410,7 +412,9 @@ 70.32 for (int i=0; i<len; i++) { 70.33 mem = code[bp]; 70.34 bp += OPSize.MEMNUM; 70.35 - if (i > 0) sb.append(", "); 70.36 + if (i > 0) { 70.37 + sb.append(", "); 70.38 + } 70.39 sb.append(mem); 70.40 } 70.41 break; 70.42 @@ -428,7 +432,9 @@ 70.43 for (int i=0; i<len; i++) { 70.44 mem = code[bp]; 70.45 bp += OPSize.MEMNUM; 70.46 - if (i > 0) sb.append(", "); 70.47 + if (i > 0) { 70.48 + sb.append(", "); 70.49 + } 70.50 sb.append(mem); 70.51 } 70.52 break; 70.53 @@ -501,7 +507,9 @@ 70.54 while (bp < end) { 70.55 ncode++; 70.56 70.57 - if (bp > 0) sb.append(ncode % 5 == 0 ? "\n" : " "); 70.58 + if (bp > 0) { 70.59 + sb.append(ncode % 5 == 0 ? "\n" : " "); 70.60 + } 70.61 70.62 bp = compiledByteCodeToString(sb, bp); 70.63 }
71.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/CodeRangeBuffer.java Wed Nov 12 13:47:23 2014 -0800 71.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/CodeRangeBuffer.java Fri Nov 14 10:03:48 2014 -0800 71.3 @@ -22,6 +22,7 @@ 71.4 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 71.5 import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; 71.6 71.7 +@SuppressWarnings("javadoc") 71.8 public final class CodeRangeBuffer implements Cloneable { 71.9 private static final int INIT_MULTI_BYTE_RANGE_SIZE = 5; 71.10 private static final int ALL_MULTI_BYTE_RANGE = 0x7fffffff; 71.11 @@ -68,7 +69,9 @@ 71.12 71.13 for (int i=0; i<p[0]; i++) { 71.14 buf.append("[").append(rangeNumToString(p[i * 2 + 1])).append("..").append(rangeNumToString(p[i * 2 + 2])).append("]"); 71.15 - if (i > 0 && i % 6 == 0) buf.append("\n "); 71.16 + if (i > 0 && i % 6 == 0) { 71.17 + buf.append("\n "); 71.18 + } 71.19 } 71.20 71.21 return buf.toString(); 71.22 @@ -97,9 +100,13 @@ 71.23 } 71.24 71.25 private void moveRight(final int from, final int to, final int n) { 71.26 - if (to + n > p.length) expand(to + n); 71.27 + if (to + n > p.length) { 71.28 + expand(to + n); 71.29 + } 71.30 System.arraycopy(p, from, p, to, n); 71.31 - if (to + n > used) used = to + n; 71.32 + if (to + n > used) { 71.33 + used = to + n; 71.34 + } 71.35 } 71.36 71.37 protected void moveLeft(final int from, final int to, final int n) { 71.38 @@ -113,9 +120,13 @@ 71.39 71.40 public void writeCodePoint(final int pos, final int b) { 71.41 final int u = pos + 1; 71.42 - if (p.length < u) expand(u); 71.43 + if (p.length < u) { 71.44 + expand(u); 71.45 + } 71.46 p[pos] = b; 71.47 - if (used < u) used = u; 71.48 + if (used < u) { 71.49 + used = u; 71.50 + } 71.51 } 71.52 71.53 @Override 71.54 @@ -125,14 +136,19 @@ 71.55 71.56 // ugly part: these methods should be made OO 71.57 // add_code_range_to_buf 71.58 - public static CodeRangeBuffer addCodeRangeToBuff(CodeRangeBuffer pbuf, int from, int to) { 71.59 + public static CodeRangeBuffer addCodeRangeToBuff(final CodeRangeBuffer pbufp, final int fromp, final int top) { 71.60 + int from = fromp, to = top; 71.61 + CodeRangeBuffer pbuf = pbufp; 71.62 + 71.63 if (from > to) { 71.64 final int n = from; 71.65 from = to; 71.66 to = n; 71.67 } 71.68 71.69 - if (pbuf == null) pbuf = new CodeRangeBuffer(); // move to CClassNode 71.70 + if (pbuf == null) { 71.71 + pbuf = new CodeRangeBuffer(); // move to CClassNode 71.72 + } 71.73 71.74 final int[]p = pbuf.p; 71.75 int n = p[0]; 71.76 @@ -163,11 +179,17 @@ 71.77 71.78 final int incN = low + 1 - high; 71.79 71.80 - if (n + incN > Config.MAX_MULTI_BYTE_RANGES_NUM) throw new ValueException(ErrorMessages.ERR_TOO_MANY_MULTI_BYTE_RANGES); 71.81 + if (n + incN > Config.MAX_MULTI_BYTE_RANGES_NUM) { 71.82 + throw new ValueException(ErrorMessages.ERR_TOO_MANY_MULTI_BYTE_RANGES); 71.83 + } 71.84 71.85 if (incN != 1) { 71.86 - if (from > p[low * 2 + 1]) from = p[low * 2 + 1]; 71.87 - if (to < p[(high - 1) * 2 + 2]) to = p[(high - 1) * 2 + 2]; 71.88 + if (from > p[low * 2 + 1]) { 71.89 + from = p[low * 2 + 1]; 71.90 + } 71.91 + if (to < p[(high - 1) * 2 + 2]) { 71.92 + to = p[(high - 1) * 2 + 2]; 71.93 + } 71.94 } 71.95 71.96 if (incN != 0 && high < n) { 71.97 @@ -197,9 +219,8 @@ 71.98 if (from > to) { 71.99 if (env.syntax.allowEmptyRangeInCC()) { 71.100 return pbuf; 71.101 - } else { 71.102 - throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 71.103 } 71.104 + throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 71.105 } 71.106 return addCodeRangeToBuff(pbuf, from, to); 71.107 } 71.108 @@ -218,12 +239,16 @@ 71.109 public static CodeRangeBuffer notCodeRangeBuff(final CodeRangeBuffer bbuf) { 71.110 CodeRangeBuffer pbuf = null; 71.111 71.112 - if (bbuf == null) return setAllMultiByteRange(pbuf); 71.113 + if (bbuf == null) { 71.114 + return setAllMultiByteRange(pbuf); 71.115 + } 71.116 71.117 final int[]p = bbuf.p; 71.118 final int n = p[0]; 71.119 71.120 - if (n <= 0) return setAllMultiByteRange(pbuf); 71.121 + if (n <= 0) { 71.122 + return setAllMultiByteRange(pbuf); 71.123 + } 71.124 71.125 int pre = EncodingHelper.mbcodeStartPosition(); 71.126 71.127 @@ -235,18 +260,26 @@ 71.128 if (pre <= from - 1) { 71.129 pbuf = addCodeRangeToBuff(pbuf, pre, from - 1); 71.130 } 71.131 - if (to == ALL_MULTI_BYTE_RANGE) break; 71.132 + if (to == ALL_MULTI_BYTE_RANGE) { 71.133 + break; 71.134 + } 71.135 pre = to + 1; 71.136 } 71.137 71.138 - if (to < ALL_MULTI_BYTE_RANGE) pbuf = addCodeRangeToBuff(pbuf, to + 1, ALL_MULTI_BYTE_RANGE); 71.139 + if (to < ALL_MULTI_BYTE_RANGE) { 71.140 + pbuf = addCodeRangeToBuff(pbuf, to + 1, ALL_MULTI_BYTE_RANGE); 71.141 + } 71.142 return pbuf; 71.143 } 71.144 71.145 // or_code_range_buf 71.146 - public static CodeRangeBuffer orCodeRangeBuff(CodeRangeBuffer bbuf1, boolean not1, 71.147 - CodeRangeBuffer bbuf2, boolean not2) { 71.148 + public static CodeRangeBuffer orCodeRangeBuff(final CodeRangeBuffer bbuf1p, final boolean not1p, 71.149 + final CodeRangeBuffer bbuf2p, final boolean not2p) { 71.150 CodeRangeBuffer pbuf = null; 71.151 + CodeRangeBuffer bbuf1 = bbuf1p; 71.152 + CodeRangeBuffer bbuf2 = bbuf2p; 71.153 + boolean not1 = not1p; 71.154 + boolean not2 = not2p; 71.155 71.156 if (bbuf1 == null && bbuf2 == null) { 71.157 if (not1 || not2) { 71.158 @@ -266,13 +299,11 @@ 71.159 if (bbuf1 == null) { 71.160 if (not1) { 71.161 return setAllMultiByteRange(pbuf); 71.162 - } else { 71.163 - if (!not2) { 71.164 - return bbuf2.clone(); 71.165 - } else { 71.166 - return notCodeRangeBuff(bbuf2); 71.167 - } 71.168 } 71.169 + if (!not2) { 71.170 + return bbuf2.clone(); 71.171 + } 71.172 + return notCodeRangeBuff(bbuf2); 71.173 } 71.174 71.175 if (not1) { 71.176 @@ -302,16 +333,18 @@ 71.177 } 71.178 71.179 // and_code_range1 71.180 - public static CodeRangeBuffer andCodeRange1(CodeRangeBuffer pbuf, int from1, int to1, final int[]data, final int n) { 71.181 + public static CodeRangeBuffer andCodeRange1(final CodeRangeBuffer pbufp, final int from1p, final int to1p, final int[]data, final int n) { 71.182 + CodeRangeBuffer pbuf = pbufp; 71.183 + int from1 = from1p, to1 = to1p; 71.184 + 71.185 for (int i=0; i<n; i++) { 71.186 final int from2 = data[i * 2 + 1]; 71.187 final int to2 = data[i * 2 + 2]; 71.188 if (from2 < from1) { 71.189 if (to2 < from1) { 71.190 continue; 71.191 - } else { 71.192 - from1 = to2 + 1; 71.193 } 71.194 + from1 = to2 + 1; 71.195 } else if (from2 <= to1) { 71.196 if (to2 < to1) { 71.197 if (from1 <= from2 - 1) { 71.198 @@ -324,7 +357,9 @@ 71.199 } else { 71.200 from1 = from2; 71.201 } 71.202 - if (from1 > to1) break; 71.203 + if (from1 > to1) { 71.204 + break; 71.205 + } 71.206 } 71.207 71.208 if (from1 <= to1) { 71.209 @@ -335,15 +370,22 @@ 71.210 } 71.211 71.212 // and_code_range_buf 71.213 - public static CodeRangeBuffer andCodeRangeBuff(CodeRangeBuffer bbuf1, boolean not1, 71.214 - CodeRangeBuffer bbuf2, boolean not2) { 71.215 + public static CodeRangeBuffer andCodeRangeBuff(final CodeRangeBuffer bbuf1p, final boolean not1p, 71.216 + final CodeRangeBuffer bbuf2p, final boolean not2p) { 71.217 CodeRangeBuffer pbuf = null; 71.218 + CodeRangeBuffer bbuf1 = bbuf1p; 71.219 + CodeRangeBuffer bbuf2 = bbuf2p; 71.220 + boolean not1 = not1p, not2 = not2p; 71.221 71.222 if (bbuf1 == null) { 71.223 - if (not1 && bbuf2 != null) return bbuf2.clone(); /* not1 != 0 -> not2 == 0 */ 71.224 + if (not1 && bbuf2 != null) { 71.225 + return bbuf2.clone(); /* not1 != 0 -> not2 == 0 */ 71.226 + } 71.227 return null; 71.228 } else if (bbuf2 == null) { 71.229 - if (not2) return bbuf1.clone(); 71.230 + if (not2) { 71.231 + return bbuf1.clone(); 71.232 + } 71.233 return null; 71.234 } 71.235 71.236 @@ -369,8 +411,12 @@ 71.237 final int from2 = p2[j * 2 + 1]; 71.238 final int to2 = p2[j * 2 + 2]; 71.239 71.240 - if (from2 > to1) break; 71.241 - if (to2 < from1) continue; 71.242 + if (from2 > to1) { 71.243 + break; 71.244 + } 71.245 + if (to2 < from1) { 71.246 + continue; 71.247 + } 71.248 final int from = from1 > from2 ? from1 : from2; 71.249 final int to = to1 < to2 ? to1 : to2; 71.250 pbuf = addCodeRangeToBuff(pbuf, from, to);
72.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Compiler.java Wed Nov 12 13:47:23 2014 -0800 72.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Compiler.java Fri Nov 14 10:03:48 2014 -0800 72.3 @@ -53,13 +53,17 @@ 72.4 protected abstract void compileAltNode(ConsAltNode node); 72.5 72.6 private void compileStringRawNode(final StringNode sn) { 72.7 - if (sn.length() <= 0) return; 72.8 + if (sn.length() <= 0) { 72.9 + return; 72.10 + } 72.11 addCompileString(sn.chars, sn.p, sn.length(), false); 72.12 } 72.13 72.14 private void compileStringNode(final StringNode node) { 72.15 final StringNode sn = node; 72.16 - if (sn.length() <= 0) return; 72.17 + if (sn.length() <= 0) { 72.18 + return; 72.19 + } 72.20 72.21 final boolean ambig = sn.isAmbig(); 72.22 72.23 @@ -145,7 +149,9 @@ 72.24 } 72.25 72.26 protected final void compileTreeNTimes(final Node node, final int n) { 72.27 - for (int i=0; i<n; i++) compileTree(node); 72.28 + for (int i=0; i<n; i++) { 72.29 + compileTree(node); 72.30 + } 72.31 } 72.32 72.33 protected void newSyntaxException(final String message) {
73.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Wed Nov 12 13:47:23 2014 -0800 73.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Fri Nov 14 10:03:48 2014 -0800 73.3 @@ -21,6 +21,7 @@ 73.4 73.5 import java.io.PrintStream; 73.6 73.7 +@SuppressWarnings("javadoc") 73.8 public interface Config { 73.9 final int CHAR_TABLE_SIZE = 256; 73.10
74.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Wed Nov 12 13:47:23 2014 -0800 74.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Fri Nov 14 10:03:48 2014 -0800 74.3 @@ -23,6 +23,7 @@ 74.4 import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 74.5 import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder; 74.6 74.7 +@SuppressWarnings("javadoc") 74.8 public final class EncodingHelper { 74.9 74.10 final static int NEW_LINE = 0x000a; 74.11 @@ -79,14 +80,19 @@ 74.12 74.13 /* onigenc_get_right_adjust_char_head_with_prev */ 74.14 public static int rightAdjustCharHeadWithPrev(final int s, final IntHolder prev) { 74.15 - if (prev != null) prev.value = -1; /* Sorry */ 74.16 + if (prev != null) { 74.17 + prev.value = -1; /* Sorry */ 74.18 + } 74.19 return s; 74.20 } 74.21 74.22 // Encoding.stepBack 74.23 - public static int stepBack(final int p, int s, int n) { 74.24 - while (s != -1 && n-- > 0) { 74.25 - if (s <= p) return -1; 74.26 + public static int stepBack(final int p, final int sp, final int np) { 74.27 + int s = sp, n = np; 74.28 + while (s != -1 && n-- > 0) { 74.29 + if (s <= p) { 74.30 + return -1; 74.31 + } 74.32 s--; 74.33 } 74.34 return s; 74.35 @@ -122,7 +128,7 @@ 74.36 final int upper = toUpperCase(c); 74.37 74.38 if (upper != c) { 74.39 - fun.apply(c, upper, arg); 74.40 + ApplyCaseFold.apply(c, upper, arg); 74.41 } 74.42 } 74.43 } 74.44 @@ -133,7 +139,7 @@ 74.45 final int upper = toUpperCase(c); 74.46 74.47 if (upper != c) { 74.48 - fun.apply(upper, c, arg); 74.49 + ApplyCaseFold.apply(upper, c, arg); 74.50 } 74.51 } 74.52 }
75.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Wed Nov 12 13:47:23 2014 -0800 75.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Fri Nov 14 10:03:48 2014 -0800 75.3 @@ -21,7 +21,6 @@ 75.4 75.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isSingleline; 75.6 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.isRepeatInfinite; 75.7 - 75.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode; 75.9 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; 75.10 import jdk.nashorn.internal.runtime.regexp.joni.constants.MetaChar; 75.11 @@ -53,9 +52,8 @@ 75.12 if (!left()) { 75.13 if (synAllow) { 75.14 return 1; /* "....{" : OK! */ 75.15 - } else { 75.16 - throw new SyntaxException(ERR_END_PATTERN_AT_LEFT_BRACE); 75.17 } 75.18 + throw new SyntaxException(ERR_END_PATTERN_AT_LEFT_BRACE); 75.19 } 75.20 75.21 if (!synAllow) { 75.22 @@ -83,7 +81,9 @@ 75.23 } 75.24 } 75.25 75.26 - if (!left()) return invalidRangeQuantifier(synAllow); 75.27 + if (!left()) { 75.28 + return invalidRangeQuantifier(synAllow); 75.29 + } 75.30 75.31 fetch(); 75.32 int up; 75.33 @@ -99,25 +99,35 @@ 75.34 } 75.35 75.36 if (p == prev) { 75.37 - if (nonLow) return invalidRangeQuantifier(synAllow); 75.38 + if (nonLow) { 75.39 + return invalidRangeQuantifier(synAllow); 75.40 + } 75.41 up = QuantifierNode.REPEAT_INFINITE; /* {n,} : {n,infinite} */ 75.42 } 75.43 } else { 75.44 - if (nonLow) return invalidRangeQuantifier(synAllow); 75.45 + if (nonLow) { 75.46 + return invalidRangeQuantifier(synAllow); 75.47 + } 75.48 unfetch(); 75.49 up = low; /* {n} : exact n times */ 75.50 ret = 2; /* fixed */ 75.51 } 75.52 75.53 - if (!left()) return invalidRangeQuantifier(synAllow); 75.54 + if (!left()) { 75.55 + return invalidRangeQuantifier(synAllow); 75.56 + } 75.57 fetch(); 75.58 75.59 if (syntax.opEscBraceInterval()) { 75.60 - if (c != syntax.metaCharTable.esc) return invalidRangeQuantifier(synAllow); 75.61 + if (c != syntax.metaCharTable.esc) { 75.62 + return invalidRangeQuantifier(synAllow); 75.63 + } 75.64 fetch(); 75.65 } 75.66 75.67 - if (c != '}') return invalidRangeQuantifier(synAllow); 75.68 + if (c != '}') { 75.69 + return invalidRangeQuantifier(synAllow); 75.70 + } 75.71 75.72 if (!isRepeatInfinite(up) && low > up) { 75.73 throw new ValueException(ERR_UPPER_SMALLER_THAN_LOWER_IN_REPEAT_RANGE); 75.74 @@ -134,9 +144,8 @@ 75.75 if (synAllow) { 75.76 restore(); 75.77 return 1; 75.78 - } else { 75.79 - throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN); 75.80 } 75.81 + throw new SyntaxException(ERR_INVALID_REPEAT_RANGE_PATTERN); 75.82 } 75.83 75.84 @SuppressWarnings("fallthrough") 75.85 @@ -218,17 +227,6 @@ 75.86 } 75.87 } 75.88 75.89 - private int nameEndCodePoint(final int start) { 75.90 - switch(start) { 75.91 - case '<': 75.92 - return '>'; 75.93 - case '\'': 75.94 - return '\''; 75.95 - default: 75.96 - return 0; 75.97 - } 75.98 - } 75.99 - 75.100 private void fetchTokenInCCFor_charType(final boolean flag, final int type) { 75.101 token.type = TokenType.CHAR_TYPE; 75.102 token.setPropCType(type); 75.103 @@ -236,7 +234,9 @@ 75.104 } 75.105 75.106 private void fetchTokenInCCFor_x() { 75.107 - if (!left()) return; 75.108 + if (!left()) { 75.109 + return; 75.110 + } 75.111 final int last = p; 75.112 75.113 if (peekIs('{') && syntax.opEscXBraceHex8()) { 75.114 @@ -274,7 +274,9 @@ 75.115 } 75.116 75.117 private void fetchTokenInCCFor_u() { 75.118 - if (!left()) return; 75.119 + if (!left()) { 75.120 + return; 75.121 + } 75.122 final int last = p; 75.123 75.124 if (syntax.op2EscUHex4()) { 75.125 @@ -329,7 +331,9 @@ 75.126 } else if (c == '-') { 75.127 token.type = TokenType.CC_RANGE; 75.128 } else if (c == syntax.metaCharTable.esc) { 75.129 - if (!syntax.backSlashEscapeInCC()) return token.type; 75.130 + if (!syntax.backSlashEscapeInCC()) { 75.131 + return token.type; 75.132 + } 75.133 if (!left()) { 75.134 throw new SyntaxException(ERR_END_PATTERN_AT_ESCAPE); 75.135 } 75.136 @@ -357,10 +361,14 @@ 75.137 fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE); 75.138 break; 75.139 case 'h': 75.140 - if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(false, CharacterType.XDIGIT); 75.141 + if (syntax.op2EscHXDigit()) { 75.142 + fetchTokenInCCFor_charType(false, CharacterType.XDIGIT); 75.143 + } 75.144 break; 75.145 case 'H': 75.146 - if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); 75.147 + if (syntax.op2EscHXDigit()) { 75.148 + fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); 75.149 + } 75.150 break; 75.151 case 'x': 75.152 fetchTokenInCCFor_x(); 75.153 @@ -424,7 +432,9 @@ 75.154 } 75.155 75.156 private void fetchTokenFor_xBrace() { 75.157 - if (!left()) return; 75.158 + if (!left()) { 75.159 + return; 75.160 + } 75.161 75.162 final int last = p; 75.163 if (peekIs('{') && syntax.opEscXBraceHex8()) { 75.164 @@ -461,7 +471,9 @@ 75.165 } 75.166 75.167 private void fetchTokenFor_uHex() { 75.168 - if (!left()) return; 75.169 + if (!left()) { 75.170 + return; 75.171 + } 75.172 final int last = p; 75.173 75.174 if (syntax.op2EscUHex4()) { 75.175 @@ -562,79 +574,129 @@ 75.176 switch(c) { 75.177 75.178 case '*': 75.179 - if (syntax.opEscAsteriskZeroInf()) fetchTokenFor_repeat(0, QuantifierNode.REPEAT_INFINITE); 75.180 + if (syntax.opEscAsteriskZeroInf()) { 75.181 + fetchTokenFor_repeat(0, QuantifierNode.REPEAT_INFINITE); 75.182 + } 75.183 break; 75.184 case '+': 75.185 - if (syntax.opEscPlusOneInf()) fetchTokenFor_repeat(1, QuantifierNode.REPEAT_INFINITE); 75.186 + if (syntax.opEscPlusOneInf()) { 75.187 + fetchTokenFor_repeat(1, QuantifierNode.REPEAT_INFINITE); 75.188 + } 75.189 break; 75.190 case '?': 75.191 - if (syntax.opEscQMarkZeroOne()) fetchTokenFor_repeat(0, 1); 75.192 + if (syntax.opEscQMarkZeroOne()) { 75.193 + fetchTokenFor_repeat(0, 1); 75.194 + } 75.195 break; 75.196 case '{': 75.197 - if (syntax.opEscBraceInterval()) fetchTokenFor_openBrace(); 75.198 + if (syntax.opEscBraceInterval()) { 75.199 + fetchTokenFor_openBrace(); 75.200 + } 75.201 break; 75.202 case '|': 75.203 - if (syntax.opEscVBarAlt()) token.type = TokenType.ALT; 75.204 + if (syntax.opEscVBarAlt()) { 75.205 + token.type = TokenType.ALT; 75.206 + } 75.207 break; 75.208 case '(': 75.209 - if (syntax.opEscLParenSubexp()) token.type = TokenType.SUBEXP_OPEN; 75.210 + if (syntax.opEscLParenSubexp()) { 75.211 + token.type = TokenType.SUBEXP_OPEN; 75.212 + } 75.213 break; 75.214 case ')': 75.215 - if (syntax.opEscLParenSubexp()) token.type = TokenType.SUBEXP_CLOSE; 75.216 + if (syntax.opEscLParenSubexp()) { 75.217 + token.type = TokenType.SUBEXP_CLOSE; 75.218 + } 75.219 break; 75.220 case 'w': 75.221 - if (syntax.opEscWWord()) fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD); 75.222 + if (syntax.opEscWWord()) { 75.223 + fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD); 75.224 + } 75.225 break; 75.226 case 'W': 75.227 - if (syntax.opEscWWord()) fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD); 75.228 + if (syntax.opEscWWord()) { 75.229 + fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.W : CharacterType.WORD); 75.230 + } 75.231 break; 75.232 case 'b': 75.233 - if (syntax.opEscBWordBound()) fetchTokenFor_anchor(AnchorType.WORD_BOUND); 75.234 + if (syntax.opEscBWordBound()) { 75.235 + fetchTokenFor_anchor(AnchorType.WORD_BOUND); 75.236 + } 75.237 break; 75.238 case 'B': 75.239 - if (syntax.opEscBWordBound()) fetchTokenFor_anchor(AnchorType.NOT_WORD_BOUND); 75.240 + if (syntax.opEscBWordBound()) { 75.241 + fetchTokenFor_anchor(AnchorType.NOT_WORD_BOUND); 75.242 + } 75.243 break; 75.244 case '<': 75.245 - if (Config.USE_WORD_BEGIN_END && syntax.opEscLtGtWordBeginEnd()) fetchTokenFor_anchor(AnchorType.WORD_BEGIN); 75.246 + if (Config.USE_WORD_BEGIN_END && syntax.opEscLtGtWordBeginEnd()) { 75.247 + fetchTokenFor_anchor(AnchorType.WORD_BEGIN); 75.248 + } 75.249 break; 75.250 case '>': 75.251 - if (Config.USE_WORD_BEGIN_END && syntax.opEscLtGtWordBeginEnd()) fetchTokenFor_anchor(AnchorType.WORD_END); 75.252 + if (Config.USE_WORD_BEGIN_END && syntax.opEscLtGtWordBeginEnd()) { 75.253 + fetchTokenFor_anchor(AnchorType.WORD_END); 75.254 + } 75.255 break; 75.256 case 's': 75.257 - if (syntax.opEscSWhiteSpace()) fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE); 75.258 + if (syntax.opEscSWhiteSpace()) { 75.259 + fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE); 75.260 + } 75.261 break; 75.262 case 'S': 75.263 - if (syntax.opEscSWhiteSpace()) fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE); 75.264 + if (syntax.opEscSWhiteSpace()) { 75.265 + fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.S : CharacterType.SPACE); 75.266 + } 75.267 break; 75.268 case 'd': 75.269 - if (syntax.opEscDDigit()) fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT); 75.270 + if (syntax.opEscDDigit()) { 75.271 + fetchTokenInCCFor_charType(false, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT); 75.272 + } 75.273 break; 75.274 case 'D': 75.275 - if (syntax.opEscDDigit()) fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT); 75.276 + if (syntax.opEscDDigit()) { 75.277 + fetchTokenInCCFor_charType(true, Config.NON_UNICODE_SDW ? CharacterType.D : CharacterType.DIGIT); 75.278 + } 75.279 break; 75.280 case 'h': 75.281 - if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(false, CharacterType.XDIGIT); 75.282 + if (syntax.op2EscHXDigit()) { 75.283 + fetchTokenInCCFor_charType(false, CharacterType.XDIGIT); 75.284 + } 75.285 break; 75.286 case 'H': 75.287 - if (syntax.op2EscHXDigit()) fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); 75.288 + if (syntax.op2EscHXDigit()) { 75.289 + fetchTokenInCCFor_charType(true, CharacterType.XDIGIT); 75.290 + } 75.291 break; 75.292 case 'A': 75.293 - if (syntax.opEscAZBufAnchor()) fetchTokenFor_anchor(AnchorType.BEGIN_BUF); 75.294 + if (syntax.opEscAZBufAnchor()) { 75.295 + fetchTokenFor_anchor(AnchorType.BEGIN_BUF); 75.296 + } 75.297 break; 75.298 case 'Z': 75.299 - if (syntax.opEscAZBufAnchor()) fetchTokenFor_anchor(AnchorType.SEMI_END_BUF); 75.300 + if (syntax.opEscAZBufAnchor()) { 75.301 + fetchTokenFor_anchor(AnchorType.SEMI_END_BUF); 75.302 + } 75.303 break; 75.304 case 'z': 75.305 - if (syntax.opEscAZBufAnchor()) fetchTokenFor_anchor(AnchorType.END_BUF); 75.306 + if (syntax.opEscAZBufAnchor()) { 75.307 + fetchTokenFor_anchor(AnchorType.END_BUF); 75.308 + } 75.309 break; 75.310 case 'G': 75.311 - if (syntax.opEscCapitalGBeginAnchor()) fetchTokenFor_anchor(AnchorType.BEGIN_POSITION); 75.312 + if (syntax.opEscCapitalGBeginAnchor()) { 75.313 + fetchTokenFor_anchor(AnchorType.BEGIN_POSITION); 75.314 + } 75.315 break; 75.316 case '`': 75.317 - if (syntax.op2EscGnuBufAnchor()) fetchTokenFor_anchor(AnchorType.BEGIN_BUF); 75.318 + if (syntax.op2EscGnuBufAnchor()) { 75.319 + fetchTokenFor_anchor(AnchorType.BEGIN_BUF); 75.320 + } 75.321 break; 75.322 case '\'': 75.323 - if (syntax.op2EscGnuBufAnchor()) fetchTokenFor_anchor(AnchorType.END_BUF); 75.324 + if (syntax.op2EscGnuBufAnchor()) { 75.325 + fetchTokenFor_anchor(AnchorType.END_BUF); 75.326 + } 75.327 break; 75.328 case 'x': 75.329 fetchTokenFor_xBrace(); 75.330 @@ -684,22 +746,34 @@ 75.331 { 75.332 switch(c) { 75.333 case '.': 75.334 - if (syntax.opDotAnyChar()) token.type = TokenType.ANYCHAR; 75.335 + if (syntax.opDotAnyChar()) { 75.336 + token.type = TokenType.ANYCHAR; 75.337 + } 75.338 break; 75.339 case '*': 75.340 - if (syntax.opAsteriskZeroInf()) fetchTokenFor_repeat(0, QuantifierNode.REPEAT_INFINITE); 75.341 + if (syntax.opAsteriskZeroInf()) { 75.342 + fetchTokenFor_repeat(0, QuantifierNode.REPEAT_INFINITE); 75.343 + } 75.344 break; 75.345 case '+': 75.346 - if (syntax.opPlusOneInf()) fetchTokenFor_repeat(1, QuantifierNode.REPEAT_INFINITE); 75.347 + if (syntax.opPlusOneInf()) { 75.348 + fetchTokenFor_repeat(1, QuantifierNode.REPEAT_INFINITE); 75.349 + } 75.350 break; 75.351 case '?': 75.352 - if (syntax.opQMarkZeroOne()) fetchTokenFor_repeat(0, 1); 75.353 + if (syntax.opQMarkZeroOne()) { 75.354 + fetchTokenFor_repeat(0, 1); 75.355 + } 75.356 break; 75.357 case '{': 75.358 - if (syntax.opBraceInterval()) fetchTokenFor_openBrace(); 75.359 + if (syntax.opBraceInterval()) { 75.360 + fetchTokenFor_openBrace(); 75.361 + } 75.362 break; 75.363 case '|': 75.364 - if (syntax.opVBarAlt()) token.type = TokenType.ALT; 75.365 + if (syntax.opVBarAlt()) { 75.366 + token.type = TokenType.ALT; 75.367 + } 75.368 break; 75.369 75.370 case '(': 75.371 @@ -713,9 +787,13 @@ 75.372 } 75.373 fetch(); 75.374 if (c == syntax.metaCharTable.esc) { 75.375 - if (left()) fetch(); 75.376 + if (left()) { 75.377 + fetch(); 75.378 + } 75.379 } else { 75.380 - if (c == ')') break; 75.381 + if (c == ')') { 75.382 + break; 75.383 + } 75.384 } 75.385 } 75.386 continue start; // goto start 75.387 @@ -723,19 +801,29 @@ 75.388 unfetch(); 75.389 } 75.390 75.391 - if (syntax.opLParenSubexp()) token.type = TokenType.SUBEXP_OPEN; 75.392 + if (syntax.opLParenSubexp()) { 75.393 + token.type = TokenType.SUBEXP_OPEN; 75.394 + } 75.395 break; 75.396 case ')': 75.397 - if (syntax.opLParenSubexp()) token.type = TokenType.SUBEXP_CLOSE; 75.398 + if (syntax.opLParenSubexp()) { 75.399 + token.type = TokenType.SUBEXP_CLOSE; 75.400 + } 75.401 break; 75.402 case '^': 75.403 - if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.BEGIN_BUF : AnchorType.BEGIN_LINE); 75.404 + if (syntax.opLineAnchor()) { 75.405 + fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.BEGIN_BUF : AnchorType.BEGIN_LINE); 75.406 + } 75.407 break; 75.408 case '$': 75.409 - if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.END_BUF : AnchorType.END_LINE); 75.410 + if (syntax.opLineAnchor()) { 75.411 + fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.END_BUF : AnchorType.END_LINE); 75.412 + } 75.413 break; 75.414 case '[': 75.415 - if (syntax.opBracketCC()) token.type = TokenType.CC_CC_OPEN; 75.416 + if (syntax.opBracketCC()) { 75.417 + token.type = TokenType.CC_CC_OPEN; 75.418 + } 75.419 break; 75.420 case ']': 75.421 //if (*src > env->pattern) /* /].../ is allowed. */ 75.422 @@ -745,7 +833,9 @@ 75.423 if (Option.isExtend(env.option)) { 75.424 while (left()) { 75.425 fetch(); 75.426 - if (EncodingHelper.isNewLine(c)) break; 75.427 + if (EncodingHelper.isNewLine(c)) { 75.428 + break; 75.429 + } 75.430 } 75.431 continue start; // goto start 75.432 } 75.433 @@ -756,7 +846,10 @@ 75.434 case '\n': 75.435 case '\r': 75.436 case '\f': 75.437 - if (Option.isExtend(env.option)) continue start; // goto start 75.438 + if (Option.isExtend(env.option)) 75.439 + { 75.440 + continue start; // goto start 75.441 + } 75.442 break; 75.443 75.444 default: // string 75.445 @@ -798,8 +891,8 @@ 75.446 } 75.447 } 75.448 75.449 - protected final void syntaxWarn(final String message, final char c) { 75.450 - syntaxWarn(message.replace("<%n>", Character.toString(c))); 75.451 + protected final void syntaxWarn(final String message, final char ch) { 75.452 + syntaxWarn(message.replace("<%n>", Character.toString(ch))); 75.453 } 75.454 75.455 protected final void syntaxWarn(final String message) {
76.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Wed Nov 12 13:47:23 2014 -0800 76.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Fri Nov 14 10:03:48 2014 -0800 76.3 @@ -21,10 +21,10 @@ 76.4 package jdk.nashorn.internal.runtime.regexp.joni; 76.5 76.6 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isFindLongest; 76.7 - 76.8 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; 76.9 import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder; 76.10 76.11 +@SuppressWarnings("javadoc") 76.12 public abstract class Matcher extends IntHolder { 76.13 protected final Regex regex; 76.14 76.15 @@ -73,7 +73,9 @@ 76.16 protected final void msaInit(final int option, final int start) { 76.17 msaOptions = option; 76.18 msaStart = start; 76.19 - if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) msaBestLen = -1; 76.20 + if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) { 76.21 + msaBestLen = -1; 76.22 + } 76.23 } 76.24 76.25 public final int match(final int at, final int range, final int option) { 76.26 @@ -83,20 +85,19 @@ 76.27 76.28 if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) { 76.29 return matchAt(end /*range*/, at, prev); 76.30 - } else { 76.31 - return matchAt(range /*range*/, at, prev); 76.32 } 76.33 + return matchAt(range /*range*/, at, prev); 76.34 } 76.35 76.36 int low, high; // these are the return values 76.37 - private boolean forwardSearchRange(final char[] chars, final int str, final int end, final int s, final int range, final IntHolder lowPrev) { 76.38 + private boolean forwardSearchRange(final char[] ch, final int string, final int e, final int s, final int range, final IntHolder lowPrev) { 76.39 int pprev = -1; 76.40 int p = s; 76.41 76.42 if (Config.DEBUG_SEARCH) { 76.43 Config.log.println("forward_search_range: "+ 76.44 - "str: " + str + 76.45 - ", end: " + end + 76.46 + "str: " + string + 76.47 + ", end: " + e + 76.48 ", s: " + s + 76.49 ", range: " + range); 76.50 } 76.51 @@ -106,7 +107,7 @@ 76.52 } 76.53 76.54 retry:while (true) { 76.55 - p = regex.searchAlgorithm.search(regex, chars, p, end, range); 76.56 + p = regex.searchAlgorithm.search(regex, ch, p, e, range); 76.57 76.58 if (p != -1 && p < range) { 76.59 if (p - regex.dMin < s) { 76.60 @@ -119,9 +120,9 @@ 76.61 if (regex.subAnchor != 0) { 76.62 switch (regex.subAnchor) { 76.63 case AnchorType.BEGIN_LINE: 76.64 - if (p != str) { 76.65 - final int prev = EncodingHelper.prevCharHead((pprev != -1) ? pprev : str, p); 76.66 - if (!EncodingHelper.isNewLine(chars, prev, end)) { 76.67 + if (p != string) { 76.68 + final int prev = EncodingHelper.prevCharHead((pprev != -1) ? pprev : string, p); 76.69 + if (!EncodingHelper.isNewLine(ch, prev, e)) { 76.70 // goto retry_gate; 76.71 pprev = p; 76.72 p++; 76.73 @@ -131,17 +132,17 @@ 76.74 break; 76.75 76.76 case AnchorType.END_LINE: 76.77 - if (p == end) { 76.78 + if (p == e) { 76.79 if (!Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) { 76.80 - final int prev = EncodingHelper.prevCharHead((pprev != -1) ? pprev : str, p); 76.81 - if (prev != -1 && EncodingHelper.isNewLine(chars, prev, end)) { 76.82 + final int prev = EncodingHelper.prevCharHead((pprev != -1) ? pprev : string, p); 76.83 + if (prev != -1 && EncodingHelper.isNewLine(ch, prev, e)) { 76.84 // goto retry_gate; 76.85 pprev = p; 76.86 p++; 76.87 continue retry; 76.88 } 76.89 } 76.90 - } else if (!EncodingHelper.isNewLine(chars, p, end)) { 76.91 + } else if (!EncodingHelper.isNewLine(ch, p, e)) { 76.92 //if () break; 76.93 // goto retry_gate; 76.94 pprev = p; 76.95 @@ -149,6 +150,9 @@ 76.96 continue retry; 76.97 } 76.98 break; 76.99 + 76.100 + default: 76.101 + break; 76.102 } // switch 76.103 } 76.104 76.105 @@ -158,7 +162,7 @@ 76.106 if (low > s) { 76.107 lowPrev.value = EncodingHelper.prevCharHead(s, p); 76.108 } else { 76.109 - lowPrev.value = EncodingHelper.prevCharHead((pprev != -1) ? pprev : str, p); 76.110 + lowPrev.value = EncodingHelper.prevCharHead((pprev != -1) ? pprev : string, p); 76.111 } 76.112 } 76.113 } else { 76.114 @@ -172,7 +176,7 @@ 76.115 } 76.116 } else { 76.117 if (lowPrev != null) { 76.118 - lowPrev.value = EncodingHelper.prevCharHead((pprev != -1) ? pprev : str, low); 76.119 + lowPrev.value = EncodingHelper.prevCharHead((pprev != -1) ? pprev : string, low); 76.120 } 76.121 } 76.122 } 76.123 @@ -182,8 +186,8 @@ 76.124 76.125 if (Config.DEBUG_SEARCH) { 76.126 Config.log.println("forward_search_range success: "+ 76.127 - "low: " + (low - str) + 76.128 - ", high: " + (high - str) + 76.129 + "low: " + (low - string) + 76.130 + ", high: " + (high - string) + 76.131 ", dmin: " + regex.dMin + 76.132 ", dmax: " + regex.dMax); 76.133 } 76.134 @@ -196,20 +200,21 @@ 76.135 } 76.136 76.137 // low, high 76.138 - private boolean backwardSearchRange(final char[] chars, final int str, final int end, final int s, int range, final int adjrange) { 76.139 - range += regex.dMin; 76.140 + private boolean backwardSearchRange(final char[] ch, final int string, final int e, final int s, final int range, final int adjrange) { 76.141 + int r = range; 76.142 + r += regex.dMin; 76.143 int p = s; 76.144 76.145 retry:while (true) { 76.146 - p = regex.searchAlgorithm.searchBackward(regex, chars, range, adjrange, end, p, s, range); 76.147 + p = regex.searchAlgorithm.searchBackward(regex, ch, r, adjrange, e, p, s, r); 76.148 76.149 if (p != -1) { 76.150 if (regex.subAnchor != 0) { 76.151 switch (regex.subAnchor) { 76.152 case AnchorType.BEGIN_LINE: 76.153 - if (p != str) { 76.154 - final int prev = EncodingHelper.prevCharHead(str, p); 76.155 - if (!EncodingHelper.isNewLine(chars, prev, end)) { 76.156 + if (p != string) { 76.157 + final int prev = EncodingHelper.prevCharHead(string, p); 76.158 + if (!EncodingHelper.isNewLine(ch, prev, e)) { 76.159 p = prev; 76.160 continue retry; 76.161 } 76.162 @@ -217,21 +222,28 @@ 76.163 break; 76.164 76.165 case AnchorType.END_LINE: 76.166 - if (p == end) { 76.167 + if (p == e) { 76.168 if (!Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) { 76.169 final int prev = EncodingHelper.prevCharHead(adjrange, p); 76.170 - if (prev == -1) return false; 76.171 - if (EncodingHelper.isNewLine(chars, prev, end)) { 76.172 + if (prev == -1) { 76.173 + return false; 76.174 + } 76.175 + if (EncodingHelper.isNewLine(ch, prev, e)) { 76.176 p = prev; 76.177 continue retry; 76.178 } 76.179 } 76.180 - } else if (!EncodingHelper.isNewLine(chars, p, end)) { 76.181 + } else if (!EncodingHelper.isNewLine(ch, p, e)) { 76.182 p = EncodingHelper.prevCharHead(adjrange, p); 76.183 - if (p == -1) return false; 76.184 + if (p == -1) { 76.185 + return false; 76.186 + } 76.187 continue retry; 76.188 } 76.189 break; 76.190 + 76.191 + default: 76.192 + break; 76.193 } // switch 76.194 } 76.195 76.196 @@ -243,14 +255,16 @@ 76.197 76.198 if (Config.DEBUG_SEARCH) { 76.199 Config.log.println("backward_search_range: "+ 76.200 - "low: " + (low - str) + 76.201 - ", high: " + (high - str)); 76.202 + "low: " + (low - string) + 76.203 + ", high: " + (high - string)); 76.204 } 76.205 76.206 return true; 76.207 } 76.208 76.209 - if (Config.DEBUG_SEARCH) Config.log.println("backward_search_range: fail."); 76.210 + if (Config.DEBUG_SEARCH) { 76.211 + Config.log.println("backward_search_range: fail."); 76.212 + } 76.213 return false; 76.214 } // while 76.215 } 76.216 @@ -261,27 +275,36 @@ 76.217 if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) { 76.218 //range = upperRange; 76.219 if (matchAt(upperRange, s, prev) != -1) { 76.220 - if (!isFindLongest(regex.options)) return true; 76.221 + if (!isFindLongest(regex.options)) { 76.222 + return true; 76.223 + } 76.224 } 76.225 } else { 76.226 //range = upperRange; 76.227 - if (matchAt(upperRange, s, prev) != -1) return true; 76.228 + if (matchAt(upperRange, s, prev) != -1) { 76.229 + return true; 76.230 + } 76.231 } 76.232 } else { 76.233 if (Config.USE_FIND_LONGEST_SEARCH_ALL_OF_RANGE) { 76.234 if (matchAt(end, s, prev) != -1) { 76.235 //range = upperRange; 76.236 - if (!isFindLongest(regex.options)) return true; 76.237 + if (!isFindLongest(regex.options)) { 76.238 + return true; 76.239 + } 76.240 } 76.241 } else { 76.242 //range = upperRange; 76.243 - if (matchAt(end, s, prev) != -1) return true; 76.244 + if (matchAt(end, s, prev) != -1) { 76.245 + return true; 76.246 + } 76.247 } 76.248 } 76.249 return false; 76.250 } 76.251 76.252 - public final int search(int start, int range, final int option) { 76.253 + public final int search(final int startp, final int rangep, final int option) { 76.254 + int start = startp, range = rangep; 76.255 int s, prev; 76.256 int origStart = start; 76.257 final int origRange = range; 76.258 @@ -294,7 +317,9 @@ 76.259 ", range " + (range - str)); 76.260 } 76.261 76.262 - if (start > end || start < str) return -1; 76.263 + if (start > end || start < str) { 76.264 + return -1; 76.265 + } 76.266 76.267 /* anchor optimize: resume search range */ 76.268 if (regex.anchor != 0 && str < end) { 76.269 @@ -311,7 +336,10 @@ 76.270 } else if ((regex.anchor & AnchorType.BEGIN_BUF) != 0) { 76.271 /* search str-position only */ 76.272 if (range > start) { 76.273 - if (start != str) return -1; // mismatch_no_msa; 76.274 + if (start != str) 76.275 + { 76.276 + return -1; // mismatch_no_msa; 76.277 + } 76.278 range = str + 1; 76.279 } else { 76.280 if (range <= str) { 76.281 @@ -324,7 +352,10 @@ 76.282 } else if ((regex.anchor & AnchorType.END_BUF) != 0) { 76.283 minSemiEnd = maxSemiEnd = end; 76.284 // !end_buf:! 76.285 - if (endBuf(start, range, minSemiEnd, maxSemiEnd)) return -1; // mismatch_no_msa; 76.286 + if (endBuf(start, range, minSemiEnd, maxSemiEnd)) 76.287 + { 76.288 + return -1; // mismatch_no_msa; 76.289 + } 76.290 } else if ((regex.anchor & AnchorType.SEMI_END_BUF) != 0) { 76.291 final int preEnd = EncodingHelper.stepBack(str, end, 1); 76.292 maxSemiEnd = end; 76.293 @@ -332,12 +363,18 @@ 76.294 minSemiEnd = preEnd; 76.295 if (minSemiEnd > str && start <= minSemiEnd) { 76.296 // !goto end_buf;! 76.297 - if (endBuf(start, range, minSemiEnd, maxSemiEnd)) return -1; // mismatch_no_msa; 76.298 + if (endBuf(start, range, minSemiEnd, maxSemiEnd)) 76.299 + { 76.300 + return -1; // mismatch_no_msa; 76.301 + } 76.302 } 76.303 } else { 76.304 minSemiEnd = end; 76.305 // !goto end_buf;! 76.306 - if (endBuf(start, range, minSemiEnd, maxSemiEnd)) return -1; // mismatch_no_msa; 76.307 + if (endBuf(start, range, minSemiEnd, maxSemiEnd)) 76.308 + { 76.309 + return -1; // mismatch_no_msa; 76.310 + } 76.311 } 76.312 } else if ((regex.anchor & AnchorType.ANYCHAR_STAR_ML) != 0) { 76.313 // goto !begin_position;! 76.314 @@ -359,7 +396,9 @@ 76.315 prev = -1; 76.316 msaInit(option, start); 76.317 76.318 - if (matchCheck(end, s, prev)) return match(s); 76.319 + if (matchCheck(end, s, prev)) { 76.320 + return match(s); 76.321 + } 76.322 return mismatch(); 76.323 } 76.324 return -1; // goto mismatch_no_msa; 76.325 @@ -389,49 +428,62 @@ 76.326 schRange = end; 76.327 } else { 76.328 schRange += regex.dMax; 76.329 - if (schRange > end) schRange = end; 76.330 + if (schRange > end) { 76.331 + schRange = end; 76.332 + } 76.333 } 76.334 } 76.335 - if ((end - start) < regex.thresholdLength) return mismatch(); 76.336 + if ((end - start) < regex.thresholdLength) { 76.337 + return mismatch(); 76.338 + } 76.339 76.340 if (regex.dMax != MinMaxLen.INFINITE_DISTANCE) { 76.341 do { 76.342 - if (!forwardSearchRange(chars, str, end, s, schRange, this)) return mismatch(); // low, high, lowPrev 76.343 + if (!forwardSearchRange(chars, str, end, s, schRange, this)) { 76.344 + return mismatch(); // low, high, lowPrev 76.345 + } 76.346 if (s < low) { 76.347 s = low; 76.348 prev = value; 76.349 } 76.350 while (s <= high) { 76.351 - if (matchCheck(origRange, s, prev)) return match(s); // ??? 76.352 + if (matchCheck(origRange, s, prev)) { 76.353 + return match(s); // ??? 76.354 + } 76.355 prev = s; 76.356 s++; 76.357 } 76.358 } while (s < range); 76.359 + } 76.360 + /* check only. */ 76.361 + if (!forwardSearchRange(chars, str, end, s, schRange, null)) { 76.362 return mismatch(); 76.363 + } 76.364 76.365 - } else { /* check only. */ 76.366 - if (!forwardSearchRange(chars, str, end, s, schRange, null)) return mismatch(); 76.367 - 76.368 - if ((regex.anchor & AnchorType.ANYCHAR_STAR) != 0) { 76.369 - do { 76.370 - if (matchCheck(origRange, s, prev)) return match(s); 76.371 - prev = s; 76.372 - s++; 76.373 - } while (s < range); 76.374 - return mismatch(); 76.375 - } 76.376 - 76.377 + if ((regex.anchor & AnchorType.ANYCHAR_STAR) != 0) { 76.378 + do { 76.379 + if (matchCheck(origRange, s, prev)) { 76.380 + return match(s); 76.381 + } 76.382 + prev = s; 76.383 + s++; 76.384 + } while (s < range); 76.385 + return mismatch(); 76.386 } 76.387 } 76.388 76.389 do { 76.390 - if (matchCheck(origRange, s, prev)) return match(s); 76.391 + if (matchCheck(origRange, s, prev)) { 76.392 + return match(s); 76.393 + } 76.394 prev = s; 76.395 s++; 76.396 } while (s < range); 76.397 76.398 if (s == range) { /* because empty match with /$/. */ 76.399 - if (matchCheck(origRange, s, prev)) return match(s); 76.400 + if (matchCheck(origRange, s, prev)) { 76.401 + return match(s); 76.402 + } 76.403 } 76.404 } else { /* backward search */ 76.405 if (Config.USE_MATCH_RANGE_MUST_BE_INSIDE_OF_SPECIFIED_RANGE) { 76.406 @@ -450,37 +502,51 @@ 76.407 if (regex.dMax != MinMaxLen.INFINITE_DISTANCE && (end - range) >= regex.thresholdLength) { 76.408 do { 76.409 int schStart = s + regex.dMax; 76.410 - if (schStart > end) schStart = end; 76.411 - if (!backwardSearchRange(chars, str, end, schStart, range, adjrange)) return mismatch(); // low, high 76.412 - if (s > high) s = high; 76.413 + if (schStart > end) { 76.414 + schStart = end; 76.415 + } 76.416 + if (!backwardSearchRange(chars, str, end, schStart, range, adjrange)) 76.417 + { 76.418 + return mismatch(); // low, high 76.419 + } 76.420 + if (s > high) { 76.421 + s = high; 76.422 + } 76.423 while (s != -1 && s >= low) { 76.424 prev = EncodingHelper.prevCharHead(str, s); 76.425 - if (matchCheck(origStart, s, prev)) return match(s); 76.426 + if (matchCheck(origStart, s, prev)) { 76.427 + return match(s); 76.428 + } 76.429 s = prev; 76.430 } 76.431 } while (s >= range); 76.432 return mismatch(); 76.433 - } else { /* check only. */ 76.434 - if ((end - range) < regex.thresholdLength) return mismatch(); 76.435 + } 76.436 + if ((end - range) < regex.thresholdLength) { 76.437 + return mismatch(); 76.438 + } 76.439 76.440 - int schStart = s; 76.441 - if (regex.dMax != 0) { 76.442 - if (regex.dMax == MinMaxLen.INFINITE_DISTANCE) { 76.443 + int schStart = s; 76.444 + if (regex.dMax != 0) { 76.445 + if (regex.dMax == MinMaxLen.INFINITE_DISTANCE) { 76.446 + schStart = end; 76.447 + } else { 76.448 + schStart += regex.dMax; 76.449 + if (schStart > end) { 76.450 schStart = end; 76.451 - } else { 76.452 - schStart += regex.dMax; 76.453 - if (schStart > end) { 76.454 - schStart = end; 76.455 - } 76.456 } 76.457 } 76.458 - if (!backwardSearchRange(chars, str, end, schStart, range, adjrange)) return mismatch(); 76.459 + } 76.460 + if (!backwardSearchRange(chars, str, end, schStart, range, adjrange)) { 76.461 + return mismatch(); 76.462 } 76.463 } 76.464 76.465 do { 76.466 prev = EncodingHelper.prevCharHead(str, s); 76.467 - if (matchCheck(origStart, s, prev)) return match(s); 76.468 + if (matchCheck(origStart, s, prev)) { 76.469 + return match(s); 76.470 + } 76.471 s = prev; 76.472 } while (s >= range); 76.473 76.474 @@ -488,8 +554,13 @@ 76.475 return mismatch(); 76.476 } 76.477 76.478 - private boolean endBuf(int start, int range, final int minSemiEnd, final int maxSemiEnd) { 76.479 - if ((maxSemiEnd - str) < regex.anchorDmin) return true; // mismatch_no_msa; 76.480 + private boolean endBuf(final int startp, final int rangep, final int minSemiEnd, final int maxSemiEnd) { 76.481 + int start = startp; 76.482 + int range = rangep; 76.483 + 76.484 + if ((maxSemiEnd - str) < regex.anchorDmin) { 76.485 + return true; // mismatch_no_msa; 76.486 + } 76.487 76.488 if (range > start) { 76.489 if ((minSemiEnd - start) > regex.anchorDmax) { 76.490 @@ -502,7 +573,10 @@ 76.491 if ((maxSemiEnd - (range - 1)) < regex.anchorDmin) { 76.492 range = maxSemiEnd - regex.anchorDmin + 1; 76.493 } 76.494 - if (start >= range) return true; // mismatch_no_msa; 76.495 + if (start >= range) 76.496 + { 76.497 + return true; // mismatch_no_msa; 76.498 + } 76.499 } else { 76.500 if ((minSemiEnd - range) > regex.anchorDmax) { 76.501 range = minSemiEnd - regex.anchorDmax; 76.502 @@ -510,7 +584,10 @@ 76.503 if ((maxSemiEnd - start) < regex.anchorDmin) { 76.504 start = maxSemiEnd - regex.anchorDmin; 76.505 } 76.506 - if (range > start) return true; // mismatch_no_msa; 76.507 + if (range > start) 76.508 + { 76.509 + return true; // mismatch_no_msa; 76.510 + } 76.511 } 76.512 return false; 76.513 }
77.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory.java Wed Nov 12 13:47:23 2014 -0800 77.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/MatcherFactory.java Fri Nov 14 10:03:48 2014 -0800 77.3 @@ -19,6 +19,7 @@ 77.4 */ 77.5 package jdk.nashorn.internal.runtime.regexp.joni; 77.6 77.7 +@SuppressWarnings("javadoc") 77.8 public abstract class MatcherFactory { 77.9 public abstract Matcher create(Regex regex, char[] chars, int p, int end); 77.10
78.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/MinMaxLen.java Wed Nov 12 13:47:23 2014 -0800 78.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/MinMaxLen.java Fri Nov 14 10:03:48 2014 -0800 78.3 @@ -46,24 +46,40 @@ 78.4 }; 78.5 78.6 int distanceValue() { 78.7 - if (max == INFINITE_DISTANCE) return 0; 78.8 + if (max == INFINITE_DISTANCE) { 78.9 + return 0; 78.10 + } 78.11 final int d = max - min; 78.12 /* return dist_vals[d] * 16 / (mm->min + 12); */ 78.13 return d < distValues.length ? distValues[d] : 1; 78.14 } 78.15 78.16 - int compareDistanceValue(final MinMaxLen other, int v1, int v2) { 78.17 - if (v2 <= 0) return -1; 78.18 - if (v1 <= 0) return 1; 78.19 + int compareDistanceValue(final MinMaxLen other, final int v1p, final int v2p) { 78.20 + int v1 = v1p, v2 = v2p; 78.21 + 78.22 + if (v2 <= 0) { 78.23 + return -1; 78.24 + } 78.25 + if (v1 <= 0) { 78.26 + return 1; 78.27 + } 78.28 78.29 v1 *= distanceValue(); 78.30 v2 *= other.distanceValue(); 78.31 78.32 - if (v2 > v1) return 1; 78.33 - if (v2 < v1) return -1; 78.34 + if (v2 > v1) { 78.35 + return 1; 78.36 + } 78.37 + if (v2 < v1) { 78.38 + return -1; 78.39 + } 78.40 78.41 - if (other.min < min) return 1; 78.42 - if (other.min > min) return -1; 78.43 + if (other.min < min) { 78.44 + return 1; 78.45 + } 78.46 + if (other.min > min) { 78.47 + return -1; 78.48 + } 78.49 return 0; 78.50 } 78.51 78.52 @@ -96,27 +112,33 @@ 78.53 } 78.54 78.55 void altMerge(final MinMaxLen other) { 78.56 - if (min > other.min) min = other.min; 78.57 - if (max < other.max) max = other.max; 78.58 + if (min > other.min) { 78.59 + min = other.min; 78.60 + } 78.61 + if (max < other.max) { 78.62 + max = other.max; 78.63 + } 78.64 } 78.65 78.66 static final int INFINITE_DISTANCE = 0x7FFFFFFF; 78.67 static int distanceAdd(final int d1, final int d2) { 78.68 if (d1 == INFINITE_DISTANCE || d2 == INFINITE_DISTANCE) { 78.69 return INFINITE_DISTANCE; 78.70 - } else { 78.71 - if (d1 <= INFINITE_DISTANCE - d2) return d1 + d2; 78.72 - else return INFINITE_DISTANCE; 78.73 } 78.74 + if (d1 <= INFINITE_DISTANCE - d2) { 78.75 + return d1 + d2; 78.76 + } 78.77 + return INFINITE_DISTANCE; 78.78 } 78.79 78.80 static int distanceMultiply(final int d, final int m) { 78.81 - if (m == 0) return 0; 78.82 + if (m == 0) { 78.83 + return 0; 78.84 + } 78.85 if (d < INFINITE_DISTANCE / m) { 78.86 return d * m; 78.87 - } else { 78.88 - return INFINITE_DISTANCE; 78.89 } 78.90 + return INFINITE_DISTANCE; 78.91 } 78.92 78.93 static String distanceRangeToString(final int a, final int b) {
79.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/NodeOptInfo.java Wed Nov 12 13:47:23 2014 -0800 79.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/NodeOptInfo.java Fri Nov 14 10:03:48 2014 -0800 79.3 @@ -19,6 +19,7 @@ 79.4 */ 79.5 package jdk.nashorn.internal.runtime.regexp.joni; 79.6 79.7 +@SuppressWarnings("javadoc") 79.8 public final class NodeOptInfo { 79.9 final MinMaxLen length = new MinMaxLen(); 79.10 final OptAnchorInfo anchor = new OptAnchorInfo(); 79.11 @@ -91,8 +92,12 @@ 79.12 if (other.length.max > 0) { 79.13 // TODO: make sure it is not an Oniguruma bug (casting unsigned int to int for arithmetic comparison) 79.14 int otherLengthMax = other.length.max; 79.15 - if (otherLengthMax == MinMaxLen.INFINITE_DISTANCE) otherLengthMax = -1; 79.16 - if (expr.length > otherLengthMax) expr.length = otherLengthMax; 79.17 + if (otherLengthMax == MinMaxLen.INFINITE_DISTANCE) { 79.18 + otherLengthMax = -1; 79.19 + } 79.20 + if (expr.length > otherLengthMax) { 79.21 + expr.length = otherLengthMax; 79.22 + } 79.23 if (expr.mmd.max == 0) { 79.24 exb.select(expr); 79.25 } else {
80.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/OptAnchorInfo.java Wed Nov 12 13:47:23 2014 -0800 80.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/OptAnchorInfo.java Fri Nov 14 10:03:48 2014 -0800 80.3 @@ -36,14 +36,20 @@ 80.4 80.5 void concat(final OptAnchorInfo left, final OptAnchorInfo right, final int leftLength, final int rightLength) { 80.6 leftAnchor = left.leftAnchor; 80.7 - if (leftLength == 0) leftAnchor |= right.leftAnchor; 80.8 + if (leftLength == 0) { 80.9 + leftAnchor |= right.leftAnchor; 80.10 + } 80.11 80.12 rightAnchor = right.rightAnchor; 80.13 - if (rightLength == 0) rightAnchor |= left.rightAnchor; 80.14 + if (rightLength == 0) { 80.15 + rightAnchor |= left.rightAnchor; 80.16 + } 80.17 } 80.18 80.19 boolean isSet(final int anchor) { 80.20 - if ((leftAnchor & anchor) != 0) return true; 80.21 + if ((leftAnchor & anchor) != 0) { 80.22 + return true; 80.23 + } 80.24 return (rightAnchor & anchor) != 0; 80.25 } 80.26 80.27 @@ -77,14 +83,30 @@ 80.28 static String anchorToString(final int anchor) { 80.29 final StringBuffer s = new StringBuffer("["); 80.30 80.31 - if ((anchor & AnchorType.BEGIN_BUF) !=0 ) s.append("begin-buf "); 80.32 - if ((anchor & AnchorType.BEGIN_LINE) !=0 ) s.append("begin-line "); 80.33 - if ((anchor & AnchorType.BEGIN_POSITION) !=0 ) s.append("begin-pos "); 80.34 - if ((anchor & AnchorType.END_BUF) !=0 ) s.append("end-buf "); 80.35 - if ((anchor & AnchorType.SEMI_END_BUF) !=0 ) s.append("semi-end-buf "); 80.36 - if ((anchor & AnchorType.END_LINE) !=0 ) s.append("end-line "); 80.37 - if ((anchor & AnchorType.ANYCHAR_STAR) !=0 ) s.append("anychar-star "); 80.38 - if ((anchor & AnchorType.ANYCHAR_STAR_ML) !=0 ) s.append("anychar-star-pl "); 80.39 + if ((anchor & AnchorType.BEGIN_BUF) !=0 ) { 80.40 + s.append("begin-buf "); 80.41 + } 80.42 + if ((anchor & AnchorType.BEGIN_LINE) !=0 ) { 80.43 + s.append("begin-line "); 80.44 + } 80.45 + if ((anchor & AnchorType.BEGIN_POSITION) !=0 ) { 80.46 + s.append("begin-pos "); 80.47 + } 80.48 + if ((anchor & AnchorType.END_BUF) !=0 ) { 80.49 + s.append("end-buf "); 80.50 + } 80.51 + if ((anchor & AnchorType.SEMI_END_BUF) !=0 ) { 80.52 + s.append("semi-end-buf "); 80.53 + } 80.54 + if ((anchor & AnchorType.END_LINE) !=0 ) { 80.55 + s.append("end-line "); 80.56 + } 80.57 + if ((anchor & AnchorType.ANYCHAR_STAR) !=0 ) { 80.58 + s.append("anychar-star "); 80.59 + } 80.60 + if ((anchor & AnchorType.ANYCHAR_STAR_ML) !=0 ) { 80.61 + s.append("anychar-star-pl "); 80.62 + } 80.63 s.append("]"); 80.64 80.65 return s.toString();
81.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java Wed Nov 12 13:47:23 2014 -0800 81.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/OptExactInfo.java Fri Nov 14 10:03:48 2014 -0800 81.3 @@ -56,7 +56,9 @@ 81.4 81.5 void concat(final OptExactInfo other) { 81.6 if (!ignoreCase && other.ignoreCase) { 81.7 - if (length >= other.length) return; /* avoid */ 81.8 + if (length >= other.length) { 81.9 + return; /* avoid */ 81.10 + } 81.11 ignoreCase = true; 81.12 } 81.13 81.14 @@ -65,7 +67,9 @@ 81.15 81.16 int i; 81.17 for (i = length; p < end;) { 81.18 - if (i + 1 > OPT_EXACT_MAXLEN) break; 81.19 + if (i + 1 > OPT_EXACT_MAXLEN) { 81.20 + break; 81.21 + } 81.22 chars[i++] = other.chars[p++]; 81.23 } 81.24 81.25 @@ -74,15 +78,20 @@ 81.26 81.27 final OptAnchorInfo tmp = new OptAnchorInfo(); 81.28 tmp.concat(anchor, other.anchor, 1, 1); 81.29 - if (!other.reachEnd) tmp.rightAnchor = 0; 81.30 + if (!other.reachEnd) { 81.31 + tmp.rightAnchor = 0; 81.32 + } 81.33 anchor.copy(tmp); 81.34 } 81.35 81.36 // ?? raw is not used here 81.37 - void concatStr(final char[] lchars, int p, final int end, final boolean raw) { 81.38 + void concatStr(final char[] lchars, final int pp, final int end, final boolean raw) { 81.39 int i; 81.40 + int p = pp; 81.41 for (i = length; p < end && i < OPT_EXACT_MAXLEN;) { 81.42 - if (i + 1 > OPT_EXACT_MAXLEN) break; 81.43 + if (i + 1 > OPT_EXACT_MAXLEN) { 81.44 + break; 81.45 + } 81.46 chars[i++] = lchars[p++]; 81.47 } 81.48 81.49 @@ -102,17 +111,23 @@ 81.50 81.51 int i; 81.52 for (i = 0; i < length && i < other.length; i++) { 81.53 - if (chars[i] != other.chars[i]) break; 81.54 + if (chars[i] != other.chars[i]) { 81.55 + break; 81.56 + } 81.57 } 81.58 81.59 - if (!other.reachEnd || i<other.length || i<length) reachEnd = false; 81.60 + if (!other.reachEnd || i<other.length || i<length) { 81.61 + reachEnd = false; 81.62 + } 81.63 81.64 length = i; 81.65 ignoreCase |= other.ignoreCase; 81.66 81.67 anchor.altMerge(other.anchor); 81.68 81.69 - if (!reachEnd) anchor.rightAnchor = 0; 81.70 + if (!reachEnd) { 81.71 + anchor.rightAnchor = 0; 81.72 + } 81.73 } 81.74 81.75 81.76 @@ -130,20 +145,32 @@ 81.77 v2 = OptMapInfo.positionValue(chars[0] & 0xff); 81.78 v1 = OptMapInfo.positionValue(alt.chars[0] & 0xff); 81.79 81.80 - if (length > 1) v1 += 5; 81.81 - if (alt.length > 1) v2 += 5; 81.82 + if (length > 1) { 81.83 + v1 += 5; 81.84 + } 81.85 + if (alt.length > 1) { 81.86 + v2 += 5; 81.87 + } 81.88 } 81.89 81.90 - if (!ignoreCase) v1 *= 2; 81.91 - if (!alt.ignoreCase) v2 *= 2; 81.92 + if (!ignoreCase) { 81.93 + v1 *= 2; 81.94 + } 81.95 + if (!alt.ignoreCase) { 81.96 + v2 *= 2; 81.97 + } 81.98 81.99 - if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) copy(alt); 81.100 + if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) { 81.101 + copy(alt); 81.102 + } 81.103 } 81.104 81.105 // comp_opt_exact_or_map_info 81.106 private static final int COMP_EM_BASE = 20; 81.107 int compare(final OptMapInfo m) { 81.108 - if (m.value <= 0) return -1; 81.109 + if (m.value <= 0) { 81.110 + return -1; 81.111 + } 81.112 81.113 final int ve = COMP_EM_BASE * length * (ignoreCase ? 1 : 2); 81.114 final int vm = COMP_EM_BASE * 5 * 2 / m.value;
82.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/OptMapInfo.java Wed Nov 12 13:47:23 2014 -0800 82.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/OptMapInfo.java Fri Nov 14 10:03:48 2014 -0800 82.3 @@ -31,7 +31,9 @@ 82.4 mmd.clear(); 82.5 anchor.clear(); 82.6 value = 0; 82.7 - for (int i=0; i<map.length; i++) map[i] = 0; 82.8 + for (int i=0; i<map.length; i++) { 82.9 + map[i] = 0; 82.10 + } 82.11 } 82.12 82.13 void copy(final OptMapInfo other) { 82.14 @@ -50,11 +52,10 @@ 82.15 } 82.16 } 82.17 82.18 - void addCharAmb(final char[] chars, final int p, final int end, int caseFoldFlag) { 82.19 + void addCharAmb(final char[] chars, final int p, final int end, final int caseFoldFlag) { 82.20 addChar(chars[p]); 82.21 82.22 - caseFoldFlag &= ~Config.INTERNAL_ENC_CASE_FOLD_MULTI_CHAR; 82.23 - final char[]items = EncodingHelper.caseFoldCodesByString(caseFoldFlag, chars[p]); 82.24 + final char[]items = EncodingHelper.caseFoldCodesByString(caseFoldFlag & ~Config.INTERNAL_ENC_CASE_FOLD_MULTI_CHAR, chars[p]); 82.25 82.26 for (int i=0; i<items.length; i++) { 82.27 addChar(items[i]); 82.28 @@ -64,7 +65,9 @@ 82.29 // select_opt_map_info 82.30 private static final int z = 1<<15; /* 32768: something big value */ 82.31 void select(final OptMapInfo alt) { 82.32 - if (alt.value == 0) return; 82.33 + if (alt.value == 0) { 82.34 + return; 82.35 + } 82.36 if (value == 0) { 82.37 copy(alt); 82.38 return; 82.39 @@ -73,13 +76,17 @@ 82.40 final int v1 = z / value; 82.41 final int v2 = z /alt.value; 82.42 82.43 - if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) copy(alt); 82.44 + if (mmd.compareDistanceValue(alt.mmd, v1, v2) > 0) { 82.45 + copy(alt); 82.46 + } 82.47 } 82.48 82.49 // alt_merge_opt_map_info 82.50 void altMerge(final OptMapInfo other) { 82.51 /* if (! is_equal_mml(&to->mmd, &add->mmd)) return ; */ 82.52 - if (value == 0) return; 82.53 + if (value == 0) { 82.54 + return; 82.55 + } 82.56 if (other.value == 0 || mmd.max < other.mmd.max) { 82.57 clear(); 82.58 return; 82.59 @@ -89,8 +96,12 @@ 82.60 82.61 int val = 0; 82.62 for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) { 82.63 - if (other.map[i] != 0) map[i] = 1; 82.64 - if (map[i] != 0) val += positionValue(i); 82.65 + if (other.map[i] != 0) { 82.66 + map[i] = 1; 82.67 + } 82.68 + if (map[i] != 0) { 82.69 + val += positionValue(i); 82.70 + } 82.71 } 82.72 82.73 value = val; 82.74 @@ -112,9 +123,8 @@ 82.75 static int positionValue(final int i) { 82.76 if (i < ByteValTable.length) { 82.77 return ByteValTable[i]; 82.78 - } else { 82.79 - return 4; /* Take it easy. */ 82.80 } 82.81 + return 4; /* Take it easy. */ 82.82 } 82.83 82.84 }
83.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Option.java Wed Nov 12 13:47:23 2014 -0800 83.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Option.java Fri Nov 14 10:03:48 2014 -0800 83.3 @@ -19,6 +19,7 @@ 83.4 */ 83.5 package jdk.nashorn.internal.runtime.regexp.joni; 83.6 83.7 +@SuppressWarnings("javadoc") 83.8 public class Option { 83.9 83.10 /* options */ 83.11 @@ -43,19 +44,43 @@ 83.12 83.13 public static String toString(final int option) { 83.14 String options = ""; 83.15 - if (isIgnoreCase(option)) options += "IGNORECASE "; 83.16 - if (isExtend(option)) options += "EXTEND "; 83.17 - if (isMultiline(option)) options += "MULTILINE "; 83.18 - if (isSingleline(option)) options += "SINGLELINE "; 83.19 - if (isFindLongest(option)) options += "FIND_LONGEST "; 83.20 - if (isFindNotEmpty(option)) options += "FIND_NOT_EMPTY "; 83.21 - if (isNegateSingleline(option)) options += "NEGATE_SINGLELINE "; 83.22 - if (isDontCaptureGroup(option)) options += "DONT_CAPTURE_GROUP "; 83.23 - if (isCaptureGroup(option)) options += "CAPTURE_GROUP "; 83.24 + if (isIgnoreCase(option)) { 83.25 + options += "IGNORECASE "; 83.26 + } 83.27 + if (isExtend(option)) { 83.28 + options += "EXTEND "; 83.29 + } 83.30 + if (isMultiline(option)) { 83.31 + options += "MULTILINE "; 83.32 + } 83.33 + if (isSingleline(option)) { 83.34 + options += "SINGLELINE "; 83.35 + } 83.36 + if (isFindLongest(option)) { 83.37 + options += "FIND_LONGEST "; 83.38 + } 83.39 + if (isFindNotEmpty(option)) { 83.40 + options += "FIND_NOT_EMPTY "; 83.41 + } 83.42 + if (isNegateSingleline(option)) { 83.43 + options += "NEGATE_SINGLELINE "; 83.44 + } 83.45 + if (isDontCaptureGroup(option)) { 83.46 + options += "DONT_CAPTURE_GROUP "; 83.47 + } 83.48 + if (isCaptureGroup(option)) { 83.49 + options += "CAPTURE_GROUP "; 83.50 + } 83.51 83.52 - if (isNotBol(option)) options += "NOTBOL "; 83.53 - if (isNotEol(option)) options += "NOTEOL "; 83.54 - if (isPosixRegion(option)) options += "POSIX_REGION "; 83.55 + if (isNotBol(option)) { 83.56 + options += "NOTBOL "; 83.57 + } 83.58 + if (isNotEol(option)) { 83.59 + options += "NOTEOL "; 83.60 + } 83.61 + if (isPosixRegion(option)) { 83.62 + options += "POSIX_REGION "; 83.63 + } 83.64 83.65 return options; 83.66 }
84.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Wed Nov 12 13:47:23 2014 -0800 84.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Fri Nov 14 10:03:48 2014 -0800 84.3 @@ -22,7 +22,6 @@ 84.4 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsOnOff; 84.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isDontCaptureGroup; 84.6 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isIgnoreCase; 84.7 - 84.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnchorNode; 84.9 import jdk.nashorn.internal.runtime.regexp.joni.ast.AnyCharNode; 84.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.BackRefNode; 84.11 @@ -77,7 +76,9 @@ 84.12 restore(); 84.13 return true; 84.14 } 84.15 - if (c == syntax.metaCharTable.esc) inEsc = true; 84.16 + if (c == syntax.metaCharTable.esc) { 84.17 + inEsc = true; 84.18 + } 84.19 } 84.20 } 84.21 84.22 @@ -165,7 +166,9 @@ 84.23 arg.vIsRaw = false; 84.24 fetchTokenInCC(); 84.25 fetched = true; 84.26 - if (token.type == TokenType.CC_RANGE || andStart) env.ccEscWarn("-"); /* [--x] or [a&&-x] is warned. */ 84.27 + if (token.type == TokenType.CC_RANGE || andStart) { 84.28 + env.ccEscWarn("-"); /* [--x] or [a&&-x] is warned. */ 84.29 + } 84.30 parseCharClassValEntry(cc, arg); // goto val_entry 84.31 break; 84.32 } else if (arg.state == CCSTATE.RANGE) { 84.33 @@ -214,7 +217,9 @@ 84.34 prevCC.and(cc); 84.35 } else { 84.36 prevCC = cc; 84.37 - if (workCC == null) workCC = new CClassNode(); 84.38 + if (workCC == null) { 84.39 + workCC = new CClassNode(); 84.40 + } 84.41 cc = workCC; 84.42 } 84.43 cc.clear(); 84.44 @@ -227,7 +232,9 @@ 84.45 throw new InternalException(ERR_PARSER_BUG); 84.46 } // switch 84.47 84.48 - if (!fetched) fetchTokenInCC(); 84.49 + if (!fetched) { 84.50 + fetchTokenInCC(); 84.51 + } 84.52 84.53 } // while 84.54 84.55 @@ -443,7 +450,10 @@ 84.56 } 84.57 84.58 private Node parseExp(final TokenType term) { 84.59 - if (token.type == term) return StringNode.EMPTY; // goto end_of_token 84.60 + if (token.type == term) 84.61 + { 84.62 + return StringNode.EMPTY; // goto end_of_token 84.63 + } 84.64 84.65 Node node = null; 84.66 boolean group = false; 84.67 @@ -474,9 +484,8 @@ 84.68 } 84.69 if (token.escaped) { 84.70 return parseExpTkRawByte(group); // goto tk_raw_byte 84.71 - } else { 84.72 - return parseExpTkByte(group); // goto tk_byte 84.73 } 84.74 + return parseExpTkByte(group); // goto tk_byte 84.75 case STRING: 84.76 return parseExpTkByte(group); // tk_byte: 84.77 84.78 @@ -496,7 +505,9 @@ 84.79 if (Config.NON_UNICODE_SDW) { 84.80 final CClassNode cc = new CClassNode(); 84.81 cc.addCType(token.getPropCType(), false, env, this); 84.82 - if (token.getPropNot()) cc.setNot(); 84.83 + if (token.getPropNot()) { 84.84 + cc.setNot(); 84.85 + } 84.86 node = cc; 84.87 } 84.88 break; 84.89 @@ -507,7 +518,9 @@ 84.90 // #ifdef USE_SHARED_CCLASS_TABLE ... #endif 84.91 final CClassNode ccn = new CClassNode(); 84.92 ccn.addCType(token.getPropCType(), false, env, this); 84.93 - if (token.getPropNot()) ccn.setNot(); 84.94 + if (token.getPropNot()) { 84.95 + ccn.setNot(); 84.96 + } 84.97 node = ccn; 84.98 break; 84.99 84.100 @@ -555,9 +568,8 @@ 84.101 if (syntax.contextIndepRepeatOps()) { 84.102 if (syntax.contextInvalidRepeatOps()) { 84.103 throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_NOT_SPECIFIED); 84.104 - } else { 84.105 - node = StringNode.EMPTY; // node_new_empty 84.106 } 84.107 + node = StringNode.EMPTY; // node_new_empty 84.108 } else { 84.109 return parseExpTkByte(group); // goto tk_byte 84.110 } 84.111 @@ -578,7 +590,9 @@ 84.112 final StringNode node = new StringNode(chars, token.backP, p); // tk_byte: 84.113 while (true) { 84.114 fetchToken(); 84.115 - if (token.type != TokenType.STRING) break; 84.116 + if (token.type != TokenType.STRING) { 84.117 + break; 84.118 + } 84.119 84.120 if (token.backP == node.end) { 84.121 node.end = p; // non escaped character, remain shared, just increase shared range 84.122 @@ -605,7 +619,8 @@ 84.123 return parseExpRepeat(node, group); 84.124 } 84.125 84.126 - private Node parseExpRepeat(Node target, final boolean group) { 84.127 + private Node parseExpRepeat(final Node targetp, final boolean group) { 84.128 + Node target = targetp; 84.129 while (token.type == TokenType.OP_REPEAT || token.type == TokenType.INTERVAL) { // repeat: 84.130 if (target.isInvalidQuantifier()) { 84.131 throw new SyntaxException(ERR_TARGET_OF_REPEAT_OPERATOR_INVALID); 84.132 @@ -674,24 +689,25 @@ 84.133 84.134 if (token.type == TokenType.EOT || token.type == term || token.type == TokenType.ALT) { 84.135 return node; 84.136 - } else { 84.137 - final ConsAltNode top = ConsAltNode.newListNode(node, null); 84.138 - ConsAltNode t = top; 84.139 + } 84.140 + final ConsAltNode top = ConsAltNode.newListNode(node, null); 84.141 + ConsAltNode t = top; 84.142 84.143 - while (token.type != TokenType.EOT && token.type != term && token.type != TokenType.ALT) { 84.144 - node = parseExp(term); 84.145 - if (node.getType() == NodeType.LIST) { 84.146 - t.setCdr((ConsAltNode)node); 84.147 - while (((ConsAltNode)node).cdr != null ) node = ((ConsAltNode)node).cdr; 84.148 + while (token.type != TokenType.EOT && token.type != term && token.type != TokenType.ALT) { 84.149 + node = parseExp(term); 84.150 + if (node.getType() == NodeType.LIST) { 84.151 + t.setCdr((ConsAltNode)node); 84.152 + while (((ConsAltNode)node).cdr != null ) { 84.153 + node = ((ConsAltNode)node).cdr; 84.154 + } 84.155 84.156 - t = ((ConsAltNode)node); 84.157 - } else { 84.158 - t.setCdr(ConsAltNode.newListNode(node, null)); 84.159 - t = t.cdr; 84.160 - } 84.161 + t = ((ConsAltNode)node); 84.162 + } else { 84.163 + t.setCdr(ConsAltNode.newListNode(node, null)); 84.164 + t = t.cdr; 84.165 } 84.166 - return top; 84.167 } 84.168 + return top; 84.169 } 84.170 84.171 /* term_tok: TK_EOT or TK_SUBEXP_CLOSE */ 84.172 @@ -711,7 +727,9 @@ 84.173 t = t.cdr; 84.174 } 84.175 84.176 - if (token.type != term) parseSubExpError(term); 84.177 + if (token.type != term) { 84.178 + parseSubExpError(term); 84.179 + } 84.180 return top; 84.181 } else { 84.182 parseSubExpError(term); 84.183 @@ -719,12 +737,11 @@ 84.184 } 84.185 } 84.186 84.187 - private void parseSubExpError(final TokenType term) { 84.188 + private static void parseSubExpError(final TokenType term) { 84.189 if (term == TokenType.SUBEXP_CLOSE) { 84.190 throw new SyntaxException(ERR_END_PATTERN_WITH_UNMATCHED_PARENTHESIS); 84.191 - } else { 84.192 - throw new InternalException(ERR_PARSER_BUG); 84.193 } 84.194 + throw new InternalException(ERR_PARSER_BUG); 84.195 } 84.196 84.197 private Node parseRegexp() {
85.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java Wed Nov 12 13:47:23 2014 -0800 85.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Regex.java Fri Nov 14 10:03:48 2014 -0800 85.3 @@ -24,6 +24,7 @@ 85.4 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 85.5 import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; 85.6 85.7 +@SuppressWarnings("javadoc") 85.8 public final class Regex implements RegexState { 85.9 85.10 int[] code; /* compiled pattern */ 85.11 @@ -107,7 +108,8 @@ 85.12 } 85.13 85.14 // onig_alloc_init 85.15 - public Regex(final char[] chars, final int p, final int end, int option, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) { 85.16 + public Regex(final char[] chars, final int p, final int end, final int optionp, final int caseFoldFlag, final Syntax syntax, final WarnCallback warnings) { 85.17 + int option = optionp; 85.18 85.19 if ((option & (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) == 85.20 (Option.DONT_CAPTURE_GROUP | Option.CAPTURE_GROUP)) { 85.21 @@ -169,19 +171,33 @@ 85.22 85.23 if (len < Config.CHAR_TABLE_SIZE) { 85.24 // map/skip 85.25 - if (map == null) map = new byte[Config.CHAR_TABLE_SIZE]; 85.26 + if (map == null) { 85.27 + map = new byte[Config.CHAR_TABLE_SIZE]; 85.28 + } 85.29 85.30 - for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) map[i] = (byte)len; 85.31 - for (int i=0; i<len-1; i++) map[chars[p + i] & 0xff] = (byte)(len - 1 -i); // oxff ?? 85.32 + for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) { 85.33 + map[i] = (byte)len; 85.34 + } 85.35 + for (int i=0; i<len-1; i++) 85.36 + { 85.37 + map[chars[p + i] & 0xff] = (byte)(len - 1 -i); // oxff ?? 85.38 + } 85.39 } else { 85.40 - if (intMap == null) intMap = new int[Config.CHAR_TABLE_SIZE]; 85.41 + if (intMap == null) { 85.42 + intMap = new int[Config.CHAR_TABLE_SIZE]; 85.43 + } 85.44 85.45 - for (int i=0; i<len-1; i++) intMap[chars[p + i] & 0xff] = len - 1 - i; // oxff ?? 85.46 + for (int i=0; i<len-1; i++) 85.47 + { 85.48 + intMap[chars[p + i] & 0xff] = len - 1 - i; // oxff ?? 85.49 + } 85.50 } 85.51 } 85.52 85.53 void setExactInfo(final OptExactInfo e) { 85.54 - if (e.length == 0) return; 85.55 + if (e.length == 0) { 85.56 + return; 85.57 + } 85.58 85.59 // shall we copy that ? 85.60 exact = e.chars; 85.61 @@ -257,7 +273,11 @@ 85.62 s.append("exact: [").append(exact, exactP, exactEnd - exactP).append("]: length: ").append(exactEnd - exactP).append("\n"); 85.63 } else if (searchAlgorithm == SearchAlgorithm.MAP) { 85.64 int n=0; 85.65 - for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) if (map[i] != 0) n++; 85.66 + for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) { 85.67 + if (map[i] != 0) { 85.68 + n++; 85.69 + } 85.70 + } 85.71 85.72 s.append("map: n = ").append(n).append("\n"); 85.73 if (n > 0) {
86.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Wed Nov 12 13:47:23 2014 -0800 86.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Fri Nov 14 10:03:48 2014 -0800 86.3 @@ -19,6 +19,7 @@ 86.4 */ 86.5 package jdk.nashorn.internal.runtime.regexp.joni; 86.6 86.7 +@SuppressWarnings("javadoc") 86.8 public final class Region { 86.9 static final int REGION_NOTPOS = -1; 86.10 86.11 @@ -36,7 +37,9 @@ 86.12 public String toString() { 86.13 final StringBuilder sb = new StringBuilder(); 86.14 sb.append("Region: \n"); 86.15 - for (int i=0; i<beg.length; i++) sb.append(" " + i + ": (" + beg[i] + "-" + end[i] + ")"); 86.16 + for (int i=0; i<beg.length; i++) { 86.17 + sb.append(" " + i + ": (" + beg[i] + "-" + end[i] + ")"); 86.18 + } 86.19 return sb.toString(); 86.20 } 86.21
87.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java Wed Nov 12 13:47:23 2014 -0800 87.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScanEnvironment.java Fri Nov 14 10:03:48 2014 -0800 87.3 @@ -20,11 +20,11 @@ 87.4 package jdk.nashorn.internal.runtime.regexp.joni; 87.5 87.6 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsClear; 87.7 - 87.8 import jdk.nashorn.internal.runtime.regexp.joni.ast.Node; 87.9 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 87.10 import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; 87.11 87.12 +@SuppressWarnings("javadoc") 87.13 public final class ScanEnvironment { 87.14 87.15 private static final int SCANENV_MEMNODES_SIZE = 8; 87.16 @@ -92,7 +92,10 @@ 87.17 case 'b': return '\010'; 87.18 case 'e': return '\033'; 87.19 case 'v': 87.20 - if (syntax.op2EscVVtab()) return 11; // ??? 87.21 + if (syntax.op2EscVVtab()) 87.22 + { 87.23 + return 11; // ??? 87.24 + } 87.25 break; 87.26 default: 87.27 break;
88.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Wed Nov 12 13:47:23 2014 -0800 88.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Fri Nov 14 10:03:48 2014 -0800 88.3 @@ -60,7 +60,9 @@ 88.4 if (Character.isDigit(c)) { 88.5 final int onum = num; 88.6 num = num * 10 + EncodingHelper.digitVal(c); 88.7 - if (((onum ^ num) & INT_SIGN_BIT) != 0) return -1; 88.8 + if (((onum ^ num) & INT_SIGN_BIT) != 0) { 88.9 + return -1; 88.10 + } 88.11 } else { 88.12 unfetch(); 88.13 break; 88.14 @@ -70,16 +72,19 @@ 88.15 return num; 88.16 } 88.17 88.18 - protected final int scanUnsignedHexadecimalNumber(int maxLength) { 88.19 + protected final int scanUnsignedHexadecimalNumber(final int maxLength) { 88.20 final int last = c; 88.21 int num = 0; 88.22 - while(left() && maxLength-- != 0) { 88.23 + int ml = maxLength; 88.24 + while(left() && ml-- != 0) { 88.25 fetch(); 88.26 if (EncodingHelper.isXDigit(c)) { 88.27 final int onum = num; 88.28 final int val = EncodingHelper.xdigitVal(c); 88.29 num = (num << 4) + val; 88.30 - if (((onum ^ num) & INT_SIGN_BIT) != 0) return -1; 88.31 + if (((onum ^ num) & INT_SIGN_BIT) != 0) { 88.32 + return -1; 88.33 + } 88.34 } else { 88.35 unfetch(); 88.36 break; 88.37 @@ -89,16 +94,19 @@ 88.38 return num; 88.39 } 88.40 88.41 - protected final int scanUnsignedOctalNumber(int maxLength) { 88.42 + protected final int scanUnsignedOctalNumber(final int maxLength) { 88.43 final int last = c; 88.44 int num = 0; 88.45 - while(left() && maxLength-- != 0) { 88.46 + int ml = maxLength; 88.47 + while(left() && ml-- != 0) { 88.48 fetch(); 88.49 if (Character.isDigit(c) && c < '8') { 88.50 final int onum = num; 88.51 final int val = EncodingHelper.odigitVal(c); 88.52 num = (num << 3) + val; 88.53 - if (((onum ^ num) & INT_SIGN_BIT) != 0) return -1; 88.54 + if (((onum ^ num) & INT_SIGN_BIT) != 0) { 88.55 + return -1; 88.56 + } 88.57 } else { 88.58 unfetch(); 88.59 break; 88.60 @@ -144,8 +152,8 @@ 88.61 return p < stop ? chars[p] : 0; 88.62 } 88.63 88.64 - protected final boolean peekIs(final int c) { 88.65 - return peek() == c; 88.66 + protected final boolean peekIs(final int ch) { 88.67 + return peek() == ch; 88.68 } 88.69 88.70 protected final boolean left() {
89.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/SearchAlgorithm.java Wed Nov 12 13:47:23 2014 -0800 89.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/SearchAlgorithm.java Fri Nov 14 10:03:48 2014 -0800 89.3 @@ -19,6 +19,7 @@ 89.4 */ 89.5 package jdk.nashorn.internal.runtime.regexp.joni; 89.6 89.7 +@SuppressWarnings("javadoc") 89.8 public abstract class SearchAlgorithm { 89.9 89.10 public abstract String getName(); 89.11 @@ -62,7 +63,9 @@ 89.12 int end = textEnd; 89.13 end -= targetEnd - targetP - 1; 89.14 89.15 - if (end > textRange) end = textRange; 89.16 + if (end > textRange) { 89.17 + end = textRange; 89.18 + } 89.19 89.20 int s = textP; 89.21 89.22 @@ -71,11 +74,15 @@ 89.23 int p = s + 1; 89.24 int t = targetP + 1; 89.25 while (t < targetEnd) { 89.26 - if (target[t] != text[p++]) break; 89.27 + if (target[t] != text[p++]) { 89.28 + break; 89.29 + } 89.30 t++; 89.31 } 89.32 89.33 - if (t == targetEnd) return s; 89.34 + if (t == targetEnd) { 89.35 + return s; 89.36 + } 89.37 } 89.38 s++; 89.39 } 89.40 @@ -101,10 +108,14 @@ 89.41 int p = s + 1; 89.42 int t = targetP + 1; 89.43 while (t < targetEnd) { 89.44 - if (target[t] != text[p++]) break; 89.45 + if (target[t] != text[p++]) { 89.46 + break; 89.47 + } 89.48 t++; 89.49 } 89.50 - if (t == targetEnd) return s; 89.51 + if (t == targetEnd) { 89.52 + return s; 89.53 + } 89.54 } 89.55 // s = enc.prevCharHead or s = s <= adjustText ? -1 : s - 1; 89.56 s--; 89.57 @@ -114,10 +125,8 @@ 89.58 }; 89.59 89.60 public static final class SLOW_IC extends SearchAlgorithm { 89.61 - private final int caseFoldFlag; 89.62 - 89.63 public SLOW_IC(final Regex regex) { 89.64 - this.caseFoldFlag = regex.caseFoldFlag; 89.65 + //empty 89.66 } 89.67 89.68 @Override 89.69 @@ -134,11 +143,15 @@ 89.70 int end = textEnd; 89.71 end -= targetEnd - targetP - 1; 89.72 89.73 - if (end > textRange) end = textRange; 89.74 + if (end > textRange) { 89.75 + end = textRange; 89.76 + } 89.77 int s = textP; 89.78 89.79 while (s < end) { 89.80 - if (lowerCaseMatch(target, targetP, targetEnd, text, s, textEnd)) return s; 89.81 + if (lowerCaseMatch(target, targetP, targetEnd, text, s, textEnd)) { 89.82 + return s; 89.83 + } 89.84 s++; 89.85 } 89.86 return -1; 89.87 @@ -158,17 +171,21 @@ 89.88 } 89.89 89.90 while (s >= textP) { 89.91 - if (lowerCaseMatch(target, targetP, targetEnd, text, s, textEnd)) return s; 89.92 + if (lowerCaseMatch(target, targetP, targetEnd, text, s, textEnd)) { 89.93 + return s; 89.94 + } 89.95 s = EncodingHelper.prevCharHead(adjustText, s); 89.96 } 89.97 return -1; 89.98 } 89.99 89.100 - private boolean lowerCaseMatch(final char[] t, int tP, final int tEnd, 89.101 - final char[] chars, int p, final int end) { 89.102 + private static boolean lowerCaseMatch(final char[] t, final int tPp, final int tEnd, 89.103 + final char[] chars, final int pp, final int end) { 89.104 89.105 - while (tP < tEnd) { 89.106 - if (t[tP++] != EncodingHelper.toLowerCase(chars[p++])) return false; 89.107 + for (int tP = tPp, p = pp; tP < tEnd; ) { 89.108 + if (t[tP++] != EncodingHelper.toLowerCase(chars[p++])) { 89.109 + return false; 89.110 + } 89.111 } 89.112 return true; 89.113 } 89.114 @@ -188,7 +205,9 @@ 89.115 final int targetEnd = regex.exactEnd; 89.116 89.117 int end = textRange + (targetEnd - targetP) - 1; 89.118 - if (end > textEnd) end = textEnd; 89.119 + if (end > textEnd) { 89.120 + end = textEnd; 89.121 + } 89.122 89.123 final int tail = targetEnd - 1; 89.124 int s = textP + (targetEnd - targetP) - 1; 89.125 @@ -199,7 +218,9 @@ 89.126 int t = tail; 89.127 89.128 while (text[p] == target[t]) { 89.129 - if (t == targetP) return p; 89.130 + if (t == targetP) { 89.131 + return p; 89.132 + } 89.133 p--; t--; 89.134 } 89.135 89.136 @@ -211,7 +232,9 @@ 89.137 int t = tail; 89.138 89.139 while (text[p] == target[t]) { 89.140 - if (t == targetP) return p; 89.141 + if (t == targetP) { 89.142 + return p; 89.143 + } 89.144 p--; t--; 89.145 } 89.146 89.147 @@ -249,7 +272,9 @@ 89.148 while (t < targetEnd && text[p] == target[t]) { 89.149 p++; t++; 89.150 } 89.151 - if (t == targetEnd) return s; 89.152 + if (t == targetEnd) { 89.153 + return s; 89.154 + } 89.155 89.156 s -= regex.intMapBackward[text[s] & 0xff]; 89.157 } 89.158 @@ -268,8 +293,12 @@ 89.159 89.160 final int len = end - p; 89.161 89.162 - for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) skip[i] = len; 89.163 - for (int i=len-1; i>0; i--) skip[chars[i] & 0xff] = i; 89.164 + for (int i=0; i<Config.CHAR_TABLE_SIZE; i++) { 89.165 + skip[i] = len; 89.166 + } 89.167 + for (int i=len-1; i>0; i--) { 89.168 + skip[chars[i] & 0xff] = i; 89.169 + } 89.170 } 89.171 }; 89.172 89.173 @@ -286,7 +315,9 @@ 89.174 int s = textP; 89.175 89.176 while (s < textRange) { 89.177 - if (text[s] > 0xff || map[text[s]] != 0) return s; 89.178 + if (text[s] > 0xff || map[text[s]] != 0) { 89.179 + return s; 89.180 + } 89.181 s++; 89.182 } 89.183 return -1; 89.184 @@ -297,9 +328,13 @@ 89.185 final byte[] map = regex.map; 89.186 int s = textStart; 89.187 89.188 - if (s >= textEnd) s = textEnd - 1; 89.189 + if (s >= textEnd) { 89.190 + s = textEnd - 1; 89.191 + } 89.192 while (s >= textP) { 89.193 - if (text[s] > 0xff || map[text[s]] != 0) return s; 89.194 + if (text[s] > 0xff || map[text[s]] != 0) { 89.195 + return s; 89.196 + } 89.197 s--; 89.198 } 89.199 return -1;
90.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Wed Nov 12 13:47:23 2014 -0800 90.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Fri Nov 14 10:03:48 2014 -0800 90.3 @@ -20,7 +20,6 @@ 90.4 package jdk.nashorn.internal.runtime.regexp.joni; 90.5 90.6 import static jdk.nashorn.internal.runtime.regexp.joni.BitStatus.bsAt; 90.7 - 90.8 import java.lang.ref.WeakReference; 90.9 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackPopLevel; 90.10 import jdk.nashorn.internal.runtime.regexp.joni.constants.StackType; 90.11 @@ -61,12 +60,14 @@ 90.12 90.13 static final ThreadLocal<WeakReference<StackEntry[]>> stacks 90.14 = new ThreadLocal<WeakReference<StackEntry[]>>() { 90.15 + @SuppressWarnings("unused") 90.16 @Override 90.17 protected WeakReference<StackEntry[]> initialValue() { 90.18 return new WeakReference<StackEntry[]>(allocateStack()); 90.19 } 90.20 }; 90.21 90.22 + @SuppressWarnings("unused") 90.23 private static StackEntry[] fetchStack() { 90.24 WeakReference<StackEntry[]> ref = stacks.get(); 90.25 StackEntry[] stack = ref.get(); 90.26 @@ -78,7 +79,9 @@ 90.27 } 90.28 90.29 protected final void init() { 90.30 - if (stack != null) pushEnsured(ALT, regex.codeLength - 1); /* bottom stack */ 90.31 + if (stack != null) { 90.32 + pushEnsured(ALT, regex.codeLength - 1); /* bottom stack */ 90.33 + } 90.34 if (repeatStk != null) { 90.35 for (int i=1; i<=regex.numMem; i++) { 90.36 repeatStk[i + memStartStk] = repeatStk[i + memEndStk] = INVALID_INDEX; 90.37 @@ -87,9 +90,13 @@ 90.38 } 90.39 90.40 protected final StackEntry ensure1() { 90.41 - if (stk >= stack.length) doubleStack(); 90.42 + if (stk >= stack.length) { 90.43 + doubleStack(); 90.44 + } 90.45 StackEntry e = stack[stk]; 90.46 - if (e == null) stack[stk] = e = new StackEntry(); 90.47 + if (e == null) { 90.48 + stack[stk] = e = new StackEntry(); 90.49 + } 90.50 return e; 90.51 } 90.52 90.53 @@ -190,7 +197,9 @@ 90.54 if ((e.type & MASK_MEM_END_OR_MARK) != 0 && e.getMemNum() == mnum) { 90.55 level++; 90.56 } else if (e.type == MEM_START && e.getMemNum() == mnum) { 90.57 - if (level == 0) break; 90.58 + if (level == 0) { 90.59 + break; 90.60 + } 90.61 level--; 90.62 } 90.63 } 90.64 @@ -371,9 +380,8 @@ 90.65 if (e.getNullCheckNum() == id) { 90.66 if (level == 0) { 90.67 return e.getNullCheckPStr() == s ? 1 : 0; 90.68 - } else { 90.69 - level--; 90.70 } 90.71 + level--; 90.72 } 90.73 } else if (e.type == NULL_CHECK_END) { 90.74 level++; 90.75 @@ -393,7 +401,52 @@ 90.76 if (e.getNullCheckPStr() != s) { 90.77 isNull = 0; 90.78 break; 90.79 - } else { 90.80 + } 90.81 + int endp; 90.82 + isNull = 1; 90.83 + while (k < stk) { 90.84 + if (e.type == MEM_START) { 90.85 + if (e.getMemEnd() == INVALID_INDEX) { 90.86 + isNull = 0; 90.87 + break; 90.88 + } 90.89 + if (bsAt(regex.btMemEnd, e.getMemNum())) { 90.90 + endp = stack[e.getMemEnd()].getMemPStr(); 90.91 + } else { 90.92 + endp = e.getMemEnd(); 90.93 + } 90.94 + if (stack[e.getMemStart()].getMemPStr() != endp) { 90.95 + isNull = 0; 90.96 + break; 90.97 + } else if (endp != s) { 90.98 + isNull = -1; /* empty, but position changed */ 90.99 + } 90.100 + } 90.101 + k++; 90.102 + e = stack[k]; // !! 90.103 + } 90.104 + break; 90.105 + } 90.106 + } 90.107 + } 90.108 + return isNull; 90.109 + } 90.110 + 90.111 + protected final int nullCheckMemStRec(final int id, final int s) { 90.112 + int level = 0; 90.113 + int k = stk; 90.114 + int isNull; 90.115 + while (true) { 90.116 + k--; 90.117 + StackEntry e = stack[k]; 90.118 + 90.119 + if (e.type == NULL_CHECK_START) { 90.120 + if (e.getNullCheckNum() == id) { 90.121 + if (level == 0) { 90.122 + if (e.getNullCheckPStr() != s) { 90.123 + isNull = 0; 90.124 + break; 90.125 + } 90.126 int endp; 90.127 isNull = 1; 90.128 while (k < stk) { 90.129 @@ -415,62 +468,16 @@ 90.130 } 90.131 } 90.132 k++; 90.133 - e = stack[k]; // !! 90.134 + e = stack[k]; 90.135 } 90.136 break; 90.137 } 90.138 - } 90.139 - } 90.140 - } 90.141 - return isNull; 90.142 - } 90.143 - 90.144 - protected final int nullCheckMemStRec(final int id, final int s) { 90.145 - int level = 0; 90.146 - int k = stk; 90.147 - int isNull; 90.148 - while (true) { 90.149 - k--; 90.150 - StackEntry e = stack[k]; 90.151 - 90.152 - if (e.type == NULL_CHECK_START) { 90.153 - if (e.getNullCheckNum() == id) { 90.154 - if (level == 0) { 90.155 - if (e.getNullCheckPStr() != s) { 90.156 - isNull = 0; 90.157 - break; 90.158 - } else { 90.159 - int endp; 90.160 - isNull = 1; 90.161 - while (k < stk) { 90.162 - if (e.type == MEM_START) { 90.163 - if (e.getMemEnd() == INVALID_INDEX) { 90.164 - isNull = 0; 90.165 - break; 90.166 - } 90.167 - if (bsAt(regex.btMemEnd, e.getMemNum())) { 90.168 - endp = stack[e.getMemEnd()].getMemPStr(); 90.169 - } else { 90.170 - endp = e.getMemEnd(); 90.171 - } 90.172 - if (stack[e.getMemStart()].getMemPStr() != endp) { 90.173 - isNull = 0; 90.174 - break; 90.175 - } else if (endp != s) { 90.176 - isNull = -1; /* empty, but position changed */ 90.177 - } 90.178 - } 90.179 - k++; 90.180 - e = stack[k]; 90.181 - } 90.182 - break; 90.183 - } 90.184 - } else { 90.185 - level--; 90.186 - } 90.187 + level--; 90.188 } 90.189 } else if (e.type == NULL_CHECK_END) { 90.190 - if (e.getNullCheckNum() == id) level++; 90.191 + if (e.getNullCheckNum() == id) { 90.192 + level++; 90.193 + } 90.194 } 90.195 } 90.196 return isNull; 90.197 @@ -485,7 +492,9 @@ 90.198 90.199 if (e.type == REPEAT) { 90.200 if (level == 0) { 90.201 - if (e.getRepeatNum() == id) return k; 90.202 + if (e.getRepeatNum() == id) { 90.203 + return k; 90.204 + } 90.205 } 90.206 } else if (e.type == CALL_FRAME) { 90.207 level--; 90.208 @@ -505,9 +514,8 @@ 90.209 if (e.type == CALL_FRAME) { 90.210 if (level == 0) { 90.211 return e.getCallFrameRetAddr(); 90.212 - } else { 90.213 - level--; 90.214 } 90.215 + level--; 90.216 } else if (e.type == RETURN) { 90.217 level++; 90.218 }
91.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java Wed Nov 12 13:47:23 2014 -0800 91.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Syntax.java Fri Nov 14 10:03:48 2014 -0800 91.3 @@ -20,10 +20,10 @@ 91.4 package jdk.nashorn.internal.runtime.regexp.joni; 91.5 91.6 import static jdk.nashorn.internal.runtime.regexp.joni.constants.MetaChar.INEFFECTIVE_META_CHAR; 91.7 - 91.8 import jdk.nashorn.internal.runtime.regexp.joni.constants.SyntaxProperties; 91.9 91.10 -public final class Syntax implements SyntaxProperties{ 91.11 +@SuppressWarnings("javadoc") 91.12 +public final class Syntax implements SyntaxProperties { 91.13 private final int op; 91.14 private final int op2; 91.15 private final int behavior;
92.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/WarnCallback.java Wed Nov 12 13:47:23 2014 -0800 92.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/WarnCallback.java Fri Nov 14 10:03:48 2014 -0800 92.3 @@ -22,6 +22,7 @@ 92.4 /** 92.5 * @author <a href="mailto:ola.bini@gmail.com">Ola Bini</a> 92.6 */ 92.7 +@SuppressWarnings("javadoc") 92.8 public interface WarnCallback { 92.9 WarnCallback DEFAULT = new WarnCallback() { 92.10 @Override
93.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Warnings.java Wed Nov 12 13:47:23 2014 -0800 93.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Warnings.java Fri Nov 14 10:03:48 2014 -0800 93.3 @@ -19,6 +19,7 @@ 93.4 */ 93.5 package jdk.nashorn.internal.runtime.regexp.joni; 93.6 93.7 +@SuppressWarnings("javadoc") 93.8 public interface Warnings { 93.9 final String INVALID_BACKREFERENCE = "invalid back reference"; 93.10 final String INVALID_SUBEXP_CALL = "invalid subexp call";
94.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/AnchorNode.java Wed Nov 12 13:47:23 2014 -0800 94.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/AnchorNode.java Fri Nov 14 10:03:48 2014 -0800 94.3 @@ -21,6 +21,7 @@ 94.4 94.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.AnchorType; 94.6 94.7 +@SuppressWarnings("javadoc") 94.8 public final class AnchorNode extends Node implements AnchorType { 94.9 public int type; 94.10 public Node target; 94.11 @@ -65,28 +66,60 @@ 94.12 } 94.13 94.14 public String typeToString() { 94.15 - final StringBuilder type = new StringBuilder(); 94.16 - if (isType(BEGIN_BUF)) type.append("BEGIN_BUF "); 94.17 - if (isType(BEGIN_LINE)) type.append("BEGIN_LINE "); 94.18 - if (isType(BEGIN_POSITION)) type.append("BEGIN_POSITION "); 94.19 - if (isType(END_BUF)) type.append("END_BUF "); 94.20 - if (isType(SEMI_END_BUF)) type.append("SEMI_END_BUF "); 94.21 - if (isType(END_LINE)) type.append("END_LINE "); 94.22 - if (isType(WORD_BOUND)) type.append("WORD_BOUND "); 94.23 - if (isType(NOT_WORD_BOUND)) type.append("NOT_WORD_BOUND "); 94.24 - if (isType(WORD_BEGIN)) type.append("WORD_BEGIN "); 94.25 - if (isType(WORD_END)) type.append("WORD_END "); 94.26 - if (isType(PREC_READ)) type.append("PREC_READ "); 94.27 - if (isType(PREC_READ_NOT)) type.append("PREC_READ_NOT "); 94.28 - if (isType(LOOK_BEHIND)) type.append("LOOK_BEHIND "); 94.29 - if (isType(LOOK_BEHIND_NOT)) type.append("LOOK_BEHIND_NOT "); 94.30 - if (isType(ANYCHAR_STAR)) type.append("ANYCHAR_STAR "); 94.31 - if (isType(ANYCHAR_STAR_ML)) type.append("ANYCHAR_STAR_ML "); 94.32 - return type.toString(); 94.33 + final StringBuilder sb = new StringBuilder(); 94.34 + if (isType(BEGIN_BUF)) { 94.35 + sb.append("BEGIN_BUF "); 94.36 + } 94.37 + if (isType(BEGIN_LINE)) { 94.38 + sb.append("BEGIN_LINE "); 94.39 + } 94.40 + if (isType(BEGIN_POSITION)) { 94.41 + sb.append("BEGIN_POSITION "); 94.42 + } 94.43 + if (isType(END_BUF)) { 94.44 + sb.append("END_BUF "); 94.45 + } 94.46 + if (isType(SEMI_END_BUF)) { 94.47 + sb.append("SEMI_END_BUF "); 94.48 + } 94.49 + if (isType(END_LINE)) { 94.50 + sb.append("END_LINE "); 94.51 + } 94.52 + if (isType(WORD_BOUND)) { 94.53 + sb.append("WORD_BOUND "); 94.54 + } 94.55 + if (isType(NOT_WORD_BOUND)) { 94.56 + sb.append("NOT_WORD_BOUND "); 94.57 + } 94.58 + if (isType(WORD_BEGIN)) { 94.59 + sb.append("WORD_BEGIN "); 94.60 + } 94.61 + if (isType(WORD_END)) { 94.62 + sb.append("WORD_END "); 94.63 + } 94.64 + if (isType(PREC_READ)) { 94.65 + sb.append("PREC_READ "); 94.66 + } 94.67 + if (isType(PREC_READ_NOT)) { 94.68 + sb.append("PREC_READ_NOT "); 94.69 + } 94.70 + if (isType(LOOK_BEHIND)) { 94.71 + sb.append("LOOK_BEHIND "); 94.72 + } 94.73 + if (isType(LOOK_BEHIND_NOT)) { 94.74 + sb.append("LOOK_BEHIND_NOT "); 94.75 + } 94.76 + if (isType(ANYCHAR_STAR)) { 94.77 + sb.append("ANYCHAR_STAR "); 94.78 + } 94.79 + if (isType(ANYCHAR_STAR_ML)) { 94.80 + sb.append("ANYCHAR_STAR_ML "); 94.81 + } 94.82 + return sb.toString(); 94.83 } 94.84 94.85 - private boolean isType(final int type) { 94.86 - return (this.type & type) != 0; 94.87 + private boolean isType(final int t) { 94.88 + return (this.type & t) != 0; 94.89 } 94.90 94.91 }
95.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/AnyCharNode.java Wed Nov 12 13:47:23 2014 -0800 95.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/AnyCharNode.java Fri Nov 14 10:03:48 2014 -0800 95.3 @@ -19,6 +19,7 @@ 95.4 */ 95.5 package jdk.nashorn.internal.runtime.regexp.joni.ast; 95.6 95.7 +@SuppressWarnings("javadoc") 95.8 public final class AnyCharNode extends Node { 95.9 public AnyCharNode(){} 95.10
96.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/BackRefNode.java Wed Nov 12 13:47:23 2014 -0800 96.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/BackRefNode.java Fri Nov 14 10:03:48 2014 -0800 96.3 @@ -21,6 +21,7 @@ 96.4 96.5 import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment; 96.6 96.7 +@SuppressWarnings("javadoc") 96.8 public final class BackRefNode extends StateNode { 96.9 public final int backRef; 96.10
97.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Wed Nov 12 13:47:23 2014 -0800 97.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/CClassNode.java Fri Nov 14 10:03:48 2014 -0800 97.3 @@ -34,6 +34,7 @@ 97.4 import jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException; 97.5 import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; 97.6 97.7 +@SuppressWarnings("javadoc") 97.8 public final class CClassNode extends Node { 97.9 private static final int FLAG_NCCLASS_NOT = 1<<0; 97.10 private static final int FLAG_NCCLASS_SHARE = 1<<1; 97.11 @@ -100,7 +101,9 @@ 97.12 97.13 @Override 97.14 public boolean equals(final Object other) { 97.15 - if (!(other instanceof CClassNode)) return false; 97.16 + if (!(other instanceof CClassNode)) { 97.17 + return false; 97.18 + } 97.19 final CClassNode cc = (CClassNode)other; 97.20 return ctype == cc.ctype && isNot() == cc.isNot(); 97.21 } 97.22 @@ -110,11 +113,12 @@ 97.23 if (Config.USE_SHARED_CCLASS_TABLE) { 97.24 int hash = 0; 97.25 hash += ctype; 97.26 - if (isNot()) hash++; 97.27 + if (isNot()) { 97.28 + hash++; 97.29 + } 97.30 return hash + (hash >> 5); 97.31 - } else { 97.32 - return super.hashCode(); 97.33 } 97.34 + return super.hashCode(); 97.35 } 97.36 97.37 @Override 97.38 @@ -128,10 +132,14 @@ 97.39 } 97.40 97.41 public String flagsToString() { 97.42 - final StringBuilder flags = new StringBuilder(); 97.43 - if (isNot()) flags.append("NOT "); 97.44 - if (isShare()) flags.append("SHARE "); 97.45 - return flags.toString(); 97.46 + final StringBuilder f = new StringBuilder(); 97.47 + if (isNot()) { 97.48 + f.append("NOT "); 97.49 + } 97.50 + if (isShare()) { 97.51 + f.append("SHARE "); 97.52 + } 97.53 + return f.toString(); 97.54 } 97.55 97.56 public boolean isEmpty() { 97.57 @@ -251,7 +259,7 @@ 97.58 } 97.59 97.60 // add_ctype_to_cc_by_range // Encoding out! 97.61 - public void addCTypeByRange(final int ctype, final boolean not, final int sbOut, final int mbr[]) { 97.62 + public void addCTypeByRange(final int ct, final boolean not, final int sbOut, final int mbr[]) { 97.63 final int n = mbr[0]; 97.64 97.65 if (!not) { 97.66 @@ -294,10 +302,14 @@ 97.67 // !goto sb_end2!, remove duplication 97.68 prev = sbOut; 97.69 for (i=0; i<n; i++) { 97.70 - if (prev < mbr[2 * i + 1]) addCodeRangeToBuf(prev, mbr[i * 2 + 1] - 1); 97.71 + if (prev < mbr[2 * i + 1]) { 97.72 + addCodeRangeToBuf(prev, mbr[i * 2 + 1] - 1); 97.73 + } 97.74 prev = mbr[i * 2 + 2] + 1; 97.75 } 97.76 - if (prev < 0x7fffffff/*!!!*/) addCodeRangeToBuf(prev, 0x7fffffff); 97.77 + if (prev < 0x7fffffff/*!!!*/) { 97.78 + addCodeRangeToBuf(prev, 0x7fffffff); 97.79 + } 97.80 return; 97.81 } 97.82 bs.set(j); 97.83 @@ -312,22 +324,27 @@ 97.84 // !sb_end2:! 97.85 prev = sbOut; 97.86 for (int i=0; i<n; i++) { 97.87 - if (prev < mbr[2 * i + 1]) addCodeRangeToBuf(prev, mbr[i * 2 + 1] - 1); 97.88 + if (prev < mbr[2 * i + 1]) { 97.89 + addCodeRangeToBuf(prev, mbr[i * 2 + 1] - 1); 97.90 + } 97.91 prev = mbr[i * 2 + 2] + 1; 97.92 } 97.93 - if (prev < 0x7fffffff/*!!!*/) addCodeRangeToBuf(prev, 0x7fffffff); 97.94 + if (prev < 0x7fffffff/*!!!*/) { 97.95 + addCodeRangeToBuf(prev, 0x7fffffff); 97.96 + } 97.97 } 97.98 } 97.99 97.100 - public void addCType(int ctype, final boolean not, final ScanEnvironment env, final IntHolder sbOut) { 97.101 + public void addCType(final int ctp, final boolean not, final ScanEnvironment env, final IntHolder sbOut) { 97.102 + int ct = ctp; 97.103 if (Config.NON_UNICODE_SDW) { 97.104 - switch(ctype) { 97.105 + switch (ct) { 97.106 case CharacterType.D: 97.107 case CharacterType.S: 97.108 case CharacterType.W: 97.109 - ctype ^= CharacterType.SPECIAL_MASK; 97.110 + ct ^= CharacterType.SPECIAL_MASK; 97.111 97.112 - if (env.syntax == Syntax.JAVASCRIPT && ctype == CharacterType.SPACE) { 97.113 + if (env.syntax == Syntax.JAVASCRIPT && ct == CharacterType.SPACE) { 97.114 // \s in JavaScript includes unicode characters. 97.115 break; 97.116 } 97.117 @@ -335,26 +352,32 @@ 97.118 if (not) { 97.119 for (int c = 0; c < BitSet.SINGLE_BYTE_SIZE; c++) { 97.120 // if (!ASCIIEncoding.INSTANCE.isCodeCType(c, ctype)) bs.set(c); 97.121 - if ((AsciiCtypeTable[c] & (1 << ctype)) == 0) bs.set(c); 97.122 + if ((AsciiCtypeTable[c] & (1 << ct)) == 0) { 97.123 + bs.set(c); 97.124 + } 97.125 } 97.126 addAllMultiByteRange(); 97.127 } else { 97.128 for (int c = 0; c < BitSet.SINGLE_BYTE_SIZE; c++) { 97.129 // if (ASCIIEncoding.INSTANCE.isCodeCType(c, ctype)) bs.set(c); 97.130 - if ((AsciiCtypeTable[c] & (1 << ctype)) != 0) bs.set(c); 97.131 + if ((AsciiCtypeTable[c] & (1 << ct)) != 0) { 97.132 + bs.set(c); 97.133 + } 97.134 } 97.135 } 97.136 return; 97.137 + default: 97.138 + break; 97.139 } 97.140 } 97.141 97.142 - final int[] ranges = EncodingHelper.ctypeCodeRange(ctype, sbOut); 97.143 + final int[] ranges = EncodingHelper.ctypeCodeRange(ct, sbOut); 97.144 if (ranges != null) { 97.145 - addCTypeByRange(ctype, not, sbOut.value, ranges); 97.146 + addCTypeByRange(ct, not, sbOut.value, ranges); 97.147 return; 97.148 } 97.149 97.150 - switch(ctype) { 97.151 + switch(ct) { 97.152 case CharacterType.ALPHA: 97.153 case CharacterType.BLANK: 97.154 case CharacterType.CNTRL: 97.155 @@ -368,12 +391,16 @@ 97.156 case CharacterType.ALNUM: 97.157 if (not) { 97.158 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.159 - if (!EncodingHelper.isCodeCType(c, ctype)) bs.set(c); 97.160 + if (!EncodingHelper.isCodeCType(c, ct)) { 97.161 + bs.set(c); 97.162 + } 97.163 } 97.164 addAllMultiByteRange(); 97.165 } else { 97.166 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.167 - if (EncodingHelper.isCodeCType(c, ctype)) bs.set(c); 97.168 + if (EncodingHelper.isCodeCType(c, ct)) { 97.169 + bs.set(c); 97.170 + } 97.171 } 97.172 } 97.173 break; 97.174 @@ -382,11 +409,15 @@ 97.175 case CharacterType.PRINT: 97.176 if (not) { 97.177 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.178 - if (!EncodingHelper.isCodeCType(c, ctype)) bs.set(c); 97.179 + if (!EncodingHelper.isCodeCType(c, ct)) { 97.180 + bs.set(c); 97.181 + } 97.182 } 97.183 } else { 97.184 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.185 - if (EncodingHelper.isCodeCType(c, ctype)) bs.set(c); 97.186 + if (EncodingHelper.isCodeCType(c, ct)) { 97.187 + bs.set(c); 97.188 + } 97.189 } 97.190 addAllMultiByteRange(); 97.191 } 97.192 @@ -395,13 +426,17 @@ 97.193 case CharacterType.WORD: 97.194 if (!not) { 97.195 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.196 - if (EncodingHelper.isWord(c)) bs.set(c); 97.197 + if (EncodingHelper.isWord(c)) { 97.198 + bs.set(c); 97.199 + } 97.200 } 97.201 97.202 addAllMultiByteRange(); 97.203 } else { 97.204 for (int c=0; c<BitSet.SINGLE_BYTE_SIZE; c++) { 97.205 - if (!EncodingHelper.isWord(c)) bs.set(c); 97.206 + if (!EncodingHelper.isWord(c)) { 97.207 + bs.set(c); 97.208 + } 97.209 } 97.210 } 97.211 break; 97.212 @@ -422,7 +457,9 @@ 97.213 } 97.214 97.215 public void nextStateClass(final CCStateArg arg, final ScanEnvironment env) { 97.216 - if (arg.state == CCSTATE.RANGE) throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE); 97.217 + if (arg.state == CCSTATE.RANGE) { 97.218 + throw new SyntaxException(ErrorMessages.ERR_CHAR_CLASS_VALUE_AT_END_OF_RANGE); 97.219 + } 97.220 97.221 if (arg.state == CCSTATE.VALUE && arg.type != CCVALTYPE.CLASS) { 97.222 if (arg.type == CCVALTYPE.SB) { 97.223 @@ -440,7 +477,9 @@ 97.224 switch(arg.state) { 97.225 case VALUE: 97.226 if (arg.type == CCVALTYPE.SB) { 97.227 - if (arg.vs > 0xff) throw new ValueException(ErrorMessages.ERR_INVALID_CODE_POINT_VALUE); 97.228 + if (arg.vs > 0xff) { 97.229 + throw new ValueException(ErrorMessages.ERR_INVALID_CODE_POINT_VALUE); 97.230 + } 97.231 bs.set(arg.vs); 97.232 } else if (arg.type == CCVALTYPE.CODE_POINT) { 97.233 addCodeRange(env, arg.vs, arg.vs); 97.234 @@ -450,16 +489,17 @@ 97.235 case RANGE: 97.236 if (arg.inType == arg.type) { 97.237 if (arg.inType == CCVALTYPE.SB) { 97.238 - if (arg.vs > 0xff || arg.v > 0xff) throw new ValueException(ErrorMessages.ERR_INVALID_CODE_POINT_VALUE); 97.239 + if (arg.vs > 0xff || arg.v > 0xff) { 97.240 + throw new ValueException(ErrorMessages.ERR_INVALID_CODE_POINT_VALUE); 97.241 + } 97.242 97.243 if (arg.vs > arg.v) { 97.244 if (env.syntax.allowEmptyRangeInCC()) { 97.245 // goto ccs_range_end 97.246 arg.state = CCSTATE.COMPLETE; 97.247 break; 97.248 - } else { 97.249 - throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 97.250 } 97.251 + throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 97.252 } 97.253 bs.setRange(arg.vs, arg.v); 97.254 } else { 97.255 @@ -471,9 +511,8 @@ 97.256 // goto ccs_range_end 97.257 arg.state = CCSTATE.COMPLETE; 97.258 break; 97.259 - } else { 97.260 - throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 97.261 } 97.262 + throw new ValueException(ErrorMessages.ERR_EMPTY_RANGE_IN_CHAR_CLASS); 97.263 } 97.264 bs.setRange(arg.vs, arg.v < 0xff ? arg.v : 0xff); 97.265 addCodeRange(env, arg.vs, arg.v); 97.266 @@ -509,9 +548,8 @@ 97.267 97.268 if (isNot()) { 97.269 return !found; 97.270 - } else { 97.271 - return found; 97.272 } 97.273 + return found; 97.274 } 97.275 97.276 // onig_is_code_in_cc
98.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/ConsAltNode.java Wed Nov 12 13:47:23 2014 -0800 98.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/ConsAltNode.java Fri Nov 14 10:03:48 2014 -0800 98.3 @@ -24,6 +24,7 @@ 98.4 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 98.5 import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; 98.6 98.7 +@SuppressWarnings("javadoc") 98.8 public final class ConsAltNode extends Node { 98.9 public Node car; 98.10 public ConsAltNode cdr; 98.11 @@ -31,9 +32,13 @@ 98.12 98.13 private ConsAltNode(final Node car, final ConsAltNode cdr, final int type) { 98.14 this.car = car; 98.15 - if (car != null) car.parent = this; 98.16 + if (car != null) { 98.17 + car.parent = this; 98.18 + } 98.19 this.cdr = cdr; 98.20 - if (cdr != null) cdr.parent = this; 98.21 + if (cdr != null) { 98.22 + cdr.parent = this; 98.23 + } 98.24 98.25 this.type = type; 98.26 } 98.27 @@ -46,8 +51,9 @@ 98.28 return new ConsAltNode(left, right, LIST); 98.29 } 98.30 98.31 - public static ConsAltNode listAdd(ConsAltNode list, final Node x) { 98.32 + public static ConsAltNode listAdd(final ConsAltNode listp, final Node x) { 98.33 final ConsAltNode n = newListNode(x, null); 98.34 + ConsAltNode list = listp; 98.35 98.36 if (list != null) { 98.37 while (list.cdr != null) {
99.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Wed Nov 12 13:47:23 2014 -0800 99.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Fri Nov 14 10:03:48 2014 -0800 99.3 @@ -22,6 +22,7 @@ 99.4 import jdk.nashorn.internal.runtime.regexp.joni.Option; 99.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType; 99.6 99.7 +@SuppressWarnings("javadoc") 99.8 public final class EncloseNode extends StateNode implements EncloseType { 99.9 99.10 public final int type; // enclose type
100.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Wed Nov 12 13:47:23 2014 -0800 100.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Fri Nov 14 10:03:48 2014 -0800 100.3 @@ -24,6 +24,7 @@ 100.4 import jdk.nashorn.internal.runtime.regexp.joni.WarnCallback; 100.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeType; 100.6 100.7 +@SuppressWarnings("javadoc") 100.8 public abstract class Node implements NodeType { 100.9 public Node parent; 100.10 100.11 @@ -33,8 +34,12 @@ 100.12 return 1 << getType(); 100.13 } 100.14 100.15 - protected void setChild(final Node tgt){} // default definition 100.16 - protected Node getChild(){return null;} // default definition 100.17 + protected void setChild(final Node tgt) { 100.18 + //empty, default definition 100.19 + } 100.20 + protected Node getChild() { 100.21 + return null; // default definition 100.22 + } 100.23 100.24 public void swap(final Node with) { 100.25 Node tmp; 100.26 @@ -46,9 +51,13 @@ 100.27 //setChild(with.getChild()); 100.28 //with.setChild(tmp); 100.29 100.30 - if (parent != null) parent.setChild(with); 100.31 + if (parent != null) { 100.32 + parent.setChild(with); 100.33 + } 100.34 100.35 - if (with.parent != null) with.parent.setChild(this); 100.36 + if (with.parent != null) { 100.37 + with.parent.setChild(this); 100.38 + } 100.39 100.40 tmp = parent; 100.41 parent = with.parent; 100.42 @@ -81,16 +90,22 @@ 100.43 } 100.44 100.45 protected static String pad(final Object value, final int level) { 100.46 - if (value == null) return "NULL"; 100.47 + if (value == null) { 100.48 + return "NULL"; 100.49 + } 100.50 100.51 final StringBuilder pad = new StringBuilder(" "); 100.52 - for (int i=0; i<level; i++) pad.append(pad); 100.53 + for (int i=0; i<level; i++) { 100.54 + pad.append(pad); 100.55 + } 100.56 100.57 return value.toString().replace("\n", "\n" + pad); 100.58 } 100.59 100.60 public final boolean isInvalidQuantifier() { 100.61 - if (!Config.VANILLA) return false; 100.62 + if (!Config.VANILLA) { 100.63 + return false; 100.64 + } 100.65 100.66 ConsAltNode node; 100.67 100.68 @@ -107,14 +122,18 @@ 100.69 case LIST: 100.70 node = (ConsAltNode)this; 100.71 do { 100.72 - if (!node.car.isInvalidQuantifier()) return false; 100.73 + if (!node.car.isInvalidQuantifier()) { 100.74 + return false; 100.75 + } 100.76 } while ((node = node.cdr) != null); 100.77 return false; 100.78 100.79 case ALT: 100.80 node = (ConsAltNode)this; 100.81 do { 100.82 - if (node.car.isInvalidQuantifier()) return true; 100.83 + if (node.car.isInvalidQuantifier()) { 100.84 + return true; 100.85 + } 100.86 } while ((node = node.cdr) != null); 100.87 break; 100.88
101.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Wed Nov 12 13:47:23 2014 -0800 101.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Fri Nov 14 10:03:48 2014 -0800 101.3 @@ -26,11 +26,11 @@ 101.4 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.ReduceType.PQ_Q; 101.5 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.ReduceType.P_QQ; 101.6 import static jdk.nashorn.internal.runtime.regexp.joni.ast.QuantifierNode.ReduceType.QQ; 101.7 - 101.8 import jdk.nashorn.internal.runtime.regexp.joni.Config; 101.9 import jdk.nashorn.internal.runtime.regexp.joni.ScanEnvironment; 101.10 import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; 101.11 101.12 +@SuppressWarnings("javadoc") 101.13 public final class QuantifierNode extends StateNode { 101.14 101.15 public Node target; 101.16 @@ -78,7 +78,9 @@ 101.17 greedy = true; 101.18 targetEmptyInfo = TargetInfo.ISNOT_EMPTY; 101.19 101.20 - if (byNumber) setByNumber(); 101.21 + if (byNumber) { 101.22 + setByNumber(); 101.23 + } 101.24 } 101.25 101.26 @Override 101.27 @@ -136,17 +138,27 @@ 101.28 protected int popularNum() { 101.29 if (greedy) { 101.30 if (lower == 0) { 101.31 - if (upper == 1) return 0; 101.32 - else if (isRepeatInfinite(upper)) return 1; 101.33 + if (upper == 1) { 101.34 + return 0; 101.35 + } else if (isRepeatInfinite(upper)) { 101.36 + return 1; 101.37 + } 101.38 } else if (lower == 1) { 101.39 - if (isRepeatInfinite(upper)) return 2; 101.40 + if (isRepeatInfinite(upper)) { 101.41 + return 2; 101.42 + } 101.43 } 101.44 } else { 101.45 if (lower == 0) { 101.46 - if (upper == 1) return 3; 101.47 - else if (isRepeatInfinite(upper)) return 4; 101.48 + if (upper == 1) { 101.49 + return 3; 101.50 + } else if (isRepeatInfinite(upper)) { 101.51 + return 4; 101.52 + } 101.53 } else if (lower == 1) { 101.54 - if (isRepeatInfinite(upper)) return 5; 101.55 + if (isRepeatInfinite(upper)) { 101.56 + return 5; 101.57 + } 101.58 } 101.59 } 101.60 return -1; 101.61 @@ -171,7 +183,9 @@ 101.62 final int pnum = popularNum(); 101.63 final int cnum = other.popularNum(); 101.64 101.65 - if (pnum < 0 || cnum < 0) return; 101.66 + if (pnum < 0 || cnum < 0) { 101.67 + return; 101.68 + } 101.69 101.70 switch(REDUCE_TABLE[cnum][pnum]) { 101.71 case DEL: 101.72 @@ -224,6 +238,9 @@ 101.73 case ASIS: 101.74 setTarget(other); 101.75 return; 101.76 + 101.77 + default: 101.78 + break; 101.79 } 101.80 // ??? remove the parent from target ??? 101.81 other.target = null; // remove target from reduced quantifier 101.82 @@ -231,7 +248,9 @@ 101.83 101.84 @SuppressWarnings("fallthrough") 101.85 public int setQuantifier(final Node tgt, final boolean group, final ScanEnvironment env, final char[] chars, final int p, final int end) { 101.86 - if (lower == 1 && upper == 1) return 1; 101.87 + if (lower == 1 && upper == 1) { 101.88 + return 1; 101.89 + } 101.90 101.91 switch(tgt.getType()) { 101.92
102.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java Wed Nov 12 13:47:23 2014 -0800 102.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StateNode.java Fri Nov 14 10:03:48 2014 -0800 102.3 @@ -21,6 +21,7 @@ 102.4 102.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.NodeStatus; 102.6 102.7 +@SuppressWarnings("javadoc") 102.8 public abstract class StateNode extends Node implements NodeStatus { 102.9 protected int state; 102.10
103.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java Wed Nov 12 13:47:23 2014 -0800 103.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/StringNode.java Fri Nov 14 10:03:48 2014 -0800 103.3 @@ -22,6 +22,7 @@ 103.4 import jdk.nashorn.internal.runtime.regexp.joni.EncodingHelper; 103.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.StringType; 103.6 103.7 +@SuppressWarnings("javadoc") 103.8 public final class StringNode extends Node implements StringType { 103.9 103.10 private static final int NODE_STR_MARGIN = 16;
104.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/AnchorType.java Wed Nov 12 13:47:23 2014 -0800 104.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/AnchorType.java Fri Nov 14 10:03:48 2014 -0800 104.3 @@ -19,6 +19,7 @@ 104.4 */ 104.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 104.6 104.7 +@SuppressWarnings("javadoc") 104.8 public interface AnchorType { 104.9 final int BEGIN_BUF = (1<<0); 104.10 final int BEGIN_LINE = (1<<1);
105.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Arguments.java Wed Nov 12 13:47:23 2014 -0800 105.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Arguments.java Fri Nov 14 10:03:48 2014 -0800 105.3 @@ -19,6 +19,7 @@ 105.4 */ 105.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 105.6 105.7 +@SuppressWarnings("javadoc") 105.8 public interface Arguments { 105.9 final int SPECIAL = -1; 105.10 final int NON = 0;
106.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/AsmConstants.java Wed Nov 12 13:47:23 2014 -0800 106.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/AsmConstants.java Fri Nov 14 10:03:48 2014 -0800 106.3 @@ -19,6 +19,7 @@ 106.4 */ 106.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 106.6 106.7 +@SuppressWarnings("javadoc") 106.8 public interface AsmConstants { 106.9 final int THIS = 0; 106.10
107.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/CCSTATE.java Wed Nov 12 13:47:23 2014 -0800 107.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/CCSTATE.java Fri Nov 14 10:03:48 2014 -0800 107.3 @@ -19,6 +19,7 @@ 107.4 */ 107.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 107.6 107.7 +@SuppressWarnings("javadoc") 107.8 public enum CCSTATE { 107.9 VALUE, 107.10 RANGE,
108.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/CCVALTYPE.java Wed Nov 12 13:47:23 2014 -0800 108.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/CCVALTYPE.java Fri Nov 14 10:03:48 2014 -0800 108.3 @@ -19,6 +19,7 @@ 108.4 */ 108.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 108.6 108.7 +@SuppressWarnings("javadoc") 108.8 public enum CCVALTYPE { 108.9 SB, 108.10 CODE_POINT,
109.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/EncloseType.java Wed Nov 12 13:47:23 2014 -0800 109.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/EncloseType.java Fri Nov 14 10:03:48 2014 -0800 109.3 @@ -19,6 +19,7 @@ 109.4 */ 109.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 109.6 109.7 +@SuppressWarnings("javadoc") 109.8 public interface EncloseType { 109.9 final int MEMORY = 1<<0; 109.10 final int OPTION = 1<<1;
110.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/MetaChar.java Wed Nov 12 13:47:23 2014 -0800 110.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/MetaChar.java Fri Nov 14 10:03:48 2014 -0800 110.3 @@ -19,6 +19,7 @@ 110.4 */ 110.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 110.6 110.7 +@SuppressWarnings("javadoc") 110.8 public interface MetaChar { 110.9 final int ESCAPE = 0; 110.10 final int ANYCHAR = 1;
111.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/NodeStatus.java Wed Nov 12 13:47:23 2014 -0800 111.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/NodeStatus.java Fri Nov 14 10:03:48 2014 -0800 111.3 @@ -19,6 +19,7 @@ 111.4 */ 111.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 111.6 111.7 +@SuppressWarnings("javadoc") 111.8 public interface NodeStatus { 111.9 /* status bits */ 111.10 final int NST_MIN_FIXED = (1<<0);
112.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/NodeType.java Wed Nov 12 13:47:23 2014 -0800 112.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/NodeType.java Fri Nov 14 10:03:48 2014 -0800 112.3 @@ -19,6 +19,7 @@ 112.4 */ 112.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 112.6 112.7 +@SuppressWarnings("javadoc") 112.8 public interface NodeType { 112.9 /* node type */ 112.10 final int STR = 0;
113.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPCode.java Wed Nov 12 13:47:23 2014 -0800 113.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPCode.java Fri Nov 14 10:03:48 2014 -0800 113.3 @@ -19,6 +19,7 @@ 113.4 */ 113.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 113.6 113.7 +@SuppressWarnings("javadoc") 113.8 public interface OPCode { 113.9 final int FINISH = 0; /* matching process terminator (no more alternative) */ 113.10 final int END = 1; /* pattern code terminator (success end) */
114.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPSize.java Wed Nov 12 13:47:23 2014 -0800 114.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/OPSize.java Fri Nov 14 10:03:48 2014 -0800 114.3 @@ -19,6 +19,7 @@ 114.4 */ 114.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 114.6 114.7 +@SuppressWarnings("javadoc") 114.8 public interface OPSize { 114.9 114.10 // this might be helpful for potential byte[] migration
115.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/RegexState.java Wed Nov 12 13:47:23 2014 -0800 115.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/RegexState.java Fri Nov 14 10:03:48 2014 -0800 115.3 @@ -20,6 +20,7 @@ 115.4 package jdk.nashorn.internal.runtime.regexp.joni.constants; 115.5 115.6 // we dont need this ATM 115.7 +@SuppressWarnings("javadoc") 115.8 public interface RegexState { 115.9 final int NORMAL = 0; 115.10 final int SEARCHING = 1;
116.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StackPopLevel.java Wed Nov 12 13:47:23 2014 -0800 116.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StackPopLevel.java Fri Nov 14 10:03:48 2014 -0800 116.3 @@ -19,6 +19,7 @@ 116.4 */ 116.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 116.6 116.7 +@SuppressWarnings("javadoc") 116.8 public interface StackPopLevel { 116.9 final int FREE = 0; 116.10 final int MEM_START = 1;
117.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StackType.java Wed Nov 12 13:47:23 2014 -0800 117.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StackType.java Fri Nov 14 10:03:48 2014 -0800 117.3 @@ -19,6 +19,7 @@ 117.4 */ 117.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 117.6 117.7 +@SuppressWarnings("javadoc") 117.8 public interface StackType { 117.9 /** stack **/ 117.10 final int INVALID_STACK_INDEX = -1;
118.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StringType.java Wed Nov 12 13:47:23 2014 -0800 118.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/StringType.java Fri Nov 14 10:03:48 2014 -0800 118.3 @@ -19,6 +19,7 @@ 118.4 */ 118.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 118.6 118.7 +@SuppressWarnings("javadoc") 118.8 public interface StringType { 118.9 final int NSTR_RAW = 1<<0; 118.10 final int NSTR_AMBIG = 1<<1;
119.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/SyntaxProperties.java Wed Nov 12 13:47:23 2014 -0800 119.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/SyntaxProperties.java Fri Nov 14 10:03:48 2014 -0800 119.3 @@ -19,6 +19,7 @@ 119.4 */ 119.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 119.6 119.7 +@SuppressWarnings("javadoc") 119.8 public interface SyntaxProperties { 119.9 /* syntax (operators); */ 119.10 final int OP_VARIABLE_META_CHARACTERS = (1<<0);
120.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java Wed Nov 12 13:47:23 2014 -0800 120.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TargetInfo.java Fri Nov 14 10:03:48 2014 -0800 120.3 @@ -19,6 +19,7 @@ 120.4 */ 120.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 120.6 120.7 +@SuppressWarnings("javadoc") 120.8 public interface TargetInfo { 120.9 final int ISNOT_EMPTY = 0; 120.10 final int IS_EMPTY = 1;
121.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TokenType.java Wed Nov 12 13:47:23 2014 -0800 121.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/TokenType.java Fri Nov 14 10:03:48 2014 -0800 121.3 @@ -19,6 +19,7 @@ 121.4 */ 121.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 121.6 121.7 +@SuppressWarnings("javadoc") 121.8 public enum TokenType { 121.9 EOT, /* end of token */ 121.10 RAW_BYTE,
122.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Traverse.java Wed Nov 12 13:47:23 2014 -0800 122.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/constants/Traverse.java Fri Nov 14 10:03:48 2014 -0800 122.3 @@ -19,6 +19,7 @@ 122.4 */ 122.5 package jdk.nashorn.internal.runtime.regexp.joni.constants; 122.6 122.7 +@SuppressWarnings("javadoc") 122.8 public interface Traverse { 122.9 final int TRAVERSE_CALLBACK_AT_FIRST = 1; 122.10 final int TRAVERSE_CALLBACK_AT_LAST = 2;
123.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/CharacterType.java Wed Nov 12 13:47:23 2014 -0800 123.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/CharacterType.java Fri Nov 14 10:03:48 2014 -0800 123.3 @@ -19,6 +19,7 @@ 123.4 */ 123.5 package jdk.nashorn.internal.runtime.regexp.joni.encoding; 123.6 123.7 +@SuppressWarnings("javadoc") 123.8 public interface CharacterType { 123.9 123.10 final int NEWLINE = 0;
124.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/IntHolder.java Wed Nov 12 13:47:23 2014 -0800 124.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/IntHolder.java Fri Nov 14 10:03:48 2014 -0800 124.3 @@ -19,6 +19,7 @@ 124.4 */ 124.5 package jdk.nashorn.internal.runtime.regexp.joni.encoding; 124.6 124.7 +@SuppressWarnings("javadoc") 124.8 public class IntHolder { 124.9 public int value; 124.10 }
125.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/ObjPtr.java Wed Nov 12 13:47:23 2014 -0800 125.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/encoding/ObjPtr.java Fri Nov 14 10:03:48 2014 -0800 125.3 @@ -19,6 +19,7 @@ 125.4 */ 125.5 package jdk.nashorn.internal.runtime.regexp.joni.encoding; 125.6 125.7 +@SuppressWarnings("javadoc") 125.8 public final class ObjPtr<T> { 125.9 public ObjPtr() { 125.10 this(null);
126.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Wed Nov 12 13:47:23 2014 -0800 126.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Fri Nov 14 10:03:48 2014 -0800 126.3 @@ -19,6 +19,7 @@ 126.4 */ 126.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 126.6 126.7 +@SuppressWarnings("javadoc") 126.8 public interface ErrorMessages { 126.9 126.10 /* from jcodings */
127.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/InternalException.java Wed Nov 12 13:47:23 2014 -0800 127.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/InternalException.java Fri Nov 14 10:03:48 2014 -0800 127.3 @@ -19,6 +19,7 @@ 127.4 */ 127.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 127.6 127.7 +@SuppressWarnings("javadoc") 127.8 public class InternalException extends JOniException{ 127.9 private static final long serialVersionUID = -3871816465397927992L; 127.10
128.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/JOniException.java Wed Nov 12 13:47:23 2014 -0800 128.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/JOniException.java Fri Nov 14 10:03:48 2014 -0800 128.3 @@ -19,6 +19,7 @@ 128.4 */ 128.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 128.6 128.7 +@SuppressWarnings("javadoc") 128.8 public class JOniException extends RuntimeException{ 128.9 private static final long serialVersionUID = -6027192180014164667L; 128.10
129.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/SyntaxException.java Wed Nov 12 13:47:23 2014 -0800 129.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/SyntaxException.java Fri Nov 14 10:03:48 2014 -0800 129.3 @@ -19,6 +19,7 @@ 129.4 */ 129.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 129.6 129.7 +@SuppressWarnings("javadoc") 129.8 public class SyntaxException extends JOniException{ 129.9 private static final long serialVersionUID = 7862720128961874288L; 129.10
130.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java Wed Nov 12 13:47:23 2014 -0800 130.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ValueException.java Fri Nov 14 10:03:48 2014 -0800 130.3 @@ -19,7 +19,8 @@ 130.4 */ 130.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 130.6 130.7 -public class ValueException extends SyntaxException{ 130.8 +@SuppressWarnings("javadoc") 130.9 +public class ValueException extends SyntaxException { 130.10 private static final long serialVersionUID = -196013852479929134L; 130.11 130.12 public ValueException(final String message) {
131.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 131.2 +++ b/test/script/basic/JDK-8035312.js Fri Nov 14 10:03:48 2014 -0800 131.3 @@ -0,0 +1,225 @@ 131.4 +/* 131.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 131.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 131.7 + * 131.8 + * This code is free software; you can redistribute it and/or modify it 131.9 + * under the terms of the GNU General Public License version 2 only, as 131.10 + * published by the Free Software Foundation. 131.11 + * 131.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 131.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 131.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 131.15 + * version 2 for more details (a copy is included in the LICENSE file that 131.16 + * accompanied this code). 131.17 + * 131.18 + * You should have received a copy of the GNU General Public License version 131.19 + * 2 along with this work; if not, write to the Free Software Foundation, 131.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 131.21 + * 131.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 131.23 + * or visit www.oracle.com if you need additional information or have any 131.24 + * questions. 131.25 + */ 131.26 + 131.27 +/** 131.28 + * JDK-8035312 push to frozen array must not increase length property 131.29 + * 131.30 + * @test 131.31 + * @run 131.32 + * @fork 131.33 + * @option -Dnashorn.debug=true 131.34 + */ 131.35 + 131.36 +function printArrayDataClass(x) { 131.37 + if (typeof Debug !== 'undefined') { 131.38 + print(Debug.getArrayDataClass(x)); 131.39 + } 131.40 +} 131.41 + 131.42 +function gpush(x, elem) { 131.43 + try { 131.44 + print("Pushing " + elem + " to " + x); 131.45 + x.push(elem); 131.46 + } catch (e) { 131.47 + print("caught error" + e); 131.48 + } 131.49 + print("\tarray is now [" + x + "] length is = " + x.length); 131.50 + print(); 131.51 + printArrayDataClass(x); 131.52 +} 131.53 + 131.54 +function gpop(x) { 131.55 + try { 131.56 + print("Popping from " + x); 131.57 + x.pop(); 131.58 + } catch (e) { 131.59 + if (!(e instanceof TypeError)) { 131.60 + print("e of wrong type " + e); 131.61 + } 131.62 + } 131.63 + print("\tarray is now [" + x + "] length is = " + x.length); 131.64 + print(); 131.65 + printArrayDataClass(x); 131.66 +} 131.67 + 131.68 +function checkArray(x) { 131.69 + print(); 131.70 + print(">>> Push test"); 131.71 + 131.72 + var olen = x.length; 131.73 + gpush(x, 0); 131.74 + 131.75 + print("x.length === " + x.length + " (should be " + olen + ")"); 131.76 + print("x[3] === " + x[3] + " (should be 0)"); 131.77 + print("x[4] === " + x[4] + " (should be undefined)"); 131.78 + 131.79 + print(); 131.80 + print(">>> Pop test"); 131.81 + gpop(x); 131.82 + gpop(x); 131.83 + print("x.length === " + x.length + " (should be " + olen + ")"); 131.84 + print("x === " + x); 131.85 + 131.86 + for (var i = 0 ; i < 5; i++) { 131.87 + gpop(x); 131.88 + } 131.89 + 131.90 + print("x.length === " + x.length + " (should be " + olen + ")"); 131.91 + print("x === " + x); 131.92 +} 131.93 + 131.94 +print("*** Freezing"); 131.95 +var frozen = [1,2,3]; 131.96 +Object.freeze(frozen); 131.97 +checkArray(frozen); 131.98 +printArrayDataClass(frozen); 131.99 + 131.100 +//so far so good 131.101 + 131.102 +print(); 131.103 +print("*** Other length not writable issues"); 131.104 +var lengthNotWritable = [1,2,3]; 131.105 +Object.defineProperty(lengthNotWritable, "length", { writable: false }); 131.106 +checkArray(lengthNotWritable); 131.107 +printArrayDataClass(lengthNotWritable); 131.108 + 131.109 +function set(array, from, to, stride) { 131.110 + //add three elements 131.111 + for (var i = from; i < to; i+=stride) { 131.112 + try { 131.113 + print("Writing " + i); 131.114 + array[i] = i; 131.115 + printArrayDataClass(array); 131.116 + } catch (e) { 131.117 + print(e instanceof TypeError); 131.118 + } 131.119 + } 131.120 +} 131.121 + 131.122 +//define empty array with non writable length 131.123 +var arr = [1]; 131.124 +Object.defineProperty(arr, "length", { writable: false }); 131.125 + 131.126 +var olen2 = arr.length; 131.127 + 131.128 +set(arr, 0, 3, 1); 131.129 + 131.130 +if (arr.length != olen2) { 131.131 + throw new ("error: " + arr.length + " != " + olen2); 131.132 +} 131.133 + 131.134 +print(); 131.135 +print("array writing 0-3, with 1 stride, array = " + arr); 131.136 +print("length = " + arr.length + ", but elements are: " + arr[0] + " " + arr[1] + " " + arr[2]); 131.137 +print(); 131.138 + 131.139 +//do the same but sparse/deleted range 131.140 +var arr2 = [1]; 131.141 +Object.defineProperty(arr2, "length", { writable: false }); 131.142 + 131.143 +print("initial length = " + arr2.length); 131.144 +var olen3 = arr2.length; 131.145 + 131.146 +set(arr2, 0, 30, 3); 131.147 + 131.148 +if (arr2.length != olen3) { 131.149 + throw new ("error: " + arr2.length + " != " + olen3); 131.150 +} 131.151 + 131.152 +print(); 131.153 +var larger = 20; 131.154 +print("array writing 0-" + larger + ", with 3 stride, array = " + arr2); 131.155 +print("length = " + arr2.length + ", but elements are: " + arr2[0] + " " + arr2[1] + " " + arr2[2]); 131.156 + 131.157 +for (var i = 0; i < larger; i++) { 131.158 + if (arr2[i] === undefined) { 131.159 + continue; 131.160 + } 131.161 + print(arr2[i] + " has length " + arr2.length); 131.162 +} 131.163 + 131.164 +print(); 131.165 +var elem = 0x7fffffff - 10; 131.166 +printArrayDataClass(arr2); 131.167 +print("adding a new element high up in the array"); 131.168 +print("length before element was added " + arr2.length); 131.169 +print("putting sparse at " + elem); 131.170 +arr2[elem] = "sparse"; 131.171 +print("length after element was added " + arr2.length + " should be the same"); 131.172 +printArrayDataClass(arr2); 131.173 + 131.174 +print(); 131.175 +print("Printing arr2 - this will fail if length is > 28 and it is " + arr2.length); 131.176 +print("arr2 = [" + arr2 + "]"); 131.177 +print("new length that should not be writable = " + arr2.length); 131.178 +print(arr2[elem] === "sparse"); 131.179 +print(arr2[elem]); 131.180 +for (var i = 0; i < larger; i++) { 131.181 + print(arr2[i]); 131.182 +} 131.183 +for (var key in arr2) { 131.184 + print(key + ":" + arr2[key]); 131.185 +} 131.186 + 131.187 +//issues reported by sundar - generic setter doesn't go through push/pop bulkable 131.188 + 131.189 +function sundarExample2(arr, _writable) { 131.190 + print("Checking if push works for bulkable non bulkable arrays - Setting length property not allowed"); 131.191 + arr[0] = "bar"; 131.192 + print(arr.length + " should be 1"); // should be 1 131.193 + print(arr[0] + " should be bar"); 131.194 + print("["+ arr + "] should be [bar]"); 131.195 + 131.196 + // Object.defineProperty(arr, "length", { configurable: _writable }); 131.197 + Object.defineProperty(arr, "length", { writable: _writable }); 131.198 + arr[1] = "baz"; 131.199 + 131.200 + if (_writable) { 131.201 + print(arr.length + " should be 2"); 131.202 + print(arr[0] + " should be bar"); 131.203 + print(arr[1] + " should be baz"); 131.204 + print("["+ arr + "] should be [bar,baz]"); 131.205 + } else { 131.206 + print(arr.length + " should STILL be 1"); 131.207 + print(arr[0] + " should be bar"); 131.208 + print(arr[1] + " should be baz"); 131.209 + print("["+ arr + "] should be [bar]"); 131.210 + } 131.211 +} 131.212 + 131.213 +var newArr1 = []; 131.214 +sundarExample2(newArr1, false); 131.215 +print(); 131.216 +try { 131.217 + sundarExample2(newArr1, true); 131.218 + print("should not get here"); 131.219 +} catch (e) { 131.220 + if (!(e instanceof TypeError)) { 131.221 + print("Wrong exception"); 131.222 + } 131.223 + print("got TypeError when redefining length, as expected") 131.224 +} 131.225 +print(); 131.226 + 131.227 +sundarExample2([], true); 131.228 +print("Done");
132.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 132.2 +++ b/test/script/basic/JDK-8035312.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 132.3 @@ -0,0 +1,186 @@ 132.4 +*** Freezing 132.5 + 132.6 +>>> Push test 132.7 +Pushing 0 to 1,2,3 132.8 + array is now [1,2,3] length is = 3 132.9 + 132.10 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.11 +x.length === 3 (should be 3) 132.12 +x[3] === undefined (should be 0) 132.13 +x[4] === undefined (should be undefined) 132.14 + 132.15 +>>> Pop test 132.16 +Popping from 1,2,3 132.17 + array is now [1,2,3] length is = 3 132.18 + 132.19 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.20 +Popping from 1,2,3 132.21 + array is now [1,2,3] length is = 3 132.22 + 132.23 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.24 +x.length === 3 (should be 3) 132.25 +x === 1,2,3 132.26 +Popping from 1,2,3 132.27 + array is now [1,2,3] length is = 3 132.28 + 132.29 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.30 +Popping from 1,2,3 132.31 + array is now [1,2,3] length is = 3 132.32 + 132.33 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.34 +Popping from 1,2,3 132.35 + array is now [1,2,3] length is = 3 132.36 + 132.37 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.38 +Popping from 1,2,3 132.39 + array is now [1,2,3] length is = 3 132.40 + 132.41 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.42 +Popping from 1,2,3 132.43 + array is now [1,2,3] length is = 3 132.44 + 132.45 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.46 +x.length === 3 (should be 3) 132.47 +x === 1,2,3 132.48 +class jdk.nashorn.internal.runtime.arrays.FrozenArrayFilter 132.49 + 132.50 +*** Other length not writable issues 132.51 + 132.52 +>>> Push test 132.53 +Pushing 0 to 1,2,3 132.54 +caught errorTypeError: "length" is not a writable property of [object Array] 132.55 + array is now [1,2,3] length is = 3 132.56 + 132.57 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.58 +x.length === 3 (should be 3) 132.59 +x[3] === 0 (should be 0) 132.60 +x[4] === undefined (should be undefined) 132.61 + 132.62 +>>> Pop test 132.63 +Popping from 1,2,3 132.64 + array is now [1,2,3] length is = 3 132.65 + 132.66 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.67 +Popping from 1,2,3 132.68 + array is now [1,2,3] length is = 3 132.69 + 132.70 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.71 +x.length === 3 (should be 3) 132.72 +x === 1,2,3 132.73 +Popping from 1,2,3 132.74 + array is now [1,2,3] length is = 3 132.75 + 132.76 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.77 +Popping from 1,2,3 132.78 + array is now [1,2,3] length is = 3 132.79 + 132.80 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.81 +Popping from 1,2,3 132.82 + array is now [1,2,3] length is = 3 132.83 + 132.84 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.85 +Popping from 1,2,3 132.86 + array is now [1,2,3] length is = 3 132.87 + 132.88 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.89 +Popping from 1,2,3 132.90 + array is now [1,2,3] length is = 3 132.91 + 132.92 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.93 +x.length === 3 (should be 3) 132.94 +x === 1,2,3 132.95 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.96 +Writing 0 132.97 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.98 +Writing 1 132.99 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.100 +Writing 2 132.101 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.102 + 132.103 +array writing 0-3, with 1 stride, array = 0 132.104 +length = 1, but elements are: 0 undefined 2 132.105 + 132.106 +initial length = 1 132.107 +Writing 0 132.108 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.109 +Writing 3 132.110 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.111 +Writing 6 132.112 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.113 +Writing 9 132.114 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.115 +Writing 12 132.116 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.117 +Writing 15 132.118 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.119 +Writing 18 132.120 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.121 +Writing 21 132.122 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.123 +Writing 24 132.124 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.125 +Writing 27 132.126 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.127 + 132.128 +array writing 0-20, with 3 stride, array = 0 132.129 +length = 1, but elements are: 0 undefined undefined 132.130 +0 has length 1 132.131 + 132.132 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.133 +adding a new element high up in the array 132.134 +length before element was added 1 132.135 +putting sparse at 2147483637 132.136 +length after element was added 1 should be the same 132.137 +class jdk.nashorn.internal.runtime.arrays.LengthNotWritableFilter 132.138 + 132.139 +Printing arr2 - this will fail if length is > 28 and it is 1 132.140 +arr2 = [0] 132.141 +new length that should not be writable = 1 132.142 +true 132.143 +sparse 132.144 +0 132.145 +undefined 132.146 +undefined 132.147 +undefined 132.148 +undefined 132.149 +undefined 132.150 +undefined 132.151 +undefined 132.152 +undefined 132.153 +undefined 132.154 +undefined 132.155 +undefined 132.156 +undefined 132.157 +undefined 132.158 +undefined 132.159 +undefined 132.160 +undefined 132.161 +undefined 132.162 +undefined 132.163 +undefined 132.164 +0:0 132.165 +2147483637:sparse 132.166 +Checking if push works for bulkable non bulkable arrays - Setting length property not allowed 132.167 +1 should be 1 132.168 +bar should be bar 132.169 +[bar] should be [bar] 132.170 +1 should STILL be 1 132.171 +bar should be bar 132.172 +baz should be baz 132.173 +[bar] should be [bar] 132.174 + 132.175 +Checking if push works for bulkable non bulkable arrays - Setting length property not allowed 132.176 +1 should be 1 132.177 +bar should be bar 132.178 +[bar] should be [bar] 132.179 +got TypeError when redefining length, as expected 132.180 + 132.181 +Checking if push works for bulkable non bulkable arrays - Setting length property not allowed 132.182 +1 should be 1 132.183 +bar should be bar 132.184 +[bar] should be [bar] 132.185 +2 should be 2 132.186 +bar should be bar 132.187 +baz should be baz 132.188 +[bar,baz] should be [bar,baz] 132.189 +Done
133.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 133.2 +++ b/test/script/basic/JDK-8035312_2.js Fri Nov 14 10:03:48 2014 -0800 133.3 @@ -0,0 +1,65 @@ 133.4 +/* 133.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 133.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 133.7 + * 133.8 + * This code is free software; you can redistribute it and/or modify it 133.9 + * under the terms of the GNU General Public License version 2 only, as 133.10 + * published by the Free Software Foundation. 133.11 + * 133.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 133.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 133.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 133.15 + * version 2 for more details (a copy is included in the LICENSE file that 133.16 + * accompanied this code). 133.17 + * 133.18 + * You should have received a copy of the GNU General Public License version 133.19 + * 2 along with this work; if not, write to the Free Software Foundation, 133.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 133.21 + * 133.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 133.23 + * or visit www.oracle.com if you need additional information or have any 133.24 + * questions. 133.25 + */ 133.26 + 133.27 +/** 133.28 + * JDK-8035312_2 - length setter and iterators 133.29 + * 133.30 + * @test 133.31 + * @run 133.32 + */ 133.33 + 133.34 +"use strict" 133.35 + 133.36 +function printArray(a,n) { 133.37 + print("PRINT_ARRAY CALLED: length = " + a.length); 133.38 + print(); 133.39 + 133.40 + print("INDEXED"); 133.41 + for (var x = 0; x<n; x++) { 133.42 + print("\t" + x + ":"+a[x]); 133.43 + } 133.44 + print("KEYS"); 133.45 + for (var key in a) { 133.46 + print("\t" + key + ";" + a[key]); 133.47 + } 133.48 +} 133.49 + 133.50 +var b = [1,2,3]; 133.51 + 133.52 +Object.defineProperty(b, "length", { writable: false }); 133.53 +var high = 8; 133.54 +b[high] = high; 133.55 + 133.56 +printArray(b, high + 5); 133.57 + 133.58 +var c = [1,2,3]; 133.59 +c[high] = high; 133.60 +print(); 133.61 +print("element[" + high + "]: " + c.length + " " + c[high]); 133.62 +print("Resetting length"); 133.63 +c.length = 3; 133.64 +print("element[" + high + "]: " + c.length + " " + c[high]); 133.65 +print(); 133.66 + 133.67 +printArray(c, high + 5); 133.68 +print();
134.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 134.2 +++ b/test/script/basic/JDK-8035312_2.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 134.3 @@ -0,0 +1,47 @@ 134.4 +PRINT_ARRAY CALLED: length = 3 134.5 + 134.6 +INDEXED 134.7 + 0:1 134.8 + 1:2 134.9 + 2:3 134.10 + 3:undefined 134.11 + 4:undefined 134.12 + 5:undefined 134.13 + 6:undefined 134.14 + 7:undefined 134.15 + 8:8 134.16 + 9:undefined 134.17 + 10:undefined 134.18 + 11:undefined 134.19 + 12:undefined 134.20 +KEYS 134.21 + 0;1 134.22 + 1;2 134.23 + 2;3 134.24 + 8;8 134.25 + 134.26 +element[8]: 9 8 134.27 +Resetting length 134.28 +element[8]: 3 undefined 134.29 + 134.30 +PRINT_ARRAY CALLED: length = 3 134.31 + 134.32 +INDEXED 134.33 + 0:1 134.34 + 1:2 134.35 + 2:3 134.36 + 3:undefined 134.37 + 4:undefined 134.38 + 5:undefined 134.39 + 6:undefined 134.40 + 7:undefined 134.41 + 8:undefined 134.42 + 9:undefined 134.43 + 10:undefined 134.44 + 11:undefined 134.45 + 12:undefined 134.46 +KEYS 134.47 + 0;1 134.48 + 1;2 134.49 + 2;3 134.50 +
135.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 135.2 +++ b/test/script/basic/JDK-8035312_3.js Fri Nov 14 10:03:48 2014 -0800 135.3 @@ -0,0 +1,43 @@ 135.4 +/* 135.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 135.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 135.7 + * 135.8 + * This code is free software; you can redistribute it and/or modify it 135.9 + * under the terms of the GNU General Public License version 2 only, as 135.10 + * published by the Free Software Foundation. 135.11 + * 135.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 135.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 135.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 135.15 + * version 2 for more details (a copy is included in the LICENSE file that 135.16 + * accompanied this code). 135.17 + * 135.18 + * You should have received a copy of the GNU General Public License version 135.19 + * 2 along with this work; if not, write to the Free Software Foundation, 135.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 135.21 + * 135.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 135.23 + * or visit www.oracle.com if you need additional information or have any 135.24 + * questions. 135.25 + */ 135.26 + 135.27 +/** 135.28 + * JDK-8035312_3 - sparse array, non writable length 135.29 + * 135.30 + * @test 135.31 + * @run 135.32 + */ 135.33 + 135.34 +var b = [1,2,3]; 135.35 + 135.36 +Object.defineProperty(b, "length", { writable: false }); 135.37 +var high = 23534343; 135.38 +b[high-10] = high-10; 135.39 + 135.40 +print(b[high-10]); 135.41 + 135.42 +var c = [1,2,3]; 135.43 +c[high-10] = high-10; 135.44 +c.length = 3; 135.45 +print(c); 135.46 +print(c[high-10]);
136.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 136.2 +++ b/test/script/basic/JDK-8035312_3.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 136.3 @@ -0,0 +1,3 @@ 136.4 +23534333 136.5 +1,2,3 136.6 +undefined
137.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 137.2 +++ b/test/script/basic/JDK-8035312_4.js Fri Nov 14 10:03:48 2014 -0800 137.3 @@ -0,0 +1,59 @@ 137.4 +/* 137.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 137.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 137.7 + * 137.8 + * This code is free software; you can redistribute it and/or modify it 137.9 + * under the terms of the GNU General Public License version 2 only, as 137.10 + * published by the Free Software Foundation. 137.11 + * 137.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 137.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 137.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 137.15 + * version 2 for more details (a copy is included in the LICENSE file that 137.16 + * accompanied this code). 137.17 + * 137.18 + * You should have received a copy of the GNU General Public License version 137.19 + * 2 along with this work; if not, write to the Free Software Foundation, 137.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 137.21 + * 137.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 137.23 + * or visit www.oracle.com if you need additional information or have any 137.24 + * questions. 137.25 + */ 137.26 + 137.27 +/** 137.28 + * JDK-8035312_4 - pushes and pops for non writable length 137.29 + * 137.30 + * @test 137.31 + * @run 137.32 + */ 137.33 + 137.34 +var b = [1,2,3]; 137.35 +Object.defineProperty(b, "length", { writable: false }); 137.36 + 137.37 +try { 137.38 + b.push(4); 137.39 +} catch (e) { 137.40 + print("length = " + b.length); 137.41 + print("i caught an error"); 137.42 +} 137.43 +print(b); 137.44 +print(b[3]); 137.45 +print("length = " + b.length); 137.46 + 137.47 +var c = [1,2,3]; 137.48 +Object.defineProperty(c, "length", { writable: false }); 137.49 + 137.50 +for (var i = 0; i < 5; i++) { 137.51 + try { 137.52 + c.pop(); 137.53 + } catch (e) { 137.54 + print("length = " + c.length); 137.55 + print("I caught an error"); 137.56 + print(c); 137.57 + } 137.58 +} 137.59 + 137.60 +print(c); 137.61 +print(c[3]); 137.62 +print("length = " + b.length);
138.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 138.2 +++ b/test/script/basic/JDK-8035312_4.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 138.3 @@ -0,0 +1,23 @@ 138.4 +length = 3 138.5 +i caught an error 138.6 +1,2,3 138.7 +4 138.8 +length = 3 138.9 +length = 3 138.10 +I caught an error 138.11 +1,2, 138.12 +length = 3 138.13 +I caught an error 138.14 +1,2, 138.15 +length = 3 138.16 +I caught an error 138.17 +1,2, 138.18 +length = 3 138.19 +I caught an error 138.20 +1,2, 138.21 +length = 3 138.22 +I caught an error 138.23 +1,2, 138.24 +1,2, 138.25 +undefined 138.26 +length = 3
139.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 139.2 +++ b/test/script/basic/JDK-8035312_5.js Fri Nov 14 10:03:48 2014 -0800 139.3 @@ -0,0 +1,60 @@ 139.4 +/* 139.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 139.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 139.7 + * 139.8 + * This code is free software; you can redistribute it and/or modify it 139.9 + * under the terms of the GNU General Public License version 2 only, as 139.10 + * published by the Free Software Foundation. 139.11 + * 139.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 139.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 139.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 139.15 + * version 2 for more details (a copy is included in the LICENSE file that 139.16 + * accompanied this code). 139.17 + * 139.18 + * You should have received a copy of the GNU General Public License version 139.19 + * 2 along with this work; if not, write to the Free Software Foundation, 139.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 139.21 + * 139.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 139.23 + * or visit www.oracle.com if you need additional information or have any 139.24 + * questions. 139.25 + */ 139.26 + 139.27 +/** 139.28 + * JDK-8035312_5 - pushes and pops for frozen array 139.29 + * 139.30 + * @test 139.31 + * @run 139.32 + */ 139.33 + 139.34 +var b = [1,2,3]; 139.35 +Object.freeze(b); 139.36 + 139.37 +try { 139.38 + b.push(4); 139.39 +} catch (e) { 139.40 + print("length = " + b.length); 139.41 + print("i caught an error"); 139.42 +} 139.43 +print(b); 139.44 +print(b[3]); 139.45 +print("length = " + b.length); 139.46 + 139.47 +var c = [1,2,3]; 139.48 +Object.freeze(c); 139.49 + 139.50 +for (var i = 0; i < 5; i++) { 139.51 + try { 139.52 + c.pop(); 139.53 + } catch (e) { 139.54 + print("length = " + c.length); 139.55 + print("I caught an error"); 139.56 + print(c); 139.57 + } 139.58 +} 139.59 + 139.60 +print(c); 139.61 +print(c[3]); 139.62 +print("length = " + b.length); 139.63 +
140.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 140.2 +++ b/test/script/basic/JDK-8035312_5.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 140.3 @@ -0,0 +1,6 @@ 140.4 +1,2,3 140.5 +undefined 140.6 +length = 3 140.7 +1,2,3 140.8 +undefined 140.9 +length = 3
141.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 141.2 +++ b/test/script/basic/JDK-8057825.js Fri Nov 14 10:03:48 2014 -0800 141.3 @@ -0,0 +1,45 @@ 141.4 +/* 141.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 141.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 141.7 + * 141.8 + * This code is free software; you can redistribute it and/or modify it 141.9 + * under the terms of the GNU General Public License version 2 only, as 141.10 + * published by the Free Software Foundation. 141.11 + * 141.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 141.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 141.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 141.15 + * version 2 for more details (a copy is included in the LICENSE file that 141.16 + * accompanied this code). 141.17 + * 141.18 + * You should have received a copy of the GNU General Public License version 141.19 + * 2 along with this work; if not, write to the Free Software Foundation, 141.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 141.21 + * 141.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 141.23 + * or visit www.oracle.com if you need additional information or have any 141.24 + * questions. 141.25 + */ 141.26 + 141.27 +/** 141.28 + * JDK-8057825 : A failed apply to call generation should NOT reuse the 141.29 + * best apply to call generation so far - because it may not fit!!! 141.30 + * 141.31 + * @test 141.32 + * @run 141.33 + */ 141.34 + 141.35 +function createApplier(f) { 141.36 + function applier() { 141.37 + f.apply(this, arguments); // no transform applied here 141.38 + } 141.39 + return applier; 141.40 +} 141.41 + 141.42 +function printer(x,y) { 141.43 + print(x + " and " + y); 141.44 +} 141.45 + 141.46 +var printerApplier = createApplier(printer); 141.47 +printerApplier(); 141.48 +printerApplier.apply(this, ["foo", "bar"]);
142.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 142.2 +++ b/test/script/basic/JDK-8057825.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 142.3 @@ -0,0 +1,2 @@ 142.4 +undefined and undefined 142.5 +foo and bar
143.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 143.2 +++ b/test/script/basic/JDK-8059443.js Fri Nov 14 10:03:48 2014 -0800 143.3 @@ -0,0 +1,39 @@ 143.4 +/* 143.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 143.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 143.7 + * 143.8 + * This code is free software; you can redistribute it and/or modify it 143.9 + * under the terms of the GNU General Public License version 2 only, as 143.10 + * published by the Free Software Foundation. 143.11 + * 143.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 143.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 143.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 143.15 + * version 2 for more details (a copy is included in the LICENSE file that 143.16 + * accompanied this code). 143.17 + * 143.18 + * You should have received a copy of the GNU General Public License version 143.19 + * 2 along with this work; if not, write to the Free Software Foundation, 143.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 143.21 + * 143.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 143.23 + * or visit www.oracle.com if you need additional information or have any 143.24 + * questions. 143.25 + */ 143.26 + 143.27 +/** 143.28 + * JDK-8059443: NPE when unboxing return values 143.29 + * 143.30 + * NOTE: this test can only pass when running with a JDK where 143.31 + * JDK-8060483 is also fixed (9b37 or later). 143.32 + * 143.33 + * @test 143.34 + * @run 143.35 + */ 143.36 + 143.37 +var NullProvider = Java.type("jdk.nashorn.test.models.NullProvider"); 143.38 + 143.39 +if (!NullProvider.getBoolean()) { print("yay"); } 143.40 +print(NullProvider.getLong() * (1 << 33)); 143.41 +print(NullProvider.getDouble() / 2.5); 143.42 +print(NullProvider.getInteger() << 1);
144.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 144.2 +++ b/test/script/basic/JDK-8059443.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 144.3 @@ -0,0 +1,4 @@ 144.4 +yay 144.5 +0 144.6 +0 144.7 +0
145.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 145.2 +++ b/test/script/basic/JDK-8061959.js Fri Nov 14 10:03:48 2014 -0800 145.3 @@ -0,0 +1,35 @@ 145.4 +/* 145.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 145.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 145.7 + * 145.8 + * This code is free software; you can redistribute it and/or modify it 145.9 + * under the terms of the GNU General Public License version 2 only, as 145.10 + * published by the Free Software Foundation. 145.11 + * 145.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 145.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 145.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 145.15 + * version 2 for more details (a copy is included in the LICENSE file that 145.16 + * accompanied this code). 145.17 + * 145.18 + * You should have received a copy of the GNU General Public License version 145.19 + * 2 along with this work; if not, write to the Free Software Foundation, 145.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 145.21 + * 145.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 145.23 + * or visit www.oracle.com if you need additional information or have any 145.24 + * questions. 145.25 + */ 145.26 + 145.27 +/** 145.28 + * JDK-8061959 - Checks for the existence of ArrayBufferView 145.29 + * 145.30 + * @test 145.31 + * @run 145.32 + */ 145.33 + 145.34 +print(ArrayBuffer.isView(new Int8Array(4))); 145.35 +print(ArrayBuffer.isView("gorilla")); 145.36 +print(ArrayBuffer.isView()); 145.37 + 145.38 +
146.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 146.2 +++ b/test/script/basic/JDK-8061959.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 146.3 @@ -0,0 +1,3 @@ 146.4 +true 146.5 +false 146.6 +false
147.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 147.2 +++ b/test/script/basic/JDK-8062381.js Fri Nov 14 10:03:48 2014 -0800 147.3 @@ -0,0 +1,53 @@ 147.4 +/* 147.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 147.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 147.7 + * 147.8 + * This code is free software; you can redistribute it and/or modify it 147.9 + * under the terms of the GNU General Public License version 2 only, as 147.10 + * published by the Free Software Foundation. 147.11 + * 147.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 147.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 147.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 147.15 + * version 2 for more details (a copy is included in the LICENSE file that 147.16 + * accompanied this code). 147.17 + * 147.18 + * You should have received a copy of the GNU General Public License version 147.19 + * 2 along with this work; if not, write to the Free Software Foundation, 147.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 147.21 + * 147.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 147.23 + * or visit www.oracle.com if you need additional information or have any 147.24 + * questions. 147.25 + */ 147.26 + 147.27 +/** 147.28 + * JDK-8062381 wrong argument chosen for charCodeAt in linker logic 147.29 + * 147.30 + * @test 147.31 + * @run 147.32 + */ 147.33 + 147.34 +var s = "abcdef"; 147.35 +var len = s.length + 1; 147.36 + 147.37 +function f1() { 147.38 + for (var i = 0; i < len; i++) { 147.39 + print(s.charCodeAt(i)); 147.40 + } 147.41 + print(s.charCodeAt()); 147.42 +} 147.43 + 147.44 +function f2() { 147.45 + for (var i = 0; i < len; i++) { 147.46 + print(s.charCodeAt("" + i)); 147.47 + } 147.48 + print(s.charCodeAt()); 147.49 +} 147.50 + 147.51 +f1(); 147.52 +f2(); 147.53 +f1(); 147.54 +f2(); 147.55 + 147.56 +
148.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 148.2 +++ b/test/script/basic/JDK-8062381.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 148.3 @@ -0,0 +1,32 @@ 148.4 +97 148.5 +98 148.6 +99 148.7 +100 148.8 +101 148.9 +102 148.10 +NaN 148.11 +97 148.12 +97 148.13 +98 148.14 +99 148.15 +100 148.16 +101 148.17 +102 148.18 +NaN 148.19 +97 148.20 +97 148.21 +98 148.22 +99 148.23 +100 148.24 +101 148.25 +102 148.26 +NaN 148.27 +97 148.28 +97 148.29 +98 148.30 +99 148.31 +100 148.32 +101 148.33 +102 148.34 +NaN 148.35 +97
149.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 149.2 +++ b/test/script/basic/JDK-8062624.js Fri Nov 14 10:03:48 2014 -0800 149.3 @@ -0,0 +1,45 @@ 149.4 +/* 149.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 149.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 149.7 + * 149.8 + * This code is free software; you can redistribute it and/or modify it 149.9 + * under the terms of the GNU General Public License version 2 only, as 149.10 + * published by the Free Software Foundation. 149.11 + * 149.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 149.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 149.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 149.15 + * version 2 for more details (a copy is included in the LICENSE file that 149.16 + * accompanied this code). 149.17 + * 149.18 + * You should have received a copy of the GNU General Public License version 149.19 + * 2 along with this work; if not, write to the Free Software Foundation, 149.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 149.21 + * 149.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 149.23 + * or visit www.oracle.com if you need additional information or have any 149.24 + * questions. 149.25 + */ 149.26 + 149.27 +/** 149.28 + * JDK-8062624: java.lang.String methods not available on concatenated strings 149.29 + * 149.30 + * @test 149.31 + * @run 149.32 + */ 149.33 + 149.34 +function testStringMethods(s) { 149.35 + print(s.startsWith("f")); 149.36 + print(s.endsWith("r")); 149.37 + print(Java.from(s.getBytes())); 149.38 + print(Java.from(s.bytes)); 149.39 +} 149.40 + 149.41 +var s = "f"; 149.42 +testStringMethods(s); 149.43 +s = s + "oo"; 149.44 +testStringMethods(s); 149.45 +testStringMethods("abc"); 149.46 +s += "bar"; 149.47 +s = "baz" + s; 149.48 +testStringMethods(s);
150.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 150.2 +++ b/test/script/basic/JDK-8062624.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 150.3 @@ -0,0 +1,16 @@ 150.4 +true 150.5 +false 150.6 +102 150.7 +102 150.8 +true 150.9 +false 150.10 +102,111,111 150.11 +102,111,111 150.12 +false 150.13 +false 150.14 +97,98,99 150.15 +97,98,99 150.16 +false 150.17 +true 150.18 +98,97,122,102,111,111,98,97,114 150.19 +98,97,122,102,111,111,98,97,114
151.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 151.2 +++ b/test/script/basic/JDK-8062799.js Fri Nov 14 10:03:48 2014 -0800 151.3 @@ -0,0 +1,103 @@ 151.4 +/* 151.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 151.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 151.7 + * 151.8 + * This code is free software; you can redistribute it and/or modify it 151.9 + * under the terms of the GNU General Public License version 2 only, as 151.10 + * published by the Free Software Foundation. 151.11 + * 151.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 151.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 151.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 151.15 + * version 2 for more details (a copy is included in the LICENSE file that 151.16 + * accompanied this code). 151.17 + * 151.18 + * You should have received a copy of the GNU General Public License version 151.19 + * 2 along with this work; if not, write to the Free Software Foundation, 151.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 151.21 + * 151.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 151.23 + * or visit www.oracle.com if you need additional information or have any 151.24 + * questions. 151.25 + */ 151.26 + 151.27 +/** 151.28 + * JDK-8062799: Binary logical expressions can have numeric types 151.29 + * 151.30 + * @test 151.31 + * @run 151.32 + */ 151.33 + 151.34 +(function() { 151.35 + var inspect = Java.type("jdk.nashorn.test.tools.StaticTypeInspector").inspect; 151.36 + 151.37 + var b = true; 151.38 + var i = 1; 151.39 + var l = 4294967296; 151.40 + var d = 2.1; 151.41 + var o = "foo"; 151.42 + 151.43 + print(inspect(b || b, "b || b")); 151.44 + print(inspect(b || i, "b || i")); 151.45 + print(inspect(b || l, "b || l")); 151.46 + print(inspect(b || d, "b || d")); 151.47 + print(inspect(b || o, "b || o")); 151.48 + 151.49 + print(inspect(i || b, "i || b")); 151.50 + print(inspect(i || i, "i || i")); 151.51 + print(inspect(i || l, "i || l")); 151.52 + print(inspect(i || d, "i || d")); 151.53 + print(inspect(i || o, "i || o")); 151.54 + 151.55 + print(inspect(l || b, "l || b")); 151.56 + print(inspect(l || i, "l || i")); 151.57 + print(inspect(l || l, "l || l")); 151.58 + print(inspect(l || d, "l || d")); 151.59 + print(inspect(l || o, "l || o")); 151.60 + 151.61 + print(inspect(d || b, "d || b")); 151.62 + print(inspect(d || i, "d || i")); 151.63 + print(inspect(d || l, "d || l")); 151.64 + print(inspect(d || d, "d || d")); 151.65 + print(inspect(d || o, "d || o")); 151.66 + 151.67 + print(inspect(o || b, "o || b")); 151.68 + print(inspect(o || i, "o || i")); 151.69 + print(inspect(o || l, "o || l")); 151.70 + print(inspect(o || d, "o || d")); 151.71 + print(inspect(o || o, "o || o")); 151.72 + 151.73 + print(inspect(b && b, "b && b")); 151.74 + print(inspect(b && i, "b && i")); 151.75 + print(inspect(b && l, "b && l")); 151.76 + print(inspect(b && d, "b && d")); 151.77 + print(inspect(b && o, "b && o")); 151.78 + 151.79 + print(inspect(i && b, "i && b")); 151.80 + print(inspect(i && i, "i && i")); 151.81 + print(inspect(i && l, "i && l")); 151.82 + print(inspect(i && d, "i && d")); 151.83 + print(inspect(i && o, "i && o")); 151.84 + 151.85 + print(inspect(l && b, "l && b")); 151.86 + print(inspect(l && i, "l && i")); 151.87 + print(inspect(l && l, "l && l")); 151.88 + print(inspect(l && d, "l && d")); 151.89 + print(inspect(l && o, "l && o")); 151.90 + 151.91 + print(inspect(d && b, "d && b")); 151.92 + print(inspect(d && i, "d && i")); 151.93 + print(inspect(d && l, "d && l")); 151.94 + print(inspect(d && d, "d && d")); 151.95 + print(inspect(d && o, "d && o")); 151.96 + 151.97 + print(inspect(o && b, "o && b")); 151.98 + print(inspect(o && i, "o && i")); 151.99 + print(inspect(o && l, "o && l")); 151.100 + print(inspect(o && d, "o && d")); 151.101 + print(inspect(o && o, "o && o")); 151.102 +})(); 151.103 + 151.104 + 151.105 + 151.106 + 151.107 \ No newline at end of file
152.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 152.2 +++ b/test/script/basic/JDK-8062799.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 152.3 @@ -0,0 +1,50 @@ 152.4 +b || b: boolean 152.5 +b || i: boolean 152.6 +b || l: boolean 152.7 +b || d: boolean 152.8 +b || o: boolean 152.9 +i || b: int 152.10 +i || i: int 152.11 +i || l: long 152.12 +i || d: double 152.13 +i || o: int 152.14 +l || b: long 152.15 +l || i: long 152.16 +l || l: long 152.17 +l || d: double 152.18 +l || o: long 152.19 +d || b: double 152.20 +d || i: double 152.21 +d || l: double 152.22 +d || d: double 152.23 +d || o: double 152.24 +o || b: object 152.25 +o || i: object 152.26 +o || l: object 152.27 +o || d: object 152.28 +o || o: object 152.29 +b && b: boolean 152.30 +b && i: int 152.31 +b && l: long 152.32 +b && d: double 152.33 +b && o: object 152.34 +i && b: boolean 152.35 +i && i: int 152.36 +i && l: long 152.37 +i && d: double 152.38 +i && o: object 152.39 +l && b: boolean 152.40 +l && i: long 152.41 +l && l: long 152.42 +l && d: double 152.43 +l && o: object 152.44 +d && b: boolean 152.45 +d && i: double 152.46 +d && l: double 152.47 +d && d: double 152.48 +d && o: object 152.49 +o && b: boolean 152.50 +o && i: int 152.51 +o && l: long 152.52 +o && d: double 152.53 +o && o: object
153.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 153.2 +++ b/test/script/basic/JDK-8062937.js Fri Nov 14 10:03:48 2014 -0800 153.3 @@ -0,0 +1,46 @@ 153.4 +/* 153.5 + * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. 153.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 153.7 + * 153.8 + * This code is free software; you can redistribute it and/or modify it 153.9 + * under the terms of the GNU General Public License version 2 only, as 153.10 + * published by the Free Software Foundation. 153.11 + * 153.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 153.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 153.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 153.15 + * version 2 for more details (a copy is included in the LICENSE file that 153.16 + * accompanied this code). 153.17 + * 153.18 + * You should have received a copy of the GNU General Public License version 153.19 + * 2 along with this work; if not, write to the Free Software Foundation, 153.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 153.21 + * 153.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 153.23 + * or visit www.oracle.com if you need additional information or have any 153.24 + * questions. 153.25 + */ 153.26 + 153.27 +/** 153.28 + * JDK-8062937 - GlobalConstants produces wrong result with defineProperty and index setters 153.29 + * 153.30 + * @test 153.31 + * @run 153.32 + */ 153.33 + 153.34 +var x = 1; 153.35 +for (var i = 2; i < 5; i++) { 153.36 + print(x); 153.37 + Object.defineProperty(this, "x", {value: i}); 153.38 +} 153.39 +print(x); 153.40 + 153.41 +print(); 153.42 + 153.43 +var name = "y"; 153.44 +var y = 1; 153.45 +for (var i = 2; i < 5; i++) { 153.46 + print(y); 153.47 + this[name] = i; 153.48 +} 153.49 +print(y);
154.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 154.2 +++ b/test/script/basic/JDK-8062937.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 154.3 @@ -0,0 +1,9 @@ 154.4 +1 154.5 +2 154.6 +3 154.7 +4 154.8 + 154.9 +1 154.10 +2 154.11 +3 154.12 +4
155.1 --- a/test/script/basic/fastpushpop.js.EXPECTED Wed Nov 12 13:47:23 2014 -0800 155.2 +++ b/test/script/basic/fastpushpop.js.EXPECTED Fri Nov 14 10:03:48 2014 -0800 155.3 @@ -1,6 +1,6 @@ 155.4 1,2,3,4,5,6 155.5 first: true 155.6 -1,2,3,4,5,6,7 155.7 +1,2,3,4,5,6 155.8 1,2,3,,,,4711.17,dingo!,4,5,6 155.9 second: true 155.10 -1,2,3,,,,4711.17,dingo!,4,5,6,7 155.11 +1,2,3,,,,4711.17,dingo!,4,5,6
156.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 156.2 +++ b/test/src/jdk/internal/dynalink/beans/CallerSensitiveTest.java Fri Nov 14 10:03:48 2014 -0800 156.3 @@ -0,0 +1,37 @@ 156.4 +/* 156.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 156.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 156.7 + * 156.8 + * This code is free software; you can redistribute it and/or modify it 156.9 + * under the terms of the GNU General Public License version 2 only, as 156.10 + * published by the Free Software Foundation. Oracle designates this 156.11 + * particular file as subject to the "Classpath" exception as provided 156.12 + * by Oracle in the LICENSE file that accompanied this code. 156.13 + * 156.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 156.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 156.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 156.17 + * version 2 for more details (a copy is included in the LICENSE file that 156.18 + * accompanied this code). 156.19 + * 156.20 + * You should have received a copy of the GNU General Public License version 156.21 + * 2 along with this work; if not, write to the Free Software Foundation, 156.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 156.23 + * 156.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 156.25 + * or visit www.oracle.com if you need additional information or have any 156.26 + * questions. 156.27 + */ 156.28 + 156.29 +package jdk.internal.dynalink.beans; 156.30 + 156.31 +import jdk.nashorn.test.models.ClassLoaderAware; 156.32 +import org.testng.annotations.Test; 156.33 + 156.34 +@SuppressWarnings("javadoc") 156.35 +public class CallerSensitiveTest { 156.36 + @Test 156.37 + public void testCallerSensitive() { 156.38 + BeansLinker.getLinkerForClass(ClassLoaderAware.class); 156.39 + } 156.40 +}
157.1 --- a/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java Wed Nov 12 13:47:23 2014 -0800 157.2 +++ b/test/src/jdk/nashorn/api/javaaccess/ArrayConversionTest.java Fri Nov 14 10:03:48 2014 -0800 157.3 @@ -29,7 +29,6 @@ 157.4 import static org.testng.AssertJUnit.assertFalse; 157.5 import static org.testng.AssertJUnit.assertNull; 157.6 import static org.testng.AssertJUnit.assertTrue; 157.7 - 157.8 import java.util.Arrays; 157.9 import java.util.List; 157.10 import javax.script.ScriptContext; 157.11 @@ -41,6 +40,7 @@ 157.12 import org.testng.annotations.BeforeClass; 157.13 import org.testng.annotations.Test; 157.14 157.15 +@SuppressWarnings("javadoc") 157.16 public class ArrayConversionTest { 157.17 private static ScriptEngine e = null; 157.18 157.19 @@ -49,7 +49,7 @@ 157.20 } 157.21 157.22 @BeforeClass 157.23 - public static void setUpClass() throws ScriptException { 157.24 + public static void setUpClass() { 157.25 e = new ScriptEngineManager().getEngineByName("nashorn"); 157.26 } 157.27 157.28 @@ -205,7 +205,7 @@ 157.29 assertEquals(Arrays.asList("apple", "orange"), array[1]); 157.30 } 157.31 157.32 - public static void assertVarArg_42_17(final Object... args) throws ScriptException { 157.33 + public static void assertVarArg_42_17(final Object... args) { 157.34 assertEquals(2, args.length); 157.35 assertEquals(42, ((Number)args[0]).intValue()); 157.36 assertEquals(17, ((Number)args[1]).intValue());
158.1 --- a/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java Wed Nov 12 13:47:23 2014 -0800 158.2 +++ b/test/src/jdk/nashorn/api/javaaccess/BooleanAccessTest.java Fri Nov 14 10:03:48 2014 -0800 158.3 @@ -27,7 +27,6 @@ 158.4 158.5 import static org.testng.AssertJUnit.assertEquals; 158.6 import static org.testng.AssertJUnit.assertTrue; 158.7 - 158.8 import java.util.Arrays; 158.9 import javax.script.ScriptEngine; 158.10 import javax.script.ScriptEngineManager; 158.11 @@ -42,6 +41,7 @@ 158.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.BooleanAccessTest 158.13 * @run testng/othervm jdk.nashorn.api.javaaccess.BooleanAccessTest 158.14 */ 158.15 +@SuppressWarnings("javadoc") 158.16 public class BooleanAccessTest { 158.17 158.18 private static ScriptEngine e = null;
159.1 --- a/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java Wed Nov 12 13:47:23 2014 -0800 159.2 +++ b/test/src/jdk/nashorn/api/javaaccess/ConsStringTest.java Fri Nov 14 10:03:48 2014 -0800 159.3 @@ -26,7 +26,6 @@ 159.4 package jdk.nashorn.api.javaaccess; 159.5 159.6 import static org.testng.AssertJUnit.assertEquals; 159.7 - 159.8 import java.util.HashMap; 159.9 import java.util.Map; 159.10 import javax.script.Bindings; 159.11 @@ -40,6 +39,7 @@ 159.12 import org.testng.annotations.BeforeClass; 159.13 import org.testng.annotations.Test; 159.14 159.15 +@SuppressWarnings("javadoc") 159.16 public class ConsStringTest { 159.17 private static ScriptEngine e = null; 159.18 159.19 @@ -48,7 +48,7 @@ 159.20 } 159.21 159.22 @BeforeClass 159.23 - public static void setUpClass() throws ScriptException { 159.24 + public static void setUpClass() { 159.25 e = new ScriptEngineManager().getEngineByName("nashorn"); 159.26 } 159.27 159.28 @@ -69,7 +69,7 @@ 159.29 @Test 159.30 public void testConsStringFromMirror() throws ScriptException { 159.31 final Bindings b = e.getBindings(ScriptContext.ENGINE_SCOPE); 159.32 - final Map<Object, Object> m = new HashMap<>(); 159.33 + //final Map<Object, Object> m = new HashMap<>(); 159.34 e.eval("var x = 'f'; x += 'oo'; var obj = {x: x};"); 159.35 assertEquals("foo", ((JSObject)b.get("obj")).getMember("x")); 159.36 }
160.1 --- a/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java Wed Nov 12 13:47:23 2014 -0800 160.2 +++ b/test/src/jdk/nashorn/api/javaaccess/MethodAccessTest.java Fri Nov 14 10:03:48 2014 -0800 160.3 @@ -28,7 +28,6 @@ 160.4 import static org.testng.AssertJUnit.assertEquals; 160.5 import static org.testng.AssertJUnit.assertTrue; 160.6 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; 160.7 - 160.8 import java.util.Arrays; 160.9 import java.util.Calendar; 160.10 import java.util.Locale; 160.11 @@ -45,6 +44,7 @@ 160.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.MethodAccessTest 160.13 * @run testng/othervm jdk.nashorn.api.javaaccess.MethodAccessTest 160.14 */ 160.15 +@SuppressWarnings("javadoc") 160.16 public class MethodAccessTest { 160.17 160.18 private static ScriptEngine e = null;
161.1 --- a/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java Wed Nov 12 13:47:23 2014 -0800 161.2 +++ b/test/src/jdk/nashorn/api/javaaccess/NumberAccessTest.java Fri Nov 14 10:03:48 2014 -0800 161.3 @@ -28,7 +28,6 @@ 161.4 import static org.testng.AssertJUnit.assertEquals; 161.5 import static org.testng.AssertJUnit.assertTrue; 161.6 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; 161.7 - 161.8 import javax.script.ScriptEngine; 161.9 import javax.script.ScriptEngineManager; 161.10 import javax.script.ScriptException; 161.11 @@ -42,6 +41,7 @@ 161.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberAccessTest 161.13 * @run testng/othervm jdk.nashorn.api.javaaccess.NumberAccessTest 161.14 */ 161.15 +@SuppressWarnings("javadoc") 161.16 public class NumberAccessTest { 161.17 161.18 private static ScriptEngine e;
162.1 --- a/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java Wed Nov 12 13:47:23 2014 -0800 162.2 +++ b/test/src/jdk/nashorn/api/javaaccess/NumberBoxingTest.java Fri Nov 14 10:03:48 2014 -0800 162.3 @@ -27,7 +27,6 @@ 162.4 162.5 import static org.testng.AssertJUnit.assertEquals; 162.6 import static org.testng.AssertJUnit.assertTrue; 162.7 - 162.8 import javax.script.ScriptEngine; 162.9 import javax.script.ScriptEngineManager; 162.10 import javax.script.ScriptException; 162.11 @@ -41,6 +40,7 @@ 162.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.NumberBoxingTest 162.13 * @run testng/othervm jdk.nashorn.api.javaaccess.NumberBoxingTest 162.14 */ 162.15 +@SuppressWarnings("javadoc") 162.16 public class NumberBoxingTest { 162.17 162.18 private static ScriptEngine e;
163.1 --- a/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java Wed Nov 12 13:47:23 2014 -0800 163.2 +++ b/test/src/jdk/nashorn/api/javaaccess/ObjectAccessTest.java Fri Nov 14 10:03:48 2014 -0800 163.3 @@ -27,7 +27,6 @@ 163.4 163.5 import static org.testng.AssertJUnit.assertEquals; 163.6 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; 163.7 - 163.8 import javax.script.ScriptEngine; 163.9 import javax.script.ScriptEngineManager; 163.10 import javax.script.ScriptException; 163.11 @@ -41,6 +40,7 @@ 163.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.ObjectAccessTest 163.13 * @run testng/othervm jdk.nashorn.api.javaaccess.ObjectAccessTest 163.14 */ 163.15 +@SuppressWarnings("javadoc") 163.16 public class ObjectAccessTest { 163.17 163.18 private static ScriptEngine e = null;
164.1 --- a/test/src/jdk/nashorn/api/javaaccess/Person.java Wed Nov 12 13:47:23 2014 -0800 164.2 +++ b/test/src/jdk/nashorn/api/javaaccess/Person.java Fri Nov 14 10:03:48 2014 -0800 164.3 @@ -25,6 +25,7 @@ 164.4 164.5 package jdk.nashorn.api.javaaccess; 164.6 164.7 +@SuppressWarnings("javadoc") 164.8 public class Person { 164.9 164.10 public int id = 0;
165.1 --- a/test/src/jdk/nashorn/api/javaaccess/SharedObject.java Wed Nov 12 13:47:23 2014 -0800 165.2 +++ b/test/src/jdk/nashorn/api/javaaccess/SharedObject.java Fri Nov 14 10:03:48 2014 -0800 165.3 @@ -29,6 +29,7 @@ 165.4 import javax.script.ScriptEngine; 165.5 import javax.script.ScriptException; 165.6 165.7 +@SuppressWarnings("javadoc") 165.8 public class SharedObject { 165.9 165.10 // Public fields
166.1 --- a/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java Wed Nov 12 13:47:23 2014 -0800 166.2 +++ b/test/src/jdk/nashorn/api/javaaccess/StringAccessTest.java Fri Nov 14 10:03:48 2014 -0800 166.3 @@ -27,7 +27,6 @@ 166.4 166.5 import static org.testng.AssertJUnit.assertEquals; 166.6 import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals; 166.7 - 166.8 import javax.script.ScriptEngine; 166.9 import javax.script.ScriptEngineManager; 166.10 import javax.script.ScriptException; 166.11 @@ -41,6 +40,7 @@ 166.12 * @build jdk.nashorn.api.javaaccess.SharedObject jdk.nashorn.api.javaaccess.Person jdk.nashorn.api.javaaccess.StringAccessTest 166.13 * @run testng/othervm jdk.nashorn.api.javaaccess.StringAccessTest 166.14 */ 166.15 +@SuppressWarnings("javadoc") 166.16 public class StringAccessTest { 166.17 166.18 private static ScriptEngine e = null;
167.1 --- a/test/src/jdk/nashorn/api/scripting/InvocableTest.java Wed Nov 12 13:47:23 2014 -0800 167.2 +++ b/test/src/jdk/nashorn/api/scripting/InvocableTest.java Fri Nov 14 10:03:48 2014 -0800 167.3 @@ -27,7 +27,6 @@ 167.4 167.5 import static org.testng.Assert.assertEquals; 167.6 import static org.testng.Assert.fail; 167.7 - 167.8 import java.util.Objects; 167.9 import java.util.function.Function; 167.10 import javax.script.Invocable; 167.11 @@ -42,9 +41,10 @@ 167.12 /** 167.13 * Tests for javax.script.Invocable implementation of nashorn. 167.14 */ 167.15 +@SuppressWarnings("javadoc") 167.16 public class InvocableTest { 167.17 167.18 - private void log(final String msg) { 167.19 + private static void log(final String msg) { 167.20 org.testng.Reporter.log(msg, true); 167.21 } 167.22 167.23 @@ -100,7 +100,7 @@ 167.24 167.25 try { 167.26 final Object obj = e.eval("({})"); 167.27 - final Object res = ((Invocable) e).invokeMethod(obj, null); 167.28 + ((Invocable) e).invokeMethod(obj, null); 167.29 fail("should have thrown NPE"); 167.30 } catch (final Exception exp) { 167.31 if (!(exp instanceof NullPointerException)) { 167.32 @@ -120,7 +120,7 @@ 167.33 167.34 try { 167.35 final Object obj = e.eval("({})"); 167.36 - final Object res = ((Invocable) e).invokeMethod(obj, "nonExistentMethod"); 167.37 + ((Invocable) e).invokeMethod(obj, "nonExistentMethod"); 167.38 fail("should have thrown NoSuchMethodException"); 167.39 } catch (final Exception exp) { 167.40 if (!(exp instanceof NoSuchMethodException)) { 167.41 @@ -398,7 +398,7 @@ 167.42 final ScriptEngine e = m.getEngineByName("nashorn"); 167.43 167.44 try { 167.45 - final Object res = ((Invocable) e).invokeFunction(null); 167.46 + ((Invocable)e).invokeFunction(null); 167.47 fail("should have thrown NPE"); 167.48 } catch (final Exception exp) { 167.49 if (!(exp instanceof NullPointerException)) { 167.50 @@ -418,7 +418,7 @@ 167.51 final ScriptEngine e = m.getEngineByName("nashorn"); 167.52 167.53 try { 167.54 - final Object res = ((Invocable) e).invokeFunction("NonExistentFunc"); 167.55 + ((Invocable)e).invokeFunction("NonExistentFunc"); 167.56 fail("should have thrown NoSuchMethodException"); 167.57 } catch (final Exception exp) { 167.58 if (!(exp instanceof NoSuchMethodException)) { 167.59 @@ -439,7 +439,7 @@ 167.60 167.61 try { 167.62 // define an object with method on it 167.63 - final Object obj = e.eval("function hello() { return 'Hello World!'; }"); 167.64 + e.eval("function hello() { return 'Hello World!'; }"); 167.65 final ScriptContext ctxt = new SimpleScriptContext(); 167.66 ctxt.setBindings(e.createBindings(), ScriptContext.ENGINE_SCOPE); 167.67 // change engine's current context 167.68 @@ -526,13 +526,13 @@ 167.69 } 167.70 167.71 @Test 167.72 - @SuppressWarnings("unchecked") 167.73 public void defaultMethodTest() throws ScriptException { 167.74 final ScriptEngineManager m = new ScriptEngineManager(); 167.75 final ScriptEngine e = m.getEngineByName("nashorn"); 167.76 final Invocable inv = (Invocable) e; 167.77 167.78 final Object obj = e.eval("({ apply: function(arg) { return arg.toUpperCase(); }})"); 167.79 + @SuppressWarnings("unchecked") 167.80 final Function<String, String> func = inv.getInterface(obj, Function.class); 167.81 assertEquals(func.apply("hello"), "HELLO"); 167.82 }
168.1 --- a/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java Wed Nov 12 13:47:23 2014 -0800 168.2 +++ b/test/src/jdk/nashorn/api/scripting/MultipleEngineTest.java Fri Nov 14 10:03:48 2014 -0800 168.3 @@ -37,7 +37,7 @@ 168.4 * @test 168.5 * @run testng jdk.nashorn.api.scripting.MultipleEngineTest 168.6 */ 168.7 - 168.8 +@SuppressWarnings("javadoc") 168.9 public class MultipleEngineTest { 168.10 @Test 168.11 public void createAndUseManyEngine() throws ScriptException {
169.1 --- a/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java Wed Nov 12 13:47:23 2014 -0800 169.2 +++ b/test/src/jdk/nashorn/api/scripting/PluggableJSObjectTest.java Fri Nov 14 10:03:48 2014 -0800 169.3 @@ -44,6 +44,7 @@ 169.4 * JDK-8024615: Refactor ScriptObjectMirror and JSObject to support external 169.5 * JSObject implementations. 169.6 */ 169.7 +@SuppressWarnings("javadoc") 169.8 public class PluggableJSObjectTest { 169.9 public static class MapWrapperObject extends AbstractJSObject { 169.10 private final HashMap<String, Object> map = new LinkedHashMap<>(); 169.11 @@ -202,6 +203,7 @@ 169.12 } 169.13 169.14 public static class Factory extends AbstractJSObject { 169.15 + @SuppressWarnings("unused") 169.16 @Override 169.17 public Object newObject(final Object... args) { 169.18 return new HashMap<Object, Object>();
170.1 --- a/test/src/jdk/nashorn/api/scripting/ScopeTest.java Wed Nov 12 13:47:23 2014 -0800 170.2 +++ b/test/src/jdk/nashorn/api/scripting/ScopeTest.java Fri Nov 14 10:03:48 2014 -0800 170.3 @@ -28,7 +28,6 @@ 170.4 import static org.testng.Assert.assertNotNull; 170.5 import static org.testng.Assert.assertTrue; 170.6 import static org.testng.Assert.fail; 170.7 - 170.8 import javax.script.Bindings; 170.9 import javax.script.ScriptContext; 170.10 import javax.script.ScriptEngine; 170.11 @@ -42,6 +41,7 @@ 170.12 /** 170.13 * Tests for jsr223 Bindings "scope" (engine, global scopes) 170.14 */ 170.15 +@SuppressWarnings("javadoc") 170.16 public class ScopeTest { 170.17 170.18 @Test 170.19 @@ -655,6 +655,8 @@ 170.20 170.21 /** 170.22 * Test "slow" scopes involving {@code with} and {@code eval} statements for shared script classes with multiple globals. 170.23 + * @throws ScriptException 170.24 + * @throws InterruptedException 170.25 */ 170.26 @Test 170.27 public static void testSlowScope() throws ScriptException, InterruptedException {
171.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java Wed Nov 12 13:47:23 2014 -0800 171.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java Fri Nov 14 10:03:48 2014 -0800 171.3 @@ -26,12 +26,9 @@ 171.4 package jdk.nashorn.api.scripting; 171.5 171.6 import static org.testng.Assert.fail; 171.7 - 171.8 import java.lang.reflect.InvocationHandler; 171.9 import java.lang.reflect.Method; 171.10 import java.lang.reflect.Proxy; 171.11 -import java.util.Objects; 171.12 -import javax.script.Invocable; 171.13 import javax.script.ScriptEngine; 171.14 import javax.script.ScriptEngineManager; 171.15 import javax.script.ScriptException; 171.16 @@ -40,9 +37,10 @@ 171.17 /** 171.18 * jsr223 tests for security access checks. 171.19 */ 171.20 +@SuppressWarnings("javadoc") 171.21 public class ScriptEngineSecurityTest { 171.22 171.23 - private void log(final String msg) { 171.24 + private static void log(final String msg) { 171.25 org.testng.Reporter.log(msg, true); 171.26 } 171.27 171.28 @@ -169,6 +167,7 @@ 171.29 } 171.30 171.31 // @bug 8032948: Nashorn linkages awry 171.32 + @SuppressWarnings("serial") 171.33 public static class FakeProxy extends Proxy { 171.34 public FakeProxy(final InvocationHandler ih) { 171.35 super(ih); 171.36 @@ -180,7 +179,7 @@ 171.37 } 171.38 171.39 @Test 171.40 - public void fakeProxySubclassAccessCheckTest() throws ScriptException { 171.41 + public void fakeProxySubclassAccessCheckTest() { 171.42 if (System.getSecurityManager() == null) { 171.43 // pass vacuously 171.44 return; 171.45 @@ -197,7 +196,7 @@ 171.46 171.47 // Should not be able to call static methods of Proxy via fake subclass 171.48 try { 171.49 - final Class<?> c = (Class<?>)e.eval(getClass); 171.50 + e.eval(getClass); 171.51 fail("should have thrown SecurityException"); 171.52 } catch (final Exception exp) { 171.53 if (! (exp instanceof SecurityException)) { 171.54 @@ -207,7 +206,7 @@ 171.55 } 171.56 171.57 @Test 171.58 - public void fakeProxySubclassAccessCheckTest2() throws ScriptException { 171.59 + public void fakeProxySubclassAccessCheckTest2() { 171.60 if (System.getSecurityManager() == null) { 171.61 // pass vacuously 171.62 return; 171.63 @@ -224,7 +223,7 @@ 171.64 171.65 // Should not be able to call static methods of Proxy via fake subclass 171.66 try { 171.67 - final Class<?> c = (Class<?>)e.eval(getClass); 171.68 + e.eval(getClass); 171.69 fail("should have thrown SecurityException"); 171.70 } catch (final Exception exp) { 171.71 if (! (exp instanceof SecurityException)) { 171.72 @@ -234,7 +233,7 @@ 171.73 } 171.74 171.75 @Test 171.76 - public static void proxyStaticAccessCheckTest() throws ScriptException { 171.77 + public static void proxyStaticAccessCheckTest() { 171.78 if (System.getSecurityManager() == null) { 171.79 // pass vacuously 171.80 return; 171.81 @@ -247,7 +246,7 @@ 171.82 new Class[] { Runnable.class }, 171.83 new InvocationHandler() { 171.84 @Override 171.85 - public Object invoke(final Object p, final Method m, final Object[] a) { 171.86 + public Object invoke(final Object p, final Method mtd, final Object[] a) { 171.87 return null; 171.88 } 171.89 }); 171.90 @@ -284,7 +283,9 @@ 171.91 } 171.92 }); 171.93 fail("SecurityException should have been thrown"); 171.94 - } catch (final SecurityException exp) {} 171.95 + } catch (final SecurityException e) { 171.96 + //empty 171.97 + } 171.98 } 171.99 171.100 @Test 171.101 @@ -303,6 +304,8 @@ 171.102 } 171.103 }); 171.104 fail("SecurityException should have been thrown"); 171.105 - } catch (final SecurityException exp) {} 171.106 + } catch (final SecurityException e) { 171.107 + //empty 171.108 + } 171.109 } 171.110 }
172.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Wed Nov 12 13:47:23 2014 -0800 172.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Fri Nov 14 10:03:48 2014 -0800 172.3 @@ -29,7 +29,6 @@ 172.4 import static org.testng.Assert.assertNotNull; 172.5 import static org.testng.Assert.assertTrue; 172.6 import static org.testng.Assert.fail; 172.7 - 172.8 import java.io.StringReader; 172.9 import java.io.StringWriter; 172.10 import java.lang.reflect.InvocationHandler; 172.11 @@ -54,9 +53,10 @@ 172.12 * @build jdk.nashorn.api.scripting.Window jdk.nashorn.api.scripting.WindowEventHandler jdk.nashorn.api.scripting.VariableArityTestInterface jdk.nashorn.api.scripting.ScriptEngineTest 172.13 * @run testng/othervm jdk.nashorn.api.scripting.ScriptEngineTest 172.14 */ 172.15 +@SuppressWarnings("javadoc") 172.16 public class ScriptEngineTest { 172.17 172.18 - private void log(final String msg) { 172.19 + private static void log(final String msg) { 172.20 org.testng.Reporter.log(msg, true); 172.21 } 172.22 172.23 @@ -145,6 +145,8 @@ 172.24 case "nashorn": seenNashorn = true; break; 172.25 case "javascript": seenJavaScript = true; break; 172.26 case "ECMAScript": seenECMAScript = true; break; 172.27 + default: 172.28 + break; 172.29 } 172.30 } 172.31 172.32 @@ -159,6 +161,8 @@ 172.33 case "application/ecmascript": seenAppECMA = true; break; 172.34 case "text/javascript": seenTextJS = true; break; 172.35 case "text/ecmascript": seenTextECMA = true; break; 172.36 + default: 172.37 + break; 172.38 } 172.39 } 172.40 172.41 @@ -548,7 +552,7 @@ 172.42 new Class[] { Runnable.class }, 172.43 new InvocationHandler() { 172.44 @Override 172.45 - public Object invoke(final Object p, final Method m, final Object[] a) { 172.46 + public Object invoke(final Object p, final Method mtd, final Object[] a) { 172.47 reached[0] = true; 172.48 return null; 172.49 } 172.50 @@ -633,7 +637,7 @@ 172.51 public static class Context { 172.52 private Object myobj; 172.53 172.54 - public void set(Object o) { 172.55 + public void set(final Object o) { 172.56 myobj = o; 172.57 } 172.58
173.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java Wed Nov 12 13:47:23 2014 -0800 173.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptObjectMirrorTest.java Fri Nov 14 10:03:48 2014 -0800 173.3 @@ -46,6 +46,7 @@ 173.4 /** 173.5 * Tests to check jdk.nashorn.api.scripting.ScriptObjectMirror API. 173.6 */ 173.7 +@SuppressWarnings("javadoc") 173.8 public class ScriptObjectMirrorTest { 173.9 173.10 @SuppressWarnings("unchecked") 173.11 @@ -343,14 +344,13 @@ 173.12 assertEquals(ScriptObjectMirror.class, value3.getClass()); 173.13 assertEquals(ScriptObjectMirror.class, value4.getClass()); 173.14 assertTrue((boolean)invocable.invokeFunction("compare", value1, value1)); 173.15 - assertTrue((boolean)example.compare(value1, value1)); 173.16 + assertTrue(example.compare(value1, value1)); 173.17 assertTrue((boolean)invocable.invokeFunction("compare", value3, value4)); 173.18 - assertTrue((boolean)example.compare(value3, value4)); 173.19 + assertTrue(example.compare(value3, value4)); 173.20 } 173.21 173.22 // @bug 8053910: ScriptObjectMirror causing havoc with Invocation interface 173.23 @Test 173.24 - @SuppressWarnings("unchecked") 173.25 public void mirrorUnwrapInterfaceMethod() throws Exception { 173.26 final ScriptEngineManager engineManager = new ScriptEngineManager(); 173.27 final ScriptEngine engine = engineManager.getEngineByName("nashorn"); 173.28 @@ -358,6 +358,7 @@ 173.29 engine.eval("function apply(obj) { " + 173.30 " return obj instanceof Packages.jdk.nashorn.api.scripting.ScriptObjectMirror; " + 173.31 "}"); 173.32 + @SuppressWarnings("unchecked") 173.33 final Function<Object,Object> func = invocable.getInterface(Function.class); 173.34 assertFalse((boolean)func.apply(engine.eval("({ x: 2 })"))); 173.35 }
174.1 --- a/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java Wed Nov 12 13:47:23 2014 -0800 174.2 +++ b/test/src/jdk/nashorn/api/scripting/VariableArityTestInterface.java Fri Nov 14 10:03:48 2014 -0800 174.3 @@ -25,6 +25,7 @@ 174.4 174.5 package jdk.nashorn.api.scripting; 174.6 174.7 +@SuppressWarnings("javadoc") 174.8 public interface VariableArityTestInterface { 174.9 public String test1(int i, String... strings); 174.10 public String test2(int i, String... strings);
175.1 --- a/test/src/jdk/nashorn/api/scripting/Window.java Wed Nov 12 13:47:23 2014 -0800 175.2 +++ b/test/src/jdk/nashorn/api/scripting/Window.java Fri Nov 14 10:03:48 2014 -0800 175.3 @@ -28,6 +28,7 @@ 175.4 import java.util.Map; 175.5 import javax.script.Bindings; 175.6 175.7 +@SuppressWarnings("javadoc") 175.8 public class Window { 175.9 175.10 private String location = "http://localhost:8080/window";
176.1 --- a/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java Wed Nov 12 13:47:23 2014 -0800 176.2 +++ b/test/src/jdk/nashorn/api/scripting/WindowEventHandler.java Fri Nov 14 10:03:48 2014 -0800 176.3 @@ -25,8 +25,7 @@ 176.4 176.5 package jdk.nashorn.api.scripting; 176.6 176.7 +@SuppressWarnings("javadoc") 176.8 public interface WindowEventHandler { 176.9 - 176.10 public boolean loaded(); 176.11 - 176.12 }
177.1 --- a/test/src/jdk/nashorn/internal/codegen/CompilerTest.java Wed Nov 12 13:47:23 2014 -0800 177.2 +++ b/test/src/jdk/nashorn/internal/codegen/CompilerTest.java Fri Nov 14 10:03:48 2014 -0800 177.3 @@ -27,7 +27,6 @@ 177.4 177.5 import static jdk.nashorn.internal.runtime.Source.readFully; 177.6 import static jdk.nashorn.internal.runtime.Source.sourceFor; 177.7 - 177.8 import java.io.File; 177.9 import java.io.PrintWriter; 177.10 import java.io.StringWriter; 177.11 @@ -45,6 +44,7 @@ 177.12 /** 177.13 * Tests to check Nashorn JS compiler - just compiler and not execution of scripts. 177.14 */ 177.15 +@SuppressWarnings("javadoc") 177.16 public class CompilerTest { 177.17 private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("compilertest.verbose")); 177.18 private static final boolean TEST262 = Boolean.valueOf(System.getProperty("compilertest.test262")); 177.19 @@ -56,7 +56,7 @@ 177.20 public boolean exclude(File file, String content); 177.21 } 177.22 177.23 - private void log(final String msg) { 177.24 + private static void log(final String msg) { 177.25 org.testng.Reporter.log(msg, true); 177.26 } 177.27
178.1 --- a/test/src/jdk/nashorn/internal/parser/ParserTest.java Wed Nov 12 13:47:23 2014 -0800 178.2 +++ b/test/src/jdk/nashorn/internal/parser/ParserTest.java Fri Nov 14 10:03:48 2014 -0800 178.3 @@ -27,7 +27,6 @@ 178.4 178.5 import static jdk.nashorn.internal.runtime.Source.readFully; 178.6 import static jdk.nashorn.internal.runtime.Source.sourceFor; 178.7 - 178.8 import java.io.File; 178.9 import jdk.nashorn.internal.runtime.Context; 178.10 import jdk.nashorn.internal.runtime.ErrorManager; 178.11 @@ -41,6 +40,7 @@ 178.12 /** 178.13 * Run tests to check Nashorn's parser. 178.14 */ 178.15 +@SuppressWarnings("javadoc") 178.16 public class ParserTest { 178.17 private static final boolean VERBOSE = Boolean.valueOf(System.getProperty("parsertest.verbose")); 178.18 private static final boolean TEST262 = Boolean.valueOf(System.getProperty("parsertest.test262"));
179.1 --- a/test/src/jdk/nashorn/internal/performance/AuroraWrapper.java Wed Nov 12 13:47:23 2014 -0800 179.2 +++ b/test/src/jdk/nashorn/internal/performance/AuroraWrapper.java Fri Nov 14 10:03:48 2014 -0800 179.3 @@ -43,6 +43,7 @@ 179.4 import org.w3c.dom.NodeList; 179.5 import org.xml.sax.SAXException; 179.6 179.7 +@SuppressWarnings("javadoc") 179.8 public class AuroraWrapper { 179.9 179.10 public static String fileName = "report.xml";
180.1 --- a/test/src/jdk/nashorn/internal/performance/OctaneTest.java Wed Nov 12 13:47:23 2014 -0800 180.2 +++ b/test/src/jdk/nashorn/internal/performance/OctaneTest.java Fri Nov 14 10:03:48 2014 -0800 180.3 @@ -40,6 +40,7 @@ 180.4 import java.util.List; 180.5 import org.testng.annotations.Test; 180.6 180.7 +@SuppressWarnings("javadoc") 180.8 public class OctaneTest { 180.9 180.10 @Test 180.11 @@ -72,7 +73,7 @@ 180.12 genericTest("GBEMU"); 180.13 } 180.14 180.15 - /* @Test 180.16 +/* @Test 180.17 public void mandreelTest() { 180.18 genericTest("Mandreel"); 180.19 }*/ 180.20 @@ -107,10 +108,20 @@ 180.21 genericTest("Splay"); 180.22 } 180.23 180.24 + @Test 180.25 +/* public void typeScriptTest() { 180.26 + genericTest("TypeScript"); 180.27 + } 180.28 + 180.29 + @Test 180.30 + public void zlibTest() { 180.31 + genericTest("zlib"); 180.32 + }/*/ 180.33 + 180.34 public void genericTest(final String benchmark) { 180.35 try { 180.36 final String mainScript = "test/script/basic/run-octane.js"; 180.37 - final String benchmarkScript = "test/script/external/octane/benchmarks/"+benchmark.toLowerCase() + ".js"; 180.38 + final String benchmarkScript = "test/script/external/octane/benchmarks/" + benchmark.toLowerCase() + ".js"; 180.39 final String[] args = { 180.40 "--", 180.41 benchmarkScript,
181.1 --- a/test/src/jdk/nashorn/internal/performance/PerformanceWrapper.java Wed Nov 12 13:47:23 2014 -0800 181.2 +++ b/test/src/jdk/nashorn/internal/performance/PerformanceWrapper.java Fri Nov 14 10:03:48 2014 -0800 181.3 @@ -36,10 +36,7 @@ 181.4 import jdk.nashorn.internal.runtime.ScriptFunction; 181.5 import jdk.nashorn.internal.runtime.ScriptRuntime; 181.6 181.7 -/** 181.8 - * 181.9 - * @author Pavel Stepanov 181.10 - */ 181.11 +@SuppressWarnings("javadoc") 181.12 public class PerformanceWrapper extends jdk.nashorn.tools.Shell { 181.13 181.14 int _numberOfIterations;
182.1 --- a/test/src/jdk/nashorn/internal/performance/SplayTest.java Wed Nov 12 13:47:23 2014 -0800 182.2 +++ b/test/src/jdk/nashorn/internal/performance/SplayTest.java Fri Nov 14 10:03:48 2014 -0800 182.3 @@ -27,10 +27,7 @@ 182.4 182.5 import org.testng.annotations.Test; 182.6 182.7 -/** 182.8 - * 182.9 - * @author Pavel Stepanov 182.10 - */ 182.11 +@SuppressWarnings("javadoc") 182.12 public class SplayTest { 182.13 182.14 @Test
183.1 --- a/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java Wed Nov 12 13:47:23 2014 -0800 183.2 +++ b/test/src/jdk/nashorn/internal/runtime/ClassFilterTest.java Fri Nov 14 10:03:48 2014 -0800 183.3 @@ -25,18 +25,17 @@ 183.4 183.5 package jdk.nashorn.internal.runtime; 183.6 183.7 +import static org.testng.Assert.fail; 183.8 +import java.io.File; 183.9 +import javax.script.ScriptEngine; 183.10 +import javax.script.ScriptException; 183.11 import jdk.nashorn.api.scripting.ClassFilter; 183.12 import jdk.nashorn.api.scripting.NashornScriptEngineFactory; 183.13 import jdk.nashorn.api.scripting.URLReader; 183.14 import jdk.nashorn.internal.test.framework.TestFinder; 183.15 import org.testng.annotations.Test; 183.16 183.17 -import javax.script.ScriptEngine; 183.18 -import javax.script.ScriptException; 183.19 -import java.io.File; 183.20 - 183.21 -import static org.testng.Assert.fail; 183.22 - 183.23 +@SuppressWarnings("javadoc") 183.24 public class ClassFilterTest { 183.25 private static final String NASHORN_CODE_CACHE = "nashorn.persistent.code.cache"; 183.26 private static final String CLASSFILTER_CODE_CACHE = "build/classfilter_nashorn_code_cache"; 183.27 @@ -48,7 +47,7 @@ 183.28 // test contributes much. We need faster "ant clean test" cycle for 183.29 // developers. 183.30 public void runExternalJsTest() { 183.31 - String[] paths = new String[]{ 183.32 + final String[] paths = new String[]{ 183.33 "test/script/basic/compile-octane.js", 183.34 "test/script/basic/jquery.js", 183.35 "test/script/basic/prototype.js", 183.36 @@ -57,12 +56,12 @@ 183.37 "test/script/basic/yui.js", 183.38 "test/script/basic/run-octane.js" 183.39 }; 183.40 - NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.41 - for (String path : paths) { 183.42 - ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter()); 183.43 + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.44 + for (final String path : paths) { 183.45 + final ScriptEngine engine = factory.getScriptEngine(new String[]{"-scripting"}, getClass().getClassLoader(), getClassFilter()); 183.46 try { 183.47 engine.eval(new URLReader(new File(path).toURI().toURL())); 183.48 - } catch (Exception e) { 183.49 + } catch (final Exception e) { 183.50 fail("Script " + path + " fails with exception :" + e.getMessage()); 183.51 } 183.52 } 183.53 @@ -70,12 +69,13 @@ 183.54 183.55 @Test 183.56 public void noJavaOptionTest() { 183.57 - NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.58 - ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter()); 183.59 + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.60 + final ScriptEngine engine = factory.getScriptEngine(new String[]{"--no-java"}, getClass().getClassLoader(), getClassFilter()); 183.61 try { 183.62 engine.eval("var str = Java.type('java.lang.String');"); 183.63 fail("TypeError should have been thrown"); 183.64 - } catch (ScriptException exc) { 183.65 + } catch (final ScriptException e) { 183.66 + //emtpy 183.67 } 183.68 } 183.69 183.70 @@ -85,27 +85,31 @@ 183.71 return; 183.72 } 183.73 183.74 - NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.75 - ScriptEngine engine = factory.getScriptEngine(getClassFilter()); 183.76 + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.77 + final ScriptEngine engine = factory.getScriptEngine(getClassFilter()); 183.78 try { 183.79 engine.eval("var thread = Java.type('sun.misc.Unsafe')"); 183.80 fail("SecurityException should have been thrown"); 183.81 - } catch (final Exception exc) { 183.82 + } catch (final Exception e) { 183.83 + //empty 183.84 } 183.85 try { 183.86 engine.eval("var thread = new sun.misc.Unsafe()"); 183.87 fail("SecurityException should have been thrown"); 183.88 - } catch (final Exception exc) { 183.89 + } catch (final Exception e) { 183.90 + //empty 183.91 } 183.92 try { 183.93 engine.eval("var thread = Java.extend(sun.misc.Unsafe, {})"); 183.94 fail("TypeError should have been thrown"); 183.95 - } catch (final Exception exc) { 183.96 + } catch (final Exception e) { 183.97 + //empty 183.98 } 183.99 try { 183.100 engine.eval("java.lang.System.exit(0)"); 183.101 fail("SecurityException should have been thrown"); 183.102 - } catch (final Exception exc) { 183.103 + } catch (final Exception e) { 183.104 + //empty 183.105 } 183.106 183.107 } 183.108 @@ -124,24 +128,24 @@ 183.109 } 183.110 183.111 private void persistentCacheTestImpl() { 183.112 - NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.113 - ScriptEngine engine = factory.getScriptEngine( 183.114 + final NashornScriptEngineFactory factory = new NashornScriptEngineFactory(); 183.115 + final ScriptEngine engine = factory.getScriptEngine( 183.116 TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}), 183.117 getClass().getClassLoader(), 183.118 getClassFilter() 183.119 ); 183.120 - String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore(); 183.121 + final String testScript = "var a = Java.type('java.lang.String');" + generateCodeForPersistentStore(); 183.122 try { 183.123 engine.eval(testScript); 183.124 } catch (final ScriptException exc) { 183.125 fail(exc.getMessage()); 183.126 } 183.127 - ScriptEngine engineSafe = factory.getScriptEngine( 183.128 + final ScriptEngine engineSafe = factory.getScriptEngine( 183.129 TestFinder.addExplicitOptimisticTypes(new String[]{"--persistent-code-cache", "--optimistic-types=true"}), 183.130 getClass().getClassLoader(), 183.131 new ClassFilter() { 183.132 @Override 183.133 - public boolean exposeToScripts(String s) { 183.134 + public boolean exposeToScripts(final String s) { 183.135 return false; 183.136 } 183.137 } 183.138 @@ -156,8 +160,8 @@ 183.139 } 183.140 } 183.141 183.142 - private String generateCodeForPersistentStore() { 183.143 - StringBuilder stringBuilder = new StringBuilder(); 183.144 + private static String generateCodeForPersistentStore() { 183.145 + final StringBuilder stringBuilder = new StringBuilder(); 183.146 for (int i=0; i < 100; i++) { 183.147 stringBuilder.append("function i") 183.148 .append(i) 183.149 @@ -170,10 +174,10 @@ 183.150 return stringBuilder.toString(); 183.151 } 183.152 183.153 - private ClassFilter getClassFilter() { 183.154 + private static ClassFilter getClassFilter() { 183.155 return new ClassFilter() { 183.156 @Override 183.157 - public boolean exposeToScripts(String s) { 183.158 + public boolean exposeToScripts(final String s) { 183.159 return true; 183.160 } 183.161 };
184.1 --- a/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java Wed Nov 12 13:47:23 2014 -0800 184.2 +++ b/test/src/jdk/nashorn/internal/runtime/CodeStoreAndPathTest.java Fri Nov 14 10:03:48 2014 -0800 184.3 @@ -26,7 +26,6 @@ 184.4 184.5 import static org.testng.Assert.assertEquals; 184.6 import static org.testng.Assert.assertFalse; 184.7 - 184.8 import java.io.File; 184.9 import java.io.IOException; 184.10 import java.nio.file.DirectoryStream; 184.11 @@ -44,7 +43,7 @@ 184.12 * @summary Test for persistent code cache and path handling 184.13 * @run testng jdk.nashorn.internal.runtime.CodeStoreAndPathTest 184.14 */ 184.15 - 184.16 +@SuppressWarnings("javadoc") 184.17 public class CodeStoreAndPathTest { 184.18 184.19 final String code1 = "var code1; var x = 'Hello Script'; var x1 = 'Hello Script'; " 184.20 @@ -96,21 +95,16 @@ 184.21 final String codeCache = "build/nashorn_code_cache"; 184.22 final String oldUserDir = System.getProperty("user.dir"); 184.23 184.24 - private static final String[] ENGINE_OPTIONS = new String[]{"--persistent-code-cache", "--optimistic-types=false", "--lazy-compilation=false"}; 184.25 - 184.26 - public void checkCompiledScripts(final DirectoryStream<Path> stream, int numberOfScripts) throws IOException { 184.27 - for (final Path file : stream) { 184.28 - numberOfScripts--; 184.29 - } 184.30 - stream.close(); 184.31 - assertEquals(numberOfScripts,0); 184.32 - } 184.33 + private static final String[] ENGINE_OPTIONS_OPT = new String[]{"--persistent-code-cache", "--optimistic-types=true"}; 184.34 + private static final String[] ENGINE_OPTIONS_NOOPT = new String[]{"--persistent-code-cache", "--optimistic-types=false"}; 184.35 184.36 @Test 184.37 - public void pathHandlingTest() throws ScriptException, IOException { 184.38 + public void pathHandlingTest() { 184.39 System.setProperty("nashorn.persistent.code.cache", codeCache); 184.40 final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); 184.41 - final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS); 184.42 + 184.43 + fac.getScriptEngine(ENGINE_OPTIONS_NOOPT); 184.44 + 184.45 final Path expectedCodeCachePath = FileSystems.getDefault().getPath(oldUserDir + File.separator + codeCache); 184.46 final Path actualCodeCachePath = FileSystems.getDefault().getPath(System.getProperty( 184.47 "nashorn.persistent.code.cache")).toAbsolutePath(); 184.48 @@ -126,9 +120,8 @@ 184.49 public void changeUserDirTest() throws ScriptException, IOException { 184.50 System.setProperty("nashorn.persistent.code.cache", codeCache); 184.51 final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); 184.52 - final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS); 184.53 - final Path codeCachePath = FileSystems.getDefault().getPath(System.getProperty( 184.54 - "nashorn.persistent.code.cache")).toAbsolutePath(); 184.55 + final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT); 184.56 + final Path codeCachePath = getCodeCachePath(false); 184.57 final String newUserDir = "build/newUserDir"; 184.58 // Now changing current working directory 184.59 System.setProperty("user.dir", System.getProperty("user.dir") + File.separator + newUserDir); 184.60 @@ -147,9 +140,8 @@ 184.61 public void codeCacheTest() throws ScriptException, IOException { 184.62 System.setProperty("nashorn.persistent.code.cache", codeCache); 184.63 final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); 184.64 - final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS); 184.65 - final Path codeCachePath = FileSystems.getDefault().getPath(System.getProperty( 184.66 - "nashorn.persistent.code.cache")).toAbsolutePath(); 184.67 + final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_NOOPT); 184.68 + final Path codeCachePath = getCodeCachePath(false); 184.69 e.eval(code1); 184.70 e.eval(code2); 184.71 e.eval(code3);// less than minimum size for storing 184.72 @@ -157,4 +149,40 @@ 184.73 final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath); 184.74 checkCompiledScripts(stream, 2); 184.75 } 184.76 + 184.77 + @Test 184.78 + public void codeCacheTestOpt() throws ScriptException, IOException { 184.79 + System.setProperty("nashorn.persistent.code.cache", codeCache); 184.80 + final NashornScriptEngineFactory fac = new NashornScriptEngineFactory(); 184.81 + final ScriptEngine e = fac.getScriptEngine(ENGINE_OPTIONS_OPT); 184.82 + final Path codeCachePath = getCodeCachePath(true); 184.83 + e.eval(code1); 184.84 + e.eval(code2); 184.85 + e.eval(code3);// less than minimum size for storing 184.86 + // adding code1 and code2. 184.87 + final DirectoryStream<Path> stream = Files.newDirectoryStream(codeCachePath); 184.88 + checkCompiledScripts(stream, 2); 184.89 + } 184.90 + 184.91 + private static Path getCodeCachePath(final boolean optimistic) { 184.92 + final String codeCache = System.getProperty("nashorn.persistent.code.cache"); 184.93 + final Path codeCachePath = FileSystems.getDefault().getPath(codeCache).toAbsolutePath(); 184.94 + final String[] files = codeCachePath.toFile().list(); 184.95 + for (final String file : files) { 184.96 + if (file.endsWith("_opt") == optimistic) { 184.97 + return codeCachePath.resolve(file); 184.98 + } 184.99 + } 184.100 + throw new AssertionError("Code cache path not found"); 184.101 + } 184.102 + 184.103 + private static void checkCompiledScripts(final DirectoryStream<Path> stream, final int numberOfScripts) throws IOException { 184.104 + int n = numberOfScripts; 184.105 + for (@SuppressWarnings("unused") final Path file : stream) { 184.106 + n--; 184.107 + } 184.108 + stream.close(); 184.109 + assertEquals(n, 0); 184.110 + } 184.111 + 184.112 }
185.1 --- a/test/src/jdk/nashorn/internal/runtime/ContextTest.java Wed Nov 12 13:47:23 2014 -0800 185.2 +++ b/test/src/jdk/nashorn/internal/runtime/ContextTest.java Fri Nov 14 10:03:48 2014 -0800 185.3 @@ -29,7 +29,6 @@ 185.4 import static org.testng.Assert.assertEquals; 185.5 import static org.testng.Assert.assertTrue; 185.6 import static org.testng.Assert.fail; 185.7 - 185.8 import java.util.Map; 185.9 import jdk.nashorn.internal.objects.Global; 185.10 import jdk.nashorn.internal.runtime.options.Options; 185.11 @@ -41,6 +40,7 @@ 185.12 * @test 185.13 * @run testng jdk.nashorn.internal.runtime.ContextTest 185.14 */ 185.15 +@SuppressWarnings("javadoc") 185.16 public class ContextTest { 185.17 // basic context eval test 185.18 @Test 185.19 @@ -96,7 +96,7 @@ 185.20 final String code = "var obj = { x: 344, y: 42 }"; 185.21 eval(cx, "<reflectionTest>", code); 185.22 185.23 - final Object obj = cx.getGlobal().get("obj"); 185.24 + final Object obj = Context.getGlobal().get("obj"); 185.25 185.26 assertTrue(obj instanceof ScriptObject); 185.27 185.28 @@ -129,7 +129,7 @@ 185.29 } 185.30 } 185.31 185.32 - private Object eval(final Context cx, final String name, final String code) { 185.33 + private static Object eval(final Context cx, final String name, final String code) { 185.34 final Source source = sourceFor(name, code); 185.35 final ScriptObject global = Context.getGlobal(); 185.36 final ScriptFunction func = cx.compileScript(source, global);
186.1 --- a/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java Wed Nov 12 13:47:23 2014 -0800 186.2 +++ b/test/src/jdk/nashorn/internal/runtime/ExceptionsNotSerializable.java Fri Nov 14 10:03:48 2014 -0800 186.3 @@ -27,7 +27,6 @@ 186.4 186.5 import static org.testng.Assert.assertEquals; 186.6 import static org.testng.Assert.fail; 186.7 - 186.8 import java.io.ByteArrayOutputStream; 186.9 import java.io.IOException; 186.10 import java.io.NotSerializableException; 186.11 @@ -43,6 +42,7 @@ 186.12 * @test 186.13 * @run testng jdk.nashorn.internal.runtime.ExceptionsNotSerializable 186.14 */ 186.15 +@SuppressWarnings("javadoc") 186.16 public class ExceptionsNotSerializable { 186.17 @Test 186.18 public void rewriteExceptionNotSerializable() throws ScriptException { 186.19 @@ -59,7 +59,7 @@ 186.20 } 186.21 186.22 @Test 186.23 - public void unwarrantedOptimismExceptionNotSerializable() throws IOException { 186.24 + public void unwarrantedOptimismExceptionNotSerializable() { 186.25 tryToSerialize(new UnwarrantedOptimismException(new Double(1.0), 128)); 186.26 } 186.27
187.1 --- a/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java Wed Nov 12 13:47:23 2014 -0800 187.2 +++ b/test/src/jdk/nashorn/internal/runtime/NoPersistenceCachingTest.java Fri Nov 14 10:03:48 2014 -0800 187.3 @@ -25,7 +25,6 @@ 187.4 package jdk.nashorn.internal.runtime; 187.5 187.6 import static org.testng.Assert.fail; 187.7 - 187.8 import java.io.ByteArrayOutputStream; 187.9 import java.io.PrintStream; 187.10 import java.util.regex.Matcher; 187.11 @@ -46,6 +45,7 @@ 187.12 * @summary Sanity tests for no persistence caching 187.13 * @run testng/othervm jdk.nashorn.internal.runtime.NoPersistenceCachingTest 187.14 */ 187.15 +@SuppressWarnings("javadoc") 187.16 public class NoPersistenceCachingTest { 187.17 187.18 private ScriptEngine engine; 187.19 @@ -102,6 +102,8 @@ 187.20 engine.eval(scriptThreeContexts, context2); 187.21 engine.eval(scriptThreeContexts, context3); 187.22 break; 187.23 + default: 187.24 + break; 187.25 } 187.26 } catch (final Exception se) { 187.27 se.printStackTrace();
188.1 --- a/test/src/jdk/nashorn/internal/runtime/SourceTest.java Wed Nov 12 13:47:23 2014 -0800 188.2 +++ b/test/src/jdk/nashorn/internal/runtime/SourceTest.java Fri Nov 14 10:03:48 2014 -0800 188.3 @@ -29,7 +29,6 @@ 188.4 import static org.testng.Assert.assertEquals; 188.5 import static org.testng.Assert.assertTrue; 188.6 import static org.testng.Assert.fail; 188.7 - 188.8 import java.io.File; 188.9 import java.io.IOException; 188.10 import java.io.InputStreamReader; 188.11 @@ -42,6 +41,7 @@ 188.12 /** 188.13 * Tests different Source representations. 188.14 */ 188.15 +@SuppressWarnings("javadoc") 188.16 public class SourceTest { 188.17 188.18 final private static String SOURCE_NAME = "source.js"; 188.19 @@ -104,11 +104,11 @@ 188.20 } 188.21 } 188.22 188.23 - private Reader getReader(final String path) { 188.24 + private static Reader getReader(final String path) { 188.25 return new InputStreamReader(SourceTest.class.getResourceAsStream(path)); 188.26 } 188.27 188.28 - private void testSources(final Source source1, final Source source2) { 188.29 + private static void testSources(final Source source1, final Source source2) { 188.30 final char[] chars1 = source1.getContent(); 188.31 final char[] chars2 = source2.getContent(); 188.32 final String str1 = source1.getString();
189.1 --- a/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java Wed Nov 12 13:47:23 2014 -0800 189.2 +++ b/test/src/jdk/nashorn/internal/runtime/TrustedScriptEngineTest.java Fri Nov 14 10:03:48 2014 -0800 189.3 @@ -28,7 +28,6 @@ 189.4 import static org.testng.Assert.assertEquals; 189.5 import static org.testng.Assert.assertTrue; 189.6 import static org.testng.Assert.fail; 189.7 - 189.8 import javax.script.ScriptContext; 189.9 import javax.script.ScriptEngine; 189.10 import javax.script.ScriptEngineFactory; 189.11 @@ -42,6 +41,7 @@ 189.12 /** 189.13 * Tests for trusted client usage of nashorn script engine factory extension API 189.14 */ 189.15 +@SuppressWarnings("javadoc") 189.16 public class TrustedScriptEngineTest { 189.17 @Test 189.18 public void versionTest() { 189.19 @@ -64,7 +64,7 @@ 189.20 public boolean reached() { 189.21 return reached[0]; 189.22 } 189.23 - }; 189.24 + } 189.25 189.26 // These are for "private" extension API of NashornScriptEngineFactory that 189.27 // accepts a ClassLoader and/or command line options. 189.28 @@ -140,7 +140,8 @@ 189.29 // try nashorn specific extension 189.30 e.eval("var f = funtion(x) 2*x;"); 189.31 fail("should have thrown exception!"); 189.32 - } catch (final ScriptException se) { 189.33 + } catch (final Exception ex) { 189.34 + //empty 189.35 } 189.36 return; 189.37 } 189.38 @@ -276,7 +277,9 @@ 189.39 try { 189.40 fac.getScriptEngine((ClassFilter)null); 189.41 fail("should have thrown NPE"); 189.42 - } catch (NullPointerException npe) {} 189.43 + } catch (final NullPointerException e) { 189.44 + //empty 189.45 + } 189.46 } 189.47 189.48 @Test 189.49 @@ -285,7 +288,9 @@ 189.50 try { 189.51 fac.getScriptEngine(new String[0], null, null); 189.52 fail("should have thrown NPE"); 189.53 - } catch (NullPointerException npe) {} 189.54 + } catch (final NullPointerException e) { 189.55 + //empty 189.56 + } 189.57 } 189.58 189.59 @Test 189.60 @@ -294,7 +299,9 @@ 189.61 try { 189.62 fac.getScriptEngine((String[])null); 189.63 fail("should have thrown NPE"); 189.64 - } catch (NullPointerException npe) {} 189.65 + } catch (final NullPointerException e) { 189.66 + //empty 189.67 + } 189.68 } 189.69 189.70 @Test 189.71 @@ -308,7 +315,9 @@ 189.72 } 189.73 }); 189.74 fail("should have thrown NPE"); 189.75 - } catch (NullPointerException npe) {} 189.76 + } catch (final NullPointerException e) { 189.77 + //empty 189.78 + } 189.79 } 189.80 189.81 @Test
190.1 --- a/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java Wed Nov 12 13:47:23 2014 -0800 190.2 +++ b/test/src/jdk/nashorn/internal/runtime/regexp/joni/JoniTest.java Fri Nov 14 10:03:48 2014 -0800 190.3 @@ -33,6 +33,7 @@ 190.4 * @test 190.5 * @run testng jdk.nashorn.internal.runtime.regexp.joni.JoniTest 190.6 */ 190.7 +@SuppressWarnings("javadoc") 190.8 public class JoniTest { 190.9 190.10 @Test
191.1 --- a/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Wed Nov 12 13:47:23 2014 -0800 191.2 +++ b/test/src/jdk/nashorn/internal/test/framework/AbstractScriptRunnable.java Fri Nov 14 10:03:48 2014 -0800 191.3 @@ -34,7 +34,6 @@ 191.4 import static jdk.nashorn.internal.test.framework.TestConfig.OPTIONS_RUN; 191.5 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_FAIL_LIST; 191.6 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_SHARED_CONTEXT; 191.7 - 191.8 import java.io.BufferedReader; 191.9 import java.io.File; 191.10 import java.io.IOException; 191.11 @@ -50,6 +49,7 @@ 191.12 /** 191.13 * Abstract class to compile and run one .js script file. 191.14 */ 191.15 +@SuppressWarnings("javadoc") 191.16 public abstract class AbstractScriptRunnable { 191.17 // some test scripts need a "framework" script - whose features are used 191.18 // in the test script. This optional framework script can be null. 191.19 @@ -274,14 +274,14 @@ 191.20 // compile and run this script 191.21 protected abstract void execute(); 191.22 191.23 - private boolean equalsCompilerMsgs(final String es, final String as) { 191.24 + private static boolean equalsCompilerMsgs(final String es, final String as) { 191.25 final int split = es.indexOf(':'); 191.26 // Replace both types of separators ('/' and '\') with the one from 191.27 // current environment 191.28 return (split >= 0) && as.equals(es.substring(0, split).replaceAll("[/\\\\]", Matcher.quoteReplacement(File.separator)) + es.substring(split)); 191.29 } 191.30 191.31 - private void escape(final String value, final StringBuilder out) { 191.32 + private static void escape(final String value, final StringBuilder out) { 191.33 final int len = value.length(); 191.34 for (int i = 0; i < len; i++) { 191.35 final char ch = value.charAt(i); 191.36 @@ -297,7 +297,7 @@ 191.37 } 191.38 } 191.39 191.40 - private String escape(final String value) { 191.41 + private static String escape(final String value) { 191.42 final StringBuilder sb = new StringBuilder(); 191.43 escape(value, sb); 191.44 return sb.toString();
192.1 --- a/test/src/jdk/nashorn/internal/test/framework/OrphanTestFinder.java Wed Nov 12 13:47:23 2014 -0800 192.2 +++ b/test/src/jdk/nashorn/internal/test/framework/OrphanTestFinder.java Fri Nov 14 10:03:48 2014 -0800 192.3 @@ -34,6 +34,7 @@ 192.4 * Test case used by JSCompilerTest to complain if test files are marked as 192.5 * neither test nor subtest. 192.6 */ 192.7 +@SuppressWarnings("javadoc") 192.8 public final class OrphanTestFinder implements ITest { 192.9 private final Set<String> orphanFiles; 192.10
193.1 --- a/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java Wed Nov 12 13:47:23 2014 -0800 193.2 +++ b/test/src/jdk/nashorn/internal/test/framework/ParallelTestRunner.java Fri Nov 14 10:03:48 2014 -0800 193.3 @@ -31,7 +31,6 @@ 193.4 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_EXCLUDE_LIST; 193.5 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_FRAMEWORK; 193.6 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_ROOTS; 193.7 - 193.8 import java.io.BufferedReader; 193.9 import java.io.ByteArrayOutputStream; 193.10 import java.io.File; 193.11 @@ -73,6 +72,7 @@ 193.12 * Parallel test runner runs tests in multiple threads - but avoids any dependency 193.13 * on third-party test framework library such as TestNG. 193.14 */ 193.15 +@SuppressWarnings("javadoc") 193.16 public class ParallelTestRunner { 193.17 193.18 // ParallelTestRunner-specific 193.19 @@ -247,7 +247,7 @@ 193.20 } 193.21 } 193.22 193.23 - private void compare(final String outputFileName, final String expected, final boolean compareCompilerMsg) throws IOException { 193.24 + private void compare(final String fileName, final String expected, final boolean compareCompilerMsg) throws IOException { 193.25 final File expectedFile = new File(expected); 193.26 193.27 BufferedReader expectedReader; 193.28 @@ -257,7 +257,7 @@ 193.29 expectedReader = new BufferedReader(new StringReader("")); 193.30 } 193.31 193.32 - final BufferedReader actual = new BufferedReader(new InputStreamReader(new FileInputStream(outputFileName))); 193.33 + final BufferedReader actual = new BufferedReader(new InputStreamReader(new FileInputStream(fileName))); 193.34 193.35 compare(actual, expectedReader, compareCompilerMsg); 193.36 } 193.37 @@ -434,8 +434,8 @@ 193.38 public static void main(final String[] args) throws Exception { 193.39 parseArgs(args); 193.40 193.41 - while(new ParallelTestRunner().run()) { 193.42 - ; 193.43 + while (new ParallelTestRunner().run()) { 193.44 + //empty 193.45 } 193.46 } 193.47
194.1 --- a/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java Wed Nov 12 13:47:23 2014 -0800 194.2 +++ b/test/src/jdk/nashorn/internal/test/framework/ScriptRunnable.java Fri Nov 14 10:03:48 2014 -0800 194.3 @@ -52,6 +52,7 @@ 194.4 * class. Optionally, output from running the script is compared against the 194.5 * corresponding .EXPECTED file. 194.6 */ 194.7 +@SuppressWarnings("javadoc") 194.8 public final class ScriptRunnable extends AbstractScriptRunnable implements ITest { 194.9 public ScriptRunnable(final String framework, final File testFile, final List<String> engineOptions, final Map<String, String> testOptions, final List<String> scriptArguments) { 194.10 super(framework, testFile, engineOptions, testOptions, scriptArguments);
195.1 --- a/test/src/jdk/nashorn/internal/test/framework/ScriptTest.java Wed Nov 12 13:47:23 2014 -0800 195.2 +++ b/test/src/jdk/nashorn/internal/test/framework/ScriptTest.java Fri Nov 14 10:03:48 2014 -0800 195.3 @@ -26,7 +26,6 @@ 195.4 package jdk.nashorn.internal.test.framework; 195.5 195.6 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_INCLUDES; 195.7 - 195.8 import java.io.File; 195.9 import java.util.ArrayList; 195.10 import java.util.List; 195.11 @@ -48,7 +47,9 @@ 195.12 * Creates a test factory for the set of .js source tests. 195.13 * 195.14 * @return a Object[] of test objects. 195.15 + * @throws Exception upon failure 195.16 */ 195.17 + @SuppressWarnings("static-method") 195.18 @Factory 195.19 public Object[] suite() throws Exception { 195.20 Locale.setDefault(new Locale(""));
196.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestConfig.java Wed Nov 12 13:47:23 2014 -0800 196.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestConfig.java Fri Nov 14 10:03:48 2014 -0800 196.3 @@ -28,6 +28,7 @@ 196.4 /** 196.5 * Configuration info for script tests. 196.6 */ 196.7 +@SuppressWarnings("javadoc") 196.8 public interface TestConfig { 196.9 // Test options inferred from various test @foo tags and passed to test factory. 196.10 public static final String OPTIONS_RUN = "run";
197.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Wed Nov 12 13:47:23 2014 -0800 197.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestFinder.java Fri Nov 14 10:03:48 2014 -0800 197.3 @@ -42,7 +42,6 @@ 197.4 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_LIST; 197.5 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_ROOTS; 197.6 import static jdk.nashorn.internal.test.framework.TestConfig.TEST_JS_UNCHECKED_DIR; 197.7 - 197.8 import java.io.BufferedReader; 197.9 import java.io.File; 197.10 import java.io.FileReader; 197.11 @@ -76,6 +75,7 @@ 197.12 * Utility class to find/parse script test files and to create 'test' instances. 197.13 * Actual 'test' object type is decided by clients of this class. 197.14 */ 197.15 +@SuppressWarnings("javadoc") 197.16 public final class TestFinder { 197.17 private TestFinder() {} 197.18 197.19 @@ -299,6 +299,8 @@ 197.20 case "@fork": 197.21 fork = true; 197.22 break; 197.23 + default: 197.24 + break; 197.25 } 197.26 197.27 // negative tests are expected to fail at runtime only 197.28 @@ -377,7 +379,7 @@ 197.29 * 197.30 * @args new argument list array 197.31 */ 197.32 - public static String[] addExplicitOptimisticTypes(String[] args) { 197.33 + public static String[] addExplicitOptimisticTypes(final String[] args) { 197.34 if (hasOptimisticOverride()) { 197.35 final List<String> newList = new ArrayList<>(Arrays.asList(args)); 197.36 newList.add("--optimistic-types=" + Boolean.valueOf(OPTIMISTIC_OVERRIDE)); 197.37 @@ -392,7 +394,7 @@ 197.38 * 197.39 * @args argument list 197.40 */ 197.41 - public static void addExplicitOptimisticTypes(List<String> args) { 197.42 + public static void addExplicitOptimisticTypes(final List<String> args) { 197.43 if (hasOptimisticOverride()) { 197.44 args.add("--optimistic-types=" + Boolean.valueOf(OPTIMISTIC_OVERRIDE)); 197.45 }
198.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestHelper.java Wed Nov 12 13:47:23 2014 -0800 198.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestHelper.java Fri Nov 14 10:03:48 2014 -0800 198.3 @@ -36,6 +36,7 @@ 198.4 /** 198.5 * Simple utilities to deal with build-dir, read/dump files etc. 198.6 */ 198.7 +@SuppressWarnings("javadoc") 198.8 public abstract class TestHelper { 198.9 198.10 public static final String TEST_ROOT = "test";
199.1 --- a/test/src/jdk/nashorn/internal/test/framework/TestReorderInterceptor.java Wed Nov 12 13:47:23 2014 -0800 199.2 +++ b/test/src/jdk/nashorn/internal/test/framework/TestReorderInterceptor.java Fri Nov 14 10:03:48 2014 -0800 199.3 @@ -47,10 +47,9 @@ 199.4 final Object o2 = mi2.getInstance(); 199.5 if (o1 instanceof ITest && o2 instanceof ITest) { 199.6 return ((ITest)o1).getTestName().compareTo(((ITest)o2).getTestName()); 199.7 - } else { 199.8 - // something else, don't care about the order 199.9 - return 0; 199.10 } 199.11 + // something else, don't care about the order 199.12 + return 0; 199.13 } 199.14 }); 199.15
200.1 --- a/test/src/jdk/nashorn/internal/test/models/InternalRunnable.java Wed Nov 12 13:47:23 2014 -0800 200.2 +++ b/test/src/jdk/nashorn/internal/test/models/InternalRunnable.java Fri Nov 14 10:03:48 2014 -0800 200.3 @@ -28,6 +28,7 @@ 200.4 import java.io.PrintWriter; 200.5 import java.io.StringWriter; 200.6 200.7 +@SuppressWarnings("javadoc") 200.8 public class InternalRunnable implements Runnable, RestrictedRunnable { 200.9 200.10 // This is a public field in a restricted class; scripts should not see it.
201.1 --- a/test/src/jdk/nashorn/internal/test/models/RestrictedRunnable.java Wed Nov 12 13:47:23 2014 -0800 201.2 +++ b/test/src/jdk/nashorn/internal/test/models/RestrictedRunnable.java Fri Nov 14 10:03:48 2014 -0800 201.3 @@ -27,8 +27,8 @@ 201.4 201.5 /** 201.6 * Acts as a restricted interface implemented by a restricted class. 201.7 - * 201.8 */ 201.9 +@SuppressWarnings("javadoc") 201.10 public interface RestrictedRunnable { 201.11 public void restrictedRun(); 201.12 }
202.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 202.2 +++ b/test/src/jdk/nashorn/test/models/ClassLoaderAware.java Fri Nov 14 10:03:48 2014 -0800 202.3 @@ -0,0 +1,32 @@ 202.4 +/* 202.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 202.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 202.7 + * 202.8 + * This code is free software; you can redistribute it and/or modify it 202.9 + * under the terms of the GNU General Public License version 2 only, as 202.10 + * published by the Free Software Foundation. Oracle designates this 202.11 + * particular file as subject to the "Classpath" exception as provided 202.12 + * by Oracle in the LICENSE file that accompanied this code. 202.13 + * 202.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 202.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 202.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 202.17 + * version 2 for more details (a copy is included in the LICENSE file that 202.18 + * accompanied this code). 202.19 + * 202.20 + * You should have received a copy of the GNU General Public License version 202.21 + * 2 along with this work; if not, write to the Free Software Foundation, 202.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 202.23 + * 202.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 202.25 + * or visit www.oracle.com if you need additional information or have any 202.26 + * questions. 202.27 + */ 202.28 + 202.29 +package jdk.nashorn.test.models; 202.30 + 202.31 +@SuppressWarnings("javadoc") 202.32 +public interface ClassLoaderAware { 202.33 + public ClassLoader getContextClassLoader(); 202.34 + public void checkMemberAccess(Class<?> clazz, int which); 202.35 +}
203.1 --- a/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java Wed Nov 12 13:47:23 2014 -0800 203.2 +++ b/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java Fri Nov 14 10:03:48 2014 -0800 203.3 @@ -25,7 +25,10 @@ 203.4 203.5 package jdk.nashorn.test.models; 203.6 203.7 +@SuppressWarnings("javadoc") 203.8 public class ClassWithFinalFinalizer { 203.9 + @Override 203.10 protected final void finalize() { 203.11 + //empty 203.12 } 203.13 }
204.1 --- a/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java Wed Nov 12 13:47:23 2014 -0800 204.2 +++ b/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java Fri Nov 14 10:03:48 2014 -0800 204.3 @@ -25,5 +25,7 @@ 204.4 204.5 package jdk.nashorn.test.models; 204.6 204.7 +@SuppressWarnings("javadoc") 204.8 public class ClassWithInheritedFinalFinalizer extends ClassWithFinalFinalizer { 204.9 + //empty 204.10 }
205.1 --- a/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java Wed Nov 12 13:47:23 2014 -0800 205.2 +++ b/test/src/jdk/nashorn/test/models/ConstructorWithArgument.java Fri Nov 14 10:03:48 2014 -0800 205.3 @@ -25,6 +25,7 @@ 205.4 205.5 package jdk.nashorn.test.models; 205.6 205.7 +@SuppressWarnings("javadoc") 205.8 public abstract class ConstructorWithArgument { 205.9 private final String token; 205.10
206.1 --- a/test/src/jdk/nashorn/test/models/DessertTopping.java Wed Nov 12 13:47:23 2014 -0800 206.2 +++ b/test/src/jdk/nashorn/test/models/DessertTopping.java Fri Nov 14 10:03:48 2014 -0800 206.3 @@ -25,6 +25,7 @@ 206.4 206.5 package jdk.nashorn.test.models; 206.6 206.7 +@SuppressWarnings("javadoc") 206.8 public interface DessertTopping { 206.9 public String pourOnDessert(); 206.10 }
207.1 --- a/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java Wed Nov 12 13:47:23 2014 -0800 207.2 +++ b/test/src/jdk/nashorn/test/models/DessertToppingFloorWaxDriver.java Fri Nov 14 10:03:48 2014 -0800 207.3 @@ -25,6 +25,7 @@ 207.4 207.5 package jdk.nashorn.test.models; 207.6 207.7 +@SuppressWarnings("javadoc") 207.8 public class DessertToppingFloorWaxDriver { 207.9 public void decorateDessert(final DessertTopping dt) { 207.10 dt.pourOnDessert();
208.1 --- a/test/src/jdk/nashorn/test/models/FinalClass.java Wed Nov 12 13:47:23 2014 -0800 208.2 +++ b/test/src/jdk/nashorn/test/models/FinalClass.java Fri Nov 14 10:03:48 2014 -0800 208.3 @@ -25,6 +25,7 @@ 208.4 208.5 package jdk.nashorn.test.models; 208.6 208.7 +@SuppressWarnings("javadoc") 208.8 public final class FinalClass { 208.9 //empty 208.10 }
209.1 --- a/test/src/jdk/nashorn/test/models/FloorWax.java Wed Nov 12 13:47:23 2014 -0800 209.2 +++ b/test/src/jdk/nashorn/test/models/FloorWax.java Fri Nov 14 10:03:48 2014 -0800 209.3 @@ -25,6 +25,7 @@ 209.4 209.5 package jdk.nashorn.test.models; 209.6 209.7 +@SuppressWarnings("javadoc") 209.8 public interface FloorWax { 209.9 public String shineUpTheFloor(); 209.10 }
210.1 --- a/test/src/jdk/nashorn/test/models/IntFloatOverloadSelection.java Wed Nov 12 13:47:23 2014 -0800 210.2 +++ b/test/src/jdk/nashorn/test/models/IntFloatOverloadSelection.java Fri Nov 14 10:03:48 2014 -0800 210.3 @@ -24,6 +24,7 @@ 210.4 */ 210.5 package jdk.nashorn.test.models; 210.6 210.7 +@SuppressWarnings("javadoc") 210.8 public class IntFloatOverloadSelection { 210.9 210.10 public static String overloadedMethod(final int i) {
211.1 --- a/test/src/jdk/nashorn/test/models/InternalRunnableSuperclass.java Wed Nov 12 13:47:23 2014 -0800 211.2 +++ b/test/src/jdk/nashorn/test/models/InternalRunnableSuperclass.java Fri Nov 14 10:03:48 2014 -0800 211.3 @@ -30,8 +30,9 @@ 211.4 211.5 /** 211.6 * Acts as a non-restricted superclass for a restricted class. 211.7 - * 211.8 */ 211.9 + 211.10 +@SuppressWarnings("javadoc") 211.11 public class InternalRunnableSuperclass { 211.12 public final int canSeeThisField = 19; 211.13
212.1 --- a/test/src/jdk/nashorn/test/models/Jdk8011362TestSubject.java Wed Nov 12 13:47:23 2014 -0800 212.2 +++ b/test/src/jdk/nashorn/test/models/Jdk8011362TestSubject.java Fri Nov 14 10:03:48 2014 -0800 212.3 @@ -26,8 +26,9 @@ 212.4 package jdk.nashorn.test.models; 212.5 212.6 /** 212.7 - * Test class used by JDK-8011362.js. 212.8 + * Test class used by JDK-8011362.js 212.9 */ 212.10 +@SuppressWarnings("javadoc") 212.11 public class Jdk8011362TestSubject { 212.12 // This is selected for overloaded("", null) 212.13 public String overloaded(final String a, final String b) {
213.1 --- a/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java Wed Nov 12 13:47:23 2014 -0800 213.2 +++ b/test/src/jdk/nashorn/test/models/Nashorn401TestSubject.java Fri Nov 14 10:03:48 2014 -0800 213.3 @@ -25,6 +25,7 @@ 213.4 213.5 package jdk.nashorn.test.models; 213.6 213.7 +@SuppressWarnings("javadoc") 213.8 public class Nashorn401TestSubject { 213.9 public String method2(final int arg) { 213.10 return "int method 2";
214.1 --- a/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java Wed Nov 12 13:47:23 2014 -0800 214.2 +++ b/test/src/jdk/nashorn/test/models/NoAccessibleConstructorClass.java Fri Nov 14 10:03:48 2014 -0800 214.3 @@ -25,6 +25,7 @@ 214.4 214.5 package jdk.nashorn.test.models; 214.6 214.7 +@SuppressWarnings("javadoc") 214.8 public class NoAccessibleConstructorClass { 214.9 NoAccessibleConstructorClass() { } 214.10 }
215.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 215.2 +++ b/test/src/jdk/nashorn/test/models/NullProvider.java Fri Nov 14 10:03:48 2014 -0800 215.3 @@ -0,0 +1,34 @@ 215.4 +/* 215.5 + * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. 215.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 215.7 + * 215.8 + * This code is free software; you can redistribute it and/or modify it 215.9 + * under the terms of the GNU General Public License version 2 only, as 215.10 + * published by the Free Software Foundation. Oracle designates this 215.11 + * particular file as subject to the "Classpath" exception as provided 215.12 + * by Oracle in the LICENSE file that accompanied this code. 215.13 + * 215.14 + * This code is distributed in the hope that it will be useful, but WITHOUT 215.15 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 215.16 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 215.17 + * version 2 for more details (a copy is included in the LICENSE file that 215.18 + * accompanied this code). 215.19 + * 215.20 + * You should have received a copy of the GNU General Public License version 215.21 + * 2 along with this work; if not, write to the Free Software Foundation, 215.22 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 215.23 + * 215.24 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 215.25 + * or visit www.oracle.com if you need additional information or have any 215.26 + * questions. 215.27 + */ 215.28 + 215.29 +package jdk.nashorn.test.models; 215.30 + 215.31 + 215.32 +public class NullProvider { 215.33 + public static Integer getInteger() { return null; } 215.34 + public static Long getLong() { return null; } 215.35 + public static Double getDouble() { return null; } 215.36 + public static Boolean getBoolean() { return null; } 215.37 +}
216.1 --- a/test/src/jdk/nashorn/test/models/OuterClass.java Wed Nov 12 13:47:23 2014 -0800 216.2 +++ b/test/src/jdk/nashorn/test/models/OuterClass.java Fri Nov 14 10:03:48 2014 -0800 216.3 @@ -25,6 +25,7 @@ 216.4 216.5 package jdk.nashorn.test.models; 216.6 216.7 +@SuppressWarnings("javadoc") 216.8 public class OuterClass { 216.9 private final String value; 216.10 216.11 @@ -35,6 +36,7 @@ 216.12 public static class InnerStaticClass { 216.13 216.14 public static class InnerInnerStaticClass { 216.15 + //empty 216.16 } 216.17 216.18 private final String value; 216.19 @@ -50,15 +52,15 @@ 216.20 } 216.21 216.22 public class InnerNonStaticClass { 216.23 - private final String value; 216.24 + private final String val; 216.25 216.26 public InnerNonStaticClass(final String value) { 216.27 - this.value = value; 216.28 + this.val = value; 216.29 } 216.30 216.31 @Override 216.32 public String toString() { 216.33 - return "InnerNonStaticClass[value=" + value + ", outer=" + OuterClass.this + "]"; 216.34 + return "InnerNonStaticClass[value=" + val + ", outer=" + OuterClass.this + "]"; 216.35 } 216.36 } 216.37
217.1 --- a/test/src/jdk/nashorn/test/models/OverloadedSam.java Wed Nov 12 13:47:23 2014 -0800 217.2 +++ b/test/src/jdk/nashorn/test/models/OverloadedSam.java Fri Nov 14 10:03:48 2014 -0800 217.3 @@ -25,6 +25,7 @@ 217.4 217.5 package jdk.nashorn.test.models; 217.6 217.7 +@SuppressWarnings("javadoc") 217.8 public interface OverloadedSam { 217.9 public void sam(String s); 217.10 public void sam(String s1, String s2);
218.1 --- a/test/src/jdk/nashorn/test/models/OverrideObject.java Wed Nov 12 13:47:23 2014 -0800 218.2 +++ b/test/src/jdk/nashorn/test/models/OverrideObject.java Fri Nov 14 10:03:48 2014 -0800 218.3 @@ -25,6 +25,7 @@ 218.4 218.5 package jdk.nashorn.test.models; 218.6 218.7 +@SuppressWarnings("javadoc") 218.8 public class OverrideObject { 218.9 @Override 218.10 public int hashCode() {
219.1 --- a/test/src/jdk/nashorn/test/models/PropertyBind.java Wed Nov 12 13:47:23 2014 -0800 219.2 +++ b/test/src/jdk/nashorn/test/models/PropertyBind.java Fri Nov 14 10:03:48 2014 -0800 219.3 @@ -25,6 +25,7 @@ 219.4 219.5 package jdk.nashorn.test.models; 219.6 219.7 +@SuppressWarnings("javadoc") 219.8 public class PropertyBind { 219.9 public static int publicStaticInt; 219.10 public static final int publicStaticFinalInt = 2112;
220.1 --- a/test/src/jdk/nashorn/test/models/SourceHelper.java Wed Nov 12 13:47:23 2014 -0800 220.2 +++ b/test/src/jdk/nashorn/test/models/SourceHelper.java Fri Nov 14 10:03:48 2014 -0800 220.3 @@ -34,6 +34,7 @@ 220.4 /** 220.5 * Helper class to facilitate script access of nashorn Source class. 220.6 */ 220.7 +@SuppressWarnings("javadoc") 220.8 public final class SourceHelper { 220.9 private SourceHelper() {} 220.10
221.1 --- a/test/src/jdk/nashorn/test/models/StringArgs.java Wed Nov 12 13:47:23 2014 -0800 221.2 +++ b/test/src/jdk/nashorn/test/models/StringArgs.java Fri Nov 14 10:03:48 2014 -0800 221.3 @@ -27,6 +27,7 @@ 221.4 221.5 import java.util.List; 221.6 221.7 +@SuppressWarnings("javadoc") 221.8 public class StringArgs { 221.9 221.10 public static void checkString(final List<?> list) {
222.1 --- a/test/src/jdk/nashorn/test/models/Toothpaste.java Wed Nov 12 13:47:23 2014 -0800 222.2 +++ b/test/src/jdk/nashorn/test/models/Toothpaste.java Fri Nov 14 10:03:48 2014 -0800 222.3 @@ -25,6 +25,7 @@ 222.4 222.5 package jdk.nashorn.test.models; 222.6 222.7 +@SuppressWarnings("javadoc") 222.8 public abstract class Toothpaste { 222.9 public void applyToBrush() { 222.10 applyToBrushImpl();
223.1 --- a/test/src/jdk/nashorn/test/models/VarArgConstructor.java Wed Nov 12 13:47:23 2014 -0800 223.2 +++ b/test/src/jdk/nashorn/test/models/VarArgConstructor.java Fri Nov 14 10:03:48 2014 -0800 223.3 @@ -27,6 +27,7 @@ 223.4 223.5 import java.util.List; 223.6 223.7 +@SuppressWarnings("javadoc") 223.8 public class VarArgConstructor { 223.9 private final String indicator; 223.10
224.1 --- a/test/src/jdk/nashorn/test/tools/StaticTypeInspector.java Wed Nov 12 13:47:23 2014 -0800 224.2 +++ b/test/src/jdk/nashorn/test/tools/StaticTypeInspector.java Fri Nov 14 10:03:48 2014 -0800 224.3 @@ -26,6 +26,7 @@ 224.4 224.5 import jdk.nashorn.internal.runtime.Undefined; 224.6 224.7 +@SuppressWarnings("javadoc") 224.8 public class StaticTypeInspector { 224.9 224.10 public static String inspect(final boolean x, final String w) {