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

Side by Side Diff: src/ic.cc

Issue 14862009: Encapsulating Type information in the CompareICStub (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 7 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
« src/hydrogen.cc ('K') | « 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 2830 matching lines...) Expand 10 before | Expand all | Expand 10 after
2841 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc. 2841 // Used from ICCompareStub::GenerateMiss in code-stubs-<arch>.cc.
2842 RUNTIME_FUNCTION(Code*, CompareIC_Miss) { 2842 RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
2843 NoHandleAllocation na(isolate); 2843 NoHandleAllocation na(isolate);
2844 ASSERT(args.length() == 3); 2844 ASSERT(args.length() == 3);
2845 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2))); 2845 CompareIC ic(isolate, static_cast<Token::Value>(args.smi_at(2)));
2846 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); 2846 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
2847 return ic.target(); 2847 return ic.target();
2848 } 2848 }
2849 2849
2850 2850
2851 Code* CompareNilIC::GetRawUninitialized(EqualityKind kind,
2852 NilValue nil) {
2853 CompareNilICStub stub(kind, nil);
2854 Code* code = NULL;
2855 CHECK(stub.FindCodeInCache(&code, Isolate::Current()));
2856 return code;
2857 }
2858
2859
2860 void CompareNilIC::Clear(Address address, Code* target) { 2851 void CompareNilIC::Clear(Address address, Code* target) {
2861 if (target->ic_state() == UNINITIALIZED) return; 2852 if (target->ic_state() == UNINITIALIZED) return;
2862 Code::ExtraICState state = target->extended_extra_ic_state(); 2853 Code::ExtraICState state = target->extended_extra_ic_state();
2863 2854
2864 EqualityKind kind = 2855 CompareNilICStub stub(state, CompareNilICStub::CODE_STUB_IS_MISS);
2865 CompareNilICStub::EqualityKindFromExtraICState(state); 2856 stub.ClearTypes();
2866 NilValue nil =
2867 CompareNilICStub::NilValueFromExtraICState(state);
2868 2857
2869 SetTargetAtAddress(address, GetRawUninitialized(kind, nil)); 2858 Code* code = NULL;
2859 CHECK(stub.FindCodeInCache(&code, target->GetIsolate()));
2860
2861 SetTargetAtAddress(address, code);
2870 } 2862 }
2871 2863
2872 2864
2873 MaybeObject* CompareNilIC::DoCompareNilSlow(EqualityKind kind, 2865 MaybeObject* CompareNilIC::DoCompareNilSlow(EqualityKind kind,
2874 NilValue nil, 2866 NilValue nil,
2875 Handle<Object> object) { 2867 Handle<Object> object) {
2876 if (kind == kStrictEquality) { 2868 if (kind == kStrictEquality) {
2877 if (nil == kNullValue) { 2869 if (nil == kNullValue) {
2878 return Smi::FromInt(object->IsNull()); 2870 return Smi::FromInt(object->IsNull());
2879 } else { 2871 } else {
2880 return Smi::FromInt(object->IsUndefined()); 2872 return Smi::FromInt(object->IsUndefined());
2881 } 2873 }
2882 } 2874 }
2883 if (object->IsNull() || object->IsUndefined()) { 2875 if (object->IsNull() || object->IsUndefined()) {
2884 return Smi::FromInt(true); 2876 return Smi::FromInt(true);
2885 } 2877 }
2886 return Smi::FromInt(object->IsUndetectableObject()); 2878 return Smi::FromInt(object->IsUndetectableObject());
2887 } 2879 }
2888 2880
2889 2881
2890 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) { 2882 MaybeObject* CompareNilIC::CompareNil(Handle<Object> object) {
2891 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state(); 2883 Code::ExtraICState extra_ic_state = target()->extended_extra_ic_state();
2892 2884
2885 CompareNilICStub stub(extra_ic_state);
2886
2893 // Extract the current supported types from the patched IC and calculate what 2887 // Extract the current supported types from the patched IC and calculate what
2894 // types must be supported as a result of the miss. 2888 // types must be supported as a result of the miss.
2895 bool already_monomorphic; 2889 bool already_monomorphic = stub.IsMonomorphic();
2896 CompareNilICStub::Types types =
2897 CompareNilICStub::GetPatchedICFlags(extra_ic_state,
2898 object, &already_monomorphic);
2899 2890
2900 EqualityKind kind = 2891 stub.Record(object);
2901 CompareNilICStub::EqualityKindFromExtraICState(extra_ic_state); 2892
2902 NilValue nil = 2893 EqualityKind kind = stub.GetKind();
2903 CompareNilICStub::NilValueFromExtraICState(extra_ic_state); 2894 NilValue nil = stub.GetNilValue();
2904 2895
2905 // Find or create the specialized stub to support the new set of types. 2896 // Find or create the specialized stub to support the new set of types.
2906 CompareNilICStub stub(kind, nil, types);
2907 Handle<Code> code; 2897 Handle<Code> code;
2908 if ((types & CompareNilICStub::kCompareAgainstMonomorphicMap) != 0) { 2898 if (stub.IsMonomorphic()) {
2909 Handle<Map> monomorphic_map(already_monomorphic 2899 Handle<Map> monomorphic_map(already_monomorphic
2910 ? target()->FindFirstMap() 2900 ? target()->FindFirstMap()
2911 : HeapObject::cast(*object)->map()); 2901 : HeapObject::cast(*object)->map());
2912 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, 2902 code = isolate()->stub_cache()->ComputeCompareNil(monomorphic_map, stub);
2913 nil,
2914 stub.GetTypes());
2915 } else { 2903 } else {
2916 code = stub.GetCode(isolate()); 2904 code = stub.GetCode(isolate());
2917 } 2905 }
2918 2906
2919 patch(*code); 2907 patch(*code);
2920 2908
2921 return DoCompareNilSlow(kind, nil, object); 2909 return DoCompareNilSlow(kind, nil, object);
2922 } 2910 }
2923 2911
2924 2912
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2974 #undef ADDR 2962 #undef ADDR
2975 }; 2963 };
2976 2964
2977 2965
2978 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2966 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2979 return IC_utilities[id]; 2967 return IC_utilities[id];
2980 } 2968 }
2981 2969
2982 2970
2983 } } // namespace v8::internal 2971 } } // namespace v8::internal
OLDNEW
« src/hydrogen.cc ('K') | « src/ic.h ('k') | src/objects.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698