| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2279 | 2279 |
| 2280 | 2280 |
| 2281 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, | 2281 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, |
| 2282 Register object, | 2282 Register object, |
| 2283 Handle<Map> type, | 2283 Handle<Map> type, |
| 2284 Handle<String> name, | 2284 Handle<String> name, |
| 2285 LEnvironment* env) { | 2285 LEnvironment* env) { |
| 2286 LookupResult lookup(isolate()); | 2286 LookupResult lookup(isolate()); |
| 2287 type->LookupInDescriptors(NULL, *name, &lookup); | 2287 type->LookupInDescriptors(NULL, *name, &lookup); |
| 2288 ASSERT(lookup.IsFound() || lookup.IsCacheable()); | 2288 ASSERT(lookup.IsFound() || lookup.IsCacheable()); |
| 2289 if (lookup.IsFound() && lookup.type() == FIELD) { | 2289 if (lookup.IsField()) { |
| 2290 int index = lookup.GetLocalFieldIndexFromMap(*type); | 2290 int index = lookup.GetLocalFieldIndexFromMap(*type); |
| 2291 int offset = index * kPointerSize; | 2291 int offset = index * kPointerSize; |
| 2292 if (index < 0) { | 2292 if (index < 0) { |
| 2293 // Negative property indices are in-object properties, indexed | 2293 // Negative property indices are in-object properties, indexed |
| 2294 // from the end of the fixed part of the object. | 2294 // from the end of the fixed part of the object. |
| 2295 __ movq(result, FieldOperand(object, offset + type->instance_size())); | 2295 __ movq(result, FieldOperand(object, offset + type->instance_size())); |
| 2296 } else { | 2296 } else { |
| 2297 // Non-negative property indices are in the properties array. | 2297 // Non-negative property indices are in the properties array. |
| 2298 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2298 __ movq(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
| 2299 __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); | 2299 __ movq(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
| 2300 } | 2300 } |
| 2301 } else if (lookup.IsFound() && lookup.type() == CONSTANT_FUNCTION) { | 2301 } else if (lookup.IsConstantFunction()) { |
| 2302 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); | 2302 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); |
| 2303 __ LoadHeapObject(result, function); | 2303 __ LoadHeapObject(result, function); |
| 2304 } else { | 2304 } else { |
| 2305 // Negative lookup. | 2305 // Negative lookup. |
| 2306 // Check prototypes. | 2306 // Check prototypes. |
| 2307 Handle<HeapObject> current(HeapObject::cast((*type)->prototype())); | 2307 Handle<HeapObject> current(HeapObject::cast((*type)->prototype())); |
| 2308 Heap* heap = type->GetHeap(); | 2308 Heap* heap = type->GetHeap(); |
| 2309 while (*current != heap->null_value()) { | 2309 while (*current != heap->null_value()) { |
| 2310 __ LoadHeapObject(result, current); | 2310 __ LoadHeapObject(result, current); |
| 2311 __ Cmp(FieldOperand(result, HeapObject::kMapOffset), | 2311 __ Cmp(FieldOperand(result, HeapObject::kMapOffset), |
| 2312 Handle<Map>(current->map())); | 2312 Handle<Map>(current->map())); |
| 2313 DeoptimizeIf(not_equal, env); | 2313 DeoptimizeIf(not_equal, env); |
| 2314 current = | 2314 current = |
| 2315 Handle<HeapObject>(HeapObject::cast(current->map()->prototype())); | 2315 Handle<HeapObject>(HeapObject::cast(current->map()->prototype())); |
| 2316 } | 2316 } |
| 2317 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); | 2317 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
| 2318 } | 2318 } |
| 2319 } | 2319 } |
| 2320 | 2320 |
| 2321 | 2321 |
| 2322 // Check for cases where EmitLoadFieldOrConstantFunction needs to walk the | 2322 // Check for cases where EmitLoadFieldOrConstantFunction needs to walk the |
| 2323 // prototype chain, which causes unbounded code generation. | 2323 // prototype chain, which causes unbounded code generation. |
| 2324 static bool CompactEmit( | 2324 static bool CompactEmit( |
| 2325 SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { | 2325 SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { |
| 2326 LookupResult lookup(isolate); | 2326 LookupResult lookup(isolate); |
| 2327 Handle<Map> map = list->at(i); | 2327 Handle<Map> map = list->at(i); |
| 2328 map->LookupInDescriptors(NULL, *name, &lookup); | 2328 map->LookupInDescriptors(NULL, *name, &lookup); |
| 2329 return lookup.IsFound() && | 2329 return lookup.IsField() || lookup.IsConstantFunction(); |
| 2330 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION); | |
| 2331 } | 2330 } |
| 2332 | 2331 |
| 2333 | 2332 |
| 2334 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | 2333 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
| 2335 Register object = ToRegister(instr->object()); | 2334 Register object = ToRegister(instr->object()); |
| 2336 Register result = ToRegister(instr->result()); | 2335 Register result = ToRegister(instr->result()); |
| 2337 | 2336 |
| 2338 int map_count = instr->hydrogen()->types()->length(); | 2337 int map_count = instr->hydrogen()->types()->length(); |
| 2339 bool need_generic = instr->hydrogen()->need_generic(); | 2338 bool need_generic = instr->hydrogen()->need_generic(); |
| 2340 | 2339 |
| (...skipping 2690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5031 FixedArray::kHeaderSize - kPointerSize)); | 5030 FixedArray::kHeaderSize - kPointerSize)); |
| 5032 __ bind(&done); | 5031 __ bind(&done); |
| 5033 } | 5032 } |
| 5034 | 5033 |
| 5035 | 5034 |
| 5036 #undef __ | 5035 #undef __ |
| 5037 | 5036 |
| 5038 } } // namespace v8::internal | 5037 } } // namespace v8::internal |
| 5039 | 5038 |
| 5040 #endif // V8_TARGET_ARCH_X64 | 5039 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |