OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/bailout-reason.h" | 7 #include "src/bailout-reason.h" |
8 #include "src/code-stubs.h" | 8 #include "src/code-stubs.h" |
9 #include "src/field-index.h" | 9 #include "src/field-index.h" |
10 #include "src/hydrogen.h" | 10 #include "src/hydrogen.h" |
(...skipping 2025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 IfBuilder if_receiver_heap_object(this); | 2036 IfBuilder if_receiver_heap_object(this); |
2037 if_receiver_heap_object.IfNot<HIsSmiAndBranch>(receiver); | 2037 if_receiver_heap_object.IfNot<HIsSmiAndBranch>(receiver); |
2038 if_receiver_heap_object.Then(); | 2038 if_receiver_heap_object.Then(); |
2039 { | 2039 { |
2040 HConstant* constant_two = Add<HConstant>(2); | 2040 HConstant* constant_two = Add<HConstant>(2); |
2041 HConstant* constant_three = Add<HConstant>(3); | 2041 HConstant* constant_three = Add<HConstant>(3); |
2042 | 2042 |
2043 HValue* receiver_map = AddLoadMap(receiver, nullptr); | 2043 HValue* receiver_map = AddLoadMap(receiver, nullptr); |
2044 HValue* start = | 2044 HValue* start = |
2045 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); | 2045 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); |
2046 HValue* array_map = Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, | 2046 HValue* weak_cell = Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, |
2047 ALLOW_RETURN_HOLE); | 2047 ALLOW_RETURN_HOLE); |
| 2048 // Load the weak cell value. It may be Smi(0), or a map. Compare nonetheless |
| 2049 // against the receiver_map. |
| 2050 HValue* array_map = Add<HLoadNamedField>(weak_cell, nullptr, |
| 2051 HObjectAccess::ForWeakCellValue()); |
| 2052 |
2048 IfBuilder if_correct_map(this); | 2053 IfBuilder if_correct_map(this); |
2049 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); | 2054 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); |
2050 if_correct_map.Then(); | 2055 if_correct_map.Then(); |
2051 { TailCallHandler(receiver, name, array, start, slot, vector); } | 2056 { TailCallHandler(receiver, name, array, start, slot, vector); } |
2052 if_correct_map.Else(); | 2057 if_correct_map.Else(); |
2053 { | 2058 { |
2054 // If our array has more elements, the ic is polymorphic. Look for the | 2059 // If our array has more elements, the ic is polymorphic. Look for the |
2055 // receiver map in the rest of the array. | 2060 // receiver map in the rest of the array. |
2056 HValue* length = AddLoadFixedArrayLength(array, nullptr); | 2061 HValue* length = AddLoadFixedArrayLength(array, nullptr); |
2057 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, | 2062 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, |
2058 constant_two); | 2063 constant_two); |
2059 start = keyed_load ? constant_three : constant_two; | 2064 start = keyed_load ? constant_three : constant_two; |
2060 HValue* key = builder.BeginBody(start, length, Token::LT); | 2065 HValue* key = builder.BeginBody(start, length, Token::LT); |
2061 { | 2066 { |
2062 HValue* array_map = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, | 2067 HValue* weak_cell = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, |
2063 ALLOW_RETURN_HOLE); | 2068 ALLOW_RETURN_HOLE); |
| 2069 HValue* array_map = Add<HLoadNamedField>( |
| 2070 weak_cell, nullptr, HObjectAccess::ForWeakCellValue()); |
2064 IfBuilder if_correct_poly_map(this); | 2071 IfBuilder if_correct_poly_map(this); |
2065 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, | 2072 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, |
2066 array_map); | 2073 array_map); |
2067 if_correct_poly_map.Then(); | 2074 if_correct_poly_map.Then(); |
2068 { TailCallHandler(receiver, name, array, key, slot, vector); } | 2075 { TailCallHandler(receiver, name, array, key, slot, vector); } |
2069 } | 2076 } |
2070 builder.EndBody(); | 2077 builder.EndBody(); |
2071 } | 2078 } |
2072 if_correct_map.End(); | 2079 if_correct_map.End(); |
2073 } | 2080 } |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2200 // megamorphic case is handled as part of the default stub. | 2207 // megamorphic case is handled as part of the default stub. |
2201 DCHECK(!FLAG_vector_ics); | 2208 DCHECK(!FLAG_vector_ics); |
2202 | 2209 |
2203 // Probe the stub cache. | 2210 // Probe the stub cache. |
2204 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2211 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
2205 | 2212 |
2206 // We never continue. | 2213 // We never continue. |
2207 return graph()->GetConstant0(); | 2214 return graph()->GetConstant0(); |
2208 } | 2215 } |
2209 } } // namespace v8::internal | 2216 } } // namespace v8::internal |
OLD | NEW |