Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: test/cctest/test-parsing.cc

Issue 2173403002: Replace SmartArrayPointer<T> with unique_ptr<T[]> (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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 7362 matching lines...) Expand 10 before | Expand all | Expand 10 after
7958 "(a,);", 7959 "(a,);",
7959 "(a,b,c,);", 7960 "(a,b,c,);",
7960 NULL 7961 NULL
7961 }; 7962 };
7962 // clang-format on 7963 // clang-format on
7963 7964
7964 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas}; 7965 static const ParserFlag always_flags[] = {kAllowHarmonyTrailingCommas};
7965 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags, 7966 RunParserSyncTest(context_data, data, kError, NULL, 0, always_flags,
7966 arraysize(always_flags)); 7967 arraysize(always_flags));
7967 } 7968 }
OLDNEW
« no previous file with comments | « test/cctest/test-heap-profiler.cc ('k') | test/cctest/test-regexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698