OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/ic/call-optimization.h" | 7 #include "src/ic/call-optimization.h" |
8 | 8 |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 } | 42 } |
43 } | 43 } |
44 *holder_lookup = kHolderNotFound; | 44 *holder_lookup = kHolderNotFound; |
45 return Handle<JSObject>::null(); | 45 return Handle<JSObject>::null(); |
46 } | 46 } |
47 | 47 |
48 | 48 |
49 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver, | 49 bool CallOptimization::IsCompatibleReceiver(Handle<Object> receiver, |
50 Handle<JSObject> holder) const { | 50 Handle<JSObject> holder) const { |
51 DCHECK(is_simple_api_call()); | 51 DCHECK(is_simple_api_call()); |
52 if (!receiver->IsJSObject()) return false; | 52 if (!receiver->IsHeapObject()) return false; |
53 Handle<Map> map(JSObject::cast(*receiver)->map()); | 53 Handle<Map> map(HeapObject::cast(*receiver)->map()); |
| 54 return IsCompatibleReceiverType(map, holder); |
| 55 } |
| 56 |
| 57 |
| 58 bool CallOptimization::IsCompatibleReceiverType(Handle<Map> map, |
| 59 Handle<JSObject> holder) const { |
54 HolderLookup holder_lookup; | 60 HolderLookup holder_lookup; |
55 Handle<JSObject> api_holder = LookupHolderOfExpectedType(map, &holder_lookup); | 61 Handle<JSObject> api_holder = LookupHolderOfExpectedType(map, &holder_lookup); |
56 switch (holder_lookup) { | 62 switch (holder_lookup) { |
57 case kHolderNotFound: | 63 case kHolderNotFound: |
58 return false; | 64 return false; |
59 case kHolderIsReceiver: | 65 case kHolderIsReceiver: |
60 return true; | 66 return true; |
61 case kHolderFound: | 67 case kHolderFound: |
62 if (api_holder.is_identical_to(holder)) return true; | 68 if (api_holder.is_identical_to(holder)) return true; |
63 // Check if holder is in prototype chain of api_holder. | 69 // Check if holder is in prototype chain of api_holder. |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 | 106 |
101 if (!info->signature()->IsUndefined()) { | 107 if (!info->signature()->IsUndefined()) { |
102 expected_receiver_type_ = | 108 expected_receiver_type_ = |
103 handle(FunctionTemplateInfo::cast(info->signature())); | 109 handle(FunctionTemplateInfo::cast(info->signature())); |
104 } | 110 } |
105 | 111 |
106 is_simple_api_call_ = true; | 112 is_simple_api_call_ = true; |
107 } | 113 } |
108 } | 114 } |
109 } // namespace v8::internal | 115 } // namespace v8::internal |
OLD | NEW |