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
This commit is contained in:
parent
3fa964bf53
commit
c5c6c23a23
@ -440,10 +440,21 @@ const AccessorDescriptor Accessors::ScriptEvalFromFunctionName = {
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) {
|
Handle<Object> Accessors::FunctionGetPrototype(Handle<JSFunction> function) {
|
||||||
Isolate* isolate = Isolate::Current();
|
CALL_HEAP_FUNCTION(function->GetIsolate(),
|
||||||
CALL_HEAP_FUNCTION(
|
Accessors::FunctionGetPrototype(*function, NULL),
|
||||||
isolate, Accessors::FunctionGetPrototype(*object, 0), Object);
|
Object);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Handle<Object> Accessors::FunctionSetPrototype(Handle<JSFunction> function,
|
||||||
|
Handle<Object> 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<Object> Accessors::FunctionGetArguments(Handle<Object> object) {
|
Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction> function) {
|
||||||
Isolate* isolate = Isolate::Current();
|
CALL_HEAP_FUNCTION(function->GetIsolate(),
|
||||||
CALL_HEAP_FUNCTION(
|
Accessors::FunctionGetArguments(*function, NULL),
|
||||||
isolate, Accessors::FunctionGetArguments(*object, 0), Object);
|
Object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -77,12 +77,10 @@ class Accessors : public AllStatic {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Accessor functions called directly from the runtime system.
|
// Accessor functions called directly from the runtime system.
|
||||||
static Handle<Object> FunctionGetPrototype(Handle<Object> object);
|
static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object,
|
||||||
static Handle<Object> FunctionGetArguments(Handle<Object> object);
|
Handle<Object> value);
|
||||||
|
static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object);
|
||||||
MUST_USE_RESULT static MaybeObject* FunctionSetPrototype(JSObject* object,
|
static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
|
||||||
Object* value,
|
|
||||||
void*);
|
|
||||||
|
|
||||||
// Accessor infos.
|
// Accessor infos.
|
||||||
static Handle<AccessorInfo> MakeModuleExport(
|
static Handle<AccessorInfo> MakeModuleExport(
|
||||||
@ -90,13 +88,13 @@ class Accessors : public AllStatic {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// Accessor functions only used through the descriptor.
|
// Accessor functions only used through the descriptor.
|
||||||
|
static MaybeObject* FunctionSetPrototype(JSObject* object, Object*, void*);
|
||||||
static MaybeObject* FunctionGetPrototype(Object* object, void*);
|
static MaybeObject* FunctionGetPrototype(Object* object, void*);
|
||||||
static MaybeObject* FunctionGetLength(Object* object, void*);
|
static MaybeObject* FunctionGetLength(Object* object, void*);
|
||||||
static MaybeObject* FunctionGetName(Object* object, void*);
|
static MaybeObject* FunctionGetName(Object* object, void*);
|
||||||
static MaybeObject* FunctionGetArguments(Object* object, void*);
|
static MaybeObject* FunctionGetArguments(Object* object, void*);
|
||||||
static MaybeObject* FunctionGetCaller(Object* object, void*);
|
static MaybeObject* FunctionGetCaller(Object* object, void*);
|
||||||
MUST_USE_RESULT static MaybeObject* ArraySetLength(JSObject* object,
|
static MaybeObject* ArraySetLength(JSObject* object, Object*, void*);
|
||||||
Object* value, void*);
|
|
||||||
static MaybeObject* ArrayGetLength(Object* object, void*);
|
static MaybeObject* ArrayGetLength(Object* object, void*);
|
||||||
static MaybeObject* StringGetLength(Object* object, void*);
|
static MaybeObject* StringGetLength(Object* object, void*);
|
||||||
static MaybeObject* ScriptGetName(Object* object, void*);
|
static MaybeObject* ScriptGetName(Object* object, void*);
|
||||||
|
@ -491,7 +491,7 @@ Handle<JSFunction> Genesis::CreateEmptyFunction(Isolate* isolate) {
|
|||||||
// prototype, otherwise the missing initial_array_prototype will cause
|
// prototype, otherwise the missing initial_array_prototype will cause
|
||||||
// assertions during startup.
|
// assertions during startup.
|
||||||
native_context()->set_initial_array_prototype(*prototype);
|
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
|
// Allocate the empty function as the prototype for function ECMAScript
|
||||||
@ -1632,7 +1632,7 @@ Handle<JSFunction> Genesis::InstallInternalArray(
|
|||||||
true, true);
|
true, true);
|
||||||
Handle<JSObject> prototype =
|
Handle<JSObject> prototype =
|
||||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||||
SetPrototype(array_function, prototype);
|
Accessors::FunctionSetPrototype(array_function, prototype);
|
||||||
|
|
||||||
InternalArrayConstructorStub internal_array_constructor_stub(isolate());
|
InternalArrayConstructorStub internal_array_constructor_stub(isolate());
|
||||||
Handle<Code> code = internal_array_constructor_stub.GetCode(isolate());
|
Handle<Code> code = internal_array_constructor_stub.GetCode(isolate());
|
||||||
@ -1730,7 +1730,7 @@ bool Genesis::InstallNatives() {
|
|||||||
Builtins::kIllegal, false, false);
|
Builtins::kIllegal, false, false);
|
||||||
Handle<JSObject> prototype =
|
Handle<JSObject> prototype =
|
||||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
||||||
SetPrototype(script_fun, prototype);
|
Accessors::FunctionSetPrototype(script_fun, prototype);
|
||||||
native_context()->set_script_function(*script_fun);
|
native_context()->set_script_function(*script_fun);
|
||||||
|
|
||||||
Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
|
Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
|
||||||
@ -1886,7 +1886,7 @@ bool Genesis::InstallNatives() {
|
|||||||
Builtins::kIllegal, false, false);
|
Builtins::kIllegal, false, false);
|
||||||
Handle<JSObject> prototype =
|
Handle<JSObject> prototype =
|
||||||
factory()->NewJSObject(isolate()->object_function(), TENURED);
|
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);
|
native_context()->set_opaque_reference_function(*opaque_reference_fun);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,17 +208,6 @@ Handle<String> FlattenGetString(Handle<String> string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Handle<Object> SetPrototype(Handle<JSFunction> function,
|
|
||||||
Handle<Object> prototype) {
|
|
||||||
ASSERT(function->should_have_prototype());
|
|
||||||
CALL_HEAP_FUNCTION(function->GetIsolate(),
|
|
||||||
Accessors::FunctionSetPrototype(*function,
|
|
||||||
*prototype,
|
|
||||||
NULL),
|
|
||||||
Object);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Handle<Object> SetProperty(Isolate* isolate,
|
Handle<Object> SetProperty(Isolate* isolate,
|
||||||
Handle<Object> object,
|
Handle<Object> object,
|
||||||
Handle<Object> key,
|
Handle<Object> key,
|
||||||
|
@ -322,9 +322,6 @@ Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
|
|||||||
Handle<JSFunction> constructor,
|
Handle<JSFunction> constructor,
|
||||||
Handle<JSGlobalProxy> global);
|
Handle<JSGlobalProxy> global);
|
||||||
|
|
||||||
Handle<Object> SetPrototype(Handle<JSFunction> function,
|
|
||||||
Handle<Object> prototype);
|
|
||||||
|
|
||||||
Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table,
|
Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table,
|
||||||
Handle<Object> key);
|
Handle<Object> key);
|
||||||
|
|
||||||
|
@ -925,7 +925,7 @@ MaybeObject* LoadIC::Load(State state,
|
|||||||
if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
|
if (FLAG_trace_ic) PrintF("[LoadIC : +#prototype /function]\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return *Accessors::FunctionGetPrototype(object);
|
return *Accessors::FunctionGetPrototype(Handle<JSFunction>::cast(object));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2780,16 +2780,13 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetLength) {
|
|||||||
|
|
||||||
|
|
||||||
RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) {
|
RUNTIME_FUNCTION(MaybeObject*, Runtime_FunctionSetPrototype) {
|
||||||
SealHandleScope shs(isolate);
|
HandleScope scope(isolate);
|
||||||
ASSERT(args.length() == 2);
|
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());
|
ASSERT(fun->should_have_prototype());
|
||||||
Object* obj;
|
Accessors::FunctionSetPrototype(fun, value);
|
||||||
{ MaybeObject* maybe_obj =
|
|
||||||
Accessors::FunctionSetPrototype(fun, args[1], NULL);
|
|
||||||
if (!maybe_obj->ToObject(&obj)) return maybe_obj;
|
|
||||||
}
|
|
||||||
return args[0]; // return TOS
|
return args[0]; // return TOS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user