Simplify pending message script handling.
authormstarzinger <mstarzinger@chromium.org>
Wed, 11 Mar 2015 10:02:39 +0000 (03:02 -0700)
committerCommit bot <commit-bot@chromium.org>
Wed, 11 Mar 2015 10:02:48 +0000 (10:02 +0000)
This removes the separate tracking of the pending message script,
because that script is already stored in the message object and
duplicating it in the ThreadLocalTop makes it more brittle.

R=bmeurer@chromium.org

Review URL: https://codereview.chromium.org/995013005

Cr-Commit-Position: refs/heads/master@{#27127}

13 files changed:
include/v8.h
src/api.cc
src/arm/full-codegen-arm.cc
src/arm64/full-codegen-arm64.cc
src/assembler.cc
src/assembler.h
src/compiler/ast-graph-builder.cc
src/full-codegen.h
src/ia32/full-codegen-ia32.cc
src/isolate.cc
src/isolate.h
src/serialize.cc
src/x64/full-codegen-x64.cc

index aaebf51fb06dafa64d64a95624c90214781a32bd..fc8ff5a3ff3097dc7ccf3ae4fe1d82f4760a5555 100644 (file)
@@ -6098,7 +6098,6 @@ class V8_EXPORT TryCatch {
   v8::TryCatch* next_;
   void* exception_;
   void* message_obj_;
-  void* message_script_;
   void* js_stack_comparable_address_;
   bool is_verbose_ : 1;
   bool can_continue_ : 1;
index e7667ba006fd38a553f78265b0e40502fadaf4df..890fc1dc96dc75259e2edf42344fe1fc6bfa0691 100644 (file)
@@ -2136,7 +2136,6 @@ void v8::TryCatch::ResetInternal() {
   i::Object* the_hole = isolate_->heap()->the_hole_value();
   exception_ = the_hole;
   message_obj_ = the_hole;
-  message_script_ = the_hole;
 }
 
 
index b478d7f696eddc14fbbec32fcbacc310b8cb3bde..a551937ac573fbff912f553485e00e8dc85711cf 100644 (file)
@@ -5326,24 +5326,12 @@ void FullCodeGenerator::EnterFinallyBlock() {
   __ ldrb(r1, MemOperand(ip));
   __ SmiTag(r1);
   __ push(r1);
-
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ mov(ip, Operand(pending_message_script));
-  __ ldr(r1, MemOperand(ip));
-  __ push(r1);
 }
 
 
 void FullCodeGenerator::ExitFinallyBlock() {
   DCHECK(!result_register().is(r1));
   // Restore pending message from stack.
-  __ pop(r1);
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ mov(ip, Operand(pending_message_script));
-  __ str(r1, MemOperand(ip));
-
   __ pop(r1);
   __ SmiUntag(r1);
   ExternalReference has_pending_message =
index 9731f1b62640f12718022319d4e01384d2383fd4..a8f5ed554293af985db1328de7ee5f3e87b7d21f 100644 (file)
@@ -5348,12 +5348,6 @@ void FullCodeGenerator::EnterFinallyBlock() {
   __ SmiTag(x11);
 
   __ Push(x10, x11);
-
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ Mov(x10, pending_message_script);
-  __ Ldr(x10, MemOperand(x10));
-  __ Push(x10);
 }
 
 
@@ -5362,23 +5356,18 @@ void FullCodeGenerator::ExitFinallyBlock() {
   DCHECK(!result_register().is(x10));
 
   // Restore pending message from stack.
-  __ Pop(x10, x11, x12);
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ Mov(x13, pending_message_script);
-  __ Str(x10, MemOperand(x13));
-
-  __ SmiUntag(x11);
+  __ Pop(x10, x11);
+  __ SmiUntag(x10);
   ExternalReference has_pending_message =
       ExternalReference::address_of_has_pending_message(isolate());
   __ Mov(x13, has_pending_message);
   STATIC_ASSERT(sizeof(bool) == 1);   // NOLINT(runtime/sizeof)
-  __ Strb(x11, MemOperand(x13));
+  __ Strb(x10, MemOperand(x13));
 
   ExternalReference pending_message_obj =
       ExternalReference::address_of_pending_message_obj(isolate());
   __ Mov(x13, pending_message_obj);
-  __ Str(x12, MemOperand(x13));
+  __ Str(x11, MemOperand(x13));
 
   // Restore result register and cooked return address from the stack.
   __ Pop(x10, result_register());
index 2343616a77d26f95a9aa9d22b5fdcdba0d7c0458..d72105a447c6456d6e066c11ecaec40e9a9ad77a 100644 (file)
@@ -1273,12 +1273,6 @@ ExternalReference ExternalReference::address_of_has_pending_message(
 }
 
 
-ExternalReference ExternalReference::address_of_pending_message_script(
-    Isolate* isolate) {
-  return ExternalReference(isolate->pending_message_script_address());
-}
-
-
 ExternalReference ExternalReference::address_of_min_int() {
   return ExternalReference(reinterpret_cast<void*>(&double_constants.min_int));
 }
index b6351fae44d20f71c02b20804d4b760a28421326..9fdc7355df523999695a36fa9a682ebc462f67e2 100644 (file)
@@ -957,7 +957,6 @@ class ExternalReference BASE_EMBEDDED {
   static ExternalReference scheduled_exception_address(Isolate* isolate);
   static ExternalReference address_of_pending_message_obj(Isolate* isolate);
   static ExternalReference address_of_has_pending_message(Isolate* isolate);
-  static ExternalReference address_of_pending_message_script(Isolate* isolate);
 
   // Static variables containing common double constants.
   static ExternalReference address_of_min_int();
index 5e5721e9db92dca7c7107a092eed6175e178027e..97353b522eaf29124fd70b67ab5e4c17466cdae8 100644 (file)
@@ -1266,8 +1266,6 @@ void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
       ExternalReference::address_of_pending_message_obj(isolate());
   ExternalReference message_present =
       ExternalReference::address_of_has_pending_message(isolate());
-  ExternalReference message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
 
   // We keep a record of all paths that enter the finally-block to be able to
   // dispatch to the correct continuation point after the statements in the
@@ -1305,7 +1303,6 @@ void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
   environment()->Push(result);
   environment()->Push(BuildLoadExternal(message_object, kMachAnyTagged));
   environment()->Push(BuildLoadExternal(message_present, kMachBool));
-  environment()->Push(BuildLoadExternal(message_script, kMachAnyTagged));
 
   // Evaluate the finally-block.
   Visit(stmt->finally_block());
@@ -1313,7 +1310,6 @@ void AstGraphBuilder::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
 
   // The result value, dispatch token and message is restored from the operand
   // stack (this is in sync with FullCodeGenerator::ExitFinallyBlock).
-  BuildStoreExternal(message_script, kMachAnyTagged, environment()->Pop());
   BuildStoreExternal(message_present, kMachBool, environment()->Pop());
   BuildStoreExternal(message_object, kMachAnyTagged, environment()->Pop());
   result = environment()->Pop();
index e78535fabd7893b9196fa25e62778534f5b93d45..69234870d48312f49d7385695eead9ab9ed58328 100644 (file)
@@ -249,7 +249,7 @@ class FullCodeGenerator: public AstVisitor {
   // The finally block of a try/finally statement.
   class Finally : public NestedStatement {
    public:
-    static const int kElementCount = 5;
+    static const int kElementCount = 4;
 
     explicit Finally(FullCodeGenerator* codegen) : NestedStatement(codegen) { }
     virtual ~Finally() {}
index 3265bf45284a45ed68e1513b418cf0a10f88c9f9..18dfa0c302fe9739e7a4ef827284d1703f6781eb 100644 (file)
@@ -5254,22 +5254,12 @@ void FullCodeGenerator::EnterFinallyBlock() {
   __ mov(edx, Operand::StaticVariable(has_pending_message));
   __ SmiTag(edx);
   __ push(edx);
-
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ mov(edx, Operand::StaticVariable(pending_message_script));
-  __ push(edx);
 }
 
 
 void FullCodeGenerator::ExitFinallyBlock() {
   DCHECK(!result_register().is(edx));
   // Restore pending message from stack.
-  __ pop(edx);
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ mov(Operand::StaticVariable(pending_message_script), edx);
-
   __ pop(edx);
   __ SmiUntag(edx);
   ExternalReference has_pending_message =
index 45fa140b44bc126f9471398d01c0914914ca2f5e..c704e06338b83a0a91d9c48ddc33d5266fc258c9 100644 (file)
@@ -91,7 +91,6 @@ void ThreadLocalTop::InitializeInternal() {
   has_pending_message_ = false;
   rethrowing_message_ = false;
   pending_message_obj_ = NULL;
-  pending_message_script_ = NULL;
   scheduled_exception_ = NULL;
 }
 
@@ -190,7 +189,6 @@ void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
   // Visit the roots from the top for a given thread.
   v->VisitPointer(&thread->pending_exception_);
   v->VisitPointer(&(thread->pending_message_obj_));
-  v->VisitPointer(bit_cast<Object**>(&(thread->pending_message_script_)));
   v->VisitPointer(bit_cast<Object**>(&(thread->context_)));
   v->VisitPointer(&thread->scheduled_exception_);
 
@@ -199,7 +197,6 @@ void Isolate::Iterate(ObjectVisitor* v, ThreadLocalTop* thread) {
        block = block->next_) {
     v->VisitPointer(bit_cast<Object**>(&(block->exception_)));
     v->VisitPointer(bit_cast<Object**>(&(block->message_obj_)));
-    v->VisitPointer(bit_cast<Object**>(&(block->message_script_)));
   }
 
   // Iterate over pointers on native execution stack.
@@ -989,7 +986,6 @@ Object* Isolate::Throw(Object* exception, MessageLocation* location) {
       Handle<Object> message_obj = CreateMessage(exception_handle, location);
 
       thread_local_top()->pending_message_obj_ = *message_obj;
-      thread_local_top()->pending_message_script_ = *location->script();
 
       // If the abort-on-uncaught-exception flag is specified, abort on any
       // exception not caught by JavaScript, even when an external handler is
@@ -1161,11 +1157,8 @@ void Isolate::RestorePendingMessageFromTryCatch(v8::TryCatch* handler) {
   DCHECK(handler->rethrow_);
   DCHECK(handler->capture_message_);
   Object* message = reinterpret_cast<Object*>(handler->message_obj_);
-  Object* script = reinterpret_cast<Object*>(handler->message_script_);
   DCHECK(message->IsJSMessageObject() || message->IsTheHole());
-  DCHECK(script->IsScript() || script->IsTheHole());
   thread_local_top()->pending_message_obj_ = message;
-  thread_local_top()->pending_message_script_ = script;
 }
 
 
@@ -1446,16 +1439,12 @@ void Isolate::ReportPendingMessages() {
         HandleScope scope(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 = 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 {
-          MessageHandler::ReportMessage(this, NULL, message_obj);
-        }
+        Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script()));
+        Handle<Script> script(Script::cast(script_wrapper->value()));
+        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);
       }
     }
   }
@@ -1471,8 +1460,8 @@ MessageLocation Isolate::GetMessageLocation() {
       !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_));
+    Handle<JSValue> script_wrapper(JSValue::cast(message_obj->script()));
+    Handle<Script> script(Script::cast(script_wrapper->value()));
     int start_pos = message_obj->start_position();
     int end_pos = message_obj->end_position();
     return MessageLocation(script, start_pos, end_pos);
@@ -1988,8 +1977,6 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
     v8::TryCatch* handler = try_catch_handler();
     DCHECK(thread_local_top_.pending_message_obj_->IsJSMessageObject() ||
            thread_local_top_.pending_message_obj_->IsTheHole());
-    DCHECK(thread_local_top_.pending_message_script_->IsScript() ||
-           thread_local_top_.pending_message_script_->IsTheHole());
     handler->can_continue_ = true;
     handler->has_terminated_ = false;
     handler->exception_ = pending_exception();
@@ -1997,7 +1984,6 @@ bool Isolate::PropagatePendingExceptionToExternalTryCatch() {
     if (thread_local_top_.pending_message_obj_->IsTheHole()) return true;
 
     handler->message_obj_ = thread_local_top_.pending_message_obj_;
-    handler->message_script_ = thread_local_top_.pending_message_script_;
   }
   return true;
 }
index 3fc898959c163176c80d68275140eebd6c1822b8..ab62d371dce328088b0238970aa1a5e7c5f813cb 100644 (file)
@@ -285,7 +285,6 @@ class ThreadLocalTop BASE_EMBEDDED {
   bool has_pending_message_;
   bool rethrowing_message_;
   Object* pending_message_obj_;
-  Object* pending_message_script_;
 
   // Use a separate value for scheduled exceptions to preserve the
   // invariants that hold about pending_exception.  We may want to
@@ -608,7 +607,6 @@ class Isolate {
   void clear_pending_message() {
     thread_local_top_.has_pending_message_ = false;
     thread_local_top_.pending_message_obj_ = heap_.the_hole_value();
-    thread_local_top_.pending_message_script_ = heap_.the_hole_value();
   }
   v8::TryCatch* try_catch_handler() {
     return thread_local_top_.try_catch_handler();
@@ -632,11 +630,6 @@ class Isolate {
     return reinterpret_cast<Address>(&thread_local_top_.has_pending_message_);
   }
 
-  Address pending_message_script_address() {
-    return reinterpret_cast<Address>(
-        &thread_local_top_.pending_message_script_);
-  }
-
   Object* scheduled_exception() {
     DCHECK(has_scheduled_exception());
     DCHECK(!thread_local_top_.scheduled_exception_->IsException());
index c9e0413d76b0e633fe893d0bec91b96c725ef14b..9146ca7e204b804ccd5be5af30589ba2204a2109 100644 (file)
@@ -104,8 +104,6 @@ ExternalReferenceTable::ExternalReferenceTable(Isolate* isolate) {
       "address_of_pending_message_obj");
   Add(ExternalReference::address_of_has_pending_message(isolate).address(),
       "address_of_has_pending_message");
-  Add(ExternalReference::address_of_pending_message_script(isolate).address(),
-      "pending_message_script");
   Add(ExternalReference::get_make_code_young_function(isolate).address(),
       "Code::MakeCodeYoung");
   Add(ExternalReference::cpu_features().address(), "cpu_features");
index 2c1146c90a0999f673f9bc26e70abb21d1b96e6c..d4f062f2d06569828ae99583445f96e1451aa6bb 100644 (file)
@@ -5272,11 +5272,6 @@ void FullCodeGenerator::EnterFinallyBlock() {
   __ Load(rdx, has_pending_message);
   __ Integer32ToSmi(rdx, rdx);
   __ Push(rdx);
-
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ Load(rdx, pending_message_script);
-  __ Push(rdx);
 }
 
 
@@ -5284,11 +5279,6 @@ void FullCodeGenerator::ExitFinallyBlock() {
   DCHECK(!result_register().is(rdx));
   DCHECK(!result_register().is(rcx));
   // Restore pending message from stack.
-  __ Pop(rdx);
-  ExternalReference pending_message_script =
-      ExternalReference::address_of_pending_message_script(isolate());
-  __ Store(pending_message_script, rdx);
-
   __ Pop(rdx);
   __ SmiToInteger32(rdx, rdx);
   ExternalReference has_pending_message =