Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Side by Side Diff: src/ic.h

Issue 6529055: [Isolates] Merge crankshaft (r5922 from bleeding_edge). (Closed)
Patch Set: Win32 port Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_IC_H_ 28 #ifndef V8_IC_H_
29 #define V8_IC_H_ 29 #define V8_IC_H_
30 30
31 #include "assembler.h" 31 #include "macro-assembler.h"
32 32
33 namespace v8 { 33 namespace v8 {
34 namespace internal { 34 namespace internal {
35 35
36 36
37 // IC_UTIL_LIST defines all utility functions called from generated 37 // IC_UTIL_LIST defines all utility functions called from generated
38 // inline caching code. The argument for the macro, ICU, is the function name. 38 // inline caching code. The argument for the macro, ICU, is the function name.
39 #define IC_UTIL_LIST(ICU) \ 39 #define IC_UTIL_LIST(ICU) \
40 ICU(LoadIC_Miss) \ 40 ICU(LoadIC_Miss) \
41 ICU(KeyedLoadIC_Miss) \ 41 ICU(KeyedLoadIC_Miss) \
42 ICU(CallIC_Miss) \ 42 ICU(CallIC_Miss) \
43 ICU(KeyedCallIC_Miss) \ 43 ICU(KeyedCallIC_Miss) \
44 ICU(StoreIC_Miss) \ 44 ICU(StoreIC_Miss) \
45 ICU(StoreIC_ArrayLength) \ 45 ICU(StoreIC_ArrayLength) \
46 ICU(SharedStoreIC_ExtendStorage) \ 46 ICU(SharedStoreIC_ExtendStorage) \
47 ICU(KeyedStoreIC_Miss) \ 47 ICU(KeyedStoreIC_Miss) \
48 /* Utilities for IC stubs. */ \ 48 /* Utilities for IC stubs. */ \
49 ICU(LoadCallbackProperty) \ 49 ICU(LoadCallbackProperty) \
50 ICU(StoreCallbackProperty) \ 50 ICU(StoreCallbackProperty) \
51 ICU(LoadPropertyWithInterceptorOnly) \ 51 ICU(LoadPropertyWithInterceptorOnly) \
52 ICU(LoadPropertyWithInterceptorForLoad) \ 52 ICU(LoadPropertyWithInterceptorForLoad) \
53 ICU(LoadPropertyWithInterceptorForCall) \ 53 ICU(LoadPropertyWithInterceptorForCall) \
54 ICU(KeyedLoadPropertyWithInterceptor) \ 54 ICU(KeyedLoadPropertyWithInterceptor) \
55 ICU(StoreInterceptorProperty) \ 55 ICU(StoreInterceptorProperty) \
56 ICU(BinaryOp_Patch) 56 ICU(BinaryOp_Patch) \
57 57 ICU(TypeRecordingBinaryOp_Patch) \
58 ICU(CompareIC_Miss)
58 // 59 //
59 // IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC, 60 // IC is the base class for LoadIC, StoreIC, CallIC, KeyedLoadIC,
60 // and KeyedStoreIC. 61 // and KeyedStoreIC.
61 // 62 //
62 class IC { 63 class IC {
63 public: 64 public:
64 65
65 // The ids for utility called from the generated code. 66 // The ids for utility called from the generated code.
66 enum UtilityId { 67 enum UtilityId {
67 #define CONST_NAME(name) k##name, 68 #define CONST_NAME(name) k##name,
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 Handle<Object> object, 419 Handle<Object> object,
419 Handle<String> name, 420 Handle<String> name,
420 Handle<Object> value); 421 Handle<Object> value);
421 422
422 // Code generators for stub routines. Only called once at startup. 423 // Code generators for stub routines. Only called once at startup.
423 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); } 424 static void GenerateInitialize(MacroAssembler* masm) { GenerateMiss(masm); }
424 static void GenerateMiss(MacroAssembler* masm); 425 static void GenerateMiss(MacroAssembler* masm);
425 static void GenerateMegamorphic(MacroAssembler* masm); 426 static void GenerateMegamorphic(MacroAssembler* masm);
426 static void GenerateArrayLength(MacroAssembler* masm); 427 static void GenerateArrayLength(MacroAssembler* masm);
427 static void GenerateNormal(MacroAssembler* masm); 428 static void GenerateNormal(MacroAssembler* masm);
429 static void GenerateGlobalProxy(MacroAssembler* masm);
428 430
429 // Clear the use of an inlined version. 431 // Clear the use of an inlined version.
430 static void ClearInlinedVersion(Address address); 432 static void ClearInlinedVersion(Address address);
431 433
432 // The offset from the inlined patch site to the start of the 434 // The offset from the inlined patch site to the start of the
433 // inlined store instruction. 435 // inlined store instruction.
434 static const int kOffsetToStoreInstruction; 436 static const int kOffsetToStoreInstruction;
435 437
436 private: 438 private:
437 // Update the inline cache and the global stub cache based on the 439 // Update the inline cache and the global stub cache based on the
438 // lookup result. 440 // lookup result.
439 void UpdateCaches(LookupResult* lookup, 441 void UpdateCaches(LookupResult* lookup,
440 State state, Handle<JSObject> receiver, 442 State state, Handle<JSObject> receiver,
441 Handle<String> name, 443 Handle<String> name,
442 Handle<Object> value); 444 Handle<Object> value);
443 445
444 // Stub accessors. 446 // Stub accessors.
445 Code* megamorphic_stub() { 447 Code* megamorphic_stub() {
446 return isolate()->builtins()->builtin( 448 return isolate()->builtins()->builtin(
447 Builtins::StoreIC_Megamorphic); 449 Builtins::StoreIC_Megamorphic);
448 } 450 }
449 static Code* initialize_stub() { 451 static Code* initialize_stub() {
450 return Isolate::Current()->builtins()->builtin( 452 return Isolate::Current()->builtins()->builtin(
451 Builtins::StoreIC_Initialize); 453 Builtins::StoreIC_Initialize);
452 } 454 }
455 static Code* global_proxy_stub() {
456 return Isolate::Current()->builtins()->builtin(
457 Builtins::StoreIC_GlobalProxy);
458 }
453 459
454 static void Clear(Address address, Code* target); 460 static void Clear(Address address, Code* target);
455 461
456 // Support for patching the index and the map that is checked in an 462 // Support for patching the index and the map that is checked in an
457 // inlined version of the named store. 463 // inlined version of the named store.
458 static bool PatchInlinedStore(Address address, Object* map, int index); 464 static bool PatchInlinedStore(Address address, Object* map, int index);
459 465
460 friend class IC; 466 friend class IC;
461 }; 467 };
462 468
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
523 static bool PatchInlinedStore(Address address, Object* map); 529 static bool PatchInlinedStore(Address address, Object* map);
524 530
525 friend class IC; 531 friend class IC;
526 }; 532 };
527 533
528 534
529 class BinaryOpIC: public IC { 535 class BinaryOpIC: public IC {
530 public: 536 public:
531 537
532 enum TypeInfo { 538 enum TypeInfo {
539 UNINIT_OR_SMI,
533 DEFAULT, // Initial state. When first executed, patches to one 540 DEFAULT, // Initial state. When first executed, patches to one
534 // of the following states depending on the operands types. 541 // of the following states depending on the operands types.
535 HEAP_NUMBERS, // Both arguments are HeapNumbers. 542 HEAP_NUMBERS, // Both arguments are HeapNumbers.
536 STRINGS, // At least one of the arguments is String. 543 STRINGS, // At least one of the arguments is String.
537 GENERIC // Non-specialized case (processes any type combination). 544 GENERIC // Non-specialized case (processes any type combination).
538 }; 545 };
539 546
540 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { } 547 explicit BinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { }
541 548
542 void patch(Code* code); 549 void patch(Code* code);
543 550
544 static void Clear(Address address, Code* target);
545
546 static const char* GetName(TypeInfo type_info); 551 static const char* GetName(TypeInfo type_info);
547 552
548 static State ToState(TypeInfo type_info); 553 static State ToState(TypeInfo type_info);
549 554
550 static TypeInfo GetTypeInfo(Object* left, Object* right); 555 static TypeInfo GetTypeInfo(Object* left, Object* right);
551 }; 556 };
552 557
558
559 // Type Recording BinaryOpIC, that records the types of the inputs and outputs.
560 class TRBinaryOpIC: public IC {
561 public:
562
563 enum TypeInfo {
564 UNINITIALIZED,
565 SMI,
566 INT32,
567 HEAP_NUMBER,
568 STRING, // Only used for addition operation. At least one string operand.
569 GENERIC
570 };
571
572 explicit TRBinaryOpIC(Isolate* isolate) : IC(NO_EXTRA_FRAME, isolate) { }
573
574 void patch(Code* code);
575
576 static const char* GetName(TypeInfo type_info);
577
578 static State ToState(TypeInfo type_info);
579
580 static TypeInfo GetTypeInfo(Handle<Object> left, Handle<Object> right);
581
582 static TypeInfo JoinTypes(TypeInfo x, TypeInfo y);
583 };
584
585
586 class CompareIC: public IC {
587 public:
588 enum State {
589 UNINITIALIZED,
590 SMIS,
591 HEAP_NUMBERS,
592 OBJECTS,
593 GENERIC
594 };
595
596 CompareIC(Isolate* isolate, Token::Value op)
597 : IC(EXTRA_CALL_FRAME, isolate), op_(op) { }
598
599 // Update the inline cache for the given operands.
600 void UpdateCaches(Handle<Object> x, Handle<Object> y);
601
602 // Factory method for getting an uninitialized compare stub.
603 static Handle<Code> GetUninitialized(Token::Value op);
604
605 // Helper function for computing the condition for a compare operation.
606 static Condition ComputeCondition(Token::Value op);
607
608 // Helper function for determining the state of a compare IC.
609 static State ComputeState(Code* target);
610
611 static const char* GetStateName(State state);
612
613 private:
614 State TargetState(Handle<Object> x, Handle<Object> y);
615
616 bool strict() const { return op_ == Token::EQ_STRICT; }
617 Condition GetCondition() const { return ComputeCondition(op_); }
618 State GetState() { return ComputeState(target()); }
619
620 Token::Value op_;
621 };
622
623
553 } } // namespace v8::internal 624 } } // namespace v8::internal
554 625
555 #endif // V8_IC_H_ 626 #endif // V8_IC_H_
OLDNEW
« no previous file with comments | « src/ia32/stub-cache-ia32.cc ('k') | src/ic.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698