Revision: 9421
Author:   [email protected]
Date:     Mon Sep 26 02:17:56 2011
Log: Enable inlining functions with contexts different than their caller.

BUG=
TEST=

Review URL: http://codereview.chromium.org/7925007
http://code.google.com/p/v8/source/detail?r=9421

Modified:
 /branches/bleeding_edge/src/hydrogen.cc
 /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc

=======================================
--- /branches/bleeding_edge/src/hydrogen.cc     Fri Sep 23 01:00:06 2011
+++ /branches/bleeding_edge/src/hydrogen.cc     Mon Sep 26 02:17:56 2011
@@ -4527,14 +4527,17 @@
     return false;
   }

-  // No context change required.
   CompilationInfo* outer_info = info();
+#if !defined(V8_TARGET_ARCH_IA32)
+  // Target must be able to use caller's context.
   if (target->context() != outer_info->closure()->context() ||
       outer_info->scope()->contains_with() ||
       outer_info->scope()->num_heap_slots() > 0) {
     TraceInline(target, caller, "target requires context change");
     return false;
   }
+#endif
+

   // Don't inline deeper than kMaxInliningLevels calls.
   HEnvironment* env = environment();
@@ -4655,6 +4658,10 @@
                                      function,
                                      undefined,
                                      call_kind);
+  HConstant* context = new HConstant(Handle<Context>(target->context()),
+                                     Representation::Tagged());
+  AddInstruction(context);
+  inner_env->BindContext(context);
   HBasicBlock* body_entry = CreateBasicBlock(inner_env);
   current_block()->Goto(body_entry);
   body_entry->SetJoinId(expr->ReturnId());
=======================================
--- /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Fri Sep 23 06:28:17 2011 +++ /branches/bleeding_edge/src/ia32/lithium-codegen-ia32.cc Mon Sep 26 02:17:56 2011
@@ -516,14 +516,18 @@
                                        int argc,
                                        LInstruction* instr,
                                        LOperand* context) {
-  ASSERT(context->IsRegister() || context->IsStackSlot());
   if (context->IsRegister()) {
     if (!ToRegister(context).is(esi)) {
       __ mov(esi, ToRegister(context));
     }
-  } else {
-    // Context is stack slot.
+  } else if (context->IsStackSlot()) {
     __ mov(esi, ToOperand(context));
+  } else if (context->IsConstantOperand()) {
+    Handle<Object> literal =
+        chunk_->LookupLiteral(LConstantOperand::cast(context));
+    LoadHeapObject(esi, Handle<Context>::cast(literal));
+  } else {
+    UNREACHABLE();
   }

   __ CallRuntimeSaveDoubles(id);
@@ -1235,8 +1239,13 @@


 void LCodeGen::DoConstantT(LConstantT* instr) {
-  ASSERT(instr->result()->IsRegister());
-  __ Set(ToRegister(instr->result()), Immediate(instr->value()));
+  Register reg = ToRegister(instr->result());
+  Handle<Object> handle = instr->value();
+  if (handle->IsHeapObject()) {
+    LoadHeapObject(reg, Handle<HeapObject>::cast(handle));
+  } else {
+    __ Set(reg, Immediate(handle));
+  }
 }


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

Reply via email to