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

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

Issue 2293943002: [builtins] Create StringToNumber helper. (Closed)
Patch Set: Addressed nits. 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
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | 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 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 var_result.Bind(CallRuntime(Runtime::kStringToNumber, context, input));
2237 Goto(&end);
2238 }
2239
2240 Bind(&end);
2241 return var_result.value();
2242 }
2243
2219 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, 2244 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
2220 uint32_t mask) { 2245 uint32_t mask) {
2221 return Word32Shr(Word32And(word32, Int32Constant(mask)), 2246 return Word32Shr(Word32And(word32, Int32Constant(mask)),
2222 static_cast<int>(shift)); 2247 static_cast<int>(shift));
2223 } 2248 }
2224 2249
2225 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) { 2250 void CodeStubAssembler::SetCounter(StatsCounter* counter, int value) {
2226 if (FLAG_native_code_counters && counter->Enabled()) { 2251 if (FLAG_native_code_counters && counter->Enabled()) {
2227 Node* counter_address = ExternalConstant(ExternalReference(counter)); 2252 Node* counter_address = ExternalConstant(ExternalReference(counter));
2228 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address, 2253 StoreNoWriteBarrier(MachineRepresentation::kWord32, counter_address,
(...skipping 1983 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 Heap::kTheHoleValueRootIndex); 4237 Heap::kTheHoleValueRootIndex);
4213 4238
4214 // Store the WeakCell in the feedback vector. 4239 // Store the WeakCell in the feedback vector.
4215 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 4240 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER,
4216 CodeStubAssembler::SMI_PARAMETERS); 4241 CodeStubAssembler::SMI_PARAMETERS);
4217 return cell; 4242 return cell;
4218 } 4243 }
4219 4244
4220 } // namespace internal 4245 } // namespace internal
4221 } // namespace v8 4246 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698