Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Side by Side Diff: src/runtime/runtime-regexp.cc

Issue 2697013009: Move ArrayBuffer.prototype.slice implementation to C++ (Closed)
Patch Set: merge master Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/messages.h" 10 #include "src/messages.h"
(...skipping 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after
1299 CONVERT_ARG_HANDLE_CHECKED(JSObject, replace, 2); 1299 CONVERT_ARG_HANDLE_CHECKED(JSObject, replace, 2);
1300 1300
1301 DCHECK(RegExpUtils::IsUnmodifiedRegExp(isolate, regexp)); 1301 DCHECK(RegExpUtils::IsUnmodifiedRegExp(isolate, regexp));
1302 1302
1303 RETURN_RESULT_OR_FAILURE(isolate, StringReplaceNonGlobalRegExpWithFunction( 1303 RETURN_RESULT_OR_FAILURE(isolate, StringReplaceNonGlobalRegExpWithFunction(
1304 isolate, subject, regexp, replace)); 1304 isolate, subject, regexp, replace));
1305 } 1305 }
1306 1306
1307 namespace { 1307 namespace {
1308 1308
1309 // ES##sec-speciesconstructor
1310 // SpeciesConstructor ( O, defaultConstructor )
1311 MUST_USE_RESULT MaybeHandle<Object> SpeciesConstructor(
1312 Isolate* isolate, Handle<JSReceiver> recv,
1313 Handle<JSFunction> default_ctor) {
1314 Handle<Object> ctor_obj;
1315 ASSIGN_RETURN_ON_EXCEPTION(
1316 isolate, ctor_obj,
1317 JSObject::GetProperty(recv, isolate->factory()->constructor_string()),
1318 Object);
1319
1320 if (ctor_obj->IsUndefined(isolate)) return default_ctor;
1321
1322 if (!ctor_obj->IsJSReceiver()) {
1323 THROW_NEW_ERROR(isolate,
1324 NewTypeError(MessageTemplate::kConstructorNotReceiver),
1325 Object);
1326 }
1327
1328 Handle<JSReceiver> ctor = Handle<JSReceiver>::cast(ctor_obj);
1329
1330 Handle<Object> species;
1331 ASSIGN_RETURN_ON_EXCEPTION(
1332 isolate, species,
1333 JSObject::GetProperty(ctor, isolate->factory()->species_symbol()),
1334 Object);
1335
1336 if (species->IsNullOrUndefined(isolate)) {
1337 return default_ctor;
1338 }
1339
1340 if (species->IsConstructor()) return species;
1341
1342 THROW_NEW_ERROR(
1343 isolate, NewTypeError(MessageTemplate::kSpeciesNotConstructor), Object);
1344 }
1345
1346 MUST_USE_RESULT MaybeHandle<Object> ToUint32(Isolate* isolate, 1309 MUST_USE_RESULT MaybeHandle<Object> ToUint32(Isolate* isolate,
1347 Handle<Object> object, 1310 Handle<Object> object,
1348 uint32_t* out) { 1311 uint32_t* out) {
1349 if (object->IsUndefined(isolate)) { 1312 if (object->IsUndefined(isolate)) {
1350 *out = kMaxUInt32; 1313 *out = kMaxUInt32;
1351 return object; 1314 return object;
1352 } 1315 }
1353 1316
1354 Handle<Object> number; 1317 Handle<Object> number;
1355 ASSIGN_RETURN_ON_EXCEPTION(isolate, number, Object::ToNumber(object), Object); 1318 ASSIGN_RETURN_ON_EXCEPTION(isolate, number, Object::ToNumber(object), Object);
(...skipping 21 matching lines...) Expand all
1377 1340
1378 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, recv, 0); 1341 CONVERT_ARG_HANDLE_CHECKED(JSReceiver, recv, 0);
1379 CONVERT_ARG_HANDLE_CHECKED(String, string, 1); 1342 CONVERT_ARG_HANDLE_CHECKED(String, string, 1);
1380 CONVERT_ARG_HANDLE_CHECKED(Object, limit_obj, 2); 1343 CONVERT_ARG_HANDLE_CHECKED(Object, limit_obj, 2);
1381 1344
1382 Factory* factory = isolate->factory(); 1345 Factory* factory = isolate->factory();
1383 1346
1384 Handle<JSFunction> regexp_fun = isolate->regexp_function(); 1347 Handle<JSFunction> regexp_fun = isolate->regexp_function();
1385 Handle<Object> ctor; 1348 Handle<Object> ctor;
1386 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1349 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1387 isolate, ctor, SpeciesConstructor(isolate, recv, regexp_fun)); 1350 isolate, ctor, Object::SpeciesConstructor(isolate, recv, regexp_fun));
1388 1351
1389 Handle<Object> flags_obj; 1352 Handle<Object> flags_obj;
1390 ASSIGN_RETURN_FAILURE_ON_EXCEPTION( 1353 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(
1391 isolate, flags_obj, JSObject::GetProperty(recv, factory->flags_string())); 1354 isolate, flags_obj, JSObject::GetProperty(recv, factory->flags_string()));
1392 1355
1393 Handle<String> flags; 1356 Handle<String> flags;
1394 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, flags, 1357 ASSIGN_RETURN_FAILURE_ON_EXCEPTION(isolate, flags,
1395 Object::ToString(isolate, flags_obj)); 1358 Object::ToString(isolate, flags_obj));
1396 1359
1397 Handle<String> u_str = factory->LookupSingleCharacterStringFromCode('u'); 1360 Handle<String> u_str = factory->LookupSingleCharacterStringFromCode('u');
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after
1713 1676
1714 RUNTIME_FUNCTION(Runtime_IsRegExp) { 1677 RUNTIME_FUNCTION(Runtime_IsRegExp) {
1715 SealHandleScope shs(isolate); 1678 SealHandleScope shs(isolate);
1716 DCHECK_EQ(1, args.length()); 1679 DCHECK_EQ(1, args.length());
1717 CONVERT_ARG_CHECKED(Object, obj, 0); 1680 CONVERT_ARG_CHECKED(Object, obj, 0);
1718 return isolate->heap()->ToBoolean(obj->IsJSRegExp()); 1681 return isolate->heap()->ToBoolean(obj->IsJSRegExp());
1719 } 1682 }
1720 1683
1721 } // namespace internal 1684 } // namespace internal
1722 } // namespace v8 1685 } // namespace v8
OLDNEW
« no previous file with comments | « src/runtime/runtime.h ('k') | src/runtime/runtime-typedarray.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698