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 <stdlib.h> | 28 #include <stdlib.h> |
29 #include <stdio.h> | 29 #include <stdio.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 ast_value_factory.Internalize(CcTest::i_isolate()); |
799 i::Handle<i::String> val = | 803 i::Handle<i::String> val = |
800 scanner.AllocateInternalizedString(CcTest::i_isolate()); | 804 scanner.CurrentSymbol(&ast_value_factory)->string(); |
801 i::DisallowHeapAllocation no_alloc; | 805 i::DisallowHeapAllocation no_alloc; |
802 i::String::FlatContent content = val->GetFlatContent(); | 806 i::String::FlatContent content = val->GetFlatContent(); |
803 CHECK(content.IsAscii()); | 807 CHECK(content.IsAscii()); |
804 i::Vector<const uint8_t> actual = content.ToOneByteVector(); | 808 i::Vector<const uint8_t> actual = content.ToOneByteVector(); |
805 for (int i = 0; i < actual.length(); i++) { | 809 for (int i = 0; i < actual.length(); i++) { |
806 CHECK_NE('\0', expected[i]); | 810 CHECK_NE('\0', expected[i]); |
807 CHECK_EQ(expected[i], actual[i]); | 811 CHECK_EQ(expected[i], actual[i]); |
808 } | 812 } |
809 } | 813 } |
810 | 814 |
(...skipping 1731 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2542 v8::Local<v8::String> source = | 2546 v8::Local<v8::String> source = |
2543 v8::String::NewFromTwoByte(isolate, two_byte_source); | 2547 v8::String::NewFromTwoByte(isolate, two_byte_source); |
2544 v8::Local<v8::Value> result = CompileRun(source); | 2548 v8::Local<v8::Value> result = CompileRun(source); |
2545 CHECK(result->IsString()); | 2549 CHECK(result->IsString()); |
2546 v8::Local<v8::String> expected_name = | 2550 v8::Local<v8::String> expected_name = |
2547 v8::String::NewFromTwoByte(isolate, two_byte_name); | 2551 v8::String::NewFromTwoByte(isolate, two_byte_name); |
2548 CHECK(result->Equals(expected_name)); | 2552 CHECK(result->Equals(expected_name)); |
2549 i::DeleteArray(two_byte_source); | 2553 i::DeleteArray(two_byte_source); |
2550 i::DeleteArray(two_byte_name); | 2554 i::DeleteArray(two_byte_name); |
2551 } | 2555 } |
| 2556 |
| 2557 |
| 2558 TEST(RegressionLazyFunctionWithErrorWithArg) { |
| 2559 // The bug occurred when a lazy function had an error which requires a |
| 2560 // parameter (such as "unknown label" here). The error message was processed |
| 2561 // before the AstValueFactory containing the error message string was |
| 2562 // internalized. |
| 2563 v8::Isolate* isolate = CcTest::isolate(); |
| 2564 v8::HandleScope scope(isolate); |
| 2565 LocalContext env; |
| 2566 i::FLAG_lazy = true; |
| 2567 i::FLAG_min_preparse_length = 0; |
| 2568 CompileRun("function this_is_lazy() {\n" |
| 2569 " break p;\n" |
| 2570 "}\n" |
| 2571 "this_is_lazy();\n"); |
| 2572 } |
OLD | NEW |