| 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 1837 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1848 Handle<FixedArray> vector, | 1848 Handle<FixedArray> vector, |
| 1849 Handle<Smi> slot, | 1849 Handle<Smi> slot, |
| 1850 const State& state) { | 1850 const State& state) { |
| 1851 ASSERT(FLAG_use_ic && function->IsJSFunction()); | 1851 ASSERT(FLAG_use_ic && function->IsJSFunction()); |
| 1852 | 1852 |
| 1853 // Are we the array function? | 1853 // Are we the array function? |
| 1854 Handle<JSFunction> array_function = Handle<JSFunction>( | 1854 Handle<JSFunction> array_function = Handle<JSFunction>( |
| 1855 isolate()->context()->native_context()->array_function(), isolate()); | 1855 isolate()->context()->native_context()->array_function(), isolate()); |
| 1856 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { | 1856 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) { |
| 1857 // Alter the slot. | 1857 // Alter the slot. |
| 1858 Handle<AllocationSite> new_site = isolate()->factory()->NewAllocationSite(); | 1858 Object* feedback = vector->get(slot->value()); |
| 1859 vector->set(slot->value(), *new_site); | 1859 if (!feedback->IsAllocationSite()) { |
| 1860 Handle<AllocationSite> new_site = |
| 1861 isolate()->factory()->NewAllocationSite(); |
| 1862 vector->set(slot->value(), *new_site); |
| 1863 } |
| 1864 |
| 1860 CallIC_ArrayStub stub(isolate(), state); | 1865 CallIC_ArrayStub stub(isolate(), state); |
| 1861 set_target(*stub.GetCode()); | 1866 set_target(*stub.GetCode()); |
| 1862 Handle<String> name; | 1867 Handle<String> name; |
| 1863 if (array_function->shared()->name()->IsString()) { | 1868 if (array_function->shared()->name()->IsString()) { |
| 1864 name = Handle<String>(String::cast(array_function->shared()->name()), | 1869 name = Handle<String>(String::cast(array_function->shared()->name()), |
| 1865 isolate()); | 1870 isolate()); |
| 1866 } | 1871 } |
| 1867 | 1872 |
| 1868 TRACE_IC("CallIC (Array call)", name); | 1873 TRACE_IC("CallIC (Array call)", name); |
| 1869 return true; | 1874 return true; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1889 } | 1894 } |
| 1890 | 1895 |
| 1891 | 1896 |
| 1892 void CallIC::HandleMiss(Handle<Object> receiver, | 1897 void CallIC::HandleMiss(Handle<Object> receiver, |
| 1893 Handle<Object> function, | 1898 Handle<Object> function, |
| 1894 Handle<FixedArray> vector, | 1899 Handle<FixedArray> vector, |
| 1895 Handle<Smi> slot) { | 1900 Handle<Smi> slot) { |
| 1896 State state(target()->extra_ic_state()); | 1901 State state(target()->extra_ic_state()); |
| 1897 Object* feedback = vector->get(slot->value()); | 1902 Object* feedback = vector->get(slot->value()); |
| 1898 | 1903 |
| 1904 // Hand-coded MISS handling is easier if CallIC slots don't contain smis. |
| 1905 ASSERT(!feedback->IsSmi()); |
| 1906 |
| 1899 if (feedback->IsJSFunction() || !function->IsJSFunction()) { | 1907 if (feedback->IsJSFunction() || !function->IsJSFunction()) { |
| 1900 // We are going generic. | 1908 // We are going generic. |
| 1901 vector->set(slot->value(), | 1909 vector->set(slot->value(), |
| 1902 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), | 1910 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), |
| 1903 SKIP_WRITE_BARRIER); | 1911 SKIP_WRITE_BARRIER); |
| 1904 | 1912 |
| 1905 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); | 1913 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); |
| 1906 } else { | 1914 } else { |
| 1907 // If we came here feedback must be the uninitialized sentinel, | 1915 // The feedback is either uninitialized or an allocation site. |
| 1908 // and we are going monomorphic. | 1916 // It might be an allocation site because if we re-compile the full code |
| 1909 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate())); | 1917 // to add deoptimization support, we call with the default call-ic, and |
| 1918 // merely need to patch the target to match the feedback. |
| 1919 // TODO(mvstanton): the better approach is to dispense with patching |
| 1920 // altogether, which is in progress. |
| 1921 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate()) || |
| 1922 feedback->IsAllocationSite()); |
| 1910 | 1923 |
| 1911 // Do we want to install a custom handler? | 1924 // Do we want to install a custom handler? |
| 1912 if (FLAG_use_ic && | 1925 if (FLAG_use_ic && |
| 1913 DoCustomHandler(receiver, function, vector, slot, state)) { | 1926 DoCustomHandler(receiver, function, vector, slot, state)) { |
| 1914 return; | 1927 return; |
| 1915 } | 1928 } |
| 1916 | 1929 |
| 1917 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); | 1930 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); |
| 1918 Handle<Object> name(js_function->shared()->name(), isolate()); | 1931 Handle<Object> name(js_function->shared()->name(), isolate()); |
| 1919 TRACE_IC("CallIC", name); | 1932 TRACE_IC("CallIC", name); |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3098 #undef ADDR | 3111 #undef ADDR |
| 3099 }; | 3112 }; |
| 3100 | 3113 |
| 3101 | 3114 |
| 3102 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 3115 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 3103 return IC_utilities[id]; | 3116 return IC_utilities[id]; |
| 3104 } | 3117 } |
| 3105 | 3118 |
| 3106 | 3119 |
| 3107 } } // namespace v8::internal | 3120 } } // namespace v8::internal |
| OLD | NEW |