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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 const char* data() const { return data_; } | 193 const char* data() const { return data_; } |
194 size_t length() const { return length_; } | 194 size_t length() const { return length_; } |
195 | 195 |
196 private: | 196 private: |
197 const char* data_; | 197 const char* data_; |
198 size_t length_; | 198 size_t length_; |
199 }; | 199 }; |
200 | 200 |
201 | 201 |
202 TEST(UsingCachedData) { | 202 TEST(UsingCachedData) { |
| 203 // Producing cached parser data while parsing eagerly is not supported. |
| 204 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; |
| 205 |
203 v8::Isolate* isolate = CcTest::isolate(); | 206 v8::Isolate* isolate = CcTest::isolate(); |
204 v8::HandleScope handles(isolate); | 207 v8::HandleScope handles(isolate); |
205 v8::Local<v8::Context> context = v8::Context::New(isolate); | 208 v8::Local<v8::Context> context = v8::Context::New(isolate); |
206 v8::Context::Scope context_scope(context); | 209 v8::Context::Scope context_scope(context); |
207 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 210 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
208 i::GetCurrentStackPosition() - 128 * 1024); | 211 i::GetCurrentStackPosition() - 128 * 1024); |
209 | 212 |
210 // Source containing functions that might be lazily compiled and all types | 213 // Source containing functions that might be lazily compiled and all types |
211 // of symbols (string, propertyName, regexp). | 214 // of symbols (string, propertyName, regexp). |
212 const char* source = | 215 const char* source = |
(...skipping 30 matching lines...) Expand all Loading... |
243 .ToLocalChecked(); | 246 .ToLocalChecked(); |
244 i::FLAG_lazy = false; | 247 i::FLAG_lazy = false; |
245 v8::ScriptCompiler::CompileUnboundScript( | 248 v8::ScriptCompiler::CompileUnboundScript( |
246 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) | 249 isolate, &script_source, v8::ScriptCompiler::kConsumeParserCache) |
247 .ToLocalChecked(); | 250 .ToLocalChecked(); |
248 i::FLAG_lazy = lazy_flag; | 251 i::FLAG_lazy = lazy_flag; |
249 } | 252 } |
250 | 253 |
251 | 254 |
252 TEST(PreparseFunctionDataIsUsed) { | 255 TEST(PreparseFunctionDataIsUsed) { |
| 256 // Producing cached parser data while parsing eagerly is not supported. |
| 257 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; |
| 258 |
253 // This tests that we actually do use the function data generated by the | 259 // This tests that we actually do use the function data generated by the |
254 // preparser. | 260 // preparser. |
255 | 261 |
256 // Make preparsing work for short scripts. | 262 // Make preparsing work for short scripts. |
257 i::FLAG_min_preparse_length = 0; | 263 i::FLAG_min_preparse_length = 0; |
258 | 264 |
259 v8::Isolate* isolate = CcTest::isolate(); | 265 v8::Isolate* isolate = CcTest::isolate(); |
260 v8::HandleScope handles(isolate); | 266 v8::HandleScope handles(isolate); |
261 v8::Local<v8::Context> context = v8::Context::New(isolate); | 267 v8::Local<v8::Context> context = v8::Context::New(isolate); |
262 v8::Context::Scope context_scope(context); | 268 v8::Context::Scope context_scope(context); |
(...skipping 2966 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3229 v8::String::NewFromTwoByte(isolate, two_byte_name, | 3235 v8::String::NewFromTwoByte(isolate, two_byte_name, |
3230 v8::NewStringType::kNormal) | 3236 v8::NewStringType::kNormal) |
3231 .ToLocalChecked(); | 3237 .ToLocalChecked(); |
3232 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); | 3238 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); |
3233 i::DeleteArray(two_byte_source); | 3239 i::DeleteArray(two_byte_source); |
3234 i::DeleteArray(two_byte_name); | 3240 i::DeleteArray(two_byte_name); |
3235 } | 3241 } |
3236 | 3242 |
3237 | 3243 |
3238 TEST(RegressionLazyFunctionWithErrorWithArg) { | 3244 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 3245 // Test only applies when lazy parsing. |
| 3246 if (!i::FLAG_lazy || (i::FLAG_ignition && i::FLAG_ignition_eager)) return; |
| 3247 |
3239 // The bug occurred when a lazy function had an error which requires a | 3248 // The bug occurred when a lazy function had an error which requires a |
3240 // parameter (such as "unknown label" here). The error message was processed | 3249 // parameter (such as "unknown label" here). The error message was processed |
3241 // before the AstValueFactory containing the error message string was | 3250 // before the AstValueFactory containing the error message string was |
3242 // internalized. | 3251 // internalized. |
3243 v8::Isolate* isolate = CcTest::isolate(); | 3252 v8::Isolate* isolate = CcTest::isolate(); |
3244 v8::HandleScope scope(isolate); | 3253 v8::HandleScope scope(isolate); |
3245 LocalContext env; | 3254 LocalContext env; |
3246 i::FLAG_lazy = true; | 3255 i::FLAG_lazy = true; |
3247 i::FLAG_min_preparse_length = 0; | 3256 i::FLAG_min_preparse_length = 0; |
3248 CompileRun("function this_is_lazy() {\n" | 3257 CompileRun("function this_is_lazy() {\n" |
(...skipping 4122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7371 // "Array() **= 10", | 7380 // "Array() **= 10", |
7372 NULL | 7381 NULL |
7373 }; | 7382 }; |
7374 // clang-format on | 7383 // clang-format on |
7375 | 7384 |
7376 static const ParserFlag always_flags[] = { | 7385 static const ParserFlag always_flags[] = { |
7377 kAllowHarmonyExponentiationOperator}; | 7386 kAllowHarmonyExponentiationOperator}; |
7378 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7387 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7379 arraysize(always_flags)); | 7388 arraysize(always_flags)); |
7380 } | 7389 } |
OLD | NEW |