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

Side by Side Diff: src/code-stub-assembler.cc

Issue 2381053002: Reland "[builtins] migrate C++ String Iterator builtins to baseline TurboFan" (Closed)
Patch Set: Add the fix and test Created 4 years, 2 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/code-stub-assembler.h ('k') | src/objects-debug.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 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/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 #include "src/frames-inl.h" 7 #include "src/frames-inl.h"
8 #include "src/frames.h" 8 #include "src/frames.h"
9 #include "src/ic/handler-configuration.h" 9 #include "src/ic/handler-configuration.h"
10 #include "src/ic/stub-cache.h" 10 #include "src/ic/stub-cache.h"
(...skipping 2716 matching lines...) Expand 10 before | Expand all | Expand 10 after
2727 { 2727 {
2728 var_result.Bind( 2728 var_result.Bind(
2729 CallRuntime(Runtime::kSubString, context, string, from, to)); 2729 CallRuntime(Runtime::kSubString, context, string, from, to));
2730 Goto(&end); 2730 Goto(&end);
2731 } 2731 }
2732 2732
2733 Bind(&end); 2733 Bind(&end);
2734 return var_result.value(); 2734 return var_result.value();
2735 } 2735 }
2736 2736
2737 Node* CodeStubAssembler::StringFromCodePoint(compiler::Node* codepoint,
2738 UnicodeEncoding encoding) {
2739 Variable var_result(this, MachineRepresentation::kTagged);
2740 var_result.Bind(EmptyStringConstant());
2741
2742 Label if_isword16(this), if_isword32(this), return_result(this);
2743
2744 Branch(Uint32LessThan(codepoint, Int32Constant(0x10000)), &if_isword16,
2745 &if_isword32);
2746
2747 Bind(&if_isword16);
2748 {
2749 var_result.Bind(StringFromCharCode(codepoint));
2750 Goto(&return_result);
2751 }
2752
2753 Bind(&if_isword32);
2754 {
2755 switch (encoding) {
2756 case UnicodeEncoding::UTF16:
2757 break;
2758 case UnicodeEncoding::UTF32: {
2759 // Convert UTF32 to UTF16 code units, and store as a 32 bit word.
2760 Node* lead_offset = Int32Constant(0xD800 - (0x10000 >> 10));
2761
2762 // lead = (codepoint >> 10) + LEAD_OFFSET
2763 Node* lead =
2764 Int32Add(WordShr(codepoint, Int32Constant(10)), lead_offset);
2765
2766 // trail = (codepoint & 0x3FF) + 0xDC00;
2767 Node* trail = Int32Add(Word32And(codepoint, Int32Constant(0x3FF)),
2768 Int32Constant(0xDC00));
2769
2770 // codpoint = (trail << 16) | lead;
2771 codepoint = Word32Or(WordShl(trail, Int32Constant(16)), lead);
2772 break;
2773 }
2774 }
2775
2776 Node* value = AllocateSeqTwoByteString(2);
2777 StoreNoWriteBarrier(
2778 MachineRepresentation::kWord32, value,
2779 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag),
2780 codepoint);
2781 var_result.Bind(value);
2782 Goto(&return_result);
2783 }
2784
2785 Bind(&return_result);
2786 return var_result.value();
2787 }
2788
2737 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { 2789 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) {
2738 Label runtime(this, Label::kDeferred); 2790 Label runtime(this, Label::kDeferred);
2739 Label end(this); 2791 Label end(this);
2740 2792
2741 Variable var_result(this, MachineRepresentation::kTagged); 2793 Variable var_result(this, MachineRepresentation::kTagged);
2742 2794
2743 // Check if string has a cached array index. 2795 // Check if string has a cached array index.
2744 Node* hash = LoadNameHashField(input); 2796 Node* hash = LoadNameHashField(input);
2745 Node* bit = 2797 Node* bit =
2746 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); 2798 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask));
(...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after
5642 Heap::kTheHoleValueRootIndex); 5694 Heap::kTheHoleValueRootIndex);
5643 5695
5644 // Store the WeakCell in the feedback vector. 5696 // Store the WeakCell in the feedback vector.
5645 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 5697 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
5646 CodeStubAssembler::SMI_PARAMETERS); 5698 CodeStubAssembler::SMI_PARAMETERS);
5647 return cell; 5699 return cell;
5648 } 5700 }
5649 5701
5650 } // namespace internal 5702 } // namespace internal
5651 } // namespace v8 5703 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/objects-debug.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698