Chromium Code Reviews| 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 2390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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 Loading... | |
| 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: return handle(Type::None(), isolate); | |
| 2513 case SMI: return handle(Type::Integer31(), isolate); | |
|
rossberg
2013/06/13 14:24:30
Nit: can we get rid of the non-standard layout her
Jakob Kummerow
2013/06/14 14:26:57
Done -- although I kind of liked it the way it was
| |
| 2514 case INT32: return handle(Type::Integer32(), isolate); | |
| 2515 case NUMBER: return handle(Type::Number(), isolate); | |
| 2516 case ODDBALL: | |
| 2517 return handle(Type::Optional(handle(Type::Number(), isolate)), isolate); | |
|
rossberg
2013/06/13 14:24:30
That's a change, is that correct? In particular, w
Jakob Kummerow
2013/06/14 14:26:57
Oops, overlooked that the stub handles strings too
| |
| 2518 case STRING: return handle(Type::String(), isolate); | |
| 2519 case GENERIC: return handle(Type::Any(), isolate); | |
| 2520 } | |
| 2521 UNREACHABLE(); | |
| 2522 return handle(Type::Any(), isolate); | |
| 2523 } | |
| 2524 | |
| 2525 | |
| 2526 void BinaryOpIC::StubInfoToType(int minor_key, | |
| 2527 Handle<Type>* left, | |
| 2528 Handle<Type>* right, | |
| 2529 Handle<Type>* result, | |
| 2530 Isolate* isolate) { | |
| 2531 TypeInfo left_typeinfo, right_typeinfo, result_typeinfo; | |
| 2532 BinaryOpStub::decode_types_from_minor_key( | |
| 2533 minor_key, &left_typeinfo, &right_typeinfo, &result_typeinfo); | |
| 2534 *left = TypeInfoToType(left_typeinfo, isolate); | |
| 2535 *right = TypeInfoToType(right_typeinfo, isolate); | |
| 2536 *result = TypeInfoToType(result_typeinfo, isolate); | |
| 2537 } | |
| 2538 | |
| 2539 | |
| 2492 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { | 2540 RUNTIME_FUNCTION(MaybeObject*, UnaryOp_Patch) { |
| 2493 ASSERT(args.length() == 4); | 2541 ASSERT(args.length() == 4); |
| 2494 | 2542 |
| 2495 HandleScope scope(isolate); | 2543 HandleScope scope(isolate); |
| 2496 Handle<Object> operand = args.at<Object>(0); | 2544 Handle<Object> operand = args.at<Object>(0); |
| 2497 Token::Value op = static_cast<Token::Value>(args.smi_at(1)); | 2545 Token::Value op = static_cast<Token::Value>(args.smi_at(1)); |
| 2498 UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2)); | 2546 UnaryOverwriteMode mode = static_cast<UnaryOverwriteMode>(args.smi_at(2)); |
| 2499 UnaryOpIC::TypeInfo previous_type = | 2547 UnaryOpIC::TypeInfo previous_type = |
| 2500 static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3)); | 2548 static_cast<UnaryOpIC::TypeInfo>(args.smi_at(3)); |
| 2501 | 2549 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2795 return handle( | 2843 return handle( |
| 2796 map.is_null() ? Type::Receiver() : Type::Class(map), isolate); | 2844 map.is_null() ? Type::Receiver() : Type::Class(map), isolate); |
| 2797 case CompareIC::GENERIC: | 2845 case CompareIC::GENERIC: |
| 2798 return handle(Type::Any(), isolate); | 2846 return handle(Type::Any(), isolate); |
| 2799 } | 2847 } |
| 2800 UNREACHABLE(); | 2848 UNREACHABLE(); |
| 2801 return Handle<Type>(); | 2849 return Handle<Type>(); |
| 2802 } | 2850 } |
| 2803 | 2851 |
| 2804 | 2852 |
| 2805 static CompareIC::State InputState(CompareIC::State old_state, | 2853 void CompareIC::StubInfoToType(int stub_minor_key, |
| 2806 Handle<Object> value) { | 2854 Handle<Type>* left_type, |
| 2855 Handle<Type>* right_type, | |
| 2856 Handle<Type>* overall_type, | |
| 2857 Handle<Map> map, | |
| 2858 Isolate* isolate) { | |
| 2859 State left_state, right_state, handler_state; | |
| 2860 ICCompareStub::DecodeMinorKey(stub_minor_key, &left_state, &right_state, | |
| 2861 &handler_state, NULL); | |
| 2862 *left_type = StateToType(isolate, left_state); | |
| 2863 *right_type = StateToType(isolate, right_state); | |
| 2864 *overall_type = StateToType(isolate, handler_state, map); | |
| 2865 } | |
| 2866 | |
| 2867 | |
| 2868 CompareIC::State CompareIC::NewInputState(State old_state, | |
| 2869 Handle<Object> value) { | |
| 2807 switch (old_state) { | 2870 switch (old_state) { |
| 2808 case CompareIC::UNINITIALIZED: | 2871 case UNINITIALIZED: |
| 2809 if (value->IsSmi()) return CompareIC::SMI; | 2872 if (value->IsSmi()) return SMI; |
| 2810 if (value->IsHeapNumber()) return CompareIC::NUMBER; | 2873 if (value->IsHeapNumber()) return NUMBER; |
| 2811 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING; | 2874 if (value->IsInternalizedString()) return INTERNALIZED_STRING; |
| 2812 if (value->IsString()) return CompareIC::STRING; | 2875 if (value->IsString()) return STRING; |
| 2813 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME; | 2876 if (value->IsSymbol()) return UNIQUE_NAME; |
| 2814 if (value->IsJSObject()) return CompareIC::OBJECT; | 2877 if (value->IsJSObject()) return OBJECT; |
| 2815 break; | 2878 break; |
| 2816 case CompareIC::SMI: | 2879 case SMI: |
| 2817 if (value->IsSmi()) return CompareIC::SMI; | 2880 if (value->IsSmi()) return SMI; |
| 2818 if (value->IsHeapNumber()) return CompareIC::NUMBER; | 2881 if (value->IsHeapNumber()) return NUMBER; |
| 2819 break; | 2882 break; |
| 2820 case CompareIC::NUMBER: | 2883 case NUMBER: |
| 2821 if (value->IsNumber()) return CompareIC::NUMBER; | 2884 if (value->IsNumber()) return NUMBER; |
| 2822 break; | 2885 break; |
| 2823 case CompareIC::INTERNALIZED_STRING: | 2886 case INTERNALIZED_STRING: |
| 2824 if (value->IsInternalizedString()) return CompareIC::INTERNALIZED_STRING; | 2887 if (value->IsInternalizedString()) return INTERNALIZED_STRING; |
| 2825 if (value->IsString()) return CompareIC::STRING; | 2888 if (value->IsString()) return STRING; |
| 2826 if (value->IsSymbol()) return CompareIC::UNIQUE_NAME; | 2889 if (value->IsSymbol()) return UNIQUE_NAME; |
| 2827 break; | 2890 break; |
| 2828 case CompareIC::STRING: | 2891 case STRING: |
| 2829 if (value->IsString()) return CompareIC::STRING; | 2892 if (value->IsString()) return STRING; |
| 2830 break; | 2893 break; |
| 2831 case CompareIC::UNIQUE_NAME: | 2894 case UNIQUE_NAME: |
| 2832 if (value->IsUniqueName()) return CompareIC::UNIQUE_NAME; | 2895 if (value->IsUniqueName()) return UNIQUE_NAME; |
| 2833 break; | 2896 break; |
| 2834 case CompareIC::OBJECT: | 2897 case OBJECT: |
| 2835 if (value->IsJSObject()) return CompareIC::OBJECT; | 2898 if (value->IsJSObject()) return OBJECT; |
| 2836 break; | 2899 break; |
| 2837 case CompareIC::GENERIC: | 2900 case GENERIC: |
| 2838 break; | 2901 break; |
| 2839 case CompareIC::KNOWN_OBJECT: | 2902 case KNOWN_OBJECT: |
| 2840 UNREACHABLE(); | 2903 UNREACHABLE(); |
| 2841 break; | 2904 break; |
| 2842 } | 2905 } |
| 2843 return CompareIC::GENERIC; | 2906 return GENERIC; |
| 2844 } | 2907 } |
| 2845 | 2908 |
| 2846 | 2909 |
| 2847 CompareIC::State CompareIC::TargetState(State old_state, | 2910 CompareIC::State CompareIC::TargetState(State old_state, |
| 2848 State old_left, | 2911 State old_left, |
| 2849 State old_right, | 2912 State old_right, |
| 2850 bool has_inlined_smi_code, | 2913 bool has_inlined_smi_code, |
| 2851 Handle<Object> x, | 2914 Handle<Object> x, |
| 2852 Handle<Object> y) { | 2915 Handle<Object> y) { |
| 2853 switch (old_state) { | 2916 switch (old_state) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2906 UNREACHABLE(); | 2969 UNREACHABLE(); |
| 2907 return GENERIC; // Make the compiler happy. | 2970 return GENERIC; // Make the compiler happy. |
| 2908 } | 2971 } |
| 2909 | 2972 |
| 2910 | 2973 |
| 2911 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { | 2974 void CompareIC::UpdateCaches(Handle<Object> x, Handle<Object> y) { |
| 2912 HandleScope scope(isolate()); | 2975 HandleScope scope(isolate()); |
| 2913 State previous_left, previous_right, previous_state; | 2976 State previous_left, previous_right, previous_state; |
| 2914 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left, | 2977 ICCompareStub::DecodeMinorKey(target()->stub_info(), &previous_left, |
| 2915 &previous_right, &previous_state, NULL); | 2978 &previous_right, &previous_state, NULL); |
| 2916 State new_left = InputState(previous_left, x); | 2979 State new_left = NewInputState(previous_left, x); |
| 2917 State new_right = InputState(previous_right, y); | 2980 State new_right = NewInputState(previous_right, y); |
| 2918 State state = TargetState(previous_state, previous_left, previous_right, | 2981 State state = TargetState(previous_state, previous_left, previous_right, |
| 2919 HasInlinedSmiCode(address()), x, y); | 2982 HasInlinedSmiCode(address()), x, y); |
| 2920 ICCompareStub stub(op_, new_left, new_right, state); | 2983 ICCompareStub stub(op_, new_left, new_right, state); |
| 2921 if (state == KNOWN_OBJECT) { | 2984 if (state == KNOWN_OBJECT) { |
| 2922 stub.set_known_map( | 2985 stub.set_known_map( |
| 2923 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); | 2986 Handle<Map>(Handle<JSObject>::cast(x)->map(), isolate())); |
| 2924 } | 2987 } |
| 2925 set_target(*stub.GetCode(isolate())); | 2988 set_target(*stub.GetCode(isolate())); |
| 2926 | 2989 |
| 2927 #ifdef DEBUG | 2990 #ifdef DEBUG |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3052 #undef ADDR | 3115 #undef ADDR |
| 3053 }; | 3116 }; |
| 3054 | 3117 |
| 3055 | 3118 |
| 3056 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3119 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3057 return IC_utilities[id]; | 3120 return IC_utilities[id]; |
| 3058 } | 3121 } |
| 3059 | 3122 |
| 3060 | 3123 |
| 3061 } } // namespace v8::internal | 3124 } } // namespace v8::internal |
| OLD | NEW |