| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 const char* program = "var x = 'something';\n" | 320 const char* program = "var x = 'something';\n" |
| 321 "escape: function() {}"; | 321 "escape: function() {}"; |
| 322 // Fails parsing expecting an identifier after "function". | 322 // Fails parsing expecting an identifier after "function". |
| 323 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), | 323 // Before fix, didn't check *ok after Expect(Token::Identifier, ok), |
| 324 // and then used the invalid currently scanned literal. This always | 324 // and then used the invalid currently scanned literal. This always |
| 325 // failed in debug mode, and sometimes crashed in release mode. | 325 // failed in debug mode, and sometimes crashed in release mode. |
| 326 | 326 |
| 327 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), | 327 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), |
| 328 static_cast<unsigned>(strlen(program))); | 328 static_cast<unsigned>(strlen(program))); |
| 329 i::ScriptDataImpl* data = | 329 i::ScriptDataImpl* data = |
| 330 i::ParserApi::PreParse(&stream, NULL, false); | 330 i::ParserApi::PreParse(&stream, NULL, i::kNoParsingFlags); |
| 331 CHECK(data->HasError()); | 331 CHECK(data->HasError()); |
| 332 delete data; | 332 delete data; |
| 333 } | 333 } |
| 334 | 334 |
| 335 | 335 |
| 336 TEST(Regress928) { | 336 TEST(Regress928) { |
| 337 v8::V8::Initialize(); | 337 v8::V8::Initialize(); |
| 338 | 338 |
| 339 // Preparsing didn't consider the catch clause of a try statement | 339 // Preparsing didn't consider the catch clause of a try statement |
| 340 // as with-content, which made it assume that a function inside | 340 // as with-content, which made it assume that a function inside |
| 341 // the block could be lazily compiled, and an extra, unexpected, | 341 // the block could be lazily compiled, and an extra, unexpected, |
| 342 // entry was added to the data. | 342 // entry was added to the data. |
| 343 int marker; | 343 int marker; |
| 344 i::Isolate::Current()->stack_guard()->SetStackLimit( | 344 i::Isolate::Current()->stack_guard()->SetStackLimit( |
| 345 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 345 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
| 346 | 346 |
| 347 const char* program = | 347 const char* program = |
| 348 "try { } catch (e) { var foo = function () { /* first */ } }" | 348 "try { } catch (e) { var foo = function () { /* first */ } }" |
| 349 "var bar = function () { /* second */ }"; | 349 "var bar = function () { /* second */ }"; |
| 350 | 350 |
| 351 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), | 351 i::Utf8ToUC16CharacterStream stream(reinterpret_cast<const i::byte*>(program), |
| 352 static_cast<unsigned>(strlen(program))); | 352 static_cast<unsigned>(strlen(program))); |
| 353 i::ScriptDataImpl* data = | 353 i::ScriptDataImpl* data = |
| 354 i::ParserApi::PartialPreParse(&stream, NULL, false); | 354 i::ParserApi::PartialPreParse(&stream, NULL, i::kNoParsingFlags); |
| 355 CHECK(!data->HasError()); | 355 CHECK(!data->HasError()); |
| 356 | 356 |
| 357 data->Initialize(); | 357 data->Initialize(); |
| 358 | 358 |
| 359 int first_function = | 359 int first_function = |
| 360 static_cast<int>(strstr(program, "function") - program); | 360 static_cast<int>(strstr(program, "function") - program); |
| 361 int first_lbrace = first_function + static_cast<int>(strlen("function () ")); | 361 int first_lbrace = first_function + static_cast<int>(strlen("function () ")); |
| 362 CHECK_EQ('{', program[first_lbrace]); | 362 CHECK_EQ('{', program[first_lbrace]); |
| 363 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); | 363 i::FunctionEntry entry1 = data->GetFunctionEntry(first_lbrace); |
| 364 CHECK(!entry1.is_valid()); | 364 CHECK(!entry1.is_valid()); |
| (...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 868 CHECK_EQ(scope->inner_scopes()->length(), 1); | 868 CHECK_EQ(scope->inner_scopes()->length(), 1); |
| 869 | 869 |
| 870 i::Scope* inner_scope = scope->inner_scopes()->at(0); | 870 i::Scope* inner_scope = scope->inner_scopes()->at(0); |
| 871 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); | 871 CHECK_EQ(inner_scope->type(), source_data[i].scope_type); |
| 872 CHECK_EQ(inner_scope->start_position(), kPrefixLen); | 872 CHECK_EQ(inner_scope->start_position(), kPrefixLen); |
| 873 // The end position of a token is one position after the last | 873 // The end position of a token is one position after the last |
| 874 // character belonging to that token. | 874 // character belonging to that token. |
| 875 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); | 875 CHECK_EQ(inner_scope->end_position(), kPrefixLen + kInnerLen); |
| 876 } | 876 } |
| 877 } | 877 } |
| OLD | NEW |