OLD | NEW |
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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); | 306 CHECK_EQ(v8::preparser::PreParser::kPreParseSuccess, result); |
307 i::ScriptDataImpl data(log.ExtractData()); | 307 i::ScriptDataImpl data(log.ExtractData()); |
308 // Data contains syntax error. | 308 // Data contains syntax error. |
309 CHECK(data.has_error()); | 309 CHECK(data.has_error()); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 | 313 |
314 TEST(RegressChromium62639) { | 314 TEST(RegressChromium62639) { |
315 v8::V8::Initialize(); | 315 v8::V8::Initialize(); |
| 316 i::Isolate* isolate = i::Isolate::Current(); |
316 | 317 |
317 int marker; | 318 int marker; |
318 i::Isolate::Current()->stack_guard()->SetStackLimit( | 319 isolate->stack_guard()->SetStackLimit( |
319 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 320 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
320 | 321 |
321 const char* program = "var x = 'something';\n" | 322 const char* program = "var x = 'something';\n" |
322 "escape: function() {}"; | 323 "escape: function() {}"; |
323 // Fails parsing expecting an identifier after "function". | 324 // Fails parsing expecting an identifier after "function". |
324 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), | 325 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), |
325 // and then used the invalid currently scanned literal. This always | 326 // and then used the invalid currently scanned literal. This always |
326 // failed in debug mode, and sometimes crashed in release mode. | 327 // failed in debug mode, and sometimes crashed in release mode. |
327 | 328 |
328 i::Utf8ToUtf16CharacterStream stream( | 329 i::Utf8ToUtf16CharacterStream stream( |
329 reinterpret_cast<const i::byte*>(program), | 330 reinterpret_cast<const i::byte*>(program), |
330 static_cast<unsigned>(strlen(program))); | 331 static_cast<unsigned>(strlen(program))); |
331 i::ScriptDataImpl* data = i::PreParserApi::PreParse(&stream); | 332 i::ScriptDataImpl* data = i::PreParserApi::PreParse(isolate, &stream); |
332 CHECK(data->HasError()); | 333 CHECK(data->HasError()); |
333 delete data; | 334 delete data; |
334 } | 335 } |
335 | 336 |
336 | 337 |
337 TEST(Regress928) { | 338 TEST(Regress928) { |
338 v8::V8::Initialize(); | 339 v8::V8::Initialize(); |
339 i::Isolate* isolate = i::Isolate::Current(); | 340 i::Isolate* isolate = i::Isolate::Current(); |
340 i::Factory* factory = isolate->factory(); | 341 i::Factory* factory = isolate->factory(); |
341 | 342 |
342 // Preparsing didn't consider the catch clause of a try statement | 343 // Preparsing didn't consider the catch clause of a try statement |
343 // as with-content, which made it assume that a function inside | 344 // as with-content, which made it assume that a function inside |
344 // the block could be lazily compiled, and an extra, unexpected, | 345 // the block could be lazily compiled, and an extra, unexpected, |
345 // entry was added to the data. | 346 // entry was added to the data. |
346 int marker; | 347 int marker; |
347 isolate->stack_guard()->SetStackLimit( | 348 isolate->stack_guard()->SetStackLimit( |
348 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 349 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
349 | 350 |
350 const char* program = | 351 const char* program = |
351 "try { } catch (e) { var foo = function () { /* first */ } }" | 352 "try { } catch (e) { var foo = function () { /* first */ } }" |
352 "var bar = function () { /* second */ }"; | 353 "var bar = function () { /* second */ }"; |
353 | 354 |
354 v8::HandleScope handles(v8::Isolate::GetCurrent()); | 355 v8::HandleScope handles(v8::Isolate::GetCurrent()); |
355 i::Handle<i::String> source( | 356 i::Handle<i::String> source( |
356 factory->NewStringFromAscii(i::CStrVector(program))); | 357 factory->NewStringFromAscii(i::CStrVector(program))); |
357 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); | 358 i::GenericStringUtf16CharacterStream stream(source, 0, source->length()); |
358 i::ScriptDataImpl* data = i::PreParserApi::PreParse(&stream); | 359 i::ScriptDataImpl* data = i::PreParserApi::PreParse(isolate, &stream); |
359 CHECK(!data->HasError()); | 360 CHECK(!data->HasError()); |
360 | 361 |
361 data->Initialize(); | 362 data->Initialize(); |
362 | 363 |
363 int first_function = | 364 int first_function = |
364 static_cast<int>(strstr(program, "function") - program); | 365 static_cast<int>(strstr(program, "function") - program); |
365 int first_lbrace = first_function + i::StrLength("function () "); | 366 int first_lbrace = first_function + i::StrLength("function () "); |
366 CHECK_EQ('{', program[first_lbrace]); | 367 CHECK_EQ('{', program[first_lbrace]); |
367 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); | 368 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); |
368 CHECK(!entry1.is_valid()); | 369 CHECK(!entry1.is_valid()); |
(...skipping 948 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1317 " b = function() { \n" | 1318 " b = function() { \n" |
1318 " 01; \n" | 1319 " 01; \n" |
1319 " }; \n" | 1320 " }; \n" |
1320 "}; \n"; | 1321 "}; \n"; |
1321 v8::Script::Compile(v8::String::New(script)); | 1322 v8::Script::Compile(v8::String::New(script)); |
1322 CHECK(try_catch.HasCaught()); | 1323 CHECK(try_catch.HasCaught()); |
1323 v8::String::Utf8Value exception(try_catch.Exception()); | 1324 v8::String::Utf8Value exception(try_catch.Exception()); |
1324 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", | 1325 CHECK_EQ("SyntaxError: Octal literals are not allowed in strict mode.", |
1325 *exception); | 1326 *exception); |
1326 } | 1327 } |
OLD | NEW |