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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 Address address_; | 191 Address address_; |
192 IC::UtilityId id_; | 192 IC::UtilityId id_; |
193 }; | 193 }; |
194 | 194 |
195 | 195 |
196 class CallICBase: public IC { | 196 class CallICBase: public IC { |
197 public: | 197 public: |
198 class Contextual: public BitField<bool, 0, 1> {}; | 198 class Contextual: public BitField<bool, 0, 1> {}; |
199 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; | 199 class StringStubState: public BitField<StringStubFeedback, 1, 1> {}; |
200 | 200 |
201 protected: | |
202 CallICBase(Code::Kind kind, Isolate* isolate) | |
203 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} | |
204 | |
205 public: | |
206 // Returns a JSFunction or a Failure. | 201 // Returns a JSFunction or a Failure. |
207 MUST_USE_RESULT MaybeObject* LoadFunction(State state, | 202 MUST_USE_RESULT MaybeObject* LoadFunction(State state, |
208 Code::ExtraICState extra_ic_state, | 203 Code::ExtraICState extra_ic_state, |
209 Handle<Object> object, | 204 Handle<Object> object, |
210 Handle<String> name); | 205 Handle<String> name); |
211 | 206 |
212 protected: | 207 protected: |
213 Code::Kind kind_; | 208 CallICBase(Code::Kind kind, Isolate* isolate) |
| 209 : IC(EXTRA_CALL_FRAME, isolate), kind_(kind) {} |
214 | 210 |
215 bool TryUpdateExtraICState(LookupResult* lookup, | 211 bool TryUpdateExtraICState(LookupResult* lookup, |
216 Handle<Object> object, | 212 Handle<Object> object, |
217 Code::ExtraICState* extra_ic_state); | 213 Code::ExtraICState* extra_ic_state); |
218 | 214 |
219 // Compute a monomorphic stub if possible, otherwise return a null handle. | 215 // Compute a monomorphic stub if possible, otherwise return a null handle. |
220 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup, | 216 Handle<Code> ComputeMonomorphicStub(LookupResult* lookup, |
221 State state, | 217 State state, |
222 Code::ExtraICState extra_state, | 218 Code::ExtraICState extra_state, |
223 Handle<Object> object, | 219 Handle<Object> object, |
224 Handle<String> name); | 220 Handle<String> name); |
225 | 221 |
226 // Update the inline cache and the global stub cache based on the lookup | 222 // Update the inline cache and the global stub cache based on the lookup |
227 // result. | 223 // result. |
228 void UpdateCaches(LookupResult* lookup, | 224 void UpdateCaches(LookupResult* lookup, |
229 State state, | 225 State state, |
230 Code::ExtraICState extra_ic_state, | 226 Code::ExtraICState extra_ic_state, |
231 Handle<Object> object, | 227 Handle<Object> object, |
232 Handle<String> name); | 228 Handle<String> name); |
233 | 229 |
234 // Returns a JSFunction if the object can be called as a function, and | 230 // Returns a JSFunction if the object can be called as a function, and |
235 // patches the stack to be ready for the call. Otherwise, it returns the | 231 // patches the stack to be ready for the call. Otherwise, it returns the |
236 // undefined value. | 232 // undefined value. |
237 Handle<Object> TryCallAsFunction(Handle<Object> object); | 233 Handle<Object> TryCallAsFunction(Handle<Object> object); |
238 | 234 |
239 void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); | 235 void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); |
240 | 236 |
241 static void Clear(Address address, Code* target); | 237 static void Clear(Address address, Code* target); |
242 | 238 |
| 239 // Platform-specific generation of misses for call and keyed call. |
| 240 static void GenerateMiss(MacroAssembler* masm, |
| 241 int argc, |
| 242 IC::UtilityId id, |
| 243 Code::ExtraICState extra_state); |
| 244 |
| 245 Code::Kind kind_; |
| 246 |
243 friend class IC; | 247 friend class IC; |
244 }; | 248 }; |
245 | 249 |
246 | 250 |
247 class CallIC: public CallICBase { | 251 class CallIC: public CallICBase { |
248 public: | 252 public: |
249 explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { | 253 explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { |
250 ASSERT(target()->is_call_stub()); | 254 ASSERT(target()->is_call_stub()); |
251 } | 255 } |
252 | 256 |
253 // Code generator routines. | 257 // Code generator routines. |
254 static void GenerateInitialize(MacroAssembler* masm, | 258 static void GenerateInitialize(MacroAssembler* masm, |
255 int argc, | 259 int argc, |
256 Code::ExtraICState extra_ic_state) { | 260 Code::ExtraICState extra_state) { |
257 GenerateMiss(masm, argc, extra_ic_state); | 261 GenerateMiss(masm, argc, extra_state); |
258 } | 262 } |
| 263 |
259 static void GenerateMiss(MacroAssembler* masm, | 264 static void GenerateMiss(MacroAssembler* masm, |
260 int argc, | 265 int argc, |
261 Code::ExtraICState extra_ic_state); | 266 Code::ExtraICState extra_state) { |
| 267 CallICBase::GenerateMiss(masm, argc, IC::kCallIC_Miss, extra_state); |
| 268 } |
| 269 |
262 static void GenerateMegamorphic(MacroAssembler* masm, | 270 static void GenerateMegamorphic(MacroAssembler* masm, |
263 int argc, | 271 int argc, |
264 Code::ExtraICState extra_ic_state); | 272 Code::ExtraICState extra_ic_state); |
| 273 |
265 static void GenerateNormal(MacroAssembler* masm, int argc); | 274 static void GenerateNormal(MacroAssembler* masm, int argc); |
266 }; | 275 }; |
267 | 276 |
268 | 277 |
269 class KeyedCallIC: public CallICBase { | 278 class KeyedCallIC: public CallICBase { |
270 public: | 279 public: |
271 explicit KeyedCallIC(Isolate* isolate) | 280 explicit KeyedCallIC(Isolate* isolate) |
272 : CallICBase(Code::KEYED_CALL_IC, isolate) { | 281 : CallICBase(Code::KEYED_CALL_IC, isolate) { |
273 ASSERT(target()->is_keyed_call_stub()); | 282 ASSERT(target()->is_keyed_call_stub()); |
274 } | 283 } |
275 | 284 |
276 MUST_USE_RESULT MaybeObject* LoadFunction(State state, | 285 MUST_USE_RESULT MaybeObject* LoadFunction(State state, |
277 Handle<Object> object, | 286 Handle<Object> object, |
278 Handle<Object> key); | 287 Handle<Object> key); |
279 | 288 |
280 // Code generator routines. | 289 // Code generator routines. |
281 static void GenerateInitialize(MacroAssembler* masm, int argc) { | 290 static void GenerateInitialize(MacroAssembler* masm, int argc) { |
282 GenerateMiss(masm, argc); | 291 GenerateMiss(masm, argc); |
283 } | 292 } |
284 static void GenerateMiss(MacroAssembler* masm, int argc); | 293 |
| 294 static void GenerateMiss(MacroAssembler* masm, int argc) { |
| 295 CallICBase::GenerateMiss(masm, argc, IC::kKeyedCallIC_Miss, |
| 296 Code::kNoExtraICState); |
| 297 } |
| 298 |
285 static void GenerateMegamorphic(MacroAssembler* masm, int argc); | 299 static void GenerateMegamorphic(MacroAssembler* masm, int argc); |
286 static void GenerateNormal(MacroAssembler* masm, int argc); | 300 static void GenerateNormal(MacroAssembler* masm, int argc); |
287 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); | 301 static void GenerateNonStrictArguments(MacroAssembler* masm, int argc); |
288 }; | 302 }; |
289 | 303 |
290 | 304 |
291 class LoadIC: public IC { | 305 class LoadIC: public IC { |
292 public: | 306 public: |
293 explicit LoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { | 307 explicit LoadIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { |
294 ASSERT(target()->is_load_stub()); | 308 ASSERT(target()->is_load_stub()); |
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 void patch(Code* code); | 744 void patch(Code* code); |
731 }; | 745 }; |
732 | 746 |
733 | 747 |
734 // Helper for BinaryOpIC and CompareIC. | 748 // Helper for BinaryOpIC and CompareIC. |
735 void PatchInlinedSmiCode(Address address); | 749 void PatchInlinedSmiCode(Address address); |
736 | 750 |
737 } } // namespace v8::internal | 751 } } // namespace v8::internal |
738 | 752 |
739 #endif // V8_IC_H_ | 753 #endif // V8_IC_H_ |
OLD | NEW |