Reviewers: danno,

Description:
Allows not API functions as inputs for CreationConext method.


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

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

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


Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 7355cd61c57f20a3ac0801e83ab288a66d7e3ef3..402f22055c64919ad060ec28b333cfad311aa55e 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -3163,10 +3163,9 @@ static i::Context* GetCreationContext(i::JSObject* object) {
   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);
Index: test/cctest/test-api.cc
diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc
index c694ae38ad7f1f0a24e980a129360b186da3ecb6..d7ba7d7c7d57723959a0dde244778ff116e141ec 100644
--- a/test/cctest/test-api.cc
+++ b/test/cctest/test-api.cc
@@ -14595,6 +14595,24 @@ THREADED_TEST(CreationContext) {
 }


+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,
const AccessorInfo& info) {
   if (index == 42) return v8_str("yes");


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

Reply via email to