Author: [EMAIL PROTECTED]
Date: Wed Sep 10 07:54:15 2008
New Revision: 259

Removed:
     
changes/[EMAIL PROTECTED]/reenable-most-message-capturing/
Modified:
    branches/bleeding_edge/include/v8.h
    branches/bleeding_edge/src/api.cc
    branches/bleeding_edge/src/execution.cc
    branches/bleeding_edge/src/top.cc
    branches/bleeding_edge/test/cctest/test-api.cc

Log:
Added option for TryCatches to not capture the message object on
exceptions.

It turned out that the stack overflow fix from before had disabled
message storing in another test.  Previously, stack overflows would
actually cause a message object to start being created but cause
another exception which would not be reported and that's what stopped
the infinite regress.  This change resores that behavior.



Modified: branches/bleeding_edge/include/v8.h
==============================================================================
--- branches/bleeding_edge/include/v8.h (original)
+++ branches/bleeding_edge/include/v8.h Wed Sep 10 07:54:15 2008
@@ -1993,11 +1993,19 @@
     */
    void SetVerbose(bool value);

+  /**
+   * Set whether or not this TryCatch should capture a Message object
+   * which holds source information about where the exception
+   * occurred.  True by default.
+   */
+  void SetCaptureMessage(bool value);
+
   public:
    TryCatch* next_;
    void* exception_;
    void* message_;
    bool is_verbose_;
+  bool capture_message_;
  };



Modified: branches/bleeding_edge/src/api.cc
==============================================================================
--- branches/bleeding_edge/src/api.cc   (original)
+++ branches/bleeding_edge/src/api.cc   Wed Sep 10 07:54:15 2008
@@ -1082,7 +1082,8 @@
      : next_(i::Top::try_catch_handler()),
        exception_(i::Heap::the_hole_value()),
        message_(i::Smi::FromInt(0)),
-      is_verbose_(false) {
+      is_verbose_(false),
+      capture_message_(true) {
    i::Top::RegisterTryCatchHandler(this);
  }

@@ -1126,6 +1127,11 @@

  void v8::TryCatch::SetVerbose(bool value) {
    is_verbose_ = value;
+}
+
+
+void v8::TryCatch::SetCaptureMessage(bool value) {
+  capture_message_ = value;
  }



Modified: branches/bleeding_edge/src/execution.cc
==============================================================================
--- branches/bleeding_edge/src/execution.cc     (original)
+++ branches/bleeding_edge/src/execution.cc     Wed Sep 10 07:54:15 2008
@@ -130,9 +130,12 @@
                                    Object*** args,
                                    bool* caught_exception) {
    // Enter a try-block while executing the JavaScript code. To avoid
-  // duplicate error printing it must be non-verbose.
+  // duplicate error printing it must be non-verbose.  Also, to avoid
+  // creating message objects during stack overflow we shouldn't
+  // capture messages.
    v8::TryCatch catcher;
    catcher.SetVerbose(false);
+  catcher.SetCaptureMessage(false);

    Handle<Object> result = Invoke(false, func, receiver, argc, args,
                                   caught_exception);

Modified: branches/bleeding_edge/src/top.cc
==============================================================================
--- branches/bleeding_edge/src/top.cc   (original)
+++ branches/bleeding_edge/src/top.cc   Wed Sep 10 07:54:15 2008
@@ -770,7 +770,9 @@

    Handle<Object> message_obj;
    MessageLocation potential_computed_location;
-  if (report_exception) {
+  bool try_catch_needs_message =
+    is_caught_externally &&  
thread_local_.try_catch_handler_->capture_message_;
+  if (report_exception || try_catch_needs_message) {
      if (location == NULL) {
        // If no location was specified we use a computed one instead
        ComputeLocation(&potential_computed_location);

Modified: branches/bleeding_edge/test/cctest/test-api.cc
==============================================================================
--- branches/bleeding_edge/test/cctest/test-api.cc      (original)
+++ branches/bleeding_edge/test/cctest/test-api.cc      Wed Sep 10 07:54:15 2008
@@ -4845,6 +4845,21 @@
  }


+THREADED_TEST(CatchStackOverflow) {
+  v8::HandleScope scope;
+  LocalContext context;
+  v8::TryCatch try_catch;
+  v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(
+    "function f() {"
+    "  return f();"
+    "}"
+    ""
+    "f();"));
+  v8::Handle<v8::Value> result = script->Run();
+  CHECK(result.IsEmpty());
+}
+
+
  THREADED_TEST(TryCatchSourceInfo) {
    v8::HandleScope scope;
    LocalContext context;

--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to