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 1920 matching lines...) Loading... | |
1931 } | 1931 } |
1932 } | 1932 } |
1933 | 1933 |
1934 | 1934 |
1935 CallOptimization::CallOptimization(Handle<JSFunction> function) { | 1935 CallOptimization::CallOptimization(Handle<JSFunction> function) { |
1936 Initialize(function); | 1936 Initialize(function); |
1937 } | 1937 } |
1938 | 1938 |
1939 | 1939 |
1940 Handle<Map> CallOptimization::LookupHolderOfExpectedType( | 1940 Handle<Map> CallOptimization::LookupHolderOfExpectedType( |
1941 Handle<JSObject> receiver, | 1941 Handle<Map> receiver_map, |
1942 Handle<JSObject> object, | 1942 Handle<Map> object_map, |
1943 Handle<JSObject> holder, | 1943 Handle<Map> holder_map, |
1944 HolderLookup* holder_lookup) const { | 1944 HolderLookup* holder_lookup) const { |
1945 ASSERT(is_simple_api_call()); | 1945 ASSERT(is_simple_api_call()); |
1946 ASSERT_EQ(kHolderNotFound, *holder_lookup); | 1946 ASSERT_EQ(kHolderNotFound, *holder_lookup); |
1947 *holder_lookup = kHolderIsReceiver; | 1947 *holder_lookup = kHolderIsReceiver; |
1948 Handle<Map> map_to_holder; | 1948 Handle<Map> map_to_holder; |
1949 if (expected_receiver_type_.is_null()) { | 1949 if (expected_receiver_type_.is_null()) { |
1950 // no expected type, load from receiver. | 1950 // no expected type, load from receiver. |
1951 return map_to_holder; | 1951 return map_to_holder; |
1952 } | 1952 } |
1953 // walk down the prototype chain to the object | 1953 // walk down the prototype chain to the object |
1954 while (!receiver.is_identical_to(object)) { | 1954 while (!receiver_map.is_identical_to(object_map)) { |
1955 *holder_lookup = kHolderIsPrototypeOfMap; | 1955 *holder_lookup = kHolderIsPrototypeOfMap; |
1956 map_to_holder = Handle<Map>(receiver->map()); | 1956 map_to_holder = receiver_map; |
1957 receiver = Handle<JSObject>(JSObject::cast(map_to_holder->prototype())); | 1957 receiver_map = |
1958 Handle<Map>(JSObject::cast(map_to_holder->prototype())->map()); | |
1958 } | 1959 } |
1959 // start looking for the holder | 1960 // start looking for the holder |
1960 while (!object.is_identical_to(holder)) { | 1961 while (!object_map.is_identical_to(holder_map)) { |
Toon Verwaest
2014/01/29 13:22:39
Please extract this implicit magic to an explicit
| |
1961 Handle<Map> object_map(object->map()); | |
1962 if (expected_receiver_type_->IsTemplateFor(*object_map)) { | 1962 if (expected_receiver_type_->IsTemplateFor(*object_map)) { |
1963 return map_to_holder; | 1963 return map_to_holder; |
1964 } | 1964 } |
1965 *holder_lookup = kHolderIsPrototypeOfMap; | |
1966 map_to_holder = object_map; | |
1967 object_map = Handle<Map>(JSObject::cast(object_map->prototype())->map()); | |
1965 if (!object_map->is_hidden_prototype()) { | 1968 if (!object_map->is_hidden_prototype()) { |
1966 *holder_lookup = kHolderNotFound; | 1969 *holder_lookup = kHolderNotFound; |
1967 return Handle<Map>::null(); | 1970 return Handle<Map>::null(); |
1968 } | 1971 } |
1969 *holder_lookup = kHolderIsPrototypeOfMap; | |
1970 map_to_holder = object_map; | |
1971 object = Handle<JSObject>(JSObject::cast(object_map->prototype())); | |
1972 } | 1972 } |
1973 if (expected_receiver_type_->IsTemplateFor(holder->map())) { | 1973 if (expected_receiver_type_->IsTemplateFor(*object_map)) { |
1974 return map_to_holder; | 1974 return map_to_holder; |
1975 } | 1975 } |
1976 *holder_lookup = kHolderNotFound; | 1976 *holder_lookup = kHolderNotFound; |
1977 return Handle<Map>::null(); | 1977 return Handle<Map>::null(); |
1978 } | 1978 } |
1979 | 1979 |
1980 | 1980 |
1981 void CallOptimization::Initialize(Handle<JSFunction> function) { | 1981 void CallOptimization::Initialize(Handle<JSFunction> function) { |
1982 constant_function_ = Handle<JSFunction>::null(); | 1982 constant_function_ = Handle<JSFunction>::null(); |
1983 is_simple_api_call_ = false; | 1983 is_simple_api_call_ = false; |
(...skipping 27 matching lines...) Loading... | |
2011 Handle<FunctionTemplateInfo>( | 2011 Handle<FunctionTemplateInfo>( |
2012 FunctionTemplateInfo::cast(signature->receiver())); | 2012 FunctionTemplateInfo::cast(signature->receiver())); |
2013 } | 2013 } |
2014 } | 2014 } |
2015 | 2015 |
2016 is_simple_api_call_ = true; | 2016 is_simple_api_call_ = true; |
2017 } | 2017 } |
2018 | 2018 |
2019 | 2019 |
2020 } } // namespace v8::internal | 2020 } } // namespace v8::internal |
OLD | NEW |