Bug 745360 - Native calls are not function frames. r=luke
authorNicolas Pierron <nicolas.b.pierron@mozilla.com>
Fri, 13 Apr 2012 18:27:57 -0700
changeset 91652 dcb1ba052c3504651e7a912582d322d853674b6f
parent 91651 2411a6a8e38c8adb82489d2c2b414b55008cb3d3
child 91653 1dde63bcf17e5e6a1cd5737b03ea71da63d94ee3
push id22465
push usermak77@bonardo.net
push dateSat, 14 Apr 2012 11:58:29 +0000
treeherdermozilla-central@6880c195054f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersluke
bugs745360
milestone14.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 745360 - Native calls are not function frames. r=luke
js/src/jit-test/tests/basic/bug745360.js
js/src/jsfun.cpp
js/src/shell/js.cpp
js/src/vm/Stack.cpp
new file mode 100644
--- /dev/null
+++ b/js/src/jit-test/tests/basic/bug745360.js
@@ -0,0 +1,1 @@
+newGlobal('new-compartment').eval("eval.arguments")
--- a/js/src/jsfun.cpp
+++ b/js/src/jsfun.cpp
@@ -127,19 +127,17 @@ fun_getProperty(JSContext *cx, JSObject 
         if (!iter.isFunctionFrame() || iter.isEvalFrame())
             continue;
         if (iter.callee().toFunction() == fun)
             break;
     }
     if (iter.done())
         return true;
 
-    StackFrame *fp = NULL;
-    if (iter.isScript())
-        fp = iter.fp();
+    StackFrame *fp = iter.fp();
 
     if (JSID_IS_ATOM(id, cx->runtime->atomState.argumentsAtom)) {
         /* Warn if strict about f.arguments or equivalent unqualified uses. */
         if (!JS_ReportErrorFlagsAndNumber(cx, JSREPORT_WARNING | JSREPORT_STRICT, js_GetErrorMessage,
                                           NULL, JSMSG_DEPRECATED_USAGE, js_arguments_str)) {
             return false;
         }
 
--- a/js/src/shell/js.cpp
+++ b/js/src/shell/js.cpp
@@ -2140,17 +2140,17 @@ DumpStack(JSContext *cx, unsigned argc, 
 
     StackIter iter(cx);
     JS_ASSERT(iter.isNativeCall() && iter.callee().toFunction()->native() == DumpStack);
     ++iter;
 
     uint32_t index = 0;
     for (; !iter.done(); ++index, ++iter) {
         Value v;
-        if (iter.isNonEvalFunctionFrame()) {
+        if (iter.isNonEvalFunctionFrame() || iter.isNativeCall()) {
             v = iter.calleev();
         } else if (iter.isEvalFrame()) {
             v = StringValue(evalStr);
         } else {
             v = StringValue(globalStr);
         }
         if (!JS_SetElement(cx, arr, index, &v))
             return false;
--- a/js/src/vm/Stack.cpp
+++ b/js/src/vm/Stack.cpp
@@ -1247,17 +1247,17 @@ StackIter::isFunctionFrame() const
 {
     switch (state_) {
       case DONE:
         break;
       case SCRIPTED:
         return fp()->isFunctionFrame();
       case NATIVE:
       case IMPLICIT_NATIVE:
-        return true;
+        return false;
     }
     JS_NOT_REACHED("Unexpected state");
     return false;
 }
 
 bool
 StackIter::isEvalFrame() const
 {
@@ -1289,38 +1289,38 @@ StackIter::isNonEvalFunctionFrame() cons
     }
     JS_NOT_REACHED("Unexpected state");
     return false;
 }
 
 JSObject &
 StackIter::callee() const
 {
-    JS_ASSERT(isFunctionFrame());
     switch (state_) {
       case DONE:
         break;
       case SCRIPTED:
+        JS_ASSERT(isFunctionFrame());
         return fp()->callee();
       case NATIVE:
       case IMPLICIT_NATIVE:
         return nativeArgs().callee();
     }
     JS_NOT_REACHED("Unexpected state");
     return *(JSObject *) NULL;
 }
 
 Value
 StackIter::calleev() const
 {
-    JS_ASSERT(isFunctionFrame());
     switch (state_) {
       case DONE:
         break;
       case SCRIPTED:
+        JS_ASSERT(isFunctionFrame());
         return fp()->calleev();
       case NATIVE:
       case IMPLICIT_NATIVE:
         return nativeArgs().calleev();
     }
     JS_NOT_REACHED("Unexpected state");
     return Value();
 }