-
Sub-task
-
Resolution: Fixed
-
P4
-
9.1
-
None
-
generic
-
generic
function f(v) {
switch(v) {
case 0:
case 1:
return "zero-or-one";
default:
return "other"
}
}
Expected: switch is marked as terminal (inspect generated bytecode)
Print lower AST output from jdk9-dev nashorn:
Lower AST for: ':program'
[function root function @0x01d415d9]
[block <scope> body function @0x01211155]
[statements[0..3]]
[var statements[0] function @0x00d59286]
[ident>f S name = '{O}f' [f S] (object) @0x01b0d3ed]
[function init { @0x01de5c8c]
[block body { @0x0123a213]
[statements[0..1]]
[switch statements[0] switch @0x00ceda24]
[ident>v (slot=-1 O) expression = '{O}v' [v (slot=-1 O)] (object) @0x001e3708]
[cases[0..3]]
[case cases[0] case @0x011b0d2a]
[literal test = '0' @0x0116af24]
[block body = '' @0x010726a3]
[case cases[1] case [Terminal] @0x009494d8]
[literal test = '1' @0x00e82894]
[block body return [Terminal] @0x01846d2c]
[statements[0..1]]
[return statements[0] return [Terminal] @0x013af739]
[literal expression = '"zero-or-one"' @0x00022d9d]
[case cases[2] default [Terminal] @0x00186a70]
[block body return [Terminal] @0x008ad73b]
[statements[0..1]]
[return statements[0] return [Terminal] @0x009a5fbe]
[literal expression = '"other"' @0x00a3ec6b]
[parameters[0..1]]
[ident>v (slot=-1 O) parameters[0] = '{O}v' [v (slot=-1 O)] (object) @0x01623278]
[expression statements[1] function @0x004041cc]
[binary expression = @0x01ca2dfa]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x0153f538]
[ident>f S rhs = '{O}f' [f S] (object) @0x014593bf]
[return statements[2] function [Terminal] @0x01b4de6a]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x01a18f1b]
Lower AST for: ':program'
[function root function @0x010612ba]
[block <scope> body function @0x0040cd94]
[statements[0..3]]
[var statements[0] function @0x014168b8]
[ident>f S name = '{O}f' [f S] (object) @0x01d94634]
[function init { @0x00a90037]
[block body = '' @0x00294adb]
[parameters[0..1]]
[ident parameters[0] = '{U%}v' @0x00a9f84e]
[expression statements[1] function @0x0130f889]
[binary expression = @0x0188e820]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x01490758]
[ident>f S rhs = '{O}f' [f S] (object) @0x001df177]
[return statements[2] function [Terminal] @0x006fa74d]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x00f08448]
Print lower AST output from jdk8u-dev
Lower AST for: ':program'
[function root function @0x005997b1]
[block <scope> body function @0x00f7c8c1]
[statements[0..3]]
[var statements[0] function @0x01cd6521]
[ident>f S name = '{O}f' [f S] (object) @0x0018298f]
[function init { @0x01f924f5]
[block body { @0x0179bb86]
[statements[0..1]]
[switch statements[0] switch @0x01d66ad3]
[ident>v (slot=-1 O) expression = '{O}v' [v (slot=-1 O)] (object) @0x0111346a]
[cases[0..3]]
[case cases[0] case @0x001e7803]
[literal test = '0' @0x00d59286]
[block body = '' @0x004d6e83]
[case cases[1] case [Terminal] @0x0186f9d5]
[literal test = '1' @0x01e18270]
[block body return [Terminal] @0x00a035a0]
[statements[0..1]]
[return statements[0] return [Terminal] @0x01de5c8c]
[literal expression = '"zero-or-one"' @0x00525845]
[case cases[2] default [Terminal] @0x00da0940]
[block body return [Terminal] @0x01b467e9]
[statements[0..1]]
[return statements[0] return [Terminal] @0x0194d659]
[literal expression = '"other"' @0x00b1d79b]
[parameters[0..1]]
[ident>v (slot=-1 O) parameters[0] = '{O}v' [v (slot=-1 O)] (object) @0x00ceda24]
[expression statements[1] function @0x01a50a4c]
[binary expression = @0x0103f852]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x007c290d]
[ident>f S rhs = '{O}f' [f S] (object) @0x0116af24]
[return statements[2] function [Terminal] @0x00e82894]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x003788f3]
switch(v) {
case 0:
case 1:
return "zero-or-one";
default:
return "other"
}
}
Expected: switch is marked as terminal (inspect generated bytecode)
Print lower AST output from jdk9-dev nashorn:
Lower AST for: ':program'
[function root function @0x01d415d9]
[block <scope> body function @0x01211155]
[statements[0..3]]
[var statements[0] function @0x00d59286]
[ident>f S name = '{O}f' [f S] (object) @0x01b0d3ed]
[function init { @0x01de5c8c]
[block body { @0x0123a213]
[statements[0..1]]
[switch statements[0] switch @0x00ceda24]
[ident>v (slot=-1 O) expression = '{O}v' [v (slot=-1 O)] (object) @0x001e3708]
[cases[0..3]]
[case cases[0] case @0x011b0d2a]
[literal test = '0' @0x0116af24]
[block body = '' @0x010726a3]
[case cases[1] case [Terminal] @0x009494d8]
[literal test = '1' @0x00e82894]
[block body return [Terminal] @0x01846d2c]
[statements[0..1]]
[return statements[0] return [Terminal] @0x013af739]
[literal expression = '"zero-or-one"' @0x00022d9d]
[case cases[2] default [Terminal] @0x00186a70]
[block body return [Terminal] @0x008ad73b]
[statements[0..1]]
[return statements[0] return [Terminal] @0x009a5fbe]
[literal expression = '"other"' @0x00a3ec6b]
[parameters[0..1]]
[ident>v (slot=-1 O) parameters[0] = '{O}v' [v (slot=-1 O)] (object) @0x01623278]
[expression statements[1] function @0x004041cc]
[binary expression = @0x01ca2dfa]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x0153f538]
[ident>f S rhs = '{O}f' [f S] (object) @0x014593bf]
[return statements[2] function [Terminal] @0x01b4de6a]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x01a18f1b]
Lower AST for: ':program'
[function root function @0x010612ba]
[block <scope> body function @0x0040cd94]
[statements[0..3]]
[var statements[0] function @0x014168b8]
[ident>f S name = '{O}f' [f S] (object) @0x01d94634]
[function init { @0x00a90037]
[block body = '' @0x00294adb]
[parameters[0..1]]
[ident parameters[0] = '{U%}v' @0x00a9f84e]
[expression statements[1] function @0x0130f889]
[binary expression = @0x0188e820]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x01490758]
[ident>f S rhs = '{O}f' [f S] (object) @0x001df177]
[return statements[2] function [Terminal] @0x006fa74d]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x00f08448]
Print lower AST output from jdk8u-dev
Lower AST for: ':program'
[function root function @0x005997b1]
[block <scope> body function @0x00f7c8c1]
[statements[0..3]]
[var statements[0] function @0x01cd6521]
[ident>f S name = '{O}f' [f S] (object) @0x0018298f]
[function init { @0x01f924f5]
[block body { @0x0179bb86]
[statements[0..1]]
[switch statements[0] switch @0x01d66ad3]
[ident>v (slot=-1 O) expression = '{O}v' [v (slot=-1 O)] (object) @0x0111346a]
[cases[0..3]]
[case cases[0] case @0x001e7803]
[literal test = '0' @0x00d59286]
[block body = '' @0x004d6e83]
[case cases[1] case [Terminal] @0x0186f9d5]
[literal test = '1' @0x01e18270]
[block body return [Terminal] @0x00a035a0]
[statements[0..1]]
[return statements[0] return [Terminal] @0x01de5c8c]
[literal expression = '"zero-or-one"' @0x00525845]
[case cases[2] default [Terminal] @0x00da0940]
[block body return [Terminal] @0x01b467e9]
[statements[0..1]]
[return statements[0] return [Terminal] @0x0194d659]
[literal expression = '"other"' @0x00b1d79b]
[parameters[0..1]]
[ident>v (slot=-1 O) parameters[0] = '{O}v' [v (slot=-1 O)] (object) @0x00ceda24]
[expression statements[1] function @0x01a50a4c]
[binary expression = @0x0103f852]
[ident>:return (slot=-1 O) lhs = '{O}:return' [:return (slot=-1 O)] (object) @0x007c290d]
[ident>f S rhs = '{O}f' [f S] (object) @0x0116af24]
[return statements[2] function [Terminal] @0x00e82894]
[ident>:return (slot=-1 O) expression = '{O}:return' [:return (slot=-1 O)] (object) @0x003788f3]