| 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 2205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2216 } | 2216 } |
| 2217 | 2217 |
| 2218 | 2218 |
| 2219 bool CallIC::DoCustomHandler(Handle<Object> function, | 2219 bool CallIC::DoCustomHandler(Handle<Object> function, |
| 2220 const CallICState& callic_state) { | 2220 const CallICState& callic_state) { |
| 2221 DCHECK(FLAG_use_ic && function->IsJSFunction()); | 2221 DCHECK(FLAG_use_ic && function->IsJSFunction()); |
| 2222 | 2222 |
| 2223 // Are we the array function? | 2223 // Are we the array function? |
| 2224 Handle<JSFunction> array_function = | 2224 Handle<JSFunction> array_function = |
| 2225 Handle<JSFunction>(isolate()->native_context()->array_function()); | 2225 Handle<JSFunction>(isolate()->native_context()->array_function()); |
| 2226 CallICNexus* nexus = casted_nexus<CallICNexus>(); | |
| 2227 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { | 2226 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { |
| 2228 // Alter the slot. | 2227 // Alter the slot. |
| 2228 CallICNexus* nexus = casted_nexus<CallICNexus>(); |
| 2229 nexus->ConfigureMonomorphicArray(); | 2229 nexus->ConfigureMonomorphicArray(); |
| 2230 | 2230 |
| 2231 // Vector-based ICs have a different calling convention in optimized code | 2231 // Vector-based ICs have a different calling convention in optimized code |
| 2232 // than full code so the correct stub has to be chosen. | 2232 // than full code so the correct stub has to be chosen. |
| 2233 if (AddressIsOptimizedCode()) { | 2233 if (AddressIsOptimizedCode()) { |
| 2234 CallIC_ArrayStub stub(isolate(), callic_state); | 2234 CallIC_ArrayStub stub(isolate(), callic_state); |
| 2235 set_target(*stub.GetCode()); | 2235 set_target(*stub.GetCode()); |
| 2236 } else { | 2236 } else { |
| 2237 CallIC_ArrayTrampolineStub stub(isolate(), callic_state); | 2237 CallIC_ArrayTrampolineStub stub(isolate(), callic_state); |
| 2238 set_target(*stub.GetCode()); | 2238 set_target(*stub.GetCode()); |
| 2239 } | 2239 } |
| 2240 | 2240 |
| 2241 Handle<String> name; | 2241 Handle<String> name; |
| 2242 if (array_function->shared()->name()->IsString()) { | 2242 if (array_function->shared()->name()->IsString()) { |
| 2243 name = Handle<String>(String::cast(array_function->shared()->name()), | 2243 name = Handle<String>(String::cast(array_function->shared()->name()), |
| 2244 isolate()); | 2244 isolate()); |
| 2245 } | 2245 } |
| 2246 TRACE_IC("CallIC", name); | 2246 TRACE_IC("CallIC", name); |
| 2247 OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(), | 2247 OnTypeFeedbackChanged(isolate(), get_host(), nexus->vector(), state(), |
| 2248 MONOMORPHIC); | 2248 MONOMORPHIC); |
| 2249 return true; | 2249 return true; |
| 2250 } else { | |
| 2251 Handle<JSFunction> maybe_builtin(Handle<JSFunction>::cast(function)); | |
| 2252 if (maybe_builtin->shared()->HasBuiltinFunctionId()) { | |
| 2253 BuiltinFunctionId id = maybe_builtin->shared()->builtin_function_id(); | |
| 2254 switch (id) { | |
| 2255 case kMathRound: { | |
| 2256 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
| 2257 if (AddressIsOptimizedCode()) { | |
| 2258 CallIC_RoundStub stub(isolate(), callic_state); | |
| 2259 set_target(*stub.GetCode()); | |
| 2260 } else { | |
| 2261 CallIC_RoundTrampolineStub stub(isolate(), callic_state); | |
| 2262 set_target(*stub.GetCode()); | |
| 2263 } | |
| 2264 return true; | |
| 2265 } | |
| 2266 case kMathFloor: | |
| 2267 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
| 2268 if (AddressIsOptimizedCode()) { | |
| 2269 CallIC_FloorStub stub(isolate(), callic_state); | |
| 2270 set_target(*stub.GetCode()); | |
| 2271 } else { | |
| 2272 CallIC_FloorTrampolineStub stub(isolate(), callic_state); | |
| 2273 set_target(*stub.GetCode()); | |
| 2274 } | |
| 2275 return true; | |
| 2276 break; | |
| 2277 case kMathCeil: | |
| 2278 nexus->ConfigureMonomorphicMathFunction(maybe_builtin); | |
| 2279 if (AddressIsOptimizedCode()) { | |
| 2280 CallIC_CeilStub stub(isolate(), callic_state); | |
| 2281 set_target(*stub.GetCode()); | |
| 2282 } else { | |
| 2283 CallIC_CeilTrampolineStub stub(isolate(), callic_state); | |
| 2284 set_target(*stub.GetCode()); | |
| 2285 } | |
| 2286 return true; | |
| 2287 break; | |
| 2288 default: | |
| 2289 break; | |
| 2290 } | |
| 2291 } | |
| 2292 } | 2250 } |
| 2293 return false; | 2251 return false; |
| 2294 } | 2252 } |
| 2295 | 2253 |
| 2296 | 2254 |
| 2297 void CallIC::PatchMegamorphic(Handle<Object> function) { | 2255 void CallIC::PatchMegamorphic(Handle<Object> function) { |
| 2298 CallICState callic_state(target()->extra_ic_state()); | 2256 CallICState callic_state(target()->extra_ic_state()); |
| 2299 | 2257 |
| 2300 // We are going generic. | 2258 // We are going generic. |
| 2301 CallICNexus* nexus = casted_nexus<CallICNexus>(); | 2259 CallICNexus* nexus = casted_nexus<CallICNexus>(); |
| (...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3093 static const Address IC_utilities[] = { | 3051 static const Address IC_utilities[] = { |
| 3094 #define ADDR(name) FUNCTION_ADDR(name), | 3052 #define ADDR(name) FUNCTION_ADDR(name), |
| 3095 IC_UTIL_LIST(ADDR) NULL | 3053 IC_UTIL_LIST(ADDR) NULL |
| 3096 #undef ADDR | 3054 #undef ADDR |
| 3097 }; | 3055 }; |
| 3098 | 3056 |
| 3099 | 3057 |
| 3100 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } | 3058 Address IC::AddressFromUtilityId(IC::UtilityId id) { return IC_utilities[id]; } |
| 3101 } | 3059 } |
| 3102 } // namespace v8::internal | 3060 } // namespace v8::internal |
| OLD | NEW |