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 1047 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 a->GotoUnless(a->SmiLessThanOrEqual(var_length.value(), zero), &out); | 1058 a->GotoUnless(a->SmiLessThanOrEqual(var_length.value(), zero), &out); |
1059 a->Return(a->EmptyStringConstant()); | 1059 a->Return(a->EmptyStringConstant()); |
1060 } | 1060 } |
1061 | 1061 |
1062 a->Bind(&if_isheapnumber); | 1062 a->Bind(&if_isheapnumber); |
1063 { | 1063 { |
1064 // If {length} is a heap number, it is definitely out of bounds. There are | 1064 // If {length} is a heap number, it is definitely out of bounds. There are |
1065 // two cases according to the spec: if it is negative, "" is returned; if | 1065 // two cases according to the spec: if it is negative, "" is returned; if |
1066 // it is positive, then length is set to {string_length} - {start}. | 1066 // it is positive, then length is set to {string_length} - {start}. |
1067 | 1067 |
1068 a->Assert(a->WordEqual(a->LoadMap(var_length.value()), | 1068 a->CSA_ASSERT(a->WordEqual(a->LoadMap(var_length.value()), |
1069 a->HeapNumberMapConstant())); | 1069 a->HeapNumberMapConstant())); |
1070 | 1070 |
1071 Label if_isnegative(a), if_ispositive(a); | 1071 Label if_isnegative(a), if_ispositive(a); |
1072 Node* const float_zero = a->Float64Constant(0.); | 1072 Node* const float_zero = a->Float64Constant(0.); |
1073 Node* const length_float = a->LoadHeapNumberValue(var_length.value()); | 1073 Node* const length_float = a->LoadHeapNumberValue(var_length.value()); |
1074 a->Branch(a->Float64LessThan(length_float, float_zero), &if_isnegative, | 1074 a->Branch(a->Float64LessThan(length_float, float_zero), &if_isnegative, |
1075 &if_ispositive); | 1075 &if_ispositive); |
1076 | 1076 |
1077 a->Bind(&if_isnegative); | 1077 a->Bind(&if_isnegative); |
1078 a->Return(a->EmptyStringConstant()); | 1078 a->Return(a->EmptyStringConstant()); |
1079 | 1079 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1128 { | 1128 { |
1129 Node* const zero = a->SmiConstant(Smi::kZero); | 1129 Node* const zero = a->SmiConstant(Smi::kZero); |
1130 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); | 1130 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); |
1131 a->Goto(&out); | 1131 a->Goto(&out); |
1132 } | 1132 } |
1133 } | 1133 } |
1134 | 1134 |
1135 a->Bind(&if_isnotsmi); | 1135 a->Bind(&if_isnotsmi); |
1136 { | 1136 { |
1137 // {value} is a heap number - in this case, it is definitely out of bounds. | 1137 // {value} is a heap number - in this case, it is definitely out of bounds. |
1138 a->Assert(a->WordEqual(a->LoadMap(value_int), a->HeapNumberMapConstant())); | 1138 a->CSA_ASSERT( |
| 1139 a->WordEqual(a->LoadMap(value_int), a->HeapNumberMapConstant())); |
1139 | 1140 |
1140 Node* const float_zero = a->Float64Constant(0.); | 1141 Node* const float_zero = a->Float64Constant(0.); |
1141 Node* const smi_zero = a->SmiConstant(Smi::kZero); | 1142 Node* const smi_zero = a->SmiConstant(Smi::kZero); |
1142 Node* const value_float = a->LoadHeapNumberValue(value_int); | 1143 Node* const value_float = a->LoadHeapNumberValue(value_int); |
1143 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), | 1144 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), |
1144 smi_zero, limit)); | 1145 smi_zero, limit)); |
1145 a->Goto(&out); | 1146 a->Goto(&out); |
1146 } | 1147 } |
1147 | 1148 |
1148 a->Bind(&out); | 1149 a->Bind(&out); |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1360 assembler->Int32Constant(0xFC00)), | 1361 assembler->Int32Constant(0xFC00)), |
1361 assembler->Int32Constant(0xDC00)), | 1362 assembler->Int32Constant(0xDC00)), |
1362 &handle_surrogate_pair, &return_result); | 1363 &handle_surrogate_pair, &return_result); |
1363 | 1364 |
1364 assembler->Bind(&handle_surrogate_pair); | 1365 assembler->Bind(&handle_surrogate_pair); |
1365 { | 1366 { |
1366 Node* lead = var_result.value(); | 1367 Node* lead = var_result.value(); |
1367 Node* trail = var_trail.value(); | 1368 Node* trail = var_trail.value(); |
1368 #ifdef ENABLE_SLOW_DCHECKS | 1369 #ifdef ENABLE_SLOW_DCHECKS |
1369 // Check that this path is only taken if a surrogate pair is found | 1370 // Check that this path is only taken if a surrogate pair is found |
1370 assembler->Assert(assembler->Uint32GreaterThanOrEqual( | 1371 assembler->CSA_ASSERT(assembler->Uint32GreaterThanOrEqual( |
1371 lead, assembler->Int32Constant(0xD800))); | 1372 lead, assembler->Int32Constant(0xD800))); |
1372 assembler->Assert( | 1373 assembler->CSA_ASSERT( |
1373 assembler->Uint32LessThan(lead, assembler->Int32Constant(0xDC00))); | 1374 assembler->Uint32LessThan(lead, assembler->Int32Constant(0xDC00))); |
1374 assembler->Assert(assembler->Uint32GreaterThanOrEqual( | 1375 assembler->CSA_ASSERT(assembler->Uint32GreaterThanOrEqual( |
1375 trail, assembler->Int32Constant(0xDC00))); | 1376 trail, assembler->Int32Constant(0xDC00))); |
1376 assembler->Assert( | 1377 assembler->CSA_ASSERT( |
1377 assembler->Uint32LessThan(trail, assembler->Int32Constant(0xE000))); | 1378 assembler->Uint32LessThan(trail, assembler->Int32Constant(0xE000))); |
1378 #endif | 1379 #endif |
1379 | 1380 |
1380 switch (encoding) { | 1381 switch (encoding) { |
1381 case UnicodeEncoding::UTF16: | 1382 case UnicodeEncoding::UTF16: |
1382 var_result.Bind(assembler->WordOr( | 1383 var_result.Bind(assembler->WordOr( |
1383 // Need to swap the order for big-endian platforms | 1384 // Need to swap the order for big-endian platforms |
1384 #if V8_TARGET_BIG_ENDIAN | 1385 #if V8_TARGET_BIG_ENDIAN |
1385 assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); | 1386 assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); |
1386 #else | 1387 #else |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1491 Runtime::kThrowIncompatibleMethodReceiver, context, | 1492 Runtime::kThrowIncompatibleMethodReceiver, context, |
1492 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( | 1493 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( |
1493 "String Iterator.prototype.next", TENURED)), | 1494 "String Iterator.prototype.next", TENURED)), |
1494 iterator); | 1495 iterator); |
1495 assembler->Return(result); // Never reached. | 1496 assembler->Return(result); // Never reached. |
1496 } | 1497 } |
1497 } | 1498 } |
1498 | 1499 |
1499 } // namespace internal | 1500 } // namespace internal |
1500 } // namespace v8 | 1501 } // namespace v8 |
OLD | NEW |