Reduce stack usage (#776)

This commit is contained in:
강동윤 2020-05-17 18:50:52 +09:00 committed by GitHub
parent d74f74932e
commit 65f2faa339
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 596 additions and 12 deletions

View File

@ -13,7 +13,6 @@ on: [push, pull_request]
# - 'trying'
env:
RUST_MIN_STACK: 16777216
CARGO_INCREMENTAL: 0
CI: "1"

View File

@ -28,7 +28,6 @@ before_install:
- sed -i 's/git@github.com:/https:\/\/github.com\//' .gitmodules
- git submodule update --init --recursive
install:
- rm -rf ~/.nvm
- git clone https://github.com/creationix/nvm.git ~/.nvm
@ -66,7 +65,6 @@ notifications:
env:
global:
- CASHER_TIME_OUT=600
- RUST_MIN_STACK=16777216
- CARGO_INCREMENTAL=0
- RUSTFLAGS="--cfg procmacro2_semver_exempt"
- secure: Z4RSNlpg/12Qx2fIjS+7TToYxPJQgK70X7u9A5lJiCIa0JfzWCxr1ZEKXfAVLG9o4nQok+nWOZa+vxR1IgyUVnf6oSanjjWl1pSRbvccxMS799NvHmGzIAiqSKAlxiSJuxf7MQbs1XBuI3XahsWLfXGPo7vPT6sKe4AAf9gT6igJr61D5hpHkVIXK7P6rnrWQALQYplyaox0NlU9UlqSXXBjdJfp3138rl7FIeYRsMMow44unBNPvs+mhVP8PWpeFWeop0jxbNbTHwnJUbCm4ZWrvqnJ/m70IMlBMN1AskLmz4KeXOhPx+XR9VtdWBX4q8lJ7s9J0hMBxrEnxgiYVBPMlLoEX+wW3zwZ5F+DQs7uLpRHYRUpxpi/7ZuQjp+uT3mN9PMMSvbHwHLH2r/CC9olKYWySXIsGsGVyyMnZeUwvgzwxiYLoeCWe4zZY99zc7jvGKbSmk0RtPu6hApPwL5A6novXbXL2QsXzqqeWpgMLmZyb7KYhM5IGIAB1oPQIqI++Re9Z+/ea/DRSUJOsA96yRQ+vVbiuClrVgDhaAaJOGYCtR1XZ5N2zRb9+Spu/ECtfisLOb9Xs1584DyRbqG69nRdjuscjYOTFZUlOoOeFvuADY65Jt0kF6u7g8NIDkJ1ROb3heKQtY/bAQUrBNUJydOQnn5tBwn8Z618+Ac=

View File

@ -1,6 +1,6 @@
[package]
name = "swc_common"
version = "0.5.11"
version = "0.5.12"
authors = ["강동윤 <kdy1997.dev@gmail.com>"]
license = "Apache-2.0/MIT"
repository = "https://github.com/swc-project/swc.git"

View File

@ -27,7 +27,7 @@ use std::{
#[derive(Clone)]
pub struct DiagnosticBuilder<'a> {
pub handler: &'a Handler,
diagnostic: Diagnostic,
diagnostic: Box<Diagnostic>,
allow_suggestions: bool,
}
@ -115,7 +115,7 @@ impl<'a> DiagnosticBuilder<'a> {
// Logging here is useful to help track down where in logs an error was
// actually emitted.
debug!("buffer: diagnostic={:?}", diagnostic);
buffered_diagnostics.push(diagnostic);
buffered_diagnostics.push(*diagnostic);
}
/// Convenience function for internal use, clients should use one of the
@ -143,7 +143,7 @@ impl<'a> DiagnosticBuilder<'a> {
/// locally in whichever way makes the most sense.
pub fn delay_as_bug(&mut self) {
self.level = Level::Bug;
self.handler.delay_as_bug(self.diagnostic.clone());
self.handler.delay_as_bug(*self.diagnostic.clone());
self.cancel();
}
@ -304,10 +304,11 @@ impl<'a> DiagnosticBuilder<'a> {
/// Creates a new `DiagnosticBuilder` with an already constructed
/// diagnostic.
#[inline(always)] // box
pub fn new_diagnostic(handler: &'a Handler, diagnostic: Diagnostic) -> DiagnosticBuilder<'a> {
DiagnosticBuilder {
handler,
diagnostic,
diagnostic: Box::new(diagnostic),
allow_suggestions: true,
}
}

View File

@ -1 +0,0 @@
a.a = 1;

View File

@ -1 +0,0 @@
((((((((((((((((((((((((((((((((((((((((a))))))))))))))))))))))))))))))))))))))));

View File

@ -1 +0,0 @@
((((((((((((((((((((((((((((((((((((((((((((((((((1))))))))))))))))))))))))))))))))))))))))))))))))));

View File

@ -24,6 +24,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
"431ecef8c85d4d24.js",
"8386fbff927a9e0e.js",
"5654d4106d7025c2.js",
// Stack size (Stupid parens)
"6b5e7e125097d439.js",
"714be6d28082eaa7.js",
"882910de7dd1aef9.js",
"dd3c63403db5c06e.js",
// Wrong tests (variable name or value is different)
"0339fa95c78c11bd.js",
"0426f15dac46e92d.js",

View File

@ -24,6 +24,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
"431ecef8c85d4d24.js",
"8386fbff927a9e0e.js",
"5654d4106d7025c2.js",
// Stack size (Stupid parens)
"6b5e7e125097d439.js",
"714be6d28082eaa7.js",
"882910de7dd1aef9.js",
"dd3c63403db5c06e.js",
// Static constructor
"dcc5609dcc043200.js",
"88d42455ac933ef5.js",

View File

@ -0,0 +1,25 @@
module.exports = function test() {
if (true) {
if (true) {
while (test) {
if (test) {
if (test) {
if (test) {
if (test) {
while (test) {
if (test) {
if (asdf) {
if (asdf) {
test += ' || ' + (test) + ' === null || ' + (test) + ' === \'\' ';
}
}
}
}
}
}
}
}
}
}
}
}

View File

@ -0,0 +1,550 @@
{
"type": "Module",
"span": {
"start": 0,
"end": 839,
"ctxt": 0
},
"body": [
{
"type": "ExpressionStatement",
"span": {
"start": 0,
"end": 839,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 0,
"end": 839,
"ctxt": 0
},
"operator": "=",
"left": {
"type": "MemberExpression",
"span": {
"start": 0,
"end": 14,
"ctxt": 0
},
"object": {
"type": "Identifier",
"span": {
"start": 0,
"end": 6,
"ctxt": 0
},
"value": "module",
"typeAnnotation": null,
"optional": false
},
"property": {
"type": "Identifier",
"span": {
"start": 7,
"end": 14,
"ctxt": 0
},
"value": "exports",
"typeAnnotation": null,
"optional": false
},
"computed": false
},
"right": {
"type": "FunctionExpression",
"identifier": {
"type": "Identifier",
"span": {
"start": 26,
"end": 30,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"params": [],
"decorators": [],
"span": {
"start": 17,
"end": 839,
"ctxt": 0
},
"body": {
"type": "BlockStatement",
"span": {
"start": 33,
"end": 839,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 39,
"end": 837,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 43,
"end": 47,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 49,
"end": 837,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 59,
"end": 831,
"ctxt": 0
},
"test": {
"type": "BooleanLiteral",
"span": {
"start": 63,
"end": 67,
"ctxt": 0
},
"value": true
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 69,
"end": 831,
"ctxt": 0
},
"stmts": [
{
"type": "WhileStatement",
"span": {
"start": 83,
"end": 821,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 90,
"end": 94,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"body": {
"type": "BlockStatement",
"span": {
"start": 96,
"end": 821,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 114,
"end": 807,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 118,
"end": 122,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 124,
"end": 807,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 146,
"end": 789,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 150,
"end": 154,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 156,
"end": 789,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 182,
"end": 767,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 186,
"end": 190,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 192,
"end": 767,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 222,
"end": 741,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 226,
"end": 230,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 232,
"end": 741,
"ctxt": 0
},
"stmts": [
{
"type": "WhileStatement",
"span": {
"start": 266,
"end": 711,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 273,
"end": 277,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"body": {
"type": "BlockStatement",
"span": {
"start": 279,
"end": 711,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 317,
"end": 677,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 321,
"end": 325,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 327,
"end": 677,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 369,
"end": 639,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 373,
"end": 377,
"ctxt": 0
},
"value": "asdf",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 379,
"end": 639,
"ctxt": 0
},
"stmts": [
{
"type": "IfStatement",
"span": {
"start": 425,
"end": 597,
"ctxt": 0
},
"test": {
"type": "Identifier",
"span": {
"start": 429,
"end": 433,
"ctxt": 0
},
"value": "asdf",
"typeAnnotation": null,
"optional": false
},
"consequent": {
"type": "BlockStatement",
"span": {
"start": 435,
"end": 597,
"ctxt": 0
},
"stmts": [
{
"type": "ExpressionStatement",
"span": {
"start": 485,
"end": 551,
"ctxt": 0
},
"expression": {
"type": "AssignmentExpression",
"span": {
"start": 485,
"end": 550,
"ctxt": 0
},
"operator": "+=",
"left": {
"type": "Identifier",
"span": {
"start": 485,
"end": 489,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
},
"right": {
"type": "BinaryExpression",
"span": {
"start": 493,
"end": 550,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "BinaryExpression",
"span": {
"start": 493,
"end": 535,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "BinaryExpression",
"span": {
"start": 493,
"end": 526,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "BinaryExpression",
"span": {
"start": 493,
"end": 508,
"ctxt": 0
},
"operator": "+",
"left": {
"type": "StringLiteral",
"span": {
"start": 493,
"end": 499,
"ctxt": 0
},
"value": " || ",
"hasEscape": false
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 502,
"end": 508,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 503,
"end": 507,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
}
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 511,
"end": 526,
"ctxt": 0
},
"value": " === null || ",
"hasEscape": false
}
},
"right": {
"type": "ParenthesisExpression",
"span": {
"start": 529,
"end": 535,
"ctxt": 0
},
"expression": {
"type": "Identifier",
"span": {
"start": 530,
"end": 534,
"ctxt": 0
},
"value": "test",
"typeAnnotation": null,
"optional": false
}
}
},
"right": {
"type": "StringLiteral",
"span": {
"start": 538,
"end": 550,
"ctxt": 0
},
"value": " === '' ",
"hasEscape": true
}
}
}
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
}
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
}
}
]
},
"alternate": null
}
]
},
"alternate": null
}
]
},
"generator": false,
"async": false,
"typeParameters": null,
"returnType": null
}
}
}
],
"interpreter": null
}

View File

@ -25,6 +25,11 @@ const IGNORED_PASS_TESTS: &[&str] = &[
// TODO: uningnore
"5654d4106d7025c2.js",
"431ecef8c85d4d24.js",
// Stack size (Stupid parens)
"6b5e7e125097d439.js",
"714be6d28082eaa7.js",
"882910de7dd1aef9.js",
"dd3c63403db5c06e.js",
// Generated code is better than it from `pass`
"0da4b57d03d33129.js",
"aec65a9745669870.js",