Revision: 2696
Author: [email protected]
Date: Mon Aug 17 03:19:00 2009
Log: RegExp tweaks
Fixed bug where regexps were not callable across contexts since the
callable test used object identity on the regexp constructor.  Changed
typeof RegExp from 'object' to 'function' for compatibility.

Review URL: http://codereview.chromium.org/171039

http://code.google.com/p/v8/source/detail?r=2696

Modified:
  /branches/bleeding_edge/src/execution.cc
  /branches/bleeding_edge/src/runtime.cc
  /branches/bleeding_edge/test/mozilla/mozilla.status

=======================================
--- /branches/bleeding_edge/src/execution.cc    Fri Aug  7 00:15:16 2009
+++ /branches/bleeding_edge/src/execution.cc    Mon Aug 17 03:19:00 2009
@@ -174,12 +174,7 @@

    // Regular expressions can be called as functions in both Firefox
    // and Safari so we allow it too.
-  bool is_regexp =
-      object->IsHeapObject() &&
-      (HeapObject::cast(*object)->map()->constructor() ==
-       *Top::regexp_function());
-
-  if (is_regexp) {
+  if (object->IsJSRegExp()) {
      Handle<String> exec = Factory::exec_symbol();
      return Handle<Object>(object->GetProperty(*exec));
    }
=======================================
--- /branches/bleeding_edge/src/runtime.cc      Thu Aug 13 05:35:59 2009
+++ /branches/bleeding_edge/src/runtime.cc      Mon Aug 17 03:19:00 2009
@@ -3099,7 +3099,7 @@
        }
        ASSERT(heap_obj->IsUndefined());
        return Heap::undefined_symbol();
-    case JS_FUNCTION_TYPE:
+    case JS_FUNCTION_TYPE: case JS_REGEXP_TYPE:
        return Heap::function_symbol();
      default:
        // For any kind of object not handled above, the spec rule for
=======================================
--- /branches/bleeding_edge/test/mozilla/mozilla.status Fri Aug 14 04:24:32  
2009
+++ /branches/bleeding_edge/test/mozilla/mozilla.status Mon Aug 17 03:19:00  
2009
@@ -278,6 +278,11 @@
  js1_2/regexp/endLine: FAIL_OK


+# To be compatible with safari typeof a regexp yields 'function';
+# in firefox it yields 'object'.
+js1_2/function/regexparg-1: FAIL_OK
+
+
  # Date trouble?
  js1_5/Date/regress-301738-02: FAIL_OK


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

Reply via email to