Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/cloud_env.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <cstdlib>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#include "src/clock.h"
Expand Down Expand Up @@ -161,7 +162,7 @@ std::string CloudEnv::ProjectID(HTTPRequest* req) {
return resp;
}

project_id_ = resp;
project_id_ = std::move(resp);
return project_id_;
}

Expand Down Expand Up @@ -218,7 +219,7 @@ std::string CloudEnv::Oauth2AccessToken(HTTPRequest* req) {
continue;
}
if (pair[0] == "access_token") {
return pair[1];
return std::move(pair[1]);
}
}
LOG(ERROR) << "Could not parse access token out of '" << resp << "'";
Expand Down
2 changes: 1 addition & 1 deletion src/string.cc
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ bool ParseKeyValueList(const std::string& s,
if (k.empty()) {
return false;
}
(*out)[k] = kv.substr(pos + 1);
(*out)[std::move(k)] = kv.substr(pos + 1);
}
return true;
}
Expand Down
6 changes: 6 additions & 0 deletions src/throttler_api.cc
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,12 @@ APIThrottler::APIThrottler(
closed_(false),
backing_off_for_testing_(false) {
grpc_init();
// Note from the gRPC team :
// gpr_set_log_function will work only till gRPC version 1.64. Versions after
// that do not support gpr_set_log_function. However since your function
// GRPCLog is equivalent to what gRPC is doing internally, it would be safe to
// delete this line and the entire GRPCLog function when you upgrade gRPC to
// version 1.65 or later.
gpr_set_log_function(GRPCLog);

// Create a random number generator.
Expand Down
3 changes: 2 additions & 1 deletion src/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <memory>
#include <mutex>
#include <string>
#include <utility>
#include <vector>

#include "src/clock.h"
Expand Down Expand Up @@ -215,7 +216,7 @@ void Worker::ProfileThread(jvmtiEnv *jvmti_env, JNIEnv *jni_env, void *arg) {
LOG(ERROR) << "No profile bytes collected, skipping the upload";
continue;
}
if (!w->throttler_->Upload(profile)) {
if (!w->throttler_->Upload(std::move(profile))) {
LOG(ERROR) << "Error on profile upload, discarding the profile";
}
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/javaprofiler/heap_sampler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ namespace {
using google::javaprofiler::JVMPI_CallFrame;

std::vector<JVMPI_CallFrame> TransformFrames(jvmtiFrameInfo *stack_frames,
int count) {
jint count) {
std::vector<JVMPI_CallFrame> frames(count);

for (int i = 0; i < count; i++) {
Expand Down
20 changes: 15 additions & 5 deletions third_party/javaprofiler/method_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,27 @@

#include "third_party/javaprofiler/method_info.h"

#include <cstdint>

#include "third_party/javaprofiler/display.h"
#include "third_party/javaprofiler/stacktrace_decls.h"

namespace google {
namespace javaprofiler {

int64_t MethodInfo::Location(int line_number) {
auto it = locations_.find(line_number);
if (it == locations_.end()) {
return kInvalidLocationId;
int64_t MethodInfo::LineNumber(const JVMPI_CallFrame &frame) {
// lineno is actually the BCI of the frame.
int bci = frame.lineno;

auto it = line_numbers_.find(bci);
if (it != line_numbers_.end()) {
return it->second;
}
return it->second;

int line_number = GetLineNumber(jvmti_env_, frame.method_id, bci);

line_numbers_[bci] = line_number;
return line_number;
}

} // namespace javaprofiler
Expand Down
32 changes: 14 additions & 18 deletions third_party/javaprofiler/method_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#define GOOGLE_JAVAPROFILER_METHOD_INFO_H_

#include <cstdint>
#include <jvmti.h>
#include <string>
#include <unordered_map>

#include "perftools/profiles/proto/builder.h"
#include "third_party/javaprofiler/globals.h"
#include "third_party/javaprofiler/stacktrace_decls.h"

namespace google {
Expand All @@ -34,41 +34,37 @@ namespace javaprofiler {
class MethodInfo {
public:
// Constructor providing all the information regarding a method.
MethodInfo(const std::string &method_name, const std::string &class_name,
const std::string &file_name, const int &start_line)
: method_name_(method_name),
MethodInfo(jvmtiEnv *jvmti_env,
const std::string &method_name,
const std::string &class_name,
const std::string &file_name,
const int &start_line)
: jvmti_env_(jvmti_env),
method_name_(method_name),
class_name_(class_name),
file_name_(file_name),
start_line_(start_line) {}

// An invalid location Id.
static const int64_t kInvalidLocationId = 0;

// Return the location representing info, returns kInvalidLocationId
// if not found.
int64_t Location(int line_number);

// Put a location ID assocated to a ByteCode Index (BCI).
void AddLocation(int bci, int64_t location_id) {
locations_[bci] = location_id;
}
int64_t LineNumber(const JVMPI_CallFrame &frame);

const std::string &MethodName() const { return method_name_; }

const std::string &ClassName() const { return class_name_; }

const std::string &FileName() const { return file_name_; }

const int& StartLine() const { return start_line_; }
int StartLine() const { return start_line_; }

private:
jvmtiEnv *jvmti_env_;

std::string method_name_;
std::string class_name_;
std::string file_name_;
int start_line_;

// Cache of jlocation results.
std::unordered_map<int, int64_t> locations_;
std::unordered_map<int, int64_t> line_numbers_;
};

} // namespace javaprofiler
Expand Down
Loading