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

Side by Side Diff: src/ic.cc

Issue 6756029: Clean up runtime functions. (Closed)
Patch Set: Removed the underscore Created 9 years, 8 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
« no previous file with comments | « src/debug.cc ('k') | src/runtime.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 2006-2009 the V8 project authors. All rights reserved. 1 // Copyright 2006-2009 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 1797 matching lines...) Expand 10 before | Expand all | Expand 10 after
1808 if (in_loop == IN_LOOP) { 1808 if (in_loop == IN_LOOP) {
1809 CompileLazyInLoop(function_handle, CLEAR_EXCEPTION); 1809 CompileLazyInLoop(function_handle, CLEAR_EXCEPTION);
1810 } else { 1810 } else {
1811 CompileLazy(function_handle, CLEAR_EXCEPTION); 1811 CompileLazy(function_handle, CLEAR_EXCEPTION);
1812 } 1812 }
1813 return *function_handle; 1813 return *function_handle;
1814 } 1814 }
1815 1815
1816 1816
1817 // Used from ic-<arch>.cc. 1817 // Used from ic-<arch>.cc.
1818 MUST_USE_RESULT MaybeObject* CallIC_Miss(RUNTIME_CALLING_CONVENTION) { 1818 RUNTIME_FUNCTION(MaybeObject*, CallIC_Miss) {
1819 RUNTIME_GET_ISOLATE;
1820 NoHandleAllocation na; 1819 NoHandleAllocation na;
1821 ASSERT(args.length() == 2); 1820 ASSERT(args.length() == 2);
1822 CallIC ic(isolate); 1821 CallIC ic(isolate);
1823 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1822 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1824 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 1823 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
1825 MaybeObject* maybe_result = ic.LoadFunction(state, 1824 MaybeObject* maybe_result = ic.LoadFunction(state,
1826 extra_ic_state, 1825 extra_ic_state,
1827 args.at<Object>(0), 1826 args.at<Object>(0),
1828 args.at<String>(1)); 1827 args.at<String>(1));
1829 Object* result; 1828 Object* result;
1830 if (!maybe_result->ToObject(&result)) return maybe_result; 1829 if (!maybe_result->ToObject(&result)) return maybe_result;
1831 1830
1832 // The first time the inline cache is updated may be the first time the 1831 // The first time the inline cache is updated may be the first time the
1833 // function it references gets called. If the function was lazily compiled 1832 // function it references gets called. If the function was lazily compiled
1834 // then the first call will trigger a compilation. We check for this case 1833 // then the first call will trigger a compilation. We check for this case
1835 // and we do the compilation immediately, instead of waiting for the stub 1834 // and we do the compilation immediately, instead of waiting for the stub
1836 // currently attached to the JSFunction object to trigger compilation. We 1835 // currently attached to the JSFunction object to trigger compilation. We
1837 // do this in the case where we know that the inline cache is inside a loop, 1836 // do this in the case where we know that the inline cache is inside a loop,
1838 // because then we know that we want to optimize the function. 1837 // because then we know that we want to optimize the function.
1839 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { 1838 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) {
1840 return result; 1839 return result;
1841 } 1840 }
1842 return CompileFunction(isolate, 1841 return CompileFunction(isolate,
1843 JSFunction::cast(result), 1842 JSFunction::cast(result),
1844 ic.target()->ic_in_loop()); 1843 ic.target()->ic_in_loop());
1845 } 1844 }
1846 1845
1847 1846
1848 // Used from ic-<arch>.cc. 1847 // Used from ic-<arch>.cc.
1849 MUST_USE_RESULT MaybeObject* KeyedCallIC_Miss(RUNTIME_CALLING_CONVENTION) { 1848 RUNTIME_FUNCTION(MaybeObject*, KeyedCallIC_Miss) {
1850 RUNTIME_GET_ISOLATE;
1851 NoHandleAllocation na; 1849 NoHandleAllocation na;
1852 ASSERT(args.length() == 2); 1850 ASSERT(args.length() == 2);
1853 KeyedCallIC ic(isolate); 1851 KeyedCallIC ic(isolate);
1854 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1852 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1855 Object* result; 1853 Object* result;
1856 { MaybeObject* maybe_result = 1854 { MaybeObject* maybe_result =
1857 ic.LoadFunction(state, args.at<Object>(0), args.at<Object>(1)); 1855 ic.LoadFunction(state, args.at<Object>(0), args.at<Object>(1));
1858 if (!maybe_result->ToObject(&result)) return maybe_result; 1856 if (!maybe_result->ToObject(&result)) return maybe_result;
1859 } 1857 }
1860 1858
1861 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) { 1859 if (!result->IsJSFunction() || JSFunction::cast(result)->is_compiled()) {
1862 return result; 1860 return result;
1863 } 1861 }
1864 return CompileFunction(isolate, 1862 return CompileFunction(isolate,
1865 JSFunction::cast(result), 1863 JSFunction::cast(result),
1866 ic.target()->ic_in_loop()); 1864 ic.target()->ic_in_loop());
1867 } 1865 }
1868 1866
1869 1867
1870 // Used from ic-<arch>.cc. 1868 // Used from ic-<arch>.cc.
1871 MUST_USE_RESULT MaybeObject* LoadIC_Miss(RUNTIME_CALLING_CONVENTION) { 1869 RUNTIME_FUNCTION(MaybeObject*, LoadIC_Miss) {
1872 RUNTIME_GET_ISOLATE;
1873 NoHandleAllocation na; 1870 NoHandleAllocation na;
1874 ASSERT(args.length() == 2); 1871 ASSERT(args.length() == 2);
1875 LoadIC ic(isolate); 1872 LoadIC ic(isolate);
1876 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1873 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1877 return ic.Load(state, args.at<Object>(0), args.at<String>(1)); 1874 return ic.Load(state, args.at<Object>(0), args.at<String>(1));
1878 } 1875 }
1879 1876
1880 1877
1881 // Used from ic-<arch>.cc 1878 // Used from ic-<arch>.cc
1882 MUST_USE_RESULT MaybeObject* KeyedLoadIC_Miss(RUNTIME_CALLING_CONVENTION) { 1879 RUNTIME_FUNCTION(MaybeObject*, KeyedLoadIC_Miss) {
1883 RUNTIME_GET_ISOLATE;
1884 NoHandleAllocation na; 1880 NoHandleAllocation na;
1885 ASSERT(args.length() == 2); 1881 ASSERT(args.length() == 2);
1886 KeyedLoadIC ic(isolate); 1882 KeyedLoadIC ic(isolate);
1887 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1883 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1888 return ic.Load(state, args.at<Object>(0), args.at<Object>(1)); 1884 return ic.Load(state, args.at<Object>(0), args.at<Object>(1));
1889 } 1885 }
1890 1886
1891 1887
1892 // Used from ic-<arch>.cc. 1888 // Used from ic-<arch>.cc.
1893 MUST_USE_RESULT MaybeObject* StoreIC_Miss(RUNTIME_CALLING_CONVENTION) { 1889 RUNTIME_FUNCTION(MaybeObject*, StoreIC_Miss) {
1894 RUNTIME_GET_ISOLATE;
1895 NoHandleAllocation na; 1890 NoHandleAllocation na;
1896 ASSERT(args.length() == 3); 1891 ASSERT(args.length() == 3);
1897 StoreIC ic(isolate); 1892 StoreIC ic(isolate);
1898 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1893 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1899 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 1894 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
1900 return ic.Store(state, 1895 return ic.Store(state,
1901 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode), 1896 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode),
1902 args.at<Object>(0), 1897 args.at<Object>(0),
1903 args.at<String>(1), 1898 args.at<String>(1),
1904 args.at<Object>(2)); 1899 args.at<Object>(2));
1905 } 1900 }
1906 1901
1907 1902
1908 MUST_USE_RESULT MaybeObject* StoreIC_ArrayLength(RUNTIME_CALLING_CONVENTION) { 1903 RUNTIME_FUNCTION(MaybeObject*, StoreIC_ArrayLength) {
1909 RUNTIME_GET_ISOLATE;
1910 NoHandleAllocation nha; 1904 NoHandleAllocation nha;
1911 1905
1912 ASSERT(args.length() == 2); 1906 ASSERT(args.length() == 2);
1913 JSObject* receiver = JSObject::cast(args[0]); 1907 JSObject* receiver = JSObject::cast(args[0]);
1914 Object* len = args[1]; 1908 Object* len = args[1];
1915 1909
1916 // The generated code should filter out non-Smis before we get here. 1910 // The generated code should filter out non-Smis before we get here.
1917 ASSERT(len->IsSmi()); 1911 ASSERT(len->IsSmi());
1918 1912
1919 Object* result; 1913 Object* result;
1920 { MaybeObject* maybe_result = receiver->SetElementsLength(len); 1914 { MaybeObject* maybe_result = receiver->SetElementsLength(len);
1921 if (!maybe_result->ToObject(&result)) return maybe_result; 1915 if (!maybe_result->ToObject(&result)) return maybe_result;
1922 } 1916 }
1923 return len; 1917 return len;
1924 } 1918 }
1925 1919
1926 1920
1927 // Extend storage is called in a store inline cache when 1921 // Extend storage is called in a store inline cache when
1928 // it is necessary to extend the properties array of a 1922 // it is necessary to extend the properties array of a
1929 // JSObject. 1923 // JSObject.
1930 MUST_USE_RESULT MaybeObject* SharedStoreIC_ExtendStorage( 1924 RUNTIME_FUNCTION(MaybeObject*, SharedStoreIC_ExtendStorage) {
1931 RUNTIME_CALLING_CONVENTION) {
1932 RUNTIME_GET_ISOLATE;
1933 NoHandleAllocation na; 1925 NoHandleAllocation na;
1934 ASSERT(args.length() == 3); 1926 ASSERT(args.length() == 3);
1935 1927
1936 // Convert the parameters 1928 // Convert the parameters
1937 JSObject* object = JSObject::cast(args[0]); 1929 JSObject* object = JSObject::cast(args[0]);
1938 Map* transition = Map::cast(args[1]); 1930 Map* transition = Map::cast(args[1]);
1939 Object* value = args[2]; 1931 Object* value = args[2];
1940 1932
1941 // Check the object has run out out property space. 1933 // Check the object has run out out property space.
1942 ASSERT(object->HasFastProperties()); 1934 ASSERT(object->HasFastProperties());
(...skipping 13 matching lines...) Expand all
1956 // Set the new property value and do the map transition. 1948 // Set the new property value and do the map transition.
1957 object->set_properties(new_storage); 1949 object->set_properties(new_storage);
1958 object->set_map(transition); 1950 object->set_map(transition);
1959 1951
1960 // Return the stored value. 1952 // Return the stored value.
1961 return value; 1953 return value;
1962 } 1954 }
1963 1955
1964 1956
1965 // Used from ic-<arch>.cc. 1957 // Used from ic-<arch>.cc.
1966 MUST_USE_RESULT MaybeObject* KeyedStoreIC_Miss(RUNTIME_CALLING_CONVENTION) { 1958 RUNTIME_FUNCTION(MaybeObject*, KeyedStoreIC_Miss) {
1967 RUNTIME_GET_ISOLATE;
1968 NoHandleAllocation na; 1959 NoHandleAllocation na;
1969 ASSERT(args.length() == 3); 1960 ASSERT(args.length() == 3);
1970 KeyedStoreIC ic(isolate); 1961 KeyedStoreIC ic(isolate);
1971 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); 1962 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]);
1972 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); 1963 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state();
1973 return ic.Store(state, 1964 return ic.Store(state,
1974 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode), 1965 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode),
1975 args.at<Object>(0), 1966 args.at<Object>(0),
1976 args.at<Object>(1), 1967 args.at<Object>(1),
1977 args.at<Object>(2)); 1968 args.at<Object>(2));
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2030 } 2021 }
2031 2022
2032 return GENERIC; 2023 return GENERIC;
2033 } 2024 }
2034 2025
2035 2026
2036 // defined in code-stubs-<arch>.cc 2027 // defined in code-stubs-<arch>.cc
2037 Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info); 2028 Handle<Code> GetBinaryOpStub(int key, BinaryOpIC::TypeInfo type_info);
2038 2029
2039 2030
2040 MUST_USE_RESULT MaybeObject* BinaryOp_Patch(RUNTIME_CALLING_CONVENTION) { 2031 RUNTIME_FUNCTION(MaybeObject*, BinaryOp_Patch) {
2041 RUNTIME_GET_ISOLATE;
2042 ASSERT(args.length() == 5); 2032 ASSERT(args.length() == 5);
2043 2033
2044 HandleScope scope(isolate); 2034 HandleScope scope(isolate);
2045 Handle<Object> left = args.at<Object>(0); 2035 Handle<Object> left = args.at<Object>(0);
2046 Handle<Object> right = args.at<Object>(1); 2036 Handle<Object> right = args.at<Object>(1);
2047 int key = Smi::cast(args[2])->value(); 2037 int key = Smi::cast(args[2])->value();
2048 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value()); 2038 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value());
2049 BinaryOpIC::TypeInfo previous_type = 2039 BinaryOpIC::TypeInfo previous_type =
2050 static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); 2040 static_cast<BinaryOpIC::TypeInfo>(Smi::cast(args[4])->value());
2051 2041
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2202 } 2192 }
2203 2193
2204 2194
2205 // defined in code-stubs-<arch>.cc 2195 // defined in code-stubs-<arch>.cc
2206 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. 2196 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h.
2207 Handle<Code> GetTypeRecordingBinaryOpStub(int key, 2197 Handle<Code> GetTypeRecordingBinaryOpStub(int key,
2208 TRBinaryOpIC::TypeInfo type_info, 2198 TRBinaryOpIC::TypeInfo type_info,
2209 TRBinaryOpIC::TypeInfo result_type); 2199 TRBinaryOpIC::TypeInfo result_type);
2210 2200
2211 2201
2212 MaybeObject* TypeRecordingBinaryOp_Patch(RUNTIME_CALLING_CONVENTION) { 2202 RUNTIME_FUNCTION(MaybeObject*, TypeRecordingBinaryOp_Patch) {
2213 RUNTIME_GET_ISOLATE;
2214 ASSERT(args.length() == 5); 2203 ASSERT(args.length() == 5);
2215 2204
2216 HandleScope scope(isolate); 2205 HandleScope scope(isolate);
2217 Handle<Object> left = args.at<Object>(0); 2206 Handle<Object> left = args.at<Object>(0);
2218 Handle<Object> right = args.at<Object>(1); 2207 Handle<Object> right = args.at<Object>(1);
2219 int key = Smi::cast(args[2])->value(); 2208 int key = Smi::cast(args[2])->value();
2220 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value()); 2209 Token::Value op = static_cast<Token::Value>(Smi::cast(args[3])->value());
2221 TRBinaryOpIC::TypeInfo previous_type = 2210 TRBinaryOpIC::TypeInfo previous_type =
2222 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value()); 2211 static_cast<TRBinaryOpIC::TypeInfo>(Smi::cast(args[4])->value());
2223 2212
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
2358 if ((state == UNINITIALIZED || (state == SMIS && has_inlined_smi_code)) && 2347 if ((state == UNINITIALIZED || (state == SMIS && has_inlined_smi_code)) &&
2359 x->IsNumber() && y->IsNumber()) return HEAP_NUMBERS; 2348 x->IsNumber() && y->IsNumber()) return HEAP_NUMBERS;
2360 if (op_ != Token::EQ && op_ != Token::EQ_STRICT) return GENERIC; 2349 if (op_ != Token::EQ && op_ != Token::EQ_STRICT) return GENERIC;
2361 if (state == UNINITIALIZED && 2350 if (state == UNINITIALIZED &&
2362 x->IsJSObject() && y->IsJSObject()) return OBJECTS; 2351 x->IsJSObject() && y->IsJSObject()) return OBJECTS;
2363 return GENERIC; 2352 return GENERIC;
2364 } 2353 }
2365 2354
2366 2355
2367 // Used from ic_<arch>.cc. 2356 // Used from ic_<arch>.cc.
2368 Code* CompareIC_Miss(RUNTIME_CALLING_CONVENTION) { 2357 RUNTIME_FUNCTION(Code*, CompareIC_Miss) {
2369 RUNTIME_GET_ISOLATE;
2370 NoHandleAllocation na; 2358 NoHandleAllocation na;
2371 ASSERT(args.length() == 3); 2359 ASSERT(args.length() == 3);
2372 CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value())); 2360 CompareIC ic(isolate, static_cast<Token::Value>(Smi::cast(args[2])->value()));
2373 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1)); 2361 ic.UpdateCaches(args.at<Object>(0), args.at<Object>(1));
2374 return ic.target(); 2362 return ic.target();
2375 } 2363 }
2376 2364
2377 2365
2378 static const Address IC_utilities[] = { 2366 static const Address IC_utilities[] = {
2379 #define ADDR(name) FUNCTION_ADDR(name), 2367 #define ADDR(name) FUNCTION_ADDR(name),
2380 IC_UTIL_LIST(ADDR) 2368 IC_UTIL_LIST(ADDR)
2381 NULL 2369 NULL
2382 #undef ADDR 2370 #undef ADDR
2383 }; 2371 };
2384 2372
2385 2373
2386 Address IC::AddressFromUtilityId(IC::UtilityId id) { 2374 Address IC::AddressFromUtilityId(IC::UtilityId id) {
2387 return IC_utilities[id]; 2375 return IC_utilities[id];
2388 } 2376 }
2389 2377
2390 2378
2391 } } // namespace v8::internal 2379 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/debug.cc ('k') | src/runtime.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698