| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 // The IC code is either invoked with no extra frames on the stack | 84 // The IC code is either invoked with no extra frames on the stack |
| 85 // or with a single extra frame for supporting calls. | 85 // or with a single extra frame for supporting calls. |
| 86 enum FrameDepth { | 86 enum FrameDepth { |
| 87 NO_EXTRA_FRAME = 0, | 87 NO_EXTRA_FRAME = 0, |
| 88 EXTRA_CALL_FRAME = 1 | 88 EXTRA_CALL_FRAME = 1 |
| 89 }; | 89 }; |
| 90 | 90 |
| 91 // Construct the IC structure with the given number of extra | 91 // Construct the IC structure with the given number of extra |
| 92 // JavaScript frames on the stack. | 92 // JavaScript frames on the stack. |
| 93 IC(FrameDepth depth, Isolate* isolate); | 93 IC(FrameDepth depth, Isolate* isolate); |
| 94 virtual ~IC() {} |
| 94 | 95 |
| 95 // Get the call-site target; used for determining the state. | 96 // Get the call-site target; used for determining the state. |
| 96 Code* target() { return GetTargetAtAddress(address()); } | 97 Code* target() const { return GetTargetAtAddress(address()); } |
| 97 inline Address address(); | 98 inline Address address() const; |
| 99 |
| 100 virtual bool IsGeneric() const { return false; } |
| 98 | 101 |
| 99 // Compute the current IC state based on the target stub, receiver and name. | 102 // Compute the current IC state based on the target stub, receiver and name. |
| 100 static State StateFrom(Code* target, Object* receiver, Object* name); | 103 static State StateFrom(Code* target, Object* receiver, Object* name); |
| 101 | 104 |
| 102 // Clear the inline cache to initial state. | 105 // Clear the inline cache to initial state. |
| 103 static void Clear(Address address); | 106 static void Clear(Address address); |
| 104 | 107 |
| 105 // Computes the reloc info for this IC. This is a fairly expensive | 108 // Computes the reloc info for this IC. This is a fairly expensive |
| 106 // operation as it has to search through the heap to find the code | 109 // operation as it has to search through the heap to find the code |
| 107 // object that contains this IC site. | 110 // object that contains this IC site. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 132 InlineCacheHolderFlag holder); | 135 InlineCacheHolderFlag holder); |
| 133 | 136 |
| 134 protected: | 137 protected: |
| 135 Address fp() const { return fp_; } | 138 Address fp() const { return fp_; } |
| 136 Address pc() const { return *pc_address_; } | 139 Address pc() const { return *pc_address_; } |
| 137 Isolate* isolate() const { return isolate_; } | 140 Isolate* isolate() const { return isolate_; } |
| 138 | 141 |
| 139 #ifdef ENABLE_DEBUGGER_SUPPORT | 142 #ifdef ENABLE_DEBUGGER_SUPPORT |
| 140 // Computes the address in the original code when the code running is | 143 // Computes the address in the original code when the code running is |
| 141 // containing break points (calls to DebugBreakXXX builtins). | 144 // containing break points (calls to DebugBreakXXX builtins). |
| 142 Address OriginalCodeAddress(); | 145 Address OriginalCodeAddress() const; |
| 143 #endif | 146 #endif |
| 144 | 147 |
| 145 // Set the call-site target. | 148 // Set the call-site target. |
| 146 void set_target(Code* code) { SetTargetAtAddress(address(), code); } | 149 void set_target(Code* code) { SetTargetAtAddress(address(), code); } |
| 147 | 150 |
| 148 #ifdef DEBUG | 151 #ifdef DEBUG |
| 152 char TransitionMarkFromState(IC::State state); |
| 153 |
| 149 void TraceIC(const char* type, | 154 void TraceIC(const char* type, |
| 150 Handle<Object> name, | 155 Handle<Object> name, |
| 151 State old_state, | 156 State old_state, |
| 152 Code* new_target); | 157 Code* new_target); |
| 153 #endif | 158 #endif |
| 154 | 159 |
| 155 Failure* TypeError(const char* type, | 160 Failure* TypeError(const char* type, |
| 156 Handle<Object> object, | 161 Handle<Object> object, |
| 157 Handle<Object> key); | 162 Handle<Object> key); |
| 158 Failure* ReferenceError(const char* type, Handle<String> name); | 163 Failure* ReferenceError(const char* type, Handle<String> name); |
| (...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 // generic stub should go into slow case. | 450 // generic stub should go into slow case. |
| 446 // Access check is necessary explicitly since generic stub does not perform | 451 // Access check is necessary explicitly since generic stub does not perform |
| 447 // map checks. | 452 // map checks. |
| 448 static const int kSlowCaseBitFieldMask = | 453 static const int kSlowCaseBitFieldMask = |
| 449 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 454 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
| 450 | 455 |
| 451 virtual Handle<Code> GetElementStubWithoutMapCheck( | 456 virtual Handle<Code> GetElementStubWithoutMapCheck( |
| 452 bool is_js_array, | 457 bool is_js_array, |
| 453 ElementsKind elements_kind); | 458 ElementsKind elements_kind); |
| 454 | 459 |
| 460 virtual bool IsGeneric() const { |
| 461 return target() == *generic_stub(); |
| 462 } |
| 463 |
| 455 protected: | 464 protected: |
| 456 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } | 465 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } |
| 457 | 466 |
| 458 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, | 467 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, |
| 459 StrictModeFlag strict_mode); | 468 StrictModeFlag strict_mode); |
| 460 | 469 |
| 461 virtual Handle<Code> string_stub() { | 470 virtual Handle<Code> string_stub() { |
| 462 return isolate()->builtins()->KeyedLoadIC_String(); | 471 return isolate()->builtins()->KeyedLoadIC_String(); |
| 463 } | 472 } |
| 464 | 473 |
| 465 private: | 474 private: |
| 466 // Update the inline cache. | 475 // Update the inline cache. |
| 467 void UpdateCaches(LookupResult* lookup, | 476 void UpdateCaches(LookupResult* lookup, |
| 468 State state, | 477 State state, |
| 469 Handle<Object> object, | 478 Handle<Object> object, |
| 470 Handle<String> name); | 479 Handle<String> name); |
| 471 | 480 |
| 472 // Stub accessors. | 481 // Stub accessors. |
| 473 static Code* initialize_stub() { | 482 static Code* initialize_stub() { |
| 474 return Isolate::Current()->builtins()->builtin( | 483 return Isolate::Current()->builtins()->builtin( |
| 475 Builtins::kKeyedLoadIC_Initialize); | 484 Builtins::kKeyedLoadIC_Initialize); |
| 476 } | 485 } |
| 477 Handle<Code> megamorphic_stub() { | 486 Handle<Code> megamorphic_stub() { |
| 478 return isolate()->builtins()->KeyedLoadIC_Generic(); | 487 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 479 } | 488 } |
| 480 Handle<Code> generic_stub() { | 489 Handle<Code> generic_stub() const { |
| 481 return isolate()->builtins()->KeyedLoadIC_Generic(); | 490 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 482 } | 491 } |
| 483 Handle<Code> pre_monomorphic_stub() { | 492 Handle<Code> pre_monomorphic_stub() { |
| 484 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); | 493 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); |
| 485 } | 494 } |
| 486 Handle<Code> indexed_interceptor_stub() { | 495 Handle<Code> indexed_interceptor_stub() { |
| 487 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 496 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
| 488 } | 497 } |
| 489 Handle<Code> non_strict_arguments_stub() { | 498 Handle<Code> non_strict_arguments_stub() { |
| 490 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); | 499 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 588 StrictModeFlag strict_mode); | 597 StrictModeFlag strict_mode); |
| 589 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); | 598 static void GenerateGeneric(MacroAssembler* masm, StrictModeFlag strict_mode); |
| 590 static void GenerateNonStrictArguments(MacroAssembler* masm); | 599 static void GenerateNonStrictArguments(MacroAssembler* masm); |
| 591 static void GenerateTransitionElementsSmiToDouble(MacroAssembler* masm); | 600 static void GenerateTransitionElementsSmiToDouble(MacroAssembler* masm); |
| 592 static void GenerateTransitionElementsDoubleToObject(MacroAssembler* masm); | 601 static void GenerateTransitionElementsDoubleToObject(MacroAssembler* masm); |
| 593 | 602 |
| 594 virtual Handle<Code> GetElementStubWithoutMapCheck( | 603 virtual Handle<Code> GetElementStubWithoutMapCheck( |
| 595 bool is_js_array, | 604 bool is_js_array, |
| 596 ElementsKind elements_kind); | 605 ElementsKind elements_kind); |
| 597 | 606 |
| 607 virtual bool IsGeneric() const { |
| 608 return target() == *generic_stub() || |
| 609 target() == *generic_stub_strict(); |
| 610 } |
| 611 |
| 598 protected: | 612 protected: |
| 599 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } | 613 virtual Code::Kind kind() const { return Code::KEYED_STORE_IC; } |
| 600 | 614 |
| 601 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, | 615 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, |
| 602 StrictModeFlag strict_mode); | 616 StrictModeFlag strict_mode); |
| 603 | 617 |
| 604 private: | 618 private: |
| 605 // Update the inline cache. | 619 // Update the inline cache. |
| 606 void UpdateCaches(LookupResult* lookup, | 620 void UpdateCaches(LookupResult* lookup, |
| 607 State state, | 621 State state, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 625 static Code* initialize_stub_strict() { | 639 static Code* initialize_stub_strict() { |
| 626 return Isolate::Current()->builtins()->builtin( | 640 return Isolate::Current()->builtins()->builtin( |
| 627 Builtins::kKeyedStoreIC_Initialize_Strict); | 641 Builtins::kKeyedStoreIC_Initialize_Strict); |
| 628 } | 642 } |
| 629 Handle<Code> megamorphic_stub() { | 643 Handle<Code> megamorphic_stub() { |
| 630 return isolate()->builtins()->KeyedStoreIC_Generic(); | 644 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 631 } | 645 } |
| 632 Handle<Code> megamorphic_stub_strict() { | 646 Handle<Code> megamorphic_stub_strict() { |
| 633 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 647 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 634 } | 648 } |
| 635 Handle<Code> generic_stub() { | 649 Handle<Code> generic_stub() const { |
| 636 return isolate()->builtins()->KeyedStoreIC_Generic(); | 650 return isolate()->builtins()->KeyedStoreIC_Generic(); |
| 637 } | 651 } |
| 638 Handle<Code> generic_stub_strict() { | 652 Handle<Code> generic_stub_strict() const { |
| 639 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); | 653 return isolate()->builtins()->KeyedStoreIC_Generic_Strict(); |
| 640 } | 654 } |
| 641 Handle<Code> non_strict_arguments_stub() { | 655 Handle<Code> non_strict_arguments_stub() { |
| 642 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); | 656 return isolate()->builtins()->KeyedStoreIC_NonStrictArguments(); |
| 643 } | 657 } |
| 644 | 658 |
| 645 static void Clear(Address address, Code* target); | 659 static void Clear(Address address, Code* target); |
| 646 | 660 |
| 647 friend class IC; | 661 friend class IC; |
| 648 }; | 662 }; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 void patch(Code* code); | 763 void patch(Code* code); |
| 750 }; | 764 }; |
| 751 | 765 |
| 752 | 766 |
| 753 // Helper for BinaryOpIC and CompareIC. | 767 // Helper for BinaryOpIC and CompareIC. |
| 754 void PatchInlinedSmiCode(Address address); | 768 void PatchInlinedSmiCode(Address address); |
| 755 | 769 |
| 756 } } // namespace v8::internal | 770 } } // namespace v8::internal |
| 757 | 771 |
| 758 #endif // V8_IC_H_ | 772 #endif // V8_IC_H_ |
| OLD | NEW |