| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 2093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 __ mov(ContextOperand(context, instr->slot_index()), value); | 2104 __ mov(ContextOperand(context, instr->slot_index()), value); |
| 2105 if (instr->needs_write_barrier()) { | 2105 if (instr->needs_write_barrier()) { |
| 2106 Register temp = ToRegister(instr->TempAt(0)); | 2106 Register temp = ToRegister(instr->TempAt(0)); |
| 2107 int offset = Context::SlotOffset(instr->slot_index()); | 2107 int offset = Context::SlotOffset(instr->slot_index()); |
| 2108 __ RecordWrite(context, offset, value, temp); | 2108 __ RecordWrite(context, offset, value, temp); |
| 2109 } | 2109 } |
| 2110 } | 2110 } |
| 2111 | 2111 |
| 2112 | 2112 |
| 2113 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { | 2113 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) { |
| 2114 Register object = ToRegister(instr->InputAt(0)); | 2114 Register object = ToRegister(instr->object()); |
| 2115 Register result = ToRegister(instr->result()); | 2115 Register result = ToRegister(instr->result()); |
| 2116 if (instr->hydrogen()->is_in_object()) { | 2116 if (instr->hydrogen()->is_in_object()) { |
| 2117 __ mov(result, FieldOperand(object, instr->hydrogen()->offset())); | 2117 __ mov(result, FieldOperand(object, instr->hydrogen()->offset())); |
| 2118 } else { | 2118 } else { |
| 2119 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); | 2119 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
| 2120 __ mov(result, FieldOperand(result, instr->hydrogen()->offset())); | 2120 __ mov(result, FieldOperand(result, instr->hydrogen()->offset())); |
| 2121 } | 2121 } |
| 2122 } | 2122 } |
| 2123 | 2123 |
| 2124 | 2124 |
| 2125 void LCodeGen::EmitLoadField(Register result, |
| 2126 Register object, |
| 2127 Handle<Map> type, |
| 2128 LookupResult* lookup) { |
| 2129 ASSERT(lookup->IsProperty() && lookup->type() == FIELD); |
| 2130 int index = lookup->GetLocalFieldIndexFromMap(*type); |
| 2131 int offset = index * kPointerSize; |
| 2132 if (index < 0) { |
| 2133 // Negative property indices are in-object properties, indexed |
| 2134 // from the end of the fixed part of the object. |
| 2135 __ mov(result, FieldOperand(object, offset + type->instance_size())); |
| 2136 } else { |
| 2137 // Non-negative property indices are in the properties array. |
| 2138 __ mov(result, FieldOperand(object, JSObject::kPropertiesOffset)); |
| 2139 __ mov(result, FieldOperand(result, offset + FixedArray::kHeaderSize)); |
| 2140 } |
| 2141 } |
| 2142 |
| 2143 |
| 2144 void LCodeGen::DoLoadNamedFieldPolymorphic(LLoadNamedFieldPolymorphic* instr) { |
| 2145 Register object = ToRegister(instr->object()); |
| 2146 Register result = ToRegister(instr->result()); |
| 2147 NearLabel done; |
| 2148 int map_count = instr->hydrogen()->types()->length(); |
| 2149 for (int i = 0; i < map_count - 1; ++i) { |
| 2150 Handle<Map> map = instr->hydrogen()->types()->at(i); |
| 2151 LookupResult lookup; |
| 2152 map->LookupInDescriptors(NULL, *instr->hydrogen()->name(), &lookup); |
| 2153 NearLabel next; |
| 2154 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map); |
| 2155 __ j(not_equal, &next); |
| 2156 EmitLoadField(result, object, map, &lookup); |
| 2157 __ jmp(&done); |
| 2158 __ bind(&next); |
| 2159 } |
| 2160 if (map_count > 0) { |
| 2161 Handle<Map> map = instr->hydrogen()->types()->at(map_count - 1); |
| 2162 LookupResult lookup; |
| 2163 map->LookupInDescriptors(NULL, *instr->hydrogen()->name(), &lookup); |
| 2164 __ cmp(FieldOperand(object, HeapObject::kMapOffset), map); |
| 2165 if (instr->hydrogen()->need_generic()) { |
| 2166 NearLabel generic; |
| 2167 __ j(not_equal, &generic); |
| 2168 EmitLoadField(result, object, map, &lookup); |
| 2169 __ jmp(&done); |
| 2170 __ bind(&generic); |
| 2171 } else { |
| 2172 DeoptimizeIf(not_equal, instr->environment()); |
| 2173 EmitLoadField(result, object, map, &lookup); |
| 2174 } |
| 2175 } |
| 2176 if (instr->hydrogen()->need_generic()) { |
| 2177 __ mov(ecx, instr->hydrogen()->name()); |
| 2178 Handle<Code> ic( |
| 2179 isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); |
| 2180 CallCode(ic, RelocInfo::CODE_TARGET, instr, false); |
| 2181 } |
| 2182 __ bind(&done); |
| 2183 } |
| 2184 |
| 2185 |
| 2125 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { | 2186 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) { |
| 2126 ASSERT(ToRegister(instr->context()).is(esi)); | 2187 ASSERT(ToRegister(instr->context()).is(esi)); |
| 2127 ASSERT(ToRegister(instr->object()).is(eax)); | 2188 ASSERT(ToRegister(instr->object()).is(eax)); |
| 2128 ASSERT(ToRegister(instr->result()).is(eax)); | 2189 ASSERT(ToRegister(instr->result()).is(eax)); |
| 2129 | 2190 |
| 2130 __ mov(ecx, instr->name()); | 2191 __ mov(ecx, instr->name()); |
| 2131 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); | 2192 Handle<Code> ic(isolate()->builtins()->builtin(Builtins::LoadIC_Initialize)); |
| 2132 CallCode(ic, RelocInfo::CODE_TARGET, instr); | 2193 CallCode(ic, RelocInfo::CODE_TARGET, instr); |
| 2133 } | 2194 } |
| 2134 | 2195 |
| (...skipping 1868 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4003 ASSERT(osr_pc_offset_ == -1); | 4064 ASSERT(osr_pc_offset_ == -1); |
| 4004 osr_pc_offset_ = masm()->pc_offset(); | 4065 osr_pc_offset_ = masm()->pc_offset(); |
| 4005 } | 4066 } |
| 4006 | 4067 |
| 4007 | 4068 |
| 4008 #undef __ | 4069 #undef __ |
| 4009 | 4070 |
| 4010 } } // namespace v8::internal | 4071 } } // namespace v8::internal |
| 4011 | 4072 |
| 4012 #endif // V8_TARGET_ARCH_IA32 | 4073 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |