Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(237)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2569983003: PreParsing inner funcs: Remove nonsense code from PreParser. (Closed)
Patch Set: more tests Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 8449 matching lines...) Expand 10 before | Expand all | Expand 10 after
8460 bool ctxt_allocate; 8460 bool ctxt_allocate;
8461 } inners[] = { 8461 } inners[] = {
8462 // Context allocating because we need to: 8462 // Context allocating because we need to:
8463 {"function inner() { my_var; }", true}, 8463 {"function inner() { my_var; }", true},
8464 {"function inner() { eval(\"foo\"); }", true}, 8464 {"function inner() { eval(\"foo\"); }", true},
8465 {"function inner() { function inner2() { my_var; } }", true}, 8465 {"function inner() { function inner2() { my_var; } }", true},
8466 {"function inner() { function inner2() { eval(\"foo\"); } }", true}, 8466 {"function inner() { function inner2() { eval(\"foo\"); } }", true},
8467 {"function inner() { var {my_var : a} = {my_var}; }", true}, 8467 {"function inner() { var {my_var : a} = {my_var}; }", true},
8468 {"function inner() { let {my_var : a} = {my_var}; }", true}, 8468 {"function inner() { let {my_var : a} = {my_var}; }", true},
8469 {"function inner() { const {my_var : a} = {my_var}; }", true}, 8469 {"function inner() { const {my_var : a} = {my_var}; }", true},
8470 {"function inner(a = my_var) { }", true},
8471 {"function inner() { function inner2(a = my_var) { } }", true},
8472 {"function inner({a} = {a: my_var}) { }", true},
8473 {"function inner() { function inner2({a} = {a: my_var}) { } }", true},
8474 {"function inner([a] = [my_var]) { }", true},
8475 {"function inner() { function inner2([a] = [my_var]) { } }", true},
8470 // No pessimistic context allocation: 8476 // No pessimistic context allocation:
8471 {"function inner() { var my_var; my_var; }", false}, 8477 {"function inner() { var my_var; my_var; }", false},
8472 {"function inner() { var my_var; }", false}, 8478 {"function inner() { var my_var; }", false},
8473 {"function inner() { let my_var; my_var; }", false}, 8479 {"function inner() { let my_var; my_var; }", false},
8474 {"function inner() { let my_var; }", false}, 8480 {"function inner() { let my_var; }", false},
8475 {"function inner() { const my_var = 0; my_var; }", false}, 8481 {"function inner() { const my_var = 0; my_var; }", false},
8476 {"function inner() { const my_var = 0; }", false}, 8482 {"function inner() { const my_var = 0; }", false},
8477 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false}, 8483 {"function inner() { var [a, my_var] = [1, 2]; my_var; }", false},
8478 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false}, 8484 {"function inner() { let [a, my_var] = [1, 2]; my_var; }", false},
8479 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false}, 8485 {"function inner() { const [a, my_var] = [1, 2]; my_var; }", false},
8480 {"function inner() { var {a: my_var} = {a: 3}; my_var; }", false}, 8486 {"function inner() { var {a: my_var} = {a: 3}; my_var; }", false},
8481 {"function inner() { let {a: my_var} = {a: 3}; my_var; }", false}, 8487 {"function inner() { let {a: my_var} = {a: 3}; my_var; }", false},
8482 {"function inner() { const {a: my_var} = {a: 3}; my_var; }", false}, 8488 {"function inner() { const {a: my_var} = {a: 3}; my_var; }", false},
8483 {"function inner() { var {my_var} = {my_var: 3}; my_var; }", false}, 8489 {"function inner() { var {my_var} = {my_var: 3}; my_var; }", false},
8484 {"function inner() { let {my_var} = {my_var: 3}; my_var; }", false}, 8490 {"function inner() { let {my_var} = {my_var: 3}; my_var; }", false},
8485 {"function inner() { const {my_var} = {my_var: 3}; my_var; }", false}, 8491 {"function inner() { const {my_var} = {my_var: 3}; my_var; }", false},
8486 {"function inner(my_var) { my_var; }", false}, 8492 {"function inner(my_var) { my_var; }", false},
8487 {"function inner(my_var) { }", false}, 8493 {"function inner(my_var) { }", false},
8494 {"function inner(my_var = 5) { my_var; }", false},
8495 {"function inner(my_var = 5) { }", false},
8488 {"function inner(...my_var) { my_var; }", false}, 8496 {"function inner(...my_var) { my_var; }", false},
8489 {"function inner(...my_var) { }", false}, 8497 {"function inner(...my_var) { }", false},
8490 {"function inner([a, my_var, b]) { my_var; }", false}, 8498 {"function inner([a, my_var, b]) { my_var; }", false},
8491 {"function inner([a, my_var, b]) { }", false}, 8499 {"function inner([a, my_var, b]) { }", false},
8500 {"function inner([a, my_var, b] = [1, 2, 3]) { my_var; }", false},
8501 {"function inner([a, my_var, b] = [1, 2, 3]) { }", false},
8492 {"function inner({x: my_var}) { my_var; }", false}, 8502 {"function inner({x: my_var}) { my_var; }", false},
8493 {"function inner({x: my_var}) { }", false}, 8503 {"function inner({x: my_var}) { }", false},
8504 {"function inner({x: my_var} = {x: 0}) { my_var; }", false},
8505 {"function inner({x: my_var} = {x: 0}) { }", false},
8494 {"function inner({my_var}) { my_var; }", false}, 8506 {"function inner({my_var}) { my_var; }", false},
8495 {"function inner({my_var}) { }", false}, 8507 {"function inner({my_var}) { }", false},
8508 {"function inner({my_var} = {my_var: 0}) { my_var; }", false},
8509 {"function inner({my_var} = {my_var: 0}) { }", false},
8496 {"function inner() { function inner2(my_var) { my_var; } }", false}, 8510 {"function inner() { function inner2(my_var) { my_var; } }", false},
8497 {"function inner() { function inner2(my_var) { } }", false}, 8511 {"function inner() { function inner2(my_var) { } }", false},
8512 {"function inner() { function inner2(my_var = 5) { my_var; } }", false},
8513 {"function inner() { function inner2(my_var = 5) { } }", false},
8498 {"function inner() { function inner2(...my_var) { my_var; } }", false}, 8514 {"function inner() { function inner2(...my_var) { my_var; } }", false},
8499 {"function inner() { function inner2(...my_var) { } }", false}, 8515 {"function inner() { function inner2(...my_var) { } }", false},
8500 {"function inner() { function inner2([a, my_var, b]) { my_var; } }", 8516 {"function inner() { function inner2([a, my_var, b]) { my_var; } }",
8501 false}, 8517 false},
8502 {"function inner() { function inner2([a, my_var, b]) { } }", false}, 8518 {"function inner() { function inner2([a, my_var, b]) { } }", false},
8519 {"function inner() { function inner2([a, my_var, b] = [1, 2, 3]) { "
8520 "my_var; } }",
8521 false},
8522 {"function inner() { function inner2([a, my_var, b] = [1, 2, 3]) { } }",
8523 false},
8503 {"function inner() { function inner2({x: my_var}) { my_var; } }", false}, 8524 {"function inner() { function inner2({x: my_var}) { my_var; } }", false},
8504 {"function inner() { function inner2({x: my_var}) { } }", false}, 8525 {"function inner() { function inner2({x: my_var}) { } }", false},
8526 {"function inner() { function inner2({x: my_var} = {x: 0}) { my_var; } }",
8527 false},
8528 {"function inner() { function inner2({x: my_var} = {x: 0}) { } }", false},
8505 {"function inner() { function inner2({my_var}) { my_var; } }", false}, 8529 {"function inner() { function inner2({my_var}) { my_var; } }", false},
8506 {"function inner() { function inner2({my_var}) { } }", false}, 8530 {"function inner() { function inner2({my_var}) { } }", false},
8531 {"function inner() { function inner2({my_var} = {my_var: 8}) { my_var; } "
8532 "}",
8533 false},
8534 {"function inner() { function inner2({my_var} = {my_var: 8}) { } }",
8535 false},
8507 {"my_var => my_var; ", false}, 8536 {"my_var => my_var; ", false},
8508 {"my_var => { }", false}, 8537 {"my_var => { }", false},
8538 {"(my_var = 5) => my_var; ", false},
8539 {"(my_var = 5) => { }", false},
8509 {"(...my_var) => my_var;", false}, 8540 {"(...my_var) => my_var;", false},
8510 {"(...my_var) => { }", false}, 8541 {"(...my_var) => { }", false},
8511 {"([a, my_var, b]) => my_var;", false}, 8542 {"([a, my_var, b]) => my_var;", false},
8512 {"([a, my_var, b]) => { }", false}, 8543 {"([a, my_var, b]) => { }", false},
8544 {"([a, my_var, b] = [1, 2, 3]) => my_var;", false},
8545 {"([a, my_var, b] = [1, 2, 3]) => { }", false},
8513 {"({x: my_var}) => my_var;", false}, 8546 {"({x: my_var}) => my_var;", false},
8514 {"({x: my_var}) => { }", false}, 8547 {"({x: my_var}) => { }", false},
8548 {"({x: my_var} = {x: 0}) => my_var;", false},
8549 {"({x: my_var} = {x: 0}) => { }", false},
8515 {"({my_var}) => my_var;", false}, 8550 {"({my_var}) => my_var;", false},
8516 {"({my_var}) => { }", false}, 8551 {"({my_var}) => { }", false},
8552 {"({my_var} = {my_var: 5}) => my_var;", false},
8553 {"({my_var} = {my_var: 5}) => { }", false},
8517 {"function inner() { try { } catch (my_var) { } }", false}, 8554 {"function inner() { try { } catch (my_var) { } }", false},
8518 {"function inner() { class my_var {}; }", false}, 8555 {"function inner() { class my_var {}; }", false},
8519 // In the following cases we still context allocate pessimistically: 8556 // In the following cases we still context allocate pessimistically:
8520 {"function inner() { function my_var() {} my_var; }", true}, 8557 {"function inner() { function my_var() {} my_var; }", true},
8521 {"function inner() { if (true) { function my_var() {} } my_var; }", 8558 {"function inner() { if (true) { function my_var() {} } my_var; }",
8522 true}, 8559 true},
8523 {"function inner() { try { } catch (my_var) { my_var; } }", true}, 8560 {"function inner() { try { } catch (my_var) { my_var; } }", true},
8524 {"function inner() { for (my_var of {}) { my_var; } }", true}, 8561 {"function inner() { for (my_var of {}) { my_var; } }", true},
8525 {"function inner() { for (my_var of {}) { } }", true}, 8562 {"function inner() { for (my_var of {}) { } }", true},
8526 {"function inner() { for (my_var in []) { my_var; } }", true}, 8563 {"function inner() { for (my_var in []) { my_var; } }", true},
8527 {"function inner() { for (my_var in []) { } }", true}, 8564 {"function inner() { for (my_var in []) { } }", true},
8528 {"function inner() { my_var => my_var; }", true}, 8565 {"function inner() { my_var => my_var; }", true},
8529 {"function inner() { my_var => { }}", true}, 8566 {"function inner() { my_var => { }}", true},
8530 {"function inner() { (...my_var) => my_var;}", true}, 8567 {"function inner() { (my_var = 5) => my_var; }", true},
8568 {"function inner() { (my_var = 5) => { }}", true},
8569 {"function inner() { (...my_var) => my_var;}", true},
8531 {"function inner() { (...my_var) => { }}", true}, 8570 {"function inner() { (...my_var) => { }}", true},
8532 {"function inner() { ([a, my_var, b]) => my_var;}", true}, 8571 {"function inner() { ([a, my_var, b]) => my_var;}", true},
8533 {"function inner() { ([a, my_var, b]) => { }}", true}, 8572 {"function inner() { ([a, my_var, b]) => { }}", true},
8573 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => my_var;}", true},
8574 {"function inner() { ([a, my_var, b] = [1, 2, 3]) => { }}", true},
8534 {"function inner() { ({x: my_var}) => my_var;}", true}, 8575 {"function inner() { ({x: my_var}) => my_var;}", true},
8535 {"function inner() { ({x: my_var}) => { }}", true}, 8576 {"function inner() { ({x: my_var}) => { }}", true},
8577 {"function inner() { ({x: my_var} = {x: 0}) => my_var;}", true},
8578 {"function inner() { ({x: my_var} = {x: 0}) => { }}", true},
8536 {"function inner() { ({my_var}) => my_var;}", true}, 8579 {"function inner() { ({my_var}) => my_var;}", true},
8537 {"function inner() { ({my_var}) => { }}", true}, 8580 {"function inner() { ({my_var}) => { }}", true},
8581 {"function inner() { ({my_var} = {my_var: 5}) => my_var;}", true},
8582 {"function inner() { ({my_var} = {my_var: 5}) => { }}", true},
8538 {"function inner() { class my_var {}; my_var }", true}, 8583 {"function inner() { class my_var {}; my_var }", true},
8539 }; 8584 };
8540 8585
8541 for (unsigned i = 0; i < arraysize(inners); ++i) { 8586 for (unsigned i = 0; i < arraysize(inners); ++i) {
8542 const char* inner = inners[i].source; 8587 const char* inner = inners[i].source;
8543 int inner_len = Utf8LengthHelper(inner); 8588 int inner_len = Utf8LengthHelper(inner);
8544 int len = prefix_len + inner_len + suffix_len; 8589 int len = prefix_len + inner_len + suffix_len;
8545 i::ScopedVector<char> program(len + 1); 8590 i::ScopedVector<char> program(len + 1);
8546 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix); 8591 i::SNPrintF(program, "%s%s%s", prefix, inner, suffix);
8547 i::Handle<i::String> source = 8592 i::Handle<i::String> source =
(...skipping 13 matching lines...) Expand all
8561 DCHECK_NOT_NULL(scope); 8606 DCHECK_NOT_NULL(scope);
8562 DCHECK_NULL(scope->sibling()); 8607 DCHECK_NULL(scope->sibling());
8563 DCHECK(scope->is_function_scope()); 8608 DCHECK(scope->is_function_scope());
8564 const i::AstRawString* var_name = 8609 const i::AstRawString* var_name =
8565 info.ast_value_factory()->GetOneByteString("my_var"); 8610 info.ast_value_factory()->GetOneByteString("my_var");
8566 i::Variable* var = scope->Lookup(var_name); 8611 i::Variable* var = scope->Lookup(var_name);
8567 CHECK_EQ(inners[i].ctxt_allocate, 8612 CHECK_EQ(inners[i].ctxt_allocate,
8568 i::ScopeTestHelper::MustAllocateInContext(var)); 8613 i::ScopeTestHelper::MustAllocateInContext(var));
8569 } 8614 }
8570 } 8615 }
OLDNEW
« no previous file with comments | « src/parsing/preparser.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698