Bug 959695 part 1. Make ValueToCallable take a Handle. r=terrence
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 14 Jan 2014 21:46:43 -0500
changeset 163441 b47da97e9521a8a89114c3d3e6cf31adf14ab049
parent 163440 fdf7c54abdcd0f2c91fc64d9ae08af6855382511
child 163442 a1b7f52cccdb7fa2b4e5b27a0e5390ce079055f7
push id25996
push useremorley@mozilla.com
push dateWed, 15 Jan 2014 15:54:39 +0000
treeherdermozilla-central@dd2cf81c56b7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersterrence
bugs959695
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 959695 part 1. Make ValueToCallable take a Handle. r=terrence
js/src/jsproxy.cpp
js/src/vm/Interpreter.cpp
js/src/vm/Interpreter.h
--- a/js/src/jsproxy.cpp
+++ b/js/src/jsproxy.cpp
@@ -3295,37 +3295,38 @@ proxy_create(JSContext *cx, unsigned arg
 
     vp->setObject(*proxy);
     return true;
 }
 
 static bool
 proxy_createFunction(JSContext *cx, unsigned argc, Value *vp)
 {
-    if (argc < 2) {
+    CallArgs args = CallArgsFromVp(argc, vp);
+    if (args.length() < 2) {
         JS_ReportErrorNumber(cx, js_GetErrorMessage, nullptr, JSMSG_MORE_ARGS_NEEDED,
                              "createFunction", "1", "");
         return false;
     }
-    RootedObject handler(cx, NonNullObject(cx, vp[2]));
+    RootedObject handler(cx, NonNullObject(cx, args[0]));
     if (!handler)
         return false;
     RootedObject proto(cx), parent(cx);
-    parent = vp[0].toObject().getParent();
+    parent = args.callee().getParent();
     proto = parent->global().getOrCreateFunctionPrototype(cx);
     if (!proto)
         return false;
     parent = proto->getParent();
 
-    RootedObject call(cx, ValueToCallable(cx, vp[3], argc - 2));
+    RootedObject call(cx, ValueToCallable(cx, args[1], args.length() - 2));
     if (!call)
         return false;
     RootedObject construct(cx, nullptr);
-    if (argc > 2) {
-        construct = ValueToCallable(cx, vp[4], argc - 3);
+    if (args.length() > 2) {
+        construct = ValueToCallable(cx, args[2], args.length() - 3);
         if (!construct)
             return false;
     } else {
         construct = call;
     }
 
     // Stash the call and construct traps on a holder object that we can stick
     // in a slot on the proxy.
--- a/js/src/vm/Interpreter.cpp
+++ b/js/src/vm/Interpreter.cpp
@@ -350,17 +350,17 @@ js::ReportIsNotFunction(JSContext *cx, c
     int spIndex = numToSkip >= 0 ? -(numToSkip + 1) : JSDVG_SEARCH_STACK;
 
     RootedValue val(cx, v);
     js_ReportValueError3(cx, error, spIndex, val, NullPtr(), nullptr, nullptr);
     return false;
 }
 
 JSObject *
-js::ValueToCallable(JSContext *cx, const Value &v, int numToSkip, MaybeConstruct construct)
+js::ValueToCallable(JSContext *cx, HandleValue v, int numToSkip, MaybeConstruct construct)
 {
     if (v.isObject()) {
         JSObject *callable = &v.toObject();
         if (callable->isCallable())
             return callable;
     }
 
     ReportIsNotFunction(cx, v, numToSkip, construct);
--- a/js/src/vm/Interpreter.h
+++ b/js/src/vm/Interpreter.h
@@ -108,17 +108,17 @@ enum MaybeConstruct {
  * before it reaches |v|. If it's -1, the decompiler will search the stack.
  */
 extern bool
 ReportIsNotFunction(JSContext *cx, const Value &v, int numToSkip = -1,
                     MaybeConstruct construct = NO_CONSTRUCT);
 
 /* See ReportIsNotFunction comment for the meaning of numToSkip. */
 extern JSObject *
-ValueToCallable(JSContext *cx, const Value &vp, int numToSkip = -1,
+ValueToCallable(JSContext *cx, HandleValue v, int numToSkip = -1,
                 MaybeConstruct construct = NO_CONSTRUCT);
 
 /*
  * Invoke assumes that the given args have been pushed on the top of the
  * VM stack.
  */
 extern bool
 Invoke(JSContext *cx, CallArgs args, MaybeConstruct construct = NO_CONSTRUCT);