Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 case Code::LOAD_IC: return LoadIC::Clear(address, target); | 275 case Code::LOAD_IC: return LoadIC::Clear(address, target); |
| 276 case Code::KEYED_LOAD_IC: | 276 case Code::KEYED_LOAD_IC: |
| 277 case Code::KEYED_EXTERNAL_ARRAY_LOAD_IC: | 277 case Code::KEYED_EXTERNAL_ARRAY_LOAD_IC: |
| 278 return KeyedLoadIC::Clear(address, target); | 278 return KeyedLoadIC::Clear(address, target); |
| 279 case Code::STORE_IC: return StoreIC::Clear(address, target); | 279 case Code::STORE_IC: return StoreIC::Clear(address, target); |
| 280 case Code::KEYED_STORE_IC: | 280 case Code::KEYED_STORE_IC: |
| 281 case Code::KEYED_EXTERNAL_ARRAY_STORE_IC: | 281 case Code::KEYED_EXTERNAL_ARRAY_STORE_IC: |
| 282 return KeyedStoreIC::Clear(address, target); | 282 return KeyedStoreIC::Clear(address, target); |
| 283 case Code::CALL_IC: return CallIC::Clear(address, target); | 283 case Code::CALL_IC: return CallIC::Clear(address, target); |
| 284 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); | 284 case Code::KEYED_CALL_IC: return KeyedCallIC::Clear(address, target); |
| 285 case Code::TYPE_RECORDING_UNARY_OP_IC: | |
| 285 case Code::TYPE_RECORDING_BINARY_OP_IC: | 286 case Code::TYPE_RECORDING_BINARY_OP_IC: |
| 286 case Code::COMPARE_IC: | 287 case Code::COMPARE_IC: |
| 287 // Clearing these is tricky and does not | 288 // Clearing these is tricky and does not |
| 288 // make any performance difference. | 289 // make any performance difference. |
| 289 return; | 290 return; |
| 290 default: UNREACHABLE(); | 291 default: UNREACHABLE(); |
| 291 } | 292 } |
| 292 } | 293 } |
| 293 | 294 |
| 294 | 295 |
| (...skipping 1505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1800 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); | 1801 IC::State state = IC::StateFrom(ic.target(), args[0], args[1]); |
| 1801 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); | 1802 Code::ExtraICState extra_ic_state = ic.target()->extra_ic_state(); |
| 1802 return ic.Store(state, | 1803 return ic.Store(state, |
| 1803 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode), | 1804 static_cast<StrictModeFlag>(extra_ic_state & kStrictMode), |
| 1804 args.at<Object>(0), | 1805 args.at<Object>(0), |
| 1805 args.at<Object>(1), | 1806 args.at<Object>(1), |
| 1806 args.at<Object>(2)); | 1807 args.at<Object>(2)); |
| 1807 } | 1808 } |
| 1808 | 1809 |
| 1809 | 1810 |
| 1811 void TRUnaryOpIC::patch(Code* code) { | |
| 1812 set_target(code); | |
| 1813 } | |
| 1814 | |
| 1815 | |
| 1816 const char* TRUnaryOpIC::GetName(TypeInfo type_info) { | |
| 1817 switch (type_info) { | |
| 1818 case UNINITIALIZED: return "Uninitialized"; | |
| 1819 case SMI: return "SMI"; | |
|
fschneider
2011/04/26 13:32:52
--> "Smi"
Sven Panne
2011/04/27 00:45:54
Done.
| |
| 1820 case HEAP_NUMBER: return "HeapNumbers"; | |
| 1821 case GENERIC: return "Generic"; | |
| 1822 default: return "Invalid"; | |
| 1823 } | |
| 1824 } | |
| 1825 | |
| 1826 | |
| 1827 TRUnaryOpIC::State TRUnaryOpIC::ToState(TypeInfo type_info) { | |
| 1828 switch (type_info) { | |
| 1829 case UNINITIALIZED: | |
| 1830 return ::v8::internal::UNINITIALIZED; | |
| 1831 case SMI: | |
| 1832 case HEAP_NUMBER: | |
| 1833 return MONOMORPHIC; | |
| 1834 case GENERIC: | |
| 1835 return MEGAMORPHIC; | |
| 1836 } | |
| 1837 UNREACHABLE(); | |
| 1838 return ::v8::internal::UNINITIALIZED; | |
| 1839 } | |
| 1840 | |
| 1841 TRUnaryOpIC::TypeInfo TRUnaryOpIC::GetTypeInfo(Handle<Object> operand) { | |
| 1842 ::v8::internal::TypeInfo operand_type = | |
| 1843 ::v8::internal::TypeInfo::TypeFromValue(operand); | |
| 1844 if (operand_type.IsSmi()) { | |
| 1845 return SMI; | |
| 1846 } else if (operand_type.IsNumber()) { | |
| 1847 return HEAP_NUMBER; | |
| 1848 } else { | |
| 1849 return GENERIC; | |
| 1850 } | |
| 1851 } | |
| 1852 | |
| 1853 | |
| 1854 TRUnaryOpIC::TypeInfo TRUnaryOpIC::JoinTypes(TRUnaryOpIC::TypeInfo x, | |
| 1855 TRUnaryOpIC::TypeInfo y) { | |
| 1856 return x >= y ? x : y; | |
| 1857 } | |
| 1858 | |
| 1859 | |
| 1810 void TRBinaryOpIC::patch(Code* code) { | 1860 void TRBinaryOpIC::patch(Code* code) { |
| 1811 set_target(code); | 1861 set_target(code); |
| 1812 } | 1862 } |
| 1813 | 1863 |
| 1814 | 1864 |
| 1815 const char* TRBinaryOpIC::GetName(TypeInfo type_info) { | 1865 const char* TRBinaryOpIC::GetName(TypeInfo type_info) { |
| 1816 switch (type_info) { | 1866 switch (type_info) { |
| 1817 case UNINITIALIZED: return "Uninitialized"; | 1867 case UNINITIALIZED: return "Uninitialized"; |
| 1818 case SMI: return "SMI"; | 1868 case SMI: return "SMI"; |
| 1819 case INT32: return "Int32s"; | 1869 case INT32: return "Int32s"; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1893 // Check for oddball objects. | 1943 // Check for oddball objects. |
| 1894 if (left->IsUndefined() && right->IsNumber()) return ODDBALL; | 1944 if (left->IsUndefined() && right->IsNumber()) return ODDBALL; |
| 1895 if (left->IsNumber() && right->IsUndefined()) return ODDBALL; | 1945 if (left->IsNumber() && right->IsUndefined()) return ODDBALL; |
| 1896 | 1946 |
| 1897 return GENERIC; | 1947 return GENERIC; |
| 1898 } | 1948 } |
| 1899 | 1949 |
| 1900 | 1950 |
| 1901 // defined in code-stubs-<arch>.cc | 1951 // defined in code-stubs-<arch>.cc |
| 1902 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. | 1952 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. |
| 1953 Handle<Code> GetTypeRecordingUnaryOpStub(int key, | |
| 1954 TRUnaryOpIC::TypeInfo type_info); | |
| 1955 | |
| 1956 | |
| 1957 RUNTIME_FUNCTION(MaybeObject*, TypeRecordingUnaryOp_Patch) { | |
| 1958 ASSERT(args.length() == 4); | |
| 1959 | |
| 1960 HandleScope scope(isolate); | |
| 1961 Handle<Object> operand = args.at<Object>(0); | |
| 1962 int key = Smi::cast(args[1])->value(); | |
| 1963 Token::Value op = static_cast<Token::Value>(Smi::cast(args[2])->value()); | |
| 1964 TRUnaryOpIC::TypeInfo previous_type = | |
| 1965 static_cast<TRUnaryOpIC::TypeInfo>(Smi::cast(args[3])->value()); | |
| 1966 | |
| 1967 TRUnaryOpIC::TypeInfo type = TRUnaryOpIC::GetTypeInfo(operand); | |
| 1968 type = TRUnaryOpIC::JoinTypes(type, previous_type); | |
| 1969 | |
| 1970 Handle<Code> code = GetTypeRecordingUnaryOpStub(key, type); | |
| 1971 if (!code.is_null()) { | |
| 1972 if (FLAG_trace_ic) { | |
| 1973 PrintF("[TypeRecordingUnaryOpIC (%s->%s)#%s]\n", | |
| 1974 TRUnaryOpIC::GetName(previous_type), | |
| 1975 TRUnaryOpIC::GetName(type), | |
| 1976 Token::Name(op)); | |
| 1977 } | |
| 1978 TRUnaryOpIC ic(isolate); | |
| 1979 ic.patch(*code); | |
| 1980 } | |
| 1981 | |
| 1982 Handle<JSBuiltinsObject> builtins = Handle<JSBuiltinsObject>( | |
| 1983 isolate->thread_local_top()->context_->builtins(), isolate); | |
| 1984 Object* builtin = NULL; // Initialization calms down the compiler. | |
| 1985 switch (op) { | |
| 1986 case Token::SUB: | |
| 1987 builtin = builtins->javascript_builtin(Builtins::UNARY_MINUS); | |
| 1988 break; | |
| 1989 case Token::BIT_NOT: | |
| 1990 builtin = builtins->javascript_builtin(Builtins::BIT_NOT); | |
| 1991 break; | |
| 1992 default: | |
| 1993 UNREACHABLE(); | |
| 1994 } | |
| 1995 | |
| 1996 Handle<JSFunction> builtin_function(JSFunction::cast(builtin), isolate); | |
| 1997 | |
| 1998 bool caught_exception; | |
| 1999 Handle<Object> result = Execution::Call(builtin_function, operand, 0, NULL, | |
| 2000 &caught_exception); | |
| 2001 if (caught_exception) { | |
| 2002 return Failure::Exception(); | |
| 2003 } | |
| 2004 return *result; | |
| 2005 } | |
| 2006 | |
| 2007 // defined in code-stubs-<arch>.cc | |
| 2008 // Only needed to remove dependency of ic.cc on code-stubs-<arch>.h. | |
| 1903 Handle<Code> GetTypeRecordingBinaryOpStub(int key, | 2009 Handle<Code> GetTypeRecordingBinaryOpStub(int key, |
| 1904 TRBinaryOpIC::TypeInfo type_info, | 2010 TRBinaryOpIC::TypeInfo type_info, |
| 1905 TRBinaryOpIC::TypeInfo result_type); | 2011 TRBinaryOpIC::TypeInfo result_type); |
| 1906 | 2012 |
| 1907 | 2013 |
| 1908 RUNTIME_FUNCTION(MaybeObject*, TypeRecordingBinaryOp_Patch) { | 2014 RUNTIME_FUNCTION(MaybeObject*, TypeRecordingBinaryOp_Patch) { |
| 1909 ASSERT(args.length() == 5); | 2015 ASSERT(args.length() == 5); |
| 1910 | 2016 |
| 1911 HandleScope scope(isolate); | 2017 HandleScope scope(isolate); |
| 1912 Handle<Object> left = args.at<Object>(0); | 2018 Handle<Object> left = args.at<Object>(0); |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2075 #undef ADDR | 2181 #undef ADDR |
| 2076 }; | 2182 }; |
| 2077 | 2183 |
| 2078 | 2184 |
| 2079 Address IC::AddressFromUtilityId(IC::UtilityId id) { | 2185 Address IC::AddressFromUtilityId(IC::UtilityId id) { |
| 2080 return IC_utilities[id]; | 2186 return IC_utilities[id]; |
| 2081 } | 2187 } |
| 2082 | 2188 |
| 2083 | 2189 |
| 2084 } } // namespace v8::internal | 2190 } } // namespace v8::internal |
| OLD | NEW |