Author: davemo...@chromium.org
Date: Wed May  6 11:30:37 2009
New Revision: 1887

Modified:
    branches/bleeding_edge/include/v8.h
    branches/bleeding_edge/src/api.cc

Log:
Make check in GetExternalString a runtime check instead of ASSERT.
This will allow us to remove the separate call to IsExternal() from our
chrome client code, speeding up the combination.

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

Modified: branches/bleeding_edge/include/v8.h
==============================================================================
--- branches/bleeding_edge/include/v8.h (original)
+++ branches/bleeding_edge/include/v8.h Wed May  6 11:30:37 2009
@@ -827,14 +827,14 @@
    };

    /**
-   * Get the ExternalStringResource for an external string.  Only
-   * valid if IsExternal() returns true.
+   * Get the ExternalStringResource for an external string.  Returns
+   * NULL if IsExternal() doesn't return true.
     */
    ExternalStringResource* GetExternalStringResource() const;

    /**
     * Get the ExternalAsciiStringResource for an external ascii string.
-   * Only valid if IsExternalAscii() returns true.
+   * Returns NULL if IsExternalAscii() doesn't return true.
     */
    ExternalAsciiStringResource* GetExternalAsciiStringResource() const;


Modified: branches/bleeding_edge/src/api.cc
==============================================================================
--- branches/bleeding_edge/src/api.cc   (original)
+++ branches/bleeding_edge/src/api.cc   Wed May  6 11:30:37 2009
@@ -2355,9 +2355,12 @@
  v8::String::GetExternalStringResource() const {
    EnsureInitialized("v8::String::GetExternalStringResource()");
    i::Handle<i::String> str = Utils::OpenHandle(this);
-  ASSERT(str->IsExternalTwoByteString());
-  void* resource =  
i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
-  return reinterpret_cast<ExternalStringResource*>(resource);
+  if (i::StringShape(*str).IsExternalTwoByte()) {
+    void* resource =  
i::Handle<i::ExternalTwoByteString>::cast(str)->resource();
+    return reinterpret_cast<ExternalStringResource*>(resource);
+  } else {
+    return NULL;
+  }
  }


@@ -2365,9 +2368,12 @@
        v8::String::GetExternalAsciiStringResource() const {
    EnsureInitialized("v8::String::GetExternalAsciiStringResource()");
    i::Handle<i::String> str = Utils::OpenHandle(this);
-  ASSERT(str->IsExternalAsciiString());
-  void* resource =  
i::Handle<i::ExternalAsciiString>::cast(str)->resource();
-  return reinterpret_cast<ExternalAsciiStringResource*>(resource);
+  if (i::StringShape(*str).IsExternalAscii()) {
+    void* resource =  
i::Handle<i::ExternalAsciiString>::cast(str)->resource();
+    return reinterpret_cast<ExternalAsciiStringResource*>(resource);
+  } else {
+    return NULL;
+  }
  }



--~--~---------~--~----~------------~-------~--~----~
v8-dev mailing list
v8-dev@googlegroups.com
http://groups.google.com/group/v8-dev
-~----------~----~----~----~------~----~------~--~---

Reply via email to