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-utils.h" | 5 #include "src/builtins/builtins-utils.h" |
6 #include "src/builtins/builtins.h" | 6 #include "src/builtins/builtins.h" |
7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
8 #include "src/code-stub-assembler.h" | 8 #include "src/code-stub-assembler.h" |
9 #include "src/regexp/regexp-utils.h" | 9 #include "src/regexp/regexp-utils.h" |
10 | 10 |
(...skipping 462 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
473 | 473 |
474 // Load the character code at the {position} from the {receiver}. | 474 // Load the character code at the {position} from the {receiver}. |
475 Node* code = assembler.StringCharCodeAt(receiver, position, | 475 Node* code = assembler.StringCharCodeAt(receiver, position, |
476 CodeStubAssembler::INTPTR_PARAMETERS); | 476 CodeStubAssembler::INTPTR_PARAMETERS); |
477 | 477 |
478 // And return the single character string with only that {code} | 478 // And return the single character string with only that {code} |
479 Node* result = assembler.StringFromCharCode(code); | 479 Node* result = assembler.StringFromCharCode(code); |
480 assembler.Return(result); | 480 assembler.Return(result); |
481 } | 481 } |
482 | 482 |
| 483 // static |
| 484 void Builtins::Generate_StringCharCodeAt(compiler::CodeAssemblerState* state) { |
| 485 typedef compiler::Node Node; |
| 486 CodeStubAssembler assembler(state); |
| 487 |
| 488 Node* receiver = assembler.Parameter(0); |
| 489 Node* position = assembler.Parameter(1); |
| 490 |
| 491 // Load the character code at the {position} from the {receiver}. |
| 492 Node* code = assembler.StringCharCodeAt(receiver, position, |
| 493 CodeStubAssembler::INTPTR_PARAMETERS); |
| 494 |
| 495 // And return it as TaggedSigned value. |
| 496 // TODO(turbofan): Allow builtins to return values untagged. |
| 497 Node* result = assembler.SmiFromWord32(code); |
| 498 assembler.Return(result); |
| 499 } |
| 500 |
483 // ----------------------------------------------------------------------------- | 501 // ----------------------------------------------------------------------------- |
484 // ES6 section 21.1 String Objects | 502 // ES6 section 21.1 String Objects |
485 | 503 |
486 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) | 504 // ES6 section 21.1.2.1 String.fromCharCode ( ...codeUnits ) |
487 void Builtins::Generate_StringFromCharCode( | 505 void Builtins::Generate_StringFromCharCode( |
488 compiler::CodeAssemblerState* state) { | 506 compiler::CodeAssemblerState* state) { |
489 typedef CodeStubAssembler::Label Label; | 507 typedef CodeStubAssembler::Label Label; |
490 typedef compiler::Node Node; | 508 typedef compiler::Node Node; |
491 typedef CodeStubAssembler::Variable Variable; | 509 typedef CodeStubAssembler::Variable Variable; |
492 CodeStubAssembler assembler(state); | 510 CodeStubAssembler assembler(state); |
(...skipping 1138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1631 Runtime::kThrowIncompatibleMethodReceiver, context, | 1649 Runtime::kThrowIncompatibleMethodReceiver, context, |
1632 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( | 1650 assembler.HeapConstant(assembler.factory()->NewStringFromAsciiChecked( |
1633 "String Iterator.prototype.next", TENURED)), | 1651 "String Iterator.prototype.next", TENURED)), |
1634 iterator); | 1652 iterator); |
1635 assembler.Return(result); // Never reached. | 1653 assembler.Return(result); // Never reached. |
1636 } | 1654 } |
1637 } | 1655 } |
1638 | 1656 |
1639 } // namespace internal | 1657 } // namespace internal |
1640 } // namespace v8 | 1658 } // namespace v8 |
OLD | NEW |