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

Side by Side Diff: runtime/vm/os_android.cc

Issue 2481873005: clang-format runtime/vm (Closed)
Patch Set: Merge Created 4 years, 1 month 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/vm/os.h ('k') | runtime/vm/os_fuchsia.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 "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_OS_ANDROID) 6 #if defined(TARGET_OS_ANDROID)
7 7
8 #include "vm/os.h" 8 #include "vm/os.h"
9 9
10 #include <android/log.h> // NOLINT 10 #include <android/log.h> // NOLINT
11 #include <endian.h> // NOLINT 11 #include <endian.h> // NOLINT
12 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
13 #include <limits.h> // NOLINT 13 #include <limits.h> // NOLINT
14 #include <malloc.h> // NOLINT 14 #include <malloc.h> // NOLINT
15 #include <time.h> // NOLINT 15 #include <time.h> // NOLINT
16 #include <sys/resource.h> // NOLINT 16 #include <sys/resource.h> // NOLINT
17 #include <sys/time.h> // NOLINT 17 #include <sys/time.h> // NOLINT
18 #include <sys/types.h> // NOLINT 18 #include <sys/types.h> // NOLINT
19 #include <unistd.h> // NOLINT 19 #include <unistd.h> // NOLINT
20 20
21 #include "platform/utils.h" 21 #include "platform/utils.h"
22 #include "vm/code_observers.h" 22 #include "vm/code_observers.h"
23 #include "vm/dart.h" 23 #include "vm/dart.h"
24 #include "vm/isolate.h" 24 #include "vm/isolate.h"
25 #include "vm/zone.h" 25 #include "vm/zone.h"
26 26
27 27
28 namespace dart { 28 namespace dart {
29 29
30 // Android CodeObservers. 30 // Android CodeObservers.
31 31
32 #ifndef PRODUCT 32 #ifndef PRODUCT
33 33
34 DEFINE_FLAG(bool, generate_perf_events_symbols, false, 34 DEFINE_FLAG(bool,
35 "Generate events symbols for profiling with perf"); 35 generate_perf_events_symbols,
36 false,
37 "Generate events symbols for profiling with perf");
36 38
37 class PerfCodeObserver : public CodeObserver { 39 class PerfCodeObserver : public CodeObserver {
38 public: 40 public:
39 PerfCodeObserver() : out_file_(NULL) { 41 PerfCodeObserver() : out_file_(NULL) {
40 Dart_FileOpenCallback file_open = Dart::file_open_callback(); 42 Dart_FileOpenCallback file_open = Dart::file_open_callback();
41 if (file_open == NULL) { 43 if (file_open == NULL) {
42 return; 44 return;
43 } 45 }
44 intptr_t pid = getpid(); 46 intptr_t pid = getpid();
45 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid); 47 char* filename = OS::SCreate(NULL, "/tmp/perf-%" Pd ".map", pid);
(...skipping 16 matching lines...) Expand all
62 virtual void Notify(const char* name, 64 virtual void Notify(const char* name,
63 uword base, 65 uword base,
64 uword prologue_offset, 66 uword prologue_offset,
65 uword size, 67 uword size,
66 bool optimized) { 68 bool optimized) {
67 Dart_FileWriteCallback file_write = Dart::file_write_callback(); 69 Dart_FileWriteCallback file_write = Dart::file_write_callback();
68 if ((file_write == NULL) || (out_file_ == NULL)) { 70 if ((file_write == NULL) || (out_file_ == NULL)) {
69 return; 71 return;
70 } 72 }
71 const char* marker = optimized ? "*" : ""; 73 const char* marker = optimized ? "*" : "";
72 char* buffer = OS::SCreate(Thread::Current()->zone(), 74 char* buffer =
73 "%" Px " %" Px " %s%s\n", base, size, marker, name); 75 OS::SCreate(Thread::Current()->zone(), "%" Px " %" Px " %s%s\n", base,
76 size, marker, name);
74 (*file_write)(buffer, strlen(buffer), out_file_); 77 (*file_write)(buffer, strlen(buffer), out_file_);
75 } 78 }
76 79
77 private: 80 private:
78 void* out_file_; 81 void* out_file_;
79 82
80 DISALLOW_COPY_AND_ASSIGN(PerfCodeObserver); 83 DISALLOW_COPY_AND_ASSIGN(PerfCodeObserver);
81 }; 84 };
82 85
83 #endif // !PRODUCT 86 #endif // !PRODUCT
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 int64_t result = ts.tv_sec; 180 int64_t result = ts.tv_sec;
178 result *= kMicrosecondsPerSecond; 181 result *= kMicrosecondsPerSecond;
179 result += (ts.tv_nsec / kNanosecondsPerMicrosecond); 182 result += (ts.tv_nsec / kNanosecondsPerMicrosecond);
180 return result; 183 return result;
181 } 184 }
182 185
183 186
184 // TODO(5411554): May need to hoist these architecture dependent code 187 // TODO(5411554): May need to hoist these architecture dependent code
185 // into a architecture specific file e.g: os_ia32_linux.cc 188 // into a architecture specific file e.g: os_ia32_linux.cc
186 intptr_t OS::ActivationFrameAlignment() { 189 intptr_t OS::ActivationFrameAlignment() {
187 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \ 190 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \
188 defined(TARGET_ARCH_ARM64) 191 defined(TARGET_ARCH_ARM64)
189 const int kMinimumAlignment = 16; 192 const int kMinimumAlignment = 16;
190 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC) 193 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_DBC)
191 const int kMinimumAlignment = 8; 194 const int kMinimumAlignment = 8;
192 #else 195 #else
193 #error Unsupported architecture. 196 #error Unsupported architecture.
194 #endif 197 #endif
195 intptr_t alignment = kMinimumAlignment; 198 intptr_t alignment = kMinimumAlignment;
196 // TODO(5411554): Allow overriding default stack alignment for 199 // TODO(5411554): Allow overriding default stack alignment for
197 // testing purposes. 200 // testing purposes.
198 // Flags::DebugIsInt("stackalign", &alignment); 201 // Flags::DebugIsInt("stackalign", &alignment);
199 ASSERT(Utils::IsPowerOfTwo(alignment)); 202 ASSERT(Utils::IsPowerOfTwo(alignment));
200 ASSERT(alignment >= kMinimumAlignment); 203 ASSERT(alignment >= kMinimumAlignment);
201 return alignment; 204 return alignment;
202 } 205 }
203 206
204 207
205 intptr_t OS::PreferredCodeAlignment() { 208 intptr_t OS::PreferredCodeAlignment() {
206 #if defined(TARGET_ARCH_IA32) || \ 209 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) || \
207 defined(TARGET_ARCH_X64) || \ 210 defined(TARGET_ARCH_ARM64) || defined(TARGET_ARCH_DBC)
208 defined(TARGET_ARCH_ARM64) || \
209 defined(TARGET_ARCH_DBC)
210 const int kMinimumAlignment = 32; 211 const int kMinimumAlignment = 32;
211 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS) 212 #elif defined(TARGET_ARCH_ARM) || defined(TARGET_ARCH_MIPS)
212 const int kMinimumAlignment = 16; 213 const int kMinimumAlignment = 16;
213 #else 214 #else
214 #error Unsupported architecture. 215 #error Unsupported architecture.
215 #endif 216 #endif
216 intptr_t alignment = kMinimumAlignment; 217 intptr_t alignment = kMinimumAlignment;
217 // TODO(5411554): Allow overriding default code alignment for 218 // TODO(5411554): Allow overriding default code alignment for
218 // testing purposes. 219 // testing purposes.
219 // Flags::DebugIsInt("codealign", &alignment); 220 // Flags::DebugIsInt("codealign", &alignment);
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
383 384
384 385
385 bool OS::StringToInt64(const char* str, int64_t* value) { 386 bool OS::StringToInt64(const char* str, int64_t* value) {
386 ASSERT(str != NULL && strlen(str) > 0 && value != NULL); 387 ASSERT(str != NULL && strlen(str) > 0 && value != NULL);
387 int32_t base = 10; 388 int32_t base = 10;
388 char* endptr; 389 char* endptr;
389 int i = 0; 390 int i = 0;
390 if (str[0] == '-') { 391 if (str[0] == '-') {
391 i = 1; 392 i = 1;
392 } 393 }
393 if ((str[i] == '0') && 394 if ((str[i] == '0') && (str[i + 1] == 'x' || str[i + 1] == 'X') &&
394 (str[i + 1] == 'x' || str[i + 1] == 'X') &&
395 (str[i + 2] != '\0')) { 395 (str[i + 2] != '\0')) {
396 base = 16; 396 base = 16;
397 } 397 }
398 errno = 0; 398 errno = 0;
399 *value = strtoll(str, &endptr, base); 399 *value = strtoll(str, &endptr, base);
400 return ((errno == 0) && (endptr != str) && (*endptr == 0)); 400 return ((errno == 0) && (endptr != str) && (*endptr == 0));
401 } 401 }
402 402
403 403
404 void OS::RegisterCodeObservers() { 404 void OS::RegisterCodeObservers() {
(...skipping 18 matching lines...) Expand all
423 void OS::InitOnce() { 423 void OS::InitOnce() {
424 // TODO(5411554): For now we check that initonce is called only once, 424 // TODO(5411554): For now we check that initonce is called only once,
425 // Once there is more formal mechanism to call InitOnce we can move 425 // Once there is more formal mechanism to call InitOnce we can move
426 // this check there. 426 // this check there.
427 static bool init_once_called = false; 427 static bool init_once_called = false;
428 ASSERT(init_once_called == false); 428 ASSERT(init_once_called == false);
429 init_once_called = true; 429 init_once_called = true;
430 } 430 }
431 431
432 432
433 void OS::Shutdown() { 433 void OS::Shutdown() {}
434 }
435 434
436 435
437 void OS::Abort() { 436 void OS::Abort() {
438 abort(); 437 abort();
439 } 438 }
440 439
441 440
442 void OS::Exit(int code) { 441 void OS::Exit(int code) {
443 exit(code); 442 exit(code);
444 } 443 }
445 444
446 } // namespace dart 445 } // namespace dart
447 446
448 #endif // defined(TARGET_OS_ANDROID) 447 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« no previous file with comments | « runtime/vm/os.h ('k') | runtime/vm/os_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698