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 | 8 |
9 namespace v8 { | 9 namespace v8 { |
10 namespace internal { | 10 namespace internal { |
(...skipping 1474 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1485 Node* capacity = | 1485 Node* capacity = |
1486 TaggedToParameter(LoadFixedArrayBaseLength(var_elements.value()), mode); | 1486 TaggedToParameter(LoadFixedArrayBaseLength(var_elements.value()), mode); |
1487 | 1487 |
1488 // Resize the capacity of the fixed array if it doesn't fit. | 1488 // Resize the capacity of the fixed array if it doesn't fit. |
1489 Label fits(this, &var_elements); | 1489 Label fits(this, &var_elements); |
1490 Node* first = arg_index.value(); | 1490 Node* first = arg_index.value(); |
1491 Node* growth = IntPtrSub(args.GetLength(), first); | 1491 Node* growth = IntPtrSub(args.GetLength(), first); |
1492 Node* new_length = | 1492 Node* new_length = |
1493 IntPtrOrSmiAdd(WordToParameter(growth, mode), var_length.value(), mode); | 1493 IntPtrOrSmiAdd(WordToParameter(growth, mode), var_length.value(), mode); |
1494 GotoUnless(IntPtrOrSmiGreaterThan(new_length, capacity, mode), &fits); | 1494 GotoUnless(IntPtrOrSmiGreaterThan(new_length, capacity, mode), &fits); |
1495 Node* new_capacity = CalculateNewElementsCapacity( | 1495 Node* new_capacity = CalculateNewElementsCapacity(new_length, mode); |
1496 IntPtrOrSmiAdd(new_length, IntPtrOrSmiConstant(1, mode), mode), mode); | |
1497 var_elements.Bind(GrowElementsCapacity(array, var_elements.value(), kind, | 1496 var_elements.Bind(GrowElementsCapacity(array, var_elements.value(), kind, |
1498 kind, capacity, new_capacity, mode, | 1497 kind, capacity, new_capacity, mode, |
1499 &pre_bailout)); | 1498 &pre_bailout)); |
1500 Goto(&fits); | 1499 Goto(&fits); |
1501 Bind(&fits); | 1500 Bind(&fits); |
1502 Node* elements = var_elements.value(); | 1501 Node* elements = var_elements.value(); |
1503 | 1502 |
1504 // Push each argument onto the end of the array now that there is enough | 1503 // Push each argument onto the end of the array now that there is enough |
1505 // capacity. | 1504 // capacity. |
1506 CodeStubAssembler::VariableList push_vars({&var_length}, zone()); | 1505 CodeStubAssembler::VariableList push_vars({&var_length}, zone()); |
(...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2339 } else { | 2338 } else { |
2340 value = LoadHeapNumberValue(value); | 2339 value = LoadHeapNumberValue(value); |
2341 } | 2340 } |
2342 } | 2341 } |
2343 return value; | 2342 return value; |
2344 } | 2343 } |
2345 } | 2344 } |
2346 | 2345 |
2347 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, | 2346 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, |
2348 ParameterMode mode) { | 2347 ParameterMode mode) { |
2349 if (mode == SMI_PARAMETERS) { | 2348 Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); |
2350 old_capacity = BitcastTaggedToWord(old_capacity); | 2349 Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); |
2351 } | 2350 Node* padding = IntPtrOrSmiConstant(16, mode); |
2352 Node* half_old_capacity = WordShr(old_capacity, IntPtrConstant(1)); | 2351 return IntPtrOrSmiAdd(new_capacity, padding, mode); |
2353 Node* new_capacity = IntPtrAdd(half_old_capacity, old_capacity); | |
2354 Node* unconditioned_result = IntPtrAdd(new_capacity, IntPtrConstant(16)); | |
2355 if (mode == SMI_PARAMETERS) { | |
2356 return SmiAnd(BitcastWordToTaggedSigned(unconditioned_result), | |
2357 SmiConstant(-1)); | |
2358 } else { | |
2359 return unconditioned_result; | |
2360 } | |
2361 } | 2352 } |
2362 | 2353 |
2363 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, | 2354 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
2364 ElementsKind kind, Node* key, | 2355 ElementsKind kind, Node* key, |
2365 Label* bailout) { | 2356 Label* bailout) { |
2366 Node* capacity = LoadFixedArrayBaseLength(elements); | 2357 Node* capacity = LoadFixedArrayBaseLength(elements); |
2367 | 2358 |
2368 ParameterMode mode = OptimalParameterMode(); | 2359 ParameterMode mode = OptimalParameterMode(); |
2369 capacity = TaggedToParameter(capacity, mode); | 2360 capacity = TaggedToParameter(capacity, mode); |
2370 key = TaggedToParameter(key, mode); | 2361 key = TaggedToParameter(key, mode); |
(...skipping 5973 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8344 StoreObjectFieldNoWriteBarrier(result, | 8335 StoreObjectFieldNoWriteBarrier(result, |
8345 PromiseReactionJobInfo::kDebugNameOffset, | 8336 PromiseReactionJobInfo::kDebugNameOffset, |
8346 SmiConstant(kDebugNotActive)); | 8337 SmiConstant(kDebugNotActive)); |
8347 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, | 8338 StoreObjectFieldNoWriteBarrier(result, PromiseReactionJobInfo::kContextOffset, |
8348 context); | 8339 context); |
8349 return result; | 8340 return result; |
8350 } | 8341 } |
8351 | 8342 |
8352 } // namespace internal | 8343 } // namespace internal |
8353 } // namespace v8 | 8344 } // namespace v8 |
OLD | NEW |