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

Side by Side Diff: src/ic.cc

Issue 279423005: Customized support for feedback on calls to Array. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Rebase and comments. 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/objects.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(function->IsJSFunction());
1848 // Are we the array function?
1849 Handle<JSFunction> array_function = Handle<JSFunction>(
1850 isolate()->context()->native_context()->array_function(), isolate());
1851 if (array_function.is_identical_to(Handle<JSFunction>::cast(function))) {
1852 // Alter the slot.
1853 vector->set(slot->value(), *isolate()->factory()->NewAllocationSite());
1854 State new_state = state.ToMonomorphicArrayCallState();
1855 CallICStub stub(isolate(), new_state);
1856 set_target(*stub.GetCode());
1857 Handle<String> name;
1858 if (array_function->shared()->name()->IsString()) {
1859 name = Handle<String>(String::cast(array_function->shared()->name()),
1860 isolate());
1861 }
1862
1863 TRACE_IC("CallIC (Array call)", name);
1864 return true;
1865 }
1866 return false;
1867 }
1868
1869
1833 void CallIC::HandleMiss(Handle<Object> receiver, 1870 void CallIC::HandleMiss(Handle<Object> receiver,
1834 Handle<Object> function, 1871 Handle<Object> function,
1835 Handle<FixedArray> vector, 1872 Handle<FixedArray> vector,
1836 Handle<Smi> slot) { 1873 Handle<Smi> slot) {
1837 State state(target()->extra_ic_state()); 1874 State state(target()->extra_ic_state());
1838 Object* feedback = vector->get(slot->value()); 1875 Object* feedback = vector->get(slot->value());
1839 1876
1840 if (feedback->IsJSFunction() || !function->IsJSFunction()) { 1877 if (feedback->IsJSFunction() || !function->IsJSFunction() ||
1878 state.stub_type() != DEFAULT) {
1841 // We are going generic. 1879 // We are going generic.
1842 ASSERT(!function->IsJSFunction() || *function != feedback);
1843
1844 vector->set(slot->value(), 1880 vector->set(slot->value(),
1845 *TypeFeedbackInfo::MegamorphicSentinel(isolate()), 1881 *TypeFeedbackInfo::MegamorphicSentinel(isolate()),
1846 SKIP_WRITE_BARRIER); 1882 SKIP_WRITE_BARRIER);
1883
1884 State new_state = state.ToGenericState();
1885 if (new_state != state) {
1886 // Only happens when the array ic goes generic.
1887 ASSERT(state.stub_type() == MONOMORPHIC_ARRAY);
1888 CallICStub stub(isolate(), new_state);
1889 Handle<Code> code = stub.GetCode();
1890 set_target(*code);
1891 }
1892
1847 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic"); 1893 TRACE_GENERIC_IC(isolate(), "CallIC", "megamorphic");
1848 } else { 1894 } else {
1849 // If we came here feedback must be the uninitialized sentinel, 1895 // If we came here feedback must be the uninitialized sentinel,
1850 // and we are going monomorphic. 1896 // and we are going monomorphic.
1851 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate())); 1897 ASSERT(feedback == *TypeFeedbackInfo::UninitializedSentinel(isolate()));
1898
1899 // Do we want to install a custom handler?
1900 if (DoCustomHandler(receiver, function, vector, slot, state)) {
1901 return;
1902 }
1903
1852 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function); 1904 Handle<JSFunction> js_function = Handle<JSFunction>::cast(function);
1853 Handle<Object> name(js_function->shared()->name(), isolate()); 1905 Handle<Object> name(js_function->shared()->name(), isolate());
1854 TRACE_IC("CallIC", name); 1906 TRACE_IC("CallIC", name);
1855 vector->set(slot->value(), *function); 1907 vector->set(slot->value(), *function);
1856 } 1908 }
1857 } 1909 }
1858 1910
1859 1911
1860 #undef TRACE_IC 1912 #undef TRACE_IC
1861 1913
(...skipping 1124 matching lines...) Expand 10 before | Expand all | Expand 10 after
2986 #undef ADDR 3038 #undef ADDR
2987 }; 3039 };
2988 3040
2989 3041
2990 Address IC::AddressFromUtilityId(IC::UtilityId id) { 3042 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2991 return IC_utilities[id]; 3043 return IC_utilities[id];
2992 } 3044 }
2993 3045
2994 3046
2995 } } // namespace v8::internal 3047 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ic.h ('k') | src/objects.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698