docs/DEVELOPER_README

Wed, 27 Apr 2016 01:36:41 +0800

author
aoqi
date
Wed, 27 Apr 2016 01:36:41 +0800
changeset 0
b1a7da25b547
child 952
6d5471a497fb
permissions
-rw-r--r--

Initial load
http://hg.openjdk.java.net/jdk8u/jdk8u/nashorn/
changeset: 1034:4b9cc65dd24d
tag: jdk8u25-b17

aoqi@0 1 This document describes system properties that are used for internal
aoqi@0 2 debugging and instrumentation purposes, along with the system loggers,
aoqi@0 3 which are used for the same thing.
aoqi@0 4
aoqi@0 5 This document is intended as a developer resource, and it is not
aoqi@0 6 needed as Nashorn documentation for normal usage. Flags and system
aoqi@0 7 properties described herein are subject to change without notice.
aoqi@0 8
aoqi@0 9 =====================================
aoqi@0 10 1. System properties used internally
aoqi@0 11 =====================================
aoqi@0 12
aoqi@0 13 This documentation of the system property flags assume that the
aoqi@0 14 default value of the flag is false, unless otherwise specified.
aoqi@0 15
aoqi@0 16 SYSTEM PROPERTY: -Dnashorn.args=<string>
aoqi@0 17
aoqi@0 18 This property takes as its value a space separated list of Nashorn
aoqi@0 19 command line options that should be passed to Nashorn. This might be
aoqi@0 20 useful in environments where it is hard to tell how a nashorn.jar is
aoqi@0 21 launched.
aoqi@0 22
aoqi@0 23 Example:
aoqi@0 24
aoqi@0 25 > java -Dnashorn.args="--lazy-complation --log=compiler" large-java-app-with-nashorn.jar
aoqi@0 26 > ant -Dnashorn.args="--log=codegen" antjob
aoqi@0 27
aoqi@0 28 SYSTEM PROPERTY: -Dnashorn.unstable.relink.threshold=x
aoqi@0 29
aoqi@0 30 This property controls how many call site misses are allowed before a
aoqi@0 31 callsite is relinked with "apply" semantics to never change again.
aoqi@0 32 In the case of megamorphic callsites, this is necessary, or the
aoqi@0 33 program would spend all its time swapping out callsite targets. Dynalink
aoqi@0 34 has a default value (currently 8 relinks) for this property if it
aoqi@0 35 is not explicitly set.
aoqi@0 36
aoqi@0 37
aoqi@0 38 SYSTEM PROPERTY: -Dnashorn.compiler.splitter.threshold=x
aoqi@0 39
aoqi@0 40 This will change the node weight that requires a subgraph of the IR to
aoqi@0 41 be split into several classes in order not to run out of bytecode space.
aoqi@0 42 The default value is 0x8000 (32768).
aoqi@0 43
aoqi@0 44
aoqi@0 45 SYSTEM PROPERTY: -Dnashorn.compiler.intarithmetic
aoqi@0 46
aoqi@0 47 (and integer arithmetic in general)
aoqi@0 48
aoqi@0 49 <currently disabled - this is being refactored for update releases>
aoqi@0 50
aoqi@0 51 Arithmetic operations in Nashorn (except bitwise ones) typically
aoqi@0 52 coerce the operands to doubles (as per the JavaScript spec). To switch
aoqi@0 53 this off and remain in integer mode, for example for "var x = a&b; var
aoqi@0 54 y = c&d; var z = x*y;", use this flag. This will force the
aoqi@0 55 multiplication of variables that are ints to be done with the IMUL
aoqi@0 56 bytecode and the result "z" to become an int.
aoqi@0 57
aoqi@0 58 WARNING: Note that is is experimental only to ensure that type support
aoqi@0 59 exists for all primitive types. The generated code is unsound. This
aoqi@0 60 will be the case until we do optimizations based on it. There is a CR
aoqi@0 61 in Nashorn to do better range analysis, and ensure that this is only
aoqi@0 62 done where the operation can't overflow into a wider type. Currently
aoqi@0 63 no overflow checking is done, so at the moment, until range analysis
aoqi@0 64 has been completed, this option is turned off.
aoqi@0 65
aoqi@0 66 We've experimented by using int arithmetic for everything and putting
aoqi@0 67 overflow checks afterwards, which would recompute the operation with
aoqi@0 68 the correct precision, but have yet to find a configuration where this
aoqi@0 69 is faster than just using doubles directly, even if the int operation
aoqi@0 70 does not overflow. Getting access to a JVM intrinsic that does branch
aoqi@0 71 on overflow would probably alleviate this.
aoqi@0 72
aoqi@0 73 The future:
aoqi@0 74
aoqi@0 75 We are transitioning to an optimistic type system that uses int
aoqi@0 76 arithmetic everywhere until proven wrong. The problem here is mostly
aoqi@0 77 catch an overflow exception and rolling back the state to a new method
aoqi@0 78 with less optimistic assumptions for an operation at a particular
aoqi@0 79 program point. This will most likely not be in the Java 8.0 release
aoqi@0 80 but likely end up in an update release
aoqi@0 81
aoqi@0 82 For Java 8, several java.lang.Math methods like addExact, subExact and
aoqi@0 83 mulExact are available to help us. Experiments intrinsifying these
aoqi@0 84 show a lot of promise, and we have devised a system that basically
aoqi@0 85 does on stack replacement with exceptions in bytecode to revert
aoqi@0 86 erroneous assumptions. An explanation of how this works and what we
aoqi@0 87 are doing can be found here:
aoqi@0 88 http://www.slideshare.net/lagergren/lagergren-jvmls2013final
aoqi@0 89
aoqi@0 90 Experiments with this show significant ~x2-3 performance increases on
aoqi@0 91 pretty much everything, provided that optimistic assumptions don't
aoqi@0 92 fail much. It will affect warmup time negatively, depending on how
aoqi@0 93 many erroneous too optimistic assumptions are placed in the code at
aoqi@0 94 compile time. We don't think this will be much of an issue.
aoqi@0 95
aoqi@0 96 For example for a small benchmark that repeatedly executes this
aoqi@0 97 method taken from the Crypto Octane benchmark
aoqi@0 98
aoqi@0 99 function am3(i,x,w,j,c,n) {
aoqi@0 100 var this_array = this.array;
aoqi@0 101 var w_array = w.array;
aoqi@0 102 var xl = x&0x3fff, xh = x>>14;
aoqi@0 103 while(--n >= 0) {
aoqi@0 104 var l = this_array[i]&0x3fff;
aoqi@0 105 var h = this_array[i++]>>14;
aoqi@0 106 var m = xh*l+h*xl;
aoqi@0 107 l = xl*l+((m&0x3fff)<<14)+w_array[j]+c;
aoqi@0 108 c = (l>>28)+(m>>14)+xh*h;
aoqi@0 109 w_array[j++] = l&0xfffffff;
aoqi@0 110 }
aoqi@0 111
aoqi@0 112 return c;
aoqi@0 113 }
aoqi@0 114
aoqi@0 115 The performance increase more than doubles. We are also working hard
aoqi@0 116 with the code generation team in the Java Virtual Machine to fix
aoqi@0 117 things that are lacking in invokedynamic performance, which is another
aoqi@0 118 area where a lot of ongoing performance work takes place
aoqi@0 119
aoqi@0 120 "Pessimistic" bytecode for am3, guaranteed to be semantically correct:
aoqi@0 121
aoqi@0 122 // access flags 0x9
aoqi@0 123 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;
aoqi@0 124 L0
aoqi@0 125 LINENUMBER 12 L0
aoqi@0 126 ALOAD 0
aoqi@0 127 INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 128 // handle kind 0x6 : INVOKESTATIC
aoqi@0 129 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 130 // arguments:
aoqi@0 131 0
aoqi@0 132 ]
aoqi@0 133 ASTORE 8
aoqi@0 134 L1
aoqi@0 135 LINENUMBER 13 L1
aoqi@0 136 ALOAD 3
aoqi@0 137 INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 138 // handle kind 0x6 : INVOKESTATIC
aoqi@0 139 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 140 // arguments:
aoqi@0 141 0
aoqi@0 142 ]
aoqi@0 143 ASTORE 9
aoqi@0 144 L2
aoqi@0 145 LINENUMBER 14 L2
aoqi@0 146 ALOAD 2
aoqi@0 147 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I
aoqi@0 148 SIPUSH 16383
aoqi@0 149 IAND
aoqi@0 150 ISTORE 10
aoqi@0 151 ALOAD 2
aoqi@0 152 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I
aoqi@0 153 BIPUSH 14
aoqi@0 154 ISHR
aoqi@0 155 ISTORE 11
aoqi@0 156 L3
aoqi@0 157 LINENUMBER 15 L3
aoqi@0 158 GOTO L4
aoqi@0 159 L5
aoqi@0 160 LINENUMBER 16 L5
aoqi@0 161 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] []
aoqi@0 162 ALOAD 8
aoqi@0 163 ALOAD 1
aoqi@0 164 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;Ljava/lang/Object;)I [
aoqi@0 165 // handle kind 0x6 : INVOKESTATIC
aoqi@0 166 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 167 // arguments:
aoqi@0 168 0
aoqi@0 169 ]
aoqi@0 170 SIPUSH 16383
aoqi@0 171 IAND
aoqi@0 172 INVOKESTATIC java/lang/Integer.valueOf (I)Ljava/lang/Integer;
aoqi@0 173 ASTORE 12
aoqi@0 174 L6
aoqi@0 175 LINENUMBER 17 L6
aoqi@0 176 ALOAD 8
aoqi@0 177 ALOAD 1
aoqi@0 178 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D
aoqi@0 179 DUP2
aoqi@0 180 DCONST_1
aoqi@0 181 DADD
aoqi@0 182 INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double;
aoqi@0 183 ASTORE 1
aoqi@0 184 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;D)I [
aoqi@0 185 // handle kind 0x6 : INVOKESTATIC
aoqi@0 186 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 187 // arguments:
aoqi@0 188 0
aoqi@0 189 ]
aoqi@0 190 BIPUSH 14
aoqi@0 191 ISHR
aoqi@0 192 ISTORE 13
aoqi@0 193 L7
aoqi@0 194 LINENUMBER 18 L7
aoqi@0 195 ILOAD 11
aoqi@0 196 I2D
aoqi@0 197 ALOAD 12
aoqi@0 198 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D
aoqi@0 199 DMUL
aoqi@0 200 ILOAD 13
aoqi@0 201 I2D
aoqi@0 202 ILOAD 10
aoqi@0 203 I2D
aoqi@0 204 DMUL
aoqi@0 205 DADD
aoqi@0 206 DSTORE 14
aoqi@0 207 L8
aoqi@0 208 LINENUMBER 19 L8
aoqi@0 209 ILOAD 10
aoqi@0 210 I2D
aoqi@0 211 ALOAD 12
aoqi@0 212 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D
aoqi@0 213 DMUL
aoqi@0 214 DLOAD 14
aoqi@0 215 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (D)I
aoqi@0 216 SIPUSH 16383
aoqi@0 217 IAND
aoqi@0 218 BIPUSH 14
aoqi@0 219 ISHL
aoqi@0 220 I2D
aoqi@0 221 DADD
aoqi@0 222 ALOAD 9
aoqi@0 223 ALOAD 4
aoqi@0 224 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 225 // handle kind 0x6 : INVOKESTATIC
aoqi@0 226 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 227 // arguments:
aoqi@0 228 0
aoqi@0 229 ]
aoqi@0 230 INVOKEDYNAMIC ADD:ODO_D(DLjava/lang/Object;)Ljava/lang/Object; [
aoqi@0 231 // handle kind 0x6 : INVOKESTATIC
aoqi@0 232 jdk/nashorn/internal/runtime/linker/Bootstrap.runtimeBootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;)
aoqi@0 233 // arguments: none
aoqi@0 234 ]
aoqi@0 235 ALOAD 5
aoqi@0 236 INVOKEDYNAMIC ADD:OOO_I(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 237 // handle kind 0x6 : INVOKESTATIC
aoqi@0 238 jdk/nashorn/internal/runtime/linker/Bootstrap.runtimeBootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;)
aoqi@0 239 // arguments: none
aoqi@0 240 ]
aoqi@0 241 ASTORE 12
aoqi@0 242 L9
aoqi@0 243 LINENUMBER 20 L9
aoqi@0 244 ALOAD 12
aoqi@0 245 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I
aoqi@0 246 BIPUSH 28
aoqi@0 247 ISHR
aoqi@0 248 I2D
aoqi@0 249 DLOAD 14
aoqi@0 250 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (D)I
aoqi@0 251 BIPUSH 14
aoqi@0 252 ISHR
aoqi@0 253 I2D
aoqi@0 254 DADD
aoqi@0 255 ILOAD 11
aoqi@0 256 I2D
aoqi@0 257 ILOAD 13
aoqi@0 258 I2D
aoqi@0 259 DMUL
aoqi@0 260 DADD
aoqi@0 261 INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double;
aoqi@0 262 ASTORE 5
aoqi@0 263 L10
aoqi@0 264 LINENUMBER 21 L10
aoqi@0 265 ALOAD 9
aoqi@0 266 ALOAD 4
aoqi@0 267 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D
aoqi@0 268 DUP2
aoqi@0 269 DCONST_1
aoqi@0 270 DADD
aoqi@0 271 INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double;
aoqi@0 272 ASTORE 4
aoqi@0 273 ALOAD 12
aoqi@0 274 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toInt32 (Ljava/lang/Object;)I
aoqi@0 275 LDC 268435455
aoqi@0 276 IAND
aoqi@0 277 INVOKEDYNAMIC dyn:setElem|setProp(Ljava/lang/Object;DI)V [
aoqi@0 278 // handle kind 0x6 : INVOKESTATIC
aoqi@0 279 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 280 // arguments:
aoqi@0 281 0
aoqi@0 282 ]
aoqi@0 283 L4
aoqi@0 284 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] []
aoqi@0 285 ALOAD 6
aoqi@0 286 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.toNumber (Ljava/lang/Object;)D
aoqi@0 287 LDC -1.0
aoqi@0 288 DADD
aoqi@0 289 DUP2
aoqi@0 290 INVOKESTATIC java/lang/Double.valueOf (D)Ljava/lang/Double;
aoqi@0 291 ASTORE 6
aoqi@0 292 DCONST_0
aoqi@0 293 DCMPL
aoqi@0 294 IFGE L5
aoqi@0 295 L11
aoqi@0 296 LINENUMBER 24 L11
aoqi@0 297 ALOAD 5
aoqi@0 298 ARETURN
aoqi@0 299
aoqi@0 300 "Optimistic" bytecode that requires invalidation on e.g overflow. Factor
aoqi@0 301 x2-3 speedup:
aoqi@0 302
aoqi@0 303 public static am3(Ljava/lang/Object;IILjava/lang/Object;III)I
aoqi@0 304 L0
aoqi@0 305 LINENUMBER 12 L0
aoqi@0 306 ALOAD 0
aoqi@0 307 INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 308 // handle kind 0x6 : INVOKESTATIC
aoqi@0 309 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 310 // arguments:
aoqi@0 311 0
aoqi@0 312 ]
aoqi@0 313 ASTORE 8
aoqi@0 314 L1
aoqi@0 315 LINENUMBER 13 L1
aoqi@0 316 ALOAD 3
aoqi@0 317 INVOKEDYNAMIC dyn:getProp|getElem|getMethod:array(Ljava/lang/Object;)Ljava/lang/Object; [
aoqi@0 318 // handle kind 0x6 : INVOKESTATIC
aoqi@0 319 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 320 // arguments:
aoqi@0 321 0
aoqi@0 322 ]
aoqi@0 323 ASTORE 9
aoqi@0 324 L2
aoqi@0 325 LINENUMBER 14 L2
aoqi@0 326 ILOAD 2
aoqi@0 327 SIPUSH 16383
aoqi@0 328 IAND
aoqi@0 329 ISTORE 10
aoqi@0 330 ILOAD 2
aoqi@0 331 BIPUSH 14
aoqi@0 332 ISHR
aoqi@0 333 ISTORE 11
aoqi@0 334 L3
aoqi@0 335 LINENUMBER 15 L3
aoqi@0 336 GOTO L4
aoqi@0 337 L5
aoqi@0 338 LINENUMBER 16 L5
aoqi@0 339 FRAME FULL [java/lang/Object I I java/lang/Object I I I T java/lang/Object java/lang/Object I I] []
aoqi@0 340 ALOAD 8
aoqi@0 341 ILOAD 1
aoqi@0 342 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [
aoqi@0 343 // handle kind 0x6 : INVOKESTATIC
aoqi@0 344 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 345 // arguments:
aoqi@0 346 0
aoqi@0 347 ]
aoqi@0 348 SIPUSH 16383
aoqi@0 349 IAND
aoqi@0 350 ISTORE 12
aoqi@0 351 L6
aoqi@0 352 LINENUMBER 17 L6
aoqi@0 353 ALOAD 8
aoqi@0 354 ILOAD 1
aoqi@0 355 DUP
aoqi@0 356 ICONST_1
aoqi@0 357 IADD
aoqi@0 358 ISTORE 1
aoqi@0 359 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [
aoqi@0 360 // handle kind 0x6 : INVOKESTATIC
aoqi@0 361 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 362 // arguments:
aoqi@0 363 0
aoqi@0 364 ]
aoqi@0 365 BIPUSH 14
aoqi@0 366 ISHR
aoqi@0 367 ISTORE 13
aoqi@0 368 L7
aoqi@0 369 LINENUMBER 18 L7
aoqi@0 370 ILOAD 11
aoqi@0 371 ILOAD 12
aoqi@0 372 BIPUSH 8
aoqi@0 373 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I
aoqi@0 374 ILOAD 13
aoqi@0 375 ILOAD 10
aoqi@0 376 BIPUSH 9
aoqi@0 377 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I
aoqi@0 378 IADD
aoqi@0 379 ISTORE 14
aoqi@0 380 L8
aoqi@0 381 LINENUMBER 19 L8
aoqi@0 382 ILOAD 10
aoqi@0 383 ILOAD 12
aoqi@0 384 BIPUSH 11
aoqi@0 385 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I
aoqi@0 386 ILOAD 14
aoqi@0 387 SIPUSH 16383
aoqi@0 388 IAND
aoqi@0 389 BIPUSH 14
aoqi@0 390 ISHL
aoqi@0 391 IADD
aoqi@0 392 ALOAD 9
aoqi@0 393 ILOAD 4
aoqi@0 394 INVOKEDYNAMIC dyn:getElem|getProp|getMethod(Ljava/lang/Object;I)I [
aoqi@0 395 // handle kind 0x6 : INVOKESTATIC
aoqi@0 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;)
aoqi@0 397 // arguments:
aoqi@0 398 0
aoqi@0 399 ]
aoqi@0 400 IADD
aoqi@0 401 ILOAD 5
aoqi@0 402 IADD
aoqi@0 403 ISTORE 12
aoqi@0 404 L9
aoqi@0 405 LINENUMBER 20 L9
aoqi@0 406 ILOAD 12
aoqi@0 407 BIPUSH 28
aoqi@0 408 ISHR
aoqi@0 409 ILOAD 14
aoqi@0 410 BIPUSH 14
aoqi@0 411 ISHR
aoqi@0 412 IADD
aoqi@0 413 ILOAD 11
aoqi@0 414 ILOAD 13
aoqi@0 415 BIPUSH 21
aoqi@0 416 INVOKESTATIC jdk/nashorn/internal/runtime/JSType.mulExact (III)I
aoqi@0 417 IADD
aoqi@0 418 ISTORE 5
aoqi@0 419 L10
aoqi@0 420 LINENUMBER 21 L10
aoqi@0 421 ALOAD 9
aoqi@0 422 ILOAD 4
aoqi@0 423 DUP
aoqi@0 424 ICONST_1
aoqi@0 425 IADD
aoqi@0 426 ISTORE 4
aoqi@0 427 ILOAD 12
aoqi@0 428 LDC 268435455
aoqi@0 429 IAND
aoqi@0 430 INVOKEDYNAMIC dyn:setElem|setProp(Ljava/lang/Object;II)V [
aoqi@0 431 // handle kind 0x6 : INVOKESTATIC
aoqi@0 432 jdk/nashorn/internal/runtime/linker/Bootstrap.bootstrap((Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;I)Ljava/lang/invoke/CallSite;)
aoqi@0 433 // arguments:
aoqi@0 434 0
aoqi@0 435 ]
aoqi@0 436 L4
aoqi@0 437 FRAME SAME
aoqi@0 438 ILOAD 6
aoqi@0 439 ICONST_M1
aoqi@0 440 IADD
aoqi@0 441 DUP
aoqi@0 442 ISTORE 6
aoqi@0 443 ICONST_0
aoqi@0 444 IF_ICMPGE L5
aoqi@0 445 L11
aoqi@0 446 LINENUMBER 24 L11
aoqi@0 447 ILOAD 5
aoqi@0 448 IRETURN
aoqi@0 449
aoqi@0 450
aoqi@0 451 SYSTEM PROPERTY: -Dnashorn.codegen.debug, -Dnashorn.codegen.debug.trace=<x>
aoqi@0 452
aoqi@0 453 See the description of the codegen logger below.
aoqi@0 454
aoqi@0 455
aoqi@0 456 SYSTEM_PROPERTY: -Dnashorn.fields.debug
aoqi@0 457
aoqi@0 458 See the description on the fields logger below.
aoqi@0 459
aoqi@0 460
aoqi@0 461 SYSTEM PROPERTY: -Dnashorn.fields.dual
aoqi@0 462
aoqi@0 463 When this property is true, Nashorn will attempt to use primitive
aoqi@0 464 fields for AccessorProperties (currently just AccessorProperties, not
aoqi@0 465 spill properties). Memory footprint for script objects will increase,
aoqi@0 466 as we need to maintain both a primitive field (a long) as well as an
aoqi@0 467 Object field for the property value. Ints are represented as the 32
aoqi@0 468 low bits of the long fields. Doubles are represented as the
aoqi@0 469 doubleToLongBits of their value. This way a single field can be used
aoqi@0 470 for all primitive types. Packing and unpacking doubles to their bit
aoqi@0 471 representation is intrinsified by the JVM and extremely fast.
aoqi@0 472
aoqi@0 473 While dual fields in theory runs significantly faster than Object
aoqi@0 474 fields due to reduction of boxing and memory allocation overhead,
aoqi@0 475 there is still work to be done to make this a general purpose
aoqi@0 476 solution. Research is ongoing.
aoqi@0 477
aoqi@0 478 In the future, this might complement or be replaced by experimental
aoqi@0 479 feature sun.misc.TaggedArray, which has been discussed on the mlvm
aoqi@0 480 mailing list. TaggedArrays are basically a way to share data space
aoqi@0 481 between primitives and references, and have the GC understand this.
aoqi@0 482
aoqi@0 483 As long as only primitive values are written to the fields and enough
aoqi@0 484 type information exists to make sure that any reads don't have to be
aoqi@0 485 uselessly boxed and unboxed, this is significantly faster than the
aoqi@0 486 standard "Objects only" approach that currently is the default. See
aoqi@0 487 test/examples/dual-fields-micro.js for an example that runs twice as
aoqi@0 488 fast with dual fields as without them. Here, the compiler, can
aoqi@0 489 determine that we are dealing with numbers only throughout the entire
aoqi@0 490 property life span of the properties involved.
aoqi@0 491
aoqi@0 492 If a "real" object (not a boxed primitive) is written to a field that
aoqi@0 493 has a primitive representation, its callsite is relinked and an Object
aoqi@0 494 field is used forevermore for that particular field in that
aoqi@0 495 PropertyMap and its children, even if primitives are later assigned to
aoqi@0 496 it.
aoqi@0 497
aoqi@0 498 As the amount of compile time type information is very small in a
aoqi@0 499 dynamic language like JavaScript, it is frequently the case that
aoqi@0 500 something has to be treated as an object, because we don't know any
aoqi@0 501 better. In reality though, it is often a boxed primitive is stored to
aoqi@0 502 an AccessorProperty. The fastest way to handle this soundly is to use
aoqi@0 503 a callsite typecheck and avoid blowing the field up to an Object. We
aoqi@0 504 never revert object fields to primitives. Ping-pong:ing back and forth
aoqi@0 505 between primitive representation and Object representation would cause
aoqi@0 506 fatal performance overhead, so this is not an option.
aoqi@0 507
aoqi@0 508 For a general application the dual fields approach is still slower
aoqi@0 509 than objects only fields in some places, about the same in most cases,
aoqi@0 510 and significantly faster in very few. This is due the program using
aoqi@0 511 primitives, but we still can't prove it. For example "local_var a =
aoqi@0 512 call(); field = a;" may very well write a double to the field, but the
aoqi@0 513 compiler dare not guess a double type if field is a local variable,
aoqi@0 514 due to bytecode variables being strongly typed and later non
aoqi@0 515 interchangeable. To get around this, the entire method would have to
aoqi@0 516 be replaced and a continuation retained to restart from. We believe
aoqi@0 517 that the next steps we should go through are instead:
aoqi@0 518
aoqi@0 519 1) Implement method specialization based on callsite, as it's quite
aoqi@0 520 frequently the case that numbers are passed around, but currently our
aoqi@0 521 function nodes just have object types visible to the compiler. For
aoqi@0 522 example "var b = 17; func(a,b,17)" is an example where two parameters
aoqi@0 523 can be specialized, but the main version of func might also be called
aoqi@0 524 from another callsite with func(x,y,"string").
aoqi@0 525
aoqi@0 526 2) This requires lazy jitting as the functions have to be specialized
aoqi@0 527 per callsite.
aoqi@0 528
aoqi@0 529 Even though "function square(x) { return x*x }" might look like a
aoqi@0 530 trivial function that can always only take doubles, this is not
aoqi@0 531 true. Someone might have overridden the valueOf for x so that the
aoqi@0 532 toNumber coercion has side effects. To fulfil JavaScript semantics,
aoqi@0 533 the coercion has to run twice for both terms of the multiplication
aoqi@0 534 even if they are the same object. This means that call site
aoqi@0 535 specialization is necessary, not parameter specialization on the form
aoqi@0 536 "function square(x) { var xd = (double)x; return xd*xd; }", as one
aoqi@0 537 might first think.
aoqi@0 538
aoqi@0 539 Generating a method specialization for any variant of a function that
aoqi@0 540 we can determine by types at compile time is a combinatorial explosion
aoqi@0 541 of byte code (try it e.g. on all the variants of am3 in the Octane
aoqi@0 542 benchmark crypto.js). Thus, this needs to be lazy
aoqi@0 543
aoqi@0 544 3) Optimistic callsite writes, something on the form
aoqi@0 545
aoqi@0 546 x = y; //x is a field known to be a primitive. y is only an object as
aoqi@0 547 far as we can tell
aoqi@0 548
aoqi@0 549 turns into
aoqi@0 550
aoqi@0 551 try {
aoqi@0 552 x = (int)y;
aoqi@0 553 } catch (X is not an integer field right now | ClassCastException e) {
aoqi@0 554 x = y;
aoqi@0 555 }
aoqi@0 556
aoqi@0 557 Mini POC shows that this is the key to a lot of dual field performance
aoqi@0 558 in seemingly trivial micros where one unknown object, in reality
aoqi@0 559 actually a primitive, foils it for us. Very common pattern. Once we
aoqi@0 560 are "all primitives", dual fields runs a lot faster than Object fields
aoqi@0 561 only.
aoqi@0 562
aoqi@0 563 We still have to deal with objects vs primitives for local bytecode
aoqi@0 564 slots, possibly through code copying and versioning.
aoqi@0 565
aoqi@0 566 The Future:
aoqi@0 567
aoqi@0 568 We expect the usefulness of dual fields to increase significantly
aoqi@0 569 after the optimistic type system described in the section on
aoqi@0 570 integer arithmetic above is implemented.
aoqi@0 571
aoqi@0 572
aoqi@0 573 SYSTEM PROPERTY: -Dnashorn.compiler.symbol.trace=[<x>[,*]],
aoqi@0 574 -Dnashorn.compiler.symbol.stacktrace=[<x>[,*]]
aoqi@0 575
aoqi@0 576 When this property is set, creation and manipulation of any symbol
aoqi@0 577 named "x" will show information about when the compiler changes its
aoqi@0 578 type assumption, bytecode local variable slot assignment and other
aoqi@0 579 data. This is useful if, for example, a symbol shows up as an Object,
aoqi@0 580 when you believe it should be a primitive. Usually there is an
aoqi@0 581 explanation for this, for example that it exists in the global scope
aoqi@0 582 and type analysis has to be more conservative.
aoqi@0 583
aoqi@0 584 Several symbols names to watch can be specified by comma separation.
aoqi@0 585
aoqi@0 586 If no variable name is specified (and no equals sign), all symbols
aoqi@0 587 will be watched
aoqi@0 588
aoqi@0 589 By using "stacktrace" instead of or together with "trace", stack
aoqi@0 590 traces will be displayed upon symbol changes according to the same
aoqi@0 591 semantics.
aoqi@0 592
aoqi@0 593
aoqi@0 594 SYSTEM PROPERTY: -Dnashorn.lexer.xmlliterals
aoqi@0 595
aoqi@0 596 If this property it set, it means that the Lexer should attempt to
aoqi@0 597 parse XML literals, which would otherwise generate syntax
aoqi@0 598 errors. Warning: there are currently no unit tests for this
aoqi@0 599 functionality.
aoqi@0 600
aoqi@0 601 XML literals, when this is enabled, end up as standard LiteralNodes in
aoqi@0 602 the IR.
aoqi@0 603
aoqi@0 604
aoqi@0 605 SYSTEM_PROPERTY: -Dnashorn.debug
aoqi@0 606
aoqi@0 607 If this property is set to true, Nashorn runs in Debug mode. Debug
aoqi@0 608 mode is slightly slower, as for example statistics counters are enabled
aoqi@0 609 during the run. Debug mode makes available a NativeDebug instance
aoqi@0 610 called "Debug" in the global space that can be used to print property
aoqi@0 611 maps and layout for script objects, as well as a "dumpCounters" method
aoqi@0 612 that will print the current values of the previously mentioned stats
aoqi@0 613 counters.
aoqi@0 614
aoqi@0 615 These functions currently exists for Debug:
aoqi@0 616
aoqi@0 617 "map" - print(Debug.map(x)) will dump the PropertyMap for object x to
aoqi@0 618 stdout (currently there also exist functions called "embedX", where X
aoqi@0 619 is a value from 0 to 3, that will dump the contents of the embed pool
aoqi@0 620 for the first spill properties in any script object and "spill", that
aoqi@0 621 will dump the contents of the growing spill pool of spill properties
aoqi@0 622 in any script object. This is of course subject to change without
aoqi@0 623 notice, should we change the script object layout.
aoqi@0 624
aoqi@0 625 "methodHandle" - this method returns the method handle that is used
aoqi@0 626 for invoking a particular script function.
aoqi@0 627
aoqi@0 628 "identical" - this method compares two script objects for reference
aoqi@0 629 equality. It is a == Java comparison
aoqi@0 630
aoqi@0 631 "dumpCounters" - will dump the debug counters' current values to
aoqi@0 632 stdout.
aoqi@0 633
aoqi@0 634 Currently we count number of ScriptObjects in the system, number of
aoqi@0 635 Scope objects in the system, number of ScriptObject listeners added,
aoqi@0 636 removed and dead (without references).
aoqi@0 637
aoqi@0 638 We also count number of ScriptFunctions, ScriptFunction invocations
aoqi@0 639 and ScriptFunction allocations.
aoqi@0 640
aoqi@0 641 Furthermore we count PropertyMap statistics: how many property maps
aoqi@0 642 exist, how many times were property maps cloned, how many times did
aoqi@0 643 the property map history cache hit, prevent new allocations, how many
aoqi@0 644 prototype invalidations were done, how many time the property map
aoqi@0 645 proto cache hit.
aoqi@0 646
aoqi@0 647 Finally we count callsite misses on a per callsite bases, which occur
aoqi@0 648 when a callsite has to be relinked, due to a previous assumption of
aoqi@0 649 object layout being invalidated.
aoqi@0 650
aoqi@0 651
aoqi@0 652 SYSTEM PROPERTY: -Dnashorn.methodhandles.debug,
aoqi@0 653 -Dnashorn.methodhandles.debug=create
aoqi@0 654
aoqi@0 655 If this property is enabled, each MethodHandle related call that uses
aoqi@0 656 the java.lang.invoke package gets its MethodHandle intercepted and an
aoqi@0 657 instrumentation printout of arguments and return value appended to
aoqi@0 658 it. This shows exactly which method handles are executed and from
aoqi@0 659 where. (Also MethodTypes and SwitchPoints). This can be augmented with
aoqi@0 660 more information, for example, instance count, by subclassing or
aoqi@0 661 further extending the TraceMethodHandleFactory implementation in
aoqi@0 662 MethodHandleFactory.java.
aoqi@0 663
aoqi@0 664 If the property is specialized with "=create" as its option,
aoqi@0 665 instrumentation will be shown for method handles upon creation time
aoqi@0 666 rather than at runtime usage.
aoqi@0 667
aoqi@0 668
aoqi@0 669 SYSTEM PROPERTY: -Dnashorn.methodhandles.debug.stacktrace
aoqi@0 670
aoqi@0 671 This does the same as nashorn.methodhandles.debug, but when enabled
aoqi@0 672 also dumps the stack trace for every instrumented method handle
aoqi@0 673 operation. Warning: This is enormously verbose, but provides a pretty
aoqi@0 674 decent "grep:able" picture of where the calls are coming from.
aoqi@0 675
aoqi@0 676 See the description of the codegen logger below for a more verbose
aoqi@0 677 description of this option
aoqi@0 678
aoqi@0 679
aoqi@0 680 SYSTEM PROPERTY: -Dnashorn.scriptfunction.specialization.disable
aoqi@0 681
aoqi@0 682 There are several "fast path" implementations of constructors and
aoqi@0 683 functions in the NativeObject classes that, in their original form,
aoqi@0 684 take a variable amount of arguments. Said functions are also declared
aoqi@0 685 to take Object parameters in their original form, as this is what the
aoqi@0 686 JavaScript specification mandates.
aoqi@0 687 However, we often know quite a lot more at a callsite of one of these
aoqi@0 688 functions. For example, Math.min is called with a fixed number (2) of
aoqi@0 689 integer arguments. The overhead of boxing these ints to Objects and
aoqi@0 690 folding them into an Object array for the generic varargs Math.min
aoqi@0 691 function is an order of magnitude slower than calling a specialized
aoqi@0 692 implementation of Math.min that takes two integers. Specialized
aoqi@0 693 functions and constructors are identified by the tag
aoqi@0 694 @SpecializedFunction and @SpecializedConstructor in the Nashorn
aoqi@0 695 code. The linker will link in the most appropriate (narrowest types,
aoqi@0 696 right number of types and least number of arguments) specialization if
aoqi@0 697 specializations are available.
aoqi@0 698
aoqi@0 699 Every ScriptFunction may carry specializations that the linker can
aoqi@0 700 choose from. This framework will likely be extended for user defined
aoqi@0 701 functions. The compiler can often infer enough parameter type info
aoqi@0 702 from callsites for in order to generate simpler versions with less
aoqi@0 703 generic Object types. This feature depends on future lazy jitting, as
aoqi@0 704 there tend to be many calls to user defined functions, some where the
aoqi@0 705 callsite can be specialized, some where we mostly see object
aoqi@0 706 parameters even at the callsite.
aoqi@0 707
aoqi@0 708 If this system property is set to true, the linker will not attempt to
aoqi@0 709 use any specialized function or constructor for native objects, but
aoqi@0 710 just call the generic one.
aoqi@0 711
aoqi@0 712
aoqi@0 713 SYSTEM PROPERTY: -Dnashorn.tcs.miss.samplePercent=<x>
aoqi@0 714
aoqi@0 715 When running with the trace callsite option (-tcs), Nashorn will count
aoqi@0 716 and instrument any callsite misses that require relinking. As the
aoqi@0 717 number of relinks is large and usually produces a lot of output, this
aoqi@0 718 system property can be used to constrain the percentage of misses that
aoqi@0 719 should be logged. Typically this is set to 1 or 5 (percent). 1% is the
aoqi@0 720 default value.
aoqi@0 721
aoqi@0 722
aoqi@0 723 SYSTEM_PROPERTY: -Dnashorn.profilefile=<filename>
aoqi@0 724
aoqi@0 725 When running with the profile callsite options (-pcs), Nashorn will
aoqi@0 726 dump profiling data for all callsites to stderr as a shutdown hook. To
aoqi@0 727 instead redirect this to a file, specify the path to the file using
aoqi@0 728 this system property.
aoqi@0 729
aoqi@0 730
aoqi@0 731 SYSTEM_PROPERTY: -Dnashorn.regexp.impl=[jdk|joni]
aoqi@0 732
aoqi@0 733 This property defines the regular expression engine to be used by
aoqi@0 734 Nashorn. Set this flag to "jdk" to get an implementation based on the
aoqi@0 735 JDK's java.util.regex package. Set this property to "joni" to install
aoqi@0 736 an implementation based on Joni, the regular expression engine used by
aoqi@0 737 the JRuby project. The default value for this flag is "joni"
aoqi@0 738
aoqi@0 739
aoqi@0 740 SYSTEM PROPERTY: -Dnashorn.time
aoqi@0 741
aoqi@0 742 This enables timers for various phases of script compilation. The timers
aoqi@0 743 will be dumped when the Nashorn process exits. We see a percentage value
aoqi@0 744 of how much time was spent not executing bytecode (i.e. compilation and
aoqi@0 745 internal tasks) at the end of the report.
aoqi@0 746
aoqi@0 747 Here is an example:
aoqi@0 748
aoqi@0 749 [JavaScript Parsing] 61 ms
aoqi@0 750 [Constant Folding] 11 ms
aoqi@0 751 [Control Flow Lowering] 26 ms
aoqi@0 752 [Type Attribution] 81 ms
aoqi@0 753 [Range Analysis] 0 ms
aoqi@0 754 [Code Splitting] 29 ms
aoqi@0 755 [Type Finalization] 19 ms
aoqi@0 756 [Bytecode Generation] 189 ms
aoqi@0 757 [Code Installation] 7 ms
aoqi@0 758 Total runtime: 508 ms (Non-runtime: 423 ms [83%])
aoqi@0 759
aoqi@0 760 ===============
aoqi@0 761 2. The loggers.
aoqi@0 762 ===============
aoqi@0 763
aoqi@0 764 It is very simple to create your own logger. Use the DebugLogger class
aoqi@0 765 and give the subsystem name as a constructor argument.
aoqi@0 766
aoqi@0 767 The Nashorn loggers can be used to print per-module or per-subsystem
aoqi@0 768 debug information with different levels of verbosity. The loggers for
aoqi@0 769 a given subsystem are available are enabled by using
aoqi@0 770
aoqi@0 771 --log=<systemname>[:<level>]
aoqi@0 772
aoqi@0 773 on the command line.
aoqi@0 774
aoqi@0 775 Here <systemname> identifies the name of the subsystem to be logged
aoqi@0 776 and the optional colon and level argument is a standard
aoqi@0 777 java.util.logging.Level name (severe, warning, info, config, fine,
aoqi@0 778 finer, finest). If the level is left out for a particular subsystem,
aoqi@0 779 it defaults to "info". Any log message logged as the level or a level
aoqi@0 780 that is more important will be output to stderr by the logger.
aoqi@0 781
aoqi@0 782 Several loggers can be enabled by a single command line option, by
aoqi@0 783 putting a comma after each subsystem/level tuple (or each subsystem if
aoqi@0 784 level is unspecified). The --log option can also be given multiple
aoqi@0 785 times on the same command line, with the same effect.
aoqi@0 786
aoqi@0 787 For example: --log=codegen,fields:finest is equivalent to
aoqi@0 788 --log=codegen:info --log=fields:finest
aoqi@0 789
aoqi@0 790 The subsystems that currently support logging are:
aoqi@0 791
aoqi@0 792
aoqi@0 793 * compiler
aoqi@0 794
aoqi@0 795 The compiler is in charge of turning source code and function nodes
aoqi@0 796 into byte code, and installs the classes into a class loader
aoqi@0 797 controlled from the Context. Log messages are, for example, about
aoqi@0 798 things like new compile units being allocated. The compiler has global
aoqi@0 799 settings that all the tiers of codegen (e.g. Lower and CodeGenerator)
aoqi@0 800 use.s
aoqi@0 801
aoqi@0 802
aoqi@0 803 * codegen
aoqi@0 804
aoqi@0 805 The code generator is the emitter stage of the code pipeline, and
aoqi@0 806 turns the lowest tier of a FunctionNode into bytecode. Codegen logging
aoqi@0 807 shows byte codes as they are being emitted, line number information
aoqi@0 808 and jumps. It also shows the contents of the bytecode stack prior to
aoqi@0 809 each instruction being emitted. This is a good debugging aid. For
aoqi@0 810 example:
aoqi@0 811
aoqi@0 812 [codegen] #41 line:2 (f)_afc824e
aoqi@0 813 [codegen] #42 load symbol x slot=2
aoqi@0 814 [codegen] #43 {1:O} load int 0
aoqi@0 815 [codegen] #44 {2:I O} dynamic_runtime_call GT:ZOI_I args=2 returnType=boolean
aoqi@0 816 [codegen] #45 signature (Ljava/lang/Object;I)Z
aoqi@0 817 [codegen] #46 {1:Z} ifeq ternary_false_5402fe28
aoqi@0 818 [codegen] #47 load symbol x slot=2
aoqi@0 819 [codegen] #48 {1:O} goto ternary_exit_107c1f2f
aoqi@0 820 [codegen] #49 ternary_false_5402fe28
aoqi@0 821 [codegen] #50 load symbol x slot=2
aoqi@0 822 [codegen] #51 {1:O} convert object -> double
aoqi@0 823 [codegen] #52 {1:D} neg
aoqi@0 824 [codegen] #53 {1:D} convert double -> object
aoqi@0 825 [codegen] #54 {1:O} ternary_exit_107c1f2f
aoqi@0 826 [codegen] #55 {1:O} return object
aoqi@0 827
aoqi@0 828 shows a ternary node being generated for the sequence "return x > 0 ?
aoqi@0 829 x : -x"
aoqi@0 830
aoqi@0 831 The first number on the log line is a unique monotonically increasing
aoqi@0 832 emission id per bytecode. There is no guarantee this is the same id
aoqi@0 833 between runs. depending on non deterministic code
aoqi@0 834 execution/compilation, but for small applications it usually is. If
aoqi@0 835 the system variable -Dnashorn.codegen.debug.trace=<x> is set, where x
aoqi@0 836 is a bytecode emission id, a stack trace will be shown as the
aoqi@0 837 particular bytecode is about to be emitted. This can be a quick way to
aoqi@0 838 determine where it comes from without attaching the debugger. "Who
aoqi@0 839 generated that neg?"
aoqi@0 840
aoqi@0 841 The --log=codegen option is equivalent to setting the system variable
aoqi@0 842 "nashorn.codegen.debug" to true.
aoqi@0 843
aoqi@0 844 * fold
aoqi@0 845
aoqi@0 846 Shows constant folding taking place before lowering
aoqi@0 847
aoqi@0 848 * lower
aoqi@0 849
aoqi@0 850 This is the first lowering pass.
aoqi@0 851
aoqi@0 852 Lower is a code generation pass that turns high level IR nodes into
aoqi@0 853 lower level one, for example substituting comparisons to RuntimeNodes
aoqi@0 854 and inlining finally blocks.
aoqi@0 855
aoqi@0 856 Lower is also responsible for determining control flow information
aoqi@0 857 like end points.
aoqi@0 858
aoqi@0 859
aoqi@0 860 * attr
aoqi@0 861
aoqi@0 862 The lowering annotates a FunctionNode with symbols for each identifier
aoqi@0 863 and transforms high level constructs into lower level ones, that the
aoqi@0 864 CodeGenerator consumes.
aoqi@0 865
aoqi@0 866 Lower logging typically outputs things like post pass actions,
aoqi@0 867 insertions of casts because symbol types have been changed and type
aoqi@0 868 specialization information. Currently very little info is generated by
aoqi@0 869 this logger. This will probably change.
aoqi@0 870
aoqi@0 871
aoqi@0 872 * finalize
aoqi@0 873
aoqi@0 874 This --log=finalize log option outputs information for type finalization,
aoqi@0 875 the third tier of the compiler. This means things like placement of
aoqi@0 876 specialized scope nodes or explicit conversions.
aoqi@0 877
aoqi@0 878
aoqi@0 879 * fields
aoqi@0 880
aoqi@0 881 The --log=fields option (at info level) is equivalent to setting the
aoqi@0 882 system variable "nashorn.fields.debug" to true. At the info level it
aoqi@0 883 will only show info about type assumptions that were invalidated. If
aoqi@0 884 the level is set to finest, it will also trace every AccessorProperty
aoqi@0 885 getter and setter in the program, show arguments, return values
aoqi@0 886 etc. It will also show the internal representation of respective field
aoqi@0 887 (Object in the normal case, unless running with the dual field
aoqi@0 888 representation)
aoqi@0 889
aoqi@0 890
aoqi@0 891 =======================
aoqi@0 892 3. Undocumented options
aoqi@0 893 =======================
aoqi@0 894
aoqi@0 895 Here follows a short description of undocumented options for Nashorn.
aoqi@0 896 To see a list of all undocumented options, use the (undocumented) flag
aoqi@0 897 "-xhelp".
aoqi@0 898
aoqi@0 899 i.e. jjs -xhelp or java -jar nashorn.jar -xhelp
aoqi@0 900
aoqi@0 901 Undocumented options are not guaranteed to work, run correctly or be
aoqi@0 902 bug free. They are experimental and for internal or debugging use.
aoqi@0 903 They are also subject to change without notice.
aoqi@0 904
aoqi@0 905 In practice, though, all options below not explicitly documented as
aoqi@0 906 EXPERIMENTAL can be relied upon, for example --dump-on-error is useful
aoqi@0 907 for any JavaScript/Nashorn developer, but there is no guarantee.
aoqi@0 908
aoqi@0 909 A short summary follows:
aoqi@0 910
aoqi@0 911 -D (-Dname=value. Set a system property. This option can be repeated.)
aoqi@0 912
aoqi@0 913 -ccs, --class-cache-size (Size of the Class cache size per global scope.)
aoqi@0 914
aoqi@0 915 -cp, -classpath (-cp path. Specify where to find user class files.)
aoqi@0 916
aoqi@0 917 -co, --compile-only (Compile script without running. Exit after compilation)
aoqi@0 918 param: [true|false] default: false
aoqi@0 919
aoqi@0 920 -d, --dump-debug-dir (specify a destination directory to dump class files.
aoqi@0 921 This must be combined with the --compile-only option to work)
aoqi@0 922 param: <path>
aoqi@0 923
aoqi@0 924 --debug-lines (Generate line number table in .class files.)
aoqi@0 925 param: [true|false] default: true
aoqi@0 926
aoqi@0 927 --debug-locals (Generate local variable table in .class files.)
aoqi@0 928 param: [true|false] default: false
aoqi@0 929
aoqi@0 930 -doe, -dump-on-error (Dump a stack trace on errors.)
aoqi@0 931 param: [true|false] default: false
aoqi@0 932
aoqi@0 933 --early-lvalue-error (invalid lvalue expressions should be reported as early errors.)
aoqi@0 934 param: [true|false] default: true
aoqi@0 935
aoqi@0 936 --empty-statements (Preserve empty statements in AST.)
aoqi@0 937 param: [true|false] default: false
aoqi@0 938
aoqi@0 939 -fv, -fullversion (Print full version info of Nashorn.)
aoqi@0 940 param: [true|false] default: false
aoqi@0 941
aoqi@0 942 --function-statement-error (Report an error when function declaration is used as a statement.)
aoqi@0 943 param: [true|false] default: false
aoqi@0 944
aoqi@0 945 --function-statement-warning (Warn when function declaration is used as a statement.)
aoqi@0 946 param: [true|false] default: false
aoqi@0 947
aoqi@0 948 -fx (Launch script as an fx application.)
aoqi@0 949 param: [true|false] default: false
aoqi@0 950
aoqi@0 951 --global-per-engine (Use single Global instance per script engine instance.)
aoqi@0 952 param: [true|false] default: false
aoqi@0 953
aoqi@0 954 -h, -help (Print help for command line flags.)
aoqi@0 955 param: [true|false] default: false
aoqi@0 956
aoqi@0 957 --lazy-compilation (EXPERIMENTAL: Use lazy code generation strategies - do not compile
aoqi@0 958 the entire script at once.)
aoqi@0 959 param: [true|false] default: false
aoqi@0 960
aoqi@0 961 --loader-per-compile (Create a new class loader per compile.)
aoqi@0 962 param: [true|false] default: true
aoqi@0 963
aoqi@0 964 -l, --locale (Set Locale for script execution.)
aoqi@0 965 param: <locale> default: en-US
aoqi@0 966
aoqi@0 967 --log (Enable logging of a given level for a given number of sub systems.
aoqi@0 968 [for example: --log=fields:finest,codegen:info])
aoqi@0 969 param: <module:level>,*
aoqi@0 970
aoqi@0 971 -nj, --no-java (No Java support)
aoqi@0 972 param: [true|false] default: false
aoqi@0 973
aoqi@0 974 -nse, --no-syntax-extensions (No non-standard syntax extensions)
aoqi@0 975 param: [true|false] default: false
aoqi@0 976
aoqi@0 977 -nta, --no-typed-arrays (No Typed arrays support)
aoqi@0 978 param: [true|false] default: false
aoqi@0 979
aoqi@0 980 --parse-only (Parse without compiling.)
aoqi@0 981 param: [true|false] default: false
aoqi@0 982
aoqi@0 983 --print-ast (Print abstract syntax tree.)
aoqi@0 984 param: [true|false] default: false
aoqi@0 985
aoqi@0 986 --print-code (Print bytecode.)
aoqi@0 987 param: [true|false] default: false
aoqi@0 988
aoqi@0 989 --print-lower-ast (Print lowered abstract syntax tree.)
aoqi@0 990 param: [true|false] default: false
aoqi@0 991
aoqi@0 992 --print-lower-parse (Print the parse tree after lowering.)
aoqi@0 993 param: [true|false] default: false
aoqi@0 994
aoqi@0 995 --print-mem-usage (Print memory usage of IR after each compile stage.)
aoqi@0 996 param: [true|false] default: false
aoqi@0 997
aoqi@0 998 --print-no-newline (Print function will not print new line char.)
aoqi@0 999 param: [true|false] default: false
aoqi@0 1000
aoqi@0 1001 --print-parse (Print the parse tree.)
aoqi@0 1002 param: [true|false] default: false
aoqi@0 1003
aoqi@0 1004 --print-symbols (Print the symbol table.)
aoqi@0 1005 param: [true|false] default: false
aoqi@0 1006
aoqi@0 1007 -pcs, --profile-callsites (Dump callsite profile data.)
aoqi@0 1008 param: [true|false] default: false
aoqi@0 1009
aoqi@0 1010 --range-analysis (EXPERIMENTAL: Do range analysis using known compile time types,
aoqi@0 1011 and try to narrow number types)
aoqi@0 1012 param: [true|false] default: false
aoqi@0 1013
aoqi@0 1014 -scripting (Enable scripting features.)
aoqi@0 1015 param: [true|false] default: false
aoqi@0 1016
aoqi@0 1017 --specialize-calls (EXPERIMENTAL: Specialize all or a set of method according
aoqi@0 1018 to callsite parameter types)
aoqi@0 1019 param: [=function_1,...,function_n]
aoqi@0 1020
aoqi@0 1021 --stderr (Redirect stderr to a filename or to another tty, e.g. stdout)
aoqi@0 1022 param: <output console>
aoqi@0 1023
aoqi@0 1024 --stdout (Redirect stdout to a filename or to another tty, e.g. stderr)
aoqi@0 1025 param: <output console>
aoqi@0 1026
aoqi@0 1027 -strict (Run scripts in strict mode.)
aoqi@0 1028 param: [true|false] default: false
aoqi@0 1029
aoqi@0 1030 -t, -timezone (Set timezone for script execution.)
aoqi@0 1031 param: <timezone> default: Europe/Stockholm
aoqi@0 1032
aoqi@0 1033 -tcs, --trace-callsites (Enable callsite trace mode. Options are: miss [trace callsite misses]
aoqi@0 1034 enterexit [trace callsite enter/exit], objects [print object properties])
aoqi@0 1035 param: [=[option,]*]
aoqi@0 1036
aoqi@0 1037 --verify-code (Verify byte code before running.)
aoqi@0 1038 param: [true|false] default: false
aoqi@0 1039
aoqi@0 1040 -v, -version (Print version info of Nashorn.)
aoqi@0 1041 param: [true|false] default: false
aoqi@0 1042
aoqi@0 1043 -xhelp (Print extended help for command line flags.)
aoqi@0 1044 param: [true|false] default: false
aoqi@0 1045

mercurial