From: dcarney@chromium.org Date: Mon, 9 Sep 2013 07:16:24 +0000 (+0000) Subject: revert 16584 for breaking build X-Git-Tag: upstream/4.7.83~12617 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5b0a2816048f48d810eae74ff7effd7e7b0a4ddf;p=platform%2Fupstream%2Fv8.git revert 16584 for breaking build TBR=mstarzinger@chromium.org BUG= Review URL: https://codereview.chromium.org/23680014 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16585 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/include/v8.h b/include/v8.h index 2fce3ab..be838c2 100644 --- a/include/v8.h +++ b/include/v8.h @@ -2361,23 +2361,11 @@ class V8_EXPORT Array : public Object { }; -typedef void (*FunctionCallback)(const FunctionCallbackInfo& info); - - /** * A JavaScript function object (ECMA-262, 15.3). */ class V8_EXPORT Function : public Object { public: - /** - * Create a function in the current execution context - * for a given FunctionCallback. - */ - static Local New(Isolate* isolate, - FunctionCallback callback, - Local data = Local(), - int length = 0); - Local NewInstance() const; Local NewInstance(int argc, Handle argv[]) const; Local Call(Handle recv, int argc, Handle argv[]); @@ -3152,6 +3140,8 @@ class PropertyCallbackInfo { }; +typedef void (*FunctionCallback)(const FunctionCallbackInfo& info); + /** * NamedProperty[Getter|Setter] are used as interceptors on object. * See ObjectTemplate::SetNamedPropertyHandler. diff --git a/src/api.cc b/src/api.cc index 4b7fa43..22228c4 100644 --- a/src/api.cc +++ b/src/api.cc @@ -1052,24 +1052,22 @@ void FunctionTemplate::Inherit(v8::Handle value) { } -static Local FunctionTemplateNew( - i::Isolate* isolate, +Local FunctionTemplate::New( FunctionCallback callback, v8::Handle data, v8::Handle signature, - int length, - bool do_not_cache) { + int length) { + i::Isolate* isolate = i::Isolate::Current(); + EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); + LOG_API(isolate, "FunctionTemplate::New"); + ENTER_V8(isolate); i::Handle struct_obj = isolate->factory()->NewStruct(i::FUNCTION_TEMPLATE_INFO_TYPE); i::Handle obj = i::Handle::cast(struct_obj); InitializeFunctionTemplate(obj); - obj->set_do_not_cache(do_not_cache); - int next_serial_number = 0; - if (!do_not_cache) { - next_serial_number = isolate->next_serial_number() + 1; - isolate->set_next_serial_number(next_serial_number); - } + int next_serial_number = isolate->next_serial_number(); + isolate->set_next_serial_number(next_serial_number + 1); obj->set_serial_number(i::Smi::FromInt(next_serial_number)); if (callback != 0) { if (data.IsEmpty()) data = v8::Undefined(); @@ -1078,24 +1076,12 @@ static Local FunctionTemplateNew( obj->set_length(length); obj->set_undetectable(false); obj->set_needs_access_check(false); + if (!signature.IsEmpty()) obj->set_signature(*Utils::OpenHandle(*signature)); return Utils::ToLocal(obj); } -Local FunctionTemplate::New( - FunctionCallback callback, - v8::Handle data, - v8::Handle signature, - int length) { - i::Isolate* isolate = i::Isolate::Current(); - EnsureInitializedForIsolate(isolate, "v8::FunctionTemplate::New()"); - LOG_API(isolate, "FunctionTemplate::New"); - ENTER_V8(isolate); - return FunctionTemplateNew( - isolate, callback, data, signature, length, false); -} - Local Signature::New(Handle receiver, int argc, Handle argv[]) { @@ -4203,19 +4189,6 @@ Local Object::CallAsConstructor(int argc, } -Local Function::New(Isolate* v8_isolate, - FunctionCallback callback, - Local data, - int length) { - i::Isolate* isolate = reinterpret_cast(v8_isolate); - LOG_API(isolate, "Function::New"); - ENTER_V8(isolate); - return FunctionTemplateNew( - isolate, callback, data, Local(), length, true)-> - GetFunction(); -} - - Local Function::NewInstance() const { return NewInstance(0, NULL); } diff --git a/src/apinatives.js b/src/apinatives.js index 5fb36c0..7adeb7e 100644 --- a/src/apinatives.js +++ b/src/apinatives.js @@ -74,9 +74,8 @@ function InstantiateFunction(data, name) { cache[serialNumber] = null; var fun = %CreateApiFunction(data); if (name) %FunctionSetName(fun, name); + cache[serialNumber] = fun; var flags = %GetTemplateField(data, kApiFlagOffset); - var doNotCache = flags & (1 << kDoNotCacheBit); - if (!doNotCache) cache[serialNumber] = fun; if (flags & (1 << kRemovePrototypeBit)) { %FunctionRemovePrototype(fun); } else { @@ -98,7 +97,6 @@ function InstantiateFunction(data, name) { } } ConfigureTemplateInstance(fun, data); - if (doNotCache) return fun; } catch (e) { cache[serialNumber] = kUninitialized; throw e; diff --git a/src/execution.cc b/src/execution.cc index c59a737..91d340e 100644 --- a/src/execution.cc +++ b/src/execution.cc @@ -705,14 +705,12 @@ Handle Execution::InstantiateFunction( Handle data, bool* exc) { Isolate* isolate = data->GetIsolate(); - if (!data->do_not_cache()) { - // Fast case: see if the function has already been instantiated - int serial_number = Smi::cast(data->serial_number())->value(); - Object* elm = - isolate->native_context()->function_cache()-> - GetElementNoExceptionThrown(isolate, serial_number); - if (elm->IsJSFunction()) return Handle(JSFunction::cast(elm)); - } + // Fast case: see if the function has already been instantiated + int serial_number = Smi::cast(data->serial_number())->value(); + Object* elm = + isolate->native_context()->function_cache()-> + GetElementNoExceptionThrown(isolate, serial_number); + if (elm->IsJSFunction()) return Handle(JSFunction::cast(elm)); // The function has not yet been instantiated in this context; do it. Handle args[] = { data }; Handle result = Call(isolate, diff --git a/src/macros.py b/src/macros.py index d699c14..38b9a08 100644 --- a/src/macros.py +++ b/src/macros.py @@ -69,7 +69,6 @@ const msPerMonth = 2592000000; const kUninitialized = -1; const kReadOnlyPrototypeBit = 3; const kRemovePrototypeBit = 4; # For FunctionTemplateInfo, matches objects.h -const kDoNotCacheBit = 5; # For FunctionTemplateInfo, matches objects.h # Note: kDayZeroInJulianDay = ToJulianDay(1970, 0, 1). const kInvalidDate = 'Invalid Date'; diff --git a/src/objects-inl.h b/src/objects-inl.h index 8a3cbec..cd8426f 100644 --- a/src/objects-inl.h +++ b/src/objects-inl.h @@ -4569,8 +4569,6 @@ BOOL_ACCESSORS(FunctionTemplateInfo, flag, read_only_prototype, kReadOnlyPrototypeBit) BOOL_ACCESSORS(FunctionTemplateInfo, flag, remove_prototype, kRemovePrototypeBit) -BOOL_ACCESSORS(FunctionTemplateInfo, flag, do_not_cache, - kDoNotCacheBit) BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_expression, kIsExpressionBit) BOOL_ACCESSORS(SharedFunctionInfo, start_position_and_type, is_toplevel, diff --git a/src/objects.h b/src/objects.h index 97d1e5d..30b1b85 100644 --- a/src/objects.h +++ b/src/objects.h @@ -9878,7 +9878,6 @@ class FunctionTemplateInfo: public TemplateInfo { DECL_BOOLEAN_ACCESSORS(needs_access_check) DECL_BOOLEAN_ACCESSORS(read_only_prototype) DECL_BOOLEAN_ACCESSORS(remove_prototype) - DECL_BOOLEAN_ACCESSORS(do_not_cache) static inline FunctionTemplateInfo* cast(Object* obj); @@ -9914,7 +9913,6 @@ class FunctionTemplateInfo: public TemplateInfo { static const int kNeedsAccessCheckBit = 2; static const int kReadOnlyPrototypeBit = 3; static const int kRemovePrototypeBit = 4; - static const int kDoNotCacheBit = 5; DISALLOW_IMPLICIT_CONSTRUCTORS(FunctionTemplateInfo); }; diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 71d1b27..1e572ba 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -20491,34 +20491,4 @@ THREADED_TEST(CrankshaftInterceptorFieldWrite) { ExpectInt32("obj.interceptor_age", 103); } - #endif // V8_OS_POSIX - - -static Local function_new_expected_env; -static void FunctionNewCallback(const v8::FunctionCallbackInfo& info) { - CHECK_EQ(function_new_expected_env, info.Data()); - info.GetReturnValue().Set(17); -} - - -THREADED_TEST(FunctionNew) { - LocalContext env; - v8::Isolate* isolate = env->GetIsolate(); - v8::HandleScope scope(isolate); - Local data = v8::Object::New(); - function_new_expected_env = data; - Local func = Function::New(isolate, FunctionNewCallback, data); - env->Global()->Set(v8_str("func"), func); - Local result = CompileRun("func();"); - CHECK_EQ(v8::Integer::New(17, isolate), result); - // Verify function not cached - int serial_number = - i::Smi::cast(v8::Utils::OpenHandle(*func) - ->shared()->get_api_func_data()->serial_number())->value(); - i::Isolate* i_isolate = reinterpret_cast(isolate); - i::Object* elm = i_isolate->native_context()->function_cache() - ->GetElementNoExceptionThrown(i_isolate, serial_number); - CHECK(elm->IsNull()); -} -