| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #if V8_TARGET_ARCH_PPC | 5 #if V8_TARGET_ARCH_PPC |
| 6 | 6 |
| 7 #include "src/ic/ic.h" | 7 #include "src/ic/ic.h" |
| 8 #include "src/ic/ic-compiler.h" | 8 #include "src/ic/ic-compiler.h" |
| 9 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| 11 namespace internal { | 11 namespace internal { |
| 12 | 12 |
| 13 #define __ ACCESS_MASM(masm) | 13 #define __ ACCESS_MASM(masm) |
| 14 | 14 |
| 15 | 15 |
| 16 void PropertyICCompiler::GenerateRuntimeSetProperty( | 16 void PropertyICCompiler::GenerateRuntimeSetProperty( |
| 17 MacroAssembler* masm, LanguageMode language_mode) { | 17 MacroAssembler* masm, LanguageMode language_mode) { |
| 18 __ mov(r0, Operand(Smi::FromInt(language_mode))); | 18 __ mov(r0, Operand(Smi::FromInt(language_mode))); |
| 19 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), | 19 __ Push(StoreDescriptor::ReceiverRegister(), StoreDescriptor::NameRegister(), |
| 20 StoreDescriptor::ValueRegister(), r0); | 20 StoreDescriptor::ValueRegister(), r0); |
| 21 | 21 |
| 22 // Do tail-call to runtime routine. | 22 // Do tail-call to runtime routine. |
| 23 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 23 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
| 24 } | 24 } |
| 25 | 25 |
| 26 | 26 |
| 27 #undef __ | 27 #undef __ |
| 28 #define __ ACCESS_MASM(masm()) | |
| 29 | |
| 30 | |
| 31 Handle<Code> PropertyICCompiler::CompilePolymorphic(MapHandleList* maps, | |
| 32 CodeHandleList* handlers, | |
| 33 Handle<Name> name, | |
| 34 Code::StubType type, | |
| 35 IcCheckType check) { | |
| 36 Label miss; | |
| 37 | |
| 38 if (check == PROPERTY && | |
| 39 (kind() == Code::KEYED_LOAD_IC || kind() == Code::KEYED_STORE_IC)) { | |
| 40 // In case we are compiling an IC for dictionary loads or stores, just | |
| 41 // check whether the name is unique. | |
| 42 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | |
| 43 // Keyed loads with dictionaries shouldn't be here, they go generic. | |
| 44 // The DCHECK is to protect assumptions when --vector-ics is on. | |
| 45 DCHECK(kind() != Code::KEYED_LOAD_IC); | |
| 46 Register tmp = scratch1(); | |
| 47 __ JumpIfSmi(this->name(), &miss); | |
| 48 __ LoadP(tmp, FieldMemOperand(this->name(), HeapObject::kMapOffset)); | |
| 49 __ lbz(tmp, FieldMemOperand(tmp, Map::kInstanceTypeOffset)); | |
| 50 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); | |
| 51 } else { | |
| 52 __ Cmpi(this->name(), Operand(name), r0); | |
| 53 __ bne(&miss); | |
| 54 } | |
| 55 } | |
| 56 | |
| 57 Label number_case; | |
| 58 Label* smi_target = IncludesNumberMap(maps) ? &number_case : &miss; | |
| 59 __ JumpIfSmi(receiver(), smi_target); | |
| 60 | |
| 61 // Polymorphic keyed stores may use the map register | |
| 62 Register map_reg = scratch1(); | |
| 63 DCHECK(kind() != Code::KEYED_STORE_IC || | |
| 64 map_reg.is(StoreTransitionDescriptor::MapRegister())); | |
| 65 | |
| 66 int receiver_count = maps->length(); | |
| 67 int number_of_handled_maps = 0; | |
| 68 __ LoadP(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
| 69 for (int current = 0; current < receiver_count; ++current) { | |
| 70 Handle<Map> map = maps->at(current); | |
| 71 if (!map->is_deprecated()) { | |
| 72 number_of_handled_maps++; | |
| 73 Handle<WeakCell> cell = Map::WeakCellForMap(map); | |
| 74 __ CmpWeakValue(map_reg, cell, scratch2()); | |
| 75 Label next; | |
| 76 __ bne(&next); | |
| 77 if (map->instance_type() == HEAP_NUMBER_TYPE) { | |
| 78 DCHECK(!number_case.is_unused()); | |
| 79 __ bind(&number_case); | |
| 80 } | |
| 81 __ Jump(handlers->at(current), RelocInfo::CODE_TARGET); | |
| 82 __ bind(&next); | |
| 83 } | |
| 84 } | |
| 85 DCHECK(number_of_handled_maps != 0); | |
| 86 | |
| 87 __ bind(&miss); | |
| 88 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
| 89 | |
| 90 // Return the generated code. | |
| 91 InlineCacheState state = | |
| 92 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; | |
| 93 return GetCode(kind(), type, name, state); | |
| 94 } | |
| 95 | |
| 96 | |
| 97 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | |
| 98 MapHandleList* receiver_maps, CodeHandleList* handler_stubs, | |
| 99 MapHandleList* transitioned_maps) { | |
| 100 Label miss; | |
| 101 __ JumpIfSmi(receiver(), &miss); | |
| 102 | |
| 103 int receiver_count = receiver_maps->length(); | |
| 104 Register map_reg = scratch1(); | |
| 105 __ LoadP(map_reg, FieldMemOperand(receiver(), HeapObject::kMapOffset)); | |
| 106 for (int i = 0; i < receiver_count; ++i) { | |
| 107 Handle<WeakCell> cell = Map::WeakCellForMap(receiver_maps->at(i)); | |
| 108 __ CmpWeakValue(map_reg, cell, scratch2()); | |
| 109 if (transitioned_maps->at(i).is_null()) { | |
| 110 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, eq); | |
| 111 } else { | |
| 112 Label next_map; | |
| 113 __ bne(&next_map); | |
| 114 Handle<WeakCell> cell = Map::WeakCellForMap(transitioned_maps->at(i)); | |
| 115 Register transition_map = scratch1(); | |
| 116 DCHECK(!FLAG_vector_stores && | |
| 117 transition_map.is(StoreTransitionDescriptor::MapRegister())); | |
| 118 __ LoadWeakValue(transition_map, cell, &miss); | |
| 119 __ Jump(handler_stubs->at(i), RelocInfo::CODE_TARGET, al); | |
| 120 __ bind(&next_map); | |
| 121 } | |
| 122 } | |
| 123 | |
| 124 __ bind(&miss); | |
| 125 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
| 126 | |
| 127 // Return the generated code. | |
| 128 return GetCode(kind(), Code::NORMAL, factory()->empty_string(), POLYMORPHIC); | |
| 129 } | |
| 130 | |
| 131 | |
| 132 #undef __ | |
| 133 } // namespace internal | 28 } // namespace internal |
| 134 } // namespace v8 | 29 } // namespace v8 |
| 135 | 30 |
| 136 #endif // V8_TARGET_ARCH_PPC | 31 #endif // V8_TARGET_ARCH_PPC |
| OLD | NEW |