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

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

Issue 157373002: Add regression tests for PrePreparser. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 1856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 "var foo = {}; foo.yield;", 1867 "var foo = {}; foo.yield;",
1868 "var foo = {}; foo.super;", 1868 "var foo = {}; foo.super;",
1869 "var foo = {}; foo.interface;", 1869 "var foo = {}; foo.interface;",
1870 "var foo = {}; foo.eval;", 1870 "var foo = {}; foo.eval;",
1871 "var foo = {}; foo.arguments;", 1871 "var foo = {}; foo.arguments;",
1872 NULL 1872 NULL
1873 }; 1873 };
1874 1874
1875 RunParserSyncTest(context_data, statement_data, kSuccess); 1875 RunParserSyncTest(context_data, statement_data, kSuccess);
1876 } 1876 }
1877
1878
1879 TEST(DontRegressPreParserDataSizes) {
1880 // These tests make sure that PreParser doesn't start producing less data.
1881
1882 v8::V8::Initialize();
1883
1884 int marker;
1885 CcTest::i_isolate()->stack_guard()->SetStackLimit(
1886 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
1887
1888 struct TestCase {
1889 const char* program;
1890 int symbols;
1891 int functions;
1892 } test_cases[] = {
1893 // Labels, variables and functions are recorded as symbols.
1894 {"{label: 42}", 1, 0}, {"{label: 42; label2: 43}", 2, 0},
1895 {"var x = 42;", 1, 0}, {"var x = 42, y = 43;", 2, 0},
1896 {"function foo() {}", 1, 1}, {"function foo() {} function bar() {}", 2, 2},
1897 // Labels, variables and functions insize lazy functions are not recorded.
1898 {"function lazy() { var a, b, c; }", 1, 1},
1899 {"function lazy() { a: 1; b: 2; c: 3; }", 1, 1},
1900 {"function lazy() { function a() {} function b() {} function c() {} }", 1,
1901 1},
1902 {NULL, 0, 0}
1903 };
1904 // Each function adds 5 elements to the preparse function data.
1905 const int kDataPerFunction = 5;
1906
1907 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit();
1908 for (int i = 0; test_cases[i].program; i++) {
1909 const char* program = test_cases[i].program;
1910 i::Utf8ToUtf16CharacterStream stream(
1911 reinterpret_cast<const i::byte*>(program),
1912 static_cast<unsigned>(strlen(program)));
1913 i::CompleteParserRecorder log;
1914 i::Scanner scanner(CcTest::i_isolate()->unicode_cache());
1915 scanner.Initialize(&stream);
1916
1917 i::PreParser preparser(&scanner, &log, stack_limit);
1918 preparser.set_allow_lazy(true);
1919 preparser.set_allow_natives_syntax(true);
1920 i::PreParser::PreParseResult result = preparser.PreParseProgram();
1921 CHECK_EQ(i::PreParser::kPreParseSuccess, result);
1922 if (log.symbol_ids() != test_cases[i].symbols) {
1923 i::OS::Print(
1924 "Expected preparse data for program:\n"
1925 "\t%s\n"
1926 "to contain %d symbols, however, received %d symbols.\n",
1927 program, test_cases[i].symbols, log.symbol_ids());
1928 CHECK(false);
1929 }
1930 if (log.function_position() != test_cases[i].functions * kDataPerFunction) {
1931 i::OS::Print(
1932 "Expected preparse data for program:\n"
1933 "\t%s\n"
1934 "to contain %d functions, however, received %d functions.\n",
1935 program, test_cases[i].functions,
1936 log.function_position() / kDataPerFunction);
1937 CHECK(false);
1938 }
1939 i::ScriptDataImpl data(log.ExtractData());
1940 CHECK(!data.has_error());
1941 }
1942 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698