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 983 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
994 a->GotoUnless(a->SmiLessThanOrEqual(var_length.value(), zero), &out); | 994 a->GotoUnless(a->SmiLessThanOrEqual(var_length.value(), zero), &out); |
995 a->Return(a->EmptyStringConstant()); | 995 a->Return(a->EmptyStringConstant()); |
996 } | 996 } |
997 | 997 |
998 a->Bind(&if_isheapnumber); | 998 a->Bind(&if_isheapnumber); |
999 { | 999 { |
1000 // If {length} is a heap number, it is definitely out of bounds. There are | 1000 // If {length} is a heap number, it is definitely out of bounds. There are |
1001 // two cases according to the spec: if it is negative, "" is returned; if | 1001 // two cases according to the spec: if it is negative, "" is returned; if |
1002 // it is positive, then length is set to {string_length} - {start}. | 1002 // it is positive, then length is set to {string_length} - {start}. |
1003 | 1003 |
1004 a->Assert(a->WordEqual(a->LoadMap(var_length.value()), | 1004 CSA_ASSERT(a, a->WordEqual(a->LoadMap(var_length.value()), |
1005 a->HeapNumberMapConstant())); | 1005 a->HeapNumberMapConstant())); |
1006 | 1006 |
1007 Label if_isnegative(a), if_ispositive(a); | 1007 Label if_isnegative(a), if_ispositive(a); |
1008 Node* const float_zero = a->Float64Constant(0.); | 1008 Node* const float_zero = a->Float64Constant(0.); |
1009 Node* const length_float = a->LoadHeapNumberValue(var_length.value()); | 1009 Node* const length_float = a->LoadHeapNumberValue(var_length.value()); |
1010 a->Branch(a->Float64LessThan(length_float, float_zero), &if_isnegative, | 1010 a->Branch(a->Float64LessThan(length_float, float_zero), &if_isnegative, |
1011 &if_ispositive); | 1011 &if_ispositive); |
1012 | 1012 |
1013 a->Bind(&if_isnegative); | 1013 a->Bind(&if_isnegative); |
1014 a->Return(a->EmptyStringConstant()); | 1014 a->Return(a->EmptyStringConstant()); |
1015 | 1015 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1064 { | 1064 { |
1065 Node* const zero = a->SmiConstant(Smi::kZero); | 1065 Node* const zero = a->SmiConstant(Smi::kZero); |
1066 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); | 1066 var_result.Bind(a->Select(a->SmiLessThan(value_int, zero), zero, limit)); |
1067 a->Goto(&out); | 1067 a->Goto(&out); |
1068 } | 1068 } |
1069 } | 1069 } |
1070 | 1070 |
1071 a->Bind(&if_isnotsmi); | 1071 a->Bind(&if_isnotsmi); |
1072 { | 1072 { |
1073 // {value} is a heap number - in this case, it is definitely out of bounds. | 1073 // {value} is a heap number - in this case, it is definitely out of bounds. |
1074 a->Assert(a->WordEqual(a->LoadMap(value_int), a->HeapNumberMapConstant())); | 1074 CSA_ASSERT(a, |
| 1075 a->WordEqual(a->LoadMap(value_int), a->HeapNumberMapConstant())); |
1075 | 1076 |
1076 Node* const float_zero = a->Float64Constant(0.); | 1077 Node* const float_zero = a->Float64Constant(0.); |
1077 Node* const smi_zero = a->SmiConstant(Smi::kZero); | 1078 Node* const smi_zero = a->SmiConstant(Smi::kZero); |
1078 Node* const value_float = a->LoadHeapNumberValue(value_int); | 1079 Node* const value_float = a->LoadHeapNumberValue(value_int); |
1079 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), | 1080 var_result.Bind(a->Select(a->Float64LessThan(value_float, float_zero), |
1080 smi_zero, limit)); | 1081 smi_zero, limit)); |
1081 a->Goto(&out); | 1082 a->Goto(&out); |
1082 } | 1083 } |
1083 | 1084 |
1084 a->Bind(&out); | 1085 a->Bind(&out); |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1294 assembler->Branch(assembler->Word32Equal( | 1295 assembler->Branch(assembler->Word32Equal( |
1295 assembler->Word32And(var_trail.value(), | 1296 assembler->Word32And(var_trail.value(), |
1296 assembler->Int32Constant(0xFC00)), | 1297 assembler->Int32Constant(0xFC00)), |
1297 assembler->Int32Constant(0xDC00)), | 1298 assembler->Int32Constant(0xDC00)), |
1298 &handle_surrogate_pair, &return_result); | 1299 &handle_surrogate_pair, &return_result); |
1299 | 1300 |
1300 assembler->Bind(&handle_surrogate_pair); | 1301 assembler->Bind(&handle_surrogate_pair); |
1301 { | 1302 { |
1302 Node* lead = var_result.value(); | 1303 Node* lead = var_result.value(); |
1303 Node* trail = var_trail.value(); | 1304 Node* trail = var_trail.value(); |
1304 #ifdef ENABLE_SLOW_DCHECKS | 1305 |
1305 // Check that this path is only taken if a surrogate pair is found | 1306 // Check that this path is only taken if a surrogate pair is found |
1306 assembler->Assert(assembler->Uint32GreaterThanOrEqual( | 1307 CSA_SLOW_ASSERT(assembler, assembler->Uint32GreaterThanOrEqual( |
1307 lead, assembler->Int32Constant(0xD800))); | 1308 lead, assembler->Int32Constant(0xD800))); |
1308 assembler->Assert( | 1309 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan( |
1309 assembler->Uint32LessThan(lead, assembler->Int32Constant(0xDC00))); | 1310 lead, assembler->Int32Constant(0xDC00))); |
1310 assembler->Assert(assembler->Uint32GreaterThanOrEqual( | 1311 CSA_SLOW_ASSERT(assembler, assembler->Uint32GreaterThanOrEqual( |
1311 trail, assembler->Int32Constant(0xDC00))); | 1312 trail, assembler->Int32Constant(0xDC00))); |
1312 assembler->Assert( | 1313 CSA_SLOW_ASSERT(assembler, assembler->Uint32LessThan( |
1313 assembler->Uint32LessThan(trail, assembler->Int32Constant(0xE000))); | 1314 trail, assembler->Int32Constant(0xE000))); |
1314 #endif | |
1315 | 1315 |
1316 switch (encoding) { | 1316 switch (encoding) { |
1317 case UnicodeEncoding::UTF16: | 1317 case UnicodeEncoding::UTF16: |
1318 var_result.Bind(assembler->WordOr( | 1318 var_result.Bind(assembler->WordOr( |
1319 // Need to swap the order for big-endian platforms | 1319 // Need to swap the order for big-endian platforms |
1320 #if V8_TARGET_BIG_ENDIAN | 1320 #if V8_TARGET_BIG_ENDIAN |
1321 assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); | 1321 assembler->WordShl(lead, assembler->Int32Constant(16)), trail)); |
1322 #else | 1322 #else |
1323 assembler->WordShl(trail, assembler->Int32Constant(16)), lead)); | 1323 assembler->WordShl(trail, assembler->Int32Constant(16)), lead)); |
1324 #endif | 1324 #endif |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1427 Runtime::kThrowIncompatibleMethodReceiver, context, | 1427 Runtime::kThrowIncompatibleMethodReceiver, context, |
1428 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( | 1428 assembler->HeapConstant(assembler->factory()->NewStringFromAsciiChecked( |
1429 "String Iterator.prototype.next", TENURED)), | 1429 "String Iterator.prototype.next", TENURED)), |
1430 iterator); | 1430 iterator); |
1431 assembler->Return(result); // Never reached. | 1431 assembler->Return(result); // Never reached. |
1432 } | 1432 } |
1433 } | 1433 } |
1434 | 1434 |
1435 } // namespace internal | 1435 } // namespace internal |
1436 } // namespace v8 | 1436 } // namespace v8 |
OLD | NEW |