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

Side by Side Diff: src/isolate.cc

Issue 987353002: Simplify and correctify pending message location handling. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 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
« no previous file with comments | « src/isolate.h ('k') | no next file » | 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 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <stdlib.h> 5 #include <stdlib.h>
6 6
7 #include <fstream> // NOLINT(readability/streams) 7 #include <fstream> // NOLINT(readability/streams)
8 #include <sstream> 8 #include <sstream>
9 9
10 #include "src/v8.h" 10 #include "src/v8.h"
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
983 if (bootstrapper()->IsActive()) { 983 if (bootstrapper()->IsActive()) {
984 // It's not safe to try to make message objects or collect stack traces 984 // It's not safe to try to make message objects or collect stack traces
985 // while the bootstrapper is active since the infrastructure may not have 985 // while the bootstrapper is active since the infrastructure may not have
986 // been properly initialized. 986 // been properly initialized.
987 ReportBootstrappingException(exception_handle, location); 987 ReportBootstrappingException(exception_handle, location);
988 } else { 988 } else {
989 Handle<Object> message_obj = CreateMessage(exception_handle, location); 989 Handle<Object> message_obj = CreateMessage(exception_handle, location);
990 990
991 thread_local_top()->pending_message_obj_ = *message_obj; 991 thread_local_top()->pending_message_obj_ = *message_obj;
992 thread_local_top()->pending_message_script_ = *location->script(); 992 thread_local_top()->pending_message_script_ = *location->script();
993 thread_local_top()->pending_message_start_pos_ = location->start_pos();
994 thread_local_top()->pending_message_end_pos_ = location->end_pos();
995 993
996 // If the abort-on-uncaught-exception flag is specified, abort on any 994 // If the abort-on-uncaught-exception flag is specified, abort on any
997 // exception not caught by JavaScript, even when an external handler is 995 // exception not caught by JavaScript, even when an external handler is
998 // present. This flag is intended for use by JavaScript developers, so 996 // present. This flag is intended for use by JavaScript developers, so
999 // print a user-friendly stack trace (not an internal one). 997 // print a user-friendly stack trace (not an internal one).
1000 if (fatal_exception_depth == 0 && FLAG_abort_on_uncaught_exception && 998 if (fatal_exception_depth == 0 && FLAG_abort_on_uncaught_exception &&
1001 (report_exception || can_be_caught_externally)) { 999 (report_exception || can_be_caught_externally)) {
1002 fatal_exception_depth++; 1000 fatal_exception_depth++;
1003 PrintF(stderr, "%s\n\nFROM\n", 1001 PrintF(stderr, "%s\n\nFROM\n",
1004 MessageHandler::GetLocalizedMessage(this, message_obj).get()); 1002 MessageHandler::GetLocalizedMessage(this, message_obj).get());
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1161 DCHECK(handler == try_catch_handler()); 1159 DCHECK(handler == try_catch_handler());
1162 DCHECK(handler->HasCaught()); 1160 DCHECK(handler->HasCaught());
1163 DCHECK(handler->rethrow_); 1161 DCHECK(handler->rethrow_);
1164 DCHECK(handler->capture_message_); 1162 DCHECK(handler->capture_message_);
1165 Object* message = reinterpret_cast<Object*>(handler->message_obj_); 1163 Object* message = reinterpret_cast<Object*>(handler->message_obj_);
1166 Object* script = reinterpret_cast<Object*>(handler->message_script_); 1164 Object* script = reinterpret_cast<Object*>(handler->message_script_);
1167 DCHECK(message->IsJSMessageObject() || message->IsTheHole()); 1165 DCHECK(message->IsJSMessageObject() || message->IsTheHole());
1168 DCHECK(script->IsScript() || script->IsTheHole()); 1166 DCHECK(script->IsScript() || script->IsTheHole());
1169 thread_local_top()->pending_message_obj_ = message; 1167 thread_local_top()->pending_message_obj_ = message;
1170 thread_local_top()->pending_message_script_ = script; 1168 thread_local_top()->pending_message_script_ = script;
1171 thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_;
1172 thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_;
1173 } 1169 }
1174 1170
1175 1171
1176 void Isolate::CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler) { 1172 void Isolate::CancelScheduledExceptionFromTryCatch(v8::TryCatch* handler) {
1177 DCHECK(has_scheduled_exception()); 1173 DCHECK(has_scheduled_exception());
1178 if (scheduled_exception() == handler->exception_) { 1174 if (scheduled_exception() == handler->exception_) {
1179 DCHECK(scheduled_exception() != heap()->termination_exception()); 1175 DCHECK(scheduled_exception() != heap()->termination_exception());
1180 clear_scheduled_exception(); 1176 clear_scheduled_exception();
1181 } 1177 }
1182 } 1178 }
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 1437
1442 HandleScope scope(this); 1438 HandleScope scope(this);
1443 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) { 1439 if (thread_local_top_.pending_exception_ == heap()->termination_exception()) {
1444 // Do nothing: if needed, the exception has been already propagated to 1440 // Do nothing: if needed, the exception has been already propagated to
1445 // v8::TryCatch. 1441 // v8::TryCatch.
1446 } else { 1442 } else {
1447 if (thread_local_top_.has_pending_message_) { 1443 if (thread_local_top_.has_pending_message_) {
1448 thread_local_top_.has_pending_message_ = false; 1444 thread_local_top_.has_pending_message_ = false;
1449 if (!thread_local_top_.pending_message_obj_->IsTheHole()) { 1445 if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
1450 HandleScope scope(this); 1446 HandleScope scope(this);
1451 Handle<Object> message_obj(thread_local_top_.pending_message_obj_, 1447 Handle<JSMessageObject> message_obj(
1452 this); 1448 JSMessageObject::cast(thread_local_top_.pending_message_obj_));
1453 if (!thread_local_top_.pending_message_script_->IsTheHole()) { 1449 if (!thread_local_top_.pending_message_script_->IsTheHole()) {
1454 Handle<Script> script( 1450 Handle<Script> script(
1455 Script::cast(thread_local_top_.pending_message_script_)); 1451 Script::cast(thread_local_top_.pending_message_script_));
1456 int start_pos = thread_local_top_.pending_message_start_pos_; 1452 int start_pos = message_obj->start_position();
1457 int end_pos = thread_local_top_.pending_message_end_pos_; 1453 int end_pos = message_obj->end_position();
1458 MessageLocation location(script, start_pos, end_pos); 1454 MessageLocation location(script, start_pos, end_pos);
1459 MessageHandler::ReportMessage(this, &location, message_obj); 1455 MessageHandler::ReportMessage(this, &location, message_obj);
1460 } else { 1456 } else {
1461 MessageHandler::ReportMessage(this, NULL, message_obj); 1457 MessageHandler::ReportMessage(this, NULL, message_obj);
1462 } 1458 }
1463 } 1459 }
1464 } 1460 }
1465 } 1461 }
1466 if (can_clear_message) clear_pending_message(); 1462 if (can_clear_message) clear_pending_message();
1467 } 1463 }
1468 1464
1469 1465
1470 MessageLocation Isolate::GetMessageLocation() { 1466 MessageLocation Isolate::GetMessageLocation() {
Michael Starzinger 2015/03/10 13:45:07 Please appreciate the fact that I can put UNREACHA
titzer 2015/03/10 13:48:24 Yeah, given that you showed me that this is only c
1471 DCHECK(has_pending_exception()); 1467 DCHECK(has_pending_exception());
1472 1468
1473 if (thread_local_top_.pending_exception_ != heap()->termination_exception() && 1469 if (thread_local_top_.pending_exception_ != heap()->termination_exception() &&
1474 thread_local_top_.has_pending_message_ && 1470 thread_local_top_.has_pending_message_ &&
1475 !thread_local_top_.pending_message_obj_->IsTheHole()) { 1471 !thread_local_top_.pending_message_obj_->IsTheHole()) {
1472 Handle<JSMessageObject> message_obj(
1473 JSMessageObject::cast(thread_local_top_.pending_message_obj_));
1476 Handle<Script> script( 1474 Handle<Script> script(
1477 Script::cast(thread_local_top_.pending_message_script_)); 1475 Script::cast(thread_local_top_.pending_message_script_));
1478 int start_pos = thread_local_top_.pending_message_start_pos_; 1476 int start_pos = message_obj->start_position();
1479 int end_pos = thread_local_top_.pending_message_end_pos_; 1477 int end_pos = message_obj->end_position();
1480 return MessageLocation(script, start_pos, end_pos); 1478 return MessageLocation(script, start_pos, end_pos);
1481 } 1479 }
1482 1480
1483 return MessageLocation(); 1481 return MessageLocation();
1484 } 1482 }
1485 1483
1486 1484
1487 bool Isolate::OptionalRescheduleException(bool is_bottom_call) { 1485 bool Isolate::OptionalRescheduleException(bool is_bottom_call) {
1488 DCHECK(has_pending_exception()); 1486 DCHECK(has_pending_exception());
1489 PropagatePendingExceptionToExternalTryCatch(); 1487 PropagatePendingExceptionToExternalTryCatch();
(...skipping 503 matching lines...) Expand 10 before | Expand all | Expand 10 after
1993 DCHECK(thread_local_top_.pending_message_script_->IsScript() || 1991 DCHECK(thread_local_top_.pending_message_script_->IsScript() ||
1994 thread_local_top_.pending_message_script_->IsTheHole()); 1992 thread_local_top_.pending_message_script_->IsTheHole());
1995 handler->can_continue_ = true; 1993 handler->can_continue_ = true;
1996 handler->has_terminated_ = false; 1994 handler->has_terminated_ = false;
1997 handler->exception_ = pending_exception(); 1995 handler->exception_ = pending_exception();
1998 // Propagate to the external try-catch only if we got an actual message. 1996 // Propagate to the external try-catch only if we got an actual message.
1999 if (thread_local_top_.pending_message_obj_->IsTheHole()) return true; 1997 if (thread_local_top_.pending_message_obj_->IsTheHole()) return true;
2000 1998
2001 handler->message_obj_ = thread_local_top_.pending_message_obj_; 1999 handler->message_obj_ = thread_local_top_.pending_message_obj_;
2002 handler->message_script_ = thread_local_top_.pending_message_script_; 2000 handler->message_script_ = thread_local_top_.pending_message_script_;
2003 handler->message_start_pos_ = thread_local_top_.pending_message_start_pos_;
2004 handler->message_end_pos_ = thread_local_top_.pending_message_end_pos_;
2005 } 2001 }
2006 return true; 2002 return true;
2007 } 2003 }
2008 2004
2009 2005
2010 void Isolate::InitializeLoggingAndCounters() { 2006 void Isolate::InitializeLoggingAndCounters() {
2011 if (logger_ == NULL) { 2007 if (logger_ == NULL) {
2012 logger_ = new Logger(this); 2008 logger_ = new Logger(this);
2013 } 2009 }
2014 if (counters_ == NULL) { 2010 if (counters_ == NULL) {
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
2654 if (prev_ && prev_->Intercept(flag)) return true; 2650 if (prev_ && prev_->Intercept(flag)) return true;
2655 // Then check whether this scope intercepts. 2651 // Then check whether this scope intercepts.
2656 if ((flag & intercept_mask_)) { 2652 if ((flag & intercept_mask_)) {
2657 intercepted_flags_ |= flag; 2653 intercepted_flags_ |= flag;
2658 return true; 2654 return true;
2659 } 2655 }
2660 return false; 2656 return false;
2661 } 2657 }
2662 2658
2663 } } // namespace v8::internal 2659 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/isolate.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698