Changes to the V8 debugger support which otherwise caused problems with Chrome.
authorsgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 19 Jan 2009 15:21:41 +0000 (15:21 +0000)
committersgjesse@chromium.org <sgjesse@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Mon, 19 Jan 2009 15:21:41 +0000 (15:21 +0000)
Added quoting of the name of the ref property using {"ref":1} instead of {ref:1}. The Chrome C++ JSON parser implementation requires quoted property names.

Changed the JSON format for non finite numbers. The previous formatting using NaN, Infinite and -Infinite caused the Chrome C++ JSON parser implementation to fail. Values "NaN", "Infinite" and "-Infinite" (incuding quotes) are now used.

Reverted changes to DebugLookupResultValue (runtime.cc) from http://codereview.chromium.org/17377. The change caused callback into Chrome with the current V8 context expected to have a DOM Window global object. This is not the case when the debugger context is the active context. This causes properties from interceptors and accessors to be reported as undefined in the debugger.
Review URL: http://codereview.chromium.org/18194

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@1101 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/mirror-delay.js
src/runtime.cc
test/cctest/test-debug.cc
test/mjsunit/mirror-object.js

index f087f68..fe6fb9c 100644 (file)
@@ -1660,7 +1660,7 @@ JSONProtocolSerializer.prototype.serialize_ = function(mirror, reference,
   // mirror to the referenced mirrors.
   if (reference && mirror.isValue()) {
     this.add_(mirror);
-    return '{ref:' + mirror.handle() + '}';
+    return '{"ref":' + mirror.handle() + '}';
   }
   
   // Collect the JSON property/value pairs in an array.
@@ -1922,7 +1922,26 @@ function BooleanToJSON_(value) {
 }
 
 
+/**
+ * Convert a number to a JSON string value. For all finite numbers the number
+ * literal representation is used. For non finite numbers NaN, Infinite and
+ * -Infinite the string representation "NaN", "Infinite" or "-Infinite"
+ * (including the quotes) is returned.
+ *
+ * @param {number} value The number value to convert to a JSON value
+ * @returns {String} JSON value
+ */
 function NumberToJSON_(value) {
+  if (isNaN(value)) {
+    return '"NaN"';
+  }
+  if (!isFinite(value)) {
+    if (value > 0) {
+      return '"Infinity"';
+    } else {
+      return '"-Infinity"';
+    }
+  }
   return String(value); 
 }
 
index 36fae9d..fd36724 100644 (file)
@@ -4536,32 +4536,49 @@ static Object* Runtime_Break(Arguments args) {
 }
 
 
-static Object* DebugLookupResultValue(Object* obj, String* name,
-                                      LookupResult* result,
+static Object* DebugLookupResultValue(Object* receiver, LookupResult* result,
                                       bool* caught_exception) {
+  Object* value;
   switch (result->type()) {
-    case NORMAL:
+    case NORMAL: {
+      Dictionary* dict =
+          JSObject::cast(result->holder())->property_dictionary();
+      value = dict->ValueAt(result->GetDictionaryEntry());
+      if (value->IsTheHole()) {
+        return Heap::undefined_value();
+      }
+      return value;
+    }
     case FIELD:
+      value =
+          JSObject::cast(
+              result->holder())->FastPropertyAt(result->GetFieldIndex());
+      if (value->IsTheHole()) {
+        return Heap::undefined_value();
+      }
+      return value;
     case CONSTANT_FUNCTION:
-      return obj->GetProperty(name);
+      return result->GetConstantFunction();
     case CALLBACKS: {
-      // Get the property value. If there is an exception it must be thrown from
-      // a JavaScript getter.
-      Object* value;
-      value = obj->GetProperty(name);
-      if (value->IsException()) {
-        if (caught_exception != NULL) {
-          *caught_exception = true;
+      Object* structure = result->GetCallbackObject();
+      if (structure->IsProxy()) {
+        AccessorDescriptor* callback =
+            reinterpret_cast<AccessorDescriptor*>(
+                Proxy::cast(structure)->proxy());
+        value = (callback->getter)(receiver, callback->data);
+        if (value->IsFailure()) {
+          value = Top::pending_exception();
+          Top::clear_pending_exception();
+          if (caught_exception != NULL) {
+            *caught_exception = true;
+          }
         }
-        value = Top::pending_exception();
-        Top::optional_reschedule_exception(true);
+        return value;
+      } else {
+        return Heap::undefined_value();
       }
-      ASSERT(!Top::has_pending_exception());
-      ASSERT(!Top::external_caught_exception());
-      return value;
     }
     case INTERCEPTOR:
-      return obj->GetProperty(name);
     case MAP_TRANSITION:
     case CONSTANT_TRANSITION:
     case NULL_DESCRIPTOR:
@@ -4609,7 +4626,7 @@ static Object* Runtime_DebugGetPropertyDetails(Arguments args) {
   obj->LocalLookup(*name, &result);
   if (result.IsProperty()) {
     bool caught_exception = false;
-    Handle<Object> value(DebugLookupResultValue(*obj, *name, &result,
+    Handle<Object> value(DebugLookupResultValue(*obj, &result,
                                                 &caught_exception));
     // If the callback object is a fixed array then it contains JavaScript
     // getter and/or setter.
@@ -4643,7 +4660,7 @@ static Object* Runtime_DebugGetProperty(Arguments args) {
   LookupResult result;
   obj->Lookup(*name, &result);
   if (result.IsProperty()) {
-    return DebugLookupResultValue(*obj, *name, &result, NULL);
+    return DebugLookupResultValue(*obj, &result, NULL);
   }
   return Heap::undefined_value();
 }
index 816972b..cd85b8f 100644 (file)
@@ -2746,22 +2746,6 @@ TEST(InterceptorPropertyMirror) {
 
   source = "both_values[4].name() == 10";
   CHECK(CompileRun(source)->BooleanValue());
-
-  // Check the property values.
-  source = "both_values[0].value().value() == 'AA'";
-  CHECK(CompileRun(source)->BooleanValue());
-
-  source = "both_values[1].value().value() == 'BB'";
-  CHECK(CompileRun(source)->BooleanValue());
-
-  source = "both_values[2].value().value() == 'CC'";
-  CHECK(CompileRun(source)->BooleanValue());
-
-  source = "both_values[3].value().value() == 2";
-  CHECK(CompileRun(source)->BooleanValue());
-
-  source = "both_values[4].value().value() == 11";
-  CHECK(CompileRun(source)->BooleanValue());
 }
 
 
index b9b0e1a..ec5afa3 100644 (file)
@@ -193,8 +193,6 @@ assertEquals(debug.PropertyType.Callbacks, mirror.property('a').propertyType());
 assertEquals('function', mirror.property('a').getter().type());
 assertEquals('undefined', mirror.property('a').setter().type());
 assertEquals('function (){return \'a\';}', mirror.property('a').getter().source());
-assertEquals('a', mirror.property('a').value().value());
-assertFalse(mirror.property('a').isException());
 // b has setter but no getter.
 assertFalse(mirror.property('b').hasGetter());
 assertTrue(mirror.property('b').hasSetter());
@@ -211,8 +209,6 @@ assertEquals('function', mirror.property('c').getter().type());
 assertEquals('function', mirror.property('c').setter().type());
 assertEquals('function (){throw \'c\';}', mirror.property('c').getter().source());
 assertEquals('function (){throw \'c\';}', mirror.property('c').setter().source());
-assertEquals('c', mirror.property('c').value().value());
-assertTrue(mirror.property('c').isException());
 
 // Test objects with native accessors.
 mirror = debug.MakeMirror(new String('abc'));