Reviewers: Mads Ager,

Description:
Fix issue 54: internal field count on the global template is lost.


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

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

Affected files:
   M     src/api.cc
   M     test/cctest/test-api.cc


Index: test/cctest/test-api.cc
===================================================================
--- test/cctest/test-api.cc     (revision 958)
+++ test/cctest/test-api.cc     (working copy)
@@ -5535,3 +5535,15 @@
      CompileRun("for (var j = 0; j < 10; j++) RegExp('')");
    }
  }
+
+
+// This tests that internal field count set on the global template is
+// not lost when it is used to create a context.
+TEST(GlobalInternalFieldCountNotLost) {
+  v8::HandleScope scope;
+  v8::Local<v8::ObjectTemplate> global_tmpl = v8::ObjectTemplate::New();
+  global_tmpl->SetInternalFieldCount(1);
+  v8::Persistent<Context> context = Context::New(NULL, global_tmpl);
+  Context::Scope ctx_scope(context);
+  CHECK_EQ(1, context->Global()->InternalFieldCount());
+}
Index: src/api.cc
===================================================================
--- src/api.cc  (revision 958)
+++ src/api.cc  (working copy)
@@ -2229,8 +2229,10 @@

    // Make sure that the global_template has a constructor.
    if (!global_template.IsEmpty()) {
+    i::Handle<i::ObjectTemplateInfo> i_global_template(
+        Utils::OpenHandle(*global_template));
      i::Handle<i::FunctionTemplateInfo> constructor =
-        EnsureConstructor(Utils::OpenHandle(*global_template));
+        EnsureConstructor(i_global_template);

      // Create a fresh template for global proxy object.
      Local<ObjectTemplate> proxy_template = ObjectTemplate::New();
@@ -2243,6 +2245,10 @@
      proxy_constructor->set_prototype_template(
          *Utils::OpenHandle(*global_template));

+    // Migrate internal field count from global_template to proxy_template.
+    Utils::OpenHandle(*proxy_template)->set_internal_field_count(
+         i_global_template->internal_field_count());
+
      // Migrate security handlers from global_template to proxy_template.
      if (!constructor->access_check_info()->IsUndefined()) {
         proxy_constructor->set_access_check_info(



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

Reply via email to