Reviewers: Yang,

Message:
PTAL.

Description:
Push stacktrace and die if the receiver is of unknown type.


Please review this at https://chromiumcodereview.appspot.com/10917086/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/isolate.h
  M src/isolate.cc
  M src/objects.cc


Index: src/isolate.cc
diff --git a/src/isolate.cc b/src/isolate.cc
index 7d31029a96da23db975c40909390806eefa33d86..e941d933a6b17abe95ba926f07dac485d1eaeb52 100644
--- a/src/isolate.cc
+++ b/src/isolate.cc
@@ -535,6 +535,23 @@ Handle<String> Isolate::StackTraceString() {
 }


+void Isolate::PushStackTraceAndDie(unsigned int magic,
+                                   Object* object,
+                                   Map* map,
+                                   unsigned int magic2) {
+  const int kMaxStackTraceSize = 8192;
+  Handle<String> trace = StackTraceString();
+  char buffer[kMaxStackTraceSize];
+  int length = Min(kMaxStackTraceSize, trace->length());
+  String::WriteToFlat(*trace, buffer, 0, length - 1);
+  OS::PrintError("Stacktrace (%x-%x) %p %p: %s\n",
+                 magic, magic2,
+                 static_cast<void*>(object), static_cast<void*>(map),
+                 buffer);
+  OS::Abort();
+}
+
+
void Isolate::CaptureAndSetCurrentStackTraceFor(Handle<JSObject> error_object) {
   if (capture_stack_trace_for_uncaught_exceptions_) {
     // Capture stack trace for a detailed exception message.
Index: src/isolate.h
diff --git a/src/isolate.h b/src/isolate.h
index 93b9fb3361dacec621b96b9912b9bb66b4c8a008..799a857e69b5a1c6e190e16249e290df848d996d 100644
--- a/src/isolate.h
+++ b/src/isolate.h
@@ -707,6 +707,10 @@ class Isolate {
   void PrintStack(StringStream* accumulator);
   void PrintStack();
   Handle<String> StackTraceString();
+  void PushStackTraceAndDie(unsigned int magic,
+                            Object* object,
+                            Map* map,
+                            unsigned int magic2);
   Handle<JSArray> CaptureCurrentStackTrace(
       int frame_limit,
       StackTrace::StackTraceOptions options);
Index: src/objects.cc
diff --git a/src/objects.cc b/src/objects.cc
index 09f6947aeb5d29d620d4c2668b648b073c811572..e3c40fdfe12990aa7bc9426626e10f24da181c3a 100644
--- a/src/objects.cc
+++ b/src/objects.cc
@@ -141,6 +141,9 @@ void Object::Lookup(String* name, LookupResult* result) {
       holder = native_context->string_function()->instance_prototype();
     } else if (IsBoolean()) {
       holder = native_context->boolean_function()->instance_prototype();
+    } else {
+      Isolate::Current()->PushStackTraceAndDie(
+          0xDEAD0000, this, JSReceiver::cast(this)->map(), 0xDEAD0001);
     }
   }
   ASSERT(holder != NULL);  // Cannot handle null or undefined.


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

Reply via email to