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

Side by Side Diff: src/snapshot/mksnapshot.cc

Issue 1110603005: Remove support for malloc'd typed arrays (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: updates 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 | « src/runtime/runtime-typedarray.cc ('k') | test/unittests/run-all-unittests.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 2006-2008 the V8 project authors. All rights reserved. 1 // Copyright 2006-2008 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 <signal.h> 6 #include <signal.h>
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include "src/v8.h" 9 #include "src/v8.h"
10 10
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 exit(1); 102 exit(1);
103 } 103 }
104 return fp; 104 return fp;
105 } 105 }
106 106
107 FILE* fp_; 107 FILE* fp_;
108 FILE* startup_blob_file_; 108 FILE* startup_blob_file_;
109 }; 109 };
110 110
111 111
112 class ArrayBufferAllocator : public v8::ArrayBuffer::Allocator {
113 public:
114 virtual void* Allocate(size_t length) {
115 void* data = AllocateUninitialized(length);
116 return data == NULL ? data : memset(data, 0, length);
117 }
118 virtual void* AllocateUninitialized(size_t length) { return malloc(length); }
119 virtual void Free(void* data, size_t) { free(data); }
120 };
121
122
112 char* GetExtraCode(char* filename) { 123 char* GetExtraCode(char* filename) {
113 if (filename == NULL || strlen(filename) == 0) return NULL; 124 if (filename == NULL || strlen(filename) == 0) return NULL;
114 ::printf("Embedding extra script: %s\n", filename); 125 ::printf("Embedding extra script: %s\n", filename);
115 FILE* file = base::OS::FOpen(filename, "rb"); 126 FILE* file = base::OS::FOpen(filename, "rb");
116 if (file == NULL) { 127 if (file == NULL) {
117 fprintf(stderr, "Failed to open '%s': errno %d\n", filename, errno); 128 fprintf(stderr, "Failed to open '%s': errno %d\n", filename, errno);
118 exit(1); 129 exit(1);
119 } 130 }
120 fseek(file, 0, SEEK_END); 131 fseek(file, 0, SEEK_END);
121 size_t size = ftell(file); 132 size_t size = ftell(file);
(...skipping 24 matching lines...) Expand all
146 if (result > 0 || (argc != 2 && argc != 3) || i::FLAG_help) { 157 if (result > 0 || (argc != 2 && argc != 3) || i::FLAG_help) {
147 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); 158 ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
148 i::FlagList::PrintHelp(); 159 i::FlagList::PrintHelp();
149 return !i::FLAG_help; 160 return !i::FLAG_help;
150 } 161 }
151 162
152 i::CpuFeatures::Probe(true); 163 i::CpuFeatures::Probe(true);
153 V8::InitializeICU(); 164 V8::InitializeICU();
154 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); 165 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
155 v8::V8::InitializePlatform(platform); 166 v8::V8::InitializePlatform(platform);
167 ArrayBufferAllocator array_buffer_allocator;
168 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
156 v8::V8::Initialize(); 169 v8::V8::Initialize();
157 170
158 { 171 {
159 SnapshotWriter writer(argv[1]); 172 SnapshotWriter writer(argv[1]);
160 if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob); 173 if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob);
161 char* extra_code = GetExtraCode(argc == 3 ? argv[2] : NULL); 174 char* extra_code = GetExtraCode(argc == 3 ? argv[2] : NULL);
162 StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code); 175 StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code);
163 CHECK(blob.data); 176 CHECK(blob.data);
164 writer.WriteSnapshot(blob); 177 writer.WriteSnapshot(blob);
165 delete[] extra_code; 178 delete[] extra_code;
166 delete[] blob.data; 179 delete[] blob.data;
167 } 180 }
168 181
169 V8::Dispose(); 182 V8::Dispose();
170 V8::ShutdownPlatform(); 183 V8::ShutdownPlatform();
171 delete platform; 184 delete platform;
172 return 0; 185 return 0;
173 } 186 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-typedarray.cc ('k') | test/unittests/run-all-unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698