Reviewers: Vyacheslav Egorov,

Description:
Fix the debugger for strict-mode functions.

undefined is passed unchanged as the receiver for strict-mode
functions through call and apply. Also, if a strict-mode function is
called without an explicit receiver, undefined is passed as the
receiver (not the global object as for other functions).

[email protected]
BUG=89236
TEST=mjsunit/debug-scopes.js


Please review this at http://codereview.chromium.org/7388011/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files:
  M src/runtime.cc
  M test/mjsunit/debug-scopes.js


Index: src/runtime.cc
diff --git a/src/runtime.cc b/src/runtime.cc
index c6b26493ce9bcdf709248177842db4348d6736be..6ecc852ee243a3b51c173d5ab2b0bc124fdf656f 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -10299,12 +10299,12 @@ RUNTIME_FUNCTION(MaybeObject*, Runtime_GetFrameDetails) {
   // THIS MUST BE DONE LAST SINCE WE MIGHT ADVANCE
   // THE FRAME ITERATOR TO WRAP THE RECEIVER.
   Handle<Object> receiver(it.frame()->receiver(), isolate);
-  if (!receiver->IsJSObject()) {
-    // If the receiver is NOT a JSObject we have hit an optimization
-    // where a value object is not converted into a wrapped JS objects.
-    // To hide this optimization from the debugger, we wrap the receiver
-    // by creating correct wrapper object based on the calling frame's
-    // global context.
+  if (!receiver->IsJSObject() && !receiver->IsUndefined()) {
+    // If the receiver is not a JSObject and is not undefined we have
+    // hit an optimization where a value object is not converted into
+    // a wrapped JS objects. To hide this optimization from the
+    // debugger, we wrap the receiver by creating correct wrapper
+    // object based on the calling frame's global context.
     it.Advance();
     Handle<Context> calling_frames_global_context(
Context::cast(Context::cast(it.frame()->context())->global_context()));
Index: test/mjsunit/debug-scopes.js
diff --git a/test/mjsunit/debug-scopes.js b/test/mjsunit/debug-scopes.js
index 40adf5b2d2a3f35b4e92f790144518a3043176c1..b9f9814205ebd7913a50c7bfacf27642b7f280af 100644
--- a/test/mjsunit/debug-scopes.js
+++ b/test/mjsunit/debug-scopes.js
@@ -308,6 +308,24 @@ local_7(1, 2);
 EndTest();


+// Simple empty local scope but for a strict-mode function where the
+// receiver is undefined.
+BeginTest("Local 8");
+
+function local_8() {
+  "use strict";
+  debugger;
+}
+
+listener_delegate = function(exec_state) {
+  CheckScopeChain([debug.ScopeType.Local,
+                   debug.ScopeType.Global], exec_state);
+  CheckScopeContent({}, 0, exec_state);
+};
+local_8();
+EndTest();
+
+
 // Single empty with block.
 BeginTest("With 1");



--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to