| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 305 i::FLAG_crankshaft = false; | 305 i::FLAG_crankshaft = false; |
| 306 | 306 |
| 307 v8::Isolate* isolate = CcTest::isolate(); | 307 v8::Isolate* isolate = CcTest::isolate(); |
| 308 v8::HandleScope handles(isolate); | 308 v8::HandleScope handles(isolate); |
| 309 v8::Local<v8::Context> context = v8::Context::New(isolate); | 309 v8::Local<v8::Context> context = v8::Context::New(isolate); |
| 310 v8::Context::Scope context_scope(context); | 310 v8::Context::Scope context_scope(context); |
| 311 int marker; | 311 int marker; |
| 312 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 312 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
| 313 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); | 313 reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
| 314 | 314 |
| 315 // Note that the ( before function makes the | 315 // Note that the ( before function makes the function not lazily compiled. |
| 316 const char* good_source = | 316 const char* good_source = |
| 317 "(function weird() { var foo = 26; return foo; })()"; | 317 "(function weird() { var foo = 26; return foo; })()"; |
| 318 | 318 |
| 319 // Insert an undefined identifier. If the preparser data is used, the symbol | 319 // Insert an undefined identifier. If the preparser data is used, the symbol |
| 320 // stream is used instead, and this identifier resolves correctly to"foo". | 320 // stream is used instead, and this identifier resolves to "foo". |
| 321 const char* bad_source = | 321 const char* bad_source = |
| 322 "(function weird() { var foo = 26; return wut; })()"; | 322 "(function weird() { var foo = 26; return wut; })()"; |
| 323 | 323 |
| 324 v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8_str(good_source)); | 324 v8::ScriptData* preparse = v8::ScriptData::PreCompile(v8_str(good_source)); |
| 325 CHECK(!preparse->HasError()); | 325 CHECK(!preparse->HasError()); |
| 326 | 326 |
| 327 // Now compile the erroneous code with the good preparse data. If the preparse | 327 // Now compile the erroneous code with the good preparse data. If the preparse |
| 328 // data is used, we will see a second occurrence of "foo" instead of the | 328 // data is used, we will see a second occurrence of "foo" instead of the |
| 329 // unknown "wut". | 329 // unknown "wut". |
| 330 v8::ScriptCompiler::Source source( | 330 v8::ScriptCompiler::Source source( |
| (...skipping 2121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2452 | 2452 |
| 2453 const char* statement_data[] = { | 2453 const char* statement_data[] = { |
| 2454 statement, | 2454 statement, |
| 2455 NULL | 2455 NULL |
| 2456 }; | 2456 }; |
| 2457 | 2457 |
| 2458 // The test is quite slow, so run it with a reduced set of flags. | 2458 // The test is quite slow, so run it with a reduced set of flags. |
| 2459 static const ParserFlag empty_flags[] = {kAllowLazy}; | 2459 static const ParserFlag empty_flags[] = {kAllowLazy}; |
| 2460 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); | 2460 RunParserSyncTest(context_data, statement_data, kError, empty_flags, 1); |
| 2461 } | 2461 } |
| OLD | NEW |