Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Side by Side Diff: src/isolate.cc

Issue 239113009: Reland "Move functions from handles.cc to where they belong." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: fix Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/handles.cc ('k') | src/json-stringifier.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) { 512 for (int i = frames.length() - 1; i >= 0 && frames_seen < limit; i--) {
513 // Create a JSObject to hold the information for the StackFrame. 513 // Create a JSObject to hold the information for the StackFrame.
514 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function()); 514 Handle<JSObject> stack_frame = factory()->NewJSObject(object_function());
515 515
516 Handle<JSFunction> fun = frames[i].function(); 516 Handle<JSFunction> fun = frames[i].function();
517 Handle<Script> script(Script::cast(fun->shared()->script())); 517 Handle<Script> script(Script::cast(fun->shared()->script()));
518 518
519 if (options & StackTrace::kLineNumber) { 519 if (options & StackTrace::kLineNumber) {
520 int script_line_offset = script->line_offset()->value(); 520 int script_line_offset = script->line_offset()->value();
521 int position = frames[i].code()->SourcePosition(frames[i].pc()); 521 int position = frames[i].code()->SourcePosition(frames[i].pc());
522 int line_number = GetScriptLineNumber(script, position); 522 int line_number = Script::GetLineNumber(script, position);
523 // line_number is already shifted by the script_line_offset. 523 // line_number is already shifted by the script_line_offset.
524 int relative_line_number = line_number - script_line_offset; 524 int relative_line_number = line_number - script_line_offset;
525 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) { 525 if (options & StackTrace::kColumnOffset && relative_line_number >= 0) {
526 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends())); 526 Handle<FixedArray> line_ends(FixedArray::cast(script->line_ends()));
527 int start = (relative_line_number == 0) ? 0 : 527 int start = (relative_line_number == 0) ? 0 :
528 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1; 528 Smi::cast(line_ends->get(relative_line_number - 1))->value() + 1;
529 int column_offset = position - start; 529 int column_offset = position - start;
530 if (relative_line_number == 0) { 530 if (relative_line_number == 0) {
531 // For the case where the code is on the same line as the script 531 // For the case where the code is on the same line as the script
532 // tag. 532 // tag.
(...skipping 14 matching lines...) Expand all
547 stack_frame, script_id_key, script_id, NONE).Check(); 547 stack_frame, script_id_key, script_id, NONE).Check();
548 } 548 }
549 549
550 if (options & StackTrace::kScriptName) { 550 if (options & StackTrace::kScriptName) {
551 Handle<Object> script_name(script->name(), this); 551 Handle<Object> script_name(script->name(), this);
552 JSObject::SetLocalPropertyIgnoreAttributes( 552 JSObject::SetLocalPropertyIgnoreAttributes(
553 stack_frame, script_name_key, script_name, NONE).Check(); 553 stack_frame, script_name_key, script_name, NONE).Check();
554 } 554 }
555 555
556 if (options & StackTrace::kScriptNameOrSourceURL) { 556 if (options & StackTrace::kScriptNameOrSourceURL) {
557 Handle<Object> result = GetScriptNameOrSourceURL(script); 557 Handle<Object> result = Script::GetNameOrSourceURL(script);
558 JSObject::SetLocalPropertyIgnoreAttributes( 558 JSObject::SetLocalPropertyIgnoreAttributes(
559 stack_frame, script_name_or_source_url_key, result, NONE).Check(); 559 stack_frame, script_name_or_source_url_key, result, NONE).Check();
560 } 560 }
561 561
562 if (options & StackTrace::kFunctionName) { 562 if (options & StackTrace::kFunctionName) {
563 Handle<Object> fun_name(fun->shared()->name(), this); 563 Handle<Object> fun_name(fun->shared()->name(), this);
564 if (!fun_name->BooleanValue()) { 564 if (!fun_name->BooleanValue()) {
565 fun_name = Handle<Object>(fun->shared()->inferred_name(), this); 565 fun_name = Handle<Object>(fun->shared()->inferred_name(), this);
566 } 566 }
567 JSObject::SetLocalPropertyIgnoreAttributes( 567 JSObject::SetLocalPropertyIgnoreAttributes(
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
812 // At this point we cannot create an Error object using its javascript 812 // At this point we cannot create an Error object using its javascript
813 // constructor. Instead, we copy the pre-constructed boilerplate and 813 // constructor. Instead, we copy the pre-constructed boilerplate and
814 // attach the stack trace as a hidden property. 814 // attach the stack trace as a hidden property.
815 Handle<String> key = factory()->stack_overflow_string(); 815 Handle<String> key = factory()->stack_overflow_string();
816 Handle<JSObject> boilerplate = Handle<JSObject>::cast( 816 Handle<JSObject> boilerplate = Handle<JSObject>::cast(
817 Object::GetProperty(js_builtins_object(), key).ToHandleChecked()); 817 Object::GetProperty(js_builtins_object(), key).ToHandleChecked());
818 Handle<JSObject> exception = JSObject::Copy(boilerplate); 818 Handle<JSObject> exception = JSObject::Copy(boilerplate);
819 DoThrow(*exception, NULL); 819 DoThrow(*exception, NULL);
820 820
821 // Get stack trace limit. 821 // Get stack trace limit.
822 Handle<Object> error = 822 Handle<Object> error = Object::GetProperty(
823 GetProperty(js_builtins_object(), "$Error").ToHandleChecked(); 823 this, js_builtins_object(), "$Error").ToHandleChecked();
824 if (!error->IsJSObject()) return Failure::Exception(); 824 if (!error->IsJSObject()) return Failure::Exception();
825 825
826 Handle<String> stackTraceLimit = 826 Handle<String> stackTraceLimit =
827 factory()->InternalizeUtf8String("stackTraceLimit"); 827 factory()->InternalizeUtf8String("stackTraceLimit");
828 ASSERT(!stackTraceLimit.is_null()); 828 ASSERT(!stackTraceLimit.is_null());
829 Handle<Object> stack_trace_limit = 829 Handle<Object> stack_trace_limit =
830 JSObject::GetDataProperty(Handle<JSObject>::cast(error), 830 JSObject::GetDataProperty(Handle<JSObject>::cast(error),
831 stackTraceLimit); 831 stackTraceLimit);
832 if (!stack_trace_limit->IsNumber()) return Failure::Exception(); 832 if (!stack_trace_limit->IsNumber()) return Failure::Exception();
833 double dlimit = stack_trace_limit->Number(); 833 double dlimit = stack_trace_limit->Number();
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 MessageHandler::GetLocalizedMessage(this, message_obj).get()); 1130 MessageHandler::GetLocalizedMessage(this, message_obj).get());
1131 PrintCurrentStackTrace(stderr); 1131 PrintCurrentStackTrace(stderr);
1132 OS::Abort(); 1132 OS::Abort();
1133 } 1133 }
1134 } else if (location != NULL && !location->script().is_null()) { 1134 } else if (location != NULL && !location->script().is_null()) {
1135 // We are bootstrapping and caught an error where the location is set 1135 // We are bootstrapping and caught an error where the location is set
1136 // and we have a script for the location. 1136 // and we have a script for the location.
1137 // In this case we could have an extension (or an internal error 1137 // In this case we could have an extension (or an internal error
1138 // somewhere) and we print out the line number at which the error occured 1138 // somewhere) and we print out the line number at which the error occured
1139 // to the console for easier debugging. 1139 // to the console for easier debugging.
1140 int line_number = GetScriptLineNumberSafe(location->script(), 1140 int line_number =
1141 location->start_pos()); 1141 location->script()->GetLineNumber(location->start_pos()) + 1;
1142 if (exception->IsString() && location->script()->name()->IsString()) { 1142 if (exception->IsString() && location->script()->name()->IsString()) {
1143 OS::PrintError( 1143 OS::PrintError(
1144 "Extension or internal compilation error: %s in %s at line %d.\n", 1144 "Extension or internal compilation error: %s in %s at line %d.\n",
1145 String::cast(exception)->ToCString().get(), 1145 String::cast(exception)->ToCString().get(),
1146 String::cast(location->script()->name())->ToCString().get(), 1146 String::cast(location->script()->name())->ToCString().get(),
1147 line_number + 1); 1147 line_number);
1148 } else if (location->script()->name()->IsString()) { 1148 } else if (location->script()->name()->IsString()) {
1149 OS::PrintError( 1149 OS::PrintError(
1150 "Extension or internal compilation error in %s at line %d.\n", 1150 "Extension or internal compilation error in %s at line %d.\n",
1151 String::cast(location->script()->name())->ToCString().get(), 1151 String::cast(location->script()->name())->ToCString().get(),
1152 line_number + 1); 1152 line_number);
1153 } else { 1153 } else {
1154 OS::PrintError("Extension or internal compilation error.\n"); 1154 OS::PrintError("Extension or internal compilation error.\n");
1155 } 1155 }
1156 } 1156 }
1157 } 1157 }
1158 1158
1159 // Save the message for reporting if the the exception remains uncaught. 1159 // Save the message for reporting if the the exception remains uncaught.
1160 thread_local_top()->has_pending_message_ = report_exception; 1160 thread_local_top()->has_pending_message_ = report_exception;
1161 1161
1162 // Do not forget to clean catcher_ if currently thrown exception cannot 1162 // Do not forget to clean catcher_ if currently thrown exception cannot
(...skipping 1087 matching lines...) Expand 10 before | Expand all | Expand 10 after
2250 Handle<JSObject> obj = factory()->NewJSObjectFromMap(map); 2250 Handle<JSObject> obj = factory()->NewJSObjectFromMap(map);
2251 JSObject::NormalizeProperties(obj, KEEP_INOBJECT_PROPERTIES, 8); 2251 JSObject::NormalizeProperties(obj, KEEP_INOBJECT_PROPERTIES, 8);
2252 JSObject::SetProperty(registry, name, obj, NONE, STRICT).Assert(); 2252 JSObject::SetProperty(registry, name, obj, NONE, STRICT).Assert();
2253 } 2253 }
2254 } 2254 }
2255 return Handle<JSObject>::cast(factory()->symbol_registry()); 2255 return Handle<JSObject>::cast(factory()->symbol_registry());
2256 } 2256 }
2257 2257
2258 2258
2259 } } // namespace v8::internal 2259 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/handles.cc ('k') | src/json-stringifier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698