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

Side by Side Diff: src/snapshot/mksnapshot.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 | « src/runtime/runtime-typedarray.cc ('k') | test/cctest/cctest.h » ('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
123 char* GetExtraCode(char* filename) { 112 char* GetExtraCode(char* filename) {
124 if (filename == NULL || strlen(filename) == 0) return NULL; 113 if (filename == NULL || strlen(filename) == 0) return NULL;
125 ::printf("Embedding extra script: %s\n", filename); 114 ::printf("Embedding extra script: %s\n", filename);
126 FILE* file = base::OS::FOpen(filename, "rb"); 115 FILE* file = base::OS::FOpen(filename, "rb");
127 if (file == NULL) { 116 if (file == NULL) {
128 fprintf(stderr, "Failed to open '%s': errno %d\n", filename, errno); 117 fprintf(stderr, "Failed to open '%s': errno %d\n", filename, errno);
129 exit(1); 118 exit(1);
130 } 119 }
131 fseek(file, 0, SEEK_END); 120 fseek(file, 0, SEEK_END);
132 size_t size = ftell(file); 121 size_t size = ftell(file);
(...skipping 24 matching lines...) Expand all
157 if (result > 0 || (argc != 2 && argc != 3) || i::FLAG_help) { 146 if (result > 0 || (argc != 2 && argc != 3) || i::FLAG_help) {
158 ::printf("Usage: %s [flag] ... outfile\n", argv[0]); 147 ::printf("Usage: %s [flag] ... outfile\n", argv[0]);
159 i::FlagList::PrintHelp(); 148 i::FlagList::PrintHelp();
160 return !i::FLAG_help; 149 return !i::FLAG_help;
161 } 150 }
162 151
163 i::CpuFeatures::Probe(true); 152 i::CpuFeatures::Probe(true);
164 V8::InitializeICU(); 153 V8::InitializeICU();
165 v8::Platform* platform = v8::platform::CreateDefaultPlatform(); 154 v8::Platform* platform = v8::platform::CreateDefaultPlatform();
166 v8::V8::InitializePlatform(platform); 155 v8::V8::InitializePlatform(platform);
167 ArrayBufferAllocator array_buffer_allocator;
168 v8::V8::SetArrayBufferAllocator(&array_buffer_allocator);
169 v8::V8::Initialize(); 156 v8::V8::Initialize();
170 157
171 { 158 {
172 SnapshotWriter writer(argv[1]); 159 SnapshotWriter writer(argv[1]);
173 if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob); 160 if (i::FLAG_startup_blob) writer.SetStartupBlobFile(i::FLAG_startup_blob);
174 char* extra_code = GetExtraCode(argc == 3 ? argv[2] : NULL); 161 char* extra_code = GetExtraCode(argc == 3 ? argv[2] : NULL);
175 StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code); 162 StartupData blob = v8::V8::CreateSnapshotDataBlob(extra_code);
176 CHECK(blob.data); 163 CHECK(blob.data);
177 writer.WriteSnapshot(blob); 164 writer.WriteSnapshot(blob);
178 delete[] extra_code; 165 delete[] extra_code;
179 delete[] blob.data; 166 delete[] blob.data;
180 } 167 }
181 168
182 V8::Dispose(); 169 V8::Dispose();
183 V8::ShutdownPlatform(); 170 V8::ShutdownPlatform();
184 delete platform; 171 delete platform;
185 return 0; 172 return 0;
186 } 173 }
OLDNEW
« no previous file with comments | « src/runtime/runtime-typedarray.cc ('k') | test/cctest/cctest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698