Reviewers: Mads Ager,

Description:
Do not cache functions until we know they are fully constructed.

Please review this at http://codereview.chromium.org/17354

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

Affected files:
   M     src/apinatives.js


Index: src/apinatives.js
===================================================================
--- src/apinatives.js   (revision 1050)
+++ src/apinatives.js   (working copy)
@@ -60,11 +60,13 @@

  function InstantiateFunction(data, name) {
    var serialNumber = %GetTemplateField(data, kApiSerialNumberOffset);
-  if (!(serialNumber in kApiFunctionCache)) {
+  var functionIsCached =
+    serialNumber in kApiFunctionCache &&
+    kApiFunctionCache[serialNumber] != null;
+  if (!functionIsCached) {
      kApiFunctionCache[serialNumber] = null;
      var fun = %CreateApiFunction(data);
      if (name) %FunctionSetName(fun, name);
-    kApiFunctionCache[serialNumber] = fun;
      var prototype = %GetTemplateField(data, kApiPrototypeTemplateOffset);
      fun.prototype = prototype ? Instantiate(prototype) : {};
      %SetProperty(fun.prototype, "constructor", fun, DONT_ENUM);
@@ -74,6 +76,7 @@
        fun.prototype.__proto__ = parent_fun.prototype;
      }
      ConfigureTemplateInstance(fun, data);
+    kApiFunctionCache[serialNumber] = fun;
    }
    return kApiFunctionCache[serialNumber];
  }



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

Reply via email to