| 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 2394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2405 | 2405 |
| 2406 | 2406 |
| 2407 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, | 2407 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, |
| 2408 Register object, | 2408 Register object, |
| 2409 Handle<Map> type, | 2409 Handle<Map> type, |
| 2410 Handle<String> name, | 2410 Handle<String> name, |
| 2411 LEnvironment* env) { | 2411 LEnvironment* env) { |
| 2412 LookupResult lookup(isolate()); | 2412 LookupResult lookup(isolate()); |
| 2413 type->LookupInDescriptors(NULL, *name, &lookup); | 2413 type->LookupInDescriptors(NULL, *name, &lookup); |
| 2414 ASSERT(lookup.IsFound() || lookup.IsCacheable()); | 2414 ASSERT(lookup.IsFound() || lookup.IsCacheable()); |
| 2415 if (lookup.IsFound() && lookup.type() == FIELD) { | 2415 if (lookup.IsField()) { |
| 2416 int index = lookup.GetLocalFieldIndexFromMap(*type); | 2416 int index = lookup.GetLocalFieldIndexFromMap(*type); |
| 2417 int offset = index * kPointerSize; | 2417 int offset = index * kPointerSize; |
| 2418 if (index < 0) { | 2418 if (index < 0) { |
| 2419 // Negative property indices are in-object properties, indexed | 2419 // Negative property indices are in-object properties, indexed |
| 2420 // from the end of the fixed part of the object. | 2420 // from the end of the fixed part of the object. |
| 2421 __ mov(result, FieldOperand(object, offset + type->instance_size())); | 2421 __ mov(result, FieldOperand(object, offset + type->instance_size())); |
| 2422 } else { | 2422 } else { |
| 2423 // Non-negative property indices are in the properties array. | 2423 // Non-negative property indices are in the properties array. |
| 2424 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2424 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
| 2425 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); | 2425 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
| 2426 } | 2426 } |
| 2427 } else if (lookup.IsFound() && lookup.type() == CONSTANT_FUNCTION) { | 2427 } else if (lookup.IsConstantFunction()) { |
| 2428 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); | 2428 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); |
| 2429 __ LoadHeapObject(result, function); | 2429 __ LoadHeapObject(result, function); |
| 2430 } else { | 2430 } else { |
| 2431 // Negative lookup. | 2431 // Negative lookup. |
| 2432 // Check prototypes. | 2432 // Check prototypes. |
| 2433 Handle<HeapObject> current(HeapObject::cast((*type)->prototype())); | 2433 Handle<HeapObject> current(HeapObject::cast((*type)->prototype())); |
| 2434 Heap* heap = type->GetHeap(); | 2434 Heap* heap = type->GetHeap(); |
| 2435 while (*current != heap->null_value()) { | 2435 while (*current != heap->null_value()) { |
| 2436 __ LoadHeapObject(result, current); | 2436 __ LoadHeapObject(result, current); |
| 2437 __ cmp(FieldOperand(result, HeapObject::kMapOffset), | 2437 __ cmp(FieldOperand(result, HeapObject::kMapOffset), |
| (...skipping 24 matching lines...) Expand all Loading... |
| 2462 } | 2462 } |
| 2463 | 2463 |
| 2464 | 2464 |
| 2465 // Check for cases where EmitLoadFieldOrConstantFunction needs to walk the | 2465 // Check for cases where EmitLoadFieldOrConstantFunction needs to walk the |
| 2466 // prototype chain, which causes unbounded code generation. | 2466 // prototype chain, which causes unbounded code generation. |
| 2467 static bool CompactEmit( | 2467 static bool CompactEmit( |
| 2468 SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { | 2468 SmallMapList* list, Handle<String> name, int i, Isolate* isolate) { |
| 2469 LookupResult lookup(isolate); | 2469 LookupResult lookup(isolate); |
| 2470 Handle<Map> map = list->at(i); | 2470 Handle<Map> map = list->at(i); |
| 2471 map->LookupInDescriptors(NULL, *name, &lookup); | 2471 map->LookupInDescriptors(NULL, *name, &lookup); |
| 2472 return lookup.IsFound() && | 2472 return lookup.IsField() || lookup.IsConstantFunction(); |
| 2473 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION); | |
| 2474 } | 2473 } |
| 2475 | 2474 |
| 2476 | 2475 |
| 2477 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | 2476 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
| 2478 Register object = ToRegister(instr->object()); | 2477 Register object = ToRegister(instr->object()); |
| 2479 Register result = ToRegister(instr->result()); | 2478 Register result = ToRegister(instr->result()); |
| 2480 | 2479 |
| 2481 int map_count = instr->hydrogen()->types()->length(); | 2480 int map_count = instr->hydrogen()->types()->length(); |
| 2482 bool need_generic = instr->hydrogen()->need_generic(); | 2481 bool need_generic = instr->hydrogen()->need_generic(); |
| 2483 | 2482 |
| (...skipping 2848 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5332 FixedArray::kHeaderSize - kPointerSize)); | 5331 FixedArray::kHeaderSize - kPointerSize)); |
| 5333 __ bind(&done); | 5332 __ bind(&done); |
| 5334 } | 5333 } |
| 5335 | 5334 |
| 5336 | 5335 |
| 5337 #undef __ | 5336 #undef __ |
| 5338 | 5337 |
| 5339 } } // namespace v8::internal | 5338 } } // namespace v8::internal |
| 5340 | 5339 |
| 5341 #endif // V8_TARGET_ARCH_IA32 | 5340 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |