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

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

Issue 1915853004: Option to output precompiled instructions as a blob for use with mmap instead of assembly for use i… (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 8 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/file_linux.cc ('k') | runtime/bin/file_win.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 (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 "platform/globals.h" 5 #include "platform/globals.h"
6 #if defined(TARGET_OS_MACOS) 6 #if defined(TARGET_OS_MACOS)
7 7
8 #include "bin/file.h" 8 #include "bin/file.h"
9 9
10 #include <copyfile.h> // NOLINT 10 #include <copyfile.h> // NOLINT
11 #include <errno.h> // NOLINT 11 #include <errno.h> // NOLINT
12 #include <fcntl.h> // NOLINT 12 #include <fcntl.h> // NOLINT
13 #include <libgen.h> // NOLINT 13 #include <libgen.h> // NOLINT
14 #include <limits.h> // NOLINT 14 #include <limits.h> // NOLINT
15 #include <sys/mman.h> // NOLINT
15 #include <sys/stat.h> // NOLINT 16 #include <sys/stat.h> // NOLINT
16 #include <unistd.h> // NOLINT 17 #include <unistd.h> // NOLINT
17 18
18 #include "bin/builtin.h" 19 #include "bin/builtin.h"
19 #include "bin/fdutils.h" 20 #include "bin/fdutils.h"
20 #include "bin/log.h" 21 #include "bin/log.h"
21 22
22 #include "platform/signal_blocker.h" 23 #include "platform/signal_blocker.h"
23 #include "platform/utils.h" 24 #include "platform/utils.h"
24 25
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 intptr_t File::GetFD() { 72 intptr_t File::GetFD() {
72 return handle_->fd(); 73 return handle_->fd();
73 } 74 }
74 75
75 76
76 bool File::IsClosed() { 77 bool File::IsClosed() {
77 return handle_->fd() == kClosedFd; 78 return handle_->fd() == kClosedFd;
78 } 79 }
79 80
80 81
82 void* File::MapExecutable(intptr_t* len) {
83 ASSERT(handle_->fd() >= 0);
84 intptr_t length = Length();
85 void* addr = mmap(0, length,
86 PROT_READ | PROT_EXEC, MAP_PRIVATE,
87 handle_->fd(), 0);
88 if (addr == MAP_FAILED) {
89 *len = -1;
90 } else {
91 *len = length;
92 }
93 return addr;
94 }
95
96
81 int64_t File::Read(void* buffer, int64_t num_bytes) { 97 int64_t File::Read(void* buffer, int64_t num_bytes) {
82 ASSERT(handle_->fd() >= 0); 98 ASSERT(handle_->fd() >= 0);
83 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes)); 99 return TEMP_FAILURE_RETRY(read(handle_->fd(), buffer, num_bytes));
84 } 100 }
85 101
86 102
87 int64_t File::Write(const void* buffer, int64_t num_bytes) { 103 int64_t File::Write(const void* buffer, int64_t num_bytes) {
88 ASSERT(handle_->fd() >= 0); 104 ASSERT(handle_->fd() >= 0);
89 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes)); 105 return TEMP_FAILURE_RETRY(write(handle_->fd(), buffer, num_bytes));
90 } 106 }
(...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 return ((file_1_info.st_ino == file_2_info.st_ino) && 477 return ((file_1_info.st_ino == file_2_info.st_ino) &&
462 (file_1_info.st_dev == file_2_info.st_dev)) ? 478 (file_1_info.st_dev == file_2_info.st_dev)) ?
463 File::kIdentical : 479 File::kIdentical :
464 File::kDifferent; 480 File::kDifferent;
465 } 481 }
466 482
467 } // namespace bin 483 } // namespace bin
468 } // namespace dart 484 } // namespace dart
469 485
470 #endif // defined(TARGET_OS_MACOS) 486 #endif // defined(TARGET_OS_MACOS)
OLDNEW
« no previous file with comments | « runtime/bin/file_linux.cc ('k') | runtime/bin/file_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698