OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 Handle<JSObject> stackFrame = Factory::NewJSObject(object_function()); | 387 Handle<JSObject> stackFrame = Factory::NewJSObject(object_function()); |
388 | 388 |
389 JavaScriptFrame* frame = it.frame(); | 389 JavaScriptFrame* frame = it.frame(); |
390 JSFunction* fun(JSFunction::cast(frame->function())); | 390 JSFunction* fun(JSFunction::cast(frame->function())); |
391 Script* script = Script::cast(fun->shared()->script()); | 391 Script* script = Script::cast(fun->shared()->script()); |
392 | 392 |
393 if (options & StackTrace::kLineNumber) { | 393 if (options & StackTrace::kLineNumber) { |
394 int script_line_offset = script->line_offset()->value(); | 394 int script_line_offset = script->line_offset()->value(); |
395 int position = frame->code()->SourcePosition(frame->pc()); | 395 int position = frame->code()->SourcePosition(frame->pc()); |
396 int line_number = GetScriptLineNumber(Handle<Script>(script), position); | 396 int line_number = GetScriptLineNumber(Handle<Script>(script), position); |
397 | 397 // line_number is already shifted by the script_line_offset. |
398 if (options & StackTrace::kColumnOffset) { | 398 int relative_line_number = line_number - script_line_offset; |
| 399 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { |
399 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); | 400 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); |
400 int start = (line_number == 0) ? | 401 int start = (relative_line_number == 0) ? 0 : |
401 0 : Smi::cast(line_ends->get(line_number - 1))->value() + 1; | 402 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; |
402 int column_offset = position - start; | 403 int column_offset = position - start; |
403 if (line_number == script_line_offset) { | 404 if (relative_line_number == 0) { |
404 // For the case where the code is on the same line as the script tag. | 405 // For the case where the code is on the same line as the script tag. |
405 column_offset += script_line_offset; | 406 column_offset += script->column_offset()->value(); |
406 } | 407 } |
407 SetProperty(stackFrame, column_key, | 408 SetProperty(stackFrame, column_key, |
408 Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE); | 409 Handle<Smi>(Smi::FromInt(column_offset + 1)), NONE); |
409 } | 410 } |
410 // Adjust the line_number by the offset in the parent resource. | |
411 line_number += script_line_offset; | |
412 SetProperty(stackFrame, line_key, | 411 SetProperty(stackFrame, line_key, |
413 Handle<Smi>(Smi::FromInt(line_number + 1)), NONE); | 412 Handle<Smi>(Smi::FromInt(line_number + 1)), NONE); |
414 } | 413 } |
415 | 414 |
416 if (options & StackTrace::kScriptName) { | 415 if (options & StackTrace::kScriptName) { |
417 Handle<Object> script_name(script->name()); | 416 Handle<Object> script_name(script->name()); |
418 SetProperty(stackFrame, script_key, script_name, NONE); | 417 SetProperty(stackFrame, script_key, script_name, NONE); |
419 } | 418 } |
420 | 419 |
421 if (options & StackTrace::kFunctionName) { | 420 if (options & StackTrace::kFunctionName) { |
422 Handle<Object> fun_name(fun->shared()->name()); | 421 Handle<Object> fun_name(fun->shared()->name()); |
423 if (!fun_name->IsString()) { | 422 if (fun_name->ToBoolean()->IsFalse()) { |
424 fun_name = Handle<Object>(fun->shared()->inferred_name()); | 423 fun_name = Handle<Object>(fun->shared()->inferred_name()); |
425 } | 424 } |
426 SetProperty(stackFrame, function_key, fun_name, NONE); | 425 SetProperty(stackFrame, function_key, fun_name, NONE); |
427 } | 426 } |
428 | 427 |
429 if (options & StackTrace::kIsEval) { | 428 if (options & StackTrace::kIsEval) { |
430 int type = Smi::cast(script->compilation_type())->value(); | 429 int type = Smi::cast(script->compilation_type())->value(); |
431 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? | 430 Handle<Object> is_eval = (type == Script::COMPILATION_TYPE_EVAL) ? |
432 Factory::true_value() : Factory::false_value(); | 431 Factory::true_value() : Factory::false_value(); |
433 SetProperty(stackFrame, eval_key, is_eval, NONE); | 432 SetProperty(stackFrame, eval_key, is_eval, NONE); |
(...skipping 627 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1061 Top::break_access_->Lock(); | 1060 Top::break_access_->Lock(); |
1062 } | 1061 } |
1063 | 1062 |
1064 | 1063 |
1065 ExecutionAccess::~ExecutionAccess() { | 1064 ExecutionAccess::~ExecutionAccess() { |
1066 Top::break_access_->Unlock(); | 1065 Top::break_access_->Unlock(); |
1067 } | 1066 } |
1068 | 1067 |
1069 | 1068 |
1070 } } // namespace v8::internal | 1069 } } // namespace v8::internal |
OLD | NEW |