OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 1264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, | 1275 void CallStubCompiler::GenerateJumpFunction(Handle<Object> object, |
1276 Register actual_closure, | 1276 Register actual_closure, |
1277 Handle<JSFunction> function) { | 1277 Handle<JSFunction> function) { |
1278 PatchImplicitReceiver(object); | 1278 PatchImplicitReceiver(object); |
1279 ParameterCount expected(function); | 1279 ParameterCount expected(function); |
1280 __ InvokeFunction(actual_closure, expected, arguments(), | 1280 __ InvokeFunction(actual_closure, expected, arguments(), |
1281 JUMP_FUNCTION, NullCallWrapper()); | 1281 JUMP_FUNCTION, NullCallWrapper()); |
1282 } | 1282 } |
1283 | 1283 |
1284 | 1284 |
1285 Handle<Code> CallStubCompiler::CompileArrayPushCall( | |
1286 Handle<Object> object, | |
1287 Handle<JSObject> holder, | |
1288 Handle<Cell> cell, | |
1289 Handle<JSFunction> function, | |
1290 Handle<String> name, | |
1291 Code::StubType type) { | |
1292 // If object is not an array or is observed or sealed, bail out to regular | |
1293 // call. | |
1294 if (!object->IsJSArray() || | |
1295 !cell.is_null() || | |
1296 Handle<JSArray>::cast(object)->map()->is_observed() || | |
1297 !Handle<JSArray>::cast(object)->map()->is_extensible()) { | |
1298 return Handle<Code>::null(); | |
1299 } | |
1300 | |
1301 Label miss; | |
1302 | |
1303 HandlerFrontendHeader(object, holder, name, RECEIVER_MAP_CHECK, &miss); | |
1304 | |
1305 Handle<Map> map(Handle<JSArray>::cast(object)->map()); | |
1306 ElementsKind elements_kind = map->elements_kind(); | |
1307 const int argc = arguments().immediate(); | |
1308 | |
1309 ArrayPushStub stub(elements_kind, argc); | |
1310 Handle<Code> code = stub.GetCode(isolate()); | |
1311 StubCompiler::GenerateTailCall(masm(), code); | |
1312 | |
1313 HandlerFrontendFooter(&miss); | |
1314 | |
1315 // Return the generated code. | |
1316 return GetCode(type, name); | |
1317 } | |
1318 | |
1319 | |
1320 Handle<Code> CallStubCompiler::CompileCallConstant( | 1285 Handle<Code> CallStubCompiler::CompileCallConstant( |
1321 Handle<Object> object, | 1286 Handle<Object> object, |
1322 Handle<JSObject> holder, | 1287 Handle<JSObject> holder, |
1323 Handle<Name> name, | 1288 Handle<Name> name, |
1324 CheckType check, | 1289 CheckType check, |
1325 Handle<JSFunction> function) { | 1290 Handle<JSFunction> function) { |
1326 if (HasCustomCallGenerator(function)) { | 1291 if (HasCustomCallGenerator(function)) { |
1327 Handle<Code> code = CompileCustomCall(object, holder, | 1292 Handle<Code> code = CompileCustomCall(object, holder, |
1328 Handle<Cell>::null(), | 1293 Handle<Cell>::null(), |
1329 function, Handle<String>::cast(name), | 1294 function, Handle<String>::cast(name), |
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1906 ExtraICState extra_state, | 1871 ExtraICState extra_state, |
1907 InlineCacheHolderFlag cache_holder) | 1872 InlineCacheHolderFlag cache_holder) |
1908 : StubCompiler(isolate, extra_state), | 1873 : StubCompiler(isolate, extra_state), |
1909 arguments_(argc), | 1874 arguments_(argc), |
1910 kind_(kind), | 1875 kind_(kind), |
1911 cache_holder_(cache_holder) { | 1876 cache_holder_(cache_holder) { |
1912 } | 1877 } |
1913 | 1878 |
1914 | 1879 |
1915 bool CallStubCompiler::HasCustomCallGenerator(Handle<JSFunction> function) { | 1880 bool CallStubCompiler::HasCustomCallGenerator(Handle<JSFunction> function) { |
1916 if (function->shared()->HasBuiltinFunctionId()) { | |
1917 BuiltinFunctionId id = function->shared()->builtin_function_id(); | |
1918 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; | |
1919 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | |
1920 #undef CALL_GENERATOR_CASE | |
1921 } | |
1922 | |
1923 CallOptimization optimization(function); | 1881 CallOptimization optimization(function); |
1924 return optimization.is_simple_api_call(); | 1882 return optimization.is_simple_api_call(); |
1925 } | 1883 } |
1926 | 1884 |
1927 | 1885 |
1928 Handle<Code> CallStubCompiler::CompileCustomCall( | 1886 Handle<Code> CallStubCompiler::CompileCustomCall( |
1929 Handle<Object> object, | 1887 Handle<Object> object, |
1930 Handle<JSObject> holder, | 1888 Handle<JSObject> holder, |
1931 Handle<Cell> cell, | 1889 Handle<Cell> cell, |
1932 Handle<JSFunction> function, | 1890 Handle<JSFunction> function, |
1933 Handle<String> fname, | 1891 Handle<String> fname, |
1934 Code::StubType type) { | 1892 Code::StubType type) { |
1935 ASSERT(HasCustomCallGenerator(function)); | 1893 ASSERT(HasCustomCallGenerator(function)); |
1936 | |
1937 if (function->shared()->HasBuiltinFunctionId()) { | |
1938 BuiltinFunctionId id = function->shared()->builtin_function_id(); | |
1939 #define CALL_GENERATOR_CASE(name) \ | |
1940 if (id == k##name) { \ | |
1941 return CallStubCompiler::Compile##name##Call(object, \ | |
1942 holder, \ | |
1943 cell, \ | |
1944 function, \ | |
1945 fname, \ | |
1946 type); \ | |
1947 } | |
1948 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | |
1949 #undef CALL_GENERATOR_CASE | |
1950 } | |
1951 CallOptimization optimization(function); | 1894 CallOptimization optimization(function); |
1952 ASSERT(optimization.is_simple_api_call()); | 1895 ASSERT(optimization.is_simple_api_call()); |
1953 return CompileFastApiCall(optimization, | 1896 return CompileFastApiCall(optimization, |
1954 object, | 1897 object, |
1955 holder, | 1898 holder, |
1956 cell, | 1899 cell, |
1957 function, | 1900 function, |
1958 fname); | 1901 fname); |
1959 } | 1902 } |
1960 | 1903 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 Handle<FunctionTemplateInfo>( | 2011 Handle<FunctionTemplateInfo>( |
2069 FunctionTemplateInfo::cast(signature->receiver())); | 2012 FunctionTemplateInfo::cast(signature->receiver())); |
2070 } | 2013 } |
2071 } | 2014 } |
2072 | 2015 |
2073 is_simple_api_call_ = true; | 2016 is_simple_api_call_ = true; |
2074 } | 2017 } |
2075 | 2018 |
2076 | 2019 |
2077 } } // namespace v8::internal | 2020 } } // namespace v8::internal |
OLD | NEW |