| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_X87 | 5 #if V8_TARGET_ARCH_X87 |
| 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 { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 __ push(StoreDescriptor::ValueRegister()); | 25 __ push(StoreDescriptor::ValueRegister()); |
| 26 __ push(Immediate(Smi::FromInt(language_mode))); | 26 __ push(Immediate(Smi::FromInt(language_mode))); |
| 27 __ push(ebx); // return address | 27 __ push(ebx); // return address |
| 28 | 28 |
| 29 // Do tail-call to runtime routine. | 29 // Do tail-call to runtime routine. |
| 30 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); | 30 __ TailCallRuntime(Runtime::kSetProperty, 4, 1); |
| 31 } | 31 } |
| 32 | 32 |
| 33 | 33 |
| 34 #undef __ | 34 #undef __ |
| 35 #define __ ACCESS_MASM(masm()) | |
| 36 | |
| 37 Handle<Code> PropertyICCompiler::CompilePolymorphic(MapHandleList* maps, | |
| 38 CodeHandleList* handlers, | |
| 39 Handle<Name> name, | |
| 40 Code::StubType type, | |
| 41 IcCheckType check) { | |
| 42 Label miss; | |
| 43 | |
| 44 if (check == PROPERTY && | |
| 45 (kind() == Code::KEYED_STORE_IC || kind() == Code::KEYED_LOAD_IC)) { | |
| 46 // In case we are compiling an IC for dictionary loads or stores, just | |
| 47 // check whether the name is unique. | |
| 48 if (name.is_identical_to(isolate()->factory()->normal_ic_symbol())) { | |
| 49 // Keyed loads with dictionaries shouldn't be here, they go generic. | |
| 50 // The DCHECK is to protect assumptions when --vector-ics is on. | |
| 51 DCHECK(kind() != Code::KEYED_LOAD_IC); | |
| 52 Register tmp = scratch1(); | |
| 53 __ JumpIfSmi(this->name(), &miss); | |
| 54 __ mov(tmp, FieldOperand(this->name(), HeapObject::kMapOffset)); | |
| 55 __ movzx_b(tmp, FieldOperand(tmp, Map::kInstanceTypeOffset)); | |
| 56 __ JumpIfNotUniqueNameInstanceType(tmp, &miss); | |
| 57 } else { | |
| 58 __ cmp(this->name(), Immediate(name)); | |
| 59 __ j(not_equal, &miss); | |
| 60 } | |
| 61 } | |
| 62 | |
| 63 Label number_case; | |
| 64 Label* smi_target = IncludesNumberMap(maps) ? &number_case : &miss; | |
| 65 __ JumpIfSmi(receiver(), smi_target); | |
| 66 | |
| 67 // Polymorphic keyed stores may use the map register | |
| 68 Register map_reg = scratch1(); | |
| 69 DCHECK(kind() != Code::KEYED_STORE_IC || | |
| 70 map_reg.is(StoreTransitionDescriptor::MapRegister())); | |
| 71 __ mov(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); | |
| 72 int receiver_count = maps->length(); | |
| 73 int number_of_handled_maps = 0; | |
| 74 for (int current = 0; current < receiver_count; ++current) { | |
| 75 Handle<Map> map = maps->at(current); | |
| 76 if (!map->is_deprecated()) { | |
| 77 number_of_handled_maps++; | |
| 78 Handle<WeakCell> cell = Map::WeakCellForMap(map); | |
| 79 __ CmpWeakValue(map_reg, cell, scratch2()); | |
| 80 if (map->instance_type() == HEAP_NUMBER_TYPE) { | |
| 81 DCHECK(!number_case.is_unused()); | |
| 82 __ bind(&number_case); | |
| 83 } | |
| 84 __ j(equal, handlers->at(current)); | |
| 85 } | |
| 86 } | |
| 87 DCHECK(number_of_handled_maps != 0); | |
| 88 | |
| 89 __ bind(&miss); | |
| 90 TailCallBuiltin(masm(), MissBuiltin(kind())); | |
| 91 | |
| 92 // Return the generated code. | |
| 93 InlineCacheState state = | |
| 94 number_of_handled_maps > 1 ? POLYMORPHIC : MONOMORPHIC; | |
| 95 return GetCode(kind(), type, name, state); | |
| 96 } | |
| 97 | |
| 98 | |
| 99 Handle<Code> PropertyICCompiler::CompileKeyedStorePolymorphic( | |
| 100 MapHandleList* receiver_maps, CodeHandleList* handler_stubs, | |
| 101 MapHandleList* transitioned_maps) { | |
| 102 Label miss; | |
| 103 __ JumpIfSmi(receiver(), &miss, Label::kNear); | |
| 104 Register map_reg = scratch1(); | |
| 105 __ mov(map_reg, FieldOperand(receiver(), HeapObject::kMapOffset)); | |
| 106 for (int i = 0; i < receiver_maps->length(); ++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 __ j(equal, handler_stubs->at(i)); | |
| 111 } else { | |
| 112 Label next_map; | |
| 113 __ j(not_equal, &next_map, Label::kNear); | |
| 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 __ jmp(handler_stubs->at(i), RelocInfo::CODE_TARGET); | |
| 120 __ bind(&next_map); | |
| 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 | 35 } // namespace internal |
| 133 } // namespace v8 | 36 } // namespace v8 |
| 134 | 37 |
| 135 #endif // V8_TARGET_ARCH_X87 | 38 #endif // V8_TARGET_ARCH_X87 |
| OLD | NEW |