OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/runtime/runtime-utils.h" | 5 #include "src/runtime/runtime-utils.h" |
6 | 6 |
7 #include "src/arguments.h" | 7 #include "src/arguments.h" |
8 #include "src/conversions-inl.h" | 8 #include "src/conversions-inl.h" |
9 #include "src/isolate-inl.h" | 9 #include "src/isolate-inl.h" |
10 #include "src/regexp/jsregexp-inl.h" | 10 #include "src/regexp/jsregexp-inl.h" |
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1151 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1151 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1152 isolate, result, isolate->factory()->NewRawOneByteString(length)); | 1152 isolate, result, isolate->factory()->NewRawOneByteString(length)); |
1153 } else { | 1153 } else { |
1154 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | 1154 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( |
1155 isolate, result, isolate->factory()->NewRawTwoByteString(length)); | 1155 isolate, result, isolate->factory()->NewRawTwoByteString(length)); |
1156 } | 1156 } |
1157 return *result; | 1157 return *result; |
1158 } | 1158 } |
1159 | 1159 |
1160 | 1160 |
1161 RUNTIME_FUNCTION(Runtime_NewConsString) { | |
1162 HandleScope scope(isolate); | |
1163 DCHECK(args.length() == 4); | |
1164 CONVERT_INT32_ARG_CHECKED(length, 0); | |
1165 CONVERT_BOOLEAN_ARG_CHECKED(is_one_byte, 1); | |
1166 CONVERT_ARG_HANDLE_CHECKED(String, left, 2); | |
1167 CONVERT_ARG_HANDLE_CHECKED(String, right, 3); | |
1168 | |
1169 Handle<String> result; | |
1170 if (is_one_byte) { | |
1171 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
1172 isolate, result, | |
1173 isolate->factory()->NewOneByteConsString(length, left, right)); | |
1174 } else { | |
1175 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( | |
1176 isolate, result, | |
1177 isolate->factory()->NewTwoByteConsString(length, left, right)); | |
1178 } | |
1179 return *result; | |
1180 } | |
1181 | |
1182 | |
1183 RUNTIME_FUNCTION(Runtime_StringEquals) { | 1161 RUNTIME_FUNCTION(Runtime_StringEquals) { |
1184 HandleScope handle_scope(isolate); | 1162 HandleScope handle_scope(isolate); |
1185 DCHECK(args.length() == 2); | 1163 DCHECK(args.length() == 2); |
1186 | 1164 |
1187 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); | 1165 CONVERT_ARG_HANDLE_CHECKED(String, x, 0); |
1188 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); | 1166 CONVERT_ARG_HANDLE_CHECKED(String, y, 1); |
1189 | 1167 |
1190 bool not_equal = !String::Equals(x, y); | 1168 bool not_equal = !String::Equals(x, y); |
1191 // This is slightly convoluted because the value that signifies | 1169 // This is slightly convoluted because the value that signifies |
1192 // equality is 0 and inequality is 1 so we have to negate the result | 1170 // equality is 0 and inequality is 1 so we have to negate the result |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 | 1253 |
1276 | 1254 |
1277 RUNTIME_FUNCTION(Runtime_StringGetLength) { | 1255 RUNTIME_FUNCTION(Runtime_StringGetLength) { |
1278 HandleScope scope(isolate); | 1256 HandleScope scope(isolate); |
1279 DCHECK(args.length() == 1); | 1257 DCHECK(args.length() == 1); |
1280 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); | 1258 CONVERT_ARG_HANDLE_CHECKED(String, s, 0); |
1281 return Smi::FromInt(s->length()); | 1259 return Smi::FromInt(s->length()); |
1282 } | 1260 } |
1283 } // namespace internal | 1261 } // namespace internal |
1284 } // namespace v8 | 1262 } // namespace v8 |
OLD | NEW |