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

Unified Diff: test/cctest/test-parsing.cc

Issue 261273003: Remove symbol preparse data altogether. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 6 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/test-parsing.cc
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc
index e0c21f449e628e32d5b842002c079495c8cf8052..58734d054e2d67ddb15d036213cc91ff7a3f2150 100644
--- a/test/cctest/test-parsing.cc
+++ b/test/cctest/test-parsing.cc
@@ -277,56 +277,6 @@ TEST(PreparseFunctionDataIsUsed) {
}
-TEST(PreparseSymbolDataIsUsed) {
- // This tests that we actually do use the symbol data generated by the
- // preparser.
-
- // Only do one compilation pass in this test (otherwise we will parse the
- // source code again without preparse data and it will fail).
- i::FLAG_crankshaft = false;
-
- // Make preparsing work for short scripts.
- i::FLAG_min_preparse_length = 0;
-
- v8::Isolate* isolate = CcTest::isolate();
- v8::HandleScope handles(isolate);
- v8::Local<v8::Context> context = v8::Context::New(isolate);
- v8::Context::Scope context_scope(context);
- int marker;
- CcTest::i_isolate()->stack_guard()->SetStackLimit(
- reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
-
- // Note that the ( before function makes the function not lazily compiled.
- const char* good_code =
- "(function weird() { var foo = 26; return foo; })()";
-
- // Insert an undefined identifier. If the preparser data is used, the symbol
- // stream is used instead, and this identifier resolves to "foo".
- const char* bad_code =
- "(function weird() { var foo = 26; return wut; })()";
-
- v8::ScriptCompiler::Source good_source(v8_str(good_code));
- v8::ScriptCompiler::Compile(isolate, &good_source,
- v8::ScriptCompiler::kProduceDataToCache);
-
- const v8::ScriptCompiler::CachedData* cached_data =
- good_source.GetCachedData();
- CHECK(cached_data->data != NULL);
- CHECK_GT(cached_data->length, 0);
-
- // Now compile the erroneous code with the good preparse data. If the preparse
- // data is used, we will see a second occurrence of "foo" instead of the
- // unknown "wut".
- v8::ScriptCompiler::Source bad_source(
- v8_str(bad_code), new v8::ScriptCompiler::CachedData(
- cached_data->data, cached_data->length));
- v8::Local<v8::Value> result =
- v8::ScriptCompiler::Compile(isolate, &bad_source)->Run();
- CHECK(result->IsInt32());
- CHECK_EQ(26, result->Int32Value());
-}
-
-
TEST(StandAlonePreParser) {
v8::V8::Initialize();
@@ -435,53 +385,6 @@ TEST(PreparsingObjectLiterals) {
}
}
-namespace v8 {
-namespace internal {
-
-struct CompleteParserRecorderFriend {
- static void FakeWritingSymbolIdInPreParseData(CompleteParserRecorder* log,
- int number) {
- log->WriteNumber(number);
- if (log->symbol_id_ < number + 1) {
- log->symbol_id_ = number + 1;
- }
- }
-};
-
-}
-}
-
-
-TEST(StoringNumbersInPreParseData) {
- // Symbol IDs are split into chunks of 7 bits for storing. This is a
- // regression test for a bug where a symbol id was incorrectly stored if some
- // of the chunks in the middle were all zeros.
- typedef i::CompleteParserRecorderFriend F;
- i::CompleteParserRecorder log;
- for (int i = 0; i < 18; ++i) {
- F::FakeWritingSymbolIdInPreParseData(&log, 1 << i);
- }
- for (int i = 1; i < 18; ++i) {
- F::FakeWritingSymbolIdInPreParseData(&log, (1 << i) + 1);
- }
- for (int i = 6; i < 18; ++i) {
- F::FakeWritingSymbolIdInPreParseData(&log, (3 << i) + (5 << (i - 6)));
- }
- i::Vector<unsigned> store = log.ExtractData();
- i::ScriptData script_data(store);
- script_data.Initialize();
- // Check that we get the same symbols back.
- for (int i = 0; i < 18; ++i) {
- CHECK_EQ(1 << i, script_data.GetSymbolIdentifier());
- }
- for (int i = 1; i < 18; ++i) {
- CHECK_EQ((1 << i) + 1, script_data.GetSymbolIdentifier());
- }
- for (int i = 6; i < 18; ++i) {
- CHECK_EQ((3 << i) + (5 << (i - 6)), script_data.GetSymbolIdentifier());
- }
-}
-
TEST(RegressChromium62639) {
v8::V8::Initialize();
@@ -2072,28 +1975,19 @@ TEST(DontRegressPreParserDataSizes) {
struct TestCase {
const char* program;
- int symbols;
int functions;
} test_cases[] = {
- // Labels and variables are recorded as symbols.
- {"{label: 42}", 1, 0}, {"{label: 42; label2: 43}", 2, 0},
- {"var x = 42;", 1, 0}, {"var x = 42, y = 43;", 2, 0},
- {"var x = {y: 1};", 2, 0},
- {"var x = {}; x.y = 1", 2, 0},
- // "get" is recorded as a symbol too.
- {"var x = {get foo(){} };", 3, 1},
- // When keywords are used as identifiers, they're logged as symbols, too:
- {"var x = {if: 1};", 2, 0},
- {"var x = {}; x.if = 1", 2, 0},
- {"var x = {get if(){} };", 3, 1},
- // Functions
- {"function foo() {}", 1, 1}, {"function foo() {} function bar() {}", 2, 2},
- // Labels, variables and functions insize lazy functions are not recorded.
- {"function lazy() { var a, b, c; }", 1, 1},
- {"function lazy() { a: 1; b: 2; c: 3; }", 1, 1},
- {"function lazy() { function a() {} function b() {} function c() {} }", 1,
- 1},
- {NULL, 0, 0}
+ // No functions.
+ {"var x = 42;", 0},
+ // Functions.
+ {"function foo() {}", 1}, {"function foo() {} function bar() {}", 2},
+ // Getter / setter functions are recorded as functions if they're on the top
+ // level.
+ {"var x = {get foo(){} };", 1},
+ // Functions insize lazy functions are not recorded.
+ {"function lazy() { function a() {} function b() {} function c() {} }", 1},
+ {"function lazy() { var x = {get foo(){} } }", 1},
+ {NULL, 0}
};
for (int i = 0; test_cases[i].program; i++) {
@@ -2109,14 +2003,6 @@ TEST(DontRegressPreParserDataSizes) {
CHECK(data);
CHECK(!data->HasError());
- if (data->symbol_count() != test_cases[i].symbols) {
- i::OS::Print(
- "Expected preparse data for program:\n"
- "\t%s\n"
- "to contain %d symbols, however, received %d symbols.\n",
- program, test_cases[i].symbols, data->symbol_count());
- CHECK(false);
- }
if (data->function_count() != test_cases[i].functions) {
i::OS::Print(
"Expected preparse data for program:\n"
« no previous file with comments | « src/scanner.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698