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

Side by Side Diff: src/ic.cc

Issue 16361015: Migrate Compare ICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Comments Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('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 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 2402 matching lines...) Expand 10 before | Expand all | Expand 10 after
2413 case NUMBER: 2413 case NUMBER:
2414 return MONOMORPHIC; 2414 return MONOMORPHIC;
2415 case GENERIC: 2415 case GENERIC:
2416 return ::v8::internal::GENERIC; 2416 return ::v8::internal::GENERIC;
2417 } 2417 }
2418 UNREACHABLE(); 2418 UNREACHABLE();
2419 return ::v8::internal::UNINITIALIZED; 2419 return ::v8::internal::UNINITIALIZED;
2420 } 2420 }
2421 2421
2422 UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) { 2422 UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
2423 ::v8::internal::TypeInfo operand_type = 2423 v8::internal::TypeInfo operand_type =
2424 ::v8::internal::TypeInfo::TypeFromValue(operand); 2424 v8::internal::TypeInfo::FromValue(operand);
2425 if (operand_type.IsSmi()) { 2425 if (operand_type.IsSmi()) {
2426 return SMI; 2426 return SMI;
2427 } else if (operand_type.IsNumber()) { 2427 } else if (operand_type.IsNumber()) {
2428 return NUMBER; 2428 return NUMBER;
2429 } else { 2429 } else {
2430 return GENERIC; 2430 return GENERIC;
2431 } 2431 }
2432 } 2432 }
2433 2433
2434 2434
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
2538 &caught_exception); 2538 &caught_exception);
2539 if (caught_exception) { 2539 if (caught_exception) {
2540 return Failure::Exception(); 2540 return Failure::Exception();
2541 } 2541 }
2542 return *result; 2542 return *result;
2543 } 2543 }
2544 2544
2545 2545
2546 static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value, 2546 static BinaryOpIC::TypeInfo TypeInfoFromValue(Handle<Object> value,
2547 Token::Value op) { 2547 Token::Value op) {
2548 ::v8::internal::TypeInfo type = 2548 v8::internal::TypeInfo type = v8::internal::TypeInfo::FromValue(value);
2549 ::v8::internal::TypeInfo::TypeFromValue(value);
2550 if (type.IsSmi()) return BinaryOpIC::SMI; 2549 if (type.IsSmi()) return BinaryOpIC::SMI;
2551 if (type.IsInteger32()) { 2550 if (type.IsInteger32()) {
2552 if (kSmiValueSize == 32) return BinaryOpIC::SMI; 2551 if (kSmiValueSize == 32) return BinaryOpIC::SMI;
2553 return BinaryOpIC::INT32; 2552 return BinaryOpIC::INT32;
2554 } 2553 }
2555 if (type.IsNumber()) return BinaryOpIC::NUMBER; 2554 if (type.IsNumber()) return BinaryOpIC::NUMBER;
2556 if (type.IsString()) return BinaryOpIC::STRING; 2555 if (type.IsString()) return BinaryOpIC::STRING;
2557 if (value->IsUndefined()) { 2556 if (value->IsUndefined()) {
2558 if (op == Token::BIT_AND || 2557 if (op == Token::BIT_AND ||
2559 op == Token::BIT_OR || 2558 op == Token::BIT_OR ||
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 switch (state) { 2759 switch (state) {
2761 case UNINITIALIZED: return "UNINITIALIZED"; 2760 case UNINITIALIZED: return "UNINITIALIZED";
2762 case SMI: return "SMI"; 2761 case SMI: return "SMI";
2763 case NUMBER: return "NUMBER"; 2762 case NUMBER: return "NUMBER";
2764 case INTERNALIZED_STRING: return "INTERNALIZED_STRING"; 2763 case INTERNALIZED_STRING: return "INTERNALIZED_STRING";
2765 case STRING: return "STRING"; 2764 case STRING: return "STRING";
2766 case UNIQUE_NAME: return "UNIQUE_NAME"; 2765 case UNIQUE_NAME: return "UNIQUE_NAME";
2767 case OBJECT: return "OBJECT"; 2766 case OBJECT: return "OBJECT";
2768 case KNOWN_OBJECT: return "KNOWN_OBJECT"; 2767 case KNOWN_OBJECT: return "KNOWN_OBJECT";
2769 case GENERIC: return "GENERIC"; 2768 case GENERIC: return "GENERIC";
2770 default:
2771 UNREACHABLE();
2772 return NULL;
2773 } 2769 }
2770 UNREACHABLE();
2771 return NULL;
2774 } 2772 }
2775 2773
2776 2774
2775 Handle<Type> CompareIC::StateToType(
2776 Isolate* isolate,
2777 CompareIC::State state,
2778 Handle<Map> map) {
2779 switch (state) {
2780 case CompareIC::UNINITIALIZED:
2781 return handle(Type::None(), isolate);
2782 case CompareIC::SMI:
2783 return handle(Type::Integer31(), isolate);
2784 case CompareIC::NUMBER:
2785 return handle(Type::Number(), isolate);
2786 case CompareIC::STRING:
2787 return handle(Type::String(), isolate);
2788 case CompareIC::INTERNALIZED_STRING:
2789 return handle(Type::InternalizedString(), isolate);
2790 case CompareIC::UNIQUE_NAME:
2791 return handle(Type::UniqueName(), isolate);
2792 case CompareIC::OBJECT:
2793 return handle(Type::Receiver(), isolate);
2794 case CompareIC::KNOWN_OBJECT:
2795 return handle(
2796 map.is_null() ? Type::Receiver() : Type::Class(map), isolate);
2797 case CompareIC::GENERIC:
2798 return handle(Type::Any(), isolate);
2799 }
2800 UNREACHABLE();
2801 return Handle<Type>();
2802 }
2803
2804
2777 static CompareIC::State InputState(CompareIC::State old_state, 2805 static CompareIC::State InputState(CompareIC::State old_state,
2778 Handle<Object> value) { 2806 Handle<Object> value) {
2779 switch (old_state) { 2807 switch (old_state) {
2780 case CompareIC::UNINITIALIZED: 2808 case CompareIC::UNINITIALIZED:
2781 if (value->IsSmi()) return CompareIC::SMI; 2809 if (value->IsSmi()) return CompareIC::SMI;
2782 if (value->IsHeapNumber()) return CompareIC::NUMBER; 2810 if (value->IsHeapNumber()) return CompareIC::NUMBER;
2783 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING; 2811 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING;
2784 if (value->IsString()) return CompareIC::STRING; 2812 if (value->IsString()) return CompareIC::STRING;
2785 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME; 2813 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME;
2786 if (value->IsJSObject()) return CompareIC::OBJECT; 2814 if (value->IsJSObject()) return CompareIC::OBJECT;
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
2927 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); 2955 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
2928 return ic.target(); 2956 return ic.target();
2929 } 2957 }
2930 2958
2931 2959
2932 void CompareNilIC::Clear(Address address, Code* target) { 2960 void CompareNilIC::Clear(Address address, Code* target) {
2933 if (target->ic_state() == UNINITIALIZED) return; 2961 if (target->ic_state() == UNINITIALIZED) return;
2934 Code::ExtraICState state = target->extended_extra_ic_state(); 2962 Code::ExtraICState state = target->extended_extra_ic_state();
2935 2963
2936 CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED); 2964 CompareNilICStub stub(state, HydrogenCodeStub::UNINITIALIZED);
2937 stub.ClearTypes(); 2965 stub.ClearState();
2938 2966
2939 Code* code = NULL; 2967 Code* code = NULL;
2940 CHECK(stub.FindCodeInCache(&code, target->GetIsolate())); 2968 CHECK(stub.FindCodeInCache(&code, target->GetIsolate()));
2941 2969
2942 SetTargetAtAddress(address, code); 2970 SetTargetAtAddress(address, code);
2943 } 2971 }
2944 2972
2945 2973
2946 MaybeObject* CompareNilIC::DoCompareNilSlow(NilValue nil, 2974 MaybeObject* CompareNilIC::DoCompareNilSlow(NilValue nil,
2947 Handle<Object> object) { 2975 Handle<Object> object) {
2948 if (object->IsNull() || object->IsUndefined()) { 2976 if (object->IsNull() || object->IsUndefined()) {
2949 return Smi::FromInt(true); 2977 return Smi::FromInt(true);
2950 } 2978 }
2951 return Smi::FromInt(object->IsUndetectableObject()); 2979 return Smi::FromInt(object->IsUndetectableObject());
2952 } 2980 }
2953 2981
2954 2982
2955 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { 2983 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) {
2956 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state(); 2984 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state();
2957 2985
2958 CompareNilICStub stub(extra_ic_state); 2986 CompareNilICStub stub(extra_ic_state);
2959 2987
2960 // Extract the current supported types from the patched IC and calculate what 2988 // Extract the current supported types from the patched IC and calculate what
2961 // types must be supported as a result of the miss. 2989 // types must be supported as a result of the miss.
2962 bool already_monomorphic = stub.IsMonomorphic(); 2990 bool already_monomorphic = stub.IsMonomorphic();
2963 2991
2964 CompareNilICStub::Types old_types = stub.GetTypes(); 2992 CompareNilICStub::State old_state = stub.GetState();
2965 stub.Record(object); 2993 stub.Record(object);
2966 old_types.TraceTransition(stub.GetTypes()); 2994 old_state.TraceTransition(stub.GetState());
2967 2995
2968 NilValue nil = stub.GetNilValue(); 2996 NilValue nil = stub.GetNilValue();
2969 2997
2970 // Find or create the specialized stub to support the new set of types. 2998 // Find or create the specialized stub to support the new set of types.
2971 Handle<Code> code; 2999 Handle<Code> code;
2972 if (stub.IsMonomorphic()) { 3000 if (stub.IsMonomorphic()) {
2973 Handle<Map> monomorphic_map(already_monomorphic 3001 Handle<Map> monomorphic_map(already_monomorphic
2974 ? target()->FindFirstMap() 3002 ? target()->FindFirstMap()
2975 : HeapObject::cast(*object)->map()); 3003 : HeapObject::cast(*object)->map());
2976 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, stub); 3004 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, stub);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
3024 #undef ADDR 3052 #undef ADDR
3025 }; 3053 };
3026 3054
3027 3055
3028 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3056 Address IC::AddressFromUtilityId(IC::UtilityId id) {
3029 return IC_utilities[id]; 3057 return IC_utilities[id];
3030 } 3058 }
3031 3059
3032 3060
3033 } } // namespace v8::internal 3061 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698