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/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 2411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2422 MachineRepresentation::kWord16, result, | 2422 MachineRepresentation::kWord16, result, |
2423 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); | 2423 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); |
2424 var_result.Bind(result); | 2424 var_result.Bind(result); |
2425 Goto(&if_done); | 2425 Goto(&if_done); |
2426 } | 2426 } |
2427 | 2427 |
2428 Bind(&if_done); | 2428 Bind(&if_done); |
2429 return var_result.value(); | 2429 return var_result.value(); |
2430 } | 2430 } |
2431 | 2431 |
2432 Node* CodeStubAssembler::StringFromCodePoint(compiler::Node* codepoint, | |
2433 UnicodeEncoding encoding) { | |
2434 Variable var_result(this, MachineRepresentation::kTagged); | |
2435 var_result.Bind(EmptyStringConstant()); | |
2436 | |
2437 Label if_isword16(this), if_isword32(this), return_result(this); | |
2438 | |
2439 Branch(Uint32LessThan(codepoint, Int32Constant(0x10000)), &if_isword16, | |
2440 &if_isword32); | |
2441 | |
2442 Bind(&if_isword16); | |
2443 { | |
2444 var_result.Bind(StringFromCharCode(codepoint)); | |
2445 Goto(&return_result); | |
2446 } | |
2447 | |
2448 Bind(&if_isword32); | |
2449 { | |
2450 switch (encoding) { | |
2451 case UnicodeEncoding::UTF16: | |
2452 break; | |
2453 case UnicodeEncoding::UTF32: { | |
2454 // Convert UTF32 to UTF16 code units, and store as a 32 bit word. | |
2455 Node* lead_offset = Int32Constant(0xD800 - (0x10000 >> 10)); | |
2456 | |
2457 Node* lead = | |
2458 Int32Add(WordShr(codepoint, Int32Constant(10)), lead_offset); | |
2459 | |
2460 Node* trail = Int32Add(Word32And(codepoint, Int32Constant(0x3FF)), | |
2461 Int32Constant(0xDC00)); | |
2462 | |
2463 codepoint = Word32Or(WordShl(trail, Int32Constant(16)), lead); | |
Benedikt Meurer
2016/09/26 18:38:22
Nit: add explicit break for readability.
caitp
2016/09/27 08:55:57
Done, although clang-format complains unless I rea
caitp
2016/09/27 09:14:18
Actually, clang-format isn't happy even with the c
Benedikt Meurer
2016/09/27 09:16:02
I mean the keyword break, not a line break.
caitp
2016/09/27 09:20:41
Oh, I see. Haven't had much coffee yet this mornin
Benedikt Meurer
2016/09/27 09:52:38
Thanks!
Now grab a coffee. ;-)
| |
2464 } | |
2465 default: | |
Benedikt Meurer
2016/09/26 18:38:22
Don't add default here. The C++ compiler cannot fl
caitp
2016/09/27 08:55:57
Done.
| |
2466 UNREACHABLE(); | |
2467 } | |
2468 | |
2469 Node* value = AllocateSeqTwoByteString(2); | |
2470 StoreNoWriteBarrier( | |
2471 MachineRepresentation::kWord32, value, | |
2472 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), | |
2473 codepoint); | |
2474 var_result.Bind(value); | |
2475 Goto(&return_result); | |
2476 } | |
2477 | |
2478 Bind(&return_result); | |
2479 return var_result.value(); | |
2480 } | |
2481 | |
2432 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { | 2482 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { |
2433 Label runtime(this, Label::kDeferred); | 2483 Label runtime(this, Label::kDeferred); |
2434 Label end(this); | 2484 Label end(this); |
2435 | 2485 |
2436 Variable var_result(this, MachineRepresentation::kTagged); | 2486 Variable var_result(this, MachineRepresentation::kTagged); |
2437 | 2487 |
2438 // Check if string has a cached array index. | 2488 // Check if string has a cached array index. |
2439 Node* hash = LoadNameHashField(input); | 2489 Node* hash = LoadNameHashField(input); |
2440 Node* bit = | 2490 Node* bit = |
2441 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); | 2491 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); |
(...skipping 2732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5174 Heap::kTheHoleValueRootIndex); | 5224 Heap::kTheHoleValueRootIndex); |
5175 | 5225 |
5176 // Store the WeakCell in the feedback vector. | 5226 // Store the WeakCell in the feedback vector. |
5177 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 5227 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
5178 CodeStubAssembler::SMI_PARAMETERS); | 5228 CodeStubAssembler::SMI_PARAMETERS); |
5179 return cell; | 5229 return cell; |
5180 } | 5230 } |
5181 | 5231 |
5182 } // namespace internal | 5232 } // namespace internal |
5183 } // namespace v8 | 5233 } // namespace v8 |
OLD | NEW |