From c5c6c23a237cb7fc94663edc8afd6e8cf7486d3e Mon Sep 17 00:00:00 2001 From: "mstarzinger@chromium.org" Date: Fri, 16 Aug 2013 21:27:11 +0000 Subject: [PATCH] Handlify Accessors::FunctionSetPrototype method. R=rossberg@chromium.org Review URL: https://codereview.chromium.org/23280004 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@16210 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/accessors.cc | 27 +++++++++++++++++++-------- src/accessors.h | 14 ++++++-------- src/bootstrapper.cc | 8 ++++---- src/handles.cc | 11 ----------- src/handles.h | 3 --- src/ic.cc | 2 +- src/runtime.cc | 11 ++++------- 7 files changed, 34 insertions(+), 42 deletions(-) diff --git a/src/accessors.cc b/src/accessors.cc index a43eb78..45869ea 100644 --- a/src/accessors.cc +++ b/src/accessors.cc @@ -440,10 +440,21 @@ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = { // -Handle Accessors::FunctionGetPrototype(Handle object) { - Isolate* isolate = Isolate::Current(); - CALL_HEAP_FUNCTION( - isolate, Accessors::FunctionGetPrototype(*object, 0), Object); +Handle Accessors::FunctionGetPrototype(Handle function) { + CALL_HEAP_FUNCTION(function->GetIsolate(), + Accessors::FunctionGetPrototype(*function, NULL), + Object); +} + + +Handle Accessors::FunctionSetPrototype(Handle function, + Handle prototype) { + ASSERT(function->should_have_prototype()); + CALL_HEAP_FUNCTION(function->GetIsolate(), + Accessors::FunctionSetPrototype(*function, + *prototype, + NULL), + Object); } @@ -575,10 +586,10 @@ const AccessorDescriptor Accessors::FunctionName = { // -Handle Accessors::FunctionGetArguments(Handle object) { - Isolate* isolate = Isolate::Current(); - CALL_HEAP_FUNCTION( - isolate, Accessors::FunctionGetArguments(*object, 0), Object); +Handle Accessors::FunctionGetArguments(Handle function) { + CALL_HEAP_FUNCTION(function->GetIsolate(), + Accessors::FunctionGetArguments(*function, NULL), + Object); } diff --git a/src/accessors.h b/src/accessors.h index ae56a3d..38368c2 100644 --- a/src/accessors.h +++ b/src/accessors.h @@ -77,12 +77,10 @@ class Accessors : public AllStatic { }; // Accessor functions called directly from the runtime system. - static Handle FunctionGetPrototype(Handle object); - static Handle FunctionGetArguments(Handle object); - - MUST_USE_RESULT static MaybeObject* FunctionSetPrototype(JSObject* object, - Object* value, - void*); + static Handle FunctionSetPrototype(Handle object, + Handle value); + static Handle FunctionGetPrototype(Handle object); + static Handle FunctionGetArguments(Handle object); // Accessor infos. static Handle MakeModuleExport( @@ -90,13 +88,13 @@ class Accessors : public AllStatic { private: // Accessor functions only used through the descriptor. + static MaybeObject* FunctionSetPrototype(JSObject* object, Object*, void*); static MaybeObject* FunctionGetPrototype(Object* object, void*); static MaybeObject* FunctionGetLength(Object* object, void*); static MaybeObject* FunctionGetName(Object* object, void*); static MaybeObject* FunctionGetArguments(Object* object, void*); static MaybeObject* FunctionGetCaller(Object* object, void*); - MUST_USE_RESULT static MaybeObject* ArraySetLength(JSObject* object, - Object* value, void*); + static MaybeObject* ArraySetLength(JSObject* object, Object*, void*); static MaybeObject* ArrayGetLength(Object* object, void*); static MaybeObject* StringGetLength(Object* object, void*); static MaybeObject* ScriptGetName(Object* object, void*); diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 2a385aa..82b2320 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -491,7 +491,7 @@ Handle Genesis::CreateEmptyFunction(Isolate* isolate) { // prototype, otherwise the missing initial_array_prototype will cause // assertions during startup. native_context()->set_initial_array_prototype(*prototype); - SetPrototype(object_fun, prototype); + Accessors::FunctionSetPrototype(object_fun, prototype); } // Allocate the empty function as the prototype for function ECMAScript @@ -1632,7 +1632,7 @@ Handle Genesis::InstallInternalArray( true, true); Handle prototype = factory()->NewJSObject(isolate()->object_function(), TENURED); - SetPrototype(array_function, prototype); + Accessors::FunctionSetPrototype(array_function, prototype); InternalArrayConstructorStub internal_array_constructor_stub(isolate()); Handle code = internal_array_constructor_stub.GetCode(isolate()); @@ -1730,7 +1730,7 @@ bool Genesis::InstallNatives() { Builtins::kIllegal, false, false); Handle prototype = factory()->NewJSObject(isolate()->object_function(), TENURED); - SetPrototype(script_fun, prototype); + Accessors::FunctionSetPrototype(script_fun, prototype); native_context()->set_script_function(*script_fun); Handle script_map = Handle(script_fun->initial_map()); @@ -1886,7 +1886,7 @@ bool Genesis::InstallNatives() { Builtins::kIllegal, false, false); Handle prototype = factory()->NewJSObject(isolate()->object_function(), TENURED); - SetPrototype(opaque_reference_fun, prototype); + Accessors::FunctionSetPrototype(opaque_reference_fun, prototype); native_context()->set_opaque_reference_function(*opaque_reference_fun); } diff --git a/src/handles.cc b/src/handles.cc index 48114d9..b173edc 100644 --- a/src/handles.cc +++ b/src/handles.cc @@ -208,17 +208,6 @@ Handle FlattenGetString(Handle string) { } -Handle SetPrototype(Handle function, - Handle prototype) { - ASSERT(function->should_have_prototype()); - CALL_HEAP_FUNCTION(function->GetIsolate(), - Accessors::FunctionSetPrototype(*function, - *prototype, - NULL), - Object); -} - - Handle SetProperty(Isolate* isolate, Handle object, Handle key, diff --git a/src/handles.h b/src/handles.h index 90db7d1..560944c 100644 --- a/src/handles.h +++ b/src/handles.h @@ -322,9 +322,6 @@ Handle ReinitializeJSGlobalProxy( Handle constructor, Handle global); -Handle SetPrototype(Handle function, - Handle prototype); - Handle ObjectHashSetAdd(Handle table, Handle key); diff --git a/src/ic.cc b/src/ic.cc index 3c22580..ad1a313 100644 --- a/src/ic.cc +++ b/src/ic.cc @@ -925,7 +925,7 @@ MaybeObject* LoadIC::Load(State state, if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n"); #endif } - return *Accessors::FunctionGetPrototype(object); + return *Accessors::FunctionGetPrototype(Handle::cast(object)); } } diff --git a/src/runtime.cc b/src/runtime.cc index 6553044..f6da371 100644 --- a/src/runtime.cc +++ b/src/runtime.cc @@ -2780,16 +2780,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) { RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) { - SealHandleScope shs(isolate); + HandleScope scope(isolate); ASSERT(args.length() == 2); - CONVERT_ARG_CHECKED(JSFunction, fun, 0); + CONVERT_ARG_HANDLE_CHECKED(JSFunction, fun, 0); + CONVERT_ARG_HANDLE_CHECKED(Object, value, 1); ASSERT(fun->should_have_prototype()); - Object* obj; - { MaybeObject* maybe_obj = - Accessors::FunctionSetPrototype(fun, args[1], NULL); - if (!maybe_obj->ToObject(&obj)) return maybe_obj; - } + Accessors::FunctionSetPrototype(fun, value); return args[0]; // return TOS } -- 2.7.4