Commit 5465c25c authored by alph's avatar alph Committed by Commit bot

Add two CpuProfileNode API functions to allow thread safe access to the node.

GetFunctionNameStr and GetScriptResourceNameStr can be called from a thread
other than isolate VM thread unlike their conterparts GetFunctionName
and GetScriptResourceName.

BUG=406277

Review-Url: https://codereview.chromium.org/2328673003
Cr-Commit-Position: refs/heads/master@{#39313}
parent fcac706a
......@@ -131,12 +131,26 @@ class V8_EXPORT CpuProfileNode {
/** Returns function name (empty string for anonymous functions.) */
Local<String> GetFunctionName() const;
/**
* Returns function name (empty string for anonymous functions.)
* The string ownership is *not* passed to the caller. It stays valid until
* profile is deleted. The function is thread safe.
*/
const char* GetFunctionNameStr() const;
/** Returns id of the script where function is located. */
int GetScriptId() const;
/** Returns resource name for script from where the function originates. */
Local<String> GetScriptResourceName() const;
/**
* Returns resource name for script from where the function originates.
* The string ownership is *not* passed to the caller. It stays valid until
* profile is deleted. The function is thread safe.
*/
const char* GetScriptResourceNameStr() const;
/**
* Returns the number, 1-based, of the line where the function originates.
* kNoLineNumberInfo if no line number information is available.
......
......@@ -8579,6 +8579,10 @@ Local<String> CpuProfileNode::GetFunctionName() const {
}
}
const char* CpuProfileNode::GetFunctionNameStr() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
return node->entry()->name();
}
int CpuProfileNode::GetScriptId() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
......@@ -8586,7 +8590,6 @@ int CpuProfileNode::GetScriptId() const {
return entry->script_id();
}
Local<String> CpuProfileNode::GetScriptResourceName() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
i::Isolate* isolate = node->isolate();
......@@ -8594,6 +8597,10 @@ Local<String> CpuProfileNode::GetScriptResourceName() const {
node->entry()->resource_name()));
}
const char* CpuProfileNode::GetScriptResourceNameStr() const {
const i::ProfileNode* node = reinterpret_cast<const i::ProfileNode*>(this);
return node->entry()->resource_name();
}
int CpuProfileNode::GetLineNumber() const {
return reinterpret_cast<const i::ProfileNode*>(this)->entry()->line_number();
......
......@@ -1671,9 +1671,11 @@ static void CheckFunctionDetails(v8::Isolate* isolate,
int script_id, int line, int column) {
v8::Local<v8::Context> context = isolate->GetCurrentContext();
CHECK(v8_str(name)->Equals(context, node->GetFunctionName()).FromJust());
CHECK_EQ(0, strcmp(name, node->GetFunctionNameStr()));
CHECK(v8_str(script_name)
->Equals(context, node->GetScriptResourceName())
.FromJust());
CHECK_EQ(0, strcmp(script_name, node->GetScriptResourceNameStr()));
CHECK_EQ(script_id, node->GetScriptId());
CHECK_EQ(line, node->GetLineNumber());
CHECK_EQ(column, node->GetColumnNumber());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment