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 2190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 Register result = ToRegister(instr->result()); | 2201 Register result = ToRegister(instr->result()); |
2202 if (instr->hydrogen()->is_in_object()) { | 2202 if (instr->hydrogen()->is_in_object()) { |
2203 __ movq(result, FieldOperand(object, instr->hydrogen()->offset())); | 2203 __ movq(result, FieldOperand(object, instr->hydrogen()->offset())); |
2204 } else { | 2204 } else { |
2205 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2205 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
2206 __ movq(result, FieldOperand(result, instr->hydrogen()->offset())); | 2206 __ movq(result, FieldOperand(result, instr->hydrogen()->offset())); |
2207 } | 2207 } |
2208 } | 2208 } |
2209 | 2209 |
2210 | 2210 |
2211 void LCodeGen::EmitLoadField(Register result, | 2211 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, |
2212 Register object, | 2212 Register object, |
2213 Handle<Map> type, | 2213 Handle<Map> type, |
2214 Handle<String> name) { | 2214 Handle<String> name) { |
2215 LookupResult lookup; | 2215 LookupResult lookup; |
2216 type->LookupInDescriptors(NULL, *name, &lookup); | 2216 type->LookupInDescriptors(NULL, *name, &lookup); |
2217 ASSERT(lookup.IsProperty() && lookup.type() == FIELD); | 2217 ASSERT(lookup.IsProperty() && |
2218 int index = lookup.GetLocalFieldIndexFromMap(*type); | 2218 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION)); |
2219 int offset = index * kPointerSize; | 2219 if (lookup.type() == FIELD) { |
2220 if (index < 0) { | 2220 int index = lookup.GetLocalFieldIndexFromMap(*type); |
2221 // Negative property indices are in-object properties, indexed | 2221 int offset = index * kPointerSize; |
2222 // from the end of the fixed part of the object. | 2222 if (index < 0) { |
2223 __ movq(result, FieldOperand(object, offset + type->instance_size())); | 2223 // Negative property indices are in-object properties, indexed |
| 2224 // from the end of the fixed part of the object. |
| 2225 __ movq(result, FieldOperand(object, offset + type->instance_size())); |
| 2226 } else { |
| 2227 // Non-negative property indices are in the properties array. |
| 2228 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
| 2229 __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
| 2230 } |
2224 } else { | 2231 } else { |
2225 // Non-negative property indices are in the properties array. | 2232 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); |
2226 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2233 LoadHeapObject(result, Handle<HeapObject>::cast(function)); |
2227 __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); | |
2228 } | 2234 } |
2229 } | 2235 } |
2230 | 2236 |
2231 | 2237 |
2232 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | 2238 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
2233 Register object = ToRegister(instr->object()); | 2239 Register object = ToRegister(instr->object()); |
2234 Register result = ToRegister(instr->result()); | 2240 Register result = ToRegister(instr->result()); |
2235 | 2241 |
2236 int map_count = instr->hydrogen()->types()->length(); | 2242 int map_count = instr->hydrogen()->types()->length(); |
2237 Handle<String> name = instr->hydrogen()->name(); | 2243 Handle<String> name = instr->hydrogen()->name(); |
2238 | 2244 |
2239 if (map_count == 0) { | 2245 if (map_count == 0) { |
2240 ASSERT(instr->hydrogen()->need_generic()); | 2246 ASSERT(instr->hydrogen()->need_generic()); |
2241 __ Move(rcx, instr->hydrogen()->name()); | 2247 __ Move(rcx, instr->hydrogen()->name()); |
2242 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 2248 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
2243 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2249 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2244 } else { | 2250 } else { |
2245 NearLabel done; | 2251 NearLabel done; |
2246 for (int i = 0; i < map_count - 1; ++i) { | 2252 for (int i = 0; i < map_count - 1; ++i) { |
2247 Handle<Map> map = instr->hydrogen()->types()->at(i); | 2253 Handle<Map> map = instr->hydrogen()->types()->at(i); |
2248 NearLabel next; | 2254 NearLabel next; |
2249 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map); | 2255 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map); |
2250 __ j(not_equal, &next); | 2256 __ j(not_equal, &next); |
2251 EmitLoadField(result, object, map, name); | 2257 EmitLoadFieldOrConstantFunction(result, object, map, name); |
2252 __ jmp(&done); | 2258 __ jmp(&done); |
2253 __ bind(&next); | 2259 __ bind(&next); |
2254 } | 2260 } |
2255 Handle<Map> map = instr->hydrogen()->types()->last(); | 2261 Handle<Map> map = instr->hydrogen()->types()->last(); |
2256 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map); | 2262 __ Cmp(FieldOperand(object, HeapObject::kMapOffset), map); |
2257 if (instr->hydrogen()->need_generic()) { | 2263 if (instr->hydrogen()->need_generic()) { |
2258 NearLabel generic; | 2264 NearLabel generic; |
2259 __ j(not_equal, &generic); | 2265 __ j(not_equal, &generic); |
2260 EmitLoadField(result, object, map, name); | 2266 EmitLoadFieldOrConstantFunction(result, object, map, name); |
2261 __ jmp(&done); | 2267 __ jmp(&done); |
2262 __ bind(&generic); | 2268 __ bind(&generic); |
2263 __ Move(rcx, instr->hydrogen()->name()); | 2269 __ Move(rcx, instr->hydrogen()->name()); |
2264 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 2270 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
2265 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2271 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2266 } else { | 2272 } else { |
2267 DeoptimizeIf(not_equal, instr->environment()); | 2273 DeoptimizeIf(not_equal, instr->environment()); |
2268 EmitLoadField(result, object, map, name); | 2274 EmitLoadFieldOrConstantFunction(result, object, map, name); |
2269 } | 2275 } |
2270 __ bind(&done); | 2276 __ bind(&done); |
2271 } | 2277 } |
2272 } | 2278 } |
2273 | 2279 |
2274 | 2280 |
2275 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 2281 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
2276 ASSERT(ToRegister(instr->object()).is(rax)); | 2282 ASSERT(ToRegister(instr->object()).is(rax)); |
2277 ASSERT(ToRegister(instr->result()).is(rax)); | 2283 ASSERT(ToRegister(instr->result()).is(rax)); |
2278 | 2284 |
(...skipping 1817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4096 RegisterEnvironmentForDeoptimization(environment); | 4102 RegisterEnvironmentForDeoptimization(environment); |
4097 ASSERT(osr_pc_offset_ == -1); | 4103 ASSERT(osr_pc_offset_ == -1); |
4098 osr_pc_offset_ = masm()->pc_offset(); | 4104 osr_pc_offset_ = masm()->pc_offset(); |
4099 } | 4105 } |
4100 | 4106 |
4101 #undef __ | 4107 #undef __ |
4102 | 4108 |
4103 } } // namespace v8::internal | 4109 } } // namespace v8::internal |
4104 | 4110 |
4105 #endif // V8_TARGET_ARCH_X64 | 4111 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |