Reviewers: rossberg,
Description:
Handlify Accessors::FunctionSetPrototype method.
[email protected]
Please review this at https://codereview.chromium.org/23280004/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/accessors.h
M src/accessors.cc
M src/bootstrapper.cc
M src/handles.h
M src/handles.cc
M src/ic.cc
M src/runtime.cc
Index: src/accessors.cc
diff --git a/src/accessors.cc b/src/accessors.cc
index
a43eb78b8702d57ca504e734a38e1bc635582bec..45869ea63097fbdfee192f76d4f2f0cfc6581ccf
100644
--- a/src/accessors.cc
+++ b/src/accessors.cc
@@ -440,10 +440,21 @@ const AccessorDescriptor
Accessors::ScriptEvalFromFunctionName = {
//
-Handle<Object> Accessors::FunctionGetPrototype(Handle<Object> object) {
- Isolate* isolate = Isolate::Current();
- CALL_HEAP_FUNCTION(
- isolate, Accessors::FunctionGetPrototype(*object, 0), Object);
+Handle<Object> Accessors::FunctionGetPrototype(Handle<JSFunction>
function) {
+ CALL_HEAP_FUNCTION(function->GetIsolate(),
+ Accessors::FunctionGetPrototype(*function, NULL),
+ 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) {
- Isolate* isolate = Isolate::Current();
- CALL_HEAP_FUNCTION(
- isolate, Accessors::FunctionGetArguments(*object, 0), Object);
+Handle<Object> Accessors::FunctionGetArguments(Handle<JSFunction>
function) {
+ CALL_HEAP_FUNCTION(function->GetIsolate(),
+ Accessors::FunctionGetArguments(*function, NULL),
+ Object);
}
Index: src/accessors.h
diff --git a/src/accessors.h b/src/accessors.h
index
ae56a3d444914365571c28e8ced7be99265eb5e1..38368c2436524e327023f8fe6d3482660cc2c60a
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<Object> FunctionGetPrototype(Handle<Object> object);
- static Handle<Object> FunctionGetArguments(Handle<Object> object);
-
- MUST_USE_RESULT static MaybeObject* FunctionSetPrototype(JSObject*
object,
- Object* value,
- void*);
+ static Handle<Object> FunctionSetPrototype(Handle<JSFunction> object,
+ Handle<Object> value);
+ static Handle<Object> FunctionGetPrototype(Handle<JSFunction> object);
+ static Handle<Object> FunctionGetArguments(Handle<JSFunction> object);
// Accessor infos.
static Handle<AccessorInfo> 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*);
Index: src/bootstrapper.cc
diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc
index
2a385aa4865d97d87b152e20380566bb809c9b17..82b2320c6b1b35aeb0a43f7ae5819f7c8fb51087
100644
--- a/src/bootstrapper.cc
+++ b/src/bootstrapper.cc
@@ -491,7 +491,7 @@ Handle<JSFunction>
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<JSFunction> Genesis::InstallInternalArray(
true, true);
Handle<JSObject> prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED);
- SetPrototype(array_function, prototype);
+ Accessors::FunctionSetPrototype(array_function, prototype);
InternalArrayConstructorStub internal_array_constructor_stub(isolate());
Handle<Code> code = internal_array_constructor_stub.GetCode(isolate());
@@ -1730,7 +1730,7 @@ bool Genesis::InstallNatives() {
Builtins::kIllegal, false, false);
Handle<JSObject> prototype =
factory()->NewJSObject(isolate()->object_function(), TENURED);
- SetPrototype(script_fun, prototype);
+ Accessors::FunctionSetPrototype(script_fun, prototype);
native_context()->set_script_function(*script_fun);
Handle<Map> script_map = Handle<Map>(script_fun->initial_map());
@@ -1886,7 +1886,7 @@ bool Genesis::InstallNatives() {
Builtins::kIllegal, false, false);
Handle<JSObject> 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);
}
Index: src/handles.cc
diff --git a/src/handles.cc b/src/handles.cc
index
48114d91a71a3c396b29df5208674308f32cc99e..b173edc9914a59cd095f223193d30cb6625d48cd
100644
--- a/src/handles.cc
+++ b/src/handles.cc
@@ -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> object,
Handle<Object> key,
Index: src/handles.h
diff --git a/src/handles.h b/src/handles.h
index
90db7d1212104a6b16eb0877f22b93f1d98ae7ac..560944cc14e5a4633a914675aae51fc4f7f93727
100644
--- a/src/handles.h
+++ b/src/handles.h
@@ -322,9 +322,6 @@ Handle<JSGlobalProxy> ReinitializeJSGlobalProxy(
Handle<JSFunction> constructor,
Handle<JSGlobalProxy> global);
-Handle<Object> SetPrototype(Handle<JSFunction> function,
- Handle<Object> prototype);
-
Handle<ObjectHashSet> ObjectHashSetAdd(Handle<ObjectHashSet> table,
Handle<Object> key);
Index: src/ic.cc
diff --git a/src/ic.cc b/src/ic.cc
index
3c22580c2c7e2b36d851444304435e6f433d4a17..ad1a313376d2f3a1de20a716298aef849e6b60cd
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<JSFunction>::cast(object));
}
}
Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index
10de6f9e5ec001c595a0b86632599f9be9a22074..446e1c5c24b31b87712005a9781abfff801806ab
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
}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.