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 11 matching lines...) Expand all Loading... |
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 <memory> |
| 33 |
32 #include "src/v8.h" | 34 #include "src/v8.h" |
33 | 35 |
34 #include "src/ast/ast.h" | 36 #include "src/ast/ast.h" |
35 #include "src/ast/ast-numbering.h" | 37 #include "src/ast/ast-numbering.h" |
36 #include "src/ast/ast-value-factory.h" | 38 #include "src/ast/ast-value-factory.h" |
37 #include "src/compiler.h" | 39 #include "src/compiler.h" |
38 #include "src/execution.h" | 40 #include "src/execution.h" |
39 #include "src/isolate.h" | 41 #include "src/isolate.h" |
40 #include "src/objects.h" | 42 #include "src/objects.h" |
41 #include "src/parsing/parser.h" | 43 #include "src/parsing/parser.h" |
(...skipping 479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
521 } | 523 } |
522 | 524 |
523 | 525 |
524 TEST(PreParseOverflow) { | 526 TEST(PreParseOverflow) { |
525 v8::V8::Initialize(); | 527 v8::V8::Initialize(); |
526 | 528 |
527 CcTest::i_isolate()->stack_guard()->SetStackLimit( | 529 CcTest::i_isolate()->stack_guard()->SetStackLimit( |
528 i::GetCurrentStackPosition() - 128 * 1024); | 530 i::GetCurrentStackPosition() - 128 * 1024); |
529 | 531 |
530 size_t kProgramSize = 1024 * 1024; | 532 size_t kProgramSize = 1024 * 1024; |
531 v8::base::SmartArrayPointer<char> program( | 533 std::unique_ptr<char[]> program(i::NewArray<char>(kProgramSize + 1)); |
532 i::NewArray<char>(kProgramSize + 1)); | |
533 memset(program.get(), '(', kProgramSize); | 534 memset(program.get(), '(', kProgramSize); |
534 program[kProgramSize] = '\0'; | 535 program[kProgramSize] = '\0'; |
535 | 536 |
536 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); | 537 uintptr_t stack_limit = CcTest::i_isolate()->stack_guard()->real_climit(); |
537 | 538 |
538 i::Utf8ToUtf16CharacterStream stream( | 539 i::Utf8ToUtf16CharacterStream stream( |
539 reinterpret_cast<const i::byte*>(program.get()), | 540 reinterpret_cast<const i::byte*>(program.get()), |
540 static_cast<unsigned>(kProgramSize)); | 541 static_cast<unsigned>(kProgramSize)); |
541 i::CompleteParserRecorder log; | 542 i::CompleteParserRecorder log; |
542 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); | 543 i::Scanner scanner(CcTest::i_isolate()->unicode_cache()); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 | 576 |
576 #define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2)) | 577 #define CHECK_EQU(v1, v2) CHECK_EQ(static_cast<int>(v1), static_cast<int>(v2)) |
577 | 578 |
578 void TestCharacterStream(const char* one_byte_source, unsigned length, | 579 void TestCharacterStream(const char* one_byte_source, unsigned length, |
579 unsigned start = 0, unsigned end = 0) { | 580 unsigned start = 0, unsigned end = 0) { |
580 if (end == 0) end = length; | 581 if (end == 0) end = length; |
581 unsigned sub_length = end - start; | 582 unsigned sub_length = end - start; |
582 i::Isolate* isolate = CcTest::i_isolate(); | 583 i::Isolate* isolate = CcTest::i_isolate(); |
583 i::Factory* factory = isolate->factory(); | 584 i::Factory* factory = isolate->factory(); |
584 i::HandleScope test_scope(isolate); | 585 i::HandleScope test_scope(isolate); |
585 v8::base::SmartArrayPointer<i::uc16> uc16_buffer(new i::uc16[length]); | 586 std::unique_ptr<i::uc16[]> uc16_buffer(new i::uc16[length]); |
586 for (unsigned i = 0; i < length; i++) { | 587 for (unsigned i = 0; i < length; i++) { |
587 uc16_buffer[i] = static_cast<i::uc16>(one_byte_source[i]); | 588 uc16_buffer[i] = static_cast<i::uc16>(one_byte_source[i]); |
588 } | 589 } |
589 i::Vector<const char> one_byte_vector(one_byte_source, | 590 i::Vector<const char> one_byte_vector(one_byte_source, |
590 static_cast<int>(length)); | 591 static_cast<int>(length)); |
591 i::Handle<i::String> one_byte_string = | 592 i::Handle<i::String> one_byte_string = |
592 factory->NewStringFromAscii(one_byte_vector).ToHandleChecked(); | 593 factory->NewStringFromAscii(one_byte_vector).ToHandleChecked(); |
593 TestExternalResource resource(uc16_buffer.get(), length); | 594 TestExternalResource resource(uc16_buffer.get(), length); |
594 i::Handle<i::String> uc16_string( | 595 i::Handle<i::String> uc16_string( |
595 factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked()); | 596 factory->NewExternalStringFromTwoByte(&resource).ToHandleChecked()); |
(...skipping 7359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7955 "(a,);", | 7956 "(a,);", |
7956 "(a,b,c,);", | 7957 "(a,b,c,);", |
7957 NULL | 7958 NULL |
7958 }; | 7959 }; |
7959 // clang-format on | 7960 // clang-format on |
7960 | 7961 |
7961 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; | 7962 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; |
7962 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, | 7963 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, |
7963 arraysize(always_flags)); | 7964 arraysize(always_flags)); |
7964 } | 7965 } |
OLD | NEW |