OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 #include "src/ic/handler-configuration.h" | 8 #include "src/ic/handler-configuration.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 2206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2217 // If size of the allocation for the new capacity doesn't fit in a page | 2217 // If size of the allocation for the new capacity doesn't fit in a page |
2218 // that we can bump-pointer allocate from, fall back to the runtime. | 2218 // that we can bump-pointer allocate from, fall back to the runtime. |
2219 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); | 2219 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); |
2220 GotoIf(UintPtrGreaterThanOrEqual(new_capacity, | 2220 GotoIf(UintPtrGreaterThanOrEqual(new_capacity, |
2221 IntPtrOrSmiConstant(max_size, mode)), | 2221 IntPtrOrSmiConstant(max_size, mode)), |
2222 bailout); | 2222 bailout); |
2223 | 2223 |
2224 // Allocate the new backing store. | 2224 // Allocate the new backing store. |
2225 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode); | 2225 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode); |
2226 | 2226 |
2227 // Fill in the added capacity in the new store with holes. | |
2228 FillFixedArrayWithValue(to_kind, new_elements, capacity, new_capacity, | |
Jakob Kummerow
2016/11/04 18:58:26
CopyFixedArrayElements() does this too, no need to
Igor Sheludko
2016/11/07 14:43:39
Acknowledged.
| |
2229 Heap::kTheHoleValueRootIndex, mode); | |
2230 | |
2231 // Copy the elements from the old elements store to the new. | 2227 // Copy the elements from the old elements store to the new. |
2232 // The size-check above guarantees that the |new_elements| is allocated | 2228 // The size-check above guarantees that the |new_elements| is allocated |
2233 // in new space so we can skip the write barrier. | 2229 // in new space so we can skip the write barrier. |
2234 CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity, | 2230 CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity, |
2235 new_capacity, SKIP_WRITE_BARRIER, mode); | 2231 new_capacity, SKIP_WRITE_BARRIER, mode); |
2236 | 2232 |
2237 StoreObjectField(object, JSObject::kElementsOffset, new_elements); | 2233 StoreObjectField(object, JSObject::kElementsOffset, new_elements); |
2238 Comment("] GrowElementsCapacity"); | 2234 Comment("] GrowElementsCapacity"); |
2239 return new_elements; | 2235 return new_elements; |
2240 } | 2236 } |
(...skipping 3002 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5243 Bind(&done); | 5239 Bind(&done); |
5244 return var_intptr_key.value(); | 5240 return var_intptr_key.value(); |
5245 } | 5241 } |
5246 | 5242 |
5247 void CodeStubAssembler::EmitFastElementsBoundsCheck(Node* object, | 5243 void CodeStubAssembler::EmitFastElementsBoundsCheck(Node* object, |
5248 Node* elements, | 5244 Node* elements, |
5249 Node* intptr_index, | 5245 Node* intptr_index, |
5250 Node* is_jsarray_condition, | 5246 Node* is_jsarray_condition, |
5251 Label* miss) { | 5247 Label* miss) { |
5252 Variable var_length(this, MachineType::PointerRepresentation()); | 5248 Variable var_length(this, MachineType::PointerRepresentation()); |
5249 Comment("Fast elements bounds check"); | |
5253 Label if_array(this), length_loaded(this, &var_length); | 5250 Label if_array(this), length_loaded(this, &var_length); |
5254 GotoIf(is_jsarray_condition, &if_array); | 5251 GotoIf(is_jsarray_condition, &if_array); |
5255 { | 5252 { |
5256 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements))); | 5253 var_length.Bind(SmiUntag(LoadFixedArrayBaseLength(elements))); |
5257 Goto(&length_loaded); | 5254 Goto(&length_loaded); |
5258 } | 5255 } |
5259 Bind(&if_array); | 5256 Bind(&if_array); |
5260 { | 5257 { |
5261 var_length.Bind(SmiUntag(LoadJSArrayLength(object))); | 5258 var_length.Bind(SmiUntag(LoadJSArrayLength(object))); |
5262 Goto(&length_loaded); | 5259 Goto(&length_loaded); |
5263 } | 5260 } |
5264 Bind(&length_loaded); | 5261 Bind(&length_loaded); |
5265 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss); | 5262 GotoUnless(UintPtrLessThan(intptr_index, var_length.value()), miss); |
5266 } | 5263 } |
5267 | 5264 |
5268 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements, | 5265 void CodeStubAssembler::EmitElementLoad(Node* object, Node* elements, |
5269 Node* elements_kind, Node* intptr_index, | 5266 Node* elements_kind, Node* intptr_index, |
5270 Node* is_jsarray_condition, | 5267 Node* is_jsarray_condition, |
5271 Label* if_hole, Label* rebox_double, | 5268 Label* if_hole, Label* rebox_double, |
5272 Variable* var_double_value, | 5269 Variable* var_double_value, |
5273 Label* unimplemented_elements_kind, | 5270 Label* unimplemented_elements_kind, |
5274 Label* out_of_bounds, Label* miss) { | 5271 Label* out_of_bounds, Label* miss) { |
5275 Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this), | 5272 Label if_typed_array(this), if_fast_packed(this), if_fast_holey(this), |
5276 if_fast_double(this), if_fast_holey_double(this), if_nonfast(this), | 5273 if_fast_double(this), if_fast_holey_double(this), if_nonfast(this), |
5277 if_dictionary(this), unreachable(this); | 5274 if_dictionary(this); |
5278 GotoIf( | 5275 GotoIf( |
5279 IntPtrGreaterThan(elements_kind, IntPtrConstant(LAST_FAST_ELEMENTS_KIND)), | 5276 IntPtrGreaterThan(elements_kind, IntPtrConstant(LAST_FAST_ELEMENTS_KIND)), |
5280 &if_nonfast); | 5277 &if_nonfast); |
5281 | 5278 |
5282 EmitFastElementsBoundsCheck(object, elements, intptr_index, | 5279 EmitFastElementsBoundsCheck(object, elements, intptr_index, |
5283 is_jsarray_condition, out_of_bounds); | 5280 is_jsarray_condition, out_of_bounds); |
5284 int32_t kinds[] = {// Handled by if_fast_packed. | 5281 int32_t kinds[] = {// Handled by if_fast_packed. |
5285 FAST_SMI_ELEMENTS, FAST_ELEMENTS, | 5282 FAST_SMI_ELEMENTS, FAST_ELEMENTS, |
5286 // Handled by if_fast_holey. | 5283 // Handled by if_fast_holey. |
5287 FAST_HOLEY_SMI_ELEMENTS, FAST_HOLEY_ELEMENTS, | 5284 FAST_HOLEY_SMI_ELEMENTS, FAST_HOLEY_ELEMENTS, |
(...skipping 3550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8838 } | 8835 } |
8839 | 8836 |
8840 void CodeStubArguments::PopAndReturn(compiler::Node* value) { | 8837 void CodeStubArguments::PopAndReturn(compiler::Node* value) { |
8841 assembler_->PopAndReturn( | 8838 assembler_->PopAndReturn( |
8842 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)), | 8839 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)), |
8843 value); | 8840 value); |
8844 } | 8841 } |
8845 | 8842 |
8846 } // namespace internal | 8843 } // namespace internal |
8847 } // namespace v8 | 8844 } // namespace v8 |
OLD | NEW |