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

Side by Side Diff: src/builtins/builtins-string.cc

Issue 2339123002: [builtins] Move StringLastIndexOf to a builtin. (Closed)
Patch Set: Test natives callable from extensions with str compare instead Created 4 years, 3 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
OLDNEW
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 9
10 namespace v8 { 10 namespace v8 {
(...skipping 459 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 assembler->Return(assembler->NaNConstant()); 470 assembler->Return(assembler->NaNConstant());
471 assembler->Bind(&if_positioninbounds); 471 assembler->Bind(&if_positioninbounds);
472 } 472 }
473 473
474 // Load the character at the {position} from the {receiver}. 474 // Load the character at the {position} from the {receiver}.
475 Node* value = assembler->StringCharCodeAt(receiver, position); 475 Node* value = assembler->StringCharCodeAt(receiver, position);
476 Node* result = assembler->SmiFromWord32(value); 476 Node* result = assembler->SmiFromWord32(value);
477 assembler->Return(result); 477 assembler->Return(result);
478 } 478 }
479 479
480 // ES6 section 21.1.3.9
481 // String.prototype.lastIndexOf ( searchString [ , position ] )
482 BUILTIN(StringPrototypeLastIndexOf) {
483 HandleScope handle_scope(isolate);
484 return String::LastIndexOf(isolate, args.receiver(),
485 args.atOrUndefined(isolate, 1),
486 args.atOrUndefined(isolate, 2));
487 }
488
480 // ES6 section 21.1.3.10 String.prototype.localeCompare ( that ) 489 // ES6 section 21.1.3.10 String.prototype.localeCompare ( that )
481 // 490 //
482 // This function is implementation specific. For now, we do not 491 // This function is implementation specific. For now, we do not
483 // do anything locale specific. 492 // do anything locale specific.
484 // If internationalization is enabled, then i18n.js will override this function 493 // If internationalization is enabled, then i18n.js will override this function
485 // and provide the proper functionality, so this is just a fallback. 494 // and provide the proper functionality, so this is just a fallback.
486 BUILTIN(StringPrototypeLocaleCompare) { 495 BUILTIN(StringPrototypeLocaleCompare) {
487 HandleScope handle_scope(isolate); 496 HandleScope handle_scope(isolate);
488 DCHECK_EQ(2, args.length()); 497 DCHECK_EQ(2, args.length());
489 498
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 Node* receiver = assembler->Parameter(0); 611 Node* receiver = assembler->Parameter(0);
603 Node* context = assembler->Parameter(3); 612 Node* context = assembler->Parameter(3);
604 613
605 Node* result = assembler->ToThisValue( 614 Node* result = assembler->ToThisValue(
606 context, receiver, PrimitiveType::kString, "String.prototype.valueOf"); 615 context, receiver, PrimitiveType::kString, "String.prototype.valueOf");
607 assembler->Return(result); 616 assembler->Return(result);
608 } 617 }
609 618
610 } // namespace internal 619 } // namespace internal
611 } // namespace v8 620 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/js/i18n.js » ('j') | src/objects.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698