Chromium Code Reviews| Index: src/isolate.cc |
| diff --git a/src/isolate.cc b/src/isolate.cc |
| index 3c9a89999a7bb52191dcb2b63ea69f2bdf498eb1..24d4e52b455b1b70e430afd4acca30d0cf23b9a0 100644 |
| --- a/src/isolate.cc |
| +++ b/src/isolate.cc |
| @@ -547,46 +547,58 @@ class CaptureStackTraceHelper { |
| Handle<JSObject> stack_frame = |
| factory()->NewJSObject(isolate_->object_function()); |
| - Handle<Script> script(Script::cast(fun->shared()->script())); |
| - |
| - if (!line_key_.is_null()) { |
| - int script_line_offset = script->line_offset(); |
| - int line_number = Script::GetLineNumber(script, position); |
| - // line_number is already shifted by the script_line_offset. |
| - int relative_line_number = line_number - script_line_offset; |
| - if (!column_key_.is_null() && relative_line_number >= 0) { |
| - Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| - int start = (relative_line_number == 0) ? 0 : |
| - Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; |
| - int column_offset = position - start; |
| - if (relative_line_number == 0) { |
| - // For the case where the code is on the same line as the script |
| - // tag. |
| - column_offset += script->column_offset(); |
| + if (!fun->shared()->script()->IsUndefined()) { |
|
JF
2016/04/11 17:46:33
In which cases is script() undefined? When coming
Clemens Hammacher
2016/04/12 09:30:57
Yes, just for wasm functions. I added a TODO.
|
| + Handle<Script> script(Script::cast(fun->shared()->script())); |
| + |
| + if (!line_key_.is_null()) { |
| + int script_line_offset = script->line_offset(); |
| + int line_number = Script::GetLineNumber(script, position); |
| + // line_number is already shifted by the script_line_offset. |
| + int relative_line_number = line_number - script_line_offset; |
| + if (!column_key_.is_null() && relative_line_number >= 0) { |
| + Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
| + int start = (relative_line_number == 0) |
| + ? 0 |
| + : Smi::cast(line_ends->get(relative_line_number - 1)) |
| + ->value() + |
| + 1; |
| + int column_offset = position - start; |
| + if (relative_line_number == 0) { |
| + // For the case where the code is on the same line as the script |
| + // tag. |
| + column_offset += script->column_offset(); |
| + } |
| + JSObject::AddProperty( |
| + stack_frame, column_key_, |
| + handle(Smi::FromInt(column_offset + 1), isolate_), NONE); |
| } |
| - JSObject::AddProperty(stack_frame, column_key_, |
| - handle(Smi::FromInt(column_offset + 1), isolate_), |
| + JSObject::AddProperty(stack_frame, line_key_, |
| + handle(Smi::FromInt(line_number + 1), isolate_), |
| NONE); |
| } |
| - JSObject::AddProperty(stack_frame, line_key_, |
| - handle(Smi::FromInt(line_number + 1), isolate_), |
| - NONE); |
| - } |
| - if (!script_id_key_.is_null()) { |
| - JSObject::AddProperty(stack_frame, script_id_key_, |
| - handle(Smi::FromInt(script->id()), isolate_), NONE); |
| - } |
| + if (!script_id_key_.is_null()) { |
| + JSObject::AddProperty(stack_frame, script_id_key_, |
| + handle(Smi::FromInt(script->id()), isolate_), |
| + NONE); |
| + } |
| - if (!script_name_key_.is_null()) { |
| - JSObject::AddProperty(stack_frame, script_name_key_, |
| - handle(script->name(), isolate_), NONE); |
| - } |
| + if (!script_name_key_.is_null()) { |
| + JSObject::AddProperty(stack_frame, script_name_key_, |
| + handle(script->name(), isolate_), NONE); |
| + } |
| - if (!script_name_or_source_url_key_.is_null()) { |
| - Handle<Object> result = Script::GetNameOrSourceURL(script); |
| - JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, result, |
| - NONE); |
| + if (!script_name_or_source_url_key_.is_null()) { |
| + Handle<Object> result = Script::GetNameOrSourceURL(script); |
| + JSObject::AddProperty(stack_frame, script_name_or_source_url_key_, |
| + result, NONE); |
| + } |
| + |
| + if (!eval_key_.is_null()) { |
| + Handle<Object> is_eval = factory()->ToBoolean( |
| + script->compilation_type() == Script::COMPILATION_TYPE_EVAL); |
| + JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); |
| + } |
| } |
| if (!function_key_.is_null()) { |
| @@ -594,12 +606,6 @@ class CaptureStackTraceHelper { |
| JSObject::AddProperty(stack_frame, function_key_, fun_name, NONE); |
| } |
| - if (!eval_key_.is_null()) { |
| - Handle<Object> is_eval = factory()->ToBoolean( |
| - script->compilation_type() == Script::COMPILATION_TYPE_EVAL); |
| - JSObject::AddProperty(stack_frame, eval_key_, is_eval, NONE); |
| - } |
| - |
| if (!constructor_key_.is_null()) { |
| Handle<Object> is_constructor_obj = factory()->ToBoolean(is_constructor); |
| JSObject::AddProperty(stack_frame, constructor_key_, is_constructor_obj, |