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

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

Issue 2293943002: [builtins] Create StringToNumber helper. (Closed)
Patch Set: [builtins] Create StringToNumber helper. 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/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 2198 matching lines...) Expand 10 before | Expand all | Expand 10 after
2209 MachineRepresentation::kWord16, result, 2209 MachineRepresentation::kWord16, result,
2210 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); 2210 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code);
2211 var_result.Bind(result); 2211 var_result.Bind(result);
2212 Goto(&if_done); 2212 Goto(&if_done);
2213 } 2213 }
2214 2214
2215 Bind(&if_done); 2215 Bind(&if_done);
2216 return var_result.value(); 2216 return var_result.value();
2217 } 2217 }
2218 2218
2219 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) {
2220 Label runtime(this, Label::kDeferred);
2221 Label end(this);
2222
2223 Variable var_result(this, MachineRepresentation::kTagged);
2224
2225 // Check if string has a cached array index.
2226 Node* hash = LoadNameHashField(input);
2227 Node* bit =
2228 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask));
2229 GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime);
2230
2231 var_result.Bind(SmiTag(BitFieldDecode<String::ArrayIndexValueBits>(hash)));
2232 Goto(&end);
2233
2234 Bind(&runtime);
2235 {
2236 // Note: We cannot tail call to the runtime here, as js-to-wasm
Benedikt Meurer 2016/09/02 04:23:48 Nit: remove this note as now with the helper we ca
2237 // trampolines also use this code currently, and they declare all
2238 // outgoing parameters as untagged, while we would push a tagged
2239 // object here.
2240 var_result.Bind(CallRuntime(Runtime::kStringToNumber, context, input));
2241 Goto(&end);
2242 }
2243
2244 Bind(&end);
2245 return var_result.value();
2246 }
2247
2219 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, 2248 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
2220 uint32_t mask) { 2249 uint32_t mask) {
2221 return Word32Shr(Word32And(word32, Int32Constant(mask)), 2250 return Word32Shr(Word32And(word32, Int32Constant(mask)),
2222 static_cast<int>(shift)); 2251 static_cast<int>(shift));
2223 } 2252 }
2224 2253
2225 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) { 2254 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) {
2226 if (FLAG_native_code_counters && counter->Enabled()) { 2255 if (FLAG_native_code_counters && counter->Enabled()) {
2227 Node* counter_address = ExternalConstant(ExternalReference(counter)); 2256 Node* counter_address = ExternalConstant(ExternalReference(counter));
2228 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address, 2257 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address,
(...skipping 1982 matching lines...) Expand 10 before | Expand all | Expand 10 after
4211 Heap::kTheHoleValueRootIndex); 4240 Heap::kTheHoleValueRootIndex);
4212 4241
4213 // Store the WeakCell in the feedback vector. 4242 // Store the WeakCell in the feedback vector.
4214 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4243 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4215 CodeStubAssembler::SMI_PARAMETERS); 4244 CodeStubAssembler::SMI_PARAMETERS);
4216 return cell; 4245 return cell;
4217 } 4246 }
4218 4247
4219 } // namespace internal 4248 } // namespace internal
4220 } // namespace v8 4249 } // namespace v8
OLDNEW
« src/builtins/builtins-conversion.cc ('K') | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698