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 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 const char* data() const { return data_; } | 219 const char* data() const { return data_; } |
220 size_t length() const { return length_; } | 220 size_t length() const { return length_; } |
221 | 221 |
222 private: | 222 private: |
223 const char* data_; | 223 const char* data_; |
224 size_t length_; | 224 size_t length_; |
225 }; | 225 }; |
226 | 226 |
227 | 227 |
228 TEST(UsingCachedData) { | 228 TEST(UsingCachedData) { |
| 229 // Producing cached parser data while parsing eagerly is not supported. |
| 230 if (!i::FLAG_lazy || i::FLAG_ignition) return; |
| 231 |
229 v8::Isolate* isolate = CcTest::isolate(); | 232 v8::Isolate* isolate = CcTest::isolate(); |
230 v8::HandleScope handles(isolate); | 233 v8::HandleScope handles(isolate); |
231 v8::Local<v8::Context> context = v8::Context::New(isolate); | 234 v8::Local<v8::Context> context = v8::Context::New(isolate); |
232 v8::Context::Scope context_scope(context); | 235 v8::Context::Scope context_scope(context); |
233 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 236 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
234 i::GetCurrentStackPosition() - 128 * 1024); | 237 i::GetCurrentStackPosition() - 128 * 1024); |
235 | 238 |
236 // Source containing functions that might be lazily compiled and all types | 239 // Source containing functions that might be lazily compiled and all types |
237 // of symbols (string, propertyName, regexp). | 240 // of symbols (string, propertyName, regexp). |
238 const char* source = | 241 const char* source = |
(...skipping 30 matching lines...) Expand all Loading... |
269 .ToLocalChecked(); | 272 .ToLocalChecked(); |
270 i::FLAG_lazy = false; | 273 i::FLAG_lazy = false; |
271 v8::ScriptCompiler::CompileUnboundScript( | 274 v8::ScriptCompiler::CompileUnboundScript( |
272 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) | 275 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) |
273 .ToLocalChecked(); | 276 .ToLocalChecked(); |
274 i::FLAG_lazy = lazy_flag; | 277 i::FLAG_lazy = lazy_flag; |
275 } | 278 } |
276 | 279 |
277 | 280 |
278 TEST(PreparseFunctionDataIsUsed) { | 281 TEST(PreparseFunctionDataIsUsed) { |
| 282 // Producing cached parser data while parsing eagerly is not supported. |
| 283 if (!i::FLAG_lazy || i::FLAG_ignition) return; |
| 284 |
279 // This tests that we actually do use the function data generated by the | 285 // This tests that we actually do use the function data generated by the |
280 // preparser. | 286 // preparser. |
281 | 287 |
282 // Make preparsing work for short scripts. | 288 // Make preparsing work for short scripts. |
283 i::FLAG_min_preparse_length = 0; | 289 i::FLAG_min_preparse_length = 0; |
284 | 290 |
285 v8::Isolate* isolate = CcTest::isolate(); | 291 v8::Isolate* isolate = CcTest::isolate(); |
286 v8::HandleScope handles(isolate); | 292 v8::HandleScope handles(isolate); |
287 v8::Local<v8::Context> context = v8::Context::New(isolate); | 293 v8::Local<v8::Context> context = v8::Context::New(isolate); |
288 v8::Context::Scope context_scope(context); | 294 v8::Context::Scope context_scope(context); |
(...skipping 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3257 v8::String::NewFromTwoByte(isolate, two_byte_name, | 3263 v8::String::NewFromTwoByte(isolate, two_byte_name, |
3258 v8::NewStringType::kNormal) | 3264 v8::NewStringType::kNormal) |
3259 .ToLocalChecked(); | 3265 .ToLocalChecked(); |
3260 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); | 3266 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); |
3261 i::DeleteArray(two_byte_source); | 3267 i::DeleteArray(two_byte_source); |
3262 i::DeleteArray(two_byte_name); | 3268 i::DeleteArray(two_byte_name); |
3263 } | 3269 } |
3264 | 3270 |
3265 | 3271 |
3266 TEST(RegressionLazyFunctionWithErrorWithArg) { | 3272 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 3273 // Test only applies when lazy parsing. |
| 3274 if (!i::FLAG_lazy || i::FLAG_ignition) return; |
| 3275 |
3267 // The bug occurred when a lazy function had an error which requires a | 3276 // The bug occurred when a lazy function had an error which requires a |
3268 // parameter (such as "unknown label" here). The error message was processed | 3277 // parameter (such as "unknown label" here). The error message was processed |
3269 // before the AstValueFactory containing the error message string was | 3278 // before the AstValueFactory containing the error message string was |
3270 // internalized. | 3279 // internalized. |
3271 v8::Isolate* isolate = CcTest::isolate(); | 3280 v8::Isolate* isolate = CcTest::isolate(); |
3272 v8::HandleScope scope(isolate); | 3281 v8::HandleScope scope(isolate); |
3273 LocalContext env; | 3282 LocalContext env; |
3274 i::FLAG_lazy = true; | 3283 i::FLAG_lazy = true; |
3275 i::FLAG_min_preparse_length = 0; | 3284 i::FLAG_min_preparse_length = 0; |
3276 CompileRun("function this_is_lazy() {\n" | 3285 CompileRun("function this_is_lazy() {\n" |
(...skipping 4159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7436 // "Array() **= 10", | 7445 // "Array() **= 10", |
7437 NULL | 7446 NULL |
7438 }; | 7447 }; |
7439 // clang-format on | 7448 // clang-format on |
7440 | 7449 |
7441 static const ParserFlag always_flags[] = { | 7450 static const ParserFlag always_flags[] = { |
7442 kAllowHarmonyExponentiationOperator}; | 7451 kAllowHarmonyExponentiationOperator}; |
7443 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7452 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7444 arraysize(always_flags)); | 7453 arraysize(always_flags)); |
7445 } | 7454 } |
OLD | NEW |