| 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 20 matching lines...) Expand all Loading... |
| 31 Label ok(this); | 31 Label ok(this); |
| 32 Comment("[ Assert"); | 32 Comment("[ Assert"); |
| 33 GotoIf(condition, &ok); | 33 GotoIf(condition, &ok); |
| 34 DebugBreak(); | 34 DebugBreak(); |
| 35 Goto(&ok); | 35 Goto(&ok); |
| 36 Bind(&ok); | 36 Bind(&ok); |
| 37 Comment("] Assert"); | 37 Comment("] Assert"); |
| 38 #endif | 38 #endif |
| 39 } | 39 } |
| 40 | 40 |
| 41 Node* CodeStubAssembler::NoContextConstant() { | 41 Node* CodeStubAssembler::NoContextConstant() { return SmiConstant(Smi::kZero); } |
| 42 return SmiConstant(Smi::FromInt(0)); | |
| 43 } | |
| 44 | 42 |
| 45 #define HEAP_CONSTANT_ACCESSOR(rootName, name) \ | 43 #define HEAP_CONSTANT_ACCESSOR(rootName, name) \ |
| 46 Node* CodeStubAssembler::name##Constant() { \ | 44 Node* CodeStubAssembler::name##Constant() { \ |
| 47 return LoadRoot(Heap::k##rootName##RootIndex); \ | 45 return LoadRoot(Heap::k##rootName##RootIndex); \ |
| 48 } | 46 } |
| 49 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR); | 47 HEAP_CONSTANT_LIST(HEAP_CONSTANT_ACCESSOR); |
| 50 #undef HEAP_CONSTANT_ACCESSOR | 48 #undef HEAP_CONSTANT_ACCESSOR |
| 51 | 49 |
| 52 #define HEAP_CONSTANT_TEST(rootName, name) \ | 50 #define HEAP_CONSTANT_TEST(rootName, name) \ |
| 53 Node* CodeStubAssembler::Is##name(Node* value) { \ | 51 Node* CodeStubAssembler::Is##name(Node* value) { \ |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 Variable result(this, MachineRepresentation::kTagged); | 605 Variable result(this, MachineRepresentation::kTagged); |
| 608 Label runtime_call(this, Label::kDeferred), no_runtime_call(this); | 606 Label runtime_call(this, Label::kDeferred), no_runtime_call(this); |
| 609 Label merge_runtime(this, &result); | 607 Label merge_runtime(this, &result); |
| 610 | 608 |
| 611 Node* new_top = IntPtrAdd(top, size_in_bytes); | 609 Node* new_top = IntPtrAdd(top, size_in_bytes); |
| 612 Branch(UintPtrGreaterThanOrEqual(new_top, limit), &runtime_call, | 610 Branch(UintPtrGreaterThanOrEqual(new_top, limit), &runtime_call, |
| 613 &no_runtime_call); | 611 &no_runtime_call); |
| 614 | 612 |
| 615 Bind(&runtime_call); | 613 Bind(&runtime_call); |
| 616 // AllocateInTargetSpace does not use the context. | 614 // AllocateInTargetSpace does not use the context. |
| 617 Node* context = SmiConstant(Smi::FromInt(0)); | 615 Node* context = SmiConstant(Smi::kZero); |
| 618 | 616 |
| 619 Node* runtime_result; | 617 Node* runtime_result; |
| 620 if (flags & kPretenured) { | 618 if (flags & kPretenured) { |
| 621 Node* runtime_flags = SmiConstant( | 619 Node* runtime_flags = SmiConstant( |
| 622 Smi::FromInt(AllocateDoubleAlignFlag::encode(false) | | 620 Smi::FromInt(AllocateDoubleAlignFlag::encode(false) | |
| 623 AllocateTargetSpace::encode(AllocationSpace::OLD_SPACE))); | 621 AllocateTargetSpace::encode(AllocationSpace::OLD_SPACE))); |
| 624 runtime_result = CallRuntime(Runtime::kAllocateInTargetSpace, context, | 622 runtime_result = CallRuntime(Runtime::kAllocateInTargetSpace, context, |
| 625 SmiTag(size_in_bytes), runtime_flags); | 623 SmiTag(size_in_bytes), runtime_flags); |
| 626 } else { | 624 } else { |
| 627 runtime_result = CallRuntime(Runtime::kAllocateInNewSpace, context, | 625 runtime_result = CallRuntime(Runtime::kAllocateInNewSpace, context, |
| (...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 | 1668 |
| 1671 void CodeStubAssembler::CopyStringCharacters(compiler::Node* from_string, | 1669 void CodeStubAssembler::CopyStringCharacters(compiler::Node* from_string, |
| 1672 compiler::Node* to_string, | 1670 compiler::Node* to_string, |
| 1673 compiler::Node* from_index, | 1671 compiler::Node* from_index, |
| 1674 compiler::Node* character_count, | 1672 compiler::Node* character_count, |
| 1675 String::Encoding encoding) { | 1673 String::Encoding encoding) { |
| 1676 Label out(this); | 1674 Label out(this); |
| 1677 | 1675 |
| 1678 // Nothing to do for zero characters. | 1676 // Nothing to do for zero characters. |
| 1679 | 1677 |
| 1680 GotoIf(SmiLessThanOrEqual(character_count, SmiConstant(Smi::FromInt(0))), | 1678 GotoIf(SmiLessThanOrEqual(character_count, SmiConstant(Smi::kZero)), &out); |
| 1681 &out); | |
| 1682 | 1679 |
| 1683 // Calculate offsets into the strings. | 1680 // Calculate offsets into the strings. |
| 1684 | 1681 |
| 1685 Node* from_offset; | 1682 Node* from_offset; |
| 1686 Node* limit_offset; | 1683 Node* limit_offset; |
| 1687 Node* to_offset; | 1684 Node* to_offset; |
| 1688 | 1685 |
| 1689 { | 1686 { |
| 1690 Node* byte_count = SmiUntag(character_count); | 1687 Node* byte_count = SmiUntag(character_count); |
| 1691 Node* from_byte_index = SmiUntag(from_index); | 1688 Node* from_byte_index = SmiUntag(from_index); |
| (...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2727 var_result.Bind(StringFromCharCode(char_code)); | 2724 var_result.Bind(StringFromCharCode(char_code)); |
| 2728 Goto(&end); | 2725 Goto(&end); |
| 2729 } | 2726 } |
| 2730 | 2727 |
| 2731 Bind(&original_string_or_invalid_length); | 2728 Bind(&original_string_or_invalid_length); |
| 2732 { | 2729 { |
| 2733 // Longer than original string's length or negative: unsafe arguments. | 2730 // Longer than original string's length or negative: unsafe arguments. |
| 2734 GotoIf(SmiAbove(substr_length, string_length), &runtime); | 2731 GotoIf(SmiAbove(substr_length, string_length), &runtime); |
| 2735 | 2732 |
| 2736 // Equal length - check if {from, to} == {0, str.length}. | 2733 // Equal length - check if {from, to} == {0, str.length}. |
| 2737 GotoIf(SmiAbove(from, SmiConstant(Smi::FromInt(0))), &runtime); | 2734 GotoIf(SmiAbove(from, SmiConstant(Smi::kZero)), &runtime); |
| 2738 | 2735 |
| 2739 // Return the original string (substr_length == string_length). | 2736 // Return the original string (substr_length == string_length). |
| 2740 | 2737 |
| 2741 Counters* counters = isolate()->counters(); | 2738 Counters* counters = isolate()->counters(); |
| 2742 IncrementCounter(counters->sub_string_native(), 1); | 2739 IncrementCounter(counters->sub_string_native(), 1); |
| 2743 | 2740 |
| 2744 var_result.Bind(string); | 2741 var_result.Bind(string); |
| 2745 Goto(&end); | 2742 Goto(&end); |
| 2746 } | 2743 } |
| 2747 | 2744 |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3048 | 3045 |
| 3049 Bind(&if_argisnotheapnumber); | 3046 Bind(&if_argisnotheapnumber); |
| 3050 { | 3047 { |
| 3051 // Need to convert {arg} to a Number first. | 3048 // Need to convert {arg} to a Number first. |
| 3052 Callable callable = CodeFactory::NonNumberToNumber(isolate()); | 3049 Callable callable = CodeFactory::NonNumberToNumber(isolate()); |
| 3053 var_arg.Bind(CallStub(callable, context, arg)); | 3050 var_arg.Bind(CallStub(callable, context, arg)); |
| 3054 Goto(&loop); | 3051 Goto(&loop); |
| 3055 } | 3052 } |
| 3056 | 3053 |
| 3057 Bind(&return_zero); | 3054 Bind(&return_zero); |
| 3058 var_arg.Bind(SmiConstant(Smi::FromInt(0))); | 3055 var_arg.Bind(SmiConstant(Smi::kZero)); |
| 3059 Goto(&out); | 3056 Goto(&out); |
| 3060 } | 3057 } |
| 3061 | 3058 |
| 3062 Bind(&out); | 3059 Bind(&out); |
| 3063 return var_arg.value(); | 3060 return var_arg.value(); |
| 3064 } | 3061 } |
| 3065 | 3062 |
| 3066 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, | 3063 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, |
| 3067 uint32_t mask) { | 3064 uint32_t mask) { |
| 3068 return Word32Shr(Word32And(word32, Int32Constant(mask)), | 3065 return Word32Shr(Word32And(word32, Int32Constant(mask)), |
| (...skipping 2571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5640 BranchIfWordEqual(current_js_object.value(), NullConstant(), use_cache, | 5637 BranchIfWordEqual(current_js_object.value(), NullConstant(), use_cache, |
| 5641 &next); | 5638 &next); |
| 5642 } | 5639 } |
| 5643 } | 5640 } |
| 5644 | 5641 |
| 5645 Bind(&next); | 5642 Bind(&next); |
| 5646 { | 5643 { |
| 5647 // For all objects but the receiver, check that the cache is empty. | 5644 // For all objects but the receiver, check that the cache is empty. |
| 5648 current_map.Bind(LoadMap(current_js_object.value())); | 5645 current_map.Bind(LoadMap(current_js_object.value())); |
| 5649 Node* enum_length = EnumLength(current_map.value()); | 5646 Node* enum_length = EnumLength(current_map.value()); |
| 5650 Node* zero_constant = SmiConstant(Smi::FromInt(0)); | 5647 Node* zero_constant = SmiConstant(Smi::kZero); |
| 5651 BranchIf(WordEqual(enum_length, zero_constant), &loop, use_runtime); | 5648 BranchIf(WordEqual(enum_length, zero_constant), &loop, use_runtime); |
| 5652 } | 5649 } |
| 5653 } | 5650 } |
| 5654 | 5651 |
| 5655 Node* CodeStubAssembler::CreateAllocationSiteInFeedbackVector( | 5652 Node* CodeStubAssembler::CreateAllocationSiteInFeedbackVector( |
| 5656 Node* feedback_vector, Node* slot) { | 5653 Node* feedback_vector, Node* slot) { |
| 5657 Node* size = IntPtrConstant(AllocationSite::kSize); | 5654 Node* size = IntPtrConstant(AllocationSite::kSize); |
| 5658 Node* site = Allocate(size, CodeStubAssembler::kPretenured); | 5655 Node* site = Allocate(size, CodeStubAssembler::kPretenured); |
| 5659 | 5656 |
| 5660 // Store the map | 5657 // Store the map |
| (...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7142 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); | 7139 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); |
| 7143 Goto(&end); | 7140 Goto(&end); |
| 7144 } | 7141 } |
| 7145 | 7142 |
| 7146 Bind(&end); | 7143 Bind(&end); |
| 7147 return result.value(); | 7144 return result.value(); |
| 7148 } | 7145 } |
| 7149 | 7146 |
| 7150 } // namespace internal | 7147 } // namespace internal |
| 7151 } // namespace v8 | 7148 } // namespace v8 |
| OLD | NEW |