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

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

Issue 5188006: Push version 2.5.7 to trunk.... (Closed) Base URL: http://v8.googlecode.com/svn/trunk/
Patch Set: Created 10 years, 1 month 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 | « test/cctest/test-heap.cc ('k') | test/cctest/test-strtod.cc » ('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 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include <stdlib.h> 28 #include <stdlib.h>
29 #include <stdio.h> 29 #include <stdio.h>
30 #include <string.h>
30 31
31 #include "v8.h" 32 #include "v8.h"
32 33
33 #include "token.h" 34 #include "token.h"
34 #include "scanner.h" 35 #include "scanner.h"
35 #include "parser.h" 36 #include "parser.h"
36 #include "utils.h" 37 #include "utils.h"
37 #include "execution.h" 38 #include "execution.h"
38 #include "scanner.h" 39 #include "scanner.h"
39 #include "preparser.h" 40 #include "preparser.h"
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 i::CompleteParserRecorder log; 264 i::CompleteParserRecorder log;
264 i::Scanner scanner; 265 i::Scanner scanner;
265 scanner.Initialize(i::Handle<i::String>::null(), &stream, i::JAVASCRIPT); 266 scanner.Initialize(i::Handle<i::String>::null(), &stream, i::JAVASCRIPT);
266 v8::preparser::PreParser<i::Scanner, i::CompleteParserRecorder> preparser; 267 v8::preparser::PreParser<i::Scanner, i::CompleteParserRecorder> preparser;
267 bool result = preparser.PreParseProgram(&scanner, &log, true); 268 bool result = preparser.PreParseProgram(&scanner, &log, true);
268 CHECK(result); 269 CHECK(result);
269 i::ScriptDataImpl data(log.ExtractData()); 270 i::ScriptDataImpl data(log.ExtractData());
270 CHECK(!data.has_error()); 271 CHECK(!data.has_error());
271 } 272 }
272 } 273 }
274
275
276 TEST(RegressChromium62639) {
277 int marker;
278 i::StackGuard::SetStackLimit(
279 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
280
281 const char* program = "var x = 'something';\n"
282 "escape: function() {}";
283 // Fails parsing expecting an identifier after "function".
284 // Before fix, didn't check *ok after Expect(Token::Identifier, ok),
285 // and then used the invalid currently scanned literal. This always
286 // failed in debug mode, and sometimes crashed in release mode.
287
288 unibrow::Utf8InputBuffer<256> stream(program, strlen(program));
289 i::ScriptDataImpl* data =
290 i::ParserApi::PreParse(i::Handle<i::String>::null(), &stream, NULL);
291 CHECK(data->HasError());
292 delete data;
293 }
294
295
296 TEST(Regress928) {
297 // Preparsing didn't consider the catch clause of a try statement
298 // as with-content, which made it assume that a function inside
299 // the block could be lazily compiled, and an extra, unexpected,
300 // entry was added to the data.
301 int marker;
302 i::StackGuard::SetStackLimit(
303 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024);
304
305 const char* program =
306 "try { } catch (e) { var foo = function () { /* first */ } }"
307 "var bar = function () { /* second */ }";
308
309 unibrow::Utf8InputBuffer<256> stream(program, strlen(program));
310 i::ScriptDataImpl* data =
311 i::ParserApi::PartialPreParse(i::Handle<i::String>::null(),
312 &stream, NULL);
313 CHECK(!data->HasError());
314
315 data->Initialize();
316
317 int first_function = strstr(program, "function") - program;
318 int first_lbrace = first_function + strlen("function () ");
319 CHECK_EQ('{', program[first_lbrace]);
320 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace);
321 CHECK(!entry1.is_valid());
322
323 int second_function = strstr(program + first_lbrace, "function") - program;
324 int second_lbrace = second_function + strlen("function () ");
325 CHECK_EQ('{', program[second_lbrace]);
326 i::FunctionEntry entry2 = data->GetFunctionEntry(second_lbrace);
327 CHECK(entry2.is_valid());
328 CHECK_EQ('}', program[entry2.end_pos() - 1]);
329 delete data;
330 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap.cc ('k') | test/cctest/test-strtod.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698