diff --git a/std/assembly/date.ts b/std/assembly/date.ts index 53d83c4476..230f995c6d 100644 --- a/std/assembly/date.ts +++ b/std/assembly/date.ts @@ -168,10 +168,10 @@ export class Date { this.setTime(i64(daysSinceEpoch(this.year, this.month, day)) * MILLIS_PER_DAY + ms); } - setUTCMonth(month: i32): void { - if (this.month == month) return; + setUTCMonth(month: i32, day: i32 = this.day): void { + if (this.month == month + 1) return; var ms = euclidRem(this.epochMillis, MILLIS_PER_DAY); - this.setTime(i64(daysSinceEpoch(this.year, month + 1, this.day)) * MILLIS_PER_DAY + ms); + this.setTime(i64(daysSinceEpoch(this.year, month + 1, day)) * MILLIS_PER_DAY + ms); } setUTCFullYear(year: i32): void { diff --git a/std/assembly/index.d.ts b/std/assembly/index.d.ts index d51ebf5c91..7a6cc9e7e5 100644 --- a/std/assembly/index.d.ts +++ b/std/assembly/index.d.ts @@ -1887,7 +1887,7 @@ declare class Date { getUTCMilliseconds(): i32; setUTCFullYear(value: i32): void; - setUTCMonth(value: i32): void; + setUTCMonth(value: i32, day?: i32): void; setUTCDate(value: i32): void; setUTCHours(value: i32): void; setUTCMinutes(value: i32): void; diff --git a/tests/compiler/std/date.debug.wat b/tests/compiler/std/date.debug.wat index 2eaa891b49..59f9c2984d 100644 --- a/tests/compiler/std/date.debug.wat +++ b/tests/compiler/std/date.debug.wat @@ -35,6 +35,7 @@ (global $~lib/rt/itcms/fromSpace (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) (global $~lib/native/ASC_LOW_MEMORY_LIMIT i32 (i32.const 0)) + (global $~argumentsLength (mut i32) (i32.const 0)) (global $~lib/native/ASC_SHRINK_LEVEL i32 (i32.const 0)) (global $~lib/builtins/i32.MAX_VALUE i32 (i32.const 2147483647)) (global $~lib/native/ASC_RUNTIME i32 (i32.const 2)) @@ -2742,57 +2743,78 @@ call $~lib/date/Date#setTime drop ) - (func $~lib/date/Date#setUTCMonth (param $0 i32) (param $1 i32) - (local $2 i64) + (func $~lib/date/Date#setUTCMonth (param $0 i32) (param $1 i32) (param $2 i32) (local $3 i64) (local $4 i64) (local $5 i64) + (local $6 i64) local.get $0 i32.load offset=4 local.get $1 + i32.const 1 + i32.add i32.eq if return end local.get $0 i64.load offset=16 - local.set $3 + local.set $4 i32.const 86400000 i64.extend_i32_s - local.set $2 + local.set $3 + local.get $4 local.get $3 - local.get $2 i64.rem_s - local.set $4 - local.get $4 - local.get $4 + local.set $5 + local.get $5 + local.get $5 i64.const 0 i64.lt_s if (result i64) - local.get $2 + local.get $3 else i64.const 0 end i64.add - local.set $5 + local.set $6 local.get $0 local.get $0 i32.load local.get $1 i32.const 1 i32.add - local.get $0 - i32.load offset=8 + local.get $2 call $~lib/date/daysSinceEpoch i64.extend_i32_s i32.const 86400000 i64.extend_i32_s i64.mul - local.get $5 + local.get $6 i64.add call $~lib/date/Date#setTime drop ) + (func $~lib/date/Date#setUTCMonth@varargs (param $0 i32) (param $1 i32) (param $2 i32) + block $1of1 + block $0of1 + block $outOfRange + global.get $~argumentsLength + i32.const 1 + i32.sub + br_table $0of1 $1of1 $outOfRange + end + unreachable + end + local.get $0 + i32.load offset=8 + local.set $2 + end + local.get $0 + local.get $1 + local.get $2 + call $~lib/date/Date#setUTCMonth + ) (func $~lib/date/Date#setUTCFullYear (param $0 i32) (param $1 i32) (local $2 i64) (local $3 i64) @@ -7258,8 +7280,11 @@ i32.const 30 call $~lib/date/Date#setUTCDate local.get $1 + i32.const 0 i32.const 1 - call $~lib/date/Date#setUTCMonth + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs local.get $1 i32.const 1 call $~lib/date/Date#setUTCDate @@ -7270,8 +7295,28 @@ i32.const 2024 call $~lib/date/Date#setUTCFullYear local.get $1 + i32.const 1 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $1 + local.set $3 + local.get $3 + i32.load offset=4 + i32.const 1 + i32.sub i32.const 2 - call $~lib/date/Date#setUTCMonth + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 141 + i32.const 3 + call $~lib/builtins/abort + unreachable + end local.get $1 i32.const 1 call $~lib/date/Date#setUTCDate @@ -7279,23 +7324,46 @@ i32.const 29 call $~lib/date/Date#setUTCDate local.get $1 - local.set $3 - local.get $3 + i32.const 1 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $1 + local.set $2 + local.get $2 i64.load offset=16 - i64.const 1711674191274 + i64.const 1709168591274 i64.eq i32.eqz if i32.const 0 i32.const 128 - i32.const 144 + i32.const 146 i32.const 3 call $~lib/builtins/abort unreachable end local.get $1 - local.set $2 - local.get $2 + local.set $0 + local.get $0 + i32.load offset=4 + i32.const 1 + i32.sub + i32.const 1 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 147 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $1 + local.set $6 + local.get $6 i32.load offset=8 i32.const 29 i32.eq @@ -7303,7 +7371,7 @@ if i32.const 0 i32.const 128 - i32.const 145 + i32.const 148 i32.const 3 call $~lib/builtins/abort unreachable @@ -7316,7 +7384,7 @@ if i32.const 0 i32.const 128 - i32.const 146 + i32.const 149 i32.const 3 call $~lib/builtins/abort unreachable @@ -7329,7 +7397,7 @@ if i32.const 0 i32.const 128 - i32.const 147 + i32.const 150 i32.const 3 call $~lib/builtins/abort unreachable @@ -7342,7 +7410,7 @@ if i32.const 0 i32.const 128 - i32.const 148 + i32.const 151 i32.const 3 call $~lib/builtins/abort unreachable @@ -7357,8 +7425,8 @@ i32.const 20 call $~lib/date/Date#setUTCDate local.get $1 - local.set $0 - local.get $0 + local.set $5 + local.get $5 i64.load offset=16 i64.const 1363748399999 i64.eq @@ -7366,7 +7434,7 @@ if i32.const 0 i32.const 128 - i32.const 152 + i32.const 155 i32.const 3 call $~lib/builtins/abort unreachable @@ -7375,8 +7443,8 @@ i32.const 1 call $~lib/date/Date#setUTCDate local.get $1 - local.set $6 - local.get $6 + local.set $4 + local.get $4 i64.load offset=16 i64.const 1362106799999 i64.eq @@ -7384,7 +7452,7 @@ if i32.const 0 i32.const 128 - i32.const 154 + i32.const 157 i32.const 3 call $~lib/builtins/abort unreachable @@ -7393,8 +7461,8 @@ i32.const 1000 call $~lib/date/Date#setUTCMilliseconds local.get $1 - local.set $5 - local.get $5 + local.set $3 + local.get $3 i64.load offset=16 i64.const 1362106800000 i64.eq @@ -7402,7 +7470,7 @@ if i32.const 0 i32.const 128 - i32.const 157 + i32.const 160 i32.const 3 call $~lib/builtins/abort unreachable @@ -7415,8 +7483,8 @@ i32.mul call $~lib/date/Date#setUTCMilliseconds local.get $1 - local.set $4 - local.get $4 + local.set $2 + local.get $2 i64.load offset=16 i64.const 1362110400000 i64.eq @@ -7424,7 +7492,7 @@ if i32.const 0 i32.const 128 - i32.const 160 + i32.const 163 i32.const 3 call $~lib/builtins/abort unreachable @@ -7439,8 +7507,8 @@ i32.add call $~lib/date/Date#setUTCMilliseconds local.get $1 - local.set $3 - local.get $3 + local.set $0 + local.get $0 i64.load offset=16 i64.const 1362114000001 i64.eq @@ -7448,7 +7516,7 @@ if i32.const 0 i32.const 128 - i32.const 163 + i32.const 166 i32.const 3 call $~lib/builtins/abort unreachable @@ -7463,8 +7531,8 @@ i32.add call $~lib/date/Date#setUTCMilliseconds local.get $1 - local.set $2 - local.get $2 + local.set $6 + local.get $6 i64.load offset=16 i64.const 1362117600001 i64.eq @@ -7472,7 +7540,7 @@ if i32.const 0 i32.const 128 - i32.const 166 + i32.const 169 i32.const 3 call $~lib/builtins/abort unreachable @@ -7487,8 +7555,8 @@ i32.const -2208 call $~lib/date/Date#setUTCDate local.get $1 - local.set $0 - local.get $0 + local.set $5 + local.get $5 i64.load offset=16 i64.const -67301808726 i64.eq @@ -7496,7 +7564,7 @@ if i32.const 0 i32.const 128 - i32.const 170 + i32.const 173 i32.const 3 call $~lib/builtins/abort unreachable @@ -7511,8 +7579,8 @@ i32.const 2208 call $~lib/date/Date#setUTCDate local.get $1 - local.set $6 - local.get $6 + local.set $4 + local.get $4 i64.load offset=16 i64.const 314240591274 i64.eq @@ -7520,7 +7588,7 @@ if i32.const 0 i32.const 128 - i32.const 174 + i32.const 177 i32.const 3 call $~lib/builtins/abort unreachable @@ -7529,13 +7597,13 @@ i32.const 0 i64.const 1467763200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 i32.load - local.get $5 + local.get $3 i32.load offset=4 - local.get $5 + local.get $3 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 3 @@ -7544,7 +7612,7 @@ if i32.const 0 i32.const 128 - i32.const 184 + i32.const 187 i32.const 3 call $~lib/builtins/abort unreachable @@ -7555,13 +7623,13 @@ i64.const 1 i64.sub call $~lib/date/Date#constructor - local.tee $4 + local.tee $2 i32.store offset=8 - local.get $4 + local.get $2 i32.load - local.get $4 + local.get $2 i32.load offset=4 - local.get $4 + local.get $2 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 2 @@ -7570,7 +7638,7 @@ if i32.const 0 i32.const 128 - i32.const 185 + i32.const 188 i32.const 3 call $~lib/builtins/abort unreachable @@ -7583,13 +7651,13 @@ i64.const 1 i64.sub call $~lib/date/Date#constructor - local.tee $3 + local.tee $0 i32.store offset=12 - local.get $3 + local.get $0 i32.load - local.get $3 + local.get $0 i32.load offset=4 - local.get $3 + local.get $0 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 3 @@ -7598,7 +7666,7 @@ if i32.const 0 i32.const 128 - i32.const 186 + i32.const 189 i32.const 3 call $~lib/builtins/abort unreachable @@ -7609,13 +7677,13 @@ i64.const 86400000 i64.add call $~lib/date/Date#constructor - local.tee $2 + local.tee $6 i32.store offset=16 - local.get $2 + local.get $6 i32.load - local.get $2 + local.get $6 i32.load offset=4 - local.get $2 + local.get $6 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 4 @@ -7624,7 +7692,7 @@ if i32.const 0 i32.const 128 - i32.const 187 + i32.const 190 i32.const 3 call $~lib/builtins/abort unreachable @@ -7633,13 +7701,13 @@ i32.const 0 i64.const 1468022400000 call $~lib/date/Date#constructor - local.tee $0 + local.tee $5 i32.store offset=20 - local.get $0 + local.get $5 i32.load - local.get $0 + local.get $5 i32.load offset=4 - local.get $0 + local.get $5 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 6 @@ -7648,7 +7716,7 @@ if i32.const 0 i32.const 128 - i32.const 189 + i32.const 192 i32.const 3 call $~lib/builtins/abort unreachable @@ -7659,13 +7727,13 @@ i64.const 1 i64.sub call $~lib/date/Date#constructor - local.tee $6 + local.tee $4 i32.store offset=24 - local.get $6 + local.get $4 i32.load - local.get $6 + local.get $4 i32.load offset=4 - local.get $6 + local.get $4 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 5 @@ -7674,7 +7742,7 @@ if i32.const 0 i32.const 128 - i32.const 190 + i32.const 193 i32.const 3 call $~lib/builtins/abort unreachable @@ -7702,7 +7770,7 @@ if i32.const 0 i32.const 128 - i32.const 191 + i32.const 194 i32.const 3 call $~lib/builtins/abort unreachable @@ -7713,13 +7781,13 @@ i64.const 86400000 i64.add call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 i32.load - local.get $5 + local.get $3 i32.load offset=4 - local.get $5 + local.get $3 i32.load offset=8 call $~lib/date/dayOfWeek i32.const 0 @@ -7728,7 +7796,7 @@ if i32.const 0 i32.const 128 - i32.const 192 + i32.const 195 i32.const 3 call $~lib/builtins/abort unreachable @@ -7737,11 +7805,11 @@ i32.const 0 i64.const 7899943856218720 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $4 - local.get $4 + local.get $3 + local.set $2 + local.get $2 i32.load offset=4 i32.const 1 i32.sub @@ -7751,17 +7819,20 @@ if i32.const 0 i32.const 128 - i32.const 198 + i32.const 201 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 i32.const 10 - call $~lib/date/Date#setUTCMonth - local.get $5 - local.set $3 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs local.get $3 + local.set $0 + local.get $0 i32.load offset=4 i32.const 1 i32.sub @@ -7771,17 +7842,20 @@ if i32.const 0 i32.const 128 - i32.const 200 + i32.const 203 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 i32.const 2 - call $~lib/date/Date#setUTCMonth - local.get $5 - local.set $2 - local.get $2 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $3 + local.set $6 + local.get $6 i32.load offset=4 i32.const 1 i32.sub @@ -7791,14 +7865,14 @@ if i32.const 0 i32.const 128 - i32.const 202 + i32.const 205 i32.const 3 call $~lib/builtins/abort unreachable end + local.get $3 + local.set $5 local.get $5 - local.set $0 - local.get $0 i64.load offset=16 i64.const 7899941177818720 i64.eq @@ -7806,40 +7880,43 @@ if i32.const 0 i32.const 128 - i32.const 203 + i32.const 206 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 + i32.const 0 i32.const 1 - call $~lib/date/Date#setUTCMonth - local.get $5 - i32.const 12 - call $~lib/date/Date#setUTCMonth - local.get $5 - local.set $6 - local.get $6 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $3 + local.set $4 + local.get $4 i64.load offset=16 - i64.const 7899967616218720 + i64.const 7899936080218720 i64.eq i32.eqz if i32.const 0 i32.const 128 - i32.const 207 + i32.const 209 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 + i32.const 11 + i32.const 1 + global.set $~argumentsLength i32.const 0 - call $~lib/date/Date#setUTCMonth - local.get $5 + call $~lib/date/Date#setUTCMonth@varargs + local.get $3 local.set $1 local.get $1 i64.load offset=16 - i64.const 7899967616218720 + i64.const 7899964937818720 i64.eq i32.eqz if @@ -7850,20 +7927,78 @@ call $~lib/builtins/abort unreachable end + local.get $3 + i32.const -1 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $3 + local.set $2 + local.get $2 + i32.load offset=4 + i32.const 1 + i32.sub + i32.const 11 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 215 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.set $0 + local.get $0 + i64.load offset=16 + i64.const 7899933401818720 + i64.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 216 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $3 + i32.const 12 + i32.const 1 + global.set $~argumentsLength + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs + local.get $3 + local.set $6 + local.get $6 + i32.load offset=4 + i32.const 1 + i32.sub + i32.const 0 + i32.eq + i32.eqz + if + i32.const 0 + i32.const 128 + i32.const 218 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $3 + local.set $5 local.get $5 - i32.const 13 - call $~lib/date/Date#setUTCMonth - local.get $5 - local.set $4 - local.get $4 i64.load offset=16 - i64.const 7900001830618720 + i64.const 7899936080218720 i64.eq i32.eqz if i32.const 0 i32.const 128 - i32.const 213 + i32.const 219 i32.const 3 call $~lib/builtins/abort unreachable @@ -7872,11 +8007,11 @@ i32.const 0 i64.const 7941202527925698 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $3 local.get $3 + local.set $4 + local.get $4 i32.load i32.const 253616 i32.eq @@ -7884,17 +8019,17 @@ if i32.const 0 i32.const 128 - i32.const 219 + i32.const 225 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 i32.const 1976 call $~lib/date/Date#setUTCFullYear - local.get $5 - local.set $2 - local.get $2 + local.get $3 + local.set $1 + local.get $1 i32.load i32.const 1976 i32.eq @@ -7902,17 +8037,17 @@ if i32.const 0 i32.const 128 - i32.const 221 + i32.const 227 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 i32.const 20212 call $~lib/date/Date#setUTCFullYear - local.get $5 - local.set $0 - local.get $0 + local.get $3 + local.set $2 + local.get $2 i32.load i32.const 20212 i32.eq @@ -7920,17 +8055,17 @@ if i32.const 0 i32.const 128 - i32.const 223 + i32.const 229 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 i32.const 71 call $~lib/date/Date#setUTCFullYear - local.get $5 - local.set $6 - local.get $6 + local.get $3 + local.set $0 + local.get $0 i32.load i32.const 71 i32.eq @@ -7938,7 +8073,7 @@ if i32.const 0 i32.const 128 - i32.const 225 + i32.const 231 i32.const 3 call $~lib/builtins/abort unreachable @@ -7947,9 +8082,9 @@ i32.const 0 i64.const -62167219200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -7967,7 +8102,7 @@ if i32.const 0 i32.const 128 - i32.const 231 + i32.const 237 i32.const 3 call $~lib/builtins/abort unreachable @@ -7978,9 +8113,9 @@ i64.const 1 i64.sub call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -7998,7 +8133,7 @@ if i32.const 0 i32.const 128 - i32.const 233 + i32.const 239 i32.const 3 call $~lib/builtins/abort unreachable @@ -8007,9 +8142,9 @@ i32.const 0 i64.const -62127219200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8027,7 +8162,7 @@ if i32.const 0 i32.const 128 - i32.const 235 + i32.const 241 i32.const 3 call $~lib/builtins/abort unreachable @@ -8036,9 +8171,9 @@ i32.const 0 i64.const 1231231231020 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8056,7 +8191,7 @@ if i32.const 0 i32.const 128 - i32.const 237 + i32.const 243 i32.const 3 call $~lib/builtins/abort unreachable @@ -8065,9 +8200,9 @@ i32.const 0 i64.const 1231231231456 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8085,7 +8220,7 @@ if i32.const 0 i32.const 128 - i32.const 239 + i32.const 245 i32.const 3 call $~lib/builtins/abort unreachable @@ -8094,9 +8229,9 @@ i32.const 0 i64.const 322331231231020 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8114,7 +8249,7 @@ if i32.const 0 i32.const 128 - i32.const 241 + i32.const 247 i32.const 3 call $~lib/builtins/abort unreachable @@ -8123,9 +8258,9 @@ i32.const 0 i64.const 253402300799999 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8143,7 +8278,7 @@ if i32.const 0 i32.const 128 - i32.const 243 + i32.const 249 i32.const 3 call $~lib/builtins/abort unreachable @@ -8152,9 +8287,9 @@ i32.const 0 i64.const 253402300800000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8172,7 +8307,7 @@ if i32.const 0 i32.const 128 - i32.const 245 + i32.const 251 i32.const 3 call $~lib/builtins/abort unreachable @@ -8181,9 +8316,9 @@ i32.const 0 i64.const -62847038769226 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8201,7 +8336,7 @@ if i32.const 0 i32.const 128 - i32.const 247 + i32.const 253 i32.const 3 call $~lib/builtins/abort unreachable @@ -8210,9 +8345,9 @@ i32.const 0 i64.const -61536067200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toDateString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8230,7 +8365,7 @@ if i32.const 0 i32.const 128 - i32.const 253 + i32.const 259 i32.const 3 call $~lib/builtins/abort unreachable @@ -8239,9 +8374,9 @@ i32.const 0 i64.const 1580601600000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toDateString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8259,7 +8394,7 @@ if i32.const 0 i32.const 128 - i32.const 255 + i32.const 261 i32.const 3 call $~lib/builtins/abort unreachable @@ -8268,9 +8403,9 @@ i32.const 0 i64.const -62183116800000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toDateString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8288,7 +8423,7 @@ if i32.const 0 i32.const 128 - i32.const 258 + i32.const 264 i32.const 3 call $~lib/builtins/abort unreachable @@ -8297,9 +8432,9 @@ i32.const 0 i64.const -61536067200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toTimeString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8317,7 +8452,7 @@ if i32.const 0 i32.const 128 - i32.const 264 + i32.const 270 i32.const 3 call $~lib/builtins/abort unreachable @@ -8326,9 +8461,9 @@ i32.const 0 i64.const 253402300799999 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toTimeString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8346,7 +8481,7 @@ if i32.const 0 i32.const 128 - i32.const 267 + i32.const 273 i32.const 3 call $~lib/builtins/abort unreachable @@ -8355,9 +8490,9 @@ i32.const 0 i64.const -61536067200000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toUTCString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8375,7 +8510,7 @@ if i32.const 0 i32.const 128 - i32.const 273 + i32.const 279 i32.const 3 call $~lib/builtins/abort unreachable @@ -8384,9 +8519,9 @@ i32.const 0 i64.const 1580741613467 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toUTCString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8404,7 +8539,7 @@ if i32.const 0 i32.const 128 - i32.const 275 + i32.const 281 i32.const 3 call $~lib/builtins/abort unreachable @@ -8413,9 +8548,9 @@ i32.const 0 i64.const -62183116800000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 + local.get $3 call $~lib/date/Date#toUTCString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8433,7 +8568,7 @@ if i32.const 0 i32.const 128 - i32.const 278 + i32.const 284 i32.const 3 call $~lib/builtins/abort unreachable @@ -8446,11 +8581,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $1 - local.get $1 + local.get $3 + local.set $6 + local.get $6 i64.load offset=16 i64.const 192067200000 i64.eq @@ -8458,7 +8593,7 @@ if i32.const 0 i32.const 128 - i32.const 285 + i32.const 291 i32.const 3 call $~lib/builtins/abort unreachable @@ -8471,11 +8606,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 + local.get $3 + local.set $5 local.get $5 - local.set $4 - local.get $4 i64.load offset=16 i64.const 192067200000 i64.eq @@ -8483,7 +8618,7 @@ if i32.const 0 i32.const 128 - i32.const 287 + i32.const 293 i32.const 3 call $~lib/builtins/abort unreachable @@ -8496,11 +8631,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $3 local.get $3 + local.set $4 + local.get $4 i64.load offset=16 i64.const 11860387200000 i64.eq @@ -8508,7 +8643,7 @@ if i32.const 0 i32.const 128 - i32.const 289 + i32.const 295 i32.const 3 call $~lib/builtins/abort unreachable @@ -8521,11 +8656,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $2 - local.get $2 + local.get $3 + local.set $1 + local.get $1 i64.load offset=16 i64.const 192112496000 i64.eq @@ -8533,7 +8668,7 @@ if i32.const 0 i32.const 128 - i32.const 293 + i32.const 299 i32.const 3 call $~lib/builtins/abort unreachable @@ -8546,11 +8681,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $0 - local.get $0 + local.get $3 + local.set $2 + local.get $2 i64.load offset=16 i64.const 192112496456 i64.eq @@ -8558,7 +8693,7 @@ if i32.const 0 i32.const 128 - i32.const 297 + i32.const 303 i32.const 3 call $~lib/builtins/abort unreachable @@ -8571,11 +8706,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $6 - local.get $6 + local.get $3 + local.set $0 + local.get $0 i64.load offset=16 i64.const 192112496456 i64.eq @@ -8583,7 +8718,7 @@ if i32.const 0 i32.const 128 - i32.const 301 + i32.const 307 i32.const 3 call $~lib/builtins/abort unreachable @@ -8596,11 +8731,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $1 - local.get $1 + local.get $3 + local.set $6 + local.get $6 i64.load offset=16 i64.const -62167219200000 i64.eq @@ -8608,7 +8743,7 @@ if i32.const 0 i32.const 128 - i32.const 304 + i32.const 310 i32.const 3 call $~lib/builtins/abort unreachable @@ -8621,11 +8756,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 + local.get $3 + local.set $5 local.get $5 - local.set $4 - local.get $4 i64.load offset=16 i64.const -62135596800000 i64.eq @@ -8633,7 +8768,7 @@ if i32.const 0 i32.const 128 - i32.const 307 + i32.const 313 i32.const 3 call $~lib/builtins/abort unreachable @@ -8646,11 +8781,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $3 local.get $3 + local.set $4 + local.get $4 i64.load offset=16 i64.const 189302400000 i64.eq @@ -8658,7 +8793,7 @@ if i32.const 0 i32.const 128 - i32.const 310 + i32.const 316 i32.const 3 call $~lib/builtins/abort unreachable @@ -8671,11 +8806,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $2 - local.get $2 + local.get $3 + local.set $1 + local.get $1 i64.load offset=16 i64.const 191980800000 i64.eq @@ -8683,7 +8818,7 @@ if i32.const 0 i32.const 128 - i32.const 313 + i32.const 319 i32.const 3 call $~lib/builtins/abort unreachable @@ -8696,11 +8831,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $0 - local.get $0 + local.get $3 + local.set $2 + local.get $2 i64.load offset=16 i64.const 192067200000 i64.eq @@ -8708,7 +8843,7 @@ if i32.const 0 i32.const 128 - i32.const 316 + i32.const 322 i32.const 3 call $~lib/builtins/abort unreachable @@ -8721,11 +8856,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $6 - local.get $6 + local.get $3 + local.set $0 + local.get $0 i64.load offset=16 i64.const 192112440000 i64.eq @@ -8733,7 +8868,7 @@ if i32.const 0 i32.const 128 - i32.const 319 + i32.const 325 i32.const 3 call $~lib/builtins/abort unreachable @@ -8746,11 +8881,11 @@ i32.store offset=28 local.get $8 call $~lib/date/Date.fromString - local.tee $5 + local.tee $3 i32.store offset=4 - local.get $5 - local.set $1 - local.get $1 + local.get $3 + local.set $6 + local.get $6 i64.load offset=16 i64.const 192112496000 i64.eq @@ -8758,7 +8893,7 @@ if i32.const 0 i32.const 128 - i32.const 322 + i32.const 328 i32.const 3 call $~lib/builtins/abort unreachable @@ -8767,17 +8902,17 @@ i32.const 0 i64.const -8640000000000000 call $~lib/date/Date#constructor - local.tee $5 + local.tee $3 i32.store offset=4 global.get $~lib/memory/__stack_pointer i32.const 0 i64.const 8640000000000000 call $~lib/date/Date#constructor - local.tee $1 - i32.store + local.tee $6 + i32.store offset=16 + local.get $3 + local.set $5 local.get $5 - local.set $4 - local.get $4 i64.load offset=16 i64.const -8640000000000000 i64.eq @@ -8785,14 +8920,14 @@ if i32.const 0 i32.const 128 - i32.const 340 + i32.const 346 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $1 - local.set $3 - local.get $3 + local.get $6 + local.set $4 + local.get $4 i64.load offset=16 i64.const 8640000000000000 i64.eq @@ -8800,14 +8935,14 @@ if i32.const 0 i32.const 128 - i32.const 341 + i32.const 347 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 - local.set $2 - local.get $2 + local.get $3 + local.set $1 + local.get $1 i32.load i32.const -271821 i32.eq @@ -8815,14 +8950,14 @@ if i32.const 0 i32.const 128 - i32.const 343 + i32.const 349 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $1 - local.set $0 - local.get $0 + local.get $6 + local.set $2 + local.get $2 i32.load i32.const 275760 i32.eq @@ -8830,14 +8965,14 @@ if i32.const 0 i32.const 128 - i32.const 344 + i32.const 350 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 - local.set $6 - local.get $6 + local.get $3 + local.set $0 + local.get $0 i32.load offset=4 i32.const 1 i32.sub @@ -8847,14 +8982,14 @@ if i32.const 0 i32.const 128 - i32.const 346 + i32.const 352 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $1 - local.set $4 - local.get $4 + local.get $6 + local.set $5 + local.get $5 i32.load offset=4 i32.const 1 i32.sub @@ -8864,14 +8999,14 @@ if i32.const 0 i32.const 128 - i32.const 347 + i32.const 353 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 - local.set $3 local.get $3 + local.set $4 + local.get $4 i32.load offset=8 i32.const 20 i32.eq @@ -8879,14 +9014,14 @@ if i32.const 0 i32.const 128 - i32.const 349 + i32.const 355 i32.const 3 call $~lib/builtins/abort unreachable end + local.get $6 + local.set $1 local.get $1 - local.set $2 - local.get $2 i32.load offset=8 i32.const 13 i32.eq @@ -8894,12 +9029,12 @@ if i32.const 0 i32.const 128 - i32.const 350 + i32.const 356 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $5 + local.get $3 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8917,12 +9052,12 @@ if i32.const 0 i32.const 128 - i32.const 352 + i32.const 358 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $1 + local.get $6 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -8940,7 +9075,7 @@ if i32.const 0 i32.const 128 - i32.const 353 + i32.const 359 i32.const 3 call $~lib/builtins/abort unreachable @@ -8951,19 +9086,19 @@ i64.const 1 i64.sub call $~lib/date/Date#constructor - local.tee $2 - i32.store offset=16 + local.tee $1 + i32.store global.get $~lib/memory/__stack_pointer i32.const 0 i64.const -8640000000000000 i64.const 1 i64.add call $~lib/date/Date#constructor - local.tee $3 - i32.store offset=12 - local.get $3 - local.set $0 - local.get $0 + local.tee $4 + i32.store offset=24 + local.get $4 + local.set $2 + local.get $2 i32.load i32.const -271821 i32.eq @@ -8971,14 +9106,14 @@ if i32.const 0 i32.const 128 - i32.const 358 + i32.const 364 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 - local.set $6 - local.get $6 + local.get $4 + local.set $0 + local.get $0 i32.load offset=4 i32.const 1 i32.sub @@ -8988,14 +9123,14 @@ if i32.const 0 i32.const 128 - i32.const 359 + i32.const 365 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 - local.set $4 local.get $4 + local.set $5 + local.get $5 i32.load offset=8 i32.const 20 i32.eq @@ -9003,12 +9138,12 @@ if i32.const 0 i32.const 128 - i32.const 360 + i32.const 366 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 + local.get $4 call $~lib/date/Date#getUTCHours i32.const 0 i32.eq @@ -9016,12 +9151,12 @@ if i32.const 0 i32.const 128 - i32.const 361 + i32.const 367 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 + local.get $4 call $~lib/date/Date#getUTCMinutes i32.const 0 i32.eq @@ -9029,12 +9164,12 @@ if i32.const 0 i32.const 128 - i32.const 362 + i32.const 368 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 + local.get $4 call $~lib/date/Date#getUTCSeconds i32.const 0 i32.eq @@ -9042,12 +9177,12 @@ if i32.const 0 i32.const 128 - i32.const 363 + i32.const 369 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 + local.get $4 call $~lib/date/Date#getUTCMilliseconds i32.const 1 i32.eq @@ -9055,12 +9190,12 @@ if i32.const 0 i32.const 128 - i32.const 364 + i32.const 370 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $2 + local.get $1 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -9078,12 +9213,12 @@ if i32.const 0 i32.const 128 - i32.const 366 + i32.const 372 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $3 + local.get $4 call $~lib/date/Date#toISOString local.set $8 global.get $~lib/memory/__stack_pointer @@ -9101,7 +9236,7 @@ if i32.const 0 i32.const 128 - i32.const 367 + i32.const 373 i32.const 3 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/date.release.wat b/tests/compiler/std/date.release.wat index 8f122fe148..8c297b3419 100644 --- a/tests/compiler/std/date.release.wat +++ b/tests/compiler/std/date.release.wat @@ -25,6 +25,7 @@ (global $~lib/rt/itcms/white (mut i32) (i32.const 0)) (global $~lib/rt/itcms/fromSpace (mut i32) (i32.const 0)) (global $~lib/rt/tlsf/ROOT (mut i32) (i32.const 0)) + (global $~argumentsLength (mut i32) (i32.const 0)) (global $~lib/memory/__stack_pointer (mut i32) (i32.const 23948)) (global $~started (mut i32) (i32.const 0)) (memory $0 1) @@ -2016,95 +2017,109 @@ i64.add call $~lib/date/Date#setTime ) - (func $~lib/date/Date#setUTCMonth (param $0 i32) (param $1 i32) - (local $2 i64) - (local $3 i32) + (func $~lib/date/Date#setUTCMonth@varargs (param $0 i32) (param $1 i32) + (local $2 i32) + (local $3 i64) (local $4 i32) - local.get $1 - local.get $0 - i32.load offset=4 - i32.eq - if - return + block $1of1 + block $0of1 + block $outOfRange + global.get $~argumentsLength + i32.const 1 + i32.sub + br_table $0of1 $1of1 $outOfRange + end + unreachable + end + local.get $0 + i32.load offset=8 + local.set $2 end local.get $0 - i32.load + i32.load offset=4 local.get $1 i32.const 1 i32.add - local.tee $4 - i32.const 2 - i32.le_s - i32.sub - local.tee $3 - local.get $3 - i32.const 399 - i32.sub - local.get $3 - i32.const 0 - i32.ge_s - select - i32.const 400 - i32.div_s - local.set $1 - local.get $0 - i64.const 86400000 - i64.const 0 - local.get $0 - i64.load offset=16 - i64.const 86400000 - i64.rem_s - local.tee $2 - i64.const 0 - i64.lt_s - select - local.get $2 - i64.add - local.get $0 - i32.load offset=8 - i32.const -3 - i32.const 9 - local.get $4 - i32.const 2 - i32.gt_s - select - local.get $4 - i32.add - i32.const 153 - i32.mul - i32.const 2 - i32.add - i32.const 5 - i32.div_u - i32.add - local.get $3 - local.get $1 - i32.const 400 - i32.mul - i32.sub - local.tee $0 - i32.const 365 - i32.mul - local.get $0 - i32.const 2 - i32.shr_u - i32.add - local.get $0 - i32.const 100 - i32.div_u - i32.sub - i32.add - local.get $1 - i32.const 146097 - i32.mul - i32.add - i32.const 719469 - i32.sub - i64.extend_i32_s - i64.const 86400000 - i64.mul - i64.add - call $~lib/date/Date#setTime + i32.ne + if + local.get $0 + i64.const 86400000 + i64.const 0 + local.get $0 + i64.load offset=16 + i64.const 86400000 + i64.rem_s + local.tee $3 + i64.const 0 + i64.lt_s + select + local.get $3 + i64.add + local.get $0 + i32.load + local.get $1 + i32.const 1 + i32.add + local.tee $1 + i32.const 2 + i32.le_s + i32.sub + local.tee $0 + local.get $0 + i32.const 399 + i32.sub + local.get $0 + i32.const 0 + i32.ge_s + select + i32.const 400 + i32.div_s + local.set $4 + local.get $2 + i32.const -3 + i32.const 9 + local.get $1 + i32.const 2 + i32.gt_s + select + local.get $1 + i32.add + i32.const 153 + i32.mul + i32.const 2 + i32.add + i32.const 5 + i32.div_u + i32.add + local.get $0 + local.get $4 + i32.const 400 + i32.mul + i32.sub + local.tee $0 + i32.const 365 + i32.mul + local.get $0 + i32.const 2 + i32.shr_u + i32.add + local.get $0 + i32.const 100 + i32.div_u + i32.sub + i32.add + local.get $4 + i32.const 146097 + i32.mul + i32.add + i32.const 719469 + i32.sub + i64.extend_i32_s + i64.const 86400000 + i64.mul + i64.add + call $~lib/date/Date#setTime + end ) (func $~lib/date/Date#setUTCFullYear (param $0 i32) (param $1 i32) (local $2 i64) @@ -5923,9 +5938,11 @@ local.get $0 i32.const 30 call $~lib/date/Date#setUTCDate - local.get $0 i32.const 1 - call $~lib/date/Date#setUTCMonth + global.set $~argumentsLength + local.get $0 + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i32.const 1 call $~lib/date/Date#setUTCDate @@ -5935,23 +5952,54 @@ local.get $0 i32.const 2024 call $~lib/date/Date#setUTCFullYear + i32.const 1 + global.set $~argumentsLength local.get $0 - i32.const 2 - call $~lib/date/Date#setUTCMonth + i32.const 1 + call $~lib/date/Date#setUTCMonth@varargs + local.get $0 + i32.load offset=4 + i32.const 3 + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 141 + i32.const 3 + call $~lib/builtins/abort + unreachable + end local.get $0 i32.const 1 call $~lib/date/Date#setUTCDate local.get $0 i32.const 29 call $~lib/date/Date#setUTCDate + i32.const 1 + global.set $~argumentsLength + local.get $0 + i32.const 1 + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i64.load offset=16 - i64.const 1711674191274 + i64.const 1709168591274 i64.ne if i32.const 0 i32.const 1152 - i32.const 144 + i32.const 146 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i32.load offset=4 + i32.const 2 + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 147 i32.const 3 call $~lib/builtins/abort unreachable @@ -5963,7 +6011,7 @@ if i32.const 0 i32.const 1152 - i32.const 145 + i32.const 148 i32.const 3 call $~lib/builtins/abort unreachable @@ -5988,7 +6036,7 @@ if i32.const 0 i32.const 1152 - i32.const 146 + i32.const 149 i32.const 3 call $~lib/builtins/abort unreachable @@ -6013,7 +6061,7 @@ if i32.const 0 i32.const 1152 - i32.const 147 + i32.const 150 i32.const 3 call $~lib/builtins/abort unreachable @@ -6036,7 +6084,7 @@ if i32.const 0 i32.const 1152 - i32.const 148 + i32.const 151 i32.const 3 call $~lib/builtins/abort unreachable @@ -6056,7 +6104,7 @@ if i32.const 0 i32.const 1152 - i32.const 152 + i32.const 155 i32.const 3 call $~lib/builtins/abort unreachable @@ -6071,7 +6119,7 @@ if i32.const 0 i32.const 1152 - i32.const 154 + i32.const 157 i32.const 3 call $~lib/builtins/abort unreachable @@ -6086,7 +6134,7 @@ if i32.const 0 i32.const 1152 - i32.const 157 + i32.const 160 i32.const 3 call $~lib/builtins/abort unreachable @@ -6101,7 +6149,7 @@ if i32.const 0 i32.const 1152 - i32.const 160 + i32.const 163 i32.const 3 call $~lib/builtins/abort unreachable @@ -6116,7 +6164,7 @@ if i32.const 0 i32.const 1152 - i32.const 163 + i32.const 166 i32.const 3 call $~lib/builtins/abort unreachable @@ -6131,7 +6179,7 @@ if i32.const 0 i32.const 1152 - i32.const 166 + i32.const 169 i32.const 3 call $~lib/builtins/abort unreachable @@ -6151,7 +6199,7 @@ if i32.const 0 i32.const 1152 - i32.const 170 + i32.const 173 i32.const 3 call $~lib/builtins/abort unreachable @@ -6171,7 +6219,7 @@ if i32.const 0 i32.const 1152 - i32.const 174 + i32.const 177 i32.const 3 call $~lib/builtins/abort unreachable @@ -6244,7 +6292,7 @@ if i32.const 0 i32.const 1152 - i32.const 184 + i32.const 187 i32.const 3 call $~lib/builtins/abort unreachable @@ -6317,7 +6365,7 @@ if i32.const 0 i32.const 1152 - i32.const 185 + i32.const 188 i32.const 3 call $~lib/builtins/abort unreachable @@ -6390,7 +6438,7 @@ if i32.const 0 i32.const 1152 - i32.const 186 + i32.const 189 i32.const 3 call $~lib/builtins/abort unreachable @@ -6463,7 +6511,7 @@ if i32.const 0 i32.const 1152 - i32.const 187 + i32.const 190 i32.const 3 call $~lib/builtins/abort unreachable @@ -6536,7 +6584,7 @@ if i32.const 0 i32.const 1152 - i32.const 189 + i32.const 192 i32.const 3 call $~lib/builtins/abort unreachable @@ -6609,7 +6657,7 @@ if i32.const 0 i32.const 1152 - i32.const 190 + i32.const 193 i32.const 3 call $~lib/builtins/abort unreachable @@ -6682,7 +6730,7 @@ if i32.const 0 i32.const 1152 - i32.const 191 + i32.const 194 i32.const 3 call $~lib/builtins/abort unreachable @@ -6753,7 +6801,7 @@ if i32.const 0 i32.const 1152 - i32.const 192 + i32.const 195 i32.const 3 call $~lib/builtins/abort unreachable @@ -6770,14 +6818,16 @@ if i32.const 0 i32.const 1152 - i32.const 198 + i32.const 201 i32.const 3 call $~lib/builtins/abort unreachable end + i32.const 1 + global.set $~argumentsLength local.get $0 i32.const 10 - call $~lib/date/Date#setUTCMonth + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i32.load offset=4 i32.const 11 @@ -6785,14 +6835,16 @@ if i32.const 0 i32.const 1152 - i32.const 200 + i32.const 203 i32.const 3 call $~lib/builtins/abort unreachable end + i32.const 1 + global.set $~argumentsLength local.get $0 i32.const 2 - call $~lib/date/Date#setUTCMonth + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i32.load offset=4 i32.const 3 @@ -6800,7 +6852,7 @@ if i32.const 0 i32.const 1152 - i32.const 202 + i32.const 205 i32.const 3 call $~lib/builtins/abort unreachable @@ -6812,35 +6864,36 @@ if i32.const 0 i32.const 1152 - i32.const 203 + i32.const 206 i32.const 3 call $~lib/builtins/abort unreachable end - local.get $0 i32.const 1 - call $~lib/date/Date#setUTCMonth + global.set $~argumentsLength local.get $0 - i32.const 12 - call $~lib/date/Date#setUTCMonth + i32.const 0 + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i64.load offset=16 - i64.const 7899967616218720 + i64.const 7899936080218720 i64.ne if i32.const 0 i32.const 1152 - i32.const 207 + i32.const 209 i32.const 3 call $~lib/builtins/abort unreachable end + i32.const 1 + global.set $~argumentsLength local.get $0 - i32.const 0 - call $~lib/date/Date#setUTCMonth + i32.const 11 + call $~lib/date/Date#setUTCMonth@varargs local.get $0 i64.load offset=16 - i64.const 7899967616218720 + i64.const 7899964937818720 i64.ne if i32.const 0 @@ -6850,17 +6903,60 @@ call $~lib/builtins/abort unreachable end + i32.const 1 + global.set $~argumentsLength local.get $0 - i32.const 13 - call $~lib/date/Date#setUTCMonth + i32.const -1 + call $~lib/date/Date#setUTCMonth@varargs + local.get $0 + i32.load offset=4 + i32.const 12 + i32.ne + if + i32.const 0 + i32.const 1152 + i32.const 215 + i32.const 3 + call $~lib/builtins/abort + unreachable + end local.get $0 i64.load offset=16 - i64.const 7900001830618720 + i64.const 7899933401818720 i64.ne if i32.const 0 i32.const 1152 - i32.const 213 + i32.const 216 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + i32.const 1 + global.set $~argumentsLength + local.get $0 + i32.const 12 + call $~lib/date/Date#setUTCMonth@varargs + local.get $0 + i32.load offset=4 + i32.const 1 + i32.sub + if + i32.const 0 + i32.const 1152 + i32.const 218 + i32.const 3 + call $~lib/builtins/abort + unreachable + end + local.get $0 + i64.load offset=16 + i64.const 7899936080218720 + i64.ne + if + i32.const 0 + i32.const 1152 + i32.const 219 i32.const 3 call $~lib/builtins/abort unreachable @@ -6877,7 +6973,7 @@ if i32.const 0 i32.const 1152 - i32.const 219 + i32.const 225 i32.const 3 call $~lib/builtins/abort unreachable @@ -6892,7 +6988,7 @@ if i32.const 0 i32.const 1152 - i32.const 221 + i32.const 227 i32.const 3 call $~lib/builtins/abort unreachable @@ -6907,7 +7003,7 @@ if i32.const 0 i32.const 1152 - i32.const 223 + i32.const 229 i32.const 3 call $~lib/builtins/abort unreachable @@ -6922,7 +7018,7 @@ if i32.const 0 i32.const 1152 - i32.const 225 + i32.const 231 i32.const 3 call $~lib/builtins/abort unreachable @@ -6948,7 +7044,7 @@ if i32.const 0 i32.const 1152 - i32.const 231 + i32.const 237 i32.const 3 call $~lib/builtins/abort unreachable @@ -6974,7 +7070,7 @@ if i32.const 0 i32.const 1152 - i32.const 233 + i32.const 239 i32.const 3 call $~lib/builtins/abort unreachable @@ -7000,7 +7096,7 @@ if i32.const 0 i32.const 1152 - i32.const 235 + i32.const 241 i32.const 3 call $~lib/builtins/abort unreachable @@ -7026,7 +7122,7 @@ if i32.const 0 i32.const 1152 - i32.const 237 + i32.const 243 i32.const 3 call $~lib/builtins/abort unreachable @@ -7052,7 +7148,7 @@ if i32.const 0 i32.const 1152 - i32.const 239 + i32.const 245 i32.const 3 call $~lib/builtins/abort unreachable @@ -7078,7 +7174,7 @@ if i32.const 0 i32.const 1152 - i32.const 241 + i32.const 247 i32.const 3 call $~lib/builtins/abort unreachable @@ -7104,7 +7200,7 @@ if i32.const 0 i32.const 1152 - i32.const 243 + i32.const 249 i32.const 3 call $~lib/builtins/abort unreachable @@ -7130,7 +7226,7 @@ if i32.const 0 i32.const 1152 - i32.const 245 + i32.const 251 i32.const 3 call $~lib/builtins/abort unreachable @@ -7156,7 +7252,7 @@ if i32.const 0 i32.const 1152 - i32.const 247 + i32.const 253 i32.const 3 call $~lib/builtins/abort unreachable @@ -7182,7 +7278,7 @@ if i32.const 0 i32.const 1152 - i32.const 253 + i32.const 259 i32.const 3 call $~lib/builtins/abort unreachable @@ -7208,7 +7304,7 @@ if i32.const 0 i32.const 1152 - i32.const 255 + i32.const 261 i32.const 3 call $~lib/builtins/abort unreachable @@ -7234,7 +7330,7 @@ if i32.const 0 i32.const 1152 - i32.const 258 + i32.const 264 i32.const 3 call $~lib/builtins/abort unreachable @@ -7260,7 +7356,7 @@ if i32.const 0 i32.const 1152 - i32.const 264 + i32.const 270 i32.const 3 call $~lib/builtins/abort unreachable @@ -7286,7 +7382,7 @@ if i32.const 0 i32.const 1152 - i32.const 267 + i32.const 273 i32.const 3 call $~lib/builtins/abort unreachable @@ -7312,7 +7408,7 @@ if i32.const 0 i32.const 1152 - i32.const 273 + i32.const 279 i32.const 3 call $~lib/builtins/abort unreachable @@ -7338,7 +7434,7 @@ if i32.const 0 i32.const 1152 - i32.const 275 + i32.const 281 i32.const 3 call $~lib/builtins/abort unreachable @@ -7364,7 +7460,7 @@ if i32.const 0 i32.const 1152 - i32.const 278 + i32.const 284 i32.const 3 call $~lib/builtins/abort unreachable @@ -7385,7 +7481,7 @@ if i32.const 0 i32.const 1152 - i32.const 285 + i32.const 291 i32.const 3 call $~lib/builtins/abort unreachable @@ -7406,7 +7502,7 @@ if i32.const 0 i32.const 1152 - i32.const 287 + i32.const 293 i32.const 3 call $~lib/builtins/abort unreachable @@ -7427,7 +7523,7 @@ if i32.const 0 i32.const 1152 - i32.const 289 + i32.const 295 i32.const 3 call $~lib/builtins/abort unreachable @@ -7448,7 +7544,7 @@ if i32.const 0 i32.const 1152 - i32.const 293 + i32.const 299 i32.const 3 call $~lib/builtins/abort unreachable @@ -7469,7 +7565,7 @@ if i32.const 0 i32.const 1152 - i32.const 297 + i32.const 303 i32.const 3 call $~lib/builtins/abort unreachable @@ -7490,7 +7586,7 @@ if i32.const 0 i32.const 1152 - i32.const 301 + i32.const 307 i32.const 3 call $~lib/builtins/abort unreachable @@ -7511,7 +7607,7 @@ if i32.const 0 i32.const 1152 - i32.const 304 + i32.const 310 i32.const 3 call $~lib/builtins/abort unreachable @@ -7532,7 +7628,7 @@ if i32.const 0 i32.const 1152 - i32.const 307 + i32.const 313 i32.const 3 call $~lib/builtins/abort unreachable @@ -7553,7 +7649,7 @@ if i32.const 0 i32.const 1152 - i32.const 310 + i32.const 316 i32.const 3 call $~lib/builtins/abort unreachable @@ -7574,7 +7670,7 @@ if i32.const 0 i32.const 1152 - i32.const 313 + i32.const 319 i32.const 3 call $~lib/builtins/abort unreachable @@ -7595,7 +7691,7 @@ if i32.const 0 i32.const 1152 - i32.const 316 + i32.const 322 i32.const 3 call $~lib/builtins/abort unreachable @@ -7616,7 +7712,7 @@ if i32.const 0 i32.const 1152 - i32.const 319 + i32.const 325 i32.const 3 call $~lib/builtins/abort unreachable @@ -7637,7 +7733,7 @@ if i32.const 0 i32.const 1152 - i32.const 322 + i32.const 328 i32.const 3 call $~lib/builtins/abort unreachable @@ -7651,7 +7747,7 @@ i64.const 8640000000000000 call $~lib/date/Date#constructor local.tee $2 - i32.store + i32.store offset=16 local.get $0 i64.load offset=16 i64.const -8640000000000000 @@ -7659,7 +7755,7 @@ if i32.const 0 i32.const 1152 - i32.const 340 + i32.const 346 i32.const 3 call $~lib/builtins/abort unreachable @@ -7671,7 +7767,7 @@ if i32.const 0 i32.const 1152 - i32.const 341 + i32.const 347 i32.const 3 call $~lib/builtins/abort unreachable @@ -7683,7 +7779,7 @@ if i32.const 0 i32.const 1152 - i32.const 343 + i32.const 349 i32.const 3 call $~lib/builtins/abort unreachable @@ -7695,7 +7791,7 @@ if i32.const 0 i32.const 1152 - i32.const 344 + i32.const 350 i32.const 3 call $~lib/builtins/abort unreachable @@ -7707,7 +7803,7 @@ if i32.const 0 i32.const 1152 - i32.const 346 + i32.const 352 i32.const 3 call $~lib/builtins/abort unreachable @@ -7719,7 +7815,7 @@ if i32.const 0 i32.const 1152 - i32.const 347 + i32.const 353 i32.const 3 call $~lib/builtins/abort unreachable @@ -7731,7 +7827,7 @@ if i32.const 0 i32.const 1152 - i32.const 349 + i32.const 355 i32.const 3 call $~lib/builtins/abort unreachable @@ -7743,7 +7839,7 @@ if i32.const 0 i32.const 1152 - i32.const 350 + i32.const 356 i32.const 3 call $~lib/builtins/abort unreachable @@ -7765,7 +7861,7 @@ if i32.const 0 i32.const 1152 - i32.const 352 + i32.const 358 i32.const 3 call $~lib/builtins/abort unreachable @@ -7787,7 +7883,7 @@ if i32.const 0 i32.const 1152 - i32.const 353 + i32.const 359 i32.const 3 call $~lib/builtins/abort unreachable @@ -7796,12 +7892,12 @@ i64.const 8639999999999999 call $~lib/date/Date#constructor local.tee $0 - i32.store offset=16 + i32.store global.get $~lib/memory/__stack_pointer i64.const -8639999999999999 call $~lib/date/Date#constructor local.tee $2 - i32.store offset=12 + i32.store offset=24 local.get $2 i32.load i32.const -271821 @@ -7809,7 +7905,7 @@ if i32.const 0 i32.const 1152 - i32.const 358 + i32.const 364 i32.const 3 call $~lib/builtins/abort unreachable @@ -7821,7 +7917,7 @@ if i32.const 0 i32.const 1152 - i32.const 359 + i32.const 365 i32.const 3 call $~lib/builtins/abort unreachable @@ -7833,7 +7929,7 @@ if i32.const 0 i32.const 1152 - i32.const 360 + i32.const 366 i32.const 3 call $~lib/builtins/abort unreachable @@ -7856,7 +7952,7 @@ if i32.const 0 i32.const 1152 - i32.const 361 + i32.const 367 i32.const 3 call $~lib/builtins/abort unreachable @@ -7879,7 +7975,7 @@ if i32.const 0 i32.const 1152 - i32.const 362 + i32.const 368 i32.const 3 call $~lib/builtins/abort unreachable @@ -7902,7 +7998,7 @@ if i32.const 0 i32.const 1152 - i32.const 363 + i32.const 369 i32.const 3 call $~lib/builtins/abort unreachable @@ -7925,7 +8021,7 @@ if i32.const 0 i32.const 1152 - i32.const 364 + i32.const 370 i32.const 3 call $~lib/builtins/abort unreachable @@ -7947,7 +8043,7 @@ if i32.const 0 i32.const 1152 - i32.const 366 + i32.const 372 i32.const 3 call $~lib/builtins/abort unreachable @@ -7969,7 +8065,7 @@ if i32.const 0 i32.const 1152 - i32.const 367 + i32.const 373 i32.const 3 call $~lib/builtins/abort unreachable diff --git a/tests/compiler/std/date.ts b/tests/compiler/std/date.ts index 87cbab1df5..c2152d8aa4 100644 --- a/tests/compiler/std/date.ts +++ b/tests/compiler/std/date.ts @@ -131,17 +131,20 @@ date.setUTCDate(30); // jan has 31 days - date.setUTCMonth(1); + date.setUTCMonth(0); date.setUTCDate(1); date.setUTCDate(31); // feb on leap year date.setUTCFullYear(2024); - date.setUTCMonth(2); + date.setUTCMonth(1); + assert(date.getUTCMonth() == 2); // overflows to march due to day=31 date.setUTCDate(1); date.setUTCDate(29); + date.setUTCMonth(1); - assert(date.getTime() == 1711674191274); + assert(date.getTime() == 1709168591274); + assert(date.getUTCMonth() == 1); assert(date.getUTCDate() == 29); assert(date.getUTCMinutes() == 3); assert(date.getUTCSeconds() == 11); @@ -202,15 +205,18 @@ assert(date.getUTCMonth() == 2); assert(date.getTime() == 7899941177818720); // test boundaries - date.setUTCMonth(1); - date.setUTCMonth(12); - assert(date.getTime() == 7899967616218720); + date.setUTCMonth(0); + assert(date.getTime() == 7899936080218720); + date.setUTCMonth(11); + assert(date.getTime() == 7899964937818720); // test out of boundaries - date.setUTCMonth(0); - assert(date.getTime() == 7899967616218720); - date.setUTCMonth(13); - assert(date.getTime() == 7900001830618720); + date.setUTCMonth(-1); + assert(date.getUTCMonth() == 11); + assert(date.getTime() == 7899933401818720); + date.setUTCMonth(12); + assert(date.getUTCMonth() == 0); + assert(date.getTime() == 7899936080218720); } // Date#setUTCFullYear /////////////////////////////////////////////////////////////////////////////