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/codegen.h" | 10 #include "src/codegen.h" |
(...skipping 1819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1830 Handle<FixedArray> vector, | 1830 Handle<FixedArray> vector, |
1831 Handle<Smi> slot, | 1831 Handle<Smi> slot, |
1832 const State& state) { | 1832 const State& state) { |
1833 ASSERT(FLAG_use_ic && function->IsJSFunction()); | 1833 ASSERT(FLAG_use_ic && function->IsJSFunction()); |
1834 | 1834 |
1835 // Are we the array function? | 1835 // Are we the array function? |
1836 Handle<JSFunction> array_function = Handle<JSFunction>( | 1836 Handle<JSFunction> array_function = Handle<JSFunction>( |
1837 isolate()->native_context()->array_function()); | 1837 isolate()->native_context()->array_function()); |
1838 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { | 1838 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { |
1839 // Alter the slot. | 1839 // Alter the slot. |
1840 Handle<AllocationSite> new_site = isolate()->factory()->NewAllocationSite(); | 1840 Object* feedback = vector->get(slot->value()); |
1841 vector->set(slot->value(), *new_site); | 1841 if (!feedback->IsAllocationSite()) { |
| 1842 Handle<AllocationSite> new_site = |
| 1843 isolate()->factory()->NewAllocationSite(); |
| 1844 vector->set(slot->value(), *new_site); |
| 1845 } |
| 1846 |
1842 CallIC_ArrayStub stub(isolate(), state); | 1847 CallIC_ArrayStub stub(isolate(), state); |
1843 set_target(*stub.GetCode()); | 1848 set_target(*stub.GetCode()); |
1844 Handle<String> name; | 1849 Handle<String> name; |
1845 if (array_function->shared()->name()->IsString()) { | 1850 if (array_function->shared()->name()->IsString()) { |
1846 name = Handle<String>(String::cast(array_function->shared()->name()), | 1851 name = Handle<String>(String::cast(array_function->shared()->name()), |
1847 isolate()); | 1852 isolate()); |
1848 } | 1853 } |
1849 | 1854 |
1850 TRACE_IC("CallIC (Array call)", name); | 1855 TRACE_IC("CallIC (Array call)", name); |
1851 return true; | 1856 return true; |
(...skipping 19 matching lines...) Expand all Loading... |
1871 } | 1876 } |
1872 | 1877 |
1873 | 1878 |
1874 void CallIC::HandleMiss(Handle<Object> receiver, | 1879 void CallIC::HandleMiss(Handle<Object> receiver, |
1875 Handle<Object> function, | 1880 Handle<Object> function, |
1876 Handle<FixedArray> vector, | 1881 Handle<FixedArray> vector, |
1877 Handle<Smi> slot) { | 1882 Handle<Smi> slot) { |
1878 State state(target()->extra_ic_state()); | 1883 State state(target()->extra_ic_state()); |
1879 Object* feedback = vector->get(slot->value()); | 1884 Object* feedback = vector->get(slot->value()); |
1880 | 1885 |
| 1886 // Hand-coded MISS handling is easier if CallIC slots don't contain smis. |
| 1887 ASSERT(!feedback->IsSmi()); |
| 1888 |
1881 if (feedback->IsJSFunction() || !function->IsJSFunction()) { | 1889 if (feedback->IsJSFunction() || !function->IsJSFunction()) { |
1882 // We are going generic. | 1890 // We are going generic. |
1883 vector->set(slot->value(), | 1891 vector->set(slot->value(), |
1884 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), | 1892 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), |
1885 SKIP_WRITE_BARRIER); | 1893 SKIP_WRITE_BARRIER); |
1886 | 1894 |
1887 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); | 1895 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); |
1888 } else { | 1896 } else { |
1889 // If we came here feedback must be the uninitialized sentinel, | 1897 // The feedback is either uninitialized or an allocation site. |
1890 // and we are going monomorphic. | 1898 // It might be an allocation site because if we re-compile the full code |
1891 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate())); | 1899 // to add deoptimization support, we call with the default call-ic, and |
| 1900 // merely need to patch the target to match the feedback. |
| 1901 // TODO(mvstanton): the better approach is to dispense with patching |
| 1902 // altogether, which is in progress. |
| 1903 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate()) || |
| 1904 feedback->IsAllocationSite()); |
1892 | 1905 |
1893 // Do we want to install a custom handler? | 1906 // Do we want to install a custom handler? |
1894 if (FLAG_use_ic && | 1907 if (FLAG_use_ic && |
1895 DoCustomHandler(receiver, function, vector, slot, state)) { | 1908 DoCustomHandler(receiver, function, vector, slot, state)) { |
1896 return; | 1909 return; |
1897 } | 1910 } |
1898 | 1911 |
1899 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); | 1912 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); |
1900 Handle<Object> name(js_function->shared()->name(), isolate()); | 1913 Handle<Object> name(js_function->shared()->name(), isolate()); |
1901 TRACE_IC("CallIC", name); | 1914 TRACE_IC("CallIC", name); |
(...skipping 1134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3036 #undef ADDR | 3049 #undef ADDR |
3037 }; | 3050 }; |
3038 | 3051 |
3039 | 3052 |
3040 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3053 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
3041 return IC_utilities[id]; | 3054 return IC_utilities[id]; |
3042 } | 3055 } |
3043 | 3056 |
3044 | 3057 |
3045 } } // namespace v8::internal | 3058 } } // namespace v8::internal |
OLD | NEW |