Chromium Code Reviews| 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 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2026 receiver, name, slot, vector, | 2026 receiver, name, slot, vector, |
| 2027 HTailCallThroughMegamorphicCache::ComputeFlags(keyed_load, true)); | 2027 HTailCallThroughMegamorphicCache::ComputeFlags(keyed_load, true)); |
| 2028 // We never return here, it is a tail call. | 2028 // We never return here, it is a tail call. |
| 2029 } | 2029 } |
| 2030 | 2030 |
| 2031 | 2031 |
| 2032 void CodeStubGraphBuilderBase::HandleArrayCases(HValue* array, HValue* receiver, | 2032 void CodeStubGraphBuilderBase::HandleArrayCases(HValue* array, HValue* receiver, |
| 2033 HValue* name, HValue* slot, | 2033 HValue* name, HValue* slot, |
| 2034 HValue* vector, | 2034 HValue* vector, |
| 2035 bool keyed_load) { | 2035 bool keyed_load) { |
| 2036 HConstant* constant_two = Add<HConstant>(2); | |
| 2037 HConstant* constant_three = Add<HConstant>(3); | |
| 2038 | |
| 2036 IfBuilder if_receiver_heap_object(this); | 2039 IfBuilder if_receiver_heap_object(this); |
| 2037 if_receiver_heap_object.IfNot<HIsSmiAndBranch>(receiver); | 2040 if_receiver_heap_object.IfNot<HIsSmiAndBranch>(receiver); |
| 2038 if_receiver_heap_object.Then(); | 2041 if_receiver_heap_object.Then(); |
| 2042 Push(AddLoadMap(receiver, nullptr)); | |
|
Yang
2015/01/15 11:33:45
Don't we usually just use NULL (instead of nullptr
mvstanton
2015/01/15 12:25:39
Looks like someone did a refactoring CL a while ba
| |
| 2043 if_receiver_heap_object.Else(); | |
| 2044 HConstant* heap_number_map = | |
| 2045 Add<HConstant>(isolate()->factory()->heap_number_map()); | |
| 2046 Push(heap_number_map); | |
| 2047 if_receiver_heap_object.End(); | |
| 2048 HValue* receiver_map = Pop(); | |
| 2049 | |
| 2050 HValue* start = | |
| 2051 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); | |
| 2052 HValue* weak_cell = | |
| 2053 Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, ALLOW_RETURN_HOLE); | |
| 2054 // Load the weak cell value. It may be Smi(0), or a map. Compare nonetheless | |
| 2055 // against the receiver_map. | |
| 2056 HValue* array_map = Add<HLoadNamedField>(weak_cell, nullptr, | |
| 2057 HObjectAccess::ForWeakCellValue()); | |
| 2058 | |
| 2059 IfBuilder if_correct_map(this); | |
| 2060 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); | |
| 2061 if_correct_map.Then(); | |
| 2062 { TailCallHandler(receiver, name, array, start, slot, vector); } | |
| 2063 if_correct_map.Else(); | |
| 2039 { | 2064 { |
| 2040 HConstant* constant_two = Add<HConstant>(2); | 2065 // If our array has more elements, the ic is polymorphic. Look for the |
| 2041 HConstant* constant_three = Add<HConstant>(3); | 2066 // receiver map in the rest of the array. |
| 2042 | 2067 HValue* length = AddLoadFixedArrayLength(array, nullptr); |
| 2043 HValue* receiver_map = AddLoadMap(receiver, nullptr); | 2068 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, |
| 2044 HValue* start = | 2069 constant_two); |
| 2045 keyed_load ? graph()->GetConstant1() : graph()->GetConstant0(); | 2070 start = keyed_load ? constant_three : constant_two; |
| 2046 HValue* weak_cell = Add<HLoadKeyed>(array, start, nullptr, FAST_ELEMENTS, | 2071 HValue* key = builder.BeginBody(start, length, Token::LT); |
| 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 | |
| 2053 IfBuilder if_correct_map(this); | |
| 2054 if_correct_map.If<HCompareObjectEqAndBranch>(receiver_map, array_map); | |
| 2055 if_correct_map.Then(); | |
| 2056 { TailCallHandler(receiver, name, array, start, slot, vector); } | |
| 2057 if_correct_map.Else(); | |
| 2058 { | 2072 { |
| 2059 // If our array has more elements, the ic is polymorphic. Look for the | 2073 HValue* weak_cell = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, |
| 2060 // receiver map in the rest of the array. | 2074 ALLOW_RETURN_HOLE); |
| 2061 HValue* length = AddLoadFixedArrayLength(array, nullptr); | 2075 HValue* array_map = Add<HLoadNamedField>( |
| 2062 LoopBuilder builder(this, context(), LoopBuilder::kPostIncrement, | 2076 weak_cell, nullptr, HObjectAccess::ForWeakCellValue()); |
| 2063 constant_two); | 2077 IfBuilder if_correct_poly_map(this); |
| 2064 start = keyed_load ? constant_three : constant_two; | 2078 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, |
| 2065 HValue* key = builder.BeginBody(start, length, Token::LT); | 2079 array_map); |
| 2066 { | 2080 if_correct_poly_map.Then(); |
| 2067 HValue* weak_cell = Add<HLoadKeyed>(array, key, nullptr, FAST_ELEMENTS, | 2081 { TailCallHandler(receiver, name, array, key, slot, vector); } |
| 2068 ALLOW_RETURN_HOLE); | |
| 2069 HValue* array_map = Add<HLoadNamedField>( | |
| 2070 weak_cell, nullptr, HObjectAccess::ForWeakCellValue()); | |
| 2071 IfBuilder if_correct_poly_map(this); | |
| 2072 if_correct_poly_map.If<HCompareObjectEqAndBranch>(receiver_map, | |
| 2073 array_map); | |
| 2074 if_correct_poly_map.Then(); | |
| 2075 { TailCallHandler(receiver, name, array, key, slot, vector); } | |
| 2076 } | |
| 2077 builder.EndBody(); | |
| 2078 } | 2082 } |
| 2079 if_correct_map.End(); | 2083 builder.EndBody(); |
| 2080 } | 2084 } |
| 2085 if_correct_map.End(); | |
| 2081 } | 2086 } |
| 2082 | 2087 |
| 2083 | 2088 |
| 2084 template <> | 2089 template <> |
| 2085 HValue* CodeStubGraphBuilder<VectorLoadStub>::BuildCodeStub() { | 2090 HValue* CodeStubGraphBuilder<VectorLoadStub>::BuildCodeStub() { |
| 2086 HValue* receiver = GetParameter(VectorLoadICDescriptor::kReceiverIndex); | 2091 HValue* receiver = GetParameter(VectorLoadICDescriptor::kReceiverIndex); |
| 2087 HValue* name = GetParameter(VectorLoadICDescriptor::kNameIndex); | 2092 HValue* name = GetParameter(VectorLoadICDescriptor::kNameIndex); |
| 2088 HValue* slot = GetParameter(VectorLoadICDescriptor::kSlotIndex); | 2093 HValue* slot = GetParameter(VectorLoadICDescriptor::kSlotIndex); |
| 2089 HValue* vector = GetParameter(VectorLoadICDescriptor::kVectorIndex); | 2094 HValue* vector = GetParameter(VectorLoadICDescriptor::kVectorIndex); |
| 2090 | 2095 |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2207 // megamorphic case is handled as part of the default stub. | 2212 // megamorphic case is handled as part of the default stub. |
| 2208 DCHECK(!FLAG_vector_ics); | 2213 DCHECK(!FLAG_vector_ics); |
| 2209 | 2214 |
| 2210 // Probe the stub cache. | 2215 // Probe the stub cache. |
| 2211 Add<HTailCallThroughMegamorphicCache>(receiver, name); | 2216 Add<HTailCallThroughMegamorphicCache>(receiver, name); |
| 2212 | 2217 |
| 2213 // We never continue. | 2218 // We never continue. |
| 2214 return graph()->GetConstant0(); | 2219 return graph()->GetConstant0(); |
| 2215 } | 2220 } |
| 2216 } } // namespace v8::internal | 2221 } } // namespace v8::internal |
| OLD | NEW |