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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/ic/call-optimization.h" | 9 #include "src/ic/call-optimization.h" |
10 #include "src/ic/handler-compiler.h" | 10 #include "src/ic/handler-compiler.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 134 } |
135 | 135 |
136 | 136 |
137 // Generate call to api function. | 137 // Generate call to api function. |
138 // This function uses push() to generate smaller, faster code than | 138 // This function uses push() to generate smaller, faster code than |
139 // the version above. It is an optimization that should will be removed | 139 // the version above. It is an optimization that should will be removed |
140 // when api call ICs are generated in hydrogen. | 140 // when api call ICs are generated in hydrogen. |
141 void PropertyHandlerCompiler::GenerateApiAccessorCall( | 141 void PropertyHandlerCompiler::GenerateApiAccessorCall( |
142 MacroAssembler* masm, const CallOptimization& optimization, | 142 MacroAssembler* masm, const CallOptimization& optimization, |
143 Handle<Map> receiver_map, Register receiver, Register scratch_in, | 143 Handle<Map> receiver_map, Register receiver, Register scratch_in, |
144 bool is_store, Register store_parameter) { | 144 bool is_store, Register store_parameter, Register accessor_holder, |
| 145 int accessor_index) { |
| 146 DCHECK(!accessor_holder.is(scratch_in)); |
145 // Copy return value. | 147 // Copy return value. |
146 __ pop(scratch_in); | 148 __ pop(scratch_in); |
147 // receiver | 149 // receiver |
148 __ push(receiver); | 150 __ push(receiver); |
149 // Write the arguments to stack frame. | 151 // Write the arguments to stack frame. |
150 if (is_store) { | 152 if (is_store) { |
151 DCHECK(!receiver.is(store_parameter)); | 153 DCHECK(!receiver.is(store_parameter)); |
152 DCHECK(!scratch_in.is(store_parameter)); | 154 DCHECK(!scratch_in.is(store_parameter)); |
153 __ push(store_parameter); | 155 __ push(store_parameter); |
154 } | 156 } |
155 __ push(scratch_in); | 157 __ push(scratch_in); |
156 // Stack now matches JSFunction abi. | 158 // Stack now matches JSFunction abi. |
157 DCHECK(optimization.is_simple_api_call()); | 159 DCHECK(optimization.is_simple_api_call()); |
158 | 160 |
159 // Abi for CallApiFunctionStub. | 161 // Abi for CallApiFunctionStub. |
160 Register callee = edi; | 162 Register callee = edi; |
161 Register call_data = ebx; | 163 Register call_data = ebx; |
162 Register holder = ecx; | 164 Register holder = ecx; |
163 Register api_function_address = edx; | 165 Register api_function_address = edx; |
164 Register scratch = eax; // scratch_in is no longer valid. | 166 Register scratch = eax; // scratch_in is no longer valid. |
165 | 167 |
| 168 // Put callee in place. |
| 169 __ LoadAccessor(callee, accessor_holder, accessor_index, |
| 170 is_store ? ACCESSOR_SETTER : ACCESSOR_GETTER); |
| 171 |
166 // Put holder in place. | 172 // Put holder in place. |
167 CallOptimization::HolderLookup holder_lookup; | 173 CallOptimization::HolderLookup holder_lookup; |
168 Handle<JSObject> api_holder = | 174 Handle<JSObject> api_holder = |
169 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); | 175 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); |
170 switch (holder_lookup) { | 176 switch (holder_lookup) { |
171 case CallOptimization::kHolderIsReceiver: | 177 case CallOptimization::kHolderIsReceiver: |
172 __ Move(holder, receiver); | 178 __ Move(holder, receiver); |
173 break; | 179 break; |
174 case CallOptimization::kHolderFound: | 180 case CallOptimization::kHolderFound: |
175 __ LoadHeapObject(holder, api_holder); | 181 __ LoadHeapObject(holder, api_holder); |
176 break; | 182 break; |
177 case CallOptimization::kHolderNotFound: | 183 case CallOptimization::kHolderNotFound: |
178 UNREACHABLE(); | 184 UNREACHABLE(); |
179 break; | 185 break; |
180 } | 186 } |
181 | 187 |
182 Isolate* isolate = masm->isolate(); | 188 Isolate* isolate = masm->isolate(); |
183 Handle<JSFunction> function = optimization.constant_function(); | |
184 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 189 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
185 Handle<Object> call_data_obj(api_call_info->data(), isolate); | 190 Handle<Object> call_data_obj(api_call_info->data(), isolate); |
186 | 191 |
187 // Put callee in place. | |
188 __ LoadHeapObject(callee, function); | |
189 | 192 |
190 bool call_data_undefined = false; | 193 bool call_data_undefined = false; |
191 // Put call_data in place. | 194 // Put call_data in place. |
192 if (isolate->heap()->InNewSpace(*call_data_obj)) { | 195 if (isolate->heap()->InNewSpace(*call_data_obj)) { |
193 __ mov(scratch, api_call_info); | 196 __ mov(scratch, api_call_info); |
194 __ mov(call_data, FieldOperand(scratch, CallHandlerInfo::kDataOffset)); | 197 __ mov(call_data, FieldOperand(scratch, CallHandlerInfo::kDataOffset)); |
195 } else if (call_data_obj->IsUndefined()) { | 198 } else if (call_data_obj->IsUndefined()) { |
196 call_data_undefined = true; | 199 call_data_undefined = true; |
197 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); | 200 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); |
198 } else { | 201 } else { |
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
756 // Return the generated code. | 759 // Return the generated code. |
757 return GetCode(kind(), Code::NORMAL, name); | 760 return GetCode(kind(), Code::NORMAL, name); |
758 } | 761 } |
759 | 762 |
760 | 763 |
761 #undef __ | 764 #undef __ |
762 } | 765 } |
763 } // namespace v8::internal | 766 } // namespace v8::internal |
764 | 767 |
765 #endif // V8_TARGET_ARCH_IA32 | 768 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |