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

Side by Side Diff: src/vm/tick_sampler_posix.cc

Issue 1659163007: Rename fletch -> dartino (Closed) Base URL: https://github.com/dartino/sdk.git@master
Patch Set: address comments Created 4 years, 10 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/vm/tick_sampler_other.cc ('k') | src/vm/unicode.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) 2015, the Dartino project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dartino 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.md file. 3 // BSD-style license that can be found in the LICENSE.md file.
4 4
5 #if defined(FLETCH_TARGET_OS_POSIX) 5 #if defined(DARTINO_TARGET_OS_POSIX)
6 6
7 #include "src/vm/tick_sampler.h" 7 #include "src/vm/tick_sampler.h"
8 8
9 #include <errno.h> 9 #include <errno.h>
10 #include <stdio.h> 10 #include <stdio.h>
11 #include <sys/time.h> 11 #include <sys/time.h>
12 #include <sys/signal.h> 12 #include <sys/signal.h>
13 13
14 #include "src/shared/flags.h" 14 #include "src/shared/flags.h"
15 #include "src/shared/platform.h" 15 #include "src/shared/platform.h"
16 #include "src/shared/utils.h" 16 #include "src/shared/utils.h"
17 17
18 #include "src/vm/process.h" 18 #include "src/vm/process.h"
19 #include "src/vm/tick_queue.h" 19 #include "src/vm/tick_queue.h"
20 #include "src/vm/thread.h" 20 #include "src/vm/thread.h"
21 21
22 22
23 namespace fletch { 23 namespace dartino {
24 24
25 class TickProcessor; 25 class TickProcessor;
26 26
27 Atomic<bool> TickSampler::is_active_(false); 27 Atomic<bool> TickSampler::is_active_(false);
28 static struct sigaction old_signal_handler; 28 static struct sigaction old_signal_handler;
29 static struct itimerval old_timer; 29 static struct itimerval old_timer;
30 static stack_t signal_stack; 30 static stack_t signal_stack;
31 static stack_t old_signal_stack; 31 static stack_t old_signal_stack;
32 static TickQueue* queue; 32 static TickQueue* queue;
33 static TickProcessor* processor; 33 static TickProcessor* processor;
34 34
35 static void SignalHandler(int signal, siginfo_t* info, void* context) { 35 static void SignalHandler(int signal, siginfo_t* info, void* context) {
36 USE(info); 36 USE(info);
37 if (signal != SIGPROF) return; 37 if (signal != SIGPROF) return;
38 TickSample* sample = queue->StartAdd(); 38 TickSample* sample = queue->StartAdd();
39 if (sample == NULL) return; 39 if (sample == NULL) return;
40 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context); 40 ucontext_t* ucontext = reinterpret_cast<ucontext_t*>(context);
41 mcontext_t& mcontext = ucontext->uc_mcontext; 41 mcontext_t& mcontext = ucontext->uc_mcontext;
42 word ip; 42 word ip;
43 #if defined(FLETCH_TARGET_OS_LINUX) 43 #if defined(DARTINO_TARGET_OS_LINUX)
44 #if defined(FLETCH_TARGET_IA32) 44 #if defined(DARTINO_TARGET_IA32)
45 sample->pc = bit_cast<word>(mcontext.gregs[REG_EIP]); 45 sample->pc = bit_cast<word>(mcontext.gregs[REG_EIP]);
46 sample->sp = bit_cast<word>(mcontext.gregs[REG_ESP]); 46 sample->sp = bit_cast<word>(mcontext.gregs[REG_ESP]);
47 sample->fp = bit_cast<word>(mcontext.gregs[REG_EBP]); 47 sample->fp = bit_cast<word>(mcontext.gregs[REG_EBP]);
48 ip = bit_cast<word>(mcontext.gregs[REG_ESI]); 48 ip = bit_cast<word>(mcontext.gregs[REG_ESI]);
49 #elif defined(FLETCH_TARGET_X64) 49 #elif defined(DARTINO_TARGET_X64)
50 sample->pc = bit_cast<word>(mcontext.gregs[REG_RIP]); 50 sample->pc = bit_cast<word>(mcontext.gregs[REG_RIP]);
51 sample->sp = bit_cast<word>(mcontext.gregs[REG_RSP]); 51 sample->sp = bit_cast<word>(mcontext.gregs[REG_RSP]);
52 sample->fp = bit_cast<word>(mcontext.gregs[REG_RBP]); 52 sample->fp = bit_cast<word>(mcontext.gregs[REG_RBP]);
53 ip = bit_cast<word>(mcontext.gregs[REG_RSI]); 53 ip = bit_cast<word>(mcontext.gregs[REG_RSI]);
54 #elif defined(FLETCH_TARGET_ARM) 54 #elif defined(DARTINO_TARGET_ARM)
55 sample->pc = bit_cast<word>(mcontext.arm_pc); 55 sample->pc = bit_cast<word>(mcontext.arm_pc);
56 sample->sp = bit_cast<word>(mcontext.arm_sp); 56 sample->sp = bit_cast<word>(mcontext.arm_sp);
57 sample->fp = bit_cast<word>(mcontext.arm_fp); 57 sample->fp = bit_cast<word>(mcontext.arm_fp);
58 ip = bit_cast<word>(mcontext.arm_r5); 58 ip = bit_cast<word>(mcontext.arm_r5);
59 #else 59 #else
60 FATAL("HandleSignal not support on this platform"); 60 FATAL("HandleSignal not support on this platform");
61 #endif 61 #endif
62 #endif 62 #endif
63 #if defined(FLETCH_TARGET_OS_MACOS) 63 #if defined(DARTINO_TARGET_OS_MACOS)
64 #if defined(FLETCH_TARGET_IA32) 64 #if defined(DARTINO_TARGET_IA32)
65 sample->pc = bit_cast<word>(mcontext->__ss.__eip); 65 sample->pc = bit_cast<word>(mcontext->__ss.__eip);
66 sample->sp = bit_cast<word>(mcontext->__ss.__esp); 66 sample->sp = bit_cast<word>(mcontext->__ss.__esp);
67 sample->fp = bit_cast<word>(mcontext->__ss.__ebp); 67 sample->fp = bit_cast<word>(mcontext->__ss.__ebp);
68 ip = bit_cast<word>(mcontext->__ss.__esi); 68 ip = bit_cast<word>(mcontext->__ss.__esi);
69 #elif defined(FLETCH_TARGET_X64) 69 #elif defined(DARTINO_TARGET_X64)
70 sample->pc = bit_cast<word>(mcontext->__ss.__rip); 70 sample->pc = bit_cast<word>(mcontext->__ss.__rip);
71 sample->sp = bit_cast<word>(mcontext->__ss.__rsp); 71 sample->sp = bit_cast<word>(mcontext->__ss.__rsp);
72 sample->fp = bit_cast<word>(mcontext->__ss.__rbp); 72 sample->fp = bit_cast<word>(mcontext->__ss.__rbp);
73 ip = bit_cast<word>(mcontext->__ss.__rsi); 73 ip = bit_cast<word>(mcontext->__ss.__rsi);
74 #else 74 #else
75 FATAL("HandleSignal not support on this platform"); 75 FATAL("HandleSignal not support on this platform");
76 #endif 76 #endif
77 #endif 77 #endif
78 Process* process = Thread::GetProcess(); 78 Process* process = Thread::GetProcess();
79 if (process == NULL) { 79 if (process == NULL) {
(...skipping 25 matching lines...) Expand all
105 static void* Entry(void* data) { 105 static void* Entry(void* data) {
106 reinterpret_cast<TickProcessor*>(data)->Main(); 106 reinterpret_cast<TickProcessor*>(data)->Main();
107 return NULL; 107 return NULL;
108 } 108 }
109 109
110 void Main() { 110 void Main() {
111 FILE* file = fopen(Flags::tick_file, "w"); 111 FILE* file = fopen(Flags::tick_file, "w");
112 if (file == NULL) { 112 if (file == NULL) {
113 FATAL("Tick file could not be opened for writing"); 113 FATAL("Tick file could not be opened for writing");
114 } 114 }
115 fprintf(file, "# Tick samples from the Fletch VM.\n"); 115 fprintf(file, "# Tick samples from the Dartino VM.\n");
116 const char* model; 116 const char* model;
117 if (kPointerSize == 8 && sizeof(fletch_double) == 8) { 117 if (kPointerSize == 8 && sizeof(dartino_double) == 8) {
118 model = "b64double"; 118 model = "b64double";
119 } else if (kPointerSize == 8 && sizeof(fletch_double) == 4) { 119 } else if (kPointerSize == 8 && sizeof(dartino_double) == 4) {
120 model = "b64float"; 120 model = "b64float";
121 } else if (kPointerSize == 4 && sizeof(fletch_double) == 8) { 121 } else if (kPointerSize == 4 && sizeof(dartino_double) == 8) {
122 model = "b32double"; 122 model = "b32double";
123 } else { 123 } else {
124 ASSERT(kPointerSize == 4 && sizeof(fletch_double) == 4); 124 ASSERT(kPointerSize == 4 && sizeof(dartino_double) == 4);
125 model = "b32float"; 125 model = "b32float";
126 } 126 }
127 fprintf(file, "model=%s\n", model); 127 fprintf(file, "model=%s\n", model);
128 bool timed_out; 128 bool timed_out;
129 do { 129 do {
130 { // Ensure the monitor is locked before calling wait. 130 { // Ensure the monitor is locked before calling wait.
131 ScopedMonitorLock scope(monitor_); 131 ScopedMonitorLock scope(monitor_);
132 timed_out = monitor_->Wait(pause_in_us_); 132 timed_out = monitor_->Wait(pause_in_us_);
133 } 133 }
134 TickSample* sample = queue_->StartRemove(); 134 TickSample* sample = queue_->StartRemove();
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 bool expected = true; 223 bool expected = true;
224 if (!is_active_.compare_exchange_strong(expected, false)) { 224 if (!is_active_.compare_exchange_strong(expected, false)) {
225 FATAL("Tick profiler has not been installed"); 225 FATAL("Tick profiler has not been installed");
226 } 226 }
227 227
228 processor->Join(); 228 processor->Join();
229 delete queue; 229 delete queue;
230 delete processor; 230 delete processor;
231 } 231 }
232 232
233 } // namespace fletch 233 } // namespace dartino
234 234
235 #endif // FLETCH_TARGET_OS_POSIX 235 #endif // DARTINO_TARGET_OS_POSIX
OLDNEW
« no previous file with comments | « src/vm/tick_sampler_other.cc ('k') | src/vm/unicode.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698