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 <yusukesuzuki@chromium.org>.

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16737 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
This commit is contained in:
mstarzinger@chromium.org 2013-09-16 14:50:01 +00:00
parent bf345f022e
commit be8621a457
2 changed files with 10 additions and 2 deletions

View File

@ -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);

View File

@ -20584,6 +20584,15 @@ THREADED_TEST(FunctionNew) {
i::Isolate* i_isolate = reinterpret_cast<i::Isolate*>(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<Object> data2 = v8::Object::New();
function_new_expected_env = data2;
Local<Function> func2 = Function::New(isolate, FunctionNewCallback, data2);
CHECK(!func2->IsNull());
CHECK_NE(func, func2);
env->Global()->Set(v8_str("func2"), func2);
Local<Value> result2 = CompileRun("func2();");
CHECK_EQ(v8::Integer::New(17, isolate), result2);
}