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 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 if (object->IsJSArray() && key->IsSmi()) { |
|
danno
2013/10/02 08:49:11
A comment or two would be very useful here to desc
| |
| 841 if (object->IsJSObject()) { | 841 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 842 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 842 ElementsKind kind = array->map()->elements_kind(); |
| 843 if (receiver->elements()->map() == | 843 if (IsFastObjectElementsKind(kind) && |
| 844 isolate()->heap()->non_strict_arguments_elements_map()) { | 844 array->map() == isolate()->get_initial_js_array_map(kind)) { |
| 845 stub = isolate()->stub_cache()->ComputeCallArguments(argc); | 845 KeyedArrayCallStub stub_gen(IsHoleyElementsKind(kind), argc); |
| 846 stub = stub_gen.GetCode(isolate()); | |
| 846 } | 847 } |
| 847 } | 848 } |
| 848 ASSERT(!stub.is_null()); | 849 |
| 850 if (stub.is_null()) { | |
| 851 stub = isolate()->stub_cache()->ComputeCallMegamorphic( | |
| 852 argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); | |
| 853 if (object->IsJSObject()) { | |
| 854 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | |
| 855 if (receiver->elements()->map() == | |
| 856 isolate()->heap()->non_strict_arguments_elements_map()) { | |
| 857 stub = isolate()->stub_cache()->ComputeCallArguments(argc); | |
| 858 } | |
| 859 } | |
| 860 ASSERT(!stub.is_null()); | |
| 861 } | |
| 849 set_target(*stub); | 862 set_target(*stub); |
| 850 TRACE_IC("KeyedCallIC", key, state, target()); | 863 TRACE_IC("KeyedCallIC", key, state, target()); |
| 851 } | 864 } |
| 852 | 865 |
| 853 Handle<Object> result = GetProperty(isolate(), object, key); | 866 Handle<Object> result = GetProperty(isolate(), object, key); |
| 854 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 867 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
| 855 | 868 |
| 856 // Make receiver an object if the callee requires it. Strict mode or builtin | 869 // 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 | 870 // functions do not wrap the receiver, non-strict functions and objects |
| 858 // called as functions do. | 871 // 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]); | 2399 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
| 2387 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 2400 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
| 2388 return ic.Store(state, | 2401 return ic.Store(state, |
| 2389 Code::GetStrictMode(extra_ic_state), | 2402 Code::GetStrictMode(extra_ic_state), |
| 2390 args.at<Object>(0), | 2403 args.at<Object>(0), |
| 2391 args.at<String>(1), | 2404 args.at<String>(1), |
| 2392 args.at<Object>(2)); | 2405 args.at<Object>(2)); |
| 2393 } | 2406 } |
| 2394 | 2407 |
| 2395 | 2408 |
| 2409 RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure) { | |
| 2410 HandleScope scope(isolate); | |
| 2411 ASSERT(args.length() == 1); | |
| 2412 KeyedCallIC ic(isolate); | |
| 2413 int argc = Code::ExtractArgumentsCountFromFlags(ic.target()->flags()); | |
| 2414 | |
| 2415 StackFrameLocator locator(isolate); | |
| 2416 JavaScriptFrame* frame = locator.FindJavaScriptFrame(0); | |
| 2417 int index = frame->ComputeExpressionsCount() - (argc + 1); | |
| 2418 Object* receiver = frame->GetExpression(index); | |
| 2419 Object* key = args[0]; | |
|
danno
2013/10/02 08:49:11
Oh, this is awful. Please take a look at ArrayCons
Toon Verwaest
2013/10/02 16:28:16
Done.
| |
| 2420 | |
| 2421 IC::State state = IC::StateFrom(ic.target(), receiver, key); | |
| 2422 MaybeObject* maybe_result = | |
| 2423 ic.LoadFunction(state, handle(receiver, isolate), handle(key, isolate)); | |
| 2424 // Result could be a function or a failure. | |
| 2425 JSFunction* raw_function = NULL; | |
| 2426 if (!maybe_result->To(&raw_function)) return maybe_result; | |
| 2427 | |
| 2428 if (raw_function->is_compiled()) return raw_function; | |
| 2429 | |
| 2430 Handle<JSFunction> function(raw_function, isolate); | |
| 2431 JSFunction::CompileLazy(function, CLEAR_EXCEPTION); | |
| 2432 return *function; | |
| 2433 } | |
| 2434 | |
| 2435 | |
| 2396 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { | 2436 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { |
| 2397 SealHandleScope shs(isolate); | 2437 SealHandleScope shs(isolate); |
| 2398 | 2438 |
| 2399 ASSERT(args.length() == 2); | 2439 ASSERT(args.length() == 2); |
| 2400 JSArray* receiver = JSArray::cast(args[0]); | 2440 JSArray* receiver = JSArray::cast(args[0]); |
| 2401 Object* len = args[1]; | 2441 Object* len = args[1]; |
| 2402 | 2442 |
| 2403 // The generated code should filter out non-Smis before we get here. | 2443 // The generated code should filter out non-Smis before we get here. |
| 2404 ASSERT(len->IsSmi()); | 2444 ASSERT(len->IsSmi()); |
| 2405 | 2445 |
| (...skipping 757 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3163 #undef ADDR | 3203 #undef ADDR |
| 3164 }; | 3204 }; |
| 3165 | 3205 |
| 3166 | 3206 |
| 3167 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3207 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3168 return IC_utilities[id]; | 3208 return IC_utilities[id]; |
| 3169 } | 3209 } |
| 3170 | 3210 |
| 3171 | 3211 |
| 3172 } } // namespace v8::internal | 3212 } } // namespace v8::internal |
| OLD | NEW |