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

Side by Side Diff: runtime/bin/dartutils.cc

Issue 2894773004: Changes to make isolate reload functionality work with the --dfe option. (Closed)
Patch Set: Fix regression test errors. Created 3 years, 6 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 | « runtime/bin/dartutils.h ('k') | runtime/bin/dfe.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 (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "bin/dartutils.h" 5 #include "bin/dartutils.h"
6 6
7 #include "bin/crypto.h" 7 #include "bin/crypto.h"
8 #include "bin/directory.h" 8 #include "bin/directory.h"
9 #include "bin/extensions.h" 9 #include "bin/extensions.h"
10 #include "bin/file.h" 10 #include "bin/file.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 const uint8_t bytes[kLength]; 54 const uint8_t bytes[kLength];
55 bool should_skip; 55 bool should_skip;
56 }; 56 };
57 57
58 58
59 MagicNumberData snapshot_magic_number = {{0xf5, 0xf5, 0xdc, 0xdc}, true}; 59 MagicNumberData snapshot_magic_number = {{0xf5, 0xf5, 0xdc, 0xdc}, true};
60 MagicNumberData kernel_magic_number = {{0x90, 0xab, 0xcd, 0xef}, false}; 60 MagicNumberData kernel_magic_number = {{0x90, 0xab, 0xcd, 0xef}, false};
61 61
62 62
63 bool TryReadKernel(const char* script_uri,
64 const uint8_t** kernel_file,
65 intptr_t* kernel_length) {
66 *kernel_file = NULL;
67 *kernel_length = -1;
68 bool is_kernel_file = false;
69 void* script_file = DartUtils::OpenFile(script_uri, false);
70 if (script_file != NULL) {
71 const uint8_t* buffer = NULL;
72 DartUtils::ReadFile(&buffer, kernel_length, script_file);
73 DartUtils::CloseFile(script_file);
74 if (*kernel_length > 0 && buffer != NULL) {
75 // We need a temporary variable because SniffForMagicNumber modifies the
76 // buffer pointer to skip snapshot magic number.
77 const uint8_t* temp = buffer;
78 if (DartUtils::SniffForMagicNumber(&temp, kernel_length) !=
79 DartUtils::kKernelMagicNumber) {
80 free(const_cast<uint8_t*>(buffer));
81 *kernel_file = NULL;
82 } else {
83 // Do not free buffer if this is a kernel file - kernel_file will be
84 // backed by the same memory as the buffer and caller will own it.
85 // Caller is responsible for freeing the buffer when this function
86 // returns true.
87 is_kernel_file = true;
88 *kernel_file = buffer;
89 }
90 }
91 }
92 return is_kernel_file;
93 }
94
95
96 static bool IsWindowsHost() { 63 static bool IsWindowsHost() {
97 #if defined(HOST_OS_WINDOWS) 64 #if defined(HOST_OS_WINDOWS)
98 return true; 65 return true;
99 #else // defined(HOST_OS_WINDOWS) 66 #else // defined(HOST_OS_WINDOWS)
100 return false; 67 return false;
101 #endif // defined(HOST_OS_WINDOWS) 68 #endif // defined(HOST_OS_WINDOWS)
102 } 69 }
103 70
104 71
105 const char* DartUtils::MapLibraryUrl(const char* url_string) { 72 const char* DartUtils::MapLibraryUrl(const char* url_string) {
(...skipping 1076 matching lines...) Expand 10 before | Expand all | Expand 10 after
1182 new CObjectString(CObject::NewString(os_error->message())); 1149 new CObjectString(CObject::NewString(os_error->message()));
1183 CObjectArray* result = new CObjectArray(CObject::NewArray(3)); 1150 CObjectArray* result = new CObjectArray(CObject::NewArray(3));
1184 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError))); 1151 result->SetAt(0, new CObjectInt32(CObject::NewInt32(kOSError)));
1185 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code()))); 1152 result->SetAt(1, new CObjectInt32(CObject::NewInt32(os_error->code())));
1186 result->SetAt(2, error_message); 1153 result->SetAt(2, error_message);
1187 return result; 1154 return result;
1188 } 1155 }
1189 1156
1190 } // namespace bin 1157 } // namespace bin
1191 } // namespace dart 1158 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/dartutils.h ('k') | runtime/bin/dfe.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698