 Chromium Code Reviews
 Chromium Code Reviews Issue 6708085:
  Enable GVN for polymorphic loads by not expanding them at the HIR level.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
    
  
    Issue 6708085:
  Enable GVN for polymorphic loads by not expanding them at the HIR level.  (Closed) 
  Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/| OLD | NEW | 
|---|---|
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright | 
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. | 
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above | 
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following | 
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided | 
| (...skipping 2104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2115 Register result = ToRegister(instr->result()); | 2115 Register result = ToRegister(instr->result()); | 
| 2116 if (instr->hydrogen()->is_in_object()) { | 2116 if (instr->hydrogen()->is_in_object()) { | 
| 2117 __ mov(result, FieldOperand(object, instr->hydrogen()->offset())); | 2117 __ mov(result, FieldOperand(object, instr->hydrogen()->offset())); | 
| 2118 } else { | 2118 } else { | 
| 2119 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2119 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 
| 2120 __ mov(result, FieldOperand(result, instr->hydrogen()->offset())); | 2120 __ mov(result, FieldOperand(result, instr->hydrogen()->offset())); | 
| 2121 } | 2121 } | 
| 2122 } | 2122 } | 
| 2123 | 2123 | 
| 2124 | 2124 | 
| 2125 void LCodeGen::EmitLoadField(Register result, | |
| 2126 Register object, | |
| 
Kevin Millikin (Chromium)
2011/03/23 08:08:53
Indentation is off here.
 
fschneider
2011/03/23 13:57:56
Done.
 | |
| 2127 Handle<Map> type, | |
| 2128 LookupResult* lookup) { | |
| 2129 ASSERT(lookup->IsProperty() && lookup->type() == FIELD); | |
| 2130 int index = lookup->GetLocalFieldIndexFromMap(*type); | |
| 2131 int offset = index * kPointerSize; | |
| 2132 if (index < 0) { | |
| 2133 // Negative property indices are in-object properties, indexed | |
| 2134 // from the end of the fixed part of the object. | |
| 2135 __ mov(result, FieldOperand(object, offset + type->instance_size())); | |
| 2136 } else { | |
| 2137 // Non-negative property indices are in the properties array. | |
| 2138 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); | |
| 2139 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); | |
| 2140 } | |
| 2141 } | |
| 2142 | |
| 2143 | |
| 2144 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | |
| 2145 Register object = ToRegister(instr->InputAt(0)); | |
| 
Kevin Millikin (Chromium)
2011/03/23 08:08:53
I don't like relying on the order of the operands.
 
fschneider
2011/03/23 13:57:56
Done.
 | |
| 2146 Register result = ToRegister(instr->result()); | |
| 2147 NearLabel done; | |
| 2148 int num_maps = instr->hydrogen()->types()->length(); | |
| 
Kevin Millikin (Chromium)
2011/03/23 08:08:53
map_count is only one character longer and avoids
 
fschneider
2011/03/23 13:57:56
Done.
 | |
| 2149 for (int i = 0; i < num_maps; ++i) { | |
| 2150 Handle<Map> map = instr->hydrogen()->types()->at(i); | |
| 2151 LookupResult lookup; | |
| 2152 map->LookupInDescriptors(NULL, *instr->hydrogen()->name(), &lookup); | |
| 2153 | |
| 2154 NearLabel next; | |
| 2155 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map); | |
| 
Kevin Millikin (Chromium)
2011/03/23 08:08:53
We could avoid multiple loads of the map by using
 
fschneider
2011/03/23 13:57:56
I'll leave it as is in this change. Another way wo
 
Kevin Millikin (Chromium)
2011/03/23 14:17:04
OK, leaving it for later sounds good to me.
 | |
| 2156 if (i == num_maps - 1 && !instr->hydrogen()->need_generic()) { | |
| 2157 DeoptimizeIf(not_equal, instr->environment()); | |
| 2158 } else { | |
| 2159 __ j(not_equal, &next); | |
| 2160 } | |
| 2161 EmitLoadField(result, object, map, &lookup); | |
| 2162 if (i < num_maps - 1 || instr->hydrogen()->need_generic()) { | |
| 
Kevin Millikin (Chromium)
2011/03/23 08:08:53
If you handle all but the last map in the loop, I
 
fschneider
2011/03/23 13:57:56
Done.
 | |
| 2163 __ jmp(&done); | |
| 2164 __ bind(&next); | |
| 2165 } | |
| 2166 } | |
| 2167 if (instr->hydrogen()->need_generic()) { | |
| 2168 __ mov(ecx, instr->hydrogen()->name()); | |
| 2169 Handle<Code> ic( | |
| 2170 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); | |
| 2171 CallCode(ic, RelocInfo::CODE_TARGET, instr, false); | |
| 2172 } | |
| 2173 __ bind(&done); | |
| 2174 } | |
| 2175 | |
| 2176 | |
| 2125 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 2177 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 
| 2126 ASSERT(ToRegister(instr->context()).is(esi)); | 2178 ASSERT(ToRegister(instr->context()).is(esi)); | 
| 2127 ASSERT(ToRegister(instr->object()).is(eax)); | 2179 ASSERT(ToRegister(instr->object()).is(eax)); | 
| 2128 ASSERT(ToRegister(instr->result()).is(eax)); | 2180 ASSERT(ToRegister(instr->result()).is(eax)); | 
| 2129 | 2181 | 
| 2130 __ mov(ecx, instr->name()); | 2182 __ mov(ecx, instr->name()); | 
| 2131 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); | 2183 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); | 
| 2132 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2184 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 
| 2133 } | 2185 } | 
| 2134 | 2186 | 
| (...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4003 ASSERT(osr_pc_offset_ == -1); | 4055 ASSERT(osr_pc_offset_ == -1); | 
| 4004 osr_pc_offset_ = masm()->pc_offset(); | 4056 osr_pc_offset_ = masm()->pc_offset(); | 
| 4005 } | 4057 } | 
| 4006 | 4058 | 
| 4007 | 4059 | 
| 4008 #undef __ | 4060 #undef __ | 
| 4009 | 4061 | 
| 4010 } } // namespace v8::internal | 4062 } } // namespace v8::internal | 
| 4011 | 4063 | 
| 4012 #endif // V8_TARGET_ARCH_IA32 | 4064 #endif // V8_TARGET_ARCH_IA32 | 
| OLD | NEW |