From 48e6274cc38f3f864098490d4a9816c35209aa04 Mon Sep 17 00:00:00 2001 From: "antonm@chromium.org" Date: Thu, 11 Aug 2011 06:40:14 +0000 Subject: [PATCH] Allows not API functions as inputs for CreationConext method. Review URL: http://codereview.chromium.org/7552034 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@8885 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/api.cc | 5 ++--- test/cctest/test-api.cc | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/api.cc b/src/api.cc index 7355cd6..402f220 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); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index c694ae3..d7ba7d7 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::New(); + InstallContextId(context, 1); + + Local function; + { + Context::Scope scope(context); + function = CompileRun("function foo() {}; foo").As(); + } + + CHECK(function->CreationContext() == context); + CheckContextId(function, 1); + + context.Dispose(); +} + + Handle HasOwnPropertyIndexedPropertyGetter(uint32_t index, const AccessorInfo& info) { if (index == 42) return v8_str("yes"); -- 2.7.4