Code clean-up in src/top.cc This patch addresses late review comments for http://code.google.com/p/v8/source/detail?r=5586

Review URL: http://codereview.chromium.org/3596005

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@5592 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
yurys@chromium.org 2010-10-05 13:29:31 +00:00
parent 7c238db829
commit 481c25908c

View File

@ -344,6 +344,10 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
Handle<String> column_key = Factory::LookupAsciiSymbol("column"); Handle<String> column_key = Factory::LookupAsciiSymbol("column");
Handle<String> line_key = Factory::LookupAsciiSymbol("lineNumber"); Handle<String> line_key = Factory::LookupAsciiSymbol("lineNumber");
Handle<String> script_key = Factory::LookupAsciiSymbol("scriptName"); Handle<String> script_key = Factory::LookupAsciiSymbol("scriptName");
Handle<String> name_or_source_url_key =
Factory::LookupAsciiSymbol("nameOrSourceURL");
Handle<String> script_name_or_source_url_key =
Factory::LookupAsciiSymbol("scriptNameOrSourceURL");
Handle<String> function_key = Factory::LookupAsciiSymbol("functionName"); Handle<String> function_key = Factory::LookupAsciiSymbol("functionName");
Handle<String> eval_key = Factory::LookupAsciiSymbol("isEval"); Handle<String> eval_key = Factory::LookupAsciiSymbol("isEval");
Handle<String> constructor_key = Factory::LookupAsciiSymbol("isConstructor"); Handle<String> constructor_key = Factory::LookupAsciiSymbol("isConstructor");
@ -355,13 +359,13 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
Handle<JSObject> stackFrame = Factory::NewJSObject(object_function()); Handle<JSObject> stackFrame = Factory::NewJSObject(object_function());
JavaScriptFrame* frame = it.frame(); JavaScriptFrame* frame = it.frame();
JSFunction* fun(JSFunction::cast(frame->function())); Handle<JSFunction> fun(JSFunction::cast(frame->function()));
Script* script = Script::cast(fun->shared()->script()); Handle<Script> script(Script::cast(fun->shared()->script()));
if (options & StackTrace::kLineNumber) { if (options & StackTrace::kLineNumber) {
int script_line_offset = script->line_offset()->value(); int script_line_offset = script->line_offset()->value();
int position = frame->code()->SourcePosition(frame->pc()); int position = frame->code()->SourcePosition(frame->pc());
int line_number = GetScriptLineNumber(Handle<Script>(script), position); int line_number = GetScriptLineNumber(script, position);
// line_number is already shifted by the script_line_offset. // line_number is already shifted by the script_line_offset.
int relative_line_number = line_number - script_line_offset; int relative_line_number = line_number - script_line_offset;
if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
@ -387,10 +391,9 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
if (options & StackTrace::kScriptNameOrSourceURL) { if (options & StackTrace::kScriptNameOrSourceURL) {
Handle<Object> script_name(script->name()); Handle<Object> script_name(script->name());
Handle<String> method_name = Handle<JSValue> script_wrapper = GetScriptWrapper(script);
Factory::LookupAsciiSymbol("nameOrSourceURL"); Handle<Object> property = GetProperty(script_wrapper,
Handle<JSValue> script_wrapper = GetScriptWrapper(Handle<Script>(script)); name_or_source_url_key);
Handle<Object> property = GetProperty(script_wrapper, method_name);
ASSERT(property->IsJSFunction()); ASSERT(property->IsJSFunction());
Handle<JSFunction> method = Handle<JSFunction>::cast(property); Handle<JSFunction> method = Handle<JSFunction>::cast(property);
bool caught_exception; bool caught_exception;
@ -399,8 +402,6 @@ Handle<JSArray> Top::CaptureCurrentStackTrace(
if (caught_exception) { if (caught_exception) {
result = Factory::undefined_value(); result = Factory::undefined_value();
} }
Handle<String> script_name_or_source_url_key =
Factory::LookupAsciiSymbol("scriptNameOrSourceURL");
SetProperty(stackFrame, script_name_or_source_url_key, result, NONE); SetProperty(stackFrame, script_name_or_source_url_key, result, NONE);
} }