OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/intermediate_language.h" | 5 #include "vm/intermediate_language.h" |
6 | 6 |
7 #include "vm/bit_vector.h" | 7 #include "vm/bit_vector.h" |
8 #include "vm/bootstrap.h" | 8 #include "vm/bootstrap.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/constant_propagator.h" | 10 #include "vm/constant_propagator.h" |
(...skipping 3020 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3031 if (!FLAG_two_args_smi_icd) { | 3031 if (!FLAG_two_args_smi_icd) { |
3032 return 0; | 3032 return 0; |
3033 } | 3033 } |
3034 switch (kind) { | 3034 switch (kind) { |
3035 case Token::kADD: return StubCode::SmiAddInlineCache_entry(); | 3035 case Token::kADD: return StubCode::SmiAddInlineCache_entry(); |
3036 case Token::kSUB: return StubCode::SmiSubInlineCache_entry(); | 3036 case Token::kSUB: return StubCode::SmiSubInlineCache_entry(); |
3037 case Token::kEQ: return StubCode::SmiEqualInlineCache_entry(); | 3037 case Token::kEQ: return StubCode::SmiEqualInlineCache_entry(); |
3038 default: return NULL; | 3038 default: return NULL; |
3039 } | 3039 } |
3040 } | 3040 } |
3041 #else | |
3042 static void TryFastPathSmiOp( | |
3043 FlowGraphCompiler* compiler, ICData* call_ic_data, const String& name) { | |
3044 if (!FLAG_two_args_smi_icd) { | |
3045 return; | |
3046 } | |
3047 if ((name.raw() == Symbols::Plus().raw()) || | |
3048 (name.raw() == Symbols::Minus().raw()) || | |
3049 (name.raw() == Symbols::EqualOperator().raw()) || | |
3050 (name.raw() == Symbols::LAngleBracket().raw()) || | |
3051 (name.raw() == Symbols::RAngleBracket().raw()) || | |
3052 (name.raw() == Symbols::BitAnd().raw()) || | |
3053 (name.raw() == Symbols::BitOr().raw()) || | |
3054 (name.raw() == Symbols::Star().raw())) { | |
3055 bool is_smi_two_args_op = call_ic_data->AddSmiSmiCheckForFastSmiStubs(); | |
3056 ASSERT(is_smi_two_args_op); | |
3057 } | |
3058 if (name.raw() == Symbols::Plus().raw()) { | |
3059 __ AddTOS(); | |
3060 } else if (name.raw() == Symbols::Minus().raw()) { | |
3061 __ SubTOS(); | |
3062 } else if (name.raw() == Symbols::EqualOperator().raw()) { | |
3063 __ EqualTOS(); | |
3064 } else if (name.raw() == Symbols::LAngleBracket().raw()) { | |
3065 __ LessThanTOS(); | |
3066 } else if (name.raw() == Symbols::RAngleBracket().raw()) { | |
3067 __ GreaterThanTOS(); | |
3068 } else if (name.raw() == Symbols::BitAnd().raw()) { | |
3069 __ BitAndTOS(); | |
3070 } else if (name.raw() == Symbols::BitOr().raw()) { | |
3071 __ BitOrTOS(); | |
3072 } else if (name.raw() == Symbols::Star().raw()) { | |
3073 __ MulTOS(); | |
3074 } | |
Vyacheslav Egorov (Google)
2016/05/31 14:55:44
maybe:
} else {
return;
}
bool is_smi_two_args
zra
2016/05/31 16:33:12
Done.
| |
3075 } | |
3041 #endif | 3076 #endif |
3042 | 3077 |
3043 | 3078 |
3044 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { | 3079 void InstanceCallInstr::EmitNativeCode(FlowGraphCompiler* compiler) { |
3045 Zone* zone = compiler->zone(); | 3080 Zone* zone = compiler->zone(); |
3046 const ICData* call_ic_data = NULL; | 3081 const ICData* call_ic_data = NULL; |
3047 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || | 3082 if (!FLAG_propagate_ic_data || !compiler->is_optimizing() || |
3048 (ic_data() == NULL)) { | 3083 (ic_data() == NULL)) { |
3049 const Array& arguments_descriptor = | 3084 const Array& arguments_descriptor = |
3050 Array::Handle(zone, ArgumentsDescriptor::New(ArgumentCount(), | 3085 Array::Handle(zone, ArgumentsDescriptor::New(ArgumentCount(), |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3103 deopt_id(), token_pos(), locs()); | 3138 deopt_id(), token_pos(), locs()); |
3104 } else { | 3139 } else { |
3105 compiler->GenerateInstanceCall(deopt_id(), | 3140 compiler->GenerateInstanceCall(deopt_id(), |
3106 token_pos(), | 3141 token_pos(), |
3107 ArgumentCount(), | 3142 ArgumentCount(), |
3108 locs(), | 3143 locs(), |
3109 *call_ic_data); | 3144 *call_ic_data); |
3110 } | 3145 } |
3111 } | 3146 } |
3112 #else | 3147 #else |
3113 call_ic_data = &ICData::ZoneHandle(call_ic_data->Original()); | 3148 ICData* ic_data = &ICData::ZoneHandle(call_ic_data->Original()); |
3114 | 3149 |
3115 // Emit smi fast path instruction. If fast-path succeeds it skips the next | 3150 // Emit smi fast path instruction. If fast-path succeeds it skips the next |
3116 // instruction otherwise it falls through. | 3151 // instruction otherwise it falls through. |
3117 if (function_name().raw() == Symbols::Plus().raw()) { | 3152 TryFastPathSmiOp(compiler, ic_data, function_name()); |
3118 __ AddTOS(); | |
3119 } else if (function_name().raw() == Symbols::EqualOperator().raw()) { | |
3120 __ EqualTOS(); | |
3121 } else if (function_name().raw() == Symbols::LAngleBracket().raw()) { | |
3122 __ LessThanTOS(); | |
3123 } else if (function_name().raw() == Symbols::RAngleBracket().raw()) { | |
3124 __ GreaterThanTOS(); | |
3125 } else if (function_name().raw() == Symbols::BitAnd().raw()) { | |
3126 __ BitAndTOS(); | |
3127 } else if (function_name().raw() == Symbols::BitOr().raw()) { | |
3128 __ BitOrTOS(); | |
3129 } else if (function_name().raw() == Symbols::Star().raw()) { | |
3130 __ MulTOS(); | |
3131 } | |
3132 | 3153 |
3133 const intptr_t call_ic_data_kidx = __ AddConstant(*call_ic_data); | 3154 const intptr_t call_ic_data_kidx = __ AddConstant(*call_ic_data); |
3134 switch (call_ic_data->NumArgsTested()) { | 3155 switch (ic_data->NumArgsTested()) { |
3135 case 1: | 3156 case 1: |
3136 if (compiler->is_optimizing()) { | 3157 if (compiler->is_optimizing()) { |
3137 __ InstanceCall1Opt(ArgumentCount(), call_ic_data_kidx); | 3158 __ InstanceCall1Opt(ArgumentCount(), call_ic_data_kidx); |
3138 } else { | 3159 } else { |
3139 __ InstanceCall1(ArgumentCount(), call_ic_data_kidx); | 3160 __ InstanceCall1(ArgumentCount(), call_ic_data_kidx); |
3140 } | 3161 } |
3141 break; | 3162 break; |
3142 case 2: | 3163 case 2: |
3143 if (compiler->is_optimizing()) { | 3164 if (compiler->is_optimizing()) { |
3144 __ InstanceCall2Opt(ArgumentCount(), call_ic_data_kidx); | 3165 __ InstanceCall2Opt(ArgumentCount(), call_ic_data_kidx); |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3855 set_native_c_function(native_function); | 3876 set_native_c_function(native_function); |
3856 function().SetIsNativeAutoSetupScope(auto_setup_scope); | 3877 function().SetIsNativeAutoSetupScope(auto_setup_scope); |
3857 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); | 3878 Dart_NativeEntryResolver resolver = library.native_entry_resolver(); |
3858 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); | 3879 bool is_bootstrap_native = Bootstrap::IsBootstapResolver(resolver); |
3859 set_is_bootstrap_native(is_bootstrap_native); | 3880 set_is_bootstrap_native(is_bootstrap_native); |
3860 } | 3881 } |
3861 | 3882 |
3862 #undef __ | 3883 #undef __ |
3863 | 3884 |
3864 } // namespace dart | 3885 } // namespace dart |
OLD | NEW |