| 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 637 if (probe->IsCode()) return Handle<Code>::cast(probe); | 637 if (probe->IsCode()) return Handle<Code>::cast(probe); |
| 638 | 638 |
| 639 CallStubCompiler compiler(isolate_, argc, kind, extra_state, cache_holder); | 639 CallStubCompiler compiler(isolate_, argc, kind, extra_state, cache_holder); |
| 640 Handle<Code> code = | 640 Handle<Code> code = |
| 641 compiler.CompileCallConstant(object, holder, name, check, function); | 641 compiler.CompileCallConstant(object, holder, name, check, function); |
| 642 code->set_check_type(check); | 642 code->set_check_type(check); |
| 643 ASSERT(flags == code->flags()); | 643 ASSERT(flags == code->flags()); |
| 644 PROFILE(isolate_, | 644 PROFILE(isolate_, |
| 645 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); | 645 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
| 646 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); | 646 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
| 647 JSObject::UpdateMapCodeCache(stub_holder, name, code); | 647 |
| 648 if (CallStubCompiler::CanBeCached(function)) { |
| 649 JSObject::UpdateMapCodeCache(stub_holder, name, code); |
| 650 } |
| 648 return code; | 651 return code; |
| 649 } | 652 } |
| 650 | 653 |
| 651 | 654 |
| 652 Handle<Code> StubCache::ComputeCallField(int argc, | 655 Handle<Code> StubCache::ComputeCallField(int argc, |
| 653 Code::Kind kind, | 656 Code::Kind kind, |
| 654 Code::ExtraICState extra_state, | 657 Code::ExtraICState extra_state, |
| 655 Handle<Name> name, | 658 Handle<Name> name, |
| 656 Handle<Object> object, | 659 Handle<Object> object, |
| 657 Handle<JSObject> holder, | 660 Handle<JSObject> holder, |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 isolate_); | 749 isolate_); |
| 747 if (probe->IsCode()) return Handle<Code>::cast(probe); | 750 if (probe->IsCode()) return Handle<Code>::cast(probe); |
| 748 | 751 |
| 749 CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder); | 752 CallStubCompiler compiler(isolate(), argc, kind, extra_state, cache_holder); |
| 750 Handle<Code> code = | 753 Handle<Code> code = |
| 751 compiler.CompileCallGlobal(receiver, holder, cell, function, name); | 754 compiler.CompileCallGlobal(receiver, holder, cell, function, name); |
| 752 ASSERT(flags == code->flags()); | 755 ASSERT(flags == code->flags()); |
| 753 PROFILE(isolate(), | 756 PROFILE(isolate(), |
| 754 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); | 757 CodeCreateEvent(CALL_LOGGER_TAG(kind, CALL_IC_TAG), *code, *name)); |
| 755 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); | 758 GDBJIT(AddCode(GDBJITInterface::CALL_IC, *name, *code)); |
| 756 JSObject::UpdateMapCodeCache(stub_holder, name, code); | 759 if (CallStubCompiler::CanBeCached(function)) { |
| 760 JSObject::UpdateMapCodeCache(stub_holder, name, code); |
| 761 } |
| 757 return code; | 762 return code; |
| 758 } | 763 } |
| 759 | 764 |
| 760 | 765 |
| 761 static void FillCache(Isolate* isolate, Handle<Code> code) { | 766 static void FillCache(Isolate* isolate, Handle<Code> code) { |
| 762 Handle<UnseededNumberDictionary> dictionary = | 767 Handle<UnseededNumberDictionary> dictionary = |
| 763 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), | 768 UnseededNumberDictionary::Set(isolate->factory()->non_monomorphic_cache(), |
| 764 code->flags(), | 769 code->flags(), |
| 765 code); | 770 code); |
| 766 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); | 771 isolate->heap()->public_set_non_monomorphic_cache(*dictionary); |
| (...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1967 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; | 1972 #define CALL_GENERATOR_CASE(name) if (id == k##name) return true; |
| 1968 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | 1973 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) |
| 1969 #undef CALL_GENERATOR_CASE | 1974 #undef CALL_GENERATOR_CASE |
| 1970 } | 1975 } |
| 1971 | 1976 |
| 1972 CallOptimization optimization(function); | 1977 CallOptimization optimization(function); |
| 1973 return optimization.is_simple_api_call(); | 1978 return optimization.is_simple_api_call(); |
| 1974 } | 1979 } |
| 1975 | 1980 |
| 1976 | 1981 |
| 1982 bool CallStubCompiler::CanBeCached(Handle<JSFunction> function) { |
| 1983 if (function->shared()->HasBuiltinFunctionId()) { |
| 1984 BuiltinFunctionId id = function->shared()->builtin_function_id(); |
| 1985 #define CALL_GENERATOR_CASE(name) if (id == k##name) return false; |
| 1986 SITE_SPECIFIC_CALL_GENERATORS(CALL_GENERATOR_CASE) |
| 1987 #undef CALL_GENERATOR_CASE |
| 1988 } |
| 1989 |
| 1990 return true; |
| 1991 } |
| 1992 |
| 1993 |
| 1977 Handle<Code> CallStubCompiler::CompileCustomCall( | 1994 Handle<Code> CallStubCompiler::CompileCustomCall( |
| 1978 Handle<Object> object, | 1995 Handle<Object> object, |
| 1979 Handle<JSObject> holder, | 1996 Handle<JSObject> holder, |
| 1980 Handle<Cell> cell, | 1997 Handle<Cell> cell, |
| 1981 Handle<JSFunction> function, | 1998 Handle<JSFunction> function, |
| 1982 Handle<String> fname) { | 1999 Handle<String> fname, |
| 2000 Code::StubType type) { |
| 1983 ASSERT(HasCustomCallGenerator(function)); | 2001 ASSERT(HasCustomCallGenerator(function)); |
| 1984 | 2002 |
| 1985 if (function->shared()->HasBuiltinFunctionId()) { | 2003 if (function->shared()->HasBuiltinFunctionId()) { |
| 1986 BuiltinFunctionId id = function->shared()->builtin_function_id(); | 2004 BuiltinFunctionId id = function->shared()->builtin_function_id(); |
| 1987 #define CALL_GENERATOR_CASE(name) \ | 2005 #define CALL_GENERATOR_CASE(name) \ |
| 1988 if (id == k##name) { \ | 2006 if (id == k##name) { \ |
| 1989 return CallStubCompiler::Compile##name##Call(object, \ | 2007 return CallStubCompiler::Compile##name##Call(object, \ |
| 1990 holder, \ | 2008 holder, \ |
| 1991 cell, \ | 2009 cell, \ |
| 1992 function, \ | 2010 function, \ |
| 1993 fname); \ | 2011 fname, \ |
| 2012 type); \ |
| 1994 } | 2013 } |
| 1995 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) | 2014 CUSTOM_CALL_IC_GENERATORS(CALL_GENERATOR_CASE) |
| 1996 #undef CALL_GENERATOR_CASE | 2015 #undef CALL_GENERATOR_CASE |
| 1997 } | 2016 } |
| 1998 CallOptimization optimization(function); | 2017 CallOptimization optimization(function); |
| 1999 ASSERT(optimization.is_simple_api_call()); | 2018 ASSERT(optimization.is_simple_api_call()); |
| 2000 return CompileFastApiCall(optimization, | 2019 return CompileFastApiCall(optimization, |
| 2001 object, | 2020 object, |
| 2002 holder, | 2021 holder, |
| 2003 cell, | 2022 cell, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2093 Handle<FunctionTemplateInfo>( | 2112 Handle<FunctionTemplateInfo>( |
| 2094 FunctionTemplateInfo::cast(signature->receiver())); | 2113 FunctionTemplateInfo::cast(signature->receiver())); |
| 2095 } | 2114 } |
| 2096 } | 2115 } |
| 2097 | 2116 |
| 2098 is_simple_api_call_ = true; | 2117 is_simple_api_call_ = true; |
| 2099 } | 2118 } |
| 2100 | 2119 |
| 2101 | 2120 |
| 2102 } } // namespace v8::internal | 2121 } } // namespace v8::internal |
| OLD | NEW |