OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 // Determines which map must be used for keeping the code stub. | 126 // Determines which map must be used for keeping the code stub. |
127 // These methods should not be called with undefined or null. | 127 // These methods should not be called with undefined or null. |
128 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, | 128 static inline InlineCacheHolderFlag GetCodeCacheForObject(Object* object, |
129 JSObject* holder); | 129 JSObject* holder); |
130 static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, | 130 static inline InlineCacheHolderFlag GetCodeCacheForObject(JSObject* object, |
131 JSObject* holder); | 131 JSObject* holder); |
132 static inline JSObject* GetCodeCacheHolder(Object* object, | 132 static inline JSObject* GetCodeCacheHolder(Object* object, |
133 InlineCacheHolderFlag holder); | 133 InlineCacheHolderFlag holder); |
134 | 134 |
135 protected: | 135 protected: |
| 136 virtual Handle<Code> pre_monomorphic_stub() { |
| 137 UNREACHABLE(); |
| 138 return Handle<Code>::null(); |
| 139 } |
| 140 virtual Handle<Code> megamorphic_stub() { |
| 141 UNREACHABLE(); |
| 142 return Handle<Code>::null(); |
| 143 } |
| 144 virtual Code::Kind kind() const { |
| 145 UNREACHABLE(); |
| 146 return Code::STUB; |
| 147 } |
136 Address fp() const { return fp_; } | 148 Address fp() const { return fp_; } |
137 Address pc() const { return *pc_address_; } | 149 Address pc() const { return *pc_address_; } |
138 Isolate* isolate() const { return isolate_; } | 150 Isolate* isolate() const { return isolate_; } |
139 | 151 |
140 #ifdef ENABLE_DEBUGGER_SUPPORT | 152 #ifdef ENABLE_DEBUGGER_SUPPORT |
141 // Computes the address in the original code when the code running is | 153 // Computes the address in the original code when the code running is |
142 // containing break points (calls to DebugBreakXXX builtins). | 154 // containing break points (calls to DebugBreakXXX builtins). |
143 Address OriginalCodeAddress() const; | 155 Address OriginalCodeAddress() const; |
144 #endif | 156 #endif |
145 | 157 |
(...skipping 12 matching lines...) Expand all Loading... |
158 Failure* TypeError(const char* type, | 170 Failure* TypeError(const char* type, |
159 Handle<Object> object, | 171 Handle<Object> object, |
160 Handle<Object> key); | 172 Handle<Object> key); |
161 Failure* ReferenceError(const char* type, Handle<String> name); | 173 Failure* ReferenceError(const char* type, Handle<String> name); |
162 | 174 |
163 // Access the target code for the given IC address. | 175 // Access the target code for the given IC address. |
164 static inline Code* GetTargetAtAddress(Address address); | 176 static inline Code* GetTargetAtAddress(Address address); |
165 static inline void SetTargetAtAddress(Address address, Code* target); | 177 static inline void SetTargetAtAddress(Address address, Code* target); |
166 static void PostPatching(Address address, Code* target, Code* old_target); | 178 static void PostPatching(Address address, Code* target, Code* old_target); |
167 | 179 |
| 180 bool HandleLoad(State state, |
| 181 Handle<Object> object, |
| 182 Handle<String> name, |
| 183 MaybeObject** result); |
| 184 |
168 private: | 185 private: |
169 // Frame pointer for the frame that uses (calls) the IC. | 186 // Frame pointer for the frame that uses (calls) the IC. |
170 Address fp_; | 187 Address fp_; |
171 | 188 |
172 // All access to the program counter of an IC structure is indirect | 189 // All access to the program counter of an IC structure is indirect |
173 // to make the code GC safe. This feature is crucial since | 190 // to make the code GC safe. This feature is crucial since |
174 // GetProperty and SetProperty are called and they in turn might | 191 // GetProperty and SetProperty are called and they in turn might |
175 // invoke the garbage collector. | 192 // invoke the garbage collector. |
176 Address* pc_address_; | 193 Address* pc_address_; |
177 | 194 |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 348 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
332 static void GeneratePreMonomorphic(MacroAssembler* masm) { | 349 static void GeneratePreMonomorphic(MacroAssembler* masm) { |
333 GenerateMiss(masm); | 350 GenerateMiss(masm); |
334 } | 351 } |
335 static void GenerateMiss(MacroAssembler* masm); | 352 static void GenerateMiss(MacroAssembler* masm); |
336 static void GenerateMegamorphic(MacroAssembler* masm); | 353 static void GenerateMegamorphic(MacroAssembler* masm); |
337 static void GenerateNormal(MacroAssembler* masm); | 354 static void GenerateNormal(MacroAssembler* masm); |
338 | 355 |
339 // Specialized code generator routines. | 356 // Specialized code generator routines. |
340 static void GenerateArrayLength(MacroAssembler* masm); | 357 static void GenerateArrayLength(MacroAssembler* masm); |
341 static void GenerateStringLength(MacroAssembler* masm, | |
342 bool support_wrappers); | |
343 static void GenerateFunctionPrototype(MacroAssembler* masm); | 358 static void GenerateFunctionPrototype(MacroAssembler* masm); |
344 | 359 |
| 360 protected: |
| 361 virtual Code::Kind kind() const { return Code::LOAD_IC; } |
| 362 |
| 363 virtual Handle<Code> megamorphic_stub() { |
| 364 return isolate()->builtins()->LoadIC_Megamorphic(); |
| 365 } |
| 366 |
345 private: | 367 private: |
346 // Update the inline cache and the global stub cache based on the | 368 // Update the inline cache and the global stub cache based on the |
347 // lookup result. | 369 // lookup result. |
348 void UpdateCaches(LookupResult* lookup, | 370 void UpdateCaches(LookupResult* lookup, |
349 State state, | 371 State state, |
350 Handle<Object> object, | 372 Handle<Object> object, |
351 Handle<String> name); | 373 Handle<String> name); |
352 | 374 |
353 // Stub accessors. | 375 // Stub accessors. |
354 Handle<Code> megamorphic_stub() { | |
355 return isolate()->builtins()->LoadIC_Megamorphic(); | |
356 } | |
357 static Code* initialize_stub() { | 376 static Code* initialize_stub() { |
358 return Isolate::Current()->builtins()->builtin( | 377 return Isolate::Current()->builtins()->builtin( |
359 Builtins::kLoadIC_Initialize); | 378 Builtins::kLoadIC_Initialize); |
360 } | 379 } |
361 Handle<Code> pre_monomorphic_stub() { | 380 virtual Handle<Code> pre_monomorphic_stub() { |
362 return isolate()->builtins()->LoadIC_PreMonomorphic(); | 381 return isolate()->builtins()->LoadIC_PreMonomorphic(); |
363 } | 382 } |
364 | 383 |
365 static void Clear(Address address, Code* target); | 384 static void Clear(Address address, Code* target); |
366 | 385 |
367 friend class IC; | 386 friend class IC; |
368 }; | 387 }; |
369 | 388 |
370 | 389 |
371 class KeyedIC: public IC { | 390 class KeyedIC: public IC { |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 virtual Handle<Code> GetElementStubWithoutMapCheck( | 441 virtual Handle<Code> GetElementStubWithoutMapCheck( |
423 bool is_js_array, | 442 bool is_js_array, |
424 ElementsKind elements_kind, | 443 ElementsKind elements_kind, |
425 KeyedAccessGrowMode grow_mode) = 0; | 444 KeyedAccessGrowMode grow_mode) = 0; |
426 | 445 |
427 protected: | 446 protected: |
428 virtual Handle<Code> string_stub() { | 447 virtual Handle<Code> string_stub() { |
429 return Handle<Code>::null(); | 448 return Handle<Code>::null(); |
430 } | 449 } |
431 | 450 |
432 virtual Code::Kind kind() const = 0; | |
433 | |
434 Handle<Code> ComputeStub(Handle<JSObject> receiver, | 451 Handle<Code> ComputeStub(Handle<JSObject> receiver, |
435 StubKind stub_kind, | 452 StubKind stub_kind, |
436 StrictModeFlag strict_mode, | 453 StrictModeFlag strict_mode, |
437 Handle<Code> default_stub); | 454 Handle<Code> default_stub); |
438 | 455 |
439 virtual Handle<Code> ComputePolymorphicStub( | 456 virtual Handle<Code> ComputePolymorphicStub( |
440 MapHandleList* receiver_maps, | 457 MapHandleList* receiver_maps, |
441 StrictModeFlag strict_mode, | 458 StrictModeFlag strict_mode, |
442 KeyedAccessGrowMode grow_mode) = 0; | 459 KeyedAccessGrowMode grow_mode) = 0; |
443 | 460 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
513 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); | 530 (1 << Map::kIsAccessCheckNeeded) | (1 << Map::kHasIndexedInterceptor); |
514 | 531 |
515 virtual Handle<Code> GetElementStubWithoutMapCheck( | 532 virtual Handle<Code> GetElementStubWithoutMapCheck( |
516 bool is_js_array, | 533 bool is_js_array, |
517 ElementsKind elements_kind, | 534 ElementsKind elements_kind, |
518 KeyedAccessGrowMode grow_mode); | 535 KeyedAccessGrowMode grow_mode); |
519 | 536 |
520 protected: | 537 protected: |
521 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } | 538 virtual Code::Kind kind() const { return Code::KEYED_LOAD_IC; } |
522 | 539 |
| 540 virtual Handle<Code> megamorphic_stub() { |
| 541 return isolate()->builtins()->KeyedLoadIC_Generic(); |
| 542 } |
| 543 |
523 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, | 544 virtual Handle<Code> ComputePolymorphicStub(MapHandleList* receiver_maps, |
524 StrictModeFlag strict_mode, | 545 StrictModeFlag strict_mode, |
525 KeyedAccessGrowMode grow_mode); | 546 KeyedAccessGrowMode grow_mode); |
526 | 547 |
527 virtual Handle<Code> string_stub() { | 548 virtual Handle<Code> string_stub() { |
528 return isolate()->builtins()->KeyedLoadIC_String(); | 549 return isolate()->builtins()->KeyedLoadIC_String(); |
529 } | 550 } |
530 | 551 |
531 private: | 552 private: |
532 // Update the inline cache. | 553 // Update the inline cache. |
533 void UpdateCaches(LookupResult* lookup, | 554 void UpdateCaches(LookupResult* lookup, |
534 State state, | 555 State state, |
535 Handle<Object> object, | 556 Handle<Object> object, |
536 Handle<String> name); | 557 Handle<String> name); |
537 | 558 |
538 // Stub accessors. | 559 // Stub accessors. |
539 static Code* initialize_stub() { | 560 static Code* initialize_stub() { |
540 return Isolate::Current()->builtins()->builtin( | 561 return Isolate::Current()->builtins()->builtin( |
541 Builtins::kKeyedLoadIC_Initialize); | 562 Builtins::kKeyedLoadIC_Initialize); |
542 } | 563 } |
543 Handle<Code> megamorphic_stub() { | |
544 return isolate()->builtins()->KeyedLoadIC_Generic(); | |
545 } | |
546 Handle<Code> generic_stub() const { | 564 Handle<Code> generic_stub() const { |
547 return isolate()->builtins()->KeyedLoadIC_Generic(); | 565 return isolate()->builtins()->KeyedLoadIC_Generic(); |
548 } | 566 } |
549 Handle<Code> pre_monomorphic_stub() { | 567 virtual Handle<Code> pre_monomorphic_stub() { |
550 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); | 568 return isolate()->builtins()->KeyedLoadIC_PreMonomorphic(); |
551 } | 569 } |
552 Handle<Code> indexed_interceptor_stub() { | 570 Handle<Code> indexed_interceptor_stub() { |
553 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); | 571 return isolate()->builtins()->KeyedLoadIC_IndexedInterceptor(); |
554 } | 572 } |
555 Handle<Code> non_strict_arguments_stub() { | 573 Handle<Code> non_strict_arguments_stub() { |
556 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); | 574 return isolate()->builtins()->KeyedLoadIC_NonStrictArguments(); |
557 } | 575 } |
558 | 576 |
559 static void Clear(Address address, Code* target); | 577 static void Clear(Address address, Code* target); |
(...skipping 17 matching lines...) Expand all Loading... |
577 // Code generators for stub routines. Only called once at startup. | 595 // Code generators for stub routines. Only called once at startup. |
578 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } | 596 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } |
579 static void GenerateMiss(MacroAssembler* masm); | 597 static void GenerateMiss(MacroAssembler* masm); |
580 static void GenerateMegamorphic(MacroAssembler* masm, | 598 static void GenerateMegamorphic(MacroAssembler* masm, |
581 StrictModeFlag strict_mode); | 599 StrictModeFlag strict_mode); |
582 static void GenerateArrayLength(MacroAssembler* masm); | 600 static void GenerateArrayLength(MacroAssembler* masm); |
583 static void GenerateNormal(MacroAssembler* masm); | 601 static void GenerateNormal(MacroAssembler* masm); |
584 static void GenerateGlobalProxy(MacroAssembler* masm, | 602 static void GenerateGlobalProxy(MacroAssembler* masm, |
585 StrictModeFlag strict_mode); | 603 StrictModeFlag strict_mode); |
586 | 604 |
| 605 protected: |
| 606 virtual Code::Kind kind() const { return Code::STORE_IC; } |
| 607 virtual Handle<Code> megamorphic_stub() { |
| 608 return isolate()->builtins()->StoreIC_Megamorphic(); |
| 609 } |
| 610 |
587 private: | 611 private: |
588 // Update the inline cache and the global stub cache based on the | 612 // Update the inline cache and the global stub cache based on the |
589 // lookup result. | 613 // lookup result. |
590 void UpdateCaches(LookupResult* lookup, | 614 void UpdateCaches(LookupResult* lookup, |
591 State state, | 615 State state, |
592 StrictModeFlag strict_mode, | 616 StrictModeFlag strict_mode, |
593 Handle<JSObject> receiver, | 617 Handle<JSObject> receiver, |
594 Handle<String> name, | 618 Handle<String> name, |
595 Handle<Object> value); | 619 Handle<Object> value); |
596 | 620 |
597 void set_target(Code* code) { | 621 void set_target(Code* code) { |
598 // Strict mode must be preserved across IC patching. | 622 // Strict mode must be preserved across IC patching. |
599 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == | 623 ASSERT(Code::GetStrictMode(code->extra_ic_state()) == |
600 Code::GetStrictMode(target()->extra_ic_state())); | 624 Code::GetStrictMode(target()->extra_ic_state())); |
601 IC::set_target(code); | 625 IC::set_target(code); |
602 } | 626 } |
603 | 627 |
604 // Stub accessors. | 628 // Stub accessors. |
605 Code* megamorphic_stub() { | |
606 return isolate()->builtins()->builtin( | |
607 Builtins::kStoreIC_Megamorphic); | |
608 } | |
609 Code* megamorphic_stub_strict() { | 629 Code* megamorphic_stub_strict() { |
610 return isolate()->builtins()->builtin( | 630 return isolate()->builtins()->builtin( |
611 Builtins::kStoreIC_Megamorphic_Strict); | 631 Builtins::kStoreIC_Megamorphic_Strict); |
612 } | 632 } |
613 static Code* initialize_stub() { | 633 static Code* initialize_stub() { |
614 return Isolate::Current()->builtins()->builtin( | 634 return Isolate::Current()->builtins()->builtin( |
615 Builtins::kStoreIC_Initialize); | 635 Builtins::kStoreIC_Initialize); |
616 } | 636 } |
617 static Code* initialize_stub_strict() { | 637 static Code* initialize_stub_strict() { |
618 return Isolate::Current()->builtins()->builtin( | 638 return Isolate::Current()->builtins()->builtin( |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
841 | 861 |
842 // Helper for BinaryOpIC and CompareIC. | 862 // Helper for BinaryOpIC and CompareIC. |
843 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; | 863 enum InlinedSmiCheck { ENABLE_INLINED_SMI_CHECK, DISABLE_INLINED_SMI_CHECK }; |
844 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); | 864 void PatchInlinedSmiCode(Address address, InlinedSmiCheck check); |
845 | 865 |
846 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss); | 866 DECLARE_RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss); |
847 | 867 |
848 } } // namespace v8::internal | 868 } } // namespace v8::internal |
849 | 869 |
850 #endif // V8_IC_H_ | 870 #endif // V8_IC_H_ |
OLD | NEW |