OLD | NEW |
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 <stdio.h> | 6 #include <stdio.h> |
7 #ifdef COMPRESS_STARTUP_DATA_BZ2 | 7 #ifdef COMPRESS_STARTUP_DATA_BZ2 |
8 #include <bzlib.h> | 8 #include <bzlib.h> |
9 #endif | 9 #endif |
10 #include <signal.h> | 10 #include <signal.h> |
11 | 11 |
12 #include "src/v8.h" | 12 #include "src/v8.h" |
13 | 13 |
14 #include "src/assembler.h" | 14 #include "src/assembler.h" |
| 15 #include "src/base/platform/platform.h" |
15 #include "src/bootstrapper.h" | 16 #include "src/bootstrapper.h" |
16 #include "src/flags.h" | 17 #include "src/flags.h" |
17 #include "src/list.h" | 18 #include "src/list.h" |
18 #include "src/natives.h" | 19 #include "src/natives.h" |
19 #include "src/platform.h" | |
20 #include "src/serialize.h" | 20 #include "src/serialize.h" |
21 | 21 |
22 | 22 |
23 using namespace v8; | 23 using namespace v8; |
24 | 24 |
25 | 25 |
26 class Compressor { | 26 class Compressor { |
27 public: | 27 public: |
28 virtual ~Compressor() {} | 28 virtual ~Compressor() {} |
29 virtual bool Compress(i::Vector<char> input) = 0; | 29 virtual bool Compress(i::Vector<char> input) = 0; |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 WriteData("", snapshot_data, raw_file_); | 127 WriteData("", snapshot_data, raw_file_); |
128 WriteData("context_", context_snapshot_data, raw_context_file_); | 128 WriteData("context_", context_snapshot_data, raw_context_file_); |
129 WriteMeta("context_", context_serializer); | 129 WriteMeta("context_", context_serializer); |
130 WriteMeta("", serializer); | 130 WriteMeta("", serializer); |
131 WriteFileSuffix(); | 131 WriteFileSuffix(); |
132 } | 132 } |
133 | 133 |
134 void WriteFilePrefix() const { | 134 void WriteFilePrefix() const { |
135 fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n"); | 135 fprintf(fp_, "// Autogenerated snapshot file. Do not edit.\n\n"); |
136 fprintf(fp_, "#include \"src/v8.h\"\n"); | 136 fprintf(fp_, "#include \"src/v8.h\"\n"); |
137 fprintf(fp_, "#include \"src/platform.h\"\n\n"); | 137 fprintf(fp_, "#include \"src/base/platform/platform.h\"\n\n"); |
138 fprintf(fp_, "#include \"src/snapshot.h\"\n\n"); | 138 fprintf(fp_, "#include \"src/snapshot.h\"\n\n"); |
139 fprintf(fp_, "namespace v8 {\n"); | 139 fprintf(fp_, "namespace v8 {\n"); |
140 fprintf(fp_, "namespace internal {\n\n"); | 140 fprintf(fp_, "namespace internal {\n\n"); |
141 } | 141 } |
142 | 142 |
143 void WriteFileSuffix() const { | 143 void WriteFileSuffix() const { |
144 fprintf(fp_, "} // namespace internal\n"); | 144 fprintf(fp_, "} // namespace internal\n"); |
145 fprintf(fp_, "} // namespace v8\n"); | 145 fprintf(fp_, "} // namespace v8\n"); |
146 } | 146 } |
147 | 147 |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 if ((i & 0x1f) == 0x1f) | 224 if ((i & 0x1f) == 0x1f) |
225 fprintf(fp_, "\n"); | 225 fprintf(fp_, "\n"); |
226 if (i > 0) | 226 if (i > 0) |
227 fprintf(fp_, ","); | 227 fprintf(fp_, ","); |
228 fprintf(fp_, "%u", static_cast<unsigned char>(data->at(i))); | 228 fprintf(fp_, "%u", static_cast<unsigned char>(data->at(i))); |
229 } | 229 } |
230 fprintf(fp_, "\n"); | 230 fprintf(fp_, "\n"); |
231 } | 231 } |
232 | 232 |
233 FILE* GetFileDescriptorOrDie(const char* filename) { | 233 FILE* GetFileDescriptorOrDie(const char* filename) { |
234 FILE* fp = i::OS::FOpen(filename, "wb"); | 234 FILE* fp = base::OS::FOpen(filename, "wb"); |
235 if (fp == NULL) { | 235 if (fp == NULL) { |
236 i::PrintF("Unable to open file \"%s\" for writing.\n", filename); | 236 i::PrintF("Unable to open file \"%s\" for writing.\n", filename); |
237 exit(1); | 237 exit(1); |
238 } | 238 } |
239 return fp; | 239 return fp; |
240 } | 240 } |
241 | 241 |
242 FILE* fp_; | 242 FILE* fp_; |
243 FILE* raw_file_; | 243 FILE* raw_file_; |
244 FILE* raw_context_file_; | 244 FILE* raw_context_file_; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
356 fprintf(stderr, | 356 fprintf(stderr, |
357 "\nException thrown while compiling natives - see above.\n\n"); | 357 "\nException thrown while compiling natives - see above.\n\n"); |
358 exit(1); | 358 exit(1); |
359 } | 359 } |
360 if (i::FLAG_extra_code != NULL) { | 360 if (i::FLAG_extra_code != NULL) { |
361 // Capture 100 frames if anything happens. | 361 // Capture 100 frames if anything happens. |
362 V8::SetCaptureStackTraceForUncaughtExceptions(true, 100); | 362 V8::SetCaptureStackTraceForUncaughtExceptions(true, 100); |
363 HandleScope scope(isolate); | 363 HandleScope scope(isolate); |
364 v8::Context::Scope cscope(v8::Local<v8::Context>::New(isolate, context)); | 364 v8::Context::Scope cscope(v8::Local<v8::Context>::New(isolate, context)); |
365 const char* name = i::FLAG_extra_code; | 365 const char* name = i::FLAG_extra_code; |
366 FILE* file = i::OS::FOpen(name, "rb"); | 366 FILE* file = base::OS::FOpen(name, "rb"); |
367 if (file == NULL) { | 367 if (file == NULL) { |
368 fprintf(stderr, "Failed to open '%s': errno %d\n", name, errno); | 368 fprintf(stderr, "Failed to open '%s': errno %d\n", name, errno); |
369 exit(1); | 369 exit(1); |
370 } | 370 } |
371 | 371 |
372 fseek(file, 0, SEEK_END); | 372 fseek(file, 0, SEEK_END); |
373 int size = ftell(file); | 373 int size = ftell(file); |
374 rewind(file); | 374 rewind(file); |
375 | 375 |
376 char* chars = new char[size + 1]; | 376 char* chars = new char[size + 1]; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 writer.SetCompressor(&bzip2); | 436 writer.SetCompressor(&bzip2); |
437 #endif | 437 #endif |
438 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser); | 438 writer.WriteSnapshot(snapshot_data, ser, context_data, context_ser); |
439 } | 439 } |
440 } | 440 } |
441 | 441 |
442 isolate->Dispose(); | 442 isolate->Dispose(); |
443 V8::Dispose(); | 443 V8::Dispose(); |
444 return 0; | 444 return 0; |
445 } | 445 } |
OLD | NEW |