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/regexp/regexp-utils.h" | 9 #include "src/regexp/regexp-utils.h" |
10 | 10 |
(...skipping 1013 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1024 a.GotoUnless(a.SmiLessThanOrEqual(var_length.value(), zero), &out); | 1024 a.GotoUnless(a.SmiLessThanOrEqual(var_length.value(), zero), &out); |
1025 a.Return(a.EmptyStringConstant()); | 1025 a.Return(a.EmptyStringConstant()); |
1026 } | 1026 } |
1027 | 1027 |
1028 a.Bind(&if_isheapnumber); | 1028 a.Bind(&if_isheapnumber); |
1029 { | 1029 { |
1030 // If {length} is a heap number, it is definitely out of bounds. There are | 1030 // If {length} is a heap number, it is definitely out of bounds. There are |
1031 // two cases according to the spec: if it is negative, "" is returned; if | 1031 // two cases according to the spec: if it is negative, "" is returned; if |
1032 // it is positive, then length is set to {string_length} - {start}. | 1032 // it is positive, then length is set to {string_length} - {start}. |
1033 | 1033 |
1034 CSA_ASSERT(&a, a.WordEqual(a.LoadMap(var_length.value()), | 1034 CSA_ASSERT(&a, a.IsHeapNumberMap(a.LoadMap(var_length.value()))); |
1035 a.HeapNumberMapConstant())); | |
1036 | 1035 |
1037 Label if_isnegative(&a), if_ispositive(&a); | 1036 Label if_isnegative(&a), if_ispositive(&a); |
1038 Node* const float_zero = a.Float64Constant(0.); | 1037 Node* const float_zero = a.Float64Constant(0.); |
1039 Node* const length_float = a.LoadHeapNumberValue(var_length.value()); | 1038 Node* const length_float = a.LoadHeapNumberValue(var_length.value()); |
1040 a.Branch(a.Float64LessThan(length_float, float_zero), &if_isnegative, | 1039 a.Branch(a.Float64LessThan(length_float, float_zero), &if_isnegative, |
1041 &if_ispositive); | 1040 &if_ispositive); |
1042 | 1041 |
1043 a.Bind(&if_isnegative); | 1042 a.Bind(&if_isnegative); |
1044 a.Return(a.EmptyStringConstant()); | 1043 a.Return(a.EmptyStringConstant()); |
1045 | 1044 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1094 { | 1093 { |
1095 Node* const zero = a->SmiConstant(Smi::kZero); | 1094 Node* const zero = a->SmiConstant(Smi::kZero); |
1096 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); | 1095 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); |
1097 a->Goto(&out); | 1096 a->Goto(&out); |
1098 } | 1097 } |
1099 } | 1098 } |
1100 | 1099 |
1101 a->Bind(&if_isnotsmi); | 1100 a->Bind(&if_isnotsmi); |
1102 { | 1101 { |
1103 // {value} is a heap number - in this case, it is definitely out of bounds. | 1102 // {value} is a heap number - in this case, it is definitely out of bounds. |
1104 CSA_ASSERT(a, | 1103 CSA_ASSERT(a, a->IsHeapNumberMap(a->LoadMap(value_int))); |
1105 a->WordEqual(a->LoadMap(value_int), a->HeapNumberMapConstant())); | |
1106 | 1104 |
1107 Node* const float_zero = a->Float64Constant(0.); | 1105 Node* const float_zero = a->Float64Constant(0.); |
1108 Node* const smi_zero = a->SmiConstant(Smi::kZero); | 1106 Node* const smi_zero = a->SmiConstant(Smi::kZero); |
1109 Node* const value_float = a->LoadHeapNumberValue(value_int); | 1107 Node* const value_float = a->LoadHeapNumberValue(value_int); |
1110 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), | 1108 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), |
1111 smi_zero, limit)); | 1109 smi_zero, limit)); |
1112 a->Goto(&out); | 1110 a->Goto(&out); |
1113 } | 1111 } |
1114 | 1112 |
1115 a->Bind(&out); | 1113 a->Bind(&out); |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1466 Runtime::kThrowIncompatibleMethodReceiver, context, | 1464 Runtime::kThrowIncompatibleMethodReceiver, context, |
1467 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( | 1465 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( |
1468 "String Iterator.prototype.next", TENURED)), | 1466 "String Iterator.prototype.next", TENURED)), |
1469 iterator); | 1467 iterator); |
1470 assembler.Return(result); // Never reached. | 1468 assembler.Return(result); // Never reached. |
1471 } | 1469 } |
1472 } | 1470 } |
1473 | 1471 |
1474 } // namespace internal | 1472 } // namespace internal |
1475 } // namespace v8 | 1473 } // namespace v8 |
OLD | NEW |