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 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_X87 | 7 #if V8_TARGET_ARCH_X87 |
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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 __ ret(0); | 137 __ ret(0); |
138 } | 138 } |
139 | 139 |
140 | 140 |
141 // Generate call to api function. | 141 // Generate call to api function. |
142 // This function uses push() to generate smaller, faster code than | 142 // This function uses push() to generate smaller, faster code than |
143 // the version above. It is an optimization that should will be removed | 143 // the version above. It is an optimization that should will be removed |
144 // when api call ICs are generated in hydrogen. | 144 // when api call ICs are generated in hydrogen. |
145 void PropertyHandlerCompiler::GenerateApiAccessorCall( | 145 void PropertyHandlerCompiler::GenerateApiAccessorCall( |
146 MacroAssembler* masm, const CallOptimization& optimization, | 146 MacroAssembler* masm, const CallOptimization& optimization, |
147 Handle<Map> receiver_map, Register receiver, Register scratch_in, | 147 Handle<Map> receiver_map, Register receiver, Register scratch, |
148 bool is_store, Register store_parameter, Register accessor_holder, | 148 bool is_store, Register store_parameter, Register accessor_holder, |
149 int accessor_index) { | 149 int accessor_index) { |
150 DCHECK(!accessor_holder.is(scratch_in)); | 150 DCHECK(!accessor_holder.is(scratch)); |
151 // Copy return value. | 151 // Copy return value. |
152 __ pop(scratch_in); | 152 __ pop(scratch); |
153 // receiver | 153 // receiver |
154 __ push(receiver); | 154 __ push(receiver); |
155 // Write the arguments to stack frame. | 155 // Write the arguments to stack frame. |
156 if (is_store) { | 156 if (is_store) { |
157 DCHECK(!receiver.is(store_parameter)); | 157 DCHECK(!receiver.is(store_parameter)); |
158 DCHECK(!scratch_in.is(store_parameter)); | 158 DCHECK(!scratch.is(store_parameter)); |
159 __ push(store_parameter); | 159 __ push(store_parameter); |
160 } | 160 } |
161 __ push(scratch_in); | 161 __ push(scratch); |
162 // Stack now matches JSFunction abi. | 162 // Stack now matches JSFunction abi. |
163 DCHECK(optimization.is_simple_api_call()); | 163 DCHECK(optimization.is_simple_api_call()); |
164 | 164 |
165 // Abi for CallApiFunctionStub. | 165 // Abi for CallApiFunctionStub. |
166 Register callee = eax; | 166 Register callee = eax; |
167 Register call_data = ebx; | 167 Register data = ebx; |
168 Register holder = ecx; | 168 Register holder = ecx; |
169 Register api_function_address = edx; | 169 Register api_function_address = edx; |
170 Register scratch = edi; // scratch_in is no longer valid. | 170 scratch = no_reg; |
171 | 171 |
172 // Put callee in place. | 172 // Put callee in place. |
173 __ LoadAccessor(callee, accessor_holder, accessor_index, | 173 __ LoadAccessor(callee, accessor_holder, accessor_index, |
174 is_store ? ACCESSOR_SETTER : ACCESSOR_GETTER); | 174 is_store ? ACCESSOR_SETTER : ACCESSOR_GETTER); |
175 | 175 |
176 // Put holder in place. | 176 // Put holder in place. |
177 CallOptimization::HolderLookup holder_lookup; | 177 CallOptimization::HolderLookup holder_lookup; |
178 Handle<JSObject> api_holder = | 178 Handle<JSObject> api_holder = |
179 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); | 179 optimization.LookupHolderOfExpectedType(receiver_map, &holder_lookup); |
180 switch (holder_lookup) { | 180 switch (holder_lookup) { |
181 case CallOptimization::kHolderIsReceiver: | 181 case CallOptimization::kHolderIsReceiver: |
182 __ Move(holder, receiver); | 182 __ Move(holder, receiver); |
183 break; | 183 break; |
184 case CallOptimization::kHolderFound: | 184 case CallOptimization::kHolderFound: |
185 __ LoadHeapObject(holder, api_holder); | 185 __ LoadHeapObject(holder, api_holder); |
186 break; | 186 break; |
187 case CallOptimization::kHolderNotFound: | 187 case CallOptimization::kHolderNotFound: |
188 UNREACHABLE(); | 188 UNREACHABLE(); |
189 break; | 189 break; |
190 } | 190 } |
191 | 191 |
192 Isolate* isolate = masm->isolate(); | 192 Isolate* isolate = masm->isolate(); |
193 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); | 193 Handle<CallHandlerInfo> api_call_info = optimization.api_call_info(); |
194 Handle<Object> call_data_obj(api_call_info->data(), isolate); | |
195 | |
196 bool call_data_undefined = false; | 194 bool call_data_undefined = false; |
197 // Put call_data in place. | 195 // Put call data in place. |
198 if (isolate->heap()->InNewSpace(*call_data_obj)) { | 196 if (api_call_info->data()->IsUndefined()) { |
199 __ mov(scratch, api_call_info); | |
200 __ mov(call_data, FieldOperand(scratch, CallHandlerInfo::kDataOffset)); | |
201 } else if (call_data_obj->IsUndefined()) { | |
202 call_data_undefined = true; | 197 call_data_undefined = true; |
203 __ mov(call_data, Immediate(isolate->factory()->undefined_value())); | 198 __ mov(data, Immediate(isolate->factory()->undefined_value())); |
204 } else { | 199 } else { |
205 __ mov(call_data, call_data_obj); | 200 __ mov(data, FieldOperand(callee, JSFunction::kSharedFunctionInfoOffset)); |
| 201 __ mov(data, FieldOperand(data, SharedFunctionInfo::kFunctionDataOffset)); |
| 202 __ mov(data, FieldOperand(data, FunctionTemplateInfo::kCallCodeOffset)); |
| 203 __ mov(data, FieldOperand(data, CallHandlerInfo::kDataOffset)); |
206 } | 204 } |
207 | 205 |
208 // Put api_function_address in place. | 206 // Put api_function_address in place. |
209 Address function_address = v8::ToCData<Address>(api_call_info->callback()); | 207 Address function_address = v8::ToCData<Address>(api_call_info->callback()); |
210 __ mov(api_function_address, Immediate(function_address)); | 208 __ mov(api_function_address, Immediate(function_address)); |
211 | 209 |
212 // Jump to stub. | 210 // Jump to stub. |
213 CallApiAccessorStub stub(isolate, is_store, call_data_undefined); | 211 CallApiAccessorStub stub(isolate, is_store, call_data_undefined); |
214 __ TailCallStub(&stub); | 212 __ TailCallStub(&stub); |
215 } | 213 } |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
767 // Return the generated code. | 765 // Return the generated code. |
768 return GetCode(kind(), Code::NORMAL, name); | 766 return GetCode(kind(), Code::NORMAL, name); |
769 } | 767 } |
770 | 768 |
771 | 769 |
772 #undef __ | 770 #undef __ |
773 } | 771 } |
774 } // namespace v8::internal | 772 } // namespace v8::internal |
775 | 773 |
776 #endif // V8_TARGET_ARCH_X87 | 774 #endif // V8_TARGET_ARCH_X87 |
OLD | NEW |