Tue, 27 Aug 2013 19:26:48 +0530
Merge
1.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Mon Aug 26 14:54:25 2013 -0700 1.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ConstructorGenerator.java Tue Aug 27 19:26:48 2013 +0530 1.3 @@ -27,7 +27,6 @@ 1.4 1.5 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL; 1.6 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC; 1.7 -import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER; 1.8 import static jdk.internal.org.objectweb.asm.Opcodes.H_INVOKESTATIC; 1.9 import static jdk.internal.org.objectweb.asm.Opcodes.V1_7; 1.10 import static jdk.nashorn.internal.tools.nasgen.StringConstants.CONSTRUCTOR_SUFFIX;
2.1 --- a/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Mon Aug 26 14:54:25 2013 -0700 2.2 +++ b/buildtools/nasgen/src/jdk/nashorn/internal/tools/nasgen/ScriptClassInstrumentor.java Tue Aug 27 19:26:48 2013 +0530 2.3 @@ -27,7 +27,6 @@ 2.4 2.5 import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD; 2.6 import static jdk.internal.org.objectweb.asm.Opcodes.DUP; 2.7 -import static jdk.internal.org.objectweb.asm.Opcodes.GETSTATIC; 2.8 import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESPECIAL; 2.9 import static jdk.internal.org.objectweb.asm.Opcodes.INVOKESTATIC; 2.10 import static jdk.internal.org.objectweb.asm.Opcodes.NEW;
3.1 --- a/docs/DEVELOPER_README Mon Aug 26 14:54:25 2013 -0700 3.2 +++ b/docs/DEVELOPER_README Tue Aug 27 19:26:48 2013 +0530 3.3 @@ -16,8 +16,9 @@ 3.4 SYSTEM PROPERTY: -Dnashorn.args=<string> 3.5 3.6 This property takes as its value a space separated list of Nashorn 3.7 -command line options that should be passed to Nashorn. This might be useful 3.8 -in environments where it is hard to tell how a nashorn.jar is launched. 3.9 +command line options that should be passed to Nashorn. This might be 3.10 +useful in environments where it is hard to tell how a nashorn.jar is 3.11 +launched. 3.12 3.13 Example: 3.14 3.15 @@ -43,6 +44,10 @@ 3.16 3.17 SYSTEM PROPERTY: -Dnashorn.compiler.intarithmetic 3.18 3.19 +(and integer arithmetic in general) 3.20 + 3.21 +<currently disabled - this is being refactored for update releases> 3.22 + 3.23 Arithmetic operations in Nashorn (except bitwise ones) typically 3.24 coerce the operands to doubles (as per the JavaScript spec). To switch 3.25 this off and remain in integer mode, for example for "var x = a&b; var 3.26 @@ -65,13 +70,382 @@ 3.27 does not overflow. Getting access to a JVM intrinsic that does branch 3.28 on overflow would probably alleviate this. 3.29 3.30 -There is also a problem with this optimistic approach if the symbol 3.31 -happens to reside in a local variable slot in the bytecode, as those 3.32 -are strongly typed. Then we would need to split large sections of 3.33 -control flow, so this is probably not the right way to go, while range 3.34 -analysis is. There is a large difference between integer bytecode 3.35 -without overflow checks and double bytecode. The former is 3.36 -significantly faster. 3.37 +The future: 3.38 + 3.39 +We are transitioning to an optimistic type system that uses int 3.40 +arithmetic everywhere until proven wrong. The problem here is mostly 3.41 +catch an overflow exception and rolling back the state to a new method 3.42 +with less optimistic assumptions for an operation at a particular 3.43 +program point. This will most likely not be in the Java 8.0 release 3.44 +but likely end up in an update release 3.45 + 3.46 +For Java 8, several java.lang.Math methods like addExact, subExact and 3.47 +mulExact are available to help us. Experiments intrinsifying these 3.48 +show a lot of promise, and we have devised a system that basically 3.49 +does on stack replacement with exceptions in bytecode to revert 3.50 +erroneous assumptions. An explanation of how this works and what we 3.51 +are doing can be found here: 3.52 +http://www.slideshare.net/lagergren/lagergren-jvmls2013final 3.53 + 3.54 +Experiments with this show significant ~x2-3 performance increases on 3.55 +pretty much everything, provided that optimistic assumptions don't 3.56 +fail much. It will affect warmup time negatively, depending on how 3.57 +many erroneous too optimistic assumptions are placed in the code at 3.58 +compile time. We don't think this will be much of an issue. 3.59 + 3.60 +For example for a small benchmark that repeatedly executes this 3.61 +method taken from the Crypto Octane benchmark 3.62 + 3.63 +function am3(i,x,w,j,c,n) { 3.64 + var this_array = this.array; 3.65 + var w_array = w.array; 3.66 + var xl = x&0x3fff, xh = x>>14; 3.67 + while(--n >= 0) { 3.68 + var l = this_array[i]&0x3fff; 3.69 + var h = this_array[i++]>>14; 3.70 + var m = xh*l+h*xl; 3.71 + l = xl*l+((m&0x3fff)<<14)+w_array[j]+c; 3.72 + c = (l>>28)+(m>>14)+xh*h; 3.73 + w_array[j++] = l&0xfffffff; 3.74 + } 3.75 + 3.76 + return c; 3.77 +} 3.78 + 3.79 +The performance increase more than doubles. We are also working hard 3.80 +with the code generation team in the Java Virtual Machine to fix 3.81 +things that are lacking in invokedynamic performance, which is another 3.82 +area where a lot of ongoing performance work takes place 3.83 + 3.84 +"Pessimistic" bytecode for am3, guaranteed to be semantically correct: 3.85 + 3.86 +// access flags 0x9 3.87 + public static am3(Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; 3.88 + L0 3.89 + LINENUMBER 12 L0 3.90 + ALOAD 0 3.91 + INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [ 3.92 + // handle kind 0x6 : INVOKESTATIC 3.93 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.94 + // arguments: 3.95 + 0 3.96 + ] 3.97 + ASTORE 8 3.98 + L1 3.99 + LINENUMBER 13 L1 3.100 + ALOAD 3 3.101 + INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [ 3.102 + // handle kind 0x6 : INVOKESTATIC 3.103 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.104 + // arguments: 3.105 + 0 3.106 + ] 3.107 + ASTORE 9 3.108 + L2 3.109 + LINENUMBER 14 L2 3.110 + ALOAD 2 3.111 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I 3.112 + SIPUSH 16383 3.113 + IAND 3.114 + ISTORE 10 3.115 + ALOAD 2 3.116 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I 3.117 + BIPUSH 14 3.118 + ISHR 3.119 + ISTORE 11 3.120 + L3 3.121 + LINENUMBER 15 L3 3.122 + GOTO L4 3.123 + L5 3.124 + LINENUMBER 16 L5 3.125 + FRAME FULL [java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Double T java/lang/Object java/lang/Object I I] [] 3.126 + ALOAD 8 3.127 + ALOAD 1 3.128 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;Ljava/lang/Object;)I [ 3.129 + // handle kind 0x6 : INVOKESTATIC 3.130 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.131 + // arguments: 3.132 + 0 3.133 + ] 3.134 + SIPUSH 16383 3.135 + IAND 3.136 + INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer; 3.137 + ASTORE 12 3.138 + L6 3.139 + LINENUMBER 17 L6 3.140 + ALOAD 8 3.141 + ALOAD 1 3.142 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D 3.143 + DUP2 3.144 + DCONST_1 3.145 + DADD 3.146 + INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double; 3.147 + ASTORE 1 3.148 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;D)I [ 3.149 + // handle kind 0x6 : INVOKESTATIC 3.150 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.151 + // arguments: 3.152 + 0 3.153 + ] 3.154 + BIPUSH 14 3.155 + ISHR 3.156 + ISTORE 13 3.157 + L7 3.158 + LINENUMBER 18 L7 3.159 + ILOAD 11 3.160 + I2D 3.161 + ALOAD 12 3.162 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D 3.163 + DMUL 3.164 + ILOAD 13 3.165 + I2D 3.166 + ILOAD 10 3.167 + I2D 3.168 + DMUL 3.169 + DADD 3.170 + DSTORE 14 3.171 + L8 3.172 + LINENUMBER 19 L8 3.173 + ILOAD 10 3.174 + I2D 3.175 + ALOAD 12 3.176 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D 3.177 + DMUL 3.178 + DLOAD 14 3.179 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (D)I 3.180 + SIPUSH 16383 3.181 + IAND 3.182 + BIPUSH 14 3.183 + ISHL 3.184 + I2D 3.185 + DADD 3.186 + ALOAD 9 3.187 + ALOAD 4 3.188 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; [ 3.189 + // handle kind 0x6 : INVOKESTATIC 3.190 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.191 + // arguments: 3.192 + 0 3.193 + ] 3.194 + INVOKEDYNAMIC ADD:ODO_D(DLjava/lang/Object;)Ljava/lang/Object; [ 3.195 + // handle kind 0x6 : INVOKESTATIC 3.196 + jdk/nashorn/internal/runtime/linker/Bootstrap.runtimeBootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;) 3.197 + // arguments: none 3.198 + ] 3.199 + ALOAD 5 3.200 + INVOKEDYNAMIC ADD:OOO_I(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; [ 3.201 + // handle kind 0x6 : INVOKESTATIC 3.202 + jdk/nashorn/internal/runtime/linker/Bootstrap.runtimeBootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;) 3.203 + // arguments: none 3.204 + ] 3.205 + ASTORE 12 3.206 + L9 3.207 + LINENUMBER 20 L9 3.208 + ALOAD 12 3.209 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I 3.210 + BIPUSH 28 3.211 + ISHR 3.212 + I2D 3.213 + DLOAD 14 3.214 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (D)I 3.215 + BIPUSH 14 3.216 + ISHR 3.217 + I2D 3.218 + DADD 3.219 + ILOAD 11 3.220 + I2D 3.221 + ILOAD 13 3.222 + I2D 3.223 + DMUL 3.224 + DADD 3.225 + INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double; 3.226 + ASTORE 5 3.227 + L10 3.228 + LINENUMBER 21 L10 3.229 + ALOAD 9 3.230 + ALOAD 4 3.231 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D 3.232 + DUP2 3.233 + DCONST_1 3.234 + DADD 3.235 + INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double; 3.236 + ASTORE 4 3.237 + ALOAD 12 3.238 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I 3.239 + LDC 268435455 3.240 + IAND 3.241 + INVOKEDYNAMIC dyn:setElem|setProp(Ljava/lang/Object;DI)V [ 3.242 + // handle kind 0x6 : INVOKESTATIC 3.243 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.244 + // arguments: 3.245 + 0 3.246 + ] 3.247 + L4 3.248 + FRAME FULL [java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Object java/lang/Object T java/lang/Object java/lang/Object I I] [] 3.249 + ALOAD 6 3.250 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D 3.251 + LDC -1.0 3.252 + DADD 3.253 + DUP2 3.254 + INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double; 3.255 + ASTORE 6 3.256 + DCONST_0 3.257 + DCMPL 3.258 + IFGE L5 3.259 + L11 3.260 + LINENUMBER 24 L11 3.261 + ALOAD 5 3.262 + ARETURN 3.263 + 3.264 +"Optimistic" bytecode that requires invalidation on e.g overflow. Factor 3.265 +x2-3 speedup: 3.266 + 3.267 +public static am3(Ljava/lang/Object;IILjava/lang/Object;III)I 3.268 + L0 3.269 + LINENUMBER 12 L0 3.270 + ALOAD 0 3.271 + INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [ 3.272 + // handle kind 0x6 : INVOKESTATIC 3.273 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.274 + // arguments: 3.275 + 0 3.276 + ] 3.277 + ASTORE 8 3.278 + L1 3.279 + LINENUMBER 13 L1 3.280 + ALOAD 3 3.281 + INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [ 3.282 + // handle kind 0x6 : INVOKESTATIC 3.283 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.284 + // arguments: 3.285 + 0 3.286 + ] 3.287 + ASTORE 9 3.288 + L2 3.289 + LINENUMBER 14 L2 3.290 + ILOAD 2 3.291 + SIPUSH 16383 3.292 + IAND 3.293 + ISTORE 10 3.294 + ILOAD 2 3.295 + BIPUSH 14 3.296 + ISHR 3.297 + ISTORE 11 3.298 + L3 3.299 + LINENUMBER 15 L3 3.300 + GOTO L4 3.301 + L5 3.302 + LINENUMBER 16 L5 3.303 + FRAME FULL [java/lang/Object I I java/lang/Object I I I T java/lang/Object java/lang/Object I I] [] 3.304 + ALOAD 8 3.305 + ILOAD 1 3.306 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [ 3.307 + // handle kind 0x6 : INVOKESTATIC 3.308 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.309 + // arguments: 3.310 + 0 3.311 + ] 3.312 + SIPUSH 16383 3.313 + IAND 3.314 + ISTORE 12 3.315 + L6 3.316 + LINENUMBER 17 L6 3.317 + ALOAD 8 3.318 + ILOAD 1 3.319 + DUP 3.320 + ICONST_1 3.321 + IADD 3.322 + ISTORE 1 3.323 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [ 3.324 + // handle kind 0x6 : INVOKESTATIC 3.325 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.326 + // arguments: 3.327 + 0 3.328 + ] 3.329 + BIPUSH 14 3.330 + ISHR 3.331 + ISTORE 13 3.332 + L7 3.333 + LINENUMBER 18 L7 3.334 + ILOAD 11 3.335 + ILOAD 12 3.336 + BIPUSH 8 3.337 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I 3.338 + ILOAD 13 3.339 + ILOAD 10 3.340 + BIPUSH 9 3.341 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I 3.342 + IADD 3.343 + ISTORE 14 3.344 + L8 3.345 + LINENUMBER 19 L8 3.346 + ILOAD 10 3.347 + ILOAD 12 3.348 + BIPUSH 11 3.349 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I 3.350 + ILOAD 14 3.351 + SIPUSH 16383 3.352 + IAND 3.353 + BIPUSH 14 3.354 + ISHL 3.355 + IADD 3.356 + ALOAD 9 3.357 + ILOAD 4 3.358 + INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [ 3.359 + // handle kind 0x6 : INVOKESTATIC 3.360 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.361 + // arguments: 3.362 + 0 3.363 + ] 3.364 + IADD 3.365 + ILOAD 5 3.366 + IADD 3.367 + ISTORE 12 3.368 + L9 3.369 + LINENUMBER 20 L9 3.370 + ILOAD 12 3.371 + BIPUSH 28 3.372 + ISHR 3.373 + ILOAD 14 3.374 + BIPUSH 14 3.375 + ISHR 3.376 + IADD 3.377 + ILOAD 11 3.378 + ILOAD 13 3.379 + BIPUSH 21 3.380 + INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I 3.381 + IADD 3.382 + ISTORE 5 3.383 + L10 3.384 + LINENUMBER 21 L10 3.385 + ALOAD 9 3.386 + ILOAD 4 3.387 + DUP 3.388 + ICONST_1 3.389 + IADD 3.390 + ISTORE 4 3.391 + ILOAD 12 3.392 + LDC 268435455 3.393 + IAND 3.394 + INVOKEDYNAMIC dyn:setElem|setProp(Ljava/lang/Object;II)V [ 3.395 + // handle kind 0x6 : INVOKESTATIC 3.396 + jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;) 3.397 + // arguments: 3.398 + 0 3.399 + ] 3.400 + L4 3.401 + FRAME SAME 3.402 + ILOAD 6 3.403 + ICONST_M1 3.404 + IADD 3.405 + DUP 3.406 + ISTORE 6 3.407 + ICONST_0 3.408 + IF_ICMPGE L5 3.409 + L11 3.410 + LINENUMBER 24 L11 3.411 + ILOAD 5 3.412 + IRETURN 3.413 3.414 3.415 SYSTEM PROPERTY: -Dnashorn.codegen.debug, -Dnashorn.codegen.debug.trace=<x> 3.416 @@ -167,7 +541,7 @@ 3.417 of byte code (try it e.g. on all the variants of am3 in the Octane 3.418 benchmark crypto.js). Thus, this needs to be lazy 3.419 3.420 -3) Possibly optimistic callsite writes, something on the form 3.421 +3) Optimistic callsite writes, something on the form 3.422 3.423 x = y; //x is a field known to be a primitive. y is only an object as 3.424 far as we can tell 3.425 @@ -189,6 +563,12 @@ 3.426 We still have to deal with objects vs primitives for local bytecode 3.427 slots, possibly through code copying and versioning. 3.428 3.429 +The Future: 3.430 + 3.431 +We expect the usefulness of dual fields to increase significantly 3.432 +after the optimistic type system described in the section on 3.433 +integer arithmetic above is implemented. 3.434 + 3.435 3.436 SYSTEM PROPERTY: -Dnashorn.compiler.symbol.trace=[<x>[,*]], 3.437 -Dnashorn.compiler.symbol.stacktrace=[<x>[,*]] 3.438 @@ -211,7 +591,7 @@ 3.439 semantics. 3.440 3.441 3.442 -SYSTEM PROPERTY: nashorn.lexer.xmlliterals 3.443 +SYSTEM PROPERTY: -Dnashorn.lexer.xmlliterals 3.444 3.445 If this property it set, it means that the Lexer should attempt to 3.446 parse XML literals, which would otherwise generate syntax 3.447 @@ -222,7 +602,7 @@ 3.448 the IR. 3.449 3.450 3.451 -SYSTEM_PROPERTY: nashorn.debug 3.452 +SYSTEM_PROPERTY: -Dnashorn.debug 3.453 3.454 If this property is set to true, Nashorn runs in Debug mode. Debug 3.455 mode is slightly slower, as for example statistics counters are enabled 3.456 @@ -269,8 +649,8 @@ 3.457 object layout being invalidated. 3.458 3.459 3.460 -SYSTEM PROPERTY: nashorn.methodhandles.debug, 3.461 -nashorn.methodhandles.debug=create 3.462 +SYSTEM PROPERTY: -Dnashorn.methodhandles.debug, 3.463 +-Dnashorn.methodhandles.debug=create 3.464 3.465 If this property is enabled, each MethodHandle related call that uses 3.466 the java.lang.invoke package gets its MethodHandle intercepted and an 3.467 @@ -286,7 +666,7 @@ 3.468 rather than at runtime usage. 3.469 3.470 3.471 -SYSTEM PROPERTY: nashorn.methodhandles.debug.stacktrace 3.472 +SYSTEM PROPERTY: -Dnashorn.methodhandles.debug.stacktrace 3.473 3.474 This does the same as nashorn.methodhandles.debug, but when enabled 3.475 also dumps the stack trace for every instrumented method handle 3.476 @@ -297,14 +677,13 @@ 3.477 description of this option 3.478 3.479 3.480 -SYSTEM PROPERTY: nashorn.scriptfunction.specialization.disable 3.481 +SYSTEM PROPERTY: -Dnashorn.scriptfunction.specialization.disable 3.482 3.483 There are several "fast path" implementations of constructors and 3.484 functions in the NativeObject classes that, in their original form, 3.485 take a variable amount of arguments. Said functions are also declared 3.486 to take Object parameters in their original form, as this is what the 3.487 JavaScript specification mandates. 3.488 - 3.489 However, we often know quite a lot more at a callsite of one of these 3.490 functions. For example, Math.min is called with a fixed number (2) of 3.491 integer arguments. The overhead of boxing these ints to Objects and 3.492 @@ -331,7 +710,7 @@ 3.493 just call the generic one. 3.494 3.495 3.496 -SYSTEM PROPERTY: nashorn.tcs.miss.samplePercent=<x> 3.497 +SYSTEM PROPERTY: -Dnashorn.tcs.miss.samplePercent=<x> 3.498 3.499 When running with the trace callsite option (-tcs), Nashorn will count 3.500 and instrument any callsite misses that require relinking. As the 3.501 @@ -341,7 +720,7 @@ 3.502 default value. 3.503 3.504 3.505 -SYSTEM_PROPERTY: nashorn.profilefile=<filename> 3.506 +SYSTEM_PROPERTY: -Dnashorn.profilefile=<filename> 3.507 3.508 When running with the profile callsite options (-pcs), Nashorn will 3.509 dump profiling data for all callsites to stderr as a shutdown hook. To 3.510 @@ -349,15 +728,35 @@ 3.511 this system property. 3.512 3.513 3.514 -SYSTEM_PROPERTY: nashorn.regexp.impl=[jdk|joni] 3.515 +SYSTEM_PROPERTY: -Dnashorn.regexp.impl=[jdk|joni] 3.516 3.517 This property defines the regular expression engine to be used by 3.518 -Nashorn. The default implementation is "jdk" which is based on the 3.519 +Nashorn. Set this flag to "jdk" to get an implementation based on the 3.520 JDK's java.util.regex package. Set this property to "joni" to install 3.521 an implementation based on Joni, the regular expression engine used by 3.522 -the JRuby project. 3.523 +the JRuby project. The default value for this flag is "joni" 3.524 3.525 3.526 +SYSTEM PROPERTY: -Dnashorn.time 3.527 + 3.528 +This enables timers for various phases of script compilation. The timers 3.529 +will be dumped when the Nashorn process exits. We see a percentage value 3.530 +of how much time was spent not executing bytecode (i.e. compilation and 3.531 +internal tasks) at the end of the report. 3.532 + 3.533 +Here is an example: 3.534 + 3.535 +[JavaScript Parsing] 61 ms 3.536 +[Constant Folding] 11 ms 3.537 +[Control Flow Lowering] 26 ms 3.538 +[Type Attribution] 81 ms 3.539 +[Range Analysis] 0 ms 3.540 +[Code Splitting] 29 ms 3.541 +[Type Finalization] 19 ms 3.542 +[Bytecode Generation] 189 ms 3.543 +[Code Installation] 7 ms 3.544 +Total runtime: 508 ms (Non-runtime: 423 ms [83%]) 3.545 + 3.546 =============== 3.547 2. The loggers. 3.548 =============== 3.549 @@ -442,6 +841,9 @@ 3.550 The --log=codegen option is equivalent to setting the system variable 3.551 "nashorn.codegen.debug" to true. 3.552 3.553 +* fold 3.554 + 3.555 +Shows constant folding taking place before lowering 3.556 3.557 * lower 3.558 3.559 @@ -484,3 +886,160 @@ 3.560 etc. It will also show the internal representation of respective field 3.561 (Object in the normal case, unless running with the dual field 3.562 representation) 3.563 + 3.564 + 3.565 +======================= 3.566 +3. Undocumented options 3.567 +======================= 3.568 + 3.569 +Here follows a short description of undocumented options for Nashorn. 3.570 +To see a list of all undocumented options, use the (undocumented) flag 3.571 +"-xhelp". 3.572 + 3.573 +i.e. jjs -xhelp or java -jar nashorn.jar -xhelp 3.574 + 3.575 +Undocumented options are not guaranteed to work, run correctly or be 3.576 +bug free. They are experimental and for internal or debugging use. 3.577 +They are also subject to change without notice. 3.578 + 3.579 +In practice, though, all options below not explicitly documented as 3.580 +EXPERIMENTAL can be relied upon, for example --dump-on-error is useful 3.581 +for any JavaScript/Nashorn developer, but there is no guarantee. 3.582 + 3.583 +A short summary follows: 3.584 + 3.585 + -D (-Dname=value. Set a system property. This option can be repeated.) 3.586 + 3.587 + -ccs, --class-cache-size (Size of the Class cache size per global scope.) 3.588 + 3.589 + -cp, -classpath (-cp path. Specify where to find user class files.) 3.590 + 3.591 + -co, --compile-only (Compile script without running. Exit after compilation) 3.592 + param: [true|false] default: false 3.593 + 3.594 + -d, --dump-debug-dir (specify a destination directory to dump class files. 3.595 + This must be combined with the --compile-only option to work) 3.596 + param: <path> 3.597 + 3.598 + --debug-lines (Generate line number table in .class files.) 3.599 + param: [true|false] default: true 3.600 + 3.601 + --debug-locals (Generate local variable table in .class files.) 3.602 + param: [true|false] default: false 3.603 + 3.604 + -doe, -dump-on-error (Dump a stack trace on errors.) 3.605 + param: [true|false] default: false 3.606 + 3.607 + --early-lvalue-error (invalid lvalue expressions should be reported as early errors.) 3.608 + param: [true|false] default: true 3.609 + 3.610 + --empty-statements (Preserve empty statements in AST.) 3.611 + param: [true|false] default: false 3.612 + 3.613 + -fv, -fullversion (Print full version info of Nashorn.) 3.614 + param: [true|false] default: false 3.615 + 3.616 + --function-statement-error (Report an error when function declaration is used as a statement.) 3.617 + param: [true|false] default: false 3.618 + 3.619 + --function-statement-warning (Warn when function declaration is used as a statement.) 3.620 + param: [true|false] default: false 3.621 + 3.622 + -fx (Launch script as an fx application.) 3.623 + param: [true|false] default: false 3.624 + 3.625 + --global-per-engine (Use single Global instance per script engine instance.) 3.626 + param: [true|false] default: false 3.627 + 3.628 + -h, -help (Print help for command line flags.) 3.629 + param: [true|false] default: false 3.630 + 3.631 + --lazy-compilation (EXPERIMENTAL: Use lazy code generation strategies - do not compile 3.632 + the entire script at once.) 3.633 + param: [true|false] default: false 3.634 + 3.635 + --loader-per-compile (Create a new class loader per compile.) 3.636 + param: [true|false] default: true 3.637 + 3.638 + -l, --locale (Set Locale for script execution.) 3.639 + param: <locale> default: en-US 3.640 + 3.641 + --log (Enable logging of a given level for a given number of sub systems. 3.642 + [for example: --log=fields:finest,codegen:info]) 3.643 + param: <module:level>,* 3.644 + 3.645 + -nj, --no-java (No Java support) 3.646 + param: [true|false] default: false 3.647 + 3.648 + -nse, --no-syntax-extensions (No non-standard syntax extensions) 3.649 + param: [true|false] default: false 3.650 + 3.651 + -nta, --no-typed-arrays (No Typed arrays support) 3.652 + param: [true|false] default: false 3.653 + 3.654 + --parse-only (Parse without compiling.) 3.655 + param: [true|false] default: false 3.656 + 3.657 + --print-ast (Print abstract syntax tree.) 3.658 + param: [true|false] default: false 3.659 + 3.660 + --print-code (Print bytecode.) 3.661 + param: [true|false] default: false 3.662 + 3.663 + --print-lower-ast (Print lowered abstract syntax tree.) 3.664 + param: [true|false] default: false 3.665 + 3.666 + --print-lower-parse (Print the parse tree after lowering.) 3.667 + param: [true|false] default: false 3.668 + 3.669 + --print-mem-usage (Print memory usage of IR after each compile stage.) 3.670 + param: [true|false] default: false 3.671 + 3.672 + --print-no-newline (Print function will not print new line char.) 3.673 + param: [true|false] default: false 3.674 + 3.675 + --print-parse (Print the parse tree.) 3.676 + param: [true|false] default: false 3.677 + 3.678 + --print-symbols (Print the symbol table.) 3.679 + param: [true|false] default: false 3.680 + 3.681 + -pcs, --profile-callsites (Dump callsite profile data.) 3.682 + param: [true|false] default: false 3.683 + 3.684 + --range-analysis (EXPERIMENTAL: Do range analysis using known compile time types, 3.685 + and try to narrow number types) 3.686 + param: [true|false] default: false 3.687 + 3.688 + -scripting (Enable scripting features.) 3.689 + param: [true|false] default: false 3.690 + 3.691 + --specialize-calls (EXPERIMENTAL: Specialize all or a set of method according 3.692 + to callsite parameter types) 3.693 + param: [=function_1,...,function_n] 3.694 + 3.695 + --stderr (Redirect stderr to a filename or to another tty, e.g. stdout) 3.696 + param: <output console> 3.697 + 3.698 + --stdout (Redirect stdout to a filename or to another tty, e.g. stderr) 3.699 + param: <output console> 3.700 + 3.701 + -strict (Run scripts in strict mode.) 3.702 + param: [true|false] default: false 3.703 + 3.704 + -t, -timezone (Set timezone for script execution.) 3.705 + param: <timezone> default: Europe/Stockholm 3.706 + 3.707 + -tcs, --trace-callsites (Enable callsite trace mode. Options are: miss [trace callsite misses] 3.708 + enterexit [trace callsite enter/exit], objects [print object properties]) 3.709 + param: [=[option,]*] 3.710 + 3.711 + --verify-code (Verify byte code before running.) 3.712 + param: [true|false] default: false 3.713 + 3.714 + -v, -version (Print version info of Nashorn.) 3.715 + param: [true|false] default: false 3.716 + 3.717 + -xhelp (Print extended help for command line flags.) 3.718 + param: [true|false] default: false 3.719 +
4.1 --- a/src/jdk/internal/dynalink/ChainedCallSite.java Mon Aug 26 14:54:25 2013 -0700 4.2 +++ b/src/jdk/internal/dynalink/ChainedCallSite.java Tue Aug 27 19:26:48 2013 +0530 4.3 @@ -121,7 +121,6 @@ 4.4 * to change the value. If your override returns a value less than 1, the code will break. 4.5 * @return the maximum number of method handles in the chain. 4.6 */ 4.7 - @SuppressWarnings("static-method") 4.8 protected int getMaxChainLength() { 4.9 return 8; 4.10 }
5.1 --- a/src/jdk/internal/dynalink/DefaultBootstrapper.java Mon Aug 26 14:54:25 2013 -0700 5.2 +++ b/src/jdk/internal/dynalink/DefaultBootstrapper.java Tue Aug 27 19:26:48 2013 +0530 5.3 @@ -133,7 +133,7 @@ 5.4 * @param type the method signature at the call site 5.5 * @return a new {@link MonomorphicCallSite} linked with the default dynamic linker. 5.6 */ 5.7 - public static CallSite publicBootstrap(@SuppressWarnings("unused") MethodHandles.Lookup caller, String name, MethodType type) { 5.8 + public static CallSite publicBootstrap(MethodHandles.Lookup caller, String name, MethodType type) { 5.9 return bootstrapInternal(MethodHandles.publicLookup(), name, type); 5.10 } 5.11
6.1 --- a/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Mon Aug 26 14:54:25 2013 -0700 6.2 +++ b/src/jdk/internal/dynalink/beans/AbstractJavaLinker.java Tue Aug 27 19:26:48 2013 +0530 6.3 @@ -97,6 +97,7 @@ 6.4 import java.util.HashMap; 6.5 import java.util.List; 6.6 import java.util.Map; 6.7 + 6.8 import jdk.internal.dynalink.CallSiteDescriptor; 6.9 import jdk.internal.dynalink.beans.GuardedInvocationComponent.ValidationType; 6.10 import jdk.internal.dynalink.linker.GuardedInvocation;
7.1 --- a/src/jdk/internal/dynalink/beans/OverloadedDynamicMethod.java Mon Aug 26 14:54:25 2013 -0700 7.2 +++ b/src/jdk/internal/dynalink/beans/OverloadedDynamicMethod.java Tue Aug 27 19:26:48 2013 +0530 7.3 @@ -148,6 +148,7 @@ 7.4 } 7.5 } 7.6 7.7 + @SuppressWarnings("fallthrough") 7.8 @Override 7.9 public MethodHandle getInvocation(final CallSiteDescriptor callSiteDescriptor, final LinkerServices linkerServices) { 7.10 final MethodType callSiteType = callSiteDescriptor.getMethodType();
8.1 --- a/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Mon Aug 26 14:54:25 2013 -0700 8.2 +++ b/src/jdk/nashorn/api/scripting/NashornScriptEngine.java Tue Aug 27 19:26:48 2013 +0530 8.3 @@ -124,6 +124,7 @@ 8.4 } 8.5 8.6 // load engine.js and return content as a char[] 8.7 + @SuppressWarnings("resource") 8.8 private static char[] loadEngineJSSource() { 8.9 final String script = "resources/engine.js"; 8.10 try { 8.11 @@ -212,9 +213,8 @@ 8.12 // just create normal SimpleBindings. 8.13 // We use same 'global' for all Bindings. 8.14 return new SimpleBindings(); 8.15 - } else { 8.16 - return createGlobalMirror(null); 8.17 } 8.18 + return createGlobalMirror(null); 8.19 } 8.20 8.21 // Compilable methods
9.1 --- a/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Mon Aug 26 14:54:25 2013 -0700 9.2 +++ b/src/jdk/nashorn/api/scripting/ScriptObjectMirror.java Tue Aug 27 19:26:48 2013 +0530 9.3 @@ -391,6 +391,15 @@ 9.4 } 9.5 9.6 /** 9.7 + * ECMA [[Class]] property 9.8 + * 9.9 + * @return ECMA [[Class]] property value of this object 9.10 + */ 9.11 + public String getClassName() { 9.12 + return sobj.getClassName(); 9.13 + } 9.14 + 9.15 + /** 9.16 * ECMA 8.12.1 [[GetOwnProperty]] (P) 9.17 * 9.18 * @param key property key
10.1 --- a/src/jdk/nashorn/internal/codegen/CompilationPhase.java Mon Aug 26 14:54:25 2013 -0700 10.2 +++ b/src/jdk/nashorn/internal/codegen/CompilationPhase.java Tue Aug 27 19:26:48 2013 +0530 10.3 @@ -414,30 +414,34 @@ 10.4 compiler.getCodeInstaller().verify(bytecode); 10.5 } 10.6 10.7 - // should code be dumped to disk - only valid in compile_only 10.8 - // mode? 10.9 + // should code be dumped to disk - only valid in compile_only mode? 10.10 if (env._dest_dir != null && env._compile_only) { 10.11 final String fileName = className.replace('.', File.separatorChar) + ".class"; 10.12 - final int index = fileName.lastIndexOf(File.separatorChar); 10.13 + final int index = fileName.lastIndexOf(File.separatorChar); 10.14 10.15 + final File dir; 10.16 if (index != -1) { 10.17 - final File dir = new File(fileName.substring(0, index)); 10.18 - try { 10.19 - if (!dir.exists() && !dir.mkdirs()) { 10.20 - throw new IOException(dir.toString()); 10.21 - } 10.22 - final File file = new File(env._dest_dir, fileName); 10.23 - try (final FileOutputStream fos = new FileOutputStream(file)) { 10.24 - fos.write(bytecode); 10.25 - } 10.26 - } catch (final IOException e) { 10.27 - Compiler.LOG.warning("Skipping class dump for ", 10.28 - className, 10.29 - ": ", 10.30 - ECMAErrors.getMessage( 10.31 - "io.error.cant.write", 10.32 - dir.toString())); 10.33 + dir = new File(env._dest_dir, fileName.substring(0, index)); 10.34 + } else { 10.35 + dir = new File(env._dest_dir); 10.36 + } 10.37 + 10.38 + try { 10.39 + if (!dir.exists() && !dir.mkdirs()) { 10.40 + throw new IOException(dir.toString()); 10.41 } 10.42 + final File file = new File(env._dest_dir, fileName); 10.43 + try (final FileOutputStream fos = new FileOutputStream(file)) { 10.44 + fos.write(bytecode); 10.45 + } 10.46 + Compiler.LOG.info("Wrote class to '" + file.getAbsolutePath() + '\''); 10.47 + } catch (final IOException e) { 10.48 + Compiler.LOG.warning("Skipping class dump for ", 10.49 + className, 10.50 + ": ", 10.51 + ECMAErrors.getMessage( 10.52 + "io.error.cant.write", 10.53 + dir.toString())); 10.54 } 10.55 } 10.56 }
11.1 --- a/src/jdk/nashorn/internal/objects/NativeArray.java Mon Aug 26 14:54:25 2013 -0700 11.2 +++ b/src/jdk/nashorn/internal/objects/NativeArray.java Tue Aug 27 19:26:48 2013 +0530 11.3 @@ -40,6 +40,7 @@ 11.4 import java.util.Iterator; 11.5 import java.util.List; 11.6 import java.util.concurrent.Callable; 11.7 + 11.8 import jdk.nashorn.api.scripting.ScriptObjectMirror; 11.9 import jdk.nashorn.internal.objects.annotations.Attribute; 11.10 import jdk.nashorn.internal.objects.annotations.Constructor; 11.11 @@ -632,6 +633,7 @@ 11.12 return new NativeArray(list.toArray()); 11.13 } 11.14 11.15 + @SuppressWarnings("null") 11.16 private static void concatToList(final ArrayList<Object> list, final Object obj) { 11.17 final boolean isScriptArray = isArray(obj); 11.18 final boolean isScriptObject = isScriptArray || obj instanceof ScriptObject;
12.1 --- a/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Mon Aug 26 14:54:25 2013 -0700 12.2 +++ b/src/jdk/nashorn/internal/objects/NativeArrayBuffer.java Tue Aug 27 19:26:48 2013 +0530 12.3 @@ -73,6 +73,11 @@ 12.4 this(Arrays.copyOfRange(other.buffer, begin, end)); 12.5 } 12.6 12.7 + @Override 12.8 + public String getClassName() { 12.9 + return "ArrayBuffer"; 12.10 + } 12.11 + 12.12 @Getter(attributes = Attribute.NOT_ENUMERABLE | Attribute.NOT_WRITABLE | Attribute.NOT_CONFIGURABLE) 12.13 public static Object byteLength(final Object self) { 12.14 return ((NativeArrayBuffer)self).buffer.length;
13.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Mon Aug 26 14:54:25 2013 -0700 13.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat32Array.java Tue Aug 27 19:26:48 2013 +0530 13.3 @@ -145,6 +145,11 @@ 13.4 } 13.5 13.6 @Override 13.7 + public String getClassName() { 13.8 + return "Float32Array"; 13.9 + } 13.10 + 13.11 + @Override 13.12 protected Factory factory() { 13.13 return FACTORY; 13.14 }
14.1 --- a/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Mon Aug 26 14:54:25 2013 -0700 14.2 +++ b/src/jdk/nashorn/internal/objects/NativeFloat64Array.java Tue Aug 27 19:26:48 2013 +0530 14.3 @@ -155,6 +155,11 @@ 14.4 } 14.5 14.6 @Override 14.7 + public String getClassName() { 14.8 + return "Float64Array"; 14.9 + } 14.10 + 14.11 + @Override 14.12 protected Factory factory() { 14.13 return FACTORY; 14.14 }
15.1 --- a/src/jdk/nashorn/internal/objects/NativeInt16Array.java Mon Aug 26 14:54:25 2013 -0700 15.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt16Array.java Tue Aug 27 19:26:48 2013 +0530 15.3 @@ -109,6 +109,11 @@ 15.4 } 15.5 15.6 @Override 15.7 + public String getClassName() { 15.8 + return "Int16Array"; 15.9 + } 15.10 + 15.11 + @Override 15.12 protected Factory factory() { 15.13 return FACTORY; 15.14 }
16.1 --- a/src/jdk/nashorn/internal/objects/NativeInt32Array.java Mon Aug 26 14:54:25 2013 -0700 16.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt32Array.java Tue Aug 27 19:26:48 2013 +0530 16.3 @@ -112,6 +112,11 @@ 16.4 } 16.5 16.6 @Override 16.7 + public String getClassName() { 16.8 + return "Int32Array"; 16.9 + } 16.10 + 16.11 + @Override 16.12 protected Factory factory() { 16.13 return FACTORY; 16.14 }
17.1 --- a/src/jdk/nashorn/internal/objects/NativeInt8Array.java Mon Aug 26 14:54:25 2013 -0700 17.2 +++ b/src/jdk/nashorn/internal/objects/NativeInt8Array.java Tue Aug 27 19:26:48 2013 +0530 17.3 @@ -102,6 +102,11 @@ 17.4 } 17.5 17.6 @Override 17.7 + public String getClassName() { 17.8 + return "Int8Array"; 17.9 + } 17.10 + 17.11 + @Override 17.12 protected Factory factory() { 17.13 return FACTORY; 17.14 }
18.1 --- a/src/jdk/nashorn/internal/objects/NativeObject.java Mon Aug 26 14:54:25 2013 -0700 18.2 +++ b/src/jdk/nashorn/internal/objects/NativeObject.java Tue Aug 27 19:26:48 2013 +0530 18.3 @@ -669,15 +669,43 @@ 18.4 18.5 final List<AccessorProperty> properties = new ArrayList<>(propertyNames.size() + methodNames.size()); 18.6 for(final String methodName: methodNames) { 18.7 - properties.add(AccessorProperty.create(methodName, Property.NOT_WRITABLE, 18.8 - getBoundBeanMethodGetter(source, getBeanOperation(linker, "dyn:getMethod:" + methodName, getterType, source)), 18.9 - null)); 18.10 + final MethodHandle method; 18.11 + try { 18.12 + method = getBeanOperation(linker, "dyn:getMethod:" + methodName, getterType, source); 18.13 + } catch(final IllegalAccessError e) { 18.14 + // Presumably, this was a caller sensitive method. Ignore it and carry on. 18.15 + continue; 18.16 + } 18.17 + properties.add(AccessorProperty.create(methodName, Property.NOT_WRITABLE, getBoundBeanMethodGetter(source, 18.18 + method), null)); 18.19 } 18.20 for(final String propertyName: propertyNames) { 18.21 + MethodHandle getter; 18.22 + if(readablePropertyNames.contains(propertyName)) { 18.23 + try { 18.24 + getter = getBeanOperation(linker, "dyn:getProp:" + propertyName, getterType, source); 18.25 + } catch(final IllegalAccessError e) { 18.26 + // Presumably, this was a caller sensitive method. Ignore it and carry on. 18.27 + getter = Lookup.EMPTY_GETTER; 18.28 + } 18.29 + } else { 18.30 + getter = Lookup.EMPTY_GETTER; 18.31 + } 18.32 final boolean isWritable = writablePropertyNames.contains(propertyName); 18.33 - properties.add(AccessorProperty.create(propertyName, isWritable ? 0 : Property.NOT_WRITABLE, 18.34 - readablePropertyNames.contains(propertyName) ? getBeanOperation(linker, "dyn:getProp:" + propertyName, getterType, source) : Lookup.EMPTY_GETTER, 18.35 - isWritable ? getBeanOperation(linker, "dyn:setProp:" + propertyName, setterType, source) : Lookup.EMPTY_SETTER)); 18.36 + MethodHandle setter; 18.37 + if(isWritable) { 18.38 + try { 18.39 + setter = getBeanOperation(linker, "dyn:setProp:" + propertyName, setterType, source); 18.40 + } catch(final IllegalAccessError e) { 18.41 + // Presumably, this was a caller sensitive method. Ignore it and carry on. 18.42 + setter = Lookup.EMPTY_SETTER; 18.43 + } 18.44 + } else { 18.45 + setter = Lookup.EMPTY_SETTER; 18.46 + } 18.47 + if(getter != Lookup.EMPTY_GETTER || setter != Lookup.EMPTY_SETTER) { 18.48 + properties.add(AccessorProperty.create(propertyName, isWritable ? 0 : Property.NOT_WRITABLE, getter, setter)); 18.49 + } 18.50 } 18.51 18.52 targetObj.addBoundProperties(source, properties.toArray(new AccessorProperty[properties.size()]));
19.1 --- a/src/jdk/nashorn/internal/objects/NativeRegExp.java Mon Aug 26 14:54:25 2013 -0700 19.2 +++ b/src/jdk/nashorn/internal/objects/NativeRegExp.java Tue Aug 27 19:26:48 2013 +0530 19.3 @@ -65,10 +65,9 @@ 19.4 private RegExp regexp; 19.5 19.6 // Reference to global object needed to support static RegExp properties 19.7 - private Global globalObject; 19.8 + private final Global globalObject; 19.9 19.10 // initialized by nasgen 19.11 - @SuppressWarnings("unused") 19.12 private static PropertyMap $nasgenmap$; 19.13 19.14 static PropertyMap getInitialMap() {
20.1 --- a/src/jdk/nashorn/internal/objects/NativeString.java Mon Aug 26 14:54:25 2013 -0700 20.2 +++ b/src/jdk/nashorn/internal/objects/NativeString.java Tue Aug 27 19:26:48 2013 +0530 20.3 @@ -1058,9 +1058,8 @@ 20.4 public static Object trim(final Object self) { 20.5 20.6 final String str = checkObjectToString(self); 20.7 - final int len = str.length(); 20.8 int start = 0; 20.9 - int end = len - 1; 20.10 + int end = str.length() - 1; 20.11 20.12 while (start <= end && ScriptRuntime.isJSWhitespace(str.charAt(start))) { 20.13 start++; 20.14 @@ -1069,7 +1068,45 @@ 20.15 end--; 20.16 } 20.17 20.18 - return start == 0 && end + 1 == len ? str : str.substring(start, end + 1); 20.19 + return str.substring(start, end + 1); 20.20 + } 20.21 + 20.22 + /** 20.23 + * Nashorn extension: String.prototype.trimLeft ( ) 20.24 + * @param self self reference 20.25 + * @return string trimmed left from whitespace 20.26 + */ 20.27 + @Function(attributes = Attribute.NOT_ENUMERABLE) 20.28 + public static Object trimLeft(final Object self) { 20.29 + 20.30 + final String str = checkObjectToString(self); 20.31 + int start = 0; 20.32 + int end = str.length() - 1; 20.33 + 20.34 + while (start <= end && ScriptRuntime.isJSWhitespace(str.charAt(start))) { 20.35 + start++; 20.36 + } 20.37 + 20.38 + return str.substring(start, end + 1); 20.39 + } 20.40 + 20.41 + /** 20.42 + * Nashorn extension: String.prototype.trimRight ( ) 20.43 + * @param self self reference 20.44 + * @return string trimmed right from whitespace 20.45 + */ 20.46 + @Function(attributes = Attribute.NOT_ENUMERABLE) 20.47 + public static Object trimRight(final Object self) { 20.48 + 20.49 + final String str = checkObjectToString(self); 20.50 + int start = 0; 20.51 + int end = str.length() - 1; 20.52 + 20.53 + while (end >= start && ScriptRuntime.isJSWhitespace(str.charAt(end))) { 20.54 + end--; 20.55 + } 20.56 + 20.57 + return str.substring(start, end + 1); 20.58 } 20.59 20.60 private static Object newObj(final Object self, final CharSequence str) {
21.1 --- a/src/jdk/nashorn/internal/objects/NativeUint16Array.java Mon Aug 26 14:54:25 2013 -0700 21.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint16Array.java Tue Aug 27 19:26:48 2013 +0530 21.3 @@ -108,6 +108,11 @@ 21.4 } 21.5 21.6 @Override 21.7 + public String getClassName() { 21.8 + return "Uint16Array"; 21.9 + } 21.10 + 21.11 + @Override 21.12 protected Factory factory() { 21.13 return FACTORY; 21.14 }
22.1 --- a/src/jdk/nashorn/internal/objects/NativeUint32Array.java Mon Aug 26 14:54:25 2013 -0700 22.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint32Array.java Tue Aug 27 19:26:48 2013 +0530 22.3 @@ -127,6 +127,11 @@ 22.4 } 22.5 22.6 @Override 22.7 + public String getClassName() { 22.8 + return "Uint32Array"; 22.9 + } 22.10 + 22.11 + @Override 22.12 protected Factory factory() { 22.13 return FACTORY; 22.14 }
23.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8Array.java Mon Aug 26 14:54:25 2013 -0700 23.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8Array.java Tue Aug 27 19:26:48 2013 +0530 23.3 @@ -101,6 +101,11 @@ 23.4 } 23.5 23.6 @Override 23.7 + public String getClassName() { 23.8 + return "Uint8Array"; 23.9 + } 23.10 + 23.11 + @Override 23.12 protected Factory factory() { 23.13 return FACTORY; 23.14 }
24.1 --- a/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Mon Aug 26 14:54:25 2013 -0700 24.2 +++ b/src/jdk/nashorn/internal/objects/NativeUint8ClampedArray.java Tue Aug 27 19:26:48 2013 +0530 24.3 @@ -118,6 +118,11 @@ 24.4 } 24.5 24.6 @Override 24.7 + public String getClassName() { 24.8 + return "Uint8ClampedArray"; 24.9 + } 24.10 + 24.11 + @Override 24.12 protected Factory factory() { 24.13 return FACTORY; 24.14 }
25.1 --- a/src/jdk/nashorn/internal/parser/TokenType.java Mon Aug 26 14:54:25 2013 -0700 25.2 +++ b/src/jdk/nashorn/internal/parser/TokenType.java Tue Aug 27 19:26:48 2013 +0530 25.3 @@ -284,7 +284,7 @@ 25.4 25.5 @Override 25.6 public String toString() { 25.7 - return name; 25.8 + return getNameOrType(); 25.9 } 25.10 25.11 static {
26.1 --- a/src/jdk/nashorn/internal/runtime/Context.java Mon Aug 26 14:54:25 2013 -0700 26.2 +++ b/src/jdk/nashorn/internal/runtime/Context.java Tue Aug 27 19:26:48 2013 +0530 26.3 @@ -894,7 +894,6 @@ 26.4 return script; 26.5 } 26.6 26.7 - @SuppressWarnings("static-method") 26.8 private ScriptLoader createNewLoader() { 26.9 return AccessController.doPrivileged( 26.10 new PrivilegedAction<ScriptLoader>() {
27.1 --- a/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Mon Aug 26 14:54:25 2013 -0700 27.2 +++ b/src/jdk/nashorn/internal/runtime/DebuggerSupport.java Tue Aug 27 19:26:48 2013 +0530 27.3 @@ -44,6 +44,7 @@ 27.4 * Hook to force the loading of the DebuggerValueDesc class so that it is 27.5 * available to external debuggers. 27.6 */ 27.7 + @SuppressWarnings("unused") 27.8 DebuggerValueDesc forceLoad = new DebuggerValueDesc(null, false, null, null); 27.9 } 27.10 27.11 @@ -78,6 +79,27 @@ 27.12 } 27.13 27.14 /** 27.15 + * Call eval on the current global. 27.16 + * @param scope Scope to use. 27.17 + * @param self Receiver to use. 27.18 + * @param string String to evaluate. 27.19 + * @param returnException true if exceptions are to be returned. 27.20 + * @return Result of eval as string, or, an exception or null depending on returnException. 27.21 + */ 27.22 + static Object eval(final ScriptObject scope, final Object self, final String string, final boolean returnException) { 27.23 + final ScriptObject global = Context.getGlobalTrusted(); 27.24 + final ScriptObject initialScope = scope != null ? scope : global; 27.25 + final Object callThis = self != null ? self : global; 27.26 + final Context context = global.getContext(); 27.27 + 27.28 + try { 27.29 + return context.eval(initialScope, string, callThis, ScriptRuntime.UNDEFINED, false); 27.30 + } catch (Throwable ex) { 27.31 + return returnException ? ex : null; 27.32 + } 27.33 + } 27.34 + 27.35 + /** 27.36 * This method returns a bulk description of an object's properties. 27.37 * @param object Script object to be displayed by the debugger. 27.38 * @param all true if to include non-enumerable values. 27.39 @@ -111,9 +133,8 @@ 27.40 if (value instanceof ScriptObject && !(value instanceof ScriptFunction)) { 27.41 final ScriptObject object = (ScriptObject)value; 27.42 return new DebuggerValueDesc(name, !object.isEmpty(), value, objectAsString(object, all, duplicates)); 27.43 - } else { 27.44 - return new DebuggerValueDesc(name, false, value, valueAsString(value)); 27.45 } 27.46 + return new DebuggerValueDesc(name, false, value, valueAsString(value)); 27.47 } 27.48 27.49 /** 27.50 @@ -135,7 +156,7 @@ 27.51 27.52 for (int i = 0; i < keys.length; i++) { 27.53 final String key = keys[i]; 27.54 - descs[i] = valueInfo(key, object.get(key), true, duplicates); 27.55 + descs[i] = valueInfo(key, object.get(key), all, duplicates); 27.56 } 27.57 27.58 duplicates.remove(object); 27.59 @@ -172,7 +193,7 @@ 27.60 } 27.61 27.62 if (valueAsObject instanceof ScriptObject && !(valueAsObject instanceof ScriptFunction)) { 27.63 - final String objectString = objectAsString((ScriptObject)valueAsObject, true, duplicates); 27.64 + final String objectString = objectAsString((ScriptObject)valueAsObject, all, duplicates); 27.65 sb.append(objectString != null ? objectString : "{...}"); 27.66 } else { 27.67 sb.append(valueAsString(valueAsObject)); 27.68 @@ -199,7 +220,7 @@ 27.69 final String valueAsString = descs[i].valueAsString; 27.70 sb.append(descs[i].key); 27.71 sb.append(": "); 27.72 - sb.append(descs[i].valueAsString); 27.73 + sb.append(valueAsString); 27.74 } 27.75 } 27.76 27.77 @@ -239,9 +260,8 @@ 27.78 case FUNCTION: 27.79 if (value instanceof ScriptFunction) { 27.80 return ((ScriptFunction)value).toSource(); 27.81 - } else { 27.82 - return value.toString(); 27.83 } 27.84 + return value.toString(); 27.85 27.86 default: 27.87 return value.toString();
28.1 --- a/src/jdk/nashorn/internal/runtime/ScriptObject.java Mon Aug 26 14:54:25 2013 -0700 28.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptObject.java Tue Aug 27 19:26:48 2013 +0530 28.3 @@ -52,6 +52,7 @@ 28.4 import java.util.List; 28.5 import java.util.Map; 28.6 import java.util.Set; 28.7 + 28.8 import jdk.internal.dynalink.CallSiteDescriptor; 28.9 import jdk.internal.dynalink.linker.GuardedInvocation; 28.10 import jdk.internal.dynalink.linker.LinkRequest; 28.11 @@ -1149,12 +1150,12 @@ 28.12 28.13 if (newProto == null || newProto instanceof ScriptObject) { 28.14 // check for circularity 28.15 - ScriptObject proto = (ScriptObject)newProto; 28.16 - while (proto != null) { 28.17 - if (proto == this) { 28.18 + ScriptObject p = (ScriptObject)newProto; 28.19 + while (p != null) { 28.20 + if (p == this) { 28.21 throw typeError("circular.__proto__.set", ScriptRuntime.safeToString(this)); 28.22 } 28.23 - proto = proto.getProto(); 28.24 + p = p.getProto(); 28.25 } 28.26 setProto((ScriptObject)newProto); 28.27 } else { 28.28 @@ -2017,6 +2018,7 @@ 28.29 * @param request the link request 28.30 * @return GuardedInvocation to be invoked at call site. 28.31 */ 28.32 + @SuppressWarnings("null") 28.33 public GuardedInvocation noSuchProperty(final CallSiteDescriptor desc, final LinkRequest request) { 28.34 final String name = desc.getNameToken(CallSiteDescriptor.NAME_OPERAND); 28.35 final FindProperty find = findProperty(NO_SUCH_PROPERTY_NAME, true);
29.1 --- a/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Mon Aug 26 14:54:25 2013 -0700 29.2 +++ b/src/jdk/nashorn/internal/runtime/ScriptRuntime.java Tue Aug 27 19:26:48 2013 +0530 29.3 @@ -190,6 +190,8 @@ 29.4 case FUNCTION: 29.5 if (self instanceof ScriptObject) { 29.6 className = ((ScriptObject)self).getClassName(); 29.7 + } else if (self instanceof ScriptObjectMirror) { 29.8 + className = ((ScriptObjectMirror)self).getClassName(); 29.9 } else { 29.10 className = self.getClass().getName(); 29.11 }
30.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Mon Aug 26 14:54:25 2013 -0700 30.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ArrayCompiler.java Tue Aug 27 19:26:48 2013 +0530 30.3 @@ -39,7 +39,6 @@ 30.4 import jdk.nashorn.internal.runtime.regexp.joni.constants.OPCode; 30.5 import jdk.nashorn.internal.runtime.regexp.joni.constants.OPSize; 30.6 import jdk.nashorn.internal.runtime.regexp.joni.constants.TargetInfo; 30.7 -import jdk.nashorn.internal.runtime.regexp.joni.encoding.CharacterType; 30.8 30.9 final class ArrayCompiler extends Compiler { 30.10 private int[] code; 30.11 @@ -345,6 +344,7 @@ 30.12 30.13 private static final int QUANTIFIER_EXPAND_LIMIT_SIZE = 50; // was 50 30.14 30.15 + @SuppressWarnings("unused") 30.16 private static boolean cknOn(int ckn) { 30.17 return ckn > 0; 30.18 } 30.19 @@ -879,6 +879,7 @@ 30.20 } 30.21 } 30.22 30.23 + @SuppressWarnings("unused") 30.24 private void addStateCheckNum(int num) { 30.25 addInt(num); 30.26 } 30.27 @@ -887,6 +888,7 @@ 30.28 addInt(addr); 30.29 } 30.30 30.31 + @SuppressWarnings("unused") 30.32 private void addAbsAddr(int addr) { 30.33 addInt(addr); 30.34 }
31.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Mon Aug 26 14:54:25 2013 -0700 31.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/BitSet.java Tue Aug 27 19:26:48 2013 +0530 31.3 @@ -29,6 +29,7 @@ 31.4 final int[] bits = new int[BITSET_SIZE]; 31.5 31.6 private static final int BITS_TO_STRING_WRAP = 4; 31.7 + @Override 31.8 public String toString() { 31.9 StringBuilder buffer = new StringBuilder(); 31.10 buffer.append("BitSet");
32.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Mon Aug 26 14:54:25 2013 -0700 32.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ByteCodeMachine.java Tue Aug 27 19:26:48 2013 +0530 32.3 @@ -26,7 +26,6 @@ 32.4 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isNotBol; 32.5 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isNotEol; 32.6 import static jdk.nashorn.internal.runtime.regexp.joni.Option.isPosixRegion; 32.7 -import static jdk.nashorn.internal.runtime.regexp.joni.EncodingHelper.isCrnl; 32.8 import static jdk.nashorn.internal.runtime.regexp.joni.EncodingHelper.isNewLine; 32.9 32.10 import jdk.nashorn.internal.runtime.regexp.joni.ast.CClassNode; 32.11 @@ -96,6 +95,7 @@ 32.12 } 32.13 } 32.14 32.15 + @Override 32.16 protected final int matchAt(int range, int sstart, int sprev) { 32.17 this.range = range; 32.18 this.sstart = sstart; 32.19 @@ -499,7 +499,7 @@ 32.20 32.21 private void opAnyChar() { 32.22 if (s >= range) {opFail(); return;} 32.23 - if (chars[s] == EncodingHelper.NEW_LINE) {opFail(); return;} 32.24 + if (isNewLine(chars[s])) {opFail(); return;} 32.25 s++; 32.26 sprev = sbegin; // break; 32.27 } 32.28 @@ -537,7 +537,7 @@ 32.29 while (s < range) { 32.30 char b = chars[s]; 32.31 if (c == b) pushAlt(ip + 1, s, sprev); 32.32 - if (b == EncodingHelper.NEW_LINE) {opFail(); return;} 32.33 + if (isNewLine(b)) {opFail(); return;} 32.34 sprev = s; 32.35 s++; 32.36 } 32.37 @@ -616,7 +616,7 @@ 32.38 if (s == str) { 32.39 if (isNotBol(msaOptions)) opFail(); 32.40 return; 32.41 - } else if (EncodingHelper.isNewLine(chars, sprev, end) && s != end) { 32.42 + } else if (isNewLine(chars, sprev, end) && s != end) { 32.43 return; 32.44 } 32.45 opFail(); 32.46 @@ -625,7 +625,7 @@ 32.47 private void opEndLine() { 32.48 if (s == end) { 32.49 if (Config.USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE) { 32.50 - if (str == end || !EncodingHelper.isNewLine(chars, sprev, end)) { 32.51 + if (str == end || !isNewLine(chars, sprev, end)) { 32.52 if (isNotEol(msaOptions)) opFail(); 32.53 } 32.54 return; 32.55 @@ -633,7 +633,7 @@ 32.56 if (isNotEol(msaOptions)) opFail(); 32.57 return; 32.58 } 32.59 - } else if (isNewLine(chars, s, end) || (Config.USE_CRNL_AS_LINE_TERMINATOR && isCrnl(chars, s, end))) { 32.60 + } else if (isNewLine(chars, s, end)) { 32.61 return; 32.62 } 32.63 opFail(); 32.64 @@ -652,9 +652,6 @@ 32.65 } 32.66 } else if (isNewLine(chars, s, end) && s + 1 == end) { 32.67 return; 32.68 - } else if (Config.USE_CRNL_AS_LINE_TERMINATOR && isCrnl(chars, s, end)) { 32.69 - int ss = s + 2; 32.70 - if (ss == end) return; 32.71 } 32.72 opFail(); 32.73 } 32.74 @@ -731,8 +728,6 @@ 32.75 // STRING_CMP 32.76 while(n-- > 0) if (chars[pstart++] != chars[s++]) {opFail(); return;} 32.77 32.78 - int len; 32.79 - 32.80 // beyond string check 32.81 if (sprev < range) { 32.82 while (sprev + 1 < s) sprev++; 32.83 @@ -768,7 +763,6 @@ 32.84 if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) {opFail(); return;} 32.85 s = value; 32.86 32.87 - int len; 32.88 // if (sprev < chars.length) 32.89 while (sprev + 1 < s) sprev++; 32.90 } 32.91 @@ -796,8 +790,6 @@ 32.92 32.93 s = swork; 32.94 32.95 - int len; 32.96 - 32.97 // beyond string check 32.98 if (sprev < range) { 32.99 while (sprev + 1 < s) sprev++; 32.100 @@ -829,7 +821,6 @@ 32.101 if (!stringCmpIC(regex.caseFoldFlag, pstart, this, n, end)) continue loop; // STRING_CMP_VALUE_IC 32.102 s = value; 32.103 32.104 - int len; 32.105 // if (sprev < chars.length) 32.106 while (sprev + 1 < s) sprev++; 32.107 32.108 @@ -902,7 +893,6 @@ 32.109 32.110 sprev = s; 32.111 if (backrefMatchAtNestedLevel(ic != 0, regex.caseFoldFlag, level, tlen, ip)) { // (s) and (end) implicit 32.112 - int len; 32.113 while (sprev + 1 < s) sprev++; 32.114 ip += tlen; // * SIZE_MEMNUM 32.115 } else {
33.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/CodeRangeBuffer.java Mon Aug 26 14:54:25 2013 -0700 33.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/CodeRangeBuffer.java Tue Aug 27 19:26:48 2013 +0530 33.3 @@ -58,6 +58,7 @@ 33.4 used = orig.used; 33.5 } 33.6 33.7 + @Override 33.8 public String toString() { 33.9 StringBuilder buf = new StringBuilder(); 33.10 buf.append("CodeRange");
34.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Mon Aug 26 14:54:25 2013 -0700 34.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Config.java Tue Aug 27 19:26:48 2013 +0530 34.3 @@ -29,7 +29,6 @@ 34.4 final int INTERNAL_ENC_CASE_FOLD_MULTI_CHAR = (1<<30); 34.5 final int ENC_CASE_FOLD_MIN = INTERNAL_ENC_CASE_FOLD_MULTI_CHAR; 34.6 final int ENC_CASE_FOLD_DEFAULT = ENC_CASE_FOLD_MIN; 34.7 - final boolean USE_CRNL_AS_LINE_TERMINATOR = false; 34.8 34.9 final boolean USE_MONOMANIAC_CHECK_CAPTURES_IN_ENDLESS_REPEAT = true; /* /(?:()|())*\2/ */ 34.10 final boolean USE_NEWLINE_AT_END_OF_STRING_HAS_EMPTY_LINE = true; /* /\n$/ =~ "\n" */
35.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Mon Aug 26 14:54:25 2013 -0700 35.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/EncodingHelper.java Tue Aug 27 19:26:48 2013 +0530 35.3 @@ -24,10 +24,12 @@ 35.4 35.5 import java.util.Arrays; 35.6 35.7 -public class EncodingHelper { 35.8 +public final class EncodingHelper { 35.9 35.10 - public final static char NEW_LINE = 0xa; 35.11 - public final static char RETURN = 0xd; 35.12 + final static int NEW_LINE = 0x000a; 35.13 + final static int RETURN = 0x000d; 35.14 + final static int LINE_SEPARATOR = 0x2028; 35.15 + final static int PARAGRAPH_SEPARATOR = 0x2029; 35.16 35.17 final static char[] EMPTYCHARS = new char[0]; 35.18 final static int[][] codeRanges = new int[15][]; 35.19 @@ -64,15 +66,11 @@ 35.20 } 35.21 35.22 public static boolean isNewLine(int code) { 35.23 - return code == NEW_LINE; 35.24 + return code == NEW_LINE || code == RETURN || code == LINE_SEPARATOR || code == PARAGRAPH_SEPARATOR; 35.25 } 35.26 35.27 public static boolean isNewLine(char[] chars, int p, int end) { 35.28 - return p < end && chars[p] == NEW_LINE; 35.29 - } 35.30 - 35.31 - public static boolean isCrnl(char[] chars, int p, int end) { 35.32 - return p + 1 < end && chars[p] == RETURN && chars[p + 1] == NEW_LINE; 35.33 + return p < end && isNewLine(chars[p]); 35.34 } 35.35 35.36 // Encoding.prevCharHead 35.37 @@ -194,7 +192,7 @@ 35.38 int type; 35.39 switch (ctype) { 35.40 case CharacterType.NEWLINE: 35.41 - return code == EncodingHelper.NEW_LINE; 35.42 + return isNewLine(code); 35.43 case CharacterType.ALPHA: 35.44 return (1 << Character.getType(code) & CharacterType.ALPHA_MASK) != 0; 35.45 case CharacterType.BLANK:
36.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Mon Aug 26 14:54:25 2013 -0700 36.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Lexer.java Tue Aug 27 19:26:48 2013 +0530 36.3 @@ -139,6 +139,7 @@ 36.4 } 36.5 } 36.6 36.7 + @SuppressWarnings("fallthrough") 36.8 /* \M-, \C-, \c, or \... */ 36.9 private int fetchEscapedValue() { 36.10 if (!left()) { 36.11 @@ -731,7 +732,7 @@ 36.12 if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.BEGIN_BUF : AnchorType.BEGIN_LINE); 36.13 break; 36.14 case '$': 36.15 - if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.SEMI_END_BUF : AnchorType.END_LINE); 36.16 + if (syntax.opLineAnchor()) fetchTokenFor_anchor(isSingleline(env.option) ? AnchorType.END_BUF : AnchorType.END_LINE); 36.17 break; 36.18 case '[': 36.19 if (syntax.opBracketCC()) token.type = TokenType.CC_CC_OPEN;
37.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Mon Aug 26 14:54:25 2013 -0700 37.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Matcher.java Tue Aug 27 19:26:48 2013 +0530 37.3 @@ -141,7 +141,7 @@ 37.4 continue retry; 37.5 } 37.6 } 37.7 - } else if (!EncodingHelper.isNewLine(chars, p, end) && (!Config.USE_CRNL_AS_LINE_TERMINATOR || !EncodingHelper.isCrnl(chars, p, end))) { 37.8 + } else if (!EncodingHelper.isNewLine(chars, p, end)) { 37.9 //if () break; 37.10 // goto retry_gate; 37.11 pprev = p; 37.12 @@ -226,7 +226,7 @@ 37.13 continue retry; 37.14 } 37.15 } 37.16 - } else if (!EncodingHelper.isNewLine(chars, p, end) && (!Config.USE_CRNL_AS_LINE_TERMINATOR || !EncodingHelper.isCrnl(chars, p, end))) { 37.17 + } else if (!EncodingHelper.isNewLine(chars, p, end)) { 37.18 p = EncodingHelper.prevCharHead(adjrange, p); 37.19 if (p == -1) return false; 37.20 continue retry; 37.21 @@ -330,12 +330,6 @@ 37.22 maxSemiEnd = end; 37.23 if (EncodingHelper.isNewLine(chars, preEnd, end)) { 37.24 minSemiEnd = preEnd; 37.25 - if (Config.USE_CRNL_AS_LINE_TERMINATOR) { 37.26 - preEnd = EncodingHelper.stepBack(str, preEnd, 1); 37.27 - if (preEnd != -1 && EncodingHelper.isCrnl(chars, preEnd, end)) { 37.28 - minSemiEnd = preEnd; 37.29 - } 37.30 - } 37.31 if (minSemiEnd > str && start <= minSemiEnd) { 37.32 // !goto end_buf;! 37.33 if (endBuf(start, range, minSemiEnd, maxSemiEnd)) return -1; // mismatch_no_msa;
38.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Mon Aug 26 14:54:25 2013 -0700 38.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Parser.java Tue Aug 27 19:26:48 2013 +0530 38.3 @@ -297,8 +297,6 @@ 38.4 throw new SyntaxException(ERR_END_PATTERN_IN_GROUP); 38.5 } 38.6 38.7 - boolean listCapture = false; 38.8 - 38.9 fetch(); 38.10 switch(c) { 38.11 case ':': /* (?:...) grouping only */
39.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Mon Aug 26 14:54:25 2013 -0700 39.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/Region.java Tue Aug 27 19:26:48 2013 +0530 39.3 @@ -32,6 +32,7 @@ 39.4 this.end = new int[num]; 39.5 } 39.6 39.7 + @Override 39.8 public String toString() { 39.9 StringBuilder sb = new StringBuilder(); 39.10 sb.append("Region: \n");
40.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Mon Aug 26 14:54:25 2013 -0700 40.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ScannerSupport.java Tue Aug 27 19:26:48 2013 +0530 40.3 @@ -21,9 +21,6 @@ 40.4 40.5 import jdk.nashorn.internal.runtime.regexp.joni.encoding.IntHolder; 40.6 import jdk.nashorn.internal.runtime.regexp.joni.exception.ErrorMessages; 40.7 -import jdk.nashorn.internal.runtime.regexp.joni.exception.InternalException; 40.8 -import jdk.nashorn.internal.runtime.regexp.joni.exception.SyntaxException; 40.9 -import jdk.nashorn.internal.runtime.regexp.joni.exception.ValueException; 40.10 40.11 abstract class ScannerSupport extends IntHolder implements ErrorMessages { 40.12
41.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/SearchAlgorithm.java Mon Aug 26 14:54:25 2013 -0700 41.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/SearchAlgorithm.java Tue Aug 27 19:26:48 2013 +0530 41.3 @@ -28,14 +28,17 @@ 41.4 41.5 public static final SearchAlgorithm NONE = new SearchAlgorithm() { 41.6 41.7 + @Override 41.8 public final String getName() { 41.9 return "NONE"; 41.10 } 41.11 41.12 + @Override 41.13 public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) { 41.14 return textP; 41.15 } 41.16 41.17 + @Override 41.18 public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) { 41.19 return textP; 41.20 } 41.21 @@ -44,10 +47,12 @@ 41.22 41.23 public static final SearchAlgorithm SLOW = new SearchAlgorithm() { 41.24 41.25 + @Override 41.26 public final String getName() { 41.27 return "EXACT"; 41.28 } 41.29 41.30 + @Override 41.31 public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) { 41.32 char[] target = regex.exact; 41.33 int targetP = regex.exactP; 41.34 @@ -78,6 +83,7 @@ 41.35 return -1; 41.36 } 41.37 41.38 + @Override 41.39 public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) { 41.40 char[] target = regex.exact; 41.41 int targetP = regex.exactP; 41.42 @@ -114,10 +120,12 @@ 41.43 this.caseFoldFlag = regex.caseFoldFlag; 41.44 } 41.45 41.46 + @Override 41.47 public final String getName() { 41.48 return "EXACT_IC"; 41.49 } 41.50 41.51 + @Override 41.52 public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) { 41.53 char[] target = regex.exact; 41.54 int targetP = regex.exactP; 41.55 @@ -136,6 +144,7 @@ 41.56 return -1; 41.57 } 41.58 41.59 + @Override 41.60 public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) { 41.61 char[] target = regex.exact; 41.62 int targetP = regex.exactP; 41.63 @@ -163,14 +172,16 @@ 41.64 } 41.65 return true; 41.66 } 41.67 - }; 41.68 + } 41.69 41.70 public static final SearchAlgorithm BM = new SearchAlgorithm() { 41.71 41.72 + @Override 41.73 public final String getName() { 41.74 return "EXACT_BM"; 41.75 } 41.76 41.77 + @Override 41.78 public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) { 41.79 char[] target = regex.exact; 41.80 int targetP = regex.exactP; 41.81 @@ -212,6 +223,7 @@ 41.82 41.83 private static final int BM_BACKWARD_SEARCH_LENGTH_THRESHOLD = 100; 41.84 41.85 + @Override 41.86 public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) { 41.87 char[] target = regex.exact; 41.88 int targetP = regex.exactP; 41.89 @@ -263,10 +275,12 @@ 41.90 41.91 public static final SearchAlgorithm MAP = new SearchAlgorithm() { 41.92 41.93 + @Override 41.94 public final String getName() { 41.95 return "MAP"; 41.96 } 41.97 41.98 + @Override 41.99 public final int search(Regex regex, char[] text, int textP, int textEnd, int textRange) { 41.100 byte[] map = regex.map; 41.101 int s = textP; 41.102 @@ -278,6 +292,7 @@ 41.103 return -1; 41.104 } 41.105 41.106 + @Override 41.107 public final int searchBackward(Regex regex, char[] text, int textP, int adjustText, int textEnd, int textStart, int s_, int range_) { 41.108 byte[] map = regex.map; 41.109 int s = textStart;
42.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Mon Aug 26 14:54:25 2013 -0700 42.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/StackMachine.java Tue Aug 27 19:26:48 2013 +0530 42.3 @@ -458,7 +458,7 @@ 42.4 isNull = 0; 42.5 break; 42.6 } else if (endp != s) { 42.7 - isNull = -1;; /* empty, but position changed */ 42.8 + isNull = -1; /* empty, but position changed */ 42.9 } 42.10 } 42.11 k++;
43.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/WarnCallback.java Mon Aug 26 14:54:25 2013 -0700 43.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/WarnCallback.java Tue Aug 27 19:26:48 2013 +0530 43.3 @@ -24,6 +24,7 @@ 43.4 */ 43.5 public interface WarnCallback { 43.6 WarnCallback DEFAULT = new WarnCallback() { 43.7 + @Override 43.8 public void warn(String message) { 43.9 System.err.println(message); 43.10 }
44.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Mon Aug 26 14:54:25 2013 -0700 44.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/EncloseNode.java Tue Aug 27 19:26:48 2013 +0530 44.3 @@ -19,7 +19,6 @@ 44.4 */ 44.5 package jdk.nashorn.internal.runtime.regexp.joni.ast; 44.6 44.7 -import jdk.nashorn.internal.runtime.regexp.joni.Config; 44.8 import jdk.nashorn.internal.runtime.regexp.joni.Option; 44.9 import jdk.nashorn.internal.runtime.regexp.joni.constants.EncloseType; 44.10
45.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Mon Aug 26 14:54:25 2013 -0700 45.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/Node.java Tue Aug 27 19:26:48 2013 +0530 45.3 @@ -35,7 +35,7 @@ 45.4 } 45.5 45.6 protected void setChild(Node tgt){} // default definition 45.7 - protected Node getChild(){return null;}; // default definition 45.8 + protected Node getChild(){return null;} // default definition 45.9 45.10 public void swap(Node with) { 45.11 Node tmp; 45.12 @@ -74,6 +74,7 @@ 45.13 return getName() + ":0x" + Integer.toHexString(System.identityHashCode(this)); 45.14 } 45.15 45.16 + @Override 45.17 public final String toString() { 45.18 StringBuilder s = new StringBuilder(); 45.19 s.append("<" + getAddressName() + " (" + (parent == null ? "NULL" : parent.getAddressName()) + ")>");
46.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Mon Aug 26 14:54:25 2013 -0700 46.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/ast/QuantifierNode.java Tue Aug 27 19:26:48 2013 +0530 46.3 @@ -223,6 +223,7 @@ 46.4 other.target = null; // remove target from reduced quantifier 46.5 } 46.6 46.7 + @SuppressWarnings("fallthrough") 46.8 public int setQuantifier(Node tgt, boolean group, ScanEnvironment env, char[] chars, int p, int end) { 46.9 if (lower == 1 && upper == 1) return 1; 46.10
47.1 --- a/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Mon Aug 26 14:54:25 2013 -0700 47.2 +++ b/src/jdk/nashorn/internal/runtime/regexp/joni/exception/ErrorMessages.java Tue Aug 27 19:26:48 2013 +0530 47.3 @@ -19,8 +19,6 @@ 47.4 */ 47.5 package jdk.nashorn.internal.runtime.regexp.joni.exception; 47.6 47.7 -import jdk.nashorn.internal.runtime.regexp.joni.Config; 47.8 - 47.9 public interface ErrorMessages { 47.10 47.11 /* from jcodings */
48.1 --- a/src/jdk/nashorn/internal/runtime/resources/Options.properties Mon Aug 26 14:54:25 2013 -0700 48.2 +++ b/src/jdk/nashorn/internal/runtime/resources/Options.properties Tue Aug 27 19:26:48 2013 +0530 48.3 @@ -288,7 +288,7 @@ 48.4 nashorn.option.range.analysis = { \ 48.5 name="--range-analysis", \ 48.6 is_undocumented=true, \ 48.7 - desc="Do range analysis using known compile time types, and try to narrow number types" \ 48.8 + desc="EXPERIMENTAL: Do range analysis using known compile time types, and try to narrow number types" \ 48.9 } 48.10 48.11 nashorn.option.D = { \ 48.12 @@ -307,12 +307,12 @@ 48.13 desc="Enable scripting features." \ 48.14 } 48.15 48.16 -nashorn.option.specialize.calls = { \ 48.17 - name="--specialize-calls", \ 48.18 - is_undocumented=true, \ 48.19 - type=String, \ 48.20 - params="[=function_1,...,function_n]", \ 48.21 - desc="Specialize all or a set of method according to callsite parameter types" \ 48.22 +nashorn.option.specialize.calls = { \ 48.23 + name="--specialize-calls", \ 48.24 + is_undocumented=true, \ 48.25 + type=String, \ 48.26 + params="[=function_1,...,function_n]", \ 48.27 + desc="EXPERIMENTAL: Specialize all or a set of method according to callsite parameter types" \ 48.28 } 48.29 48.30 nashorn.option.stdout = { \
49.1 --- a/src/jdk/nashorn/tools/Shell.java Mon Aug 26 14:54:25 2013 -0700 49.2 +++ b/src/jdk/nashorn/tools/Shell.java Tue Aug 27 19:26:48 2013 +0530 49.3 @@ -445,7 +445,7 @@ 49.4 continue; 49.5 } 49.6 49.7 - if (res != null && res != ScriptRuntime.UNDEFINED) { 49.8 + if (res != ScriptRuntime.UNDEFINED) { 49.9 err.println(JSType.toString(res)); 49.10 } 49.11 }
50.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 50.2 +++ b/test/script/basic/JDK-8019987.js Tue Aug 27 19:26:48 2013 +0530 50.3 @@ -0,0 +1,171 @@ 50.4 +/* 50.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 50.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 50.7 + * 50.8 + * This code is free software; you can redistribute it and/or modify it 50.9 + * under the terms of the GNU General Public License version 2 only, as 50.10 + * published by the Free Software Foundation. 50.11 + * 50.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 50.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 50.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 50.15 + * version 2 for more details (a copy is included in the LICENSE file that 50.16 + * accompanied this code). 50.17 + * 50.18 + * You should have received a copy of the GNU General Public License version 50.19 + * 2 along with this work; if not, write to the Free Software Foundation, 50.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 50.21 + * 50.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 50.23 + * or visit www.oracle.com if you need additional information or have any 50.24 + * questions. 50.25 + */ 50.26 + 50.27 +/** 50.28 + * JDK-8019987: String trimRight and trimLeft could be defined. 50.29 + * 50.30 + * @test 50.31 + * @run 50.32 + */ 50.33 + 50.34 +var TESTSTRING = "abcde"; 50.35 + 50.36 +var SPACES = " "; 50.37 +var TESTSTRING_LEFT_SPACES = SPACES + TESTSTRING; 50.38 +var TESTSTRING_RIGHT_SPACES = TESTSTRING + SPACES; 50.39 +var TESTSTRING_BOTH_SPACES = SPACES + TESTSTRING + SPACES; 50.40 +var TESTSTRING_MIDDLE_SPACES = TESTSTRING + SPACES + TESTSTRING; 50.41 + 50.42 +var WHITESPACE = 50.43 + " \t" + // space and tab 50.44 + "\n\r" + // newline and return 50.45 + "\u2028" + // line separator 50.46 + "\u2029" + // paragraph separator 50.47 + "\u000b" + // tabulation line 50.48 + "\u000c" + // ff (ctrl-l) 50.49 + "\u00a0" + // Latin-1 space 50.50 + "\u1680" + // Ogham space mark 50.51 + "\u180e" + // separator, Mongolian vowel 50.52 + "\u2000" + // en quad 50.53 + "\u2001" + // em quad 50.54 + "\u2002" + // en space 50.55 + "\u2003" + // em space 50.56 + "\u2004" + // three-per-em space 50.57 + "\u2005" + // four-per-em space 50.58 + "\u2006" + // six-per-em space 50.59 + "\u2007" + // figure space 50.60 + "\u2008" + // punctuation space 50.61 + "\u2009" + // thin space 50.62 + "\u200a" + // hair space 50.63 + "\u202f" + // narrow no-break space 50.64 + "\u205f" + // medium mathematical space 50.65 + "\u3000" + // ideographic space 50.66 + "\ufeff"; // byte order mark 50.67 +var TESTSTRING_LEFT_WHITESPACE = WHITESPACE + TESTSTRING; 50.68 +var TESTSTRING_RIGHT_WHITESPACE = TESTSTRING + WHITESPACE; 50.69 +var TESTSTRING_BOTH_WHITESPACE = WHITESPACE + TESTSTRING + WHITESPACE; 50.70 +var TESTSTRING_MIDDLE_WHITESPACE = TESTSTRING + WHITESPACE + TESTSTRING; 50.71 + 50.72 +function escape(string) { 50.73 + var sb = new java.lang.StringBuilder(); 50.74 + sb.append("\""); 50.75 + 50.76 + for (var i = 0; i < string.length; i++) { 50.77 + var ch = string.charAt(i); 50.78 + 50.79 + switch (ch) { 50.80 + case '\\': 50.81 + sb.append("\\\\"); 50.82 + break; 50.83 + case '"': 50.84 + sb.append("\\\""); 50.85 + break; 50.86 + case '\'': 50.87 + sb.append("\\\'"); 50.88 + break; 50.89 + case '\b': 50.90 + sb.append("\\b"); 50.91 + break; 50.92 + case '\f': 50.93 + sb.append("\\f"); 50.94 + break; 50.95 + case '\n': 50.96 + sb.append("\\n"); 50.97 + break; 50.98 + case '\r': 50.99 + sb.append("\\r"); 50.100 + break; 50.101 + case '\t': 50.102 + sb.append("\\t"); 50.103 + break; 50.104 + default: 50.105 + var code = string.charCodeAt(i); 50.106 + 50.107 + if (code < 0x20 || code >= 0xFF) { 50.108 + sb.append("\\u"); 50.109 + 50.110 + var hex = java.lang.Integer.toHexString(code); 50.111 + for (var i = hex.length; i < 4; i++) { 50.112 + sb.append('0'); 50.113 + } 50.114 + sb.append(hex); 50.115 + } else { 50.116 + sb.append(ch); 50.117 + } 50.118 + 50.119 + break; 50.120 + } 50.121 + } 50.122 + 50.123 + sb.append("\""); 50.124 + 50.125 + return sb.toString(); 50.126 +} 50.127 + 50.128 +var count = 0; 50.129 +function test(expected, trimmed) { 50.130 + count++; 50.131 + if (trimmed != expected) { 50.132 + print(count + ": Expected: " + escape(expected) + ", found: " + escape(trimmed)); 50.133 + } 50.134 +} 50.135 + 50.136 +test("", SPACES.trim()); 50.137 +test("", SPACES.trimLeft()); 50.138 +test("", SPACES.trimRight()); 50.139 + 50.140 +test(TESTSTRING, TESTSTRING_LEFT_SPACES.trim()); 50.141 +test(TESTSTRING, TESTSTRING_LEFT_SPACES.trimLeft()); 50.142 +test(TESTSTRING_LEFT_SPACES, TESTSTRING_LEFT_SPACES.trimRight()); 50.143 + 50.144 +test(TESTSTRING, TESTSTRING_RIGHT_SPACES.trim()); 50.145 +test(TESTSTRING_RIGHT_SPACES, TESTSTRING_RIGHT_SPACES.trimLeft()); 50.146 +test(TESTSTRING, TESTSTRING_RIGHT_SPACES.trimRight()); 50.147 + 50.148 +test(TESTSTRING, TESTSTRING_BOTH_SPACES.trim()); 50.149 +test(TESTSTRING_RIGHT_SPACES, TESTSTRING_BOTH_SPACES.trimLeft()); 50.150 +test(TESTSTRING_LEFT_SPACES, TESTSTRING_BOTH_SPACES.trimRight()); 50.151 + 50.152 +test(TESTSTRING_MIDDLE_SPACES, TESTSTRING_MIDDLE_SPACES.trim()); 50.153 +test(TESTSTRING_MIDDLE_SPACES, TESTSTRING_MIDDLE_SPACES.trimLeft()); 50.154 +test(TESTSTRING_MIDDLE_SPACES, TESTSTRING_MIDDLE_SPACES.trimRight()); 50.155 + 50.156 +test("", WHITESPACE.trim()); 50.157 +test("", WHITESPACE.trimLeft()); 50.158 +test("", WHITESPACE.trimRight()); 50.159 + 50.160 +test(TESTSTRING, TESTSTRING_LEFT_WHITESPACE.trim()); 50.161 +test(TESTSTRING, TESTSTRING_LEFT_WHITESPACE.trimLeft()); 50.162 +test(TESTSTRING_LEFT_WHITESPACE, TESTSTRING_LEFT_WHITESPACE.trimRight()); 50.163 + 50.164 +test(TESTSTRING, TESTSTRING_RIGHT_WHITESPACE.trim()); 50.165 +test(TESTSTRING_RIGHT_WHITESPACE, TESTSTRING_RIGHT_WHITESPACE.trimLeft()); 50.166 +test(TESTSTRING, TESTSTRING_RIGHT_WHITESPACE.trimRight()); 50.167 + 50.168 +test(TESTSTRING, TESTSTRING_BOTH_WHITESPACE.trim()); 50.169 +test(TESTSTRING_RIGHT_WHITESPACE, TESTSTRING_BOTH_WHITESPACE.trimLeft()); 50.170 +test(TESTSTRING_LEFT_WHITESPACE, TESTSTRING_BOTH_WHITESPACE.trimRight()); 50.171 + 50.172 +test(TESTSTRING_MIDDLE_WHITESPACE, TESTSTRING_MIDDLE_WHITESPACE.trim()); 50.173 +test(TESTSTRING_MIDDLE_WHITESPACE, TESTSTRING_MIDDLE_WHITESPACE.trimLeft()); 50.174 +test(TESTSTRING_MIDDLE_WHITESPACE, TESTSTRING_MIDDLE_WHITESPACE.trimRight());
51.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 51.2 +++ b/test/script/basic/JDK-8023650.js Tue Aug 27 19:26:48 2013 +0530 51.3 @@ -0,0 +1,109 @@ 51.4 +/* 51.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 51.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 51.7 + * 51.8 + * This code is free software; you can redistribute it and/or modify it 51.9 + * under the terms of the GNU General Public License version 2 only, as 51.10 + * published by the Free Software Foundation. 51.11 + * 51.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 51.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 51.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 51.15 + * version 2 for more details (a copy is included in the LICENSE file that 51.16 + * accompanied this code). 51.17 + * 51.18 + * You should have received a copy of the GNU General Public License version 51.19 + * 2 along with this work; if not, write to the Free Software Foundation, 51.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 51.21 + * 51.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 51.23 + * or visit www.oracle.com if you need additional information or have any 51.24 + * questions. 51.25 + */ 51.26 + 51.27 +/** 51.28 + * JDK-8023650: Regexp m flag does not recognize CRNL or CR 51.29 + * 51.30 + * @test 51.31 + * @run 51.32 + */ 51.33 + 51.34 +if (!/^Connection: close$/m.test('\r\n\r\nConnection: close\r\n\r\n')) { 51.35 + throw new Error(); 51.36 +} 51.37 + 51.38 +if (!/^Connection: close$/m.test('\n\nConnection: close\n\n')) { 51.39 + throw new Error(); 51.40 +} 51.41 + 51.42 +if (!/^Connection: close$/m.test('\r\rConnection: close\r\r')) { 51.43 + throw new Error(); 51.44 +} 51.45 + 51.46 +if (!/^Connection: close$/m.test('\u2028\u2028Connection: close\u2028\u2028')) { 51.47 + throw new Error(); 51.48 +} 51.49 + 51.50 +if (!/^Connection: close$/m.test('\u2029\u2029Connection: close\u2029\u2029')) { 51.51 + throw new Error(); 51.52 +} 51.53 + 51.54 +var result = /a(.*)/.exec("a\r"); 51.55 +if (!result || result[0] != 'a' || result[1] != '') { 51.56 + throw new Error(); 51.57 +} 51.58 + 51.59 +result = /a(.*)/m.exec("a\r"); 51.60 +if (!result || result[0] != 'a' || result[1] != '') { 51.61 + throw new Error(); 51.62 +} 51.63 + 51.64 +result = /a(.*)/.exec("a\n"); 51.65 +if (!result || result[0] != 'a' || result[1] != '') { 51.66 + throw new Error(); 51.67 +} 51.68 + 51.69 +result = /a(.*)/m.exec("a\n"); 51.70 +if (!result || result[0] != 'a' || result[1] != '') { 51.71 + throw new Error(); 51.72 +} 51.73 + 51.74 +result = /a(.*)/.exec("a\r\n"); 51.75 +if (!result || result[0] != 'a' || result[1] != '') { 51.76 + throw new Error(); 51.77 +} 51.78 + 51.79 +result = /a(.*)/m.exec("a\r\n"); 51.80 +if (!result || result[0] != 'a' || result[1] != '') { 51.81 + throw new Error(); 51.82 +} 51.83 + 51.84 +result = /a(.*)/.exec("a\u2028"); 51.85 +if (!result || result[0] != 'a' || result[1] != '') { 51.86 + throw new Error(); 51.87 +} 51.88 + 51.89 +result = /a(.*)/m.exec("a\u2029"); 51.90 +if (!result || result[0] != 'a' || result[1] != '') { 51.91 + throw new Error(); 51.92 +} 51.93 + 51.94 +if (/a$/.test("a\n")) { 51.95 + throw new Error(); 51.96 +} 51.97 + 51.98 +if (/a$/.test("a\r")) { 51.99 + throw new Error(); 51.100 +} 51.101 + 51.102 +if (/a$/.test("a\r\n")) { 51.103 + throw new Error(); 51.104 +} 51.105 + 51.106 +if (/a$/.test("a\u2028")) { 51.107 + throw new Error(); 51.108 +} 51.109 + 51.110 +if (/a$/.test("a\u2029")) { 51.111 + throw new Error(); 51.112 +}
52.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 52.2 +++ b/test/script/basic/JDK-8023780.js Tue Aug 27 19:26:48 2013 +0530 52.3 @@ -0,0 +1,38 @@ 52.4 +/* 52.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 52.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 52.7 + * 52.8 + * This code is free software; you can redistribute it and/or modify it 52.9 + * under the terms of the GNU General Public License version 2 only, as 52.10 + * published by the Free Software Foundation. 52.11 + * 52.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 52.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 52.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 52.15 + * version 2 for more details (a copy is included in the LICENSE file that 52.16 + * accompanied this code). 52.17 + * 52.18 + * You should have received a copy of the GNU General Public License version 52.19 + * 2 along with this work; if not, write to the Free Software Foundation, 52.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 52.21 + * 52.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 52.23 + * or visit www.oracle.com if you need additional information or have any 52.24 + * questions. 52.25 + */ 52.26 + 52.27 +/** 52.28 + * JDK-8023780: Gracefully handle @CS methods while binding bean properties 52.29 + * 52.30 + * @test 52.31 + * @run 52.32 + */ 52.33 + 52.34 +var obj = {} 52.35 +Object.bindProperties(obj, java.lang.Thread.currentThread()); 52.36 + 52.37 +print(typeof obj.getName === "function") 52.38 +print(typeof obj.getCurrentContext === "undefined") 52.39 + 52.40 +print(Object.hasOwnProperty("name")) 52.41 +print(!Object.hasOwnProperty("currentContext"))
53.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 53.2 +++ b/test/script/basic/JDK-8023780.js.EXPECTED Tue Aug 27 19:26:48 2013 +0530 53.3 @@ -0,0 +1,4 @@ 53.4 +true 53.5 +true 53.6 +true 53.7 +true
54.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 54.2 +++ b/test/script/basic/JDK-8023784.js Tue Aug 27 19:26:48 2013 +0530 54.3 @@ -0,0 +1,66 @@ 54.4 +/* 54.5 + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 54.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 54.7 + * 54.8 + * This code is free software; you can redistribute it and/or modify it 54.9 + * under the terms of the GNU General Public License version 2 only, as 54.10 + * published by the Free Software Foundation. 54.11 + * 54.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 54.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 54.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 54.15 + * version 2 for more details (a copy is included in the LICENSE file that 54.16 + * accompanied this code). 54.17 + * 54.18 + * You should have received a copy of the GNU General Public License version 54.19 + * 2 along with this work; if not, write to the Free Software Foundation, 54.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 54.21 + * 54.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 54.23 + * or visit www.oracle.com if you need additional information or have any 54.24 + * questions. 54.25 + */ 54.26 + 54.27 +/** 54.28 + * JDK-8023784: Object.prototype.toString should contain the class name for all instances 54.29 + * 54.30 + * @test 54.31 + * @run 54.32 + */ 54.33 + 54.34 +// two parts to this bug -- typed array don't have proper [[Class]] property 54.35 + 54.36 +print(Object.prototype.toString.call(new ArrayBuffer(1))); 54.37 +print(Object.prototype.toString.call(new Int8Array(1))); 54.38 +print(Object.prototype.toString.call(new Int16Array(1))); 54.39 +print(Object.prototype.toString.call(new Int32Array(1))); 54.40 +print(Object.prototype.toString.call(new Uint8Array(1))); 54.41 +print(Object.prototype.toString.call(new Uint8ClampedArray(1))); 54.42 +print(Object.prototype.toString.call(new Uint16Array(1))); 54.43 +print(Object.prototype.toString.call(new Uint32Array(1))); 54.44 +print(Object.prototype.toString.call(new Float32Array(1))); 54.45 +print(Object.prototype.toString.call(new Float64Array(1))); 54.46 + 54.47 +// second part is that Object.prototype.toString does not handle mirror 54.48 +// in the manner expected. 54.49 + 54.50 +var global = loadWithNewGlobal({ 54.51 + name: "test", 54.52 + script: "this" 54.53 +}); 54.54 + 54.55 +print(Object.prototype.toString.call(new global.Object())); 54.56 +print(Object.prototype.toString.call(new global.Array())); 54.57 +print(Object.prototype.toString.call(new global.RegExp())); 54.58 +print(Object.prototype.toString.call(new global.Error("error!"))); 54.59 +print(Object.prototype.toString.call(global.Object)); 54.60 +print(Object.prototype.toString.call(new global.ArrayBuffer(1))); 54.61 +print(Object.prototype.toString.call(new global.Int8Array(1))); 54.62 +print(Object.prototype.toString.call(new global.Int16Array(1))); 54.63 +print(Object.prototype.toString.call(new global.Int32Array(1))); 54.64 +print(Object.prototype.toString.call(new global.Uint8Array(1))); 54.65 +print(Object.prototype.toString.call(new global.Uint8ClampedArray(1))); 54.66 +print(Object.prototype.toString.call(new global.Uint16Array(1))); 54.67 +print(Object.prototype.toString.call(new global.Uint32Array(1))); 54.68 +print(Object.prototype.toString.call(new global.Float32Array(1))); 54.69 +print(Object.prototype.toString.call(new global.Float64Array(1)));
55.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 55.2 +++ b/test/script/basic/JDK-8023784.js.EXPECTED Tue Aug 27 19:26:48 2013 +0530 55.3 @@ -0,0 +1,25 @@ 55.4 +[object ArrayBuffer] 55.5 +[object Int8Array] 55.6 +[object Int16Array] 55.7 +[object Int32Array] 55.8 +[object Uint8Array] 55.9 +[object Uint8ClampedArray] 55.10 +[object Uint16Array] 55.11 +[object Uint32Array] 55.12 +[object Float32Array] 55.13 +[object Float64Array] 55.14 +[object Object] 55.15 +[object Array] 55.16 +[object RegExp] 55.17 +[object Error] 55.18 +[object Function] 55.19 +[object ArrayBuffer] 55.20 +[object Int8Array] 55.21 +[object Int16Array] 55.22 +[object Int32Array] 55.23 +[object Uint8Array] 55.24 +[object Uint8ClampedArray] 55.25 +[object Uint16Array] 55.26 +[object Uint32Array] 55.27 +[object Float32Array] 55.28 +[object Float64Array]
56.1 --- a/test/script/basic/NASHORN-377.js.EXPECTED Mon Aug 26 14:54:25 2013 -0700 56.2 +++ b/test/script/basic/NASHORN-377.js.EXPECTED Tue Aug 27 19:26:48 2013 +0530 56.3 @@ -1,5 +1,5 @@ 56.4 8 8 true undefined 56.5 -[object Object] [object Object] [object Object] 56.6 +[object ArrayBuffer] [object ArrayBuffer] [object Int8Array] 56.7 0 8 8 1 56.8 0 8 8 1 56.9 0 8 8 1
57.1 --- a/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Mon Aug 26 14:54:25 2013 -0700 57.2 +++ b/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java Tue Aug 27 19:26:48 2013 +0530 57.3 @@ -30,6 +30,7 @@ 57.4 import static org.testng.Assert.assertTrue; 57.5 import static org.testng.Assert.fail; 57.6 57.7 +import java.io.PrintWriter; 57.8 import java.io.StringReader; 57.9 import java.io.StringWriter; 57.10 import java.lang.reflect.Method; 57.11 @@ -400,8 +401,7 @@ 57.12 exp.printStackTrace(); 57.13 fail(exp.getMessage()); 57.14 } 57.15 - // dos2unix - fix line endings if running on windows 57.16 - assertEquals(sw.toString().replaceAll("\r", ""), "hello world\n"); 57.17 + assertEquals(sw.toString(), println("hello world")); 57.18 } 57.19 57.20 @Test 57.21 @@ -490,8 +490,7 @@ 57.22 fail(t.getMessage()); 57.23 } 57.24 57.25 - // dos2unix - fix line endings if running on windows 57.26 - assertEquals(sw.toString().replaceAll("\r", ""), "hello\n"); 57.27 + assertEquals(sw.toString(), println("hello")); 57.28 } 57.29 57.30 @Test 57.31 @@ -508,7 +507,14 @@ 57.32 fail(t.getMessage()); 57.33 } 57.34 57.35 - // dos2unix - fix line endings if running on windows 57.36 - assertEquals(sw.toString().replaceAll("\r", ""), "34 true hello\n"); 57.37 + assertEquals(sw.toString(), println("34 true hello")); 57.38 + } 57.39 + 57.40 + private static final String LINE_SEPARATOR = System.getProperty("line.separator"); 57.41 + 57.42 + // Returns String that would be the result of calling PrintWriter.println 57.43 + // of the given String. (This is to handle platform specific newline). 57.44 + private static String println(final String str) { 57.45 + return str + LINE_SEPARATOR; 57.46 } 57.47 }
58.1 --- a/tools/fxshell/jdk/nashorn/tools/FXShell.java Mon Aug 26 14:54:25 2013 -0700 58.2 +++ b/tools/fxshell/jdk/nashorn/tools/FXShell.java Tue Aug 27 19:26:48 2013 +0530 58.3 @@ -32,13 +32,9 @@ 58.4 import java.util.ArrayList; 58.5 import java.util.List; 58.6 import java.util.Map; 58.7 -import java.util.Set; 58.8 -import java.util.logging.Level; 58.9 -import java.util.logging.Logger; 58.10 import javafx.application.Application; 58.11 import javafx.stage.Stage; 58.12 import javax.script.Invocable; 58.13 -import javax.script.ScriptContext; 58.14 import javax.script.ScriptEngine; 58.15 import javax.script.ScriptEngineFactory; 58.16 import javax.script.ScriptEngineManager; 58.17 @@ -180,6 +176,7 @@ 58.18 * 58.19 * @return Last evaluation result (discarded.) 58.20 */ 58.21 + @SuppressWarnings("resource") 58.22 private Object load(String path) { 58.23 try { 58.24 FileInputStream file = new FileInputStream(path);