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

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

Issue 5295004: Preparser extracted into separate files that can be compiled to a library. (Closed)
Patch Set: Created 10 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
« src/preparser.h ('K') | « src/scanner-base.cc ('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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 250
251 const char* programs[] = { 251 const char* programs[] = {
252 "{label: 42}", 252 "{label: 42}",
253 "var x = 42;", 253 "var x = 42;",
254 "function foo(x, y) { return x + y; }", 254 "function foo(x, y) { return x + y; }",
255 "native function foo(); return %ArgleBargle(glop);", 255 "native function foo(); return %ArgleBargle(glop);",
256 "var x = new new Function('this.x = 42');", 256 "var x = new new Function('this.x = 42');",
257 NULL 257 NULL
258 }; 258 };
259 259
260 uintptr_t stack_limit = i::StackGuard::real_climit();
260 for (int i = 0; programs[i]; i++) { 261 for (int i = 0; programs[i]; i++) {
261 const char* program = programs[i]; 262 const char* program = programs[i];
262 unibrow::Utf8InputBuffer<256> stream(program, strlen(program)); 263 unibrow::Utf8InputBuffer<256> stream(program, strlen(program));
263 i::CompleteParserRecorder log; 264 i::CompleteParserRecorder log;
264 i::V8JavaScriptScanner scanner; 265 i::V8JavaScriptScanner scanner;
265 scanner.Initialize(i::Handle<i::String>::null(), &stream); 266 scanner.Initialize(i::Handle<i::String>::null(), &stream);
266 v8::preparser::PreParser preparser; 267 v8::preparser::PreParser preparser;
267 bool result = preparser.PreParseProgram(&scanner, &log, true); 268
269 bool result = preparser.PreParseProgram(&scanner, &log, true, stack_limit);
268 CHECK(result); 270 CHECK(result);
269 i::ScriptDataImpl data(log.ExtractData()); 271 i::ScriptDataImpl data(log.ExtractData());
270 CHECK(!data.has_error()); 272 CHECK(!data.has_error());
271 } 273 }
272 } 274 }
273 275
274 276
275 TEST(RegressChromium62639) { 277 TEST(RegressChromium62639) {
276 int marker; 278 int marker;
277 i::StackGuard::SetStackLimit( 279 i::StackGuard::SetStackLimit(
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 CHECK(!entry1.is_valid()); 322 CHECK(!entry1.is_valid());
321 323
322 int second_function = strstr(program + first_lbrace, "function") - program; 324 int second_function = strstr(program + first_lbrace, "function") - program;
323 int second_lbrace = second_function + strlen("function () "); 325 int second_lbrace = second_function + strlen("function () ");
324 CHECK_EQ('{', program[second_lbrace]); 326 CHECK_EQ('{', program[second_lbrace]);
325 i::FunctionEntry entry2 = data->GetFunctionEntry(second_lbrace); 327 i::FunctionEntry entry2 = data->GetFunctionEntry(second_lbrace);
326 CHECK(entry2.is_valid()); 328 CHECK(entry2.is_valid());
327 CHECK_EQ('}', program[entry2.end_pos() - 1]); 329 CHECK_EQ('}', program[entry2.end_pos() - 1]);
328 delete data; 330 delete data;
329 } 331 }
332
333
334 TEST(PreParseOverflow) {
335 int marker;
336 i::StackGuard::SetStackLimit(
337 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
338
339 size_t kProgramSize = 1024 * 1024;
340 i::SmartPointer<char> program(
341 reinterpret_cast<char*>(malloc(kProgramSize + 1)));
342 memset(*program, '(', kProgramSize);
343 program[kProgramSize] = '\0';
344
345 uintptr_t stack_limit = i::StackGuard::real_climit();
346
347 unibrow::Utf8InputBuffer<256> stream(*program, strlen(*program));
348 i::CompleteParserRecorder log;
349 i::V8JavaScriptScanner scanner;
350 scanner.Initialize(i::Handle<i::String>::null(), &stream);
351 v8::preparser::PreParser preparser;
352
353 bool result = preparser.PreParseProgram(&scanner, &log, true, stack_limit);
354 CHECK(!result);
355 }
OLDNEW
« src/preparser.h ('K') | « src/scanner-base.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698