Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(115)

Side by Side Diff: src/ic.cc

Issue 305493003: Reland "Customized support for feedback on calls to Array." and follow-up fixes. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Bugfix and tests Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/ic.h ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "v8.h" 5 #include "v8.h"
6 6
7 #include "accessors.h" 7 #include "accessors.h"
8 #include "api.h" 8 #include "api.h"
9 #include "arguments.h" 9 #include "arguments.h"
10 #include "codegen.h" 10 #include "codegen.h"
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 // through the embedded maps. 494 // through the embedded maps.
495 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate), constant_pool); 495 SetTargetAtAddress(address, *pre_monomorphic_stub(isolate), constant_pool);
496 } 496 }
497 497
498 498
499 void CallIC::Clear(Isolate* isolate, 499 void CallIC::Clear(Isolate* isolate,
500 Address address, 500 Address address,
501 Code* target, 501 Code* target,
502 ConstantPoolArray* constant_pool) { 502 ConstantPoolArray* constant_pool) {
503 // Currently, CallIC doesn't have state changes. 503 // Currently, CallIC doesn't have state changes.
504 ASSERT(target->ic_state() == v8::internal::GENERIC); 504 if (target->ic_state() != v8::internal::MONOMORPHIC) return;
505 CallIC::State existing_state(target->extra_ic_state());
506
507 // Monomorphic array stubs don't need to be cleared because
508 // 1) the stub doesn't store information that should be cleared, and
509 // 2) the AllocationSite stored in the type feedback vector is immune
510 // from gc type feedback clearing.
511 ASSERT(existing_state.stub_type() == MONOMORPHIC_ARRAY);
505 } 512 }
506 513
507 514
508 void LoadIC::Clear(Isolate* isolate, 515 void LoadIC::Clear(Isolate* isolate,
509 Address address, 516 Address address,
510 Code* target, 517 Code* target,
511 ConstantPoolArray* constant_pool) { 518 ConstantPoolArray* constant_pool) {
512 if (IsCleared(target)) return; 519 if (IsCleared(target)) return;
513 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC( 520 Code* code = target->GetIsolate()->stub_cache()->FindPreMonomorphicIC(
514 Code::LOAD_IC, target->extra_ic_state()); 521 Code::LOAD_IC, target->extra_ic_state());
(...skipping 1296 matching lines...) Expand 10 before | Expand all | Expand 10 after
1811 set_target(*stub); 1818 set_target(*stub);
1812 TRACE_IC("StoreIC", key); 1819 TRACE_IC("StoreIC", key);
1813 } 1820 }
1814 1821
1815 return store_handle; 1822 return store_handle;
1816 } 1823 }
1817 1824
1818 1825
1819 CallIC::State::State(ExtraICState extra_ic_state) 1826 CallIC::State::State(ExtraICState extra_ic_state)
1820 : argc_(ArgcBits::decode(extra_ic_state)), 1827 : argc_(ArgcBits::decode(extra_ic_state)),
1821 call_type_(CallTypeBits::decode(extra_ic_state)) { 1828 call_type_(CallTypeBits::decode(extra_ic_state)),
1829 stub_type_(StubTypeBits::decode(extra_ic_state)) {
1822 } 1830 }
1823 1831
1824 1832
1825 ExtraICState CallIC::State::GetExtraICState() const { 1833 ExtraICState CallIC::State::GetExtraICState() const {
1826 ExtraICState extra_ic_state = 1834 ExtraICState extra_ic_state =
1827 ArgcBits::encode(argc_) | 1835 ArgcBits::encode(argc_) |
1828 CallTypeBits::encode(call_type_); 1836 CallTypeBits::encode(call_type_) |
1837 StubTypeBits::encode(stub_type_);
1829 return extra_ic_state; 1838 return extra_ic_state;
1830 } 1839 }
1831 1840
1832 1841
1842 bool CallIC::DoCustomHandler(Handle<Object> receiver,
1843 Handle<Object> function,
1844 Handle<FixedArray> vector,
1845 Handle<Smi> slot,
1846 const State& state) {
1847 ASSERT(FLAG_use_ic && function->IsJSFunction());
1848
1849 // Are we the array function?
1850 Handle<JSFunction> array_function = Handle<JSFunction>(
1851 isolate()->context()->native_context()->array_function(), isolate());
1852 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) {
1853 // Alter the slot.
1854 Handle<AllocationSite> new_site = isolate()->factory()->NewAllocationSite();
1855 vector->set(slot->value(), *new_site);
1856 State new_state = state.ToMonomorphicArrayCallState();
1857 CallICStub stub(isolate(), new_state);
1858 set_target(*stub.GetCode());
1859 Handle<String> name;
1860 if (array_function->shared()->name()->IsString()) {
1861 name = Handle<String>(String::cast(array_function->shared()->name()),
1862 isolate());
1863 }
1864
1865 TRACE_IC("CallIC (Array call)", name);
1866 return true;
1867 }
1868 return false;
1869 }
1870
1871
1833 void CallIC::HandleMiss(Handle<Object> receiver, 1872 void CallIC::HandleMiss(Handle<Object> receiver,
1834 Handle<Object> function, 1873 Handle<Object> function,
1835 Handle<FixedArray> vector, 1874 Handle<FixedArray> vector,
1836 Handle<Smi> slot) { 1875 Handle<Smi> slot) {
1837 State state(target()->extra_ic_state()); 1876 State state(target()->extra_ic_state());
1838 Object* feedback = vector->get(slot->value()); 1877 Object* feedback = vector->get(slot->value());
1839 1878
1840 if (feedback->IsJSFunction() || !function->IsJSFunction()) { 1879 if (feedback->IsJSFunction() || !function->IsJSFunction() ||
1880 state.stub_type() != DEFAULT) {
1841 // We are going generic. 1881 // We are going generic.
1842 ASSERT(!function->IsJSFunction() || *function != feedback);
1843
1844 vector->set(slot->value(), 1882 vector->set(slot->value(),
1845 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), 1883 *TypeFeedbackInfo::MegamorphicSentinel(isolate()),
1846 SKIP_WRITE_BARRIER); 1884 SKIP_WRITE_BARRIER);
1885
1886 State new_state = state.ToGenericState();
1887 if (new_state != state) {
1888 // Only happens when the array ic goes generic.
1889 ASSERT(state.stub_type() == MONOMORPHIC_ARRAY &&
1890 FLAG_use_ic);
1891 CallICStub stub(isolate(), new_state);
1892 Handle<Code> code = stub.GetCode();
1893 set_target(*code);
1894 }
1895
1847 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); 1896 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic");
1848 } else { 1897 } else {
1849 // If we came here feedback must be the uninitialized sentinel, 1898 // If we came here feedback must be the uninitialized sentinel,
1850 // and we are going monomorphic. 1899 // and we are going monomorphic.
1851 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate())); 1900 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate()));
1901
1902 // Do we want to install a custom handler?
1903 if (FLAG_use_ic &&
1904 DoCustomHandler(receiver, function, vector, slot, state)) {
1905 return;
1906 }
1907
1852 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); 1908 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
1853 Handle<Object> name(js_function->shared()->name(), isolate()); 1909 Handle<Object> name(js_function->shared()->name(), isolate());
1854 TRACE_IC("CallIC", name); 1910 TRACE_IC("CallIC", name);
1855 vector->set(slot->value(), *function); 1911 vector->set(slot->value(), *function);
1856 } 1912 }
1857 } 1913 }
1858 1914
1859 1915
1860 #undef TRACE_IC 1916 #undef TRACE_IC
1861 1917
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 #undef ADDR 3042 #undef ADDR
2987 }; 3043 };
2988 3044
2989 3045
2990 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3046 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2991 return IC_utilities[id]; 3047 return IC_utilities[id];
2992 } 3048 }
2993 3049
2994 3050
2995 } } // namespace v8::internal 3051 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/mips/code-stubs-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698