| 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 1976 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1987 Initialize(Handle<JSFunction>::null()); | 1987 Initialize(Handle<JSFunction>::null()); |
| 1988 } | 1988 } |
| 1989 } | 1989 } |
| 1990 | 1990 |
| 1991 | 1991 |
| 1992 CallOptimization::CallOptimization(Handle<JSFunction> function) { | 1992 CallOptimization::CallOptimization(Handle<JSFunction> function) { |
| 1993 Initialize(function); | 1993 Initialize(function); |
| 1994 } | 1994 } |
| 1995 | 1995 |
| 1996 | 1996 |
| 1997 Handle<Map> CallOptimization::LookupHolderOfExpectedType( | 1997 int CallOptimization::GetPrototypeDepthOfExpectedType( |
| 1998 Handle<JSObject> receiver, | |
| 1999 Handle<JSObject> object, | 1998 Handle<JSObject> object, |
| 2000 Handle<JSObject> holder, | 1999 Handle<JSObject> holder) const { |
| 2001 HolderLookup* holder_lookup) const { | |
| 2002 ASSERT(is_simple_api_call()); | 2000 ASSERT(is_simple_api_call()); |
| 2003 ASSERT_EQ(kHolderNotFound, *holder_lookup); | 2001 if (expected_receiver_type_.is_null()) return 0; |
| 2004 *holder_lookup = kHolderIsReceiver; | 2002 int depth = 0; |
| 2005 Handle<Map> map_to_holder; | 2003 while (!object.is_identical_to(holder)) { |
| 2006 if (expected_receiver_type_.is_null()) { | 2004 if (expected_receiver_type_->IsTemplateFor(object->map())) return depth; |
| 2007 // no expected type, load from receiver. | 2005 object = Handle<JSObject>(JSObject::cast(object->GetPrototype())); |
| 2008 return map_to_holder; | 2006 if (!object->map()->is_hidden_prototype()) return kInvalidProtoDepth; |
| 2007 ++depth; |
| 2009 } | 2008 } |
| 2010 // walk down the prototype chain to the object | 2009 if (expected_receiver_type_->IsTemplateFor(holder->map())) return depth; |
| 2011 while (!receiver.is_identical_to(object)) { | 2010 return kInvalidProtoDepth; |
| 2012 *holder_lookup = kHolderIsPrototypeOfMap; | |
| 2013 map_to_holder = Handle<Map>(receiver->map()); | |
| 2014 receiver = Handle<JSObject>(JSObject::cast(map_to_holder->prototype())); | |
| 2015 ASSERT(!expected_receiver_type_->IsTemplateFor(*map_to_holder)); | |
| 2016 } | |
| 2017 // start looking for the holder | |
| 2018 while (!object.is_identical_to(holder)) { | |
| 2019 Handle<Map> object_map(object->map()); | |
| 2020 if (expected_receiver_type_->IsTemplateFor(*object_map)) { | |
| 2021 return map_to_holder; | |
| 2022 } | |
| 2023 if (!object_map->is_hidden_prototype()) { | |
| 2024 *holder_lookup = kHolderNotFound; | |
| 2025 return Handle<Map>::null(); | |
| 2026 } | |
| 2027 *holder_lookup = kHolderIsPrototypeOfMap; | |
| 2028 map_to_holder = object_map; | |
| 2029 object = Handle<JSObject>(JSObject::cast(object_map->prototype())); | |
| 2030 } | |
| 2031 if (expected_receiver_type_->IsTemplateFor(holder->map())) { | |
| 2032 return map_to_holder; | |
| 2033 } | |
| 2034 *holder_lookup = kHolderNotFound; | |
| 2035 return Handle<Map>::null(); | |
| 2036 } | 2011 } |
| 2037 | 2012 |
| 2038 | 2013 |
| 2039 void CallOptimization::Initialize(Handle<JSFunction> function) { | 2014 void CallOptimization::Initialize(Handle<JSFunction> function) { |
| 2040 constant_function_ = Handle<JSFunction>::null(); | 2015 constant_function_ = Handle<JSFunction>::null(); |
| 2041 is_simple_api_call_ = false; | 2016 is_simple_api_call_ = false; |
| 2042 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); | 2017 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); |
| 2043 api_call_info_ = Handle<CallHandlerInfo>::null(); | 2018 api_call_info_ = Handle<CallHandlerInfo>::null(); |
| 2044 | 2019 |
| 2045 if (function.is_null() || !function->is_compiled()) return; | 2020 if (function.is_null() || !function->is_compiled()) return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2069 Handle<FunctionTemplateInfo>( | 2044 Handle<FunctionTemplateInfo>( |
| 2070 FunctionTemplateInfo::cast(signature->receiver())); | 2045 FunctionTemplateInfo::cast(signature->receiver())); |
| 2071 } | 2046 } |
| 2072 } | 2047 } |
| 2073 | 2048 |
| 2074 is_simple_api_call_ = true; | 2049 is_simple_api_call_ = true; |
| 2075 } | 2050 } |
| 2076 | 2051 |
| 2077 | 2052 |
| 2078 } } // namespace v8::internal | 2053 } } // namespace v8::internal |
| OLD | NEW |