nashorn/test/script/basic/scripting.js.EXPECTED
author attila
Thu, 31 Jan 2013 18:34:42 +0100
changeset 16206 83069fa0935b
parent 16196 58f6f046bb5e
child 24778 2ff5d7041566
permissions -rw-r--r--
8006529: Methods always get callee - it should be conditional Summary: This commit streamlines the bytecode function signatures, prologue, local variable use, scope creation, and invocation. It started out quite innocently when we noticed that we always emit __callee__ parameters for all functions even when they are not needed, but it turned out to be quite a deep rabbit hole. In the end, I identified exact conditions when functions need to have a callee parameter, when they need to receive parent scope, when they need to create their own scope, when they need to have variable arity signature, and when they need to have an "arguments" object, and made sure that callee parameters in signatures only show up when they are needed, that parent function's scope is only passed to a child function when it is needed, that the function only creates its own scope when it is needed. In crypto.js, the number of scopes dropped from 446 to 244, and the number of callees dropped from 315 to 145. Reviewed-by: jlaskey, lagergren
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
a normal string
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     2
line 0
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
line 1
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
Here is a long sentence
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
that may extend over 3
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
lines.!!!!
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
Here is a long sentence
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
that may extend over 4
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
lines.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
!!!!
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
This is executed how
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
    <html>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
        <head>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
            <title>Testing</title>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
        </head>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
        <body>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
            <p>This is a test.<p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
        </body>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
    </html>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
8
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
No we don't
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
    23
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
 * published by the Free Software Foundation.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    35
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    46
 * Edit strings test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
 * @test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
 * @option -scripting
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
 * @run
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
# scripting mode - shell style line comment works..
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
var t = "normal";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
print("a ${t} string");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    57
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    58
// JavaScript style line comment works too..
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    59
var i = 0;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    60
print("line ${i++}\nline ${i++}");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
var c = 3;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
print(<<EOD + "!!!!")
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
Here is a long sentence
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
that may extend over ${c}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    66
lines.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    67
EOD
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    69
c = 4;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    70
print(<<<EOD + "!!!!")
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
Here is a long sentence
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    72
that may extend over ${c}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    73
lines.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    74
EOD
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    75
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    76
eval(<<BRAINTEASER);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    77
print("This is executed how");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    78
BRAINTEASER
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
print(<<HTML);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    81
    <html>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
        <head>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
            <title>Testing</title>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
        </head>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
        <body>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
            <p>This is a test.<p>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
        </body>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
    </html>
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
HTML
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    91
var x = 1
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    92
<<
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    93
3;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    94
print(x);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    95
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    96
var y = <<EOD;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
There we go
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    98
EOD y = "No we don't";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    99
print(y);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   100
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   101
16196
58f6f046bb5e 8006983: Introduce a command line option to switch off syntactic extensions of nashorn
sundar
parents: 16151
diff changeset
   102
print(readFully(__FILE__));
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   103