Revision: 8885
Author:   [email protected]
Date:     Wed Aug 10 23:40:14 2011
Log:      Allows not API functions as inputs for CreationConext method.

Review URL: http://codereview.chromium.org/7552034
http://code.google.com/p/v8/source/detail?r=8885

Modified:
 /branches/bleeding_edge/src/api.cc
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/src/api.cc  Thu Aug  4 08:18:18 2011
+++ /branches/bleeding_edge/src/api.cc  Wed Aug 10 23:40:14 2011
@@ -3163,10 +3163,9 @@
   i::Object* constructor = object->map()->constructor();
   i::JSFunction* function;
   if (!constructor->IsJSFunction()) {
-    // API functions have null as a constructor,
+    // Functions have null as a constructor,
     // but any JSFunction knows its context immediately.
-    ASSERT(object->IsJSFunction() &&
-           i::JSFunction::cast(object)->shared()->IsApiFunction());
+    ASSERT(object->IsJSFunction());
     function = i::JSFunction::cast(object);
   } else {
     function = i::JSFunction::cast(constructor);
=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Wed Aug  3 04:12:46 2011
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Wed Aug 10 23:40:14 2011
@@ -14593,6 +14593,24 @@
   context2.Dispose();
   context3.Dispose();
 }
+
+
+THREADED_TEST(CreationContextOfJsFunction) {
+  HandleScope handle_scope;
+  Persistent<Context> context = Context::New();
+  InstallContextId(context, 1);
+
+  Local<Object> function;
+  {
+    Context::Scope scope(context);
+    function = CompileRun("function foo() {}; foo").As<Object>();
+  }
+
+  CHECK(function->CreationContext() == context);
+  CheckContextId(function, 1);
+
+  context.Dispose();
+}


 Handle<Value> HasOwnPropertyIndexedPropertyGetter(uint32_t index,

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

Reply via email to