Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Side by Side Diff: src/ia32/lithium-codegen-ia32.cc

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/
Patch Set: '' Created 9 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after
2104 __ mov(ContextOperand(context, instr->slot_index()), value); 2104 __ mov(ContextOperand(context, instr->slot_index()), value);
2105 if (instr->needs_write_barrier()) { 2105 if (instr->needs_write_barrier()) {
2106 Register temp = ToRegister(instr->TempAt(0)); 2106 Register temp = ToRegister(instr->TempAt(0));
2107 int offset = Context::SlotOffset(instr->slot_index()); 2107 int offset = Context::SlotOffset(instr->slot_index());
2108 __ RecordWrite(context, offset, value, temp); 2108 __ RecordWrite(context, offset, value, temp);
2109 } 2109 }
2110 } 2110 }
2111 2111
2112 2112
2113 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { 2113 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
2114 Register object = ToRegister(instr->InputAt(0)); 2114 Register object = ToRegister(instr->object());
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,
2127 Handle<Map> type,
2128 Handle<String> name) {
2129 LookupResult lookup;
2130 type->LookupInDescriptors(NULL, *name, &lookup);
2131 ASSERT(lookup.IsProperty() && lookup.type() == FIELD);
2132 int index = lookup.GetLocalFieldIndexFromMap(*type);
2133 int offset = index * kPointerSize;
2134 if (index < 0) {
2135 // Negative property indices are in-object properties, indexed
2136 // from the end of the fixed part of the object.
2137 __ mov(result, FieldOperand(object, offset + type->instance_size()));
2138 } else {
2139 // Non-negative property indices are in the properties array.
2140 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset));
2141 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2142 }
2143 }
2144
2145
2146 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2147 Register object = ToRegister(instr->object());
2148 Register result = ToRegister(instr->result());
2149
2150 int map_count = instr->hydrogen()->types()->length();
2151 Handle<String> name = instr->hydrogen()->name();
2152 if (map_count == 0) {
2153 ASSERT(instr->hydrogen()->need_generic());
2154 __ mov(ecx, name);
2155 Handle<Code> ic(
2156 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2157 CallCode(ic, RelocInfo::CODE_TARGET, instr, false);
2158 } else {
2159 NearLabel done;
2160 for (int i = 0; i < map_count - 1; ++i) {
2161 Handle<Map> map = instr->hydrogen()->types()->at(i);
2162 NearLabel next;
2163 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2164 __ j(not_equal, &next);
2165 EmitLoadField(result, object, map, name);
2166 __ jmp(&done);
2167 __ bind(&next);
2168 }
2169 Handle<Map> map = instr->hydrogen()->types()->last();
2170 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2171 if (instr->hydrogen()->need_generic()) {
2172 NearLabel generic;
2173 __ j(not_equal, &generic);
2174 EmitLoadField(result, object, map, name);
2175 __ jmp(&done);
2176 __ bind(&generic);
2177 __ mov(ecx, name);
2178 Handle<Code> ic(
2179 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2180 CallCode(ic, RelocInfo::CODE_TARGET, instr, false);
2181 } else {
2182 DeoptimizeIf(not_equal, instr->environment());
2183 EmitLoadField(result, object, map, name);
2184 }
2185 __ bind(&done);
2186 }
2187 }
2188
2189
2125 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2190 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2126 ASSERT(ToRegister(instr->context()).is(esi)); 2191 ASSERT(ToRegister(instr->context()).is(esi));
2127 ASSERT(ToRegister(instr->object()).is(eax)); 2192 ASSERT(ToRegister(instr->object()).is(eax));
2128 ASSERT(ToRegister(instr->result()).is(eax)); 2193 ASSERT(ToRegister(instr->result()).is(eax));
2129 2194
2130 __ mov(ecx, instr->name()); 2195 __ mov(ecx, instr->name());
2131 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); 2196 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2132 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2197 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2133 } 2198 }
2134 2199
(...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after
4003 ASSERT(osr_pc_offset_ == -1); 4068 ASSERT(osr_pc_offset_ == -1);
4004 osr_pc_offset_ = masm()->pc_offset(); 4069 osr_pc_offset_ = masm()->pc_offset();
4005 } 4070 }
4006 4071
4007 4072
4008 #undef __ 4073 #undef __
4009 4074
4010 } } // namespace v8::internal 4075 } } // namespace v8::internal
4011 4076
4012 #endif // V8_TARGET_ARCH_IA32 4077 #endif // V8_TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698