| 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 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #include <stdio.h> | 28 #include <stdio.h> |
| 29 #include <stdlib.h> | 29 #include <stdlib.h> |
| 30 #include <string.h> | 30 #include <string.h> |
| 31 | 31 |
| 32 #include "src/v8.h" | 32 #include "src/v8.h" |
| 33 | 33 |
| 34 #include "src/ast-value-factory.h" |
| 34 #include "src/compiler.h" | 35 #include "src/compiler.h" |
| 35 #include "src/execution.h" | 36 #include "src/execution.h" |
| 36 #include "src/isolate.h" | 37 #include "src/isolate.h" |
| 37 #include "src/objects.h" | 38 #include "src/objects.h" |
| 38 #include "src/parser.h" | 39 #include "src/parser.h" |
| 39 #include "src/preparser.h" | 40 #include "src/preparser.h" |
| 40 #include "src/scanner-character-streams.h" | 41 #include "src/scanner-character-streams.h" |
| 41 #include "src/token.h" | 42 #include "src/token.h" |
| 42 #include "src/utils.h" | 43 #include "src/utils.h" |
| 43 #include "test/cctest/cctest.h" | 44 #include "test/cctest/cctest.h" |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 reinterpret_cast<const i::byte*>(re_source), | 790 reinterpret_cast<const i::byte*>(re_source), |
| 790 static_cast<unsigned>(strlen(re_source))); | 791 static_cast<unsigned>(strlen(re_source))); |
| 791 i::HandleScope scope(CcTest::i_isolate()); | 792 i::HandleScope scope(CcTest::i_isolate()); |
| 792 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 793 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
| 793 scanner.Initialize(&stream); | 794 scanner.Initialize(&stream); |
| 794 | 795 |
| 795 i::Token::Value start = scanner.peek(); | 796 i::Token::Value start = scanner.peek(); |
| 796 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); | 797 CHECK(start == i::Token::DIV || start == i::Token::ASSIGN_DIV); |
| 797 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); | 798 CHECK(scanner.ScanRegExpPattern(start == i::Token::ASSIGN_DIV)); |
| 798 scanner.Next(); // Current token is now the regexp literal. | 799 scanner.Next(); // Current token is now the regexp literal. |
| 800 i::Zone zone(CcTest::i_isolate()); |
| 801 i::AstValueFactory ast_value_factory(&zone, |
| 802 CcTest::i_isolate()->heap()->HashSeed()); |
| 803 ast_value_factory.Internalize(CcTest::i_isolate()); |
| 799 i::Handle<i::String> val = | 804 i::Handle<i::String> val = |
| 800 scanner.AllocateInternalizedString(CcTest::i_isolate()); | 805 scanner.CurrentSymbol(&ast_value_factory)->string(); |
| 801 i::DisallowHeapAllocation no_alloc; | 806 i::DisallowHeapAllocation no_alloc; |
| 802 i::String::FlatContent content = val->GetFlatContent(); | 807 i::String::FlatContent content = val->GetFlatContent(); |
| 803 CHECK(content.IsAscii()); | 808 CHECK(content.IsAscii()); |
| 804 i::Vector<const uint8_t> actual = content.ToOneByteVector(); | 809 i::Vector<const uint8_t> actual = content.ToOneByteVector(); |
| 805 for (int i = 0; i < actual.length(); i++) { | 810 for (int i = 0; i < actual.length(); i++) { |
| 806 CHECK_NE('\0', expected[i]); | 811 CHECK_NE('\0', expected[i]); |
| 807 CHECK_EQ(expected[i], actual[i]); | 812 CHECK_EQ(expected[i], actual[i]); |
| 808 } | 813 } |
| 809 } | 814 } |
| 810 | 815 |
| (...skipping 1769 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2580 v8::Local<v8::String> source = | 2585 v8::Local<v8::String> source = |
| 2581 v8::String::NewFromTwoByte(isolate, two_byte_source); | 2586 v8::String::NewFromTwoByte(isolate, two_byte_source); |
| 2582 v8::Local<v8::Value> result = CompileRun(source); | 2587 v8::Local<v8::Value> result = CompileRun(source); |
| 2583 CHECK(result->IsString()); | 2588 CHECK(result->IsString()); |
| 2584 v8::Local<v8::String> expected_name = | 2589 v8::Local<v8::String> expected_name = |
| 2585 v8::String::NewFromTwoByte(isolate, two_byte_name); | 2590 v8::String::NewFromTwoByte(isolate, two_byte_name); |
| 2586 CHECK(result->Equals(expected_name)); | 2591 CHECK(result->Equals(expected_name)); |
| 2587 i::DeleteArray(two_byte_source); | 2592 i::DeleteArray(two_byte_source); |
| 2588 i::DeleteArray(two_byte_name); | 2593 i::DeleteArray(two_byte_name); |
| 2589 } | 2594 } |
| 2595 |
| 2596 |
| 2597 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 2598 // The bug occurred when a lazy function had an error which requires a |
| 2599 // parameter (such as "unknown label" here). The error message was processed |
| 2600 // before the AstValueFactory containing the error message string was |
| 2601 // internalized. |
| 2602 v8::Isolate* isolate = CcTest::isolate(); |
| 2603 v8::HandleScope scope(isolate); |
| 2604 LocalContext env; |
| 2605 i::FLAG_lazy = true; |
| 2606 i::FLAG_min_preparse_length = 0; |
| 2607 CompileRun("function this_is_lazy() {\n" |
| 2608 " break p;\n" |
| 2609 "}\n" |
| 2610 "this_is_lazy();\n"); |
| 2611 } |
| OLD | NEW |