nashorn/test/script/basic/NASHORN-627.js
author attila
Thu, 31 Jan 2013 18:34:42 +0100
changeset 16206 83069fa0935b
parent 16151 97c1e756ae1e
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
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
/**
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
 * NASHORN-627 : Make NativeDate fully ECMA compliant
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
 * @test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
 * @option -timezone=Europe/Vienna
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
 * @run
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
// constructor, toString, getTime, toISOString. EXPECTED is from spidermonkey
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
function printDate(d) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
    print(d, d.getTime(), d.toISOString());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    35
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
for (var i = -10; i < 380; i++) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
    printDate(new Date(70, 0, i));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
for (var i = -10; i < 380; i++) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
    printDate(new Date(2011, 0, i, 17, 0, 59));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
for (var i = -10; i < 380; i++) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
    printDate(new Date(2012, 0, i, 12, 30, 10, 500));
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
[
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
    '2012-03-01 09:00',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
    '2012-03-01 08:00 +0000',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
    '2012/03/01 08:00 GMT+0000',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    50
    '03/01/2012, 08:00 AM UT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
    '01 March 12 08:00 +0000',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
    'Mar 01 08:00:00 UT 2012',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
    'Sat, 01-Mar-2012 08:00:00 UT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
    'Sat, 01 Mar 2012 08:00:00 UT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
    'Mar 01 2012 08:00:00 UT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
    'Saturday, 01-Mar-2012 08:00:00 UT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    57
    '01 Mar 2012 08:00 +0000',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    58
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    59
    'Sat, 01-Mar-2012 03:00:00 EST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    60
    'Sat, 01 Mar 2012 03:00:00 EST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
    'Mar 01 2012 03:00:00 EST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
    'Saturday, 01-Mar-2012 03:00:00 EST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
    '01 Mar 2012 03:00 -0500',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
    'Sat, 01-Mar-2012 04:00:00 EDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    66
    'Sat, 01 Mar 2012 04:00:00 EDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    67
    'Mar 01 2012 04:00:00 EDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
    'Saturday, 01-Mar-2012 04:00:00 EDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    69
    '01 Mar 2012 04:00 -0400',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    70
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
    'Sat, 01-Mar-2012 02:00:00 CST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    72
    'Sat, 01 Mar 2012 02:00:00 CST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    73
    'Mar 01 2012 02:00:00 CST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    74
    'Saturday, 01-Mar-2012 02:00:00 CST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    75
    '01 Mar 2012 02:00 -0600',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    76
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    77
    'Sat, 01-Mar-2012 03:00:00 CDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    78
    'Sat, 01 Mar 2012 03:00:00 CDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
    'Mar 01 2012 03:00:00 CDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
    'Saturday, 01-Mar-2012 03:00:00 CDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    81
    '01 Mar 2012 03:00 -0500',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
    'Sat, 01-Mar-2012 01:00:00 MST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
    'Sat, 01 Mar 2012 01:00:00 MST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
    'Mar 01 2012 01:00:00 MST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
    'Saturday, 01-Mar-2012 01:00:00 MST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
    '01 Mar 2012 01:00 -0700',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
    'Sat, 01-Mar-2012 02:00:00 MDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
    'Sat, 01 Mar 2012 02:00:00 MDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    91
    'Mar 01 2012 02:00:00 MDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    92
    'Saturday, 01-Mar-2012 02:00:00 MDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    93
    '01 Mar 2012 02:00 -0600',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    94
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    95
    'Sat, 01-Mar-2012 00:00:00 PST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    96
    'Sat, 01 Mar 2012 00:00:00 PST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
    'Mar 01 2012 00:00:00 PST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    98
    'Saturday, 01-Mar-2012 00:00:00 PST',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    99
    '01 Mar 2012 00:00 -0800',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   100
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   101
    'Sat, 01-Mar-2012 01:00:00 PDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   102
    'Sat, 01 Mar 2012 01:00:00 PDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   103
    'Mar 01 2012 01:00:00 PDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   104
    'Saturday, 01-Mar-2012 01:00:00 PDT',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   105
    '01 Mar 2012 01:00 -0700'
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   106
].forEach(function(s) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   107
    parseDate(s, 1330588800000);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
});
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   109
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   110
[
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   111
    '2012-01-01T08:00:00.000Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   112
    '2012-01-01T08:00:00Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   113
    '2012-01-01T08:00Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   114
    '2012-01T08:00:00.000Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   115
    '2012T08:00:00.000Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   116
    '2012T08:00Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   117
    '2012-01T00:00:00.000-08:00',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   118
    '2012-01T00:00:00.000-08:00'
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   119
].forEach(function(s) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   120
    parseDate(s, 1325404800000);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   121
});
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   122
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   123
[
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   124
    'Mon, 25 Dec 1995 13:30:00 GMT+0430',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   125
    '1995/12/25 13:30 GMT+0430',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   126
    '12/25/1995, 01:30 PM +04:30',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
    'Dec 25 1995 13:30:00 +0430'
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
].forEach(function(s) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
    parseDate(s, 819882000000);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
});
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   132
// invalid iso dates
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   133
[
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   134
    '2000-01-01TZ',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   135
    '2000-01-01T60Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   136
    '2000-01-01T60:60Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
    '2000-01-0108:00Z',
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
    '2000-01-01T08Z'
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
].forEach(function(s) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
        parseDate(s, NaN);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   141
    });
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
// milliseconds
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
parseDate('2012-01T08:00:00.001Z', 1325404800001);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
parseDate('2012-01T08:00:00.099Z', 1325404800099);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   146
parseDate('2012-01T08:00:00.999Z', 1325404800999);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
function parseDate(s, t) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149
    var d = new Date(s.toString());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
    if (d.getTime() == t || (isNaN(d.getTime() && isNaN(t)))) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
        print('ok', d);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
    } else {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
        print('expected', t, 'got', d.getTime());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
    }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
}