| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 IC::UtilityId id_; | 186 IC::UtilityId id_; |
| 187 }; | 187 }; |
| 188 | 188 |
| 189 | 189 |
| 190 class CallICBase: public IC { | 190 class CallICBase: public IC { |
| 191 protected: | 191 protected: |
| 192 explicit CallICBase(Code::Kind kind) : IC(EXTRA_CALL_FRAME), kind_(kind) {} | 192 explicit CallICBase(Code::Kind kind) : IC(EXTRA_CALL_FRAME), kind_(kind) {} |
| 193 | 193 |
| 194 public: | 194 public: |
| 195 MUST_USE_RESULT MaybeObject* LoadFunction(State state, | 195 MUST_USE_RESULT MaybeObject* LoadFunction(State state, |
| 196 Code::ExtraICState extra_ic_state, |
| 196 Handle<Object> object, | 197 Handle<Object> object, |
| 197 Handle<String> name); | 198 Handle<String> name); |
| 198 | 199 |
| 199 protected: | 200 protected: |
| 200 Code::Kind kind_; | 201 Code::Kind kind_; |
| 201 | 202 |
| 203 bool TryUpdateExtraICState(LookupResult* lookup, |
| 204 Handle<Object> object, |
| 205 Code::ExtraICState* extra_ic_state); |
| 206 |
| 207 MUST_USE_RESULT MaybeObject* ComputeMonomorphicStub( |
| 208 LookupResult* lookup, |
| 209 State state, |
| 210 Code::ExtraICState extra_ic_state, |
| 211 Handle<Object> object, |
| 212 Handle<String> name); |
| 213 |
| 202 // Update the inline cache and the global stub cache based on the | 214 // Update the inline cache and the global stub cache based on the |
| 203 // lookup result. | 215 // lookup result. |
| 204 void UpdateCaches(LookupResult* lookup, | 216 void UpdateCaches(LookupResult* lookup, |
| 205 State state, | 217 State state, |
| 218 Code::ExtraICState extra_ic_state, |
| 206 Handle<Object> object, | 219 Handle<Object> object, |
| 207 Handle<String> name); | 220 Handle<String> name); |
| 208 | 221 |
| 209 // Returns a JSFunction if the object can be called as a function, | 222 // Returns a JSFunction if the object can be called as a function, |
| 210 // and patches the stack to be ready for the call. | 223 // and patches the stack to be ready for the call. |
| 211 // Otherwise, it returns the undefined value. | 224 // Otherwise, it returns the undefined value. |
| 212 Object* TryCallAsFunction(Object* object); | 225 Object* TryCallAsFunction(Object* object); |
| 213 | 226 |
| 214 void ReceiverToObject(Handle<Object> object); | 227 void ReceiverToObject(Handle<Object> object); |
| 215 | 228 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 264 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 277 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 265 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 278 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 266 GenerateMiss(masm); | 279 GenerateMiss(masm); |
| 267 } | 280 } |
| 268 static void GenerateMiss(MacroAssembler* masm); | 281 static void GenerateMiss(MacroAssembler* masm); |
| 269 static void GenerateMegamorphic(MacroAssembler* masm); | 282 static void GenerateMegamorphic(MacroAssembler* masm); |
| 270 static void GenerateNormal(MacroAssembler* masm); | 283 static void GenerateNormal(MacroAssembler* masm); |
| 271 | 284 |
| 272 // Specialized code generator routines. | 285 // Specialized code generator routines. |
| 273 static void GenerateArrayLength(MacroAssembler* masm); | 286 static void GenerateArrayLength(MacroAssembler* masm); |
| 274 static void GenerateStringLength(MacroAssembler* masm); | 287 static void GenerateStringLength(MacroAssembler* masm, |
| 288 bool support_wrappers); |
| 275 static void GenerateFunctionPrototype(MacroAssembler* masm); | 289 static void GenerateFunctionPrototype(MacroAssembler* masm); |
| 276 | 290 |
| 277 // Clear the use of the inlined version. | 291 // Clear the use of the inlined version. |
| 278 static void ClearInlinedVersion(Address address); | 292 static void ClearInlinedVersion(Address address); |
| 279 | 293 |
| 280 // The offset from the inlined patch site to the start of the | 294 // The offset from the inlined patch site to the start of the |
| 281 // inlined load instruction. It is architecture-dependent, and not | 295 // inlined load instruction. It is architecture-dependent, and not |
| 282 // used on ARM. | 296 // used on ARM. |
| 283 static const int kOffsetToLoadInstruction; | 297 static const int kOffsetToLoadInstruction; |
| 284 | 298 |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // Code generator routines. | 339 // Code generator routines. |
| 326 static void GenerateMiss(MacroAssembler* masm); | 340 static void GenerateMiss(MacroAssembler* masm); |
| 327 static void GenerateRuntimeGetProperty(MacroAssembler* masm); | 341 static void GenerateRuntimeGetProperty(MacroAssembler* masm); |
| 328 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 342 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 329 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 343 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
| 330 GenerateMiss(masm); | 344 GenerateMiss(masm); |
| 331 } | 345 } |
| 332 static void GenerateGeneric(MacroAssembler* masm); | 346 static void GenerateGeneric(MacroAssembler* masm); |
| 333 static void GenerateString(MacroAssembler* masm); | 347 static void GenerateString(MacroAssembler* masm); |
| 334 | 348 |
| 335 // Generators for external array types. See objects.h. | |
| 336 // These are similar to the generic IC; they optimize the case of | |
| 337 // operating upon external array types but fall back to the runtime | |
| 338 // for all other types. | |
| 339 static void GenerateExternalArray(MacroAssembler* masm, | |
| 340 ExternalArrayType array_type); | |
| 341 static void GenerateIndexedInterceptor(MacroAssembler* masm); | 349 static void GenerateIndexedInterceptor(MacroAssembler* masm); |
| 342 | 350 |
| 343 // Clear the use of the inlined version. | 351 // Clear the use of the inlined version. |
| 344 static void ClearInlinedVersion(Address address); | 352 static void ClearInlinedVersion(Address address); |
| 345 | 353 |
| 346 // Bit mask to be tested against bit field for the cases when | 354 // Bit mask to be tested against bit field for the cases when |
| 347 // generic stub should go into slow case. | 355 // generic stub should go into slow case. |
| 348 // Access check is necessary explicitly since generic stub does not perform | 356 // Access check is necessary explicitly since generic stub does not perform |
| 349 // map checks. | 357 // map checks. |
| 350 static const int kSlowCaseBitFieldMask = | 358 static const int kSlowCaseBitFieldMask = |
| (...skipping 15 matching lines...) Expand all Loading... |
| 366 } | 374 } |
| 367 static Code* generic_stub() { | 375 static Code* generic_stub() { |
| 368 return Builtins::builtin(Builtins::KeyedLoadIC_Generic); | 376 return Builtins::builtin(Builtins::KeyedLoadIC_Generic); |
| 369 } | 377 } |
| 370 static Code* pre_monomorphic_stub() { | 378 static Code* pre_monomorphic_stub() { |
| 371 return Builtins::builtin(Builtins::KeyedLoadIC_PreMonomorphic); | 379 return Builtins::builtin(Builtins::KeyedLoadIC_PreMonomorphic); |
| 372 } | 380 } |
| 373 static Code* string_stub() { | 381 static Code* string_stub() { |
| 374 return Builtins::builtin(Builtins::KeyedLoadIC_String); | 382 return Builtins::builtin(Builtins::KeyedLoadIC_String); |
| 375 } | 383 } |
| 376 static Code* external_array_stub(JSObject::ElementsKind elements_kind); | |
| 377 | 384 |
| 378 static Code* indexed_interceptor_stub() { | 385 static Code* indexed_interceptor_stub() { |
| 379 return Builtins::builtin(Builtins::KeyedLoadIC_IndexedInterceptor); | 386 return Builtins::builtin(Builtins::KeyedLoadIC_IndexedInterceptor); |
| 380 } | 387 } |
| 381 | 388 |
| 382 static void Clear(Address address, Code* target); | 389 static void Clear(Address address, Code* target); |
| 383 | 390 |
| 384 // Support for patching the map that is checked in an inlined | 391 // Support for patching the map that is checked in an inlined |
| 385 // version of keyed load. | 392 // version of keyed load. |
| 386 static bool PatchInlinedLoad(Address address, Object* map); | 393 static bool PatchInlinedLoad(Address address, Object* map); |
| 387 | 394 |
| 388 friend class IC; | 395 friend class IC; |
| 389 }; | 396 }; |
| 390 | 397 |
| 391 | 398 |
| 392 class StoreIC: public IC { | 399 class StoreIC: public IC { |
| 393 public: | 400 public: |
| 401 |
| 402 enum StoreICStrictMode { |
| 403 kStoreICNonStrict = kNonStrictMode, |
| 404 kStoreICStrict = kStrictMode |
| 405 }; |
| 406 |
| 394 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } | 407 StoreIC() : IC(NO_EXTRA_FRAME) { ASSERT(target()->is_store_stub()); } |
| 395 | 408 |
| 396 MUST_USE_RESULT MaybeObject* Store(State state, | 409 MUST_USE_RESULT MaybeObject* Store(State state, |
| 410 Code::ExtraICState extra_ic_state, |
| 397 Handle<Object> object, | 411 Handle<Object> object, |
| 398 Handle<String> name, | 412 Handle<String> name, |
| 399 Handle<Object> value); | 413 Handle<Object> value); |
| 400 | 414 |
| 401 // Code generators for stub routines. Only called once at startup. | 415 // Code generators for stub routines. Only called once at startup. |
| 402 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 416 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 403 static void GenerateMiss(MacroAssembler* masm); | 417 static void GenerateMiss(MacroAssembler* masm); |
| 404 static void GenerateMegamorphic(MacroAssembler* masm); | 418 static void GenerateMegamorphic(MacroAssembler* masm, |
| 419 Code::ExtraICState extra_ic_state); |
| 405 static void GenerateArrayLength(MacroAssembler* masm); | 420 static void GenerateArrayLength(MacroAssembler* masm); |
| 406 static void GenerateNormal(MacroAssembler* masm); | 421 static void GenerateNormal(MacroAssembler* masm); |
| 407 static void GenerateGlobalProxy(MacroAssembler* masm); | 422 static void GenerateGlobalProxy(MacroAssembler* masm); |
| 408 | 423 |
| 409 // Clear the use of an inlined version. | 424 // Clear the use of an inlined version. |
| 410 static void ClearInlinedVersion(Address address); | 425 static void ClearInlinedVersion(Address address); |
| 411 | 426 |
| 412 // The offset from the inlined patch site to the start of the | 427 // The offset from the inlined patch site to the start of the |
| 413 // inlined store instruction. | 428 // inlined store instruction. |
| 414 static const int kOffsetToStoreInstruction; | 429 static const int kOffsetToStoreInstruction; |
| 415 | 430 |
| 416 private: | 431 private: |
| 417 // Update the inline cache and the global stub cache based on the | 432 // Update the inline cache and the global stub cache based on the |
| 418 // lookup result. | 433 // lookup result. |
| 419 void UpdateCaches(LookupResult* lookup, | 434 void UpdateCaches(LookupResult* lookup, |
| 420 State state, Handle<JSObject> receiver, | 435 State state, |
| 436 Code::ExtraICState extra_ic_state, |
| 437 Handle<JSObject> receiver, |
| 421 Handle<String> name, | 438 Handle<String> name, |
| 422 Handle<Object> value); | 439 Handle<Object> value); |
| 423 | 440 |
| 424 // Stub accessors. | 441 // Stub accessors. |
| 425 static Code* megamorphic_stub() { | 442 static Code* megamorphic_stub() { |
| 426 return Builtins::builtin(Builtins::StoreIC_Megamorphic); | 443 return Builtins::builtin(Builtins::StoreIC_Megamorphic); |
| 427 } | 444 } |
| 445 static Code* megamorphic_stub_strict() { |
| 446 return Builtins::builtin(Builtins::StoreIC_Megamorphic_Strict); |
| 447 } |
| 428 static Code* initialize_stub() { | 448 static Code* initialize_stub() { |
| 429 return Builtins::builtin(Builtins::StoreIC_Initialize); | 449 return Builtins::builtin(Builtins::StoreIC_Initialize); |
| 430 } | 450 } |
| 451 static Code* initialize_stub_strict() { |
| 452 return Builtins::builtin(Builtins::StoreIC_Initialize_Strict); |
| 453 } |
| 431 static Code* global_proxy_stub() { | 454 static Code* global_proxy_stub() { |
| 432 return Builtins::builtin(Builtins::StoreIC_GlobalProxy); | 455 return Builtins::builtin(Builtins::StoreIC_GlobalProxy); |
| 433 } | 456 } |
| 457 static Code* global_proxy_stub_strict() { |
| 458 return Builtins::builtin(Builtins::StoreIC_GlobalProxy_Strict); |
| 459 } |
| 434 | 460 |
| 435 static void Clear(Address address, Code* target); | 461 static void Clear(Address address, Code* target); |
| 436 | 462 |
| 437 // Support for patching the index and the map that is checked in an | 463 // Support for patching the index and the map that is checked in an |
| 438 // inlined version of the named store. | 464 // inlined version of the named store. |
| 439 static bool PatchInlinedStore(Address address, Object* map, int index); | 465 static bool PatchInlinedStore(Address address, Object* map, int index); |
| 440 | 466 |
| 441 friend class IC; | 467 friend class IC; |
| 442 }; | 468 }; |
| 443 | 469 |
| 444 | 470 |
| 445 class KeyedStoreIC: public IC { | 471 class KeyedStoreIC: public IC { |
| 446 public: | 472 public: |
| 447 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } | 473 KeyedStoreIC() : IC(NO_EXTRA_FRAME) { } |
| 448 | 474 |
| 449 MUST_USE_RESULT MaybeObject* Store(State state, | 475 MUST_USE_RESULT MaybeObject* Store(State state, |
| 450 Handle<Object> object, | 476 Handle<Object> object, |
| 451 Handle<Object> name, | 477 Handle<Object> name, |
| 452 Handle<Object> value); | 478 Handle<Object> value); |
| 453 | 479 |
| 454 // Code generators for stub routines. Only called once at startup. | 480 // Code generators for stub routines. Only called once at startup. |
| 455 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 481 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 456 static void GenerateMiss(MacroAssembler* masm); | 482 static void GenerateMiss(MacroAssembler* masm); |
| 457 static void GenerateRuntimeSetProperty(MacroAssembler* masm); | 483 static void GenerateRuntimeSetProperty(MacroAssembler* masm); |
| 458 static void GenerateGeneric(MacroAssembler* masm); | 484 static void GenerateGeneric(MacroAssembler* masm); |
| 459 | 485 |
| 460 // Generators for external array types. See objects.h. | |
| 461 // These are similar to the generic IC; they optimize the case of | |
| 462 // operating upon external array types but fall back to the runtime | |
| 463 // for all other types. | |
| 464 static void GenerateExternalArray(MacroAssembler* masm, | |
| 465 ExternalArrayType array_type); | |
| 466 | |
| 467 // Clear the inlined version so the IC is always hit. | 486 // Clear the inlined version so the IC is always hit. |
| 468 static void ClearInlinedVersion(Address address); | 487 static void ClearInlinedVersion(Address address); |
| 469 | 488 |
| 470 // Restore the inlined version so the fast case can get hit. | 489 // Restore the inlined version so the fast case can get hit. |
| 471 static void RestoreInlinedVersion(Address address); | 490 static void RestoreInlinedVersion(Address address); |
| 472 | 491 |
| 473 private: | 492 private: |
| 474 // Update the inline cache. | 493 // Update the inline cache. |
| 475 void UpdateCaches(LookupResult* lookup, | 494 void UpdateCaches(LookupResult* lookup, |
| 476 State state, | 495 State state, |
| 477 Handle<JSObject> receiver, | 496 Handle<JSObject> receiver, |
| 478 Handle<String> name, | 497 Handle<String> name, |
| 479 Handle<Object> value); | 498 Handle<Object> value); |
| 480 | 499 |
| 481 // Stub accessors. | 500 // Stub accessors. |
| 482 static Code* initialize_stub() { | 501 static Code* initialize_stub() { |
| 483 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); | 502 return Builtins::builtin(Builtins::KeyedStoreIC_Initialize); |
| 484 } | 503 } |
| 485 static Code* megamorphic_stub() { | 504 static Code* megamorphic_stub() { |
| 486 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 505 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); |
| 487 } | 506 } |
| 488 static Code* generic_stub() { | 507 static Code* generic_stub() { |
| 489 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); | 508 return Builtins::builtin(Builtins::KeyedStoreIC_Generic); |
| 490 } | 509 } |
| 491 static Code* external_array_stub(JSObject::ElementsKind elements_kind); | |
| 492 | 510 |
| 493 static void Clear(Address address, Code* target); | 511 static void Clear(Address address, Code* target); |
| 494 | 512 |
| 495 // Support for patching the map that is checked in an inlined | 513 // Support for patching the map that is checked in an inlined |
| 496 // version of keyed store. | 514 // version of keyed store. |
| 497 // The address is the patch point for the IC call | 515 // The address is the patch point for the IC call |
| 498 // (Assembler::kCallTargetAddressOffset before the end of | 516 // (Assembler::kCallTargetAddressOffset before the end of |
| 499 // the call/return address). | 517 // the call/return address). |
| 500 // The map is the new map that the inlined code should check against. | 518 // The map is the new map that the inlined code should check against. |
| 501 static bool PatchInlinedStore(Address address, Object* map); | 519 static bool PatchInlinedStore(Address address, Object* map); |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 591 | 609 |
| 592 Token::Value op_; | 610 Token::Value op_; |
| 593 }; | 611 }; |
| 594 | 612 |
| 595 // Helper for TRBinaryOpIC and CompareIC. | 613 // Helper for TRBinaryOpIC and CompareIC. |
| 596 void PatchInlinedSmiCode(Address address); | 614 void PatchInlinedSmiCode(Address address); |
| 597 | 615 |
| 598 } } // namespace v8::internal | 616 } } // namespace v8::internal |
| 599 | 617 |
| 600 #endif // V8_IC_H_ | 618 #endif // V8_IC_H_ |
| OLD | NEW |