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

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

Issue 6930005: Support polymorphic loads of constant functions as well as fields. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Implement arm and x64 part Created 9 years, 7 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/ia32/lithium-codegen-ia32.h ('k') | src/x64/lithium-codegen-x64.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 2182 matching lines...) Expand 10 before | Expand all | Expand 10 after
2193 Register result = ToRegister(instr->result()); 2193 Register result = ToRegister(instr->result());
2194 if (instr->hydrogen()->is_in_object()) { 2194 if (instr->hydrogen()->is_in_object()) {
2195 __ mov(result, FieldOperand(object, instr->hydrogen()->offset())); 2195 __ mov(result, FieldOperand(object, instr->hydrogen()->offset()));
2196 } else { 2196 } else {
2197 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); 2197 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset));
2198 __ mov(result, FieldOperand(result, instr->hydrogen()->offset())); 2198 __ mov(result, FieldOperand(result, instr->hydrogen()->offset()));
2199 } 2199 }
2200 } 2200 }
2201 2201
2202 2202
2203 void LCodeGen::EmitLoadField(Register result, 2203 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result,
2204 Register object, 2204 Register object,
2205 Handle<Map> type, 2205 Handle<Map> type,
2206 Handle<String> name) { 2206 Handle<String> name) {
2207 LookupResult lookup; 2207 LookupResult lookup;
2208 type->LookupInDescriptors(NULL, *name, &lookup); 2208 type->LookupInDescriptors(NULL, *name, &lookup);
2209 ASSERT(lookup.IsProperty() && lookup.type() == FIELD); 2209 ASSERT(lookup.IsProperty() &&
2210 int index = lookup.GetLocalFieldIndexFromMap(*type); 2210 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION));
2211 int offset = index * kPointerSize; 2211 if (lookup.type() == FIELD) {
2212 if (index < 0) { 2212 int index = lookup.GetLocalFieldIndexFromMap(*type);
2213 // Negative property indices are in-object properties, indexed 2213 int offset = index * kPointerSize;
2214 // from the end of the fixed part of the object. 2214 if (index < 0) {
2215 __ mov(result, FieldOperand(object, offset + type->instance_size())); 2215 // Negative property indices are in-object properties, indexed
2216 // from the end of the fixed part of the object.
2217 __ mov(result, FieldOperand(object, offset + type->instance_size()));
2218 } else {
2219 // Non-negative property indices are in the properties array.
2220 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset));
2221 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2222 }
2216 } else { 2223 } else {
2217 // Non-negative property indices are in the properties array. 2224 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type));
2218 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); 2225 LoadHeapObject(result, Handle<HeapObject>::cast(function));
2219 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize));
2220 } 2226 }
2221 } 2227 }
2222 2228
2223 2229
2224 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { 2230 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) {
2225 Register object = ToRegister(instr->object()); 2231 Register object = ToRegister(instr->object());
2226 Register result = ToRegister(instr->result()); 2232 Register result = ToRegister(instr->result());
2227 2233
2228 int map_count = instr->hydrogen()->types()->length(); 2234 int map_count = instr->hydrogen()->types()->length();
2229 Handle<String> name = instr->hydrogen()->name(); 2235 Handle<String> name = instr->hydrogen()->name();
2230 if (map_count == 0) { 2236 if (map_count == 0) {
2231 ASSERT(instr->hydrogen()->need_generic()); 2237 ASSERT(instr->hydrogen()->need_generic());
2232 __ mov(ecx, name); 2238 __ mov(ecx, name);
2233 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2239 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2234 CallCode(ic, RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT); 2240 CallCode(ic, RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT);
2235 } else { 2241 } else {
2236 NearLabel done; 2242 NearLabel done;
2237 for (int i = 0; i < map_count - 1; ++i) { 2243 for (int i = 0; i < map_count - 1; ++i) {
2238 Handle<Map> map = instr->hydrogen()->types()->at(i); 2244 Handle<Map> map = instr->hydrogen()->types()->at(i);
2239 NearLabel next; 2245 NearLabel next;
2240 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map); 2246 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2241 __ j(not_equal, &next); 2247 __ j(not_equal, &next);
2242 EmitLoadField(result, object, map, name); 2248 EmitLoadFieldOrConstantFunction(result, object, map, name);
2243 __ jmp(&done); 2249 __ jmp(&done);
2244 __ bind(&next); 2250 __ bind(&next);
2245 } 2251 }
2246 Handle<Map> map = instr->hydrogen()->types()->last(); 2252 Handle<Map> map = instr->hydrogen()->types()->last();
2247 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map); 2253 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map);
2248 if (instr->hydrogen()->need_generic()) { 2254 if (instr->hydrogen()->need_generic()) {
2249 NearLabel generic; 2255 NearLabel generic;
2250 __ j(not_equal, &generic); 2256 __ j(not_equal, &generic);
2251 EmitLoadField(result, object, map, name); 2257 EmitLoadFieldOrConstantFunction(result, object, map, name);
2252 __ jmp(&done); 2258 __ jmp(&done);
2253 __ bind(&generic); 2259 __ bind(&generic);
2254 __ mov(ecx, name); 2260 __ mov(ecx, name);
2255 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); 2261 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize();
2256 CallCode(ic, RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT); 2262 CallCode(ic, RelocInfo::CODE_TARGET, instr, RESTORE_CONTEXT);
2257 } else { 2263 } else {
2258 DeoptimizeIf(not_equal, instr->environment()); 2264 DeoptimizeIf(not_equal, instr->environment());
2259 EmitLoadField(result, object, map, name); 2265 EmitLoadFieldOrConstantFunction(result, object, map, name);
2260 } 2266 }
2261 __ bind(&done); 2267 __ bind(&done);
2262 } 2268 }
2263 } 2269 }
2264 2270
2265 2271
2266 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { 2272 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2267 ASSERT(ToRegister(instr->context()).is(esi)); 2273 ASSERT(ToRegister(instr->context()).is(esi));
2268 ASSERT(ToRegister(instr->object()).is(eax)); 2274 ASSERT(ToRegister(instr->object()).is(eax));
2269 ASSERT(ToRegister(instr->result()).is(eax)); 2275 ASSERT(ToRegister(instr->result()).is(eax));
(...skipping 2029 matching lines...) Expand 10 before | Expand all | Expand 10 after
4299 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset)); 4305 __ mov(esi, Operand(ebp, StandardFrameConstants::kContextOffset));
4300 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator); 4306 __ InvokeBuiltin(Builtins::IN, CALL_FUNCTION, safepoint_generator);
4301 } 4307 }
4302 4308
4303 4309
4304 #undef __ 4310 #undef __
4305 4311
4306 } } // namespace v8::internal 4312 } } // namespace v8::internal
4307 4313
4308 #endif // V8_TARGET_ARCH_IA32 4314 #endif // V8_TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « src/ia32/lithium-codegen-ia32.h ('k') | src/x64/lithium-codegen-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698