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