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

Side by Side Diff: test/unittests/test-utils.cc

Issue 1116633002: Pass ArrayBuffer::Allocator via Isolate::CreateParams (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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/unittests/test-utils.h ('k') | tools/parser-shell.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "test/unittests/test-utils.h" 5 #include "test/unittests/test-utils.h"
6 6
7 #include "src/base/platform/time.h" 7 #include "src/base/platform/time.h"
8 #include "src/debug.h" 8 #include "src/debug.h"
9 #include "src/flags.h" 9 #include "src/flags.h"
10 #include "src/isolate.h" 10 #include "src/isolate.h"
11 11
12 namespace v8 { 12 namespace v8 {
13 13
14 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
15 public:
16 virtual void* Allocate(size_t length) {
17 void* data = AllocateUninitialized(length);
18 return data == NULL ? data : memset(data, 0, length);
19 }
20 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
21 virtual void Free(void* data, size_t) { free(data); }
22 };
23
24
25 // static
26 ArrayBufferAllocator* TestWithIsolate::array_buffer_allocator_ = NULL;
27
14 // static 28 // static
15 Isolate* TestWithIsolate::isolate_ = NULL; 29 Isolate* TestWithIsolate::isolate_ = NULL;
16 30
17 31
18 TestWithIsolate::TestWithIsolate() 32 TestWithIsolate::TestWithIsolate()
19 : isolate_scope_(isolate()), handle_scope_(isolate()) {} 33 : isolate_scope_(isolate()), handle_scope_(isolate()) {}
20 34
21 35
22 TestWithIsolate::~TestWithIsolate() {} 36 TestWithIsolate::~TestWithIsolate() {}
23 37
24 38
25 // static 39 // static
26 void TestWithIsolate::SetUpTestCase() { 40 void TestWithIsolate::SetUpTestCase() {
27 Test::SetUpTestCase(); 41 Test::SetUpTestCase();
28 EXPECT_EQ(NULL, isolate_); 42 EXPECT_EQ(NULL, isolate_);
29 isolate_ = v8::Isolate::New(); 43 v8::Isolate::CreateParams create_params;
44 array_buffer_allocator_ = new ArrayBufferAllocator;
45 create_params.array_buffer_allocator = array_buffer_allocator_;
46 isolate_ = v8::Isolate::New(create_params);
30 EXPECT_TRUE(isolate_ != NULL); 47 EXPECT_TRUE(isolate_ != NULL);
31 } 48 }
32 49
33 50
34 // static 51 // static
35 void TestWithIsolate::TearDownTestCase() { 52 void TestWithIsolate::TearDownTestCase() {
36 ASSERT_TRUE(isolate_ != NULL); 53 ASSERT_TRUE(isolate_ != NULL);
37 isolate_->Dispose(); 54 isolate_->Dispose();
38 isolate_ = NULL; 55 isolate_ = NULL;
56 delete array_buffer_allocator_;
39 Test::TearDownTestCase(); 57 Test::TearDownTestCase();
40 } 58 }
41 59
42 60
43 TestWithContext::TestWithContext() 61 TestWithContext::TestWithContext()
44 : context_(Context::New(isolate())), context_scope_(context_) {} 62 : context_(Context::New(isolate())), context_scope_(context_) {}
45 63
46 64
47 TestWithContext::~TestWithContext() {} 65 TestWithContext::~TestWithContext() {}
48 66
(...skipping 27 matching lines...) Expand all
76 94
77 base::RandomNumberGenerator* TestWithIsolate::random_number_generator() const { 95 base::RandomNumberGenerator* TestWithIsolate::random_number_generator() const {
78 return isolate()->random_number_generator(); 96 return isolate()->random_number_generator();
79 } 97 }
80 98
81 99
82 TestWithZone::~TestWithZone() {} 100 TestWithZone::~TestWithZone() {}
83 101
84 } // namespace internal 102 } // namespace internal
85 } // namespace v8 103 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/test-utils.h ('k') | tools/parser-shell.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698