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) 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) 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 2968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3231 v8::String::NewFromTwoByte(isolate, two_byte_name, | 3237 v8::String::NewFromTwoByte(isolate, two_byte_name, |
3232 v8::NewStringType::kNormal) | 3238 v8::NewStringType::kNormal) |
3233 .ToLocalChecked(); | 3239 .ToLocalChecked(); |
3234 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); | 3240 CHECK(result->Equals(isolate->GetCurrentContext(), expected_name).FromJust()); |
3235 i::DeleteArray(two_byte_source); | 3241 i::DeleteArray(two_byte_source); |
3236 i::DeleteArray(two_byte_name); | 3242 i::DeleteArray(two_byte_name); |
3237 } | 3243 } |
3238 | 3244 |
3239 | 3245 |
3240 TEST(RegressionLazyFunctionWithErrorWithArg) { | 3246 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 3247 // Test only applies when lazy parsing. |
| 3248 if (!i::FLAG_lazy || i::FLAG_ignition) return; |
| 3249 |
3241 // The bug occurred when a lazy function had an error which requires a | 3250 // The bug occurred when a lazy function had an error which requires a |
3242 // parameter (such as "unknown label" here). The error message was processed | 3251 // parameter (such as "unknown label" here). The error message was processed |
3243 // before the AstValueFactory containing the error message string was | 3252 // before the AstValueFactory containing the error message string was |
3244 // internalized. | 3253 // internalized. |
3245 v8::Isolate* isolate = CcTest::isolate(); | 3254 v8::Isolate* isolate = CcTest::isolate(); |
3246 v8::HandleScope scope(isolate); | 3255 v8::HandleScope scope(isolate); |
3247 LocalContext env; | 3256 LocalContext env; |
3248 i::FLAG_lazy = true; | 3257 i::FLAG_lazy = true; |
3249 i::FLAG_min_preparse_length = 0; | 3258 i::FLAG_min_preparse_length = 0; |
3250 CompileRun("function this_is_lazy() {\n" | 3259 CompileRun("function this_is_lazy() {\n" |
(...skipping 4159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7410 // "Array() **= 10", | 7419 // "Array() **= 10", |
7411 NULL | 7420 NULL |
7412 }; | 7421 }; |
7413 // clang-format on | 7422 // clang-format on |
7414 | 7423 |
7415 static const ParserFlag always_flags[] = { | 7424 static const ParserFlag always_flags[] = { |
7416 kAllowHarmonyExponentiationOperator}; | 7425 kAllowHarmonyExponentiationOperator}; |
7417 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, | 7426 RunParserSyncTest(context_data, error_data, kError, NULL, 0, always_flags, |
7418 arraysize(always_flags)); | 7427 arraysize(always_flags)); |
7419 } | 7428 } |
OLD | NEW |