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 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
829 } | 829 } |
830 | 830 |
831 if (object->IsUndefined() || object->IsNull()) { | 831 if (object->IsUndefined() || object->IsNull()) { |
832 return TypeError("non_object_property_call", object, key); | 832 return TypeError("non_object_property_call", object, key); |
833 } | 833 } |
834 | 834 |
835 ASSERT(!(use_ic && object->IsJSGlobalProxy())); | 835 ASSERT(!(use_ic && object->IsJSGlobalProxy())); |
836 | 836 |
837 if (use_ic && state != MEGAMORPHIC) { | 837 if (use_ic && state != MEGAMORPHIC) { |
838 int argc = target()->arguments_count(); | 838 int argc = target()->arguments_count(); |
839 Handle<Code> stub = isolate()->stub_cache()->ComputeCallMegamorphic( | 839 Handle<Code> stub; |
840 argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); | 840 |
841 if (object->IsJSObject()) { | 841 if (object->IsJSArray() && key->IsSmi()) { |
danno
2013/10/11 16:13:24
Some comments for this logic would be good. It's n
Toon Verwaest
2013/11/04 13:59:44
Done.
| |
842 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 842 Handle<JSArray> array = Handle<JSArray>::cast(object); |
843 if (receiver->elements()->map() == | 843 ElementsKind kind = array->map()->elements_kind(); |
844 isolate()->heap()->non_strict_arguments_elements_map()) { | 844 if (IsFastObjectElementsKind(kind) && |
845 stub = isolate()->stub_cache()->ComputeCallArguments(argc); | 845 array->map() == isolate()->get_initial_js_array_map(kind)) { |
846 KeyedArrayCallStub stub_gen(IsHoleyElementsKind(kind), argc); | |
847 stub = stub_gen.GetCode(isolate()); | |
846 } | 848 } |
847 } | 849 } |
848 ASSERT(!stub.is_null()); | 850 |
851 if (stub.is_null()) { | |
852 stub = isolate()->stub_cache()->ComputeCallMegamorphic( | |
853 argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); | |
854 if (object->IsJSObject()) { | |
855 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | |
856 if (receiver->elements()->map() == | |
857 isolate()->heap()->non_strict_arguments_elements_map()) { | |
858 stub = isolate()->stub_cache()->ComputeCallArguments(argc); | |
859 } | |
860 } | |
861 ASSERT(!stub.is_null()); | |
862 } | |
849 set_target(*stub); | 863 set_target(*stub); |
850 TRACE_IC("KeyedCallIC", key, state, target()); | 864 TRACE_IC("KeyedCallIC", key, state, target()); |
851 } | 865 } |
852 | 866 |
853 Handle<Object> result = GetProperty(isolate(), object, key); | 867 Handle<Object> result = GetProperty(isolate(), object, key); |
854 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 868 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
855 | 869 |
856 // Make receiver an object if the callee requires it. Strict mode or builtin | 870 // Make receiver an object if the callee requires it. Strict mode or builtin |
857 // functions do not wrap the receiver, non-strict functions and objects | 871 // functions do not wrap the receiver, non-strict functions and objects |
858 // called as functions do. | 872 // called as functions do. |
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2386 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 2400 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
2387 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2401 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
2388 return ic.Store(state, | 2402 return ic.Store(state, |
2389 Code::GetStrictMode(extra_ic_state), | 2403 Code::GetStrictMode(extra_ic_state), |
2390 args.at<Object>(0), | 2404 args.at<Object>(0), |
2391 args.at<String>(1), | 2405 args.at<String>(1), |
2392 args.at<Object>(2)); | 2406 args.at<Object>(2)); |
2393 } | 2407 } |
2394 | 2408 |
2395 | 2409 |
2410 RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure) { | |
2411 HandleScope scope(isolate); | |
2412 ASSERT(args.length() == 2); | |
2413 KeyedCallIC ic(isolate); | |
2414 Arguments* caller_args = reinterpret_cast<Arguments*>(args[0]); | |
2415 Object* key = args[1]; | |
2416 Object* receiver = (*caller_args)[0]; | |
2417 | |
2418 IC::State state = IC::StateFrom(ic.target(), receiver, key); | |
2419 MaybeObject* maybe_result = | |
2420 ic.LoadFunction(state, handle(receiver, isolate), handle(key, isolate)); | |
2421 // Result could be a function or a failure. | |
2422 JSFunction* raw_function = NULL; | |
2423 if (!maybe_result->To(&raw_function)) return maybe_result; | |
2424 | |
2425 if (raw_function->is_compiled()) return raw_function; | |
2426 | |
2427 Handle<JSFunction> function(raw_function, isolate); | |
2428 JSFunction::CompileLazy(function, CLEAR_EXCEPTION); | |
2429 return *function; | |
2430 } | |
2431 | |
2432 | |
2396 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { | 2433 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { |
2397 SealHandleScope shs(isolate); | 2434 SealHandleScope shs(isolate); |
2398 | 2435 |
2399 ASSERT(args.length() == 2); | 2436 ASSERT(args.length() == 2); |
2400 JSArray* receiver = JSArray::cast(args[0]); | 2437 JSArray* receiver = JSArray::cast(args[0]); |
2401 Object* len = args[1]; | 2438 Object* len = args[1]; |
2402 | 2439 |
2403 // The generated code should filter out non-Smis before we get here. | 2440 // The generated code should filter out non-Smis before we get here. |
2404 ASSERT(len->IsSmi()); | 2441 ASSERT(len->IsSmi()); |
2405 | 2442 |
(...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3163 #undef ADDR | 3200 #undef ADDR |
3164 }; | 3201 }; |
3165 | 3202 |
3166 | 3203 |
3167 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3204 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3168 return IC_utilities[id]; | 3205 return IC_utilities[id]; |
3169 } | 3206 } |
3170 | 3207 |
3171 | 3208 |
3172 } } // namespace v8::internal | 3209 } } // namespace v8::internal |
OLD | NEW |