OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/accessors.h" | 7 #include "src/accessors.h" |
8 #include "src/api.h" | 8 #include "src/api.h" |
9 #include "src/arguments.h" | 9 #include "src/arguments.h" |
10 #include "src/base/bits.h" | 10 #include "src/base/bits.h" |
(...skipping 2194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2205 } | 2205 } |
2206 | 2206 |
2207 | 2207 |
2208 bool CallIC::DoCustomHandler(Handle<Object> function, | 2208 bool CallIC::DoCustomHandler(Handle<Object> function, |
2209 const CallICState& callic_state) { | 2209 const CallICState& callic_state) { |
2210 DCHECK(FLAG_use_ic && function->IsJSFunction()); | 2210 DCHECK(FLAG_use_ic && function->IsJSFunction()); |
2211 | 2211 |
2212 // Are we the array function? | 2212 // Are we the array function? |
2213 Handle<JSFunction> array_function = | 2213 Handle<JSFunction> array_function = |
2214 Handle<JSFunction>(isolate()->native_context()->array_function()); | 2214 Handle<JSFunction>(isolate()->native_context()->array_function()); |
2215 CallICNexus* nexus = casted_nexus<CallICNexus>(); | |
2215 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { | 2216 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { |
2216 // Alter the slot. | 2217 // Alter the slot. |
2217 CallICNexus* nexus = casted_nexus<CallICNexus>(); | |
2218 nexus->ConfigureMonomorphicArray(); | 2218 nexus->ConfigureMonomorphicArray(); |
2219 | 2219 |
2220 // Vector-based ICs have a different calling convention in optimized code | 2220 // Vector-based ICs have a different calling convention in optimized code |
2221 // than full code so the correct stub has to be chosen. | 2221 // than full code so the correct stub has to be chosen. |
2222 if (AddressIsOptimizedCode()) { | 2222 if (AddressIsOptimizedCode()) { |
2223 CallIC_ArrayStub stub(isolate(), callic_state); | 2223 CallIC_ArrayStub stub(isolate(), callic_state); |
2224 set_target(*stub.GetCode()); | 2224 set_target(*stub.GetCode()); |
2225 } else { | 2225 } else { |
2226 CallIC_ArrayTrampolineStub stub(isolate(), callic_state); | 2226 CallIC_ArrayTrampolineStub stub(isolate(), callic_state); |
2227 set_target(*stub.GetCode()); | 2227 set_target(*stub.GetCode()); |
2228 } | 2228 } |
2229 | 2229 |
2230 Handle<String> name; | 2230 Handle<String> name; |
2231 if (array_function->shared()->name()->IsString()) { | 2231 if (array_function->shared()->name()->IsString()) { |
2232 name = Handle<String>(String::cast(array_function->shared()->name()), | 2232 name = Handle<String>(String::cast(array_function->shared()->name()), |
2233 isolate()); | 2233 isolate()); |
2234 } | 2234 } |
2235 TRACE_IC("CallIC", name); | 2235 TRACE_IC("CallIC", name); |
2236 OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(), | 2236 OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(), |
2237 MONOMORPHIC); | 2237 MONOMORPHIC); |
2238 return true; | 2238 return true; |
2239 } else { | |
2240 Handle<JSFunction> maybe_builtin(Handle<JSFunction>::cast(function)); | |
2241 if (maybe_builtin->shared()->HasBuiltinFunctionId()) { | |
2242 BuiltinFunctionId id = maybe_builtin->shared()->builtin_function_id(); | |
2243 switch (id) { | |
2244 case kMathRound: { | |
2245 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
2246 if (AddressIsOptimizedCode()) { | |
mvstanton
2015/04/28 14:21:20
Could this AddressIsOptimizedCode() { STUB1 } else
danno
2015/04/30 13:34:32
I'd like to avoid the template in this case, since
| |
2247 CallIC_RoundStub stub(isolate(), callic_state); | |
2248 set_target(*stub.GetCode()); | |
2249 } else { | |
2250 CallIC_RoundTrampolineStub stub(isolate(), callic_state); | |
2251 set_target(*stub.GetCode()); | |
2252 } | |
2253 return true; | |
2254 } | |
2255 case kMathFloor: | |
2256 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
2257 if (AddressIsOptimizedCode()) { | |
2258 CallIC_FloorStub stub(isolate(), callic_state); | |
2259 set_target(*stub.GetCode()); | |
2260 } else { | |
2261 CallIC_FloorTrampolineStub stub(isolate(), callic_state); | |
2262 set_target(*stub.GetCode()); | |
2263 } | |
2264 return true; | |
2265 break; | |
2266 case kMathCeil: | |
2267 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
2268 if (AddressIsOptimizedCode()) { | |
2269 CallIC_CeilStub stub(isolate(), callic_state); | |
2270 set_target(*stub.GetCode()); | |
2271 } else { | |
2272 CallIC_CeilTrampolineStub stub(isolate(), callic_state); | |
2273 set_target(*stub.GetCode()); | |
2274 } | |
2275 return true; | |
2276 break; | |
2277 default: | |
2278 break; | |
2279 } | |
2280 } | |
2239 } | 2281 } |
2240 return false; | 2282 return false; |
2241 } | 2283 } |
2242 | 2284 |
2243 | 2285 |
2244 void CallIC::PatchMegamorphic(Handle<Object> function) { | 2286 void CallIC::PatchMegamorphic(Handle<Object> function) { |
2245 CallICState callic_state(target()->extra_ic_state()); | 2287 CallICState callic_state(target()->extra_ic_state()); |
2246 | 2288 |
2247 // We are going generic. | 2289 // We are going generic. |
2248 CallICNexus* nexus = casted_nexus<CallICNexus>(); | 2290 CallICNexus* nexus = casted_nexus<CallICNexus>(); |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3045 static const Address IC_utilities[] = { | 3087 static const Address IC_utilities[] = { |
3046 #define ADDR(name) FUNCTION_ADDR(name), | 3088 #define ADDR(name) FUNCTION_ADDR(name), |
3047 IC_UTIL_LIST(ADDR) NULL | 3089 IC_UTIL_LIST(ADDR) NULL |
3048 #undef ADDR | 3090 #undef ADDR |
3049 }; | 3091 }; |
3050 | 3092 |
3051 | 3093 |
3052 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3094 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
3053 } | 3095 } |
3054 } // namespace v8::internal | 3096 } // namespace v8::internal |
OLD | NEW |