Reviewers: titzer,

https://codereview.chromium.org/987353002/diff/1/src/isolate.cc
File src/isolate.cc (left):

https://codereview.chromium.org/987353002/diff/1/src/isolate.cc#oldcode1470
src/isolate.cc:1470: MessageLocation Isolate::GetMessageLocation() {
Please appreciate the fact that I can put UNREACHABLE() into this method
and still pass the entire test suite. That for sure instills confidence
in our test coverage.

Description:
Simplify and correctify pending message location handling.

This makes sure that the pending message location is only tracked by
the message object, as only this is saved for finally-blocks. The
location information is duplicated and becomes stale.

[email protected]
TEST=maeh, not so much.

Please review this at https://codereview.chromium.org/987353002/

Base URL: https://chromium.googlesource.com/v8/v8.git@master

Affected files (+8, -18 lines):
  M include/v8.h
  M src/api.cc
  M src/isolate.h
  M src/isolate.cc


Index: include/v8.h
diff --git a/include/v8.h b/include/v8.h
index 74b58bf34b99d812ac4a39cb464d06038598a108..29a42878bb1224c845522a0129a59b9cb1101529 100644
--- a/include/v8.h
+++ b/include/v8.h
@@ -6089,8 +6089,6 @@ class V8_EXPORT TryCatch {
   void* message_obj_;
   void* message_script_;
   void* js_stack_comparable_address_;
-  int message_start_pos_;
-  int message_end_pos_;
   bool is_verbose_ : 1;
   bool can_continue_ : 1;
   bool capture_message_ : 1;
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 746865767bbf37f1c436f1d09b3773ea11e7cad3..4ad0df29c621b8a85046bf2bdd81c542cb5654ea 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -2144,8 +2144,6 @@ void v8::TryCatch::ResetInternal() {
   exception_ = the_hole;
   message_obj_ = the_hole;
   message_script_ = the_hole;
-  message_start_pos_ = 0;
-  message_end_pos_ = 0;
 }


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 34e4d007f8ff73c771830b5375da56437e379790..23782cd1cfc1405557277a05976de7cf501d1a43 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -990,8 +990,6 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {

       thread_local_top()->pending_message_obj_ = *message_obj;
       thread_local_top()->pending_message_script_ = *location->script();
- thread_local_top()->pending_message_start_pos_ = location->start_pos();
-      thread_local_top()->pending_message_end_pos_ = location->end_pos();

       // If the abort-on-uncaught-exception flag is specified, abort on any
// exception not caught by JavaScript, even when an external handler is @@ -1168,8 +1166,6 @@ void Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) {
   DCHECK(script->IsScript() || script->IsTheHole());
   thread_local_top()->pending_message_obj_ = message;
   thread_local_top()->pending_message_script_ = script;
- thread_local_top()->pending_message_start_pos_ = handler->message_start_pos_;
-  thread_local_top()->pending_message_end_pos_ = handler->message_end_pos_;
 }


@@ -1448,13 +1444,13 @@ void Isolate::ReportPendingMessages() {
       thread_local_top_.has_pending_message_ = false;
       if (!thread_local_top_.pending_message_obj_->IsTheHole()) {
         HandleScope scope(this);
-        Handle<Object> message_obj(thread_local_top_.pending_message_obj_,
-                                   this);
+        Handle<JSMessageObject> message_obj(
+            JSMessageObject::cast(thread_local_top_.pending_message_obj_));
         if (!thread_local_top_.pending_message_script_->IsTheHole()) {
           Handle<Script> script(
               Script::cast(thread_local_top_.pending_message_script_));
-          int start_pos = thread_local_top_.pending_message_start_pos_;
-          int end_pos = thread_local_top_.pending_message_end_pos_;
+          int start_pos = message_obj->start_position();
+          int end_pos = message_obj->end_position();
           MessageLocation location(script, start_pos, end_pos);
           MessageHandler::ReportMessage(this, &location, message_obj);
         } else {
@@ -1473,10 +1469,12 @@ MessageLocation Isolate::GetMessageLocation() {
if (thread_local_top_.pending_exception_ != heap()->termination_exception() &&
       thread_local_top_.has_pending_message_ &&
       !thread_local_top_.pending_message_obj_->IsTheHole()) {
+    Handle<JSMessageObject> message_obj(
+        JSMessageObject::cast(thread_local_top_.pending_message_obj_));
     Handle<Script> script(
         Script::cast(thread_local_top_.pending_message_script_));
-    int start_pos = thread_local_top_.pending_message_start_pos_;
-    int end_pos = thread_local_top_.pending_message_end_pos_;
+    int start_pos = message_obj->start_position();
+    int end_pos = message_obj->end_position();
     return MessageLocation(script, start_pos, end_pos);
   }

@@ -2000,8 +1998,6 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {

     handler->message_obj_ = thread_local_top_.pending_message_obj_;
     handler->message_script_ = thread_local_top_.pending_message_script_;
- handler->message_start_pos_ = thread_local_top_.pending_message_start_pos_;
-    handler->message_end_pos_ = thread_local_top_.pending_message_end_pos_;
   }
   return true;
 }
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 3ddc82278c9a4e23c070be70b3b7ee8f75582b7c..3fc898959c163176c80d68275140eebd6c1822b8 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -286,8 +286,6 @@ class ThreadLocalTop BASE_EMBEDDED {
   bool rethrowing_message_;
   Object* pending_message_obj_;
   Object* pending_message_script_;
-  int pending_message_start_pos_;
-  int pending_message_end_pos_;

   // Use a separate value for scheduled exceptions to preserve the
   // invariants that hold about pending_exception.  We may want to


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to