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 2542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2553 } else { | 2553 } else { |
2554 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 2554 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
2555 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); | 2555 __ ldr(result, FieldMemOperand(result, instr->hydrogen()->offset())); |
2556 } | 2556 } |
2557 } | 2557 } |
2558 | 2558 |
2559 | 2559 |
2560 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, | 2560 void LCodeGen::EmitLoadFieldOrConstantFunction(Register result, |
2561 Register object, | 2561 Register object, |
2562 Handle<Map> type, | 2562 Handle<Map> type, |
2563 Handle<String> name) { | 2563 Handle<String> name, |
| 2564 LEnvironment* env) { |
2564 LookupResult lookup(isolate()); | 2565 LookupResult lookup(isolate()); |
2565 type->LookupInDescriptors(NULL, *name, &lookup); | 2566 type->LookupInDescriptors(NULL, *name, &lookup); |
2566 ASSERT(lookup.IsFound() && | 2567 ASSERT(lookup.IsFound() || lookup.IsCacheable()); |
2567 (lookup.type() == FIELD || lookup.type() == CONSTANT_FUNCTION)); | 2568 if (lookup.IsFound() && lookup.type() == FIELD) { |
2568 if (lookup.type() == FIELD) { | |
2569 int index = lookup.GetLocalFieldIndexFromMap(*type); | 2569 int index = lookup.GetLocalFieldIndexFromMap(*type); |
2570 int offset = index * kPointerSize; | 2570 int offset = index * kPointerSize; |
2571 if (index < 0) { | 2571 if (index < 0) { |
2572 // Negative property indices are in-object properties, indexed | 2572 // Negative property indices are in-object properties, indexed |
2573 // from the end of the fixed part of the object. | 2573 // from the end of the fixed part of the object. |
2574 __ ldr(result, FieldMemOperand(object, offset + type->instance_size())); | 2574 __ ldr(result, FieldMemOperand(object, offset + type->instance_size())); |
2575 } else { | 2575 } else { |
2576 // Non-negative property indices are in the properties array. | 2576 // Non-negative property indices are in the properties array. |
2577 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); | 2577 __ ldr(result, FieldMemOperand(object, JSObject::kPropertiesOffset)); |
2578 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize)); | 2578 __ ldr(result, FieldMemOperand(result, offset + FixedArray::kHeaderSize)); |
2579 } | 2579 } |
2580 } else { | 2580 } else if (lookup.IsFound() && lookup.type() == CONSTANT_FUNCTION) { |
2581 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); | 2581 Handle<JSFunction> function(lookup.GetConstantFunctionFromMap(*type)); |
2582 __ LoadHeapObject(result, function); | 2582 __ LoadHeapObject(result, function); |
| 2583 } else { |
| 2584 // Negative lookup. |
| 2585 // Check prototypes. |
| 2586 HeapObject* current = HeapObject::cast((*type)->prototype()); |
| 2587 Heap* heap = type->GetHeap(); |
| 2588 while (current != heap->null_value()) { |
| 2589 Handle<HeapObject> link(current); |
| 2590 __ LoadHeapObject(result, link); |
| 2591 __ ldr(result, FieldMemOperand(result, HeapObject::kMapOffset)); |
| 2592 __ cmp(result, Operand(Handle<Map>(JSObject::cast(current)->map()))); |
| 2593 DeoptimizeIf(ne, env); |
| 2594 current = HeapObject::cast(current->map()->prototype()); |
| 2595 } |
| 2596 __ LoadRoot(result, Heap::kUndefinedValueRootIndex); |
2583 } | 2597 } |
2584 } | 2598 } |
2585 | 2599 |
2586 | 2600 |
2587 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { | 2601 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
2588 Register object = ToRegister(instr->object()); | 2602 Register object = ToRegister(instr->object()); |
2589 Register result = ToRegister(instr->result()); | 2603 Register result = ToRegister(instr->result()); |
2590 Register scratch = scratch0(); | 2604 Register object_map = scratch0(); |
2591 | 2605 |
2592 int map_count = instr->hydrogen()->types()->length(); | 2606 int map_count = instr->hydrogen()->types()->length(); |
2593 bool need_generic = instr->hydrogen()->need_generic(); | 2607 bool need_generic = instr->hydrogen()->need_generic(); |
2594 | 2608 |
2595 if (map_count == 0 && !need_generic) { | 2609 if (map_count == 0 && !need_generic) { |
2596 DeoptimizeIf(al, instr->environment()); | 2610 DeoptimizeIf(al, instr->environment()); |
2597 return; | 2611 return; |
2598 } | 2612 } |
2599 Handle<String> name = instr->hydrogen()->name(); | 2613 Handle<String> name = instr->hydrogen()->name(); |
2600 Label done; | 2614 Label done; |
2601 __ ldr(scratch, FieldMemOperand(object, HeapObject::kMapOffset)); | 2615 __ ldr(object_map, FieldMemOperand(object, HeapObject::kMapOffset)); |
2602 for (int i = 0; i < map_count; ++i) { | 2616 for (int i = 0; i < map_count; ++i) { |
2603 bool last = (i == map_count - 1); | 2617 bool last = (i == map_count - 1); |
2604 Handle<Map> map = instr->hydrogen()->types()->at(i); | 2618 Handle<Map> map = instr->hydrogen()->types()->at(i); |
2605 __ cmp(scratch, Operand(map)); | 2619 Label check_passed; |
| 2620 __ CompareMap( |
| 2621 object_map, map, &check_passed, ALLOW_ELEMENT_TRANSITION_MAPS); |
2606 if (last && !need_generic) { | 2622 if (last && !need_generic) { |
2607 DeoptimizeIf(ne, instr->environment()); | 2623 DeoptimizeIf(ne, instr->environment()); |
2608 EmitLoadFieldOrConstantFunction(result, object, map, name); | 2624 __ bind(&check_passed); |
| 2625 EmitLoadFieldOrConstantFunction( |
| 2626 result, object, map, name, instr->environment()); |
2609 } else { | 2627 } else { |
2610 Label next; | 2628 Label next; |
2611 __ b(ne, &next); | 2629 __ b(ne, &next); |
2612 EmitLoadFieldOrConstantFunction(result, object, map, name); | 2630 __ bind(&check_passed); |
| 2631 EmitLoadFieldOrConstantFunction( |
| 2632 result, object, map, name, instr->environment()); |
2613 __ b(&done); | 2633 __ b(&done); |
2614 __ bind(&next); | 2634 __ bind(&next); |
2615 } | 2635 } |
2616 } | 2636 } |
2617 if (need_generic) { | 2637 if (need_generic) { |
2618 __ mov(r2, Operand(name)); | 2638 __ mov(r2, Operand(name)); |
2619 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); | 2639 Handle<Code> ic = isolate()->builtins()->LoadIC_Initialize(); |
2620 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2640 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
2621 } | 2641 } |
2622 __ bind(&done); | 2642 __ bind(&done); |
(...skipping 2741 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5364 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); | 5384 __ sub(scratch, result, Operand(index, LSL, kPointerSizeLog2 - kSmiTagSize)); |
5365 __ ldr(result, FieldMemOperand(scratch, | 5385 __ ldr(result, FieldMemOperand(scratch, |
5366 FixedArray::kHeaderSize - kPointerSize)); | 5386 FixedArray::kHeaderSize - kPointerSize)); |
5367 __ bind(&done); | 5387 __ bind(&done); |
5368 } | 5388 } |
5369 | 5389 |
5370 | 5390 |
5371 #undef __ | 5391 #undef __ |
5372 | 5392 |
5373 } } // namespace v8::internal | 5393 } } // namespace v8::internal |
OLD | NEW |