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 786 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
797 if (object->IsUndefined() || object->IsNull()) { | 797 if (object->IsUndefined() || object->IsNull()) { |
798 return TypeError("non_object_property_call", object, key); | 798 return TypeError("non_object_property_call", object, key); |
799 } | 799 } |
800 | 800 |
801 bool use_ic = MigrateDeprecated(object) | 801 bool use_ic = MigrateDeprecated(object) |
802 ? false : FLAG_use_ic && !object->IsAccessCheckNeeded(); | 802 ? false : FLAG_use_ic && !object->IsAccessCheckNeeded(); |
803 | 803 |
804 if (use_ic && state() != MEGAMORPHIC) { | 804 if (use_ic && state() != MEGAMORPHIC) { |
805 ASSERT(!object->IsJSGlobalProxy()); | 805 ASSERT(!object->IsJSGlobalProxy()); |
806 int argc = target()->arguments_count(); | 806 int argc = target()->arguments_count(); |
807 Handle<Code> stub = isolate()->stub_cache()->ComputeCallMegamorphic( | 807 Handle<Code> stub; |
808 argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); | 808 |
809 if (object->IsJSObject()) { | 809 // Use the KeyedArrayCallStub if the call is of the form array[smi](...), |
810 Handle<JSObject> receiver = Handle<JSObject>::cast(object); | 810 // where array is an instance of one of the initial array maps (without |
811 if (receiver->elements()->map() == | 811 // extra named properties). |
812 isolate()->heap()->non_strict_arguments_elements_map()) { | 812 // TODO(verwaest): Also support keyed calls on instances of other maps. |
813 stub = isolate()->stub_cache()->ComputeCallArguments(argc); | 813 if (object->IsJSArray() && key->IsSmi()) { |
| 814 Handle<JSArray> array = Handle<JSArray>::cast(object); |
| 815 ElementsKind kind = array->map()->elements_kind(); |
| 816 if (IsFastObjectElementsKind(kind) && |
| 817 array->map() == isolate()->get_initial_js_array_map(kind)) { |
| 818 KeyedArrayCallStub stub_gen(IsHoleyElementsKind(kind), argc); |
| 819 stub = stub_gen.GetCode(isolate()); |
814 } | 820 } |
815 } | 821 } |
816 ASSERT(!stub.is_null()); | 822 |
| 823 if (stub.is_null()) { |
| 824 stub = isolate()->stub_cache()->ComputeCallMegamorphic( |
| 825 argc, Code::KEYED_CALL_IC, Code::kNoExtraICState); |
| 826 if (object->IsJSObject()) { |
| 827 Handle<JSObject> receiver = Handle<JSObject>::cast(object); |
| 828 if (receiver->elements()->map() == |
| 829 isolate()->heap()->non_strict_arguments_elements_map()) { |
| 830 stub = isolate()->stub_cache()->ComputeCallArguments(argc); |
| 831 } |
| 832 } |
| 833 ASSERT(!stub.is_null()); |
| 834 } |
817 set_target(*stub); | 835 set_target(*stub); |
818 TRACE_IC("CallIC", key); | 836 TRACE_IC("CallIC", key); |
819 } | 837 } |
820 | 838 |
821 Handle<Object> result = GetProperty(isolate(), object, key); | 839 Handle<Object> result = GetProperty(isolate(), object, key); |
822 RETURN_IF_EMPTY_HANDLE(isolate(), result); | 840 RETURN_IF_EMPTY_HANDLE(isolate(), result); |
823 | 841 |
824 // Make receiver an object if the callee requires it. Strict mode or builtin | 842 // Make receiver an object if the callee requires it. Strict mode or builtin |
825 // functions do not wrap the receiver, non-strict functions and objects | 843 // functions do not wrap the receiver, non-strict functions and objects |
826 // called as functions do. | 844 // called as functions do. |
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2115 HandleScope scope(isolate); | 2133 HandleScope scope(isolate); |
2116 ASSERT(args.length() == 3); | 2134 ASSERT(args.length() == 3); |
2117 StoreIC ic(IC::EXTRA_CALL_FRAME, isolate); | 2135 StoreIC ic(IC::EXTRA_CALL_FRAME, isolate); |
2118 Handle<Object> receiver = args.at<Object>(0); | 2136 Handle<Object> receiver = args.at<Object>(0); |
2119 Handle<String> key = args.at<String>(1); | 2137 Handle<String> key = args.at<String>(1); |
2120 ic.UpdateState(receiver, key); | 2138 ic.UpdateState(receiver, key); |
2121 return ic.Store(receiver, key, args.at<Object>(2)); | 2139 return ic.Store(receiver, key, args.at<Object>(2)); |
2122 } | 2140 } |
2123 | 2141 |
2124 | 2142 |
| 2143 RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_MissFromStubFailure) { |
| 2144 HandleScope scope(isolate); |
| 2145 ASSERT(args.length() == 2); |
| 2146 KeyedCallIC ic(isolate); |
| 2147 Arguments* caller_args = reinterpret_cast<Arguments*>(args[0]); |
| 2148 Handle<Object> key = args.at<Object>(1); |
| 2149 Handle<Object> receiver((*caller_args)[0], isolate); |
| 2150 |
| 2151 ic.UpdateState(receiver, key); |
| 2152 MaybeObject* maybe_result = ic.LoadFunction(receiver, key); |
| 2153 // Result could be a function or a failure. |
| 2154 JSFunction* raw_function = NULL; |
| 2155 if (!maybe_result->To(&raw_function)) return maybe_result; |
| 2156 |
| 2157 if (raw_function->is_compiled()) return raw_function; |
| 2158 |
| 2159 Handle<JSFunction> function(raw_function, isolate); |
| 2160 JSFunction::CompileLazy(function, CLEAR_EXCEPTION); |
| 2161 return *function; |
| 2162 } |
| 2163 |
| 2164 |
2125 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { | 2165 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) { |
2126 SealHandleScope shs(isolate); | 2166 SealHandleScope shs(isolate); |
2127 | 2167 |
2128 ASSERT(args.length() == 2); | 2168 ASSERT(args.length() == 2); |
2129 JSArray* receiver = JSArray::cast(args[0]); | 2169 JSArray* receiver = JSArray::cast(args[0]); |
2130 Object* len = args[1]; | 2170 Object* len = args[1]; |
2131 | 2171 |
2132 // The generated code should filter out non-Smis before we get here. | 2172 // The generated code should filter out non-Smis before we get here. |
2133 ASSERT(len->IsSmi()); | 2173 ASSERT(len->IsSmi()); |
2134 | 2174 |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2730 #undef ADDR | 2770 #undef ADDR |
2731 }; | 2771 }; |
2732 | 2772 |
2733 | 2773 |
2734 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2774 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
2735 return IC_utilities[id]; | 2775 return IC_utilities[id]; |
2736 } | 2776 } |
2737 | 2777 |
2738 | 2778 |
2739 } } // namespace v8::internal | 2779 } } // namespace v8::internal |
OLD | NEW |