Simplify DoLoadNamedFieldPolymorphic
authorerik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 May 2012 09:13:02 +0000 (09:13 +0000)
committererik.corry@gmail.com <erik.corry@gmail.com@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Fri, 11 May 2012 09:13:02 +0000 (09:13 +0000)
Review URL: https://chromiumcodereview.appspot.com/10386089

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@11543 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/arm/lithium-codegen-arm.cc
src/ia32/lithium-codegen-ia32.cc
src/mips/lithium-codegen-mips.cc
src/x64/lithium-codegen-x64.cc

index 0caeb12..bf11ab9 100644 (file)
@@ -2587,49 +2587,38 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
   Register object = ToRegister(instr->object());
   Register result = ToRegister(instr->result());
   Register scratch = scratch0();
+
   int map_count = instr->hydrogen()->types()->length();
+  bool need_generic = instr->hydrogen()->need_generic();
+
+  if (map_count == 0 && !need_generic) {
+    DeoptimizeIf(al, instr->environment());
+    return;
+  }
   Handle<String> name = instr->hydrogen()->name();
-  if (map_count == 0 && instr->hydrogen()->need_generic()) {
-    __ mov(r2, Operand(name));
-    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-    CallCode(ic, RelocInfo::CODE_TARGET, instr);
-  } else {
-    Label done;
-    __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
-    for (int i = 0; i < map_count - 1; ++i) {
-      Handle<Map> map = instr->hydrogen()->types()->at(i);
+  Label done;
+  __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
+  for (int i = 0; i < map_count; ++i) {
+    bool last = (i == map_count - 1);
+    Handle<Map> map = instr->hydrogen()->types()->at(i);
+    __ cmp(scratch, Operand(map));
+    if (last && !need_generic) {
+      DeoptimizeIf(ne, instr->environment());
+      EmitLoadFieldOrConstantFunction(result, object, map, name);
+    } else {
       Label next;
-      __ cmp(scratch, Operand(map));
       __ b(ne, &next);
       EmitLoadFieldOrConstantFunction(result, object, map, name);
       __ b(&done);
       __ bind(&next);
     }
-    if (instr->hydrogen()->need_generic()) {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ cmp(scratch, Operand(map));
-        Label generic;
-        __ b(ne, &generic);
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-        __ b(&done);
-        __ bind(&generic);
-      }
-      __ mov(r2, Operand(name));
-      Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-      CallCode(ic, RelocInfo::CODE_TARGET, instr);
-    } else {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ cmp(scratch, Operand(map));
-        DeoptimizeIf(ne, instr->environment());
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-      } else {
-        DeoptimizeIf(al, instr->environment());
-      }
-    }
-    __ bind(&done);
   }
+  if (need_generic) {
+    __ mov(r2, Operand(name));
+    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
+    CallCode(ic, RelocInfo::CODE_TARGET, instr);
+  }
+  __ bind(&done);
 }
 
 
index 63f9c97..455c502 100644 (file)
@@ -2274,47 +2274,35 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
   Register result = ToRegister(instr->result());
 
   int map_count = instr->hydrogen()->types()->length();
+  bool need_generic = instr->hydrogen()->need_generic();
+
+  if (map_count == 0 && !need_generic) {
+    DeoptimizeIf(no_condition, instr->environment());
+    return;
+  }
   Handle<String> name = instr->hydrogen()->name();
-  if (map_count == 0 && instr->hydrogen()->need_generic()) {
-    __ mov(ecx, name);
-    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-    CallCode(ic, RelocInfo::CODE_TARGET, instr);
-  } else {
-    Label done;
-    for (int i = 0; i < map_count - 1; ++i) {
-      Handle<Map> map = instr->hydrogen()->types()->at(i);
+  Label done;
+  for (int i = 0; i < map_count; ++i) {
+    bool last = (i == map_count - 1);
+    Handle<Map> map = instr->hydrogen()->types()->at(i);
+    __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
+    if (last && !need_generic) {
+      DeoptimizeIf(not_equal, instr->environment());
+      EmitLoadFieldOrConstantFunction(result, object, map, name);
+    } else {
       Label next;
-      __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
       __ j(not_equal, &next, Label::kNear);
       EmitLoadFieldOrConstantFunction(result, object, map, name);
       __ jmp(&done, Label::kNear);
       __ bind(&next);
     }
-    if (instr->hydrogen()->need_generic()) {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
-        Label generic;
-        __ j(not_equal, &generic, Label::kNear);
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-        __ jmp(&done, Label::kNear);
-        __ bind(&generic);
-      }
-      __ mov(ecx, name);
-      Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-      CallCode(ic, RelocInfo::CODE_TARGET, instr);
-    } else {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
-        DeoptimizeIf(not_equal, instr->environment());
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-      } else {
-        DeoptimizeIf(no_condition, instr->environment());
-      }
-    }
-    __ bind(&done);
   }
+  if (need_generic) {
+    __ mov(ecx, name);
+    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
+    CallCode(ic, RelocInfo::CODE_TARGET, instr);
+  }
+  __ bind(&done);
 }
 
 
index 5bf4d95..986921f 100644 (file)
@@ -2344,45 +2344,35 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
   Register result = ToRegister(instr->result());
   Register scratch = scratch0();
   int map_count = instr->hydrogen()->types()->length();
+  bool need_generic = instr->hydrogen()->need_generic();
+
+  if (map_count == 0 && !need_generic) {
+    DeoptimizeIf(al, instr->environment());
+    return;
+  }
   Handle<String> name = instr->hydrogen()->name();
-  if (map_count == 0 && instr->hydrogen()->need_generic()) {
-    __ li(a2, Operand(name));
-    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-    CallCode(ic, RelocInfo::CODE_TARGET, instr);
-  } else {
-    Label done;
-    __ lw(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
-    for (int i = 0; i < map_count - 1; ++i) {
-      Handle<Map> map = instr->hydrogen()->types()->at(i);
+  Label done;
+  __ lw(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
+  for (int i = 0; i < map_count; ++i) {
+    bool last = (i == map_count - 1);
+    Handle<Map> map = instr->hydrogen()->types()->at(i);
+    if (last && !need_generic) {
+      Handle<Map> map = instr->hydrogen()->types()->last();
+      DeoptimizeIf(ne, instr->environment(), scratch, Operand(map));
+    } else {
       Label next;
       __ Branch(&next, ne, scratch, Operand(map));
       EmitLoadFieldOrConstantFunction(result, object, map, name);
       __ Branch(&done);
       __ bind(&next);
     }
-    if (instr->hydrogen()->need_generic()) {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        Label generic;
-        __ Branch(&generic, ne, scratch, Operand(map));
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-        __ Branch(&done);
-        __ bind(&generic);
-      }
-      __ li(a2, Operand(name));
-      Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-      CallCode(ic, RelocInfo::CODE_TARGET, instr);
-    } else {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        DeoptimizeIf(ne, instr->environment(), scratch, Operand(map));
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-      } else {
-        DeoptimizeIf(al, instr->environment(), zero_reg, Operand(zero_reg));
-      }
-    }
-    __ bind(&done);
   }
+  if (need_generic) {
+    __ li(a2, Operand(name));
+    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
+    CallCode(ic, RelocInfo::CODE_TARGET, instr);
+  }
+  __ bind(&done);
 }
 
 
index feff9e7..5f5c2af 100644 (file)
@@ -2223,48 +2223,35 @@ void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
   Register result = ToRegister(instr->result());
 
   int map_count = instr->hydrogen()->types()->length();
-  Handle<String> name = instr->hydrogen()->name();
+  bool need_generic = instr->hydrogen()->need_generic();
 
-  if (map_count == 0 && instr->hydrogen()->need_generic()) {
-    __ Move(rcx, instr->hydrogen()->name());
-    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-    CallCode(ic, RelocInfo::CODE_TARGET, instr);
-  } else {
-    Label done;
-    for (int i = 0; i < map_count - 1; ++i) {
-      Handle<Map> map = instr->hydrogen()->types()->at(i);
+  if (map_count == 0 && !need_generic) {
+    DeoptimizeIf(no_condition, instr->environment());
+    return;
+  }
+  Handle<String> name = instr->hydrogen()->name();
+  Label done;
+  for (int i = 0; i < map_count; ++i) {
+    bool last = (i == map_count - 1);
+    Handle<Map> map = instr->hydrogen()->types()->at(i);
+    __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
+    if (last && !need_generic) {
+      DeoptimizeIf(not_equal, instr->environment());
+      EmitLoadFieldOrConstantFunction(result, object, map, name);
+    } else {
       Label next;
-      __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
       __ j(not_equal, &next, Label::kNear);
       EmitLoadFieldOrConstantFunction(result, object, map, name);
       __ jmp(&done, Label::kNear);
       __ bind(&next);
     }
-    if (instr->hydrogen()->need_generic()) {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
-        Label generic;
-        __ j(not_equal, &generic, Label::kNear);
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-        __ jmp(&done, Label::kNear);
-        __ bind(&generic);
-      }
-      __ Move(rcx, instr->hydrogen()->name());
-      Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
-      CallCode(ic, RelocInfo::CODE_TARGET, instr);
-    } else {
-      if (map_count != 0) {
-        Handle<Map> map = instr->hydrogen()->types()->last();
-        __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map);
-        DeoptimizeIf(not_equal, instr->environment());
-        EmitLoadFieldOrConstantFunction(result, object, map, name);
-      } else {
-        DeoptimizeIf(no_condition, instr->environment());
-      }
-    }
-    __ bind(&done);
   }
+  if (need_generic) {
+    __ Move(rcx, name);
+    Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
+    CallCode(ic, RelocInfo::CODE_TARGET, instr);
+  }
+  __ bind(&done);
 }