| 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 211 size_t length() const { return length_; } | 211 size_t length() const { return length_; } |
| 212 | 212 |
| 213 private: | 213 private: |
| 214 const char* data_; | 214 const char* data_; |
| 215 size_t length_; | 215 size_t length_; |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 | 218 |
| 219 TEST(UsingCachedData) { | 219 TEST(UsingCachedData) { |
| 220 // Producing cached parser data while parsing eagerly is not supported. | 220 // Producing cached parser data while parsing eagerly is not supported. |
| 221 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; | 221 if (!i::FLAG_lazy) return; |
| 222 | 222 |
| 223 v8::Isolate* isolate = CcTest::isolate(); | 223 v8::Isolate* isolate = CcTest::isolate(); |
| 224 v8::HandleScope handles(isolate); | 224 v8::HandleScope handles(isolate); |
| 225 v8::Local<v8::Context> context = v8::Context::New(isolate); | 225 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 226 v8::Context::Scope context_scope(context); | 226 v8::Context::Scope context_scope(context); |
| 227 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 227 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
| 228 i::GetCurrentStackPosition() - 128 * 1024); | 228 i::GetCurrentStackPosition() - 128 * 1024); |
| 229 | 229 |
| 230 // Source containing functions that might be lazily compiled and all types | 230 // Source containing functions that might be lazily compiled and all types |
| 231 // of symbols (string, propertyName, regexp). | 231 // of symbols (string, propertyName, regexp). |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 i::FLAG_lazy = false; | 264 i::FLAG_lazy = false; |
| 265 v8::ScriptCompiler::CompileUnboundScript( | 265 v8::ScriptCompiler::CompileUnboundScript( |
| 266 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) | 266 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) |
| 267 .ToLocalChecked(); | 267 .ToLocalChecked(); |
| 268 i::FLAG_lazy = lazy_flag; | 268 i::FLAG_lazy = lazy_flag; |
| 269 } | 269 } |
| 270 | 270 |
| 271 | 271 |
| 272 TEST(PreparseFunctionDataIsUsed) { | 272 TEST(PreparseFunctionDataIsUsed) { |
| 273 // Producing cached parser data while parsing eagerly is not supported. | 273 // Producing cached parser data while parsing eagerly is not supported. |
| 274 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; | 274 if (!i::FLAG_lazy) return; |
| 275 | 275 |
| 276 // This tests that we actually do use the function data generated by the | 276 // This tests that we actually do use the function data generated by the |
| 277 // preparser. | 277 // preparser. |
| 278 | 278 |
| 279 // Make preparsing work for short scripts. | 279 // Make preparsing work for short scripts. |
| 280 i::FLAG_min_preparse_length = 0; | 280 i::FLAG_min_preparse_length = 0; |
| 281 | 281 |
| 282 v8::Isolate* isolate = CcTest::isolate(); | 282 v8::Isolate* isolate = CcTest::isolate(); |
| 283 v8::HandleScope handles(isolate); | 283 v8::HandleScope handles(isolate); |
| 284 v8::Local<v8::Context> context = v8::Context::New(isolate); | 284 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 455 preparser.set_allow_lazy(true); | 455 preparser.set_allow_lazy(true); |
| 456 i::PreParser::PreParseResult result = preparser.PreParseProgram(); | 456 i::PreParser::PreParseResult result = preparser.PreParseProgram(); |
| 457 // Even in the case of a syntax error, kPreParseSuccess is returned. | 457 // Even in the case of a syntax error, kPreParseSuccess is returned. |
| 458 CHECK_EQ(i::PreParser::kPreParseSuccess, result); | 458 CHECK_EQ(i::PreParser::kPreParseSuccess, result); |
| 459 CHECK(log.HasError()); | 459 CHECK(log.HasError()); |
| 460 } | 460 } |
| 461 | 461 |
| 462 | 462 |
| 463 TEST(Regress928) { | 463 TEST(Regress928) { |
| 464 // Test only applies when lazy parsing. | 464 // Test only applies when lazy parsing. |
| 465 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; | 465 if (!i::FLAG_lazy) return; |
| 466 i::FLAG_min_preparse_length = 0; | 466 i::FLAG_min_preparse_length = 0; |
| 467 | 467 |
| 468 // Tests that the first non-toplevel function is not included in the preparse | 468 // Tests that the first non-toplevel function is not included in the preparse |
| 469 // data. | 469 // data. |
| 470 const char* program = | 470 const char* program = |
| 471 "try { } catch (e) { var foo = function () { /* first */ } }" | 471 "try { } catch (e) { var foo = function () { /* first */ } }" |
| 472 "var bar = function () { /* second */ }"; | 472 "var bar = function () { /* second */ }"; |
| 473 | 473 |
| 474 v8::Isolate* isolate = CcTest::isolate(); | 474 v8::Isolate* isolate = CcTest::isolate(); |
| 475 v8::HandleScope handles(isolate); | 475 v8::HandleScope handles(isolate); |
| (...skipping 2664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3140 v8::NewStringType::kNormal) | 3140 v8::NewStringType::kNormal) |
| 3141 .ToLocalChecked(); | 3141 .ToLocalChecked(); |
| 3142 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); | 3142 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); |
| 3143 i::DeleteArray(two_byte_source); | 3143 i::DeleteArray(two_byte_source); |
| 3144 i::DeleteArray(two_byte_name); | 3144 i::DeleteArray(two_byte_name); |
| 3145 } | 3145 } |
| 3146 | 3146 |
| 3147 | 3147 |
| 3148 TEST(RegressionLazyFunctionWithErrorWithArg) { | 3148 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 3149 // Test only applies when lazy parsing. | 3149 // Test only applies when lazy parsing. |
| 3150 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; | 3150 if (!i::FLAG_lazy) return; |
| 3151 | 3151 |
| 3152 // The bug occurred when a lazy function had an error which requires a | 3152 // The bug occurred when a lazy function had an error which requires a |
| 3153 // parameter (such as "unknown label" here). The error message was processed | 3153 // parameter (such as "unknown label" here). The error message was processed |
| 3154 // before the AstValueFactory containing the error message string was | 3154 // before the AstValueFactory containing the error message string was |
| 3155 // internalized. | 3155 // internalized. |
| 3156 v8::Isolate* isolate = CcTest::isolate(); | 3156 v8::Isolate* isolate = CcTest::isolate(); |
| 3157 v8::HandleScope scope(isolate); | 3157 v8::HandleScope scope(isolate); |
| 3158 LocalContext env; | 3158 LocalContext env; |
| 3159 i::FLAG_lazy = true; | 3159 i::FLAG_lazy = true; |
| 3160 i::FLAG_min_preparse_length = 0; | 3160 i::FLAG_min_preparse_length = 0; |
| (...skipping 5164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8325 const char* data[] = { | 8325 const char* data[] = { |
| 8326 "const arguments = 1", | 8326 "const arguments = 1", |
| 8327 "let arguments", | 8327 "let arguments", |
| 8328 "var arguments", | 8328 "var arguments", |
| 8329 NULL | 8329 NULL |
| 8330 }; | 8330 }; |
| 8331 // clang-format on | 8331 // clang-format on |
| 8332 RunParserSyncTest(context_data, data, kSuccess); | 8332 RunParserSyncTest(context_data, data, kSuccess); |
| 8333 } | 8333 } |
| 8334 } | 8334 } |
| OLD | NEW |