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

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

Issue 2235983003: [builtins] Migrate StringToNumber to TurboFan builtin. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 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/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.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/builtins/builtins.h" 5 #include "src/builtins/builtins.h"
6 #include "src/builtins/builtins-utils.h" 6 #include "src/builtins/builtins-utils.h"
7 #include "src/code-factory.h" 7 #include "src/code-factory.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 void Builtins::Generate_NonPrimitiveToPrimitive_Number( 102 void Builtins::Generate_NonPrimitiveToPrimitive_Number(
103 CodeStubAssembler* assembler) { 103 CodeStubAssembler* assembler) {
104 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kNumber); 104 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kNumber);
105 } 105 }
106 106
107 void Builtins::Generate_NonPrimitiveToPrimitive_String( 107 void Builtins::Generate_NonPrimitiveToPrimitive_String(
108 CodeStubAssembler* assembler) { 108 CodeStubAssembler* assembler) {
109 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kString); 109 Generate_NonPrimitiveToPrimitive(assembler, ToPrimitiveHint::kString);
110 } 110 }
111 111
112 void Builtins::Generate_StringToNumber(CodeStubAssembler* assembler) {
113 typedef CodeStubAssembler::Label Label;
114 typedef compiler::Node Node;
115 typedef TypeConversionDescriptor Descriptor;
116
117 Node* input = assembler->Parameter(Descriptor::kArgument);
118 Node* context = assembler->Parameter(Descriptor::kContext);
119
120 Label runtime(assembler);
121
122 // Check if string has a cached array index.
123 Node* hash = assembler->LoadNameHashField(input);
124 Node* bit = assembler->Word32And(
125 hash, assembler->Int32Constant(String::kContainsCachedArrayIndexMask));
126 assembler->GotoIf(assembler->Word32NotEqual(bit, assembler->Int32Constant(0)),
127 &runtime);
128
129 assembler->Return(assembler->SmiTag(
130 assembler->BitFieldDecode<String::ArrayIndexValueBits>(hash)));
131
132 assembler->Bind(&runtime);
133 {
134 // Note: We cannot tail call to the runtime here, as js-to-wasm
135 // trampolines also use this code currently, and they declare all
136 // outgoing parameters as untagged, while we would push a tagged
137 // object here.
138 Node* result =
139 assembler->CallRuntime(Runtime::kStringToNumber, context, input);
140 assembler->Return(result);
141 }
142 }
143
112 // ES6 section 7.1.3 ToNumber ( argument ) 144 // ES6 section 7.1.3 ToNumber ( argument )
113 void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) { 145 void Builtins::Generate_NonNumberToNumber(CodeStubAssembler* assembler) {
114 typedef CodeStubAssembler::Label Label; 146 typedef CodeStubAssembler::Label Label;
115 typedef compiler::Node Node; 147 typedef compiler::Node Node;
116 typedef CodeStubAssembler::Variable Variable; 148 typedef CodeStubAssembler::Variable Variable;
117 typedef TypeConversionDescriptor Descriptor; 149 typedef TypeConversionDescriptor Descriptor;
118 150
119 Node* input = assembler->Parameter(Descriptor::kArgument); 151 Node* input = assembler->Parameter(Descriptor::kArgument);
120 Node* context = assembler->Parameter(Descriptor::kContext); 152 Node* context = assembler->Parameter(Descriptor::kContext);
121 153
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 348
317 assembler->Bind(&return_true); 349 assembler->Bind(&return_true);
318 assembler->Return(assembler->BooleanConstant(true)); 350 assembler->Return(assembler->BooleanConstant(true));
319 351
320 assembler->Bind(&return_false); 352 assembler->Bind(&return_false);
321 assembler->Return(assembler->BooleanConstant(false)); 353 assembler->Return(assembler->BooleanConstant(false));
322 } 354 }
323 355
324 } // namespace internal 356 } // namespace internal
325 } // namespace v8 357 } // namespace v8
OLDNEW
« no previous file with comments | « src/builtins/builtins.h ('k') | src/builtins/ia32/builtins-ia32.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698