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

Side by Side Diff: test/cctest/asmjs/test-asm-typer.cc

Issue 2568773002: [wasm][asm.js] Forbid function declaration replacing variable declaration. (Closed)
Patch Set: git cl try 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/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <cstring> 5 #include <cstring>
6 #include <functional> 6 #include <functional>
7 #include <iostream> 7 #include <iostream>
8 #include <memory> 8 #include <memory>
9 9
10 #include "src/asmjs/asm-typer.h" 10 #include "src/asmjs/asm-typer.h"
(...skipping 654 matching lines...) Expand 10 before | Expand all | Expand 10 after
665 {"return d2s_tbl;", "cannot export function tables"}, 665 {"return d2s_tbl;", "cannot export function tables"},
666 {"return min;", "cannot export standard library functions"}, 666 {"return min;", "cannot export standard library functions"},
667 {"return ffi;", "cannot export foreign functions"}, 667 {"return ffi;", "cannot export foreign functions"},
668 {"return I;", "is not an asm.js function"}, 668 {"return I;", "is not an asm.js function"},
669 {"return {'a': d2s_tbl}", "cannot export function tables"}, 669 {"return {'a': d2s_tbl}", "cannot export function tables"},
670 {"return {'a': min}", "cannot export standard library functions"}, 670 {"return {'a': min}", "cannot export standard library functions"},
671 {"return {'a': ffi}", "cannot export foreign functions"}, 671 {"return {'a': ffi}", "cannot export foreign functions"},
672 {"return {'a': f()}", "must be an asm.js function name"}, 672 {"return {'a': f()}", "must be an asm.js function name"},
673 {"return {'a': f}", "Undefined identifier in asm.js module export"}, 673 {"return {'a': f}", "Undefined identifier in asm.js module export"},
674 {"function v() { a(); } return {b: d2s}", "Missing definition for forw"}, 674 {"function v() { a(); } return {b: d2s}", "Missing definition for forw"},
675 {"return {b: d2s, 'a': d2s_tbl}", "cannot export function tables"}, 675 {"function v() {} return {b: v, 'a': d2s_tbl}",
676 {"return {b: d2s, 'a': min}", "cannot export standard library"}, 676 "cannot export function tables"},
677 {"return {b: d2s, 'a': ffi}", "cannot export foreign functions"}, 677 {"function v() {} return {b: v, 'a': min}",
678 {"return {b: d2s, 'a': f()}", "must be an asm.js function name"}, 678 "cannot export standard library"},
679 {"return {b: d2s, 'a': f}", "Undefined identifier in asm.js module"}, 679 {"function v() {} return {b: v, 'a': ffi}",
680 "cannot export foreign functions"},
681 {"function v() {} return {b: v, 'a': f()}",
682 "must be an asm.js function name"},
683 {"function v() {} return {b: v, 'a': f}",
684 "Undefined identifier in asm.js module"},
680 }; 685 };
681 686
682 auto d2s_tbl = [](Zone* zone) -> iw::AsmType* { 687 auto d2s_tbl = [](Zone* zone) -> iw::AsmType* {
683 auto* d2s = iw::AsmType::Function(zone, iw::AsmType::Signed()); 688 auto* d2s = iw::AsmType::Function(zone, iw::AsmType::Signed());
684 d2s->AsFunctionType()->AddArgument(iw::AsmType::Double()); 689 d2s->AsFunctionType()->AddArgument(iw::AsmType::Double());
685 690
686 auto* ret = iw::AsmType::FunctionTableType(zone, 2, d2s); 691 auto* ret = iw::AsmType::FunctionTableType(zone, 2, d2s);
687 return ret; 692 return ret;
688 }; 693 };
689 694
690 auto d2s = [](Zone* zone) -> iw::AsmType* {
691 auto* ret = iw::AsmType::Function(zone, iw::AsmType::Signed());
692 ret->AsFunctionType()->AddArgument(iw::AsmType::Double());
693 return ret;
694 };
695
696 for (size_t ii = 0; ii < arraysize(kTests); ++ii) { 695 for (size_t ii = 0; ii < arraysize(kTests); ++ii) {
697 const auto* test = kTests + ii; 696 const auto* test = kTests + ii;
698 if (!ValidationOf(Export(test->module_export)) 697 if (!ValidationOf(Export(test->module_export))
699 ->WithGlobal(DynamicGlobal("d2s_tbl"), d2s_tbl) 698 ->WithGlobal(DynamicGlobal("d2s_tbl"), d2s_tbl)
700 ->WithGlobal(DynamicGlobal("d2s"), d2s)
701 ->WithImport(DynamicGlobal("min"), iw::AsmTyper::kMathMin) 699 ->WithImport(DynamicGlobal("min"), iw::AsmTyper::kMathMin)
702 ->WithImport(DynamicGlobal("ffi"), iw::AsmTyper::kFFI) 700 ->WithImport(DynamicGlobal("ffi"), iw::AsmTyper::kFFI)
703 ->WithGlobal(DynamicGlobal("I"), iw::AsmType::Int()) 701 ->WithGlobal(DynamicGlobal("I"), iw::AsmType::Int())
704 ->FailsWithMessage(test->error_message)) { 702 ->FailsWithMessage(test->error_message)) {
705 std::cerr << "Test:\n" << test->module_export; 703 std::cerr << "Test:\n" << test->module_export;
706 CHECK(false); 704 CHECK(false);
707 } 705 }
708 } 706 }
709 } 707 }
710 708
(...skipping 1338 matching lines...) Expand 10 before | Expand all | Expand 10 after
2049 if (!ValidationOf(Module(kTests[ii])) 2047 if (!ValidationOf(Module(kTests[ii]))
2050 ->FailsWithMessage( 2048 ->FailsWithMessage(
2051 "Constant in return must be signed, float, or double.")) { 2049 "Constant in return must be signed, float, or double.")) {
2052 std::cerr << "Test:\n" << kTests[ii]; 2050 std::cerr << "Test:\n" << kTests[ii];
2053 CHECK(false); 2051 CHECK(false);
2054 } 2052 }
2055 } 2053 }
2056 } 2054 }
2057 2055
2058 } // namespace 2056 } // namespace
OLDNEW
« no previous file with comments | « src/asmjs/asm-typer.cc ('k') | test/mjsunit/asm/asm-validation.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698