Reviewers: Yury Semikhatsky,
Description:
DevTools: CPUProfiler: provide url for scripts that have sourceURL property.
BUG=none
TEST=none
R= [email protected]
Please review this at https://codereview.chromium.org/16035027/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/handles.cc
M src/log.cc
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index
123fdc5adf4de5d691ba3bcdcf1ab28c3fc7810b..47f5632cb05a2cf697b882986f2becee445c4005
100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -366,6 +366,9 @@ Handle<JSValue> GetScriptWrapper(Handle<Script> script)
{
reinterpret_cast<JSValue**>(script->wrapper()->foreign_address()));
}
Isolate* isolate = script->GetIsolate();
+ if (!isolate->IsInitialized()) {
+ return Handle<JSValue>();
+ }
// Construct a new script wrapper.
isolate->counters()->script_wrappers()->Increment();
Handle<JSFunction> constructor = isolate->script_function();
@@ -601,15 +604,22 @@ Handle<Object>
GetScriptNameOrSourceURL(Handle<Script> script) {
isolate->factory()->InternalizeOneByteString(
STATIC_ASCII_VECTOR("nameOrSourceURL"));
Handle<JSValue> script_wrapper = GetScriptWrapper(script);
+ if (script_wrapper.is_null()) {
+ return isolate->factory()->undefined_value();
+ }
Handle<Object> property = GetProperty(isolate,
script_wrapper,
name_or_source_url_key);
- ASSERT(property->IsJSFunction());
- Handle<JSFunction> method = Handle<JSFunction>::cast(property);
- bool caught_exception;
- Handle<Object> result = Execution::TryCall(method, script_wrapper, 0,
- NULL, &caught_exception);
- if (caught_exception) {
+ Handle<Object> result;
+ if (property->IsJSFunction()) {
+ Handle<JSFunction> method = Handle<JSFunction>::cast(property);
+ bool caught_exception;
+ result = Execution::TryCall(method, script_wrapper, 0,
+ NULL, &caught_exception);
+ if (caught_exception) {
+ result = isolate->factory()->undefined_value();
+ }
+ } else {
result = isolate->factory()->undefined_value();
}
return result;
Index: src/log.cc
diff --git a/src/log.cc b/src/log.cc
index
610a63b37a271e4aec95d4c2a572a72a9e63b4d4..656b308324a4c9d33930143d4ac176d764888379
100644
--- a/src/log.cc
+++ b/src/log.cc
@@ -1728,10 +1728,18 @@ void
Logger::LogExistingFunction(Handle<SharedFunctionInfo> shared,
Handle<String> func_name(shared->DebugName());
if (shared->script()->IsScript()) {
Handle<Script> script(Script::cast(shared->script()));
+ Handle<String> script_name;
if (script->name()->IsString()) {
- Handle<String> script_name(String::cast(script->name()));
+ script_name = Handle<String>(String::cast(script->name()));
+ } else {
+ Handle<Object> name = GetScriptNameOrSourceURL(script);
+ if (!name.is_null() && name->IsString()) {
+ script_name = Handle<String>::cast(name);
+ }
+ }
+ if (!script_name.is_null()) {
int line_num = GetScriptLineNumber(script, shared->start_position());
- if (line_num > 0) {
+ if (line_num >= 0) {
PROFILE(isolate_,
CodeCreateEvent(
Logger::ToNativeByScript(Logger::LAZY_COMPILE_TAG,
*script),
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.