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

Side by Side Diff: src/ic.cc

Issue 16957004: Migrate BinaryOpICs and UnaryOpICs to new type rep (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed 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
« src/hydrogen.cc ('K') | « src/ic.h ('k') | src/type-info.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 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after
2401 case NUMBER: return "Number"; 2401 case NUMBER: return "Number";
2402 case GENERIC: return "Generic"; 2402 case GENERIC: return "Generic";
2403 default: return "Invalid"; 2403 default: return "Invalid";
2404 } 2404 }
2405 } 2405 }
2406 2406
2407 2407
2408 UnaryOpIC::State UnaryOpIC::ToState(TypeInfo type_info) { 2408 UnaryOpIC::State UnaryOpIC::ToState(TypeInfo type_info) {
2409 switch (type_info) { 2409 switch (type_info) {
2410 case UNINITIALIZED: 2410 case UNINITIALIZED:
2411 return ::v8::internal::UNINITIALIZED; 2411 return v8::internal::UNINITIALIZED;
2412 case SMI: 2412 case SMI:
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
2423 Handle<Type> UnaryOpIC::TypeInfoToType(TypeInfo type_info, Isolate* isolate) {
2424 switch (type_info) {
2425 case UNINITIALIZED:
2426 return handle(Type::None(), isolate);
2427 case SMI:
2428 return handle(Type::Integer31(), isolate);
2429 case NUMBER:
2430 return handle(Type::Number(), isolate);
2431 case GENERIC:
2432 return handle(Type::Any(), isolate);
2433 }
2434 UNREACHABLE();
2435 return handle(Type::Any(), isolate);
2436 }
2437
2438
2422 UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) { 2439 UnaryOpIC::TypeInfo UnaryOpIC::GetTypeInfo(Handle<Object> operand) {
2423 v8::internal::TypeInfo operand_type = 2440 v8::internal::TypeInfo operand_type =
2424 v8::internal::TypeInfo::FromValue(operand); 2441 v8::internal::TypeInfo::FromValue(operand);
2425 if (operand_type.IsSmi()) { 2442 if (operand_type.IsSmi()) {
2426 return SMI; 2443 return SMI;
2427 } else if (operand_type.IsNumber()) { 2444 } else if (operand_type.IsNumber()) {
2428 return NUMBER; 2445 return NUMBER;
2429 } else { 2446 } else {
2430 return GENERIC; 2447 return GENERIC;
2431 } 2448 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2482 case STRING: 2499 case STRING:
2483 return MONOMORPHIC; 2500 return MONOMORPHIC;
2484 case GENERIC: 2501 case GENERIC:
2485 return ::v8::internal::GENERIC; 2502 return ::v8::internal::GENERIC;
2486 } 2503 }
2487 UNREACHABLE(); 2504 UNREACHABLE();
2488 return ::v8::internal::UNINITIALIZED; 2505 return ::v8::internal::UNINITIALIZED;
2489 } 2506 }
2490 2507
2491 2508
2509 Handle<Type> BinaryOpIC::TypeInfoToType(BinaryOpIC::TypeInfo binary_type,
2510 Isolate* isolate) {
2511 switch (binary_type) {
2512 case UNINITIALIZED:
2513 return handle(Type::None(), isolate);
2514 case SMI:
2515 return handle(Type::Integer31(), isolate);
2516 case INT32:
2517 return handle(Type::Integer32(), isolate);
2518 case NUMBER:
2519 return handle(Type::Number(), isolate);
2520 case ODDBALL:
2521 return handle(Type::Optional(
2522 handle(Type::Union(
2523 handle(Type::Number(), isolate),
2524 handle(Type::String(), isolate)), isolate)), isolate);
2525 case STRING:
2526 return handle(Type::String(), isolate);
2527 case GENERIC:
2528 return handle(Type::Any(), isolate);
2529 }
2530 UNREACHABLE();
2531 return handle(Type::Any(), isolate);
2532 }
2533
2534
2535 void BinaryOpIC::StubInfoToType(int minor_key,
2536 Handle<Type>* left,
2537 Handle<Type>* right,
2538 Handle<Type>* result,
2539 Isolate* isolate) {
2540 TypeInfo left_typeinfo, right_typeinfo, result_typeinfo;
2541 BinaryOpStub::decode_types_from_minor_key(
2542 minor_key, &left_typeinfo, &right_typeinfo, &result_typeinfo);
2543 *left = TypeInfoToType(left_typeinfo, isolate);
2544 *right = TypeInfoToType(right_typeinfo, isolate);
2545 *result = TypeInfoToType(result_typeinfo, isolate);
2546 }
2547
2548
2492 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { 2549 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) {
2493 ASSERT(args.length() == 4); 2550 ASSERT(args.length() == 4);
2494 2551
2495 HandleScope scope(isolate); 2552 HandleScope scope(isolate);
2496 Handle<Object> operand = args.at<Object>(0); 2553 Handle<Object> operand = args.at<Object>(0);
2497 Token::Value op = static_cast<Token::Value>(args.smi_at(1)); 2554 Token::Value op = static_cast<Token::Value>(args.smi_at(1));
2498 UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2)); 2555 UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2));
2499 UnaryOpIC::TypeInfo previous_type = 2556 UnaryOpIC::TypeInfo previous_type =
2500 static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3)); 2557 static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3));
2501 2558
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
2795 return handle( 2852 return handle(
2796 map.is_null() ? Type::Receiver() : Type::Class(map), isolate); 2853 map.is_null() ? Type::Receiver() : Type::Class(map), isolate);
2797 case CompareIC::GENERIC: 2854 case CompareIC::GENERIC:
2798 return handle(Type::Any(), isolate); 2855 return handle(Type::Any(), isolate);
2799 } 2856 }
2800 UNREACHABLE(); 2857 UNREACHABLE();
2801 return Handle<Type>(); 2858 return Handle<Type>();
2802 } 2859 }
2803 2860
2804 2861
2805 static CompareIC::State InputState(CompareIC::State old_state, 2862 void CompareIC::StubInfoToType(int stub_minor_key,
2806 Handle<Object> value) { 2863 Handle<Type>* left_type,
2864 Handle<Type>* right_type,
2865 Handle<Type>* overall_type,
2866 Handle<Map> map,
2867 Isolate* isolate) {
2868 State left_state, right_state, handler_state;
2869 ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state,
2870 &handler_state, NULL);
2871 *left_type = StateToType(isolate, left_state);
2872 *right_type = StateToType(isolate, right_state);
2873 *overall_type = StateToType(isolate, handler_state, map);
2874 }
2875
2876
2877 CompareIC::State CompareIC::NewInputState(State old_state,
2878 Handle<Object> value) {
2807 switch (old_state) { 2879 switch (old_state) {
2808 case CompareIC::UNINITIALIZED: 2880 case UNINITIALIZED:
2809 if (value->IsSmi()) return CompareIC::SMI; 2881 if (value->IsSmi()) return SMI;
2810 if (value->IsHeapNumber()) return CompareIC::NUMBER; 2882 if (value->IsHeapNumber()) return NUMBER;
2811 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING; 2883 if (value->IsInternalizedString()) return INTERNALIZED_STRING;
2812 if (value->IsString()) return CompareIC::STRING; 2884 if (value->IsString()) return STRING;
2813 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME; 2885 if (value->IsSymbol()) return UNIQUE_NAME;
2814 if (value->IsJSObject()) return CompareIC::OBJECT; 2886 if (value->IsJSObject()) return OBJECT;
2815 break; 2887 break;
2816 case CompareIC::SMI: 2888 case SMI:
2817 if (value->IsSmi()) return CompareIC::SMI; 2889 if (value->IsSmi()) return SMI;
2818 if (value->IsHeapNumber()) return CompareIC::NUMBER; 2890 if (value->IsHeapNumber()) return NUMBER;
2819 break; 2891 break;
2820 case CompareIC::NUMBER: 2892 case NUMBER:
2821 if (value->IsNumber()) return CompareIC::NUMBER; 2893 if (value->IsNumber()) return NUMBER;
2822 break; 2894 break;
2823 case CompareIC::INTERNALIZED_STRING: 2895 case INTERNALIZED_STRING:
2824 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING; 2896 if (value->IsInternalizedString()) return INTERNALIZED_STRING;
2825 if (value->IsString()) return CompareIC::STRING; 2897 if (value->IsString()) return STRING;
2826 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME; 2898 if (value->IsSymbol()) return UNIQUE_NAME;
2827 break; 2899 break;
2828 case CompareIC::STRING: 2900 case STRING:
2829 if (value->IsString()) return CompareIC::STRING; 2901 if (value->IsString()) return STRING;
2830 break; 2902 break;
2831 case CompareIC::UNIQUE_NAME: 2903 case UNIQUE_NAME:
2832 if (value->IsUniqueName()) return CompareIC::UNIQUE_NAME; 2904 if (value->IsUniqueName()) return UNIQUE_NAME;
2833 break; 2905 break;
2834 case CompareIC::OBJECT: 2906 case OBJECT:
2835 if (value->IsJSObject()) return CompareIC::OBJECT; 2907 if (value->IsJSObject()) return OBJECT;
2836 break; 2908 break;
2837 case CompareIC::GENERIC: 2909 case GENERIC:
2838 break; 2910 break;
2839 case CompareIC::KNOWN_OBJECT: 2911 case KNOWN_OBJECT:
2840 UNREACHABLE(); 2912 UNREACHABLE();
2841 break; 2913 break;
2842 } 2914 }
2843 return CompareIC::GENERIC; 2915 return GENERIC;
2844 } 2916 }
2845 2917
2846 2918
2847 CompareIC::State CompareIC::TargetState(State old_state, 2919 CompareIC::State CompareIC::TargetState(State old_state,
2848 State old_left, 2920 State old_left,
2849 State old_right, 2921 State old_right,
2850 bool has_inlined_smi_code, 2922 bool has_inlined_smi_code,
2851 Handle<Object> x, 2923 Handle<Object> x,
2852 Handle<Object> y) { 2924 Handle<Object> y) {
2853 switch (old_state) { 2925 switch (old_state) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2906 UNREACHABLE(); 2978 UNREACHABLE();
2907 return GENERIC; // Make the compiler happy. 2979 return GENERIC; // Make the compiler happy.
2908 } 2980 }
2909 2981
2910 2982
2911 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { 2983 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) {
2912 HandleScope scope(isolate()); 2984 HandleScope scope(isolate());
2913 State previous_left, previous_right, previous_state; 2985 State previous_left, previous_right, previous_state;
2914 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left, 2986 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left,
2915 &previous_right, &previous_state, NULL); 2987 &previous_right, &previous_state, NULL);
2916 State new_left = InputState(previous_left, x); 2988 State new_left = NewInputState(previous_left, x);
2917 State new_right = InputState(previous_right, y); 2989 State new_right = NewInputState(previous_right, y);
2918 State state = TargetState(previous_state, previous_left, previous_right, 2990 State state = TargetState(previous_state, previous_left, previous_right,
2919 HasInlinedSmiCode(address()), x, y); 2991 HasInlinedSmiCode(address()), x, y);
2920 ICCompareStub stub(op_, new_left, new_right, state); 2992 ICCompareStub stub(op_, new_left, new_right, state);
2921 if (state == KNOWN_OBJECT) { 2993 if (state == KNOWN_OBJECT) {
2922 stub.set_known_map( 2994 stub.set_known_map(
2923 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); 2995 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate()));
2924 } 2996 }
2925 set_target(*stub.GetCode(isolate())); 2997 set_target(*stub.GetCode(isolate()));
2926 2998
2927 #ifdef DEBUG 2999 #ifdef DEBUG
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3052 #undef ADDR 3124 #undef ADDR
3053 }; 3125 };
3054 3126
3055 3127
3056 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3128 Address IC::AddressFromUtilityId(IC::UtilityId id) {
3057 return IC_utilities[id]; 3129 return IC_utilities[id];
3058 } 3130 }
3059 3131
3060 3132
3061 } } // namespace v8::internal 3133 } } // namespace v8::internal
OLDNEW
« src/hydrogen.cc ('K') | « src/ic.h ('k') | src/type-info.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698