Revision: 23699
Author:   [email protected]
Date:     Thu Sep  4 14:52:52 2014 UTC
Log:      Fix deoptimization of context.

We need to handle the case where the context was removed by dead code
elimination. In that case, we just use the context from the activation
(or from the inlined function if we are inlined).

For reference, here is the CL that introduced the bug: https://codereview.chromium.org/522873002

BUG=410566
LOG=N
[email protected]

Review URL: https://codereview.chromium.org/542613002
https://code.google.com/p/v8/source/detail?r=23699

Modified:
 /branches/bleeding_edge/src/deoptimizer.cc
 /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc

=======================================
--- /branches/bleeding_edge/src/deoptimizer.cc  Mon Sep  1 09:31:14 2014 UTC
+++ /branches/bleeding_edge/src/deoptimizer.cc  Thu Sep  4 14:52:52 2014 UTC
@@ -1067,6 +1067,18 @@
   // The context should not be a placeholder for a materialized object.
   CHECK(value !=
         reinterpret_cast<intptr_t>(isolate_->heap()->arguments_marker()));
+  if (value ==
+      reinterpret_cast<intptr_t>(isolate_->heap()->undefined_value())) {
+    // If the context was optimized away, just use the context from
+    // the activation. This should only apply to Crankshaft code.
+    CHECK(!compiled_code_->is_turbofanned());
+    if (is_bottommost) {
+      value = input_->GetFrameSlot(input_offset);
+    } else {
+      value = reinterpret_cast<intptr_t>(function->context());
+    }
+    output_frame->SetFrameSlot(output_offset, value);
+  }
   output_frame->SetContext(value);
   if (is_topmost) output_frame->SetRegister(context_reg.code(), value);
   if (trace_scope_ != NULL) {
=======================================
--- /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc Thu Sep 4 13:45:05 2014 UTC +++ /branches/bleeding_edge/test/cctest/compiler/test-codegen-deopt.cc Thu Sep 4 14:52:52 2014 UTC
@@ -139,10 +139,11 @@
         Unique<Object>::CreateUninitialized(deopt_function);
Node* deopt_fun_node = m.NewNode(common.HeapConstant(deopt_fun_constant));

- Handle<Context> context(deopt_function->context(), CcTest::i_isolate());
-    Unique<Object> context_constant =
-        Unique<Object>::CreateUninitialized(context);
-    Node* context_node = m.NewNode(common.HeapConstant(context_constant));
+ Handle<Context> caller_context(function->context(), CcTest::i_isolate());
+    Unique<Object> caller_context_constant =
+        Unique<Object>::CreateUninitialized(caller_context);
+    Node* caller_context_node =
+        m.NewNode(common.HeapConstant(caller_context_constant));

     bailout_id = GetCallBailoutId();
Node* parameters = m.NewNode(common.StateValues(1), m.UndefinedConstant());
@@ -151,7 +152,12 @@

     Node* state_node =
         m.NewNode(common.FrameState(bailout_id, kIgnoreOutput), parameters,
- locals, stack, m.UndefinedConstant(), m.UndefinedConstant()); + locals, stack, caller_context_node, m.UndefinedConstant());
+
+ Handle<Context> context(deopt_function->context(), CcTest::i_isolate());
+    Unique<Object> context_constant =
+        Unique<Object>::CreateUninitialized(context);
+    Node* context_node = m.NewNode(common.HeapConstant(context_constant));

m.CallJS0(deopt_fun_node, m.UndefinedConstant(), context_node, state_node);

@@ -260,7 +266,7 @@

     Node* state_node =
         m.NewNode(common.FrameState(bailout_id, kIgnoreOutput), parameters,
- locals, stack, m.UndefinedConstant(), m.UndefinedConstant());
+                  locals, stack, context_node, m.UndefinedConstant());

m.CallRuntime1(Runtime::kDeoptimizeFunction, this_fun_node, context_node,
                    state_node);

--
--
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/d/optout.

Reply via email to