| 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 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 State state, | 221 State state, |
| 222 Code::ExtraICState extra_ic_state, | 222 Code::ExtraICState extra_ic_state, |
| 223 Handle<Object> object, | 223 Handle<Object> object, |
| 224 Handle<String> name); | 224 Handle<String> name); |
| 225 | 225 |
| 226 // Returns a JSFunction if the object can be called as a function, | 226 // Returns a JSFunction if the object can be called as a function, |
| 227 // and patches the stack to be ready for the call. | 227 // and patches the stack to be ready for the call. |
| 228 // Otherwise, it returns the undefined value. | 228 // Otherwise, it returns the undefined value. |
| 229 Object* TryCallAsFunction(Object* object); | 229 Object* TryCallAsFunction(Object* object); |
| 230 | 230 |
| 231 void ReceiverToObject(Handle<Object> object); | 231 void ReceiverToObjectIfRequired(Handle<Object> callee, Handle<Object> object); |
| 232 | 232 |
| 233 static void Clear(Address address, Code* target); | 233 static void Clear(Address address, Code* target); |
| 234 friend class IC; | 234 friend class IC; |
| 235 }; | 235 }; |
| 236 | 236 |
| 237 | 237 |
| 238 class CallIC: public CallICBase { | 238 class CallIC: public CallICBase { |
| 239 public: | 239 public: |
| 240 explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { | 240 explicit CallIC(Isolate* isolate) : CallICBase(Code::CALL_IC, isolate) { |
| 241 ASSERT(target()->is_call_stub()); | 241 ASSERT(target()->is_call_stub()); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 }; | 416 }; |
| 417 | 417 |
| 418 | 418 |
| 419 class StoreIC: public IC { | 419 class StoreIC: public IC { |
| 420 public: | 420 public: |
| 421 explicit StoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { | 421 explicit StoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { |
| 422 ASSERT(target()->is_store_stub()); | 422 ASSERT(target()->is_store_stub()); |
| 423 } | 423 } |
| 424 | 424 |
| 425 MUST_USE_RESULT MaybeObject* Store(State state, | 425 MUST_USE_RESULT MaybeObject* Store(State state, |
| 426 StrictModeFlag strict_mode, |
| 426 Handle<Object> object, | 427 Handle<Object> object, |
| 427 Handle<String> name, | 428 Handle<String> name, |
| 428 Handle<Object> value); | 429 Handle<Object> value); |
| 429 | 430 |
| 430 // Code generators for stub routines. Only called once at startup. | 431 // Code generators for stub routines. Only called once at startup. |
| 431 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 432 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 432 static void GenerateMiss(MacroAssembler* masm); | 433 static void GenerateMiss(MacroAssembler* masm); |
| 433 static void GenerateMegamorphic(MacroAssembler* masm); | 434 static void GenerateMegamorphic(MacroAssembler* masm, |
| 435 StrictModeFlag strict_mode); |
| 434 static void GenerateArrayLength(MacroAssembler* masm); | 436 static void GenerateArrayLength(MacroAssembler* masm); |
| 435 static void GenerateNormal(MacroAssembler* masm); | 437 static void GenerateNormal(MacroAssembler* masm); |
| 436 static void GenerateGlobalProxy(MacroAssembler* masm); | 438 static void GenerateGlobalProxy(MacroAssembler* masm, |
| 439 StrictModeFlag strict_mode); |
| 437 | 440 |
| 438 // Clear the use of an inlined version. | 441 // Clear the use of an inlined version. |
| 439 static void ClearInlinedVersion(Address address); | 442 static void ClearInlinedVersion(Address address); |
| 440 | 443 |
| 441 // The offset from the inlined patch site to the start of the | 444 // The offset from the inlined patch site to the start of the |
| 442 // inlined store instruction. | 445 // inlined store instruction. |
| 443 static const int kOffsetToStoreInstruction; | 446 static const int kOffsetToStoreInstruction; |
| 444 | 447 |
| 445 private: | 448 private: |
| 446 // Update the inline cache and the global stub cache based on the | 449 // Update the inline cache and the global stub cache based on the |
| 447 // lookup result. | 450 // lookup result. |
| 448 void UpdateCaches(LookupResult* lookup, | 451 void UpdateCaches(LookupResult* lookup, |
| 449 State state, Handle<JSObject> receiver, | 452 State state, |
| 453 StrictModeFlag strict_mode, |
| 454 Handle<JSObject> receiver, |
| 450 Handle<String> name, | 455 Handle<String> name, |
| 451 Handle<Object> value); | 456 Handle<Object> value); |
| 452 | 457 |
| 458 void set_target(Code* code) { |
| 459 // Strict mode must be preserved across IC patching. |
| 460 ASSERT((code->extra_ic_state() & kStrictMode) == |
| 461 (target()->extra_ic_state() & kStrictMode)); |
| 462 IC::set_target(code); |
| 463 } |
| 464 |
| 453 // Stub accessors. | 465 // Stub accessors. |
| 454 Code* megamorphic_stub() { | 466 Code* megamorphic_stub() { |
| 455 return isolate()->builtins()->builtin( | 467 return isolate()->builtins()->builtin( |
| 456 Builtins::StoreIC_Megamorphic); | 468 Builtins::StoreIC_Megamorphic); |
| 457 } | 469 } |
| 470 Code* megamorphic_stub_strict() { |
| 471 return isolate()->builtins()->builtin( |
| 472 Builtins::StoreIC_Megamorphic_Strict); |
| 473 } |
| 458 static Code* initialize_stub() { | 474 static Code* initialize_stub() { |
| 459 return Isolate::Current()->builtins()->builtin( | 475 return Isolate::Current()->builtins()->builtin( |
| 460 Builtins::StoreIC_Initialize); | 476 Builtins::StoreIC_Initialize); |
| 461 } | 477 } |
| 462 static Code* global_proxy_stub() { | 478 static Code* initialize_stub_strict() { |
| 463 return Isolate::Current()->builtins()->builtin( | 479 return Isolate::Current()->builtins()->builtin( |
| 480 Builtins::StoreIC_Initialize_Strict); |
| 481 } |
| 482 Code* global_proxy_stub() { |
| 483 return isolate()->builtins()->builtin( |
| 464 Builtins::StoreIC_GlobalProxy); | 484 Builtins::StoreIC_GlobalProxy); |
| 465 } | 485 } |
| 486 Code* global_proxy_stub_strict() { |
| 487 return isolate()->builtins()->builtin( |
| 488 Builtins::StoreIC_GlobalProxy_Strict); |
| 489 } |
| 466 | 490 |
| 467 static void Clear(Address address, Code* target); | 491 static void Clear(Address address, Code* target); |
| 468 | 492 |
| 469 // Support for patching the index and the map that is checked in an | 493 // Support for patching the index and the map that is checked in an |
| 470 // inlined version of the named store. | 494 // inlined version of the named store. |
| 471 static bool PatchInlinedStore(Address address, Object* map, int index); | 495 static bool PatchInlinedStore(Address address, Object* map, int index); |
| 472 | 496 |
| 473 friend class IC; | 497 friend class IC; |
| 474 }; | 498 }; |
| 475 | 499 |
| 476 | 500 |
| 477 class KeyedStoreIC: public IC { | 501 class KeyedStoreIC: public IC { |
| 478 public: | 502 public: |
| 479 explicit KeyedStoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } | 503 explicit KeyedStoreIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } |
| 480 | 504 |
| 481 MUST_USE_RESULT MaybeObject* Store(State state, | 505 MUST_USE_RESULT MaybeObject* Store(State state, |
| 506 StrictModeFlag strict_mode, |
| 482 Handle<Object> object, | 507 Handle<Object> object, |
| 483 Handle<Object> name, | 508 Handle<Object> name, |
| 484 Handle<Object> value); | 509 Handle<Object> value); |
| 485 | 510 |
| 486 // Code generators for stub routines. Only called once at startup. | 511 // Code generators for stub routines. Only called once at startup. |
| 487 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 512 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
| 488 static void GenerateMiss(MacroAssembler* masm); | 513 static void GenerateMiss(MacroAssembler* masm); |
| 489 static void GenerateRuntimeSetProperty(MacroAssembler* masm); | 514 static void GenerateRuntimeSetProperty(MacroAssembler* masm, |
| 490 static void GenerateGeneric(MacroAssembler* masm); | 515 StrictModeFlag strict_mode); |
| 516 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 491 | 517 |
| 492 // Clear the inlined version so the IC is always hit. | 518 // Clear the inlined version so the IC is always hit. |
| 493 static void ClearInlinedVersion(Address address); | 519 static void ClearInlinedVersion(Address address); |
| 494 | 520 |
| 495 // Restore the inlined version so the fast case can get hit. | 521 // Restore the inlined version so the fast case can get hit. |
| 496 static void RestoreInlinedVersion(Address address); | 522 static void RestoreInlinedVersion(Address address); |
| 497 | 523 |
| 498 private: | 524 private: |
| 499 // Update the inline cache. | 525 // Update the inline cache. |
| 500 void UpdateCaches(LookupResult* lookup, | 526 void UpdateCaches(LookupResult* lookup, |
| 501 State state, | 527 State state, |
| 528 StrictModeFlag strict_mode, |
| 502 Handle<JSObject> receiver, | 529 Handle<JSObject> receiver, |
| 503 Handle<String> name, | 530 Handle<String> name, |
| 504 Handle<Object> value); | 531 Handle<Object> value); |
| 505 | 532 |
| 533 void set_target(Code* code) { |
| 534 // Strict mode must be preserved across IC patching. |
| 535 ASSERT((code->extra_ic_state() & kStrictMode) == |
| 536 (target()->extra_ic_state() & kStrictMode)); |
| 537 IC::set_target(code); |
| 538 } |
| 539 |
| 506 // Stub accessors. | 540 // Stub accessors. |
| 507 static Code* initialize_stub() { | 541 static Code* initialize_stub() { |
| 508 return Isolate::Current()->builtins()->builtin( | 542 return Isolate::Current()->builtins()->builtin( |
| 509 Builtins::KeyedStoreIC_Initialize); | 543 Builtins::KeyedStoreIC_Initialize); |
| 510 } | 544 } |
| 511 Code* megamorphic_stub() { | 545 Code* megamorphic_stub() { |
| 512 return isolate()->builtins()->builtin( | 546 return isolate()->builtins()->builtin( |
| 513 Builtins::KeyedStoreIC_Generic); | 547 Builtins::KeyedStoreIC_Generic); |
| 514 } | 548 } |
| 549 static Code* initialize_stub_strict() { |
| 550 return Isolate::Current()->builtins()->builtin( |
| 551 Builtins::KeyedStoreIC_Initialize_Strict); |
| 552 } |
| 553 Code* megamorphic_stub_strict() { |
| 554 return isolate()->builtins()->builtin( |
| 555 Builtins::KeyedStoreIC_Generic_Strict); |
| 556 } |
| 515 Code* generic_stub() { | 557 Code* generic_stub() { |
| 516 return isolate()->builtins()->builtin( | 558 return isolate()->builtins()->builtin( |
| 517 Builtins::KeyedStoreIC_Generic); | 559 Builtins::KeyedStoreIC_Generic); |
| 518 } | 560 } |
| 561 Code* generic_stub_strict() { |
| 562 return isolate()->builtins()->builtin( |
| 563 Builtins::KeyedStoreIC_Generic_Strict); |
| 564 } |
| 519 | 565 |
| 520 static void Clear(Address address, Code* target); | 566 static void Clear(Address address, Code* target); |
| 521 | 567 |
| 522 // Support for patching the map that is checked in an inlined | 568 // Support for patching the map that is checked in an inlined |
| 523 // version of keyed store. | 569 // version of keyed store. |
| 524 // The address is the patch point for the IC call | 570 // The address is the patch point for the IC call |
| 525 // (Assembler::kCallTargetAddressOffset before the end of | 571 // (Assembler::kCallTargetAddressOffset before the end of |
| 526 // the call/return address). | 572 // the call/return address). |
| 527 // The map is the new map that the inlined code should check against. | 573 // The map is the new map that the inlined code should check against. |
| 528 static bool PatchInlinedStore(Address address, Object* map); | 574 static bool PatchInlinedStore(Address address, Object* map); |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 619 | 665 |
| 620 Token::Value op_; | 666 Token::Value op_; |
| 621 }; | 667 }; |
| 622 | 668 |
| 623 // Helper for TRBinaryOpIC and CompareIC. | 669 // Helper for TRBinaryOpIC and CompareIC. |
| 624 void PatchInlinedSmiCode(Address address); | 670 void PatchInlinedSmiCode(Address address); |
| 625 | 671 |
| 626 } } // namespace v8::internal | 672 } } // namespace v8::internal |
| 627 | 673 |
| 628 #endif // V8_IC_H_ | 674 #endif // V8_IC_H_ |
| OLD | NEW |