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 | 4 |
5 #include "src/builtins/builtins.h" | 5 #include "src/builtins/builtins.h" |
6 #include "src/builtins/builtins-utils.h" | 6 #include "src/builtins/builtins-utils.h" |
7 | 7 |
8 #include "src/code-factory.h" | 8 #include "src/code-factory.h" |
9 #include "src/code-stub-assembler.h" | 9 #include "src/code-stub-assembler.h" |
10 #include "src/contexts.h" | 10 #include "src/contexts.h" |
(...skipping 2030 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2041 CSA_ASSERT(this, | 2041 CSA_ASSERT(this, |
2042 TaggedIsSmi(LoadObjectField(array, JSArray::kLengthOffset))); | 2042 TaggedIsSmi(LoadObjectField(array, JSArray::kLengthOffset))); |
2043 Node* len = LoadAndUntagObjectField(array, JSArray::kLengthOffset); | 2043 Node* len = LoadAndUntagObjectField(array, JSArray::kLengthOffset); |
2044 | 2044 |
2045 len_var.Bind(len); | 2045 len_var.Bind(len); |
2046 Branch(WordEqual(len_var.value(), intptr_zero), &return_not_found, &init_k); | 2046 Branch(WordEqual(len_var.value(), intptr_zero), &return_not_found, &init_k); |
2047 } | 2047 } |
2048 | 2048 |
2049 Bind(&init_k); | 2049 Bind(&init_k); |
2050 { | 2050 { |
2051 Label done(this), init_k_smi(this), init_k_heap_num(this), | 2051 Label done(this), init_k_smi(this), init_k_other(this), init_k_zero(this), |
2052 init_k_zero(this), init_k_n(this); | 2052 init_k_n(this); |
2053 Node* tagged_n = ToInteger(context, start_from); | |
2054 | 2053 |
2055 Branch(TaggedIsSmi(tagged_n), &init_k_smi, &init_k_heap_num); | 2054 Branch(TaggedIsSmi(start_from), &init_k_smi, &init_k_other); |
Jarin
2017/03/16 05:55:02
Please explain in a comment what you are doing her
Benedikt Meurer
2017/03/16 05:55:31
Done.
| |
2056 | 2055 |
2057 Bind(&init_k_smi); | 2056 Bind(&init_k_smi); |
2058 { | 2057 { |
2059 start_from_var.Bind(SmiUntag(tagged_n)); | 2058 start_from_var.Bind(SmiUntag(start_from)); |
2060 Goto(&init_k_n); | 2059 Goto(&init_k_n); |
2061 } | 2060 } |
2062 | 2061 |
2063 Bind(&init_k_heap_num); | 2062 Bind(&init_k_other); |
2064 { | 2063 { |
2065 Label do_return_not_found(this); | 2064 // For now only deal with undefined here; we must be really careful with |
2066 // This round is lossless for all valid lengths. | 2065 // side-effects from this ToInteger conversion, as the side-effects might |
2067 Node* fp_len = RoundIntPtrToFloat64(len_var.value()); | 2066 // render our assumptions about the receiver being a fast JSArray and the |
2068 Node* fp_n = LoadHeapNumberValue(tagged_n); | 2067 // length invalid. |
2069 GotoIf(Float64GreaterThanOrEqual(fp_n, fp_len), &do_return_not_found); | 2068 GotoIfNot(IsUndefined(start_from), &call_runtime); |
2070 start_from_var.Bind(ChangeInt32ToIntPtr(TruncateFloat64ToWord32(fp_n))); | 2069 start_from_var.Bind(intptr_zero); |
2071 Goto(&init_k_n); | 2070 Goto(&init_k_n); |
2072 | |
2073 Bind(&do_return_not_found); | |
2074 { | |
2075 index_var.Bind(intptr_zero); | |
2076 Goto(&return_not_found); | |
2077 } | |
2078 } | 2071 } |
2079 | 2072 |
2080 Bind(&init_k_n); | 2073 Bind(&init_k_n); |
2081 { | 2074 { |
2082 Label if_positive(this), if_negative(this), done(this); | 2075 Label if_positive(this), if_negative(this), done(this); |
2083 Branch(IntPtrLessThan(start_from_var.value(), intptr_zero), &if_negative, | 2076 Branch(IntPtrLessThan(start_from_var.value(), intptr_zero), &if_negative, |
2084 &if_positive); | 2077 &if_positive); |
2085 | 2078 |
2086 Bind(&if_positive); | 2079 Bind(&if_positive); |
2087 { | 2080 { |
(...skipping 660 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2748 { | 2741 { |
2749 Node* message = SmiConstant(MessageTemplate::kDetachedOperation); | 2742 Node* message = SmiConstant(MessageTemplate::kDetachedOperation); |
2750 CallRuntime(Runtime::kThrowTypeError, context, message, | 2743 CallRuntime(Runtime::kThrowTypeError, context, message, |
2751 HeapConstant(operation)); | 2744 HeapConstant(operation)); |
2752 Unreachable(); | 2745 Unreachable(); |
2753 } | 2746 } |
2754 } | 2747 } |
2755 | 2748 |
2756 } // namespace internal | 2749 } // namespace internal |
2757 } // namespace v8 | 2750 } // namespace v8 |
OLD | NEW |