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

Side by Side Diff: src/arm/lithium-codegen-arm.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
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 2157 matching lines...) Expand 10 before | Expand all | Expand 10 after
2168 Register result = ToRegister(instr->result()); 2168 Register result = ToRegister(instr->result());
2169 if (instr->hydrogen()->is_in_object()) { 2169 if (instr->hydrogen()->is_in_object()) {
2170 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset())); 2170 __ ldr(result, FieldMemOperand(object, instr->hydrogen()->offset()));
2171 } else { 2171 } else {
2172 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); 2172 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2173 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); 2173 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset()));
2174 } 2174 }
2175 } 2175 }
2176 2176
2177 2177
2178 void LCodeGen::EmitLoadField(Register result,
2179 Register object,
2180 Handle<Map> type,
2181 Handle<String> name) {
2182 LookupResult lookup;
2183 type->LookupInDescriptors(NULL, *name, &lookup);
2184 ASSERT(lookup.IsProperty() && lookup.type() == FIELD);
2185 int index = lookup.GetLocalFieldIndexFromMap(*type);
2186 int offset = index * kPointerSize;
2187 if (index < 0) {
2188 // Negative property indices are in-object properties, indexed
2189 // from the end of the fixed part of the object.
2190 __ ldr(result, FieldMemOperand(object, offset + type->instance_size()));
2191 } else {
2192 // Non-negative property indices are in the properties array.
2193 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset));
2194 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize));
2195 }
2196 }
2197
2198
2199 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2200 Register object = ToRegister(instr->object());
2201 Register result = ToRegister(instr->result());
2202 Register scratch = scratch0();
2203 int map_count = instr->hydrogen()->types()->length();
2204 Handle<String> name = instr->hydrogen()->name();
2205 if (map_count == 0) {
2206 ASSERT(instr->hydrogen()->need_generic());
2207 __ mov(r2, Operand(name));
2208 Handle<Code> ic(
2209 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2210 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2211 } else {
2212 Label done;
2213 __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset));
2214 for (int i = 0; i < map_count - 1; ++i) {
2215 Handle<Map> map = instr->hydrogen()->types()->at(i);
2216 Label next;
2217 __ cmp(scratch, Operand(map));
2218 __ b(ne, &next);
2219 EmitLoadField(result, object, map, name);
2220 __ b(&done);
2221 __ bind(&next);
2222 }
2223 Handle<Map> map = instr->hydrogen()->types()->last();
2224 __ cmp(scratch, Operand(map));
2225 if (instr->hydrogen()->need_generic()) {
2226 Label generic;
2227 __ b(ne, &generic);
2228 EmitLoadField(result, object, map, name);
Kevin Millikin (Chromium) 2011/03/24 09:28:25 BTW, you can write a single call to EmitLoadField
2229 __ b(&done);
2230 __ bind(&generic);
2231 __ mov(r2, Operand(name));
2232 Handle<Code> ic(
2233 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2234 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2235 } else {
2236 DeoptimizeIf(ne, instr->environment());
2237 EmitLoadField(result, object, map, name);
2238 }
2239 __ bind(&done);
2240 }
2241 }
2242
2243
2178 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2244 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2179 ASSERT(ToRegister(instr->object()).is(r0)); 2245 ASSERT(ToRegister(instr->object()).is(r0));
2180 ASSERT(ToRegister(instr->result()).is(r0)); 2246 ASSERT(ToRegister(instr->result()).is(r0));
2181 2247
2182 // Name is always in r2. 2248 // Name is always in r2.
2183 __ mov(r2, Operand(instr->name())); 2249 __ mov(r2, Operand(instr->name()));
2184 Handle<Code> ic( 2250 Handle<Code> ic(
2185 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); 2251 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize));
2186 CallCode(ic, RelocInfo::CODE_TARGET, instr); 2252 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2187 } 2253 }
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after
3972 ASSERT(!environment->HasBeenRegistered()); 4038 ASSERT(!environment->HasBeenRegistered());
3973 RegisterEnvironmentForDeoptimization(environment); 4039 RegisterEnvironmentForDeoptimization(environment);
3974 ASSERT(osr_pc_offset_ == -1); 4040 ASSERT(osr_pc_offset_ == -1);
3975 osr_pc_offset_ = masm()->pc_offset(); 4041 osr_pc_offset_ = masm()->pc_offset();
3976 } 4042 }
3977 4043
3978 4044
3979 #undef __ 4045 #undef __
3980 4046
3981 } } // namespace v8::internal 4047 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-codegen-arm.h ('k') | src/hydrogen.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698