OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 <errno.h> | 5 #include <errno.h> |
6 #include <stdlib.h> | 6 #include <stdlib.h> |
7 #include <string.h> | 7 #include <string.h> |
8 #include <sys/stat.h> | 8 #include <sys/stat.h> |
9 | 9 |
10 #include <algorithm> | 10 #include <algorithm> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 // array buffers storing the lengths as a SMI internally. | 69 // array buffers storing the lengths as a SMI internally. |
70 #define TWO_GB (2u * 1024u * 1024u * 1024u) | 70 #define TWO_GB (2u * 1024u * 1024u * 1024u) |
71 | 71 |
72 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { | 72 class ShellArrayBufferAllocator : public v8::ArrayBuffer::Allocator { |
73 public: | 73 public: |
74 virtual void* Allocate(size_t length) { | 74 virtual void* Allocate(size_t length) { |
75 #if USE_VM | 75 #if USE_VM |
76 if (RoundToPageSize(&length)) { | 76 if (RoundToPageSize(&length)) { |
77 void* data = VirtualMemoryAllocate(length); | 77 void* data = VirtualMemoryAllocate(length); |
78 #if DEBUG | 78 #if DEBUG |
79 // In debug mode, check the memory is zero-initialized. | 79 if (data) { |
80 uint8_t* ptr = reinterpret_cast<uint8_t*>(data); | 80 // In debug mode, check the memory is zero-initialized. |
81 for (size_t i = 0; i < length; i++) { | 81 size_t limit = length / sizeof(uint64_t); |
82 DCHECK_EQ(0, ptr[i]); | 82 uint64_t* ptr = reinterpret_cast<uint64_t*>(data); |
| 83 for (size_t i = 0; i < limit; i++) { |
| 84 DCHECK_EQ(0u, ptr[i]); |
| 85 } |
83 } | 86 } |
84 #endif | 87 #endif |
85 return data; | 88 return data; |
86 } | 89 } |
87 #endif | 90 #endif |
88 void* data = AllocateUninitialized(length); | 91 void* data = AllocateUninitialized(length); |
89 return data == NULL ? data : memset(data, 0, length); | 92 return data == NULL ? data : memset(data, 0, length); |
90 } | 93 } |
91 virtual void* AllocateUninitialized(size_t length) { | 94 virtual void* AllocateUninitialized(size_t length) { |
92 #if USE_VM | 95 #if USE_VM |
(...skipping 2924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3017 } | 3020 } |
3018 | 3021 |
3019 } // namespace v8 | 3022 } // namespace v8 |
3020 | 3023 |
3021 | 3024 |
3022 #ifndef GOOGLE3 | 3025 #ifndef GOOGLE3 |
3023 int main(int argc, char* argv[]) { | 3026 int main(int argc, char* argv[]) { |
3024 return v8::Shell::Main(argc, argv); | 3027 return v8::Shell::Main(argc, argv); |
3025 } | 3028 } |
3026 #endif | 3029 #endif |
OLD | NEW |