Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 4de3a00

Browse files
committedJun 25, 2015
Merge remote-tracking branch 'origin' into 1.8.7
2 parents 587100d + 206ed76 commit 4de3a00

File tree

2 files changed

+38
-12
lines changed

2 files changed

+38
-12
lines changed
 

‎vm/builtin/location.cpp

+21-6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "builtin/variable_scope.hpp"
99
#include "call_frame.hpp"
1010
#include "ontology.hpp"
11+
#include "on_stack.hpp"
1112

1213
namespace rubinius {
1314
void Location::init(STATE) {
@@ -82,11 +83,22 @@ namespace rubinius {
8283
return loc;
8384
}
8485

85-
Array* Location::from_call_stack(STATE, CallFrame* start_call_frame,
86+
Array* Location::from_call_stack(STATE, CallFrame* call_frame,
8687
bool include_vars, bool on_ip)
8788
{
88-
Array* bt = Array::create(state, 5);
89-
CallFrame* call_frame = start_call_frame;
89+
size_t count = 0;
90+
91+
CallFrame* c = call_frame;
92+
while(c) {
93+
if(c->compiled_code) count++;
94+
c = c->previous;
95+
}
96+
97+
Array* bt = 0;
98+
Location* loc = 0;
99+
OnStack<2> os(state, bt, loc);
100+
101+
bt = Array::create(state, count);
90102

91103
// Initial edge.
92104
if(!call_frame) return bt;
@@ -98,7 +110,7 @@ namespace rubinius {
98110
if(!call_frame) return bt;
99111
}
100112

101-
Location* loc = Location::create(state, call_frame, include_vars);
113+
loc = Location::create(state, call_frame, include_vars);
102114
if(on_ip) loc->set_ip_on_current(state);
103115

104116
bt->append(state, loc);
@@ -110,7 +122,7 @@ namespace rubinius {
110122
if(call_frame->compiled_code) {
111123
bt->append(state, Location::create(state, call_frame, include_vars));
112124
} else if(NativeMethodFrame* nmf = call_frame->native_method_frame()) {
113-
Location* loc = Location::create(state, nmf);
125+
loc = Location::create(state, nmf);
114126
if(loc) bt->append(state, loc);
115127
}
116128

@@ -121,6 +133,9 @@ namespace rubinius {
121133
}
122134

123135
Array* Location::mri_backtrace(STATE, CallFrame* call_frame) {
136+
Array* bt = 0;
137+
OnStack<1> os(state, bt);
138+
124139
size_t count = 0;
125140

126141
CallFrame* c = call_frame;
@@ -129,7 +144,7 @@ namespace rubinius {
129144
c = c->previous;
130145
}
131146

132-
Array* bt = Array::create(state, count);
147+
bt = Array::create(state, count);
133148

134149
while(call_frame) {
135150
// Ignore synthetic frames

‎vm/metrics.cpp

+17-6
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ namespace rubinius {
7878
cleanup();
7979
}
8080

81-
#define RBX_METRICS_FILE_BUFLEN 22
81+
#define RBX_METRICS_FILE_BUFLEN 256
8282

8383
void FileEmitter::send_metrics() {
8484
char buf[RBX_METRICS_FILE_BUFLEN];
@@ -93,7 +93,10 @@ namespace rubinius {
9393
logger::error("%s: unable to write file metrics", strerror(errno));
9494
}
9595
}
96-
write(fd_, "\n", 1);
96+
97+
if(write(fd_, "\n", 1)) {
98+
logger::error("%s: unable to write file metrics", strerror(errno));
99+
}
97100
}
98101

99102
void FileEmitter::initialize() {
@@ -102,14 +105,22 @@ namespace rubinius {
102105
}
103106

104107
if(lseek(fd_, 0, SEEK_END) == 0) {
108+
char buf[RBX_METRICS_FILE_BUFLEN];
109+
105110
for(MetricsMap::iterator i = metrics_map_.begin();
106111
i != metrics_map_.end();
107112
++i)
108113
{
109-
if(i != metrics_map_.begin()) write(fd_, ", ", 2);
110-
write(fd_, (*i)->first.c_str(), (*i)->first.size());
114+
snprintf(buf, RBX_METRICS_FILE_BUFLEN, "%s%s",
115+
i == metrics_map_.begin() ? "" : ", ", (*i)->first.c_str());
116+
if(write(fd_, buf, strlen(buf)) < 0) {
117+
logger::error("%s: unable to write file metrics", strerror(errno));
118+
}
119+
}
120+
121+
if(write(fd_, "\n", 1)) {
122+
logger::error("%s: unable to write file metrics", strerror(errno));
111123
}
112-
write(fd_, "\n", 1);
113124
}
114125
}
115126

@@ -196,7 +207,7 @@ namespace rubinius {
196207
i != metrics_map_.end();
197208
++i)
198209
{
199-
snprintf(buf, RBX_METRICS_STATSD_BUFLEN, "%s%s:%lld|c",
210+
snprintf(buf, RBX_METRICS_STATSD_BUFLEN, "%s%s:%lld|g",
200211
prefix_.c_str(), (*i)->first.c_str(), (long long unsigned int)(*i)->second);
201212
if(send(socket_fd_, buf, strlen(buf), 0) < 0) {
202213
logger::error("%s: unable to send StatsD metrics", strerror(errno));

0 commit comments

Comments
 (0)
Please sign in to comment.