| 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 1941 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1952 Initialize(Handle<JSFunction>::null()); | 1952 Initialize(Handle<JSFunction>::null()); |
| 1953 } | 1953 } |
| 1954 } | 1954 } |
| 1955 | 1955 |
| 1956 | 1956 |
| 1957 CallOptimization::CallOptimization(Handle<JSFunction> function) { | 1957 CallOptimization::CallOptimization(Handle<JSFunction> function) { |
| 1958 Initialize(function); | 1958 Initialize(function); |
| 1959 } | 1959 } |
| 1960 | 1960 |
| 1961 | 1961 |
| 1962 int CallOptimization::GetPrototypeDepthOfExpectedType( | 1962 Handle<JSObject> CallOptimization::GetPrototypeOfExpectedType( |
| 1963 Handle<JSObject> object, | 1963 Handle<JSObject> object, |
| 1964 Handle<JSObject> holder) const { | 1964 Handle<JSObject> holder) const { |
| 1965 ASSERT(is_simple_api_call()); | 1965 ASSERT(is_simple_api_call()); |
| 1966 if (expected_receiver_type_.is_null()) return 0; | 1966 if (expected_receiver_type_.is_null()) return object; |
| 1967 int depth = 0; | |
| 1968 while (!object.is_identical_to(holder)) { | 1967 while (!object.is_identical_to(holder)) { |
| 1969 if (expected_receiver_type_->IsTemplateFor(object->map())) return depth; | 1968 if (expected_receiver_type_->IsTemplateFor(object->map())) return object; |
| 1970 object = Handle<JSObject>(JSObject::cast(object->GetPrototype())); | 1969 object = Handle<JSObject>(JSObject::cast(object->GetPrototype())); |
| 1971 if (!object->map()->is_hidden_prototype()) return kInvalidProtoDepth; | 1970 if (!object->map()->is_hidden_prototype()) return Handle<JSObject>::null(); |
| 1972 ++depth; | |
| 1973 } | 1971 } |
| 1974 if (expected_receiver_type_->IsTemplateFor(holder->map())) return depth; | 1972 if (expected_receiver_type_->IsTemplateFor(holder->map())) return object; |
| 1975 return kInvalidProtoDepth; | 1973 return Handle<JSObject>::null(); |
| 1976 } | 1974 } |
| 1977 | 1975 |
| 1978 | 1976 |
| 1979 void CallOptimization::Initialize(Handle<JSFunction> function) { | 1977 void CallOptimization::Initialize(Handle<JSFunction> function) { |
| 1980 constant_function_ = Handle<JSFunction>::null(); | 1978 constant_function_ = Handle<JSFunction>::null(); |
| 1981 is_simple_api_call_ = false; | 1979 is_simple_api_call_ = false; |
| 1982 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); | 1980 expected_receiver_type_ = Handle<FunctionTemplateInfo>::null(); |
| 1983 api_call_info_ = Handle<CallHandlerInfo>::null(); | 1981 api_call_info_ = Handle<CallHandlerInfo>::null(); |
| 1984 | 1982 |
| 1985 if (function.is_null() || !function->is_compiled()) return; | 1983 if (function.is_null() || !function->is_compiled()) return; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2009 Handle<FunctionTemplateInfo>( | 2007 Handle<FunctionTemplateInfo>( |
| 2010 FunctionTemplateInfo::cast(signature->receiver())); | 2008 FunctionTemplateInfo::cast(signature->receiver())); |
| 2011 } | 2009 } |
| 2012 } | 2010 } |
| 2013 | 2011 |
| 2014 is_simple_api_call_ = true; | 2012 is_simple_api_call_ = true; |
| 2015 } | 2013 } |
| 2016 | 2014 |
| 2017 | 2015 |
| 2018 } } // namespace v8::internal | 2016 } } // namespace v8::internal |
| OLD | NEW |