From be8621a457ef09b6ad0d8f4c21955a3b10a6bad8 Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Mon, 16 Sep 2013 14:50:01 +0000 Subject: [PATCH] Don't lookup the cache for the result of Function::New Since isFunctionCached condition is wrong, we lookup the cache even if doNotCache is true. As a result, Function::New always returns null except for the first time. BUG=272579 R=dcarney@chromium.org, mstarzinger@chromium.org, yhirano@chromium.org Review URL: https://codereview.chromium.org/23513048 Patch from Yusuke Suzuki . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16737 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/apinatives.js | 1 - test/cctest/test-api.cc | 11 ++++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/apinatives.js b/src/apinatives.js index 5fb36c0..6431901 100644 --- a/src/apinatives.js +++ b/src/apinatives.js @@ -71,7 +71,6 @@ function InstantiateFunction(data, name) { (serialNumber in cache) && (cache[serialNumber] != kUninitialized); if (!isFunctionCached) { try { - cache[serialNumber] = null; var fun = %CreateApiFunction(data); if (name) %FunctionSetName(fun, name); var flags = %GetTemplateField(data, kApiFlagOffset); diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index f4e40cd..5496995 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -20584,6 +20584,15 @@ THREADED_TEST(FunctionNew) { i::Isolate* i_isolate = reinterpret_cast(isolate); i::Object* elm = i_isolate->native_context()->function_cache() ->GetElementNoExceptionThrown(i_isolate, serial_number); - CHECK(elm->IsNull()); + CHECK(elm->IsUndefined()); + // Verify that each Function::New creates a new function instance + Local data2 = v8::Object::New(); + function_new_expected_env = data2; + Local func2 = Function::New(isolate, FunctionNewCallback, data2); + CHECK(!func2->IsNull()); + CHECK_NE(func, func2); + env->Global()->Set(v8_str("func2"), func2); + Local result2 = CompileRun("func2();"); + CHECK_EQ(v8::Integer::New(17, isolate), result2); } -- 2.7.4