| 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 // lead = (codepoint >> 10) + LEAD_OFFSET | |
| 2458 Node* lead = | |
| 2459 Int32Add(WordShr(codepoint, Int32Constant(10)), lead_offset); | |
| 2460 | |
| 2461 // trail = (codepoint & 0x3FF) + 0xDC00; | |
| 2462 Node* trail = Int32Add(Word32And(codepoint, Int32Constant(0x3FF)), | |
| 2463 Int32Constant(0xDC00)); | |
| 2464 | |
| 2465 // codpoint = (trail << 16) | lead; | |
| 2466 codepoint = Word32Or(WordShl(trail, Int32Constant(16)), lead); | |
| 2467 break; | |
| 2468 } | |
| 2469 } | |
| 2470 | |
| 2471 Node* value = AllocateSeqTwoByteString(2); | |
| 2472 StoreNoWriteBarrier( | |
| 2473 MachineRepresentation::kWord32, value, | |
| 2474 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), | |
| 2475 codepoint); | |
| 2476 var_result.Bind(value); | |
| 2477 Goto(&return_result); | |
| 2478 } | |
| 2479 | |
| 2480 Bind(&return_result); | |
| 2481 return var_result.value(); | |
| 2482 } | |
| 2483 | |
| 2484 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { | 2432 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { |
| 2485 Label runtime(this, Label::kDeferred); | 2433 Label runtime(this, Label::kDeferred); |
| 2486 Label end(this); | 2434 Label end(this); |
| 2487 | 2435 |
| 2488 Variable var_result(this, MachineRepresentation::kTagged); | 2436 Variable var_result(this, MachineRepresentation::kTagged); |
| 2489 | 2437 |
| 2490 // Check if string has a cached array index. | 2438 // Check if string has a cached array index. |
| 2491 Node* hash = LoadNameHashField(input); | 2439 Node* hash = LoadNameHashField(input); |
| 2492 Node* bit = | 2440 Node* bit = |
| 2493 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); | 2441 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); |
| (...skipping 2895 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5389 Heap::kTheHoleValueRootIndex); | 5337 Heap::kTheHoleValueRootIndex); |
| 5390 | 5338 |
| 5391 // Store the WeakCell in the feedback vector. | 5339 // Store the WeakCell in the feedback vector. |
| 5392 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, | 5340 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, |
| 5393 CodeStubAssembler::SMI_PARAMETERS); | 5341 CodeStubAssembler::SMI_PARAMETERS); |
| 5394 return cell; | 5342 return cell; |
| 5395 } | 5343 } |
| 5396 | 5344 |
| 5397 } // namespace internal | 5345 } // namespace internal |
| 5398 } // namespace v8 | 5346 } // namespace v8 |
| OLD | NEW |