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

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

Issue 2519093002: [cleanup] CodeStubAssembler: s/compiler::Node/Node/ (Closed)
Patch Set: rebased Created 4 years, 1 month 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 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
877 Node* value_map_undetectable = Word32And( 877 Node* value_map_undetectable = Word32And(
878 value_map_bitfield, Int32Constant(1 << Map::kIsUndetectable)); 878 value_map_bitfield, Int32Constant(1 << Map::kIsUndetectable));
879 879
880 // Check if the {value} is undetectable. 880 // Check if the {value} is undetectable.
881 Branch(Word32Equal(value_map_undetectable, Int32Constant(0)), if_true, 881 Branch(Word32Equal(value_map_undetectable, Int32Constant(0)), if_true,
882 if_false); 882 if_false);
883 } 883 }
884 } 884 }
885 } 885 }
886 886
887 compiler::Node* CodeStubAssembler::LoadFromFrame(int offset, MachineType rep) { 887 Node* CodeStubAssembler::LoadFromFrame(int offset, MachineType rep) {
888 Node* frame_pointer = LoadFramePointer(); 888 Node* frame_pointer = LoadFramePointer();
889 return Load(rep, frame_pointer, IntPtrConstant(offset)); 889 return Load(rep, frame_pointer, IntPtrConstant(offset));
890 } 890 }
891 891
892 compiler::Node* CodeStubAssembler::LoadFromParentFrame(int offset, 892 Node* CodeStubAssembler::LoadFromParentFrame(int offset, MachineType rep) {
893 MachineType rep) {
894 Node* frame_pointer = LoadParentFramePointer(); 893 Node* frame_pointer = LoadParentFramePointer();
895 return Load(rep, frame_pointer, IntPtrConstant(offset)); 894 return Load(rep, frame_pointer, IntPtrConstant(offset));
896 } 895 }
897 896
898 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset, 897 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
899 MachineType rep) { 898 MachineType rep) {
900 return Load(rep, buffer, IntPtrConstant(offset)); 899 return Load(rep, buffer, IntPtrConstant(offset));
901 } 900 }
902 901
903 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset, 902 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset,
(...skipping 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after
2069 Bind(&next_iter); 2068 Bind(&next_iter);
2070 Node* compare = WordNotEqual(from_offset, limit_offset); 2069 Node* compare = WordNotEqual(from_offset, limit_offset);
2071 Branch(compare, &decrement, &done); 2070 Branch(compare, &decrement, &done);
2072 } 2071 }
2073 2072
2074 Bind(&done); 2073 Bind(&done);
2075 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1); 2074 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1);
2076 Comment("] CopyFixedArrayElements"); 2075 Comment("] CopyFixedArrayElements");
2077 } 2076 }
2078 2077
2079 void CodeStubAssembler::CopyStringCharacters( 2078 void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
2080 compiler::Node* from_string, compiler::Node* to_string, 2079 Node* from_index, Node* to_index,
2081 compiler::Node* from_index, compiler::Node* to_index, 2080 Node* character_count,
2082 compiler::Node* character_count, String::Encoding from_encoding, 2081 String::Encoding from_encoding,
2083 String::Encoding to_encoding, ParameterMode mode) { 2082 String::Encoding to_encoding,
2083 ParameterMode mode) {
2084 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING; 2084 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING;
2085 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING; 2085 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING;
2086 DCHECK_IMPLIES(to_one_byte, from_one_byte); 2086 DCHECK_IMPLIES(to_one_byte, from_one_byte);
2087 Comment("CopyStringCharacters %s -> %s", 2087 Comment("CopyStringCharacters %s -> %s",
2088 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING", 2088 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING",
2089 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING"); 2089 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING");
2090 2090
2091 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; 2091 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS;
2092 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; 2092 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS;
2093 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize); 2093 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize);
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2232 // The size-check above guarantees that the |new_elements| is allocated 2232 // The size-check above guarantees that the |new_elements| is allocated
2233 // in new space so we can skip the write barrier. 2233 // in new space so we can skip the write barrier.
2234 CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity, 2234 CopyFixedArrayElements(from_kind, elements, to_kind, new_elements, capacity,
2235 new_capacity, SKIP_WRITE_BARRIER, mode); 2235 new_capacity, SKIP_WRITE_BARRIER, mode);
2236 2236
2237 StoreObjectField(object, JSObject::kElementsOffset, new_elements); 2237 StoreObjectField(object, JSObject::kElementsOffset, new_elements);
2238 Comment("] GrowElementsCapacity"); 2238 Comment("] GrowElementsCapacity");
2239 return new_elements; 2239 return new_elements;
2240 } 2240 }
2241 2241
2242 void CodeStubAssembler::InitializeAllocationMemento( 2242 void CodeStubAssembler::InitializeAllocationMemento(Node* base_allocation,
2243 compiler::Node* base_allocation, int base_allocation_size, 2243 int base_allocation_size,
2244 compiler::Node* allocation_site) { 2244 Node* allocation_site) {
2245 StoreObjectFieldNoWriteBarrier( 2245 StoreObjectFieldNoWriteBarrier(
2246 base_allocation, AllocationMemento::kMapOffset + base_allocation_size, 2246 base_allocation, AllocationMemento::kMapOffset + base_allocation_size,
2247 HeapConstant(Handle<Map>(isolate()->heap()->allocation_memento_map()))); 2247 HeapConstant(Handle<Map>(isolate()->heap()->allocation_memento_map())));
2248 StoreObjectFieldNoWriteBarrier( 2248 StoreObjectFieldNoWriteBarrier(
2249 base_allocation, 2249 base_allocation,
2250 AllocationMemento::kAllocationSiteOffset + base_allocation_size, 2250 AllocationMemento::kAllocationSiteOffset + base_allocation_size,
2251 allocation_site); 2251 allocation_site);
2252 if (FLAG_allocation_site_pretenuring) { 2252 if (FLAG_allocation_site_pretenuring) {
2253 Node* count = LoadObjectField(allocation_site, 2253 Node* count = LoadObjectField(allocation_site,
2254 AllocationSite::kPretenureCreateCountOffset); 2254 AllocationSite::kPretenureCreateCountOffset);
(...skipping 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after
3435 Node* const result = 3435 Node* const result =
3436 CallRuntime(Runtime::kStringIndexOf, context, string, pattern, from); 3436 CallRuntime(Runtime::kStringIndexOf, context, string, pattern, from);
3437 var_result.Bind(result); 3437 var_result.Bind(result);
3438 Goto(&out); 3438 Goto(&out);
3439 } 3439 }
3440 3440
3441 Bind(&out); 3441 Bind(&out);
3442 return var_result.value(); 3442 return var_result.value();
3443 } 3443 }
3444 3444
3445 Node* CodeStubAssembler::StringFromCodePoint(compiler::Node* codepoint, 3445 Node* CodeStubAssembler::StringFromCodePoint(Node* codepoint,
3446 UnicodeEncoding encoding) { 3446 UnicodeEncoding encoding) {
3447 Variable var_result(this, MachineRepresentation::kTagged); 3447 Variable var_result(this, MachineRepresentation::kTagged);
3448 var_result.Bind(EmptyStringConstant()); 3448 var_result.Bind(EmptyStringConstant());
3449 3449
3450 Label if_isword16(this), if_isword32(this), return_result(this); 3450 Label if_isword16(this), if_isword32(this), return_result(this);
3451 3451
3452 Branch(Uint32LessThan(codepoint, Int32Constant(0x10000)), &if_isword16, 3452 Branch(Uint32LessThan(codepoint, Int32Constant(0x10000)), &if_isword16,
3453 &if_isword32); 3453 &if_isword32);
3454 3454
3455 Bind(&if_isword16); 3455 Bind(&if_isword16);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
3513 Bind(&runtime); 3513 Bind(&runtime);
3514 { 3514 {
3515 var_result.Bind(CallRuntime(Runtime::kStringToNumber, context, input)); 3515 var_result.Bind(CallRuntime(Runtime::kStringToNumber, context, input));
3516 Goto(&end); 3516 Goto(&end);
3517 } 3517 }
3518 3518
3519 Bind(&end); 3519 Bind(&end);
3520 return var_result.value(); 3520 return var_result.value();
3521 } 3521 }
3522 3522
3523 Node* CodeStubAssembler::NumberToString(compiler::Node* context, 3523 Node* CodeStubAssembler::NumberToString(Node* context, Node* argument) {
3524 compiler::Node* argument) {
3525 Variable result(this, MachineRepresentation::kTagged); 3524 Variable result(this, MachineRepresentation::kTagged);
3526 Label runtime(this, Label::kDeferred); 3525 Label runtime(this, Label::kDeferred);
3527 Label smi(this); 3526 Label smi(this);
3528 Label done(this, &result); 3527 Label done(this, &result);
3529 3528
3530 // Load the number string cache. 3529 // Load the number string cache.
3531 Node* number_string_cache = LoadRoot(Heap::kNumberStringCacheRootIndex); 3530 Node* number_string_cache = LoadRoot(Heap::kNumberStringCacheRootIndex);
3532 3531
3533 // Make the hash mask from the length of the number string cache. It 3532 // Make the hash mask from the length of the number string cache. It
3534 // contains two elements (number and string) for each cache entry. 3533 // contains two elements (number and string) for each cache entry.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3593 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index, 3592 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index,
3594 kPointerSize, SMI_PARAMETERS)); 3593 kPointerSize, SMI_PARAMETERS));
3595 Goto(&done); 3594 Goto(&done);
3596 } 3595 }
3597 3596
3598 Bind(&done); 3597 Bind(&done);
3599 return result.value(); 3598 return result.value();
3600 } 3599 }
3601 3600
3602 Node* CodeStubAssembler::ToName(Node* context, Node* value) { 3601 Node* CodeStubAssembler::ToName(Node* context, Node* value) {
3603 typedef CodeStubAssembler::Label Label;
3604 typedef CodeStubAssembler::Variable Variable;
3605
3606 Label end(this); 3602 Label end(this);
3607 Variable var_result(this, MachineRepresentation::kTagged); 3603 Variable var_result(this, MachineRepresentation::kTagged);
3608 3604
3609 Label is_number(this); 3605 Label is_number(this);
3610 GotoIf(TaggedIsSmi(value), &is_number); 3606 GotoIf(TaggedIsSmi(value), &is_number);
3611 3607
3612 Label not_name(this); 3608 Label not_name(this);
3613 Node* value_instance_type = LoadInstanceType(value); 3609 Node* value_instance_type = LoadInstanceType(value);
3614 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE); 3610 STATIC_ASSERT(FIRST_NAME_TYPE == FIRST_TYPE);
3615 GotoIf(Int32GreaterThan(value_instance_type, Int32Constant(LAST_NAME_TYPE)), 3611 GotoIf(Int32GreaterThan(value_instance_type, Int32Constant(LAST_NAME_TYPE)),
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after
4419 if_bailout); 4415 if_bailout);
4420 4416
4421 Node* dictionary = LoadProperties(object); 4417 Node* dictionary = LoadProperties(object);
4422 var_meta_storage->Bind(dictionary); 4418 var_meta_storage->Bind(dictionary);
4423 4419
4424 NameDictionaryLookup<GlobalDictionary>( 4420 NameDictionaryLookup<GlobalDictionary>(
4425 dictionary, unique_name, if_found_global, var_name_index, if_not_found); 4421 dictionary, unique_name, if_found_global, var_name_index, if_not_found);
4426 } 4422 }
4427 } 4423 }
4428 4424
4429 void CodeStubAssembler::TryHasOwnProperty(compiler::Node* object, 4425 void CodeStubAssembler::TryHasOwnProperty(Node* object, Node* map,
4430 compiler::Node* map, 4426 Node* instance_type,
4431 compiler::Node* instance_type, 4427 Node* unique_name, Label* if_found,
4432 compiler::Node* unique_name, 4428 Label* if_not_found,
4433 Label* if_found, Label* if_not_found,
4434 Label* if_bailout) { 4429 Label* if_bailout) {
4435 Comment("TryHasOwnProperty"); 4430 Comment("TryHasOwnProperty");
4436 Variable var_meta_storage(this, MachineRepresentation::kTagged); 4431 Variable var_meta_storage(this, MachineRepresentation::kTagged);
4437 Variable var_name_index(this, MachineType::PointerRepresentation()); 4432 Variable var_name_index(this, MachineType::PointerRepresentation());
4438 4433
4439 Label if_found_global(this); 4434 Label if_found_global(this);
4440 TryLookupProperty(object, map, instance_type, unique_name, if_found, if_found, 4435 TryLookupProperty(object, map, instance_type, unique_name, if_found, if_found,
4441 &if_found_global, &var_meta_storage, &var_name_index, 4436 &if_found_global, &var_meta_storage, &var_name_index,
4442 if_not_found, if_bailout); 4437 if_not_found, if_bailout);
4443 Bind(&if_found_global); 4438 Bind(&if_found_global);
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
5055 // Fallback to the runtime implementation. 5050 // Fallback to the runtime implementation.
5056 var_result.Bind( 5051 var_result.Bind(
5057 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object)); 5052 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object));
5058 } 5053 }
5059 Goto(&return_result); 5054 Goto(&return_result);
5060 5055
5061 Bind(&return_result); 5056 Bind(&return_result);
5062 return var_result.value(); 5057 return var_result.value();
5063 } 5058 }
5064 5059
5065 compiler::Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node, 5060 Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node,
5066 ElementsKind kind, 5061 ElementsKind kind,
5067 ParameterMode mode, 5062 ParameterMode mode,
5068 int base_size) { 5063 int base_size) {
5069 int element_size_shift = ElementsKindToShiftSize(kind); 5064 int element_size_shift = ElementsKindToShiftSize(kind);
5070 int element_size = 1 << element_size_shift; 5065 int element_size = 1 << element_size_shift;
5071 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize; 5066 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
5072 intptr_t index = 0; 5067 intptr_t index = 0;
5073 bool constant_index = false; 5068 bool constant_index = false;
5074 if (mode == SMI_PARAMETERS) { 5069 if (mode == SMI_PARAMETERS) {
5075 element_size_shift -= kSmiShiftBits; 5070 element_size_shift -= kSmiShiftBits;
5076 Smi* smi_index; 5071 Smi* smi_index;
5077 constant_index = ToSmiConstant(index_node, smi_index); 5072 constant_index = ToSmiConstant(index_node, smi_index);
5078 if (constant_index) index = smi_index->value(); 5073 if (constant_index) index = smi_index->value();
(...skipping 15 matching lines...) Expand all
5094 5089
5095 Node* shifted_index = 5090 Node* shifted_index =
5096 (element_size_shift == 0) 5091 (element_size_shift == 0)
5097 ? index_node 5092 ? index_node
5098 : ((element_size_shift > 0) 5093 : ((element_size_shift > 0)
5099 ? WordShl(index_node, IntPtrConstant(element_size_shift)) 5094 ? WordShl(index_node, IntPtrConstant(element_size_shift))
5100 : WordShr(index_node, IntPtrConstant(-element_size_shift))); 5095 : WordShr(index_node, IntPtrConstant(-element_size_shift)));
5101 return IntPtrAddFoldConstants(IntPtrConstant(base_size), shifted_index); 5096 return IntPtrAddFoldConstants(IntPtrConstant(base_size), shifted_index);
5102 } 5097 }
5103 5098
5104 compiler::Node* CodeStubAssembler::LoadTypeFeedbackVectorForStub() { 5099 Node* CodeStubAssembler::LoadTypeFeedbackVectorForStub() {
5105 Node* function = 5100 Node* function =
5106 LoadFromParentFrame(JavaScriptFrameConstants::kFunctionOffset); 5101 LoadFromParentFrame(JavaScriptFrameConstants::kFunctionOffset);
5107 Node* literals = LoadObjectField(function, JSFunction::kLiteralsOffset); 5102 Node* literals = LoadObjectField(function, JSFunction::kLiteralsOffset);
5108 return LoadObjectField(literals, LiteralsArray::kFeedbackVectorOffset); 5103 return LoadObjectField(literals, LiteralsArray::kFeedbackVectorOffset);
5109 } 5104 }
5110 5105
5111 void CodeStubAssembler::UpdateFeedback(compiler::Node* feedback, 5106 void CodeStubAssembler::UpdateFeedback(Node* feedback,
5112 compiler::Node* type_feedback_vector, 5107 Node* type_feedback_vector,
5113 compiler::Node* slot_id) { 5108 Node* slot_id) {
5114 // This method is used for binary op and compare feedback. These 5109 // This method is used for binary op and compare feedback. These
5115 // vector nodes are initialized with a smi 0, so we can simply OR 5110 // vector nodes are initialized with a smi 0, so we can simply OR
5116 // our new feedback in place. 5111 // our new feedback in place.
5117 // TODO(interpreter): Consider passing the feedback as Smi already to avoid 5112 // TODO(interpreter): Consider passing the feedback as Smi already to avoid
5118 // the tagging completely. 5113 // the tagging completely.
5119 Node* previous_feedback = 5114 Node* previous_feedback =
5120 LoadFixedArrayElement(type_feedback_vector, slot_id); 5115 LoadFixedArrayElement(type_feedback_vector, slot_id);
5121 Node* combined_feedback = SmiOr(previous_feedback, SmiFromWord32(feedback)); 5116 Node* combined_feedback = SmiOr(previous_feedback, SmiFromWord32(feedback));
5122 StoreFixedArrayElement(type_feedback_vector, slot_id, combined_feedback, 5117 StoreFixedArrayElement(type_feedback_vector, slot_id, combined_feedback,
5123 SKIP_WRITE_BARRIER); 5118 SKIP_WRITE_BARRIER);
5124 } 5119 }
5125 5120
5126 compiler::Node* CodeStubAssembler::LoadReceiverMap(compiler::Node* receiver) { 5121 Node* CodeStubAssembler::LoadReceiverMap(Node* receiver) {
5127 Variable var_receiver_map(this, MachineRepresentation::kTagged); 5122 Variable var_receiver_map(this, MachineRepresentation::kTagged);
5128 Label load_smi_map(this, Label::kDeferred), load_receiver_map(this), 5123 Label load_smi_map(this, Label::kDeferred), load_receiver_map(this),
5129 if_result(this); 5124 if_result(this);
5130 5125
5131 Branch(TaggedIsSmi(receiver), &load_smi_map, &load_receiver_map); 5126 Branch(TaggedIsSmi(receiver), &load_smi_map, &load_receiver_map);
5132 Bind(&load_smi_map); 5127 Bind(&load_smi_map);
5133 { 5128 {
5134 var_receiver_map.Bind(LoadRoot(Heap::kHeapNumberMapRootIndex)); 5129 var_receiver_map.Bind(LoadRoot(Heap::kHeapNumberMapRootIndex));
5135 Goto(&if_result); 5130 Goto(&if_result);
5136 } 5131 }
(...skipping 23 matching lines...) Expand all
5160 Bind(&key_is_smi); 5155 Bind(&key_is_smi);
5161 { 5156 {
5162 var_intptr_key.Bind(SmiUntag(key)); 5157 var_intptr_key.Bind(SmiUntag(key));
5163 Goto(&done); 5158 Goto(&done);
5164 } 5159 }
5165 5160
5166 Bind(&done); 5161 Bind(&done);
5167 return var_intptr_key.value(); 5162 return var_intptr_key.value();
5168 } 5163 }
5169 5164
5170 void CodeStubAssembler::ExtendPropertiesBackingStore(compiler::Node* object) { 5165 void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) {
5171 Node* properties = LoadProperties(object); 5166 Node* properties = LoadProperties(object);
5172 Node* length = LoadFixedArrayBaseLength(properties); 5167 Node* length = LoadFixedArrayBaseLength(properties);
5173 5168
5174 ParameterMode mode = OptimalParameterMode(); 5169 ParameterMode mode = OptimalParameterMode();
5175 length = UntagParameter(length, mode); 5170 length = UntagParameter(length, mode);
5176 5171
5177 Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode); 5172 Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode);
5178 Node* new_capacity = IntPtrAdd(length, delta); 5173 Node* new_capacity = IntPtrAdd(length, delta);
5179 5174
5180 // Grow properties array. 5175 // Grow properties array.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
5614 length, capacity, mode, bailout); 5609 length, capacity, mode, bailout);
5615 5610
5616 new_elements_var.Bind(new_elements); 5611 new_elements_var.Bind(new_elements);
5617 Goto(&done); 5612 Goto(&done);
5618 } 5613 }
5619 5614
5620 Bind(&done); 5615 Bind(&done);
5621 return new_elements_var.value(); 5616 return new_elements_var.value();
5622 } 5617 }
5623 5618
5624 void CodeStubAssembler::TransitionElementsKind( 5619 void CodeStubAssembler::TransitionElementsKind(Node* object, Node* map,
5625 compiler::Node* object, compiler::Node* map, ElementsKind from_kind, 5620 ElementsKind from_kind,
5626 ElementsKind to_kind, bool is_jsarray, Label* bailout) { 5621 ElementsKind to_kind,
5622 bool is_jsarray,
5623 Label* bailout) {
5627 DCHECK(!IsFastHoleyElementsKind(from_kind) || 5624 DCHECK(!IsFastHoleyElementsKind(from_kind) ||
5628 IsFastHoleyElementsKind(to_kind)); 5625 IsFastHoleyElementsKind(to_kind));
5629 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { 5626 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) {
5630 TrapAllocationMemento(object, bailout); 5627 TrapAllocationMemento(object, bailout);
5631 } 5628 }
5632 5629
5633 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { 5630 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) {
5634 Comment("Non-simple map transition"); 5631 Comment("Non-simple map transition");
5635 Node* elements = LoadElements(object); 5632 Node* elements = LoadElements(object);
5636 5633
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
5879 body(this, var.value()); 5876 body(this, var.value());
5880 if (mode == IndexAdvanceMode::kPost) { 5877 if (mode == IndexAdvanceMode::kPost) {
5881 var.Bind(IntPtrAdd(var.value(), IntPtrConstant(increment))); 5878 var.Bind(IntPtrAdd(var.value(), IntPtrConstant(increment)));
5882 } 5879 }
5883 Branch(WordNotEqual(var.value(), end_index), &loop, &after_loop); 5880 Branch(WordNotEqual(var.value(), end_index), &loop, &after_loop);
5884 } 5881 }
5885 Bind(&after_loop); 5882 Bind(&after_loop);
5886 } 5883 }
5887 5884
5888 void CodeStubAssembler::BuildFastFixedArrayForEach( 5885 void CodeStubAssembler::BuildFastFixedArrayForEach(
5889 compiler::Node* fixed_array, ElementsKind kind, 5886 Node* fixed_array, ElementsKind kind, Node* first_element_inclusive,
5890 compiler::Node* first_element_inclusive, 5887 Node* last_element_exclusive,
5891 compiler::Node* last_element_exclusive, 5888 std::function<void(CodeStubAssembler* assembler, Node* fixed_array,
5892 std::function<void(CodeStubAssembler* assembler, 5889 Node* offset)>
5893 compiler::Node* fixed_array, compiler::Node* offset)>
5894 body, 5890 body,
5895 ParameterMode mode, ForEachDirection direction) { 5891 ParameterMode mode, ForEachDirection direction) {
5896 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); 5892 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
5897 int32_t first_val; 5893 int32_t first_val;
5898 bool constant_first = ToInt32Constant(first_element_inclusive, first_val); 5894 bool constant_first = ToInt32Constant(first_element_inclusive, first_val);
5899 int32_t last_val; 5895 int32_t last_val;
5900 bool constent_last = ToInt32Constant(last_element_exclusive, last_val); 5896 bool constent_last = ToInt32Constant(last_element_exclusive, last_val);
5901 if (constant_first && constent_last) { 5897 if (constant_first && constent_last) {
5902 int delta = last_val - first_val; 5898 int delta = last_val - first_val;
5903 DCHECK(delta >= 0); 5899 DCHECK(delta >= 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5936 MachineType::PointerRepresentation(), start, limit, 5932 MachineType::PointerRepresentation(), start, limit,
5937 [fixed_array, body](CodeStubAssembler* assembler, Node* offset) { 5933 [fixed_array, body](CodeStubAssembler* assembler, Node* offset) {
5938 body(assembler, fixed_array, offset); 5934 body(assembler, fixed_array, offset);
5939 }, 5935 },
5940 direction == ForEachDirection::kReverse ? -increment : increment, 5936 direction == ForEachDirection::kReverse ? -increment : increment,
5941 direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre 5937 direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre
5942 : IndexAdvanceMode::kPost); 5938 : IndexAdvanceMode::kPost);
5943 } 5939 }
5944 5940
5945 void CodeStubAssembler::BranchIfNumericRelationalComparison( 5941 void CodeStubAssembler::BranchIfNumericRelationalComparison(
5946 RelationalComparisonMode mode, compiler::Node* lhs, compiler::Node* rhs, 5942 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true,
5947 Label* if_true, Label* if_false) { 5943 Label* if_false) {
5948 typedef compiler::Node Node;
5949
5950 Label end(this); 5944 Label end(this);
5951 Variable result(this, MachineRepresentation::kTagged); 5945 Variable result(this, MachineRepresentation::kTagged);
5952 5946
5953 // Shared entry for floating point comparison. 5947 // Shared entry for floating point comparison.
5954 Label do_fcmp(this); 5948 Label do_fcmp(this);
5955 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 5949 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
5956 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 5950 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
5957 5951
5958 // Check if the {lhs} is a Smi or a HeapObject. 5952 // Check if the {lhs} is a Smi or a HeapObject.
5959 Label if_lhsissmi(this), if_lhsisnotsmi(this); 5953 Label if_lhsissmi(this), if_lhsisnotsmi(this);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6041 case kGreaterThan: 6035 case kGreaterThan:
6042 Branch(Float64GreaterThan(lhs, rhs), if_true, if_false); 6036 Branch(Float64GreaterThan(lhs, rhs), if_true, if_false);
6043 break; 6037 break;
6044 case kGreaterThanOrEqual: 6038 case kGreaterThanOrEqual:
6045 Branch(Float64GreaterThanOrEqual(lhs, rhs), if_true, if_false); 6039 Branch(Float64GreaterThanOrEqual(lhs, rhs), if_true, if_false);
6046 break; 6040 break;
6047 } 6041 }
6048 } 6042 }
6049 } 6043 }
6050 6044
6051 void CodeStubAssembler::GotoUnlessNumberLessThan(compiler::Node* lhs, 6045 void CodeStubAssembler::GotoUnlessNumberLessThan(Node* lhs, Node* rhs,
6052 compiler::Node* rhs,
6053 Label* if_false) { 6046 Label* if_false) {
6054 Label if_true(this); 6047 Label if_true(this);
6055 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false); 6048 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false);
6056 Bind(&if_true); 6049 Bind(&if_true);
6057 } 6050 }
6058 6051
6059 compiler::Node* CodeStubAssembler::RelationalComparison( 6052 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
6060 RelationalComparisonMode mode, compiler::Node* lhs, compiler::Node* rhs, 6053 Node* lhs, Node* rhs,
6061 compiler::Node* context) { 6054 Node* context) {
6062 typedef compiler::Node Node;
6063
6064 Label return_true(this), return_false(this), end(this); 6055 Label return_true(this), return_false(this), end(this);
6065 Variable result(this, MachineRepresentation::kTagged); 6056 Variable result(this, MachineRepresentation::kTagged);
6066 6057
6067 // Shared entry for floating point comparison. 6058 // Shared entry for floating point comparison.
6068 Label do_fcmp(this); 6059 Label do_fcmp(this);
6069 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 6060 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
6070 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 6061 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
6071 6062
6072 // We might need to loop several times due to ToPrimitive and/or ToNumber 6063 // We might need to loop several times due to ToPrimitive and/or ToNumber
6073 // conversions. 6064 // conversions.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
6374 result.Bind(BooleanConstant(false)); 6365 result.Bind(BooleanConstant(false));
6375 Goto(&end); 6366 Goto(&end);
6376 } 6367 }
6377 6368
6378 Bind(&end); 6369 Bind(&end);
6379 return result.value(); 6370 return result.value();
6380 } 6371 }
6381 6372
6382 namespace { 6373 namespace {
6383 6374
6384 void GenerateEqual_Same(CodeStubAssembler* assembler, compiler::Node* value, 6375 void GenerateEqual_Same(CodeStubAssembler* assembler, Node* value,
6385 CodeStubAssembler::Label* if_equal, 6376 CodeStubAssembler::Label* if_equal,
6386 CodeStubAssembler::Label* if_notequal) { 6377 CodeStubAssembler::Label* if_notequal) {
6387 // In case of abstract or strict equality checks, we need additional checks 6378 // In case of abstract or strict equality checks, we need additional checks
6388 // for NaN values because they are not considered equal, even if both the 6379 // for NaN values because they are not considered equal, even if both the
6389 // left and the right hand side reference exactly the same value. 6380 // left and the right hand side reference exactly the same value.
6390 // TODO(bmeurer): This seems to violate the SIMD.js specification, but it 6381 // TODO(bmeurer): This seems to violate the SIMD.js specification, but it
6391 // seems to be what is tested in the current SIMD.js testsuite. 6382 // seems to be what is tested in the current SIMD.js testsuite.
6392 6383
6393 typedef CodeStubAssembler::Label Label; 6384 typedef CodeStubAssembler::Label Label;
6394 typedef compiler::Node Node;
6395 6385
6396 // Check if {value} is a Smi or a HeapObject. 6386 // Check if {value} is a Smi or a HeapObject.
6397 Label if_valueissmi(assembler), if_valueisnotsmi(assembler); 6387 Label if_valueissmi(assembler), if_valueisnotsmi(assembler);
6398 assembler->Branch(assembler->TaggedIsSmi(value), &if_valueissmi, 6388 assembler->Branch(assembler->TaggedIsSmi(value), &if_valueissmi,
6399 &if_valueisnotsmi); 6389 &if_valueisnotsmi);
6400 6390
6401 assembler->Bind(&if_valueisnotsmi); 6391 assembler->Bind(&if_valueisnotsmi);
6402 { 6392 {
6403 // Load the map of {value}. 6393 // Load the map of {value}.
6404 Node* value_map = assembler->LoadMap(value); 6394 Node* value_map = assembler->LoadMap(value);
(...skipping 14 matching lines...) Expand all
6419 6409
6420 assembler->Bind(&if_valueisnotnumber); 6410 assembler->Bind(&if_valueisnotnumber);
6421 assembler->Goto(if_equal); 6411 assembler->Goto(if_equal);
6422 } 6412 }
6423 6413
6424 assembler->Bind(&if_valueissmi); 6414 assembler->Bind(&if_valueissmi);
6425 assembler->Goto(if_equal); 6415 assembler->Goto(if_equal);
6426 } 6416 }
6427 6417
6428 void GenerateEqual_Simd128Value_HeapObject( 6418 void GenerateEqual_Simd128Value_HeapObject(
6429 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, 6419 CodeStubAssembler* assembler, Node* lhs, Node* lhs_map, Node* rhs,
6430 compiler::Node* rhs, compiler::Node* rhs_map, 6420 Node* rhs_map, CodeStubAssembler::Label* if_equal,
6431 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { 6421 CodeStubAssembler::Label* if_notequal) {
6432 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal, 6422 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal,
6433 if_notequal); 6423 if_notequal);
6434 } 6424 }
6435 6425
6436 } // namespace 6426 } // namespace
6437 6427
6438 // ES6 section 7.2.12 Abstract Equality Comparison 6428 // ES6 section 7.2.12 Abstract Equality Comparison
6439 compiler::Node* CodeStubAssembler::Equal(ResultMode mode, compiler::Node* lhs, 6429 Node* CodeStubAssembler::Equal(ResultMode mode, Node* lhs, Node* rhs,
6440 compiler::Node* rhs, 6430 Node* context) {
6441 compiler::Node* context) {
6442 // This is a slightly optimized version of Object::Equals represented as 6431 // This is a slightly optimized version of Object::Equals represented as
6443 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you 6432 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you
6444 // change something functionality wise in here, remember to update the 6433 // change something functionality wise in here, remember to update the
6445 // Object::Equals method as well. 6434 // Object::Equals method as well.
6446 typedef compiler::Node Node;
6447 6435
6448 Label if_equal(this), if_notequal(this), 6436 Label if_equal(this), if_notequal(this),
6449 do_rhsstringtonumber(this, Label::kDeferred), end(this); 6437 do_rhsstringtonumber(this, Label::kDeferred), end(this);
6450 Variable result(this, MachineRepresentation::kTagged); 6438 Variable result(this, MachineRepresentation::kTagged);
6451 6439
6452 // Shared entry for floating point comparison. 6440 // Shared entry for floating point comparison.
6453 Label do_fcmp(this); 6441 Label do_fcmp(this);
6454 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 6442 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
6455 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 6443 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
6456 6444
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6930 Bind(&if_notequal); 6918 Bind(&if_notequal);
6931 { 6919 {
6932 result.Bind(BooleanConstant(mode == kNegateResult)); 6920 result.Bind(BooleanConstant(mode == kNegateResult));
6933 Goto(&end); 6921 Goto(&end);
6934 } 6922 }
6935 6923
6936 Bind(&end); 6924 Bind(&end);
6937 return result.value(); 6925 return result.value();
6938 } 6926 }
6939 6927
6940 compiler::Node* CodeStubAssembler::StrictEqual(ResultMode mode, 6928 Node* CodeStubAssembler::StrictEqual(ResultMode mode, Node* lhs, Node* rhs,
6941 compiler::Node* lhs, 6929 Node* context) {
6942 compiler::Node* rhs,
6943 compiler::Node* context) {
6944 // Here's pseudo-code for the algorithm below in case of kDontNegateResult 6930 // Here's pseudo-code for the algorithm below in case of kDontNegateResult
6945 // mode; for kNegateResult mode we properly negate the result. 6931 // mode; for kNegateResult mode we properly negate the result.
6946 // 6932 //
6947 // if (lhs == rhs) { 6933 // if (lhs == rhs) {
6948 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN; 6934 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN;
6949 // return true; 6935 // return true;
6950 // } 6936 // }
6951 // if (!lhs->IsSmi()) { 6937 // if (!lhs->IsSmi()) {
6952 // if (lhs->IsHeapNumber()) { 6938 // if (lhs->IsHeapNumber()) {
6953 // if (rhs->IsSmi()) { 6939 // if (rhs->IsSmi()) {
(...skipping 28 matching lines...) Expand all
6982 // return false; 6968 // return false;
6983 // } else { 6969 // } else {
6984 // if (rhs->IsHeapNumber()) { 6970 // if (rhs->IsHeapNumber()) {
6985 // return Smi::cast(lhs)->value() == HeapNumber::cast(rhs)->value(); 6971 // return Smi::cast(lhs)->value() == HeapNumber::cast(rhs)->value();
6986 // } else { 6972 // } else {
6987 // return false; 6973 // return false;
6988 // } 6974 // }
6989 // } 6975 // }
6990 // } 6976 // }
6991 6977
6992 typedef compiler::Node Node;
6993
6994 Label if_equal(this), if_notequal(this), end(this); 6978 Label if_equal(this), if_notequal(this), end(this);
6995 Variable result(this, MachineRepresentation::kTagged); 6979 Variable result(this, MachineRepresentation::kTagged);
6996 6980
6997 // Check if {lhs} and {rhs} refer to the same object. 6981 // Check if {lhs} and {rhs} refer to the same object.
6998 Label if_same(this), if_notsame(this); 6982 Label if_same(this), if_notsame(this);
6999 Branch(WordEqual(lhs, rhs), &if_same, &if_notsame); 6983 Branch(WordEqual(lhs, rhs), &if_same, &if_notsame);
7000 6984
7001 Bind(&if_same); 6985 Bind(&if_same);
7002 { 6986 {
7003 // The {lhs} and {rhs} reference the exact same value, yet we need special 6987 // The {lhs} and {rhs} reference the exact same value, yet we need special
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
7185 Goto(&end); 7169 Goto(&end);
7186 } 7170 }
7187 7171
7188 Bind(&end); 7172 Bind(&end);
7189 return result.value(); 7173 return result.value();
7190 } 7174 }
7191 7175
7192 // ECMA#sec-samevalue 7176 // ECMA#sec-samevalue
7193 // This algorithm differs from the Strict Equality Comparison Algorithm in its 7177 // This algorithm differs from the Strict Equality Comparison Algorithm in its
7194 // treatment of signed zeroes and NaNs. 7178 // treatment of signed zeroes and NaNs.
7195 compiler::Node* CodeStubAssembler::SameValue(compiler::Node* lhs, 7179 Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) {
7196 compiler::Node* rhs,
7197 compiler::Node* context) {
7198 Variable var_result(this, MachineType::PointerRepresentation()); 7180 Variable var_result(this, MachineType::PointerRepresentation());
7199 Label strict_equal(this), out(this); 7181 Label strict_equal(this), out(this);
7200 7182
7201 Node* const int_false = IntPtrConstant(0); 7183 Node* const int_false = IntPtrConstant(0);
7202 Node* const int_true = IntPtrConstant(1); 7184 Node* const int_true = IntPtrConstant(1);
7203 7185
7204 Label if_equal(this), if_notequal(this); 7186 Label if_equal(this), if_notequal(this);
7205 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal); 7187 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal);
7206 7188
7207 Bind(&if_equal); 7189 Bind(&if_equal);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7271 Node* const is_equal = StrictEqual(kDontNegateResult, lhs, rhs, context); 7253 Node* const is_equal = StrictEqual(kDontNegateResult, lhs, rhs, context);
7272 Node* const result = WordEqual(is_equal, TrueConstant()); 7254 Node* const result = WordEqual(is_equal, TrueConstant());
7273 var_result.Bind(result); 7255 var_result.Bind(result);
7274 Goto(&out); 7256 Goto(&out);
7275 } 7257 }
7276 7258
7277 Bind(&out); 7259 Bind(&out);
7278 return var_result.value(); 7260 return var_result.value();
7279 } 7261 }
7280 7262
7281 compiler::Node* CodeStubAssembler::ForInFilter(compiler::Node* key, 7263 Node* CodeStubAssembler::ForInFilter(Node* key, Node* object, Node* context) {
7282 compiler::Node* object,
7283 compiler::Node* context) {
7284 Label return_undefined(this, Label::kDeferred), return_to_name(this), 7264 Label return_undefined(this, Label::kDeferred), return_to_name(this),
7285 end(this); 7265 end(this);
7286 7266
7287 Variable var_result(this, MachineRepresentation::kTagged); 7267 Variable var_result(this, MachineRepresentation::kTagged);
7288 7268
7289 Node* has_property = 7269 Node* has_property =
7290 HasProperty(object, key, context, Runtime::kForInHasProperty); 7270 HasProperty(object, key, context, Runtime::kForInHasProperty);
7291 7271
7292 Branch(WordEqual(has_property, BooleanConstant(true)), &return_to_name, 7272 Branch(WordEqual(has_property, BooleanConstant(true)), &return_to_name,
7293 &return_undefined); 7273 &return_undefined);
7294 7274
7295 Bind(&return_to_name); 7275 Bind(&return_to_name);
7296 { 7276 {
7297 var_result.Bind(ToName(context, key)); 7277 var_result.Bind(ToName(context, key));
7298 Goto(&end); 7278 Goto(&end);
7299 } 7279 }
7300 7280
7301 Bind(&return_undefined); 7281 Bind(&return_undefined);
7302 { 7282 {
7303 var_result.Bind(UndefinedConstant()); 7283 var_result.Bind(UndefinedConstant());
7304 Goto(&end); 7284 Goto(&end);
7305 } 7285 }
7306 7286
7307 Bind(&end); 7287 Bind(&end);
7308 return var_result.value(); 7288 return var_result.value();
7309 } 7289 }
7310 7290
7311 compiler::Node* CodeStubAssembler::HasProperty( 7291 Node* CodeStubAssembler::HasProperty(
7312 compiler::Node* object, compiler::Node* key, compiler::Node* context, 7292 Node* object, Node* key, Node* context,
7313 Runtime::FunctionId fallback_runtime_function_id) { 7293 Runtime::FunctionId fallback_runtime_function_id) {
7314 typedef compiler::Node Node;
7315 typedef CodeStubAssembler::Label Label;
7316 typedef CodeStubAssembler::Variable Variable;
7317
7318 Label call_runtime(this, Label::kDeferred), return_true(this), 7294 Label call_runtime(this, Label::kDeferred), return_true(this),
7319 return_false(this), end(this); 7295 return_false(this), end(this);
7320 7296
7321 CodeStubAssembler::LookupInHolder lookup_property_in_holder = 7297 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
7322 [this, &return_true](Node* receiver, Node* holder, Node* holder_map, 7298 [this, &return_true](Node* receiver, Node* holder, Node* holder_map,
7323 Node* holder_instance_type, Node* unique_name, 7299 Node* holder_instance_type, Node* unique_name,
7324 Label* next_holder, Label* if_bailout) { 7300 Label* next_holder, Label* if_bailout) {
7325 TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name, 7301 TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name,
7326 &return_true, next_holder, if_bailout); 7302 &return_true, next_holder, if_bailout);
7327 }; 7303 };
(...skipping 27 matching lines...) Expand all
7355 { 7331 {
7356 result.Bind( 7332 result.Bind(
7357 CallRuntime(fallback_runtime_function_id, context, object, key)); 7333 CallRuntime(fallback_runtime_function_id, context, object, key));
7358 Goto(&end); 7334 Goto(&end);
7359 } 7335 }
7360 7336
7361 Bind(&end); 7337 Bind(&end);
7362 return result.value(); 7338 return result.value();
7363 } 7339 }
7364 7340
7365 compiler::Node* CodeStubAssembler::Typeof(compiler::Node* value, 7341 Node* CodeStubAssembler::Typeof(Node* value, Node* context) {
7366 compiler::Node* context) {
7367 Variable result_var(this, MachineRepresentation::kTagged); 7342 Variable result_var(this, MachineRepresentation::kTagged);
7368 7343
7369 Label return_number(this, Label::kDeferred), if_oddball(this), 7344 Label return_number(this, Label::kDeferred), if_oddball(this),
7370 return_function(this), return_undefined(this), return_object(this), 7345 return_function(this), return_undefined(this), return_object(this),
7371 return_string(this), return_result(this); 7346 return_string(this), return_result(this);
7372 7347
7373 GotoIf(TaggedIsSmi(value), &return_number); 7348 GotoIf(TaggedIsSmi(value), &return_number);
7374 7349
7375 Node* map = LoadMap(value); 7350 Node* map = LoadMap(value);
7376 7351
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
7449 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ 7424 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \
7450 Goto(&return_result); \ 7425 Goto(&return_result); \
7451 } 7426 }
7452 SIMD128_TYPES(SIMD128_BIND_RETURN) 7427 SIMD128_TYPES(SIMD128_BIND_RETURN)
7453 #undef SIMD128_BIND_RETURN 7428 #undef SIMD128_BIND_RETURN
7454 7429
7455 Bind(&return_result); 7430 Bind(&return_result);
7456 return result_var.value(); 7431 return result_var.value();
7457 } 7432 }
7458 7433
7459 compiler::Node* CodeStubAssembler::InstanceOf(compiler::Node* object, 7434 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable,
7460 compiler::Node* callable, 7435 Node* context) {
7461 compiler::Node* context) {
7462 Label return_runtime(this, Label::kDeferred), end(this); 7436 Label return_runtime(this, Label::kDeferred), end(this);
7463 Variable result(this, MachineRepresentation::kTagged); 7437 Variable result(this, MachineRepresentation::kTagged);
7464 7438
7465 // Check if no one installed @@hasInstance somewhere. 7439 // Check if no one installed @@hasInstance somewhere.
7466 GotoUnless( 7440 GotoUnless(
7467 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), 7441 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex),
7468 PropertyCell::kValueOffset), 7442 PropertyCell::kValueOffset),
7469 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), 7443 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))),
7470 &return_runtime); 7444 &return_runtime);
7471 7445
7472 // Check if {callable} is a valid receiver. 7446 // Check if {callable} is a valid receiver.
7473 GotoIf(TaggedIsSmi(callable), &return_runtime); 7447 GotoIf(TaggedIsSmi(callable), &return_runtime);
7474 GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime); 7448 GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime);
7475 7449
7476 // Use the inline OrdinaryHasInstance directly. 7450 // Use the inline OrdinaryHasInstance directly.
7477 result.Bind(OrdinaryHasInstance(context, callable, object)); 7451 result.Bind(OrdinaryHasInstance(context, callable, object));
7478 Goto(&end); 7452 Goto(&end);
7479 7453
7480 // TODO(bmeurer): Use GetPropertyStub here once available. 7454 // TODO(bmeurer): Use GetPropertyStub here once available.
7481 Bind(&return_runtime); 7455 Bind(&return_runtime);
7482 { 7456 {
7483 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); 7457 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable));
7484 Goto(&end); 7458 Goto(&end);
7485 } 7459 }
7486 7460
7487 Bind(&end); 7461 Bind(&end);
7488 return result.value(); 7462 return result.value();
7489 } 7463 }
7490 7464
7491 compiler::Node* CodeStubAssembler::NumberInc(compiler::Node* value) { 7465 Node* CodeStubAssembler::NumberInc(Node* value) {
7492 Variable var_result(this, MachineRepresentation::kTagged), 7466 Variable var_result(this, MachineRepresentation::kTagged),
7493 var_finc_value(this, MachineRepresentation::kFloat64); 7467 var_finc_value(this, MachineRepresentation::kFloat64);
7494 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); 7468 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this);
7495 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); 7469 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
7496 7470
7497 Bind(&if_issmi); 7471 Bind(&if_issmi);
7498 { 7472 {
7499 // Try fast Smi addition first. 7473 // Try fast Smi addition first.
7500 Node* one = SmiConstant(Smi::FromInt(1)); 7474 Node* one = SmiConstant(Smi::FromInt(1));
7501 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value), 7475 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7533 Node* one = Float64Constant(1.0); 7507 Node* one = Float64Constant(1.0);
7534 Node* finc_result = Float64Add(finc_value, one); 7508 Node* finc_result = Float64Add(finc_value, one);
7535 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); 7509 var_result.Bind(AllocateHeapNumberWithValue(finc_result));
7536 Goto(&end); 7510 Goto(&end);
7537 } 7511 }
7538 7512
7539 Bind(&end); 7513 Bind(&end);
7540 return var_result.value(); 7514 return var_result.value();
7541 } 7515 }
7542 7516
7543 compiler::Node* CodeStubAssembler::CreateArrayIterator( 7517 Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
7544 compiler::Node* array, compiler::Node* array_map, 7518 Node* array_type, Node* context,
7545 compiler::Node* array_type, compiler::Node* context, IterationKind mode) { 7519 IterationKind mode) {
7546 int kBaseMapIndex = 0; 7520 int kBaseMapIndex = 0;
7547 switch (mode) { 7521 switch (mode) {
7548 case IterationKind::kKeys: 7522 case IterationKind::kKeys:
7549 kBaseMapIndex = Context::TYPED_ARRAY_KEY_ITERATOR_MAP_INDEX; 7523 kBaseMapIndex = Context::TYPED_ARRAY_KEY_ITERATOR_MAP_INDEX;
7550 break; 7524 break;
7551 case IterationKind::kValues: 7525 case IterationKind::kValues:
7552 kBaseMapIndex = Context::UINT8_ARRAY_VALUE_ITERATOR_MAP_INDEX; 7526 kBaseMapIndex = Context::UINT8_ARRAY_VALUE_ITERATOR_MAP_INDEX;
7553 break; 7527 break;
7554 case IterationKind::kEntries: 7528 case IterationKind::kEntries:
7555 kBaseMapIndex = Context::UINT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX; 7529 kBaseMapIndex = Context::UINT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
7721 LoadFixedArrayElement(LoadNativeContext(context), var_map_index.value(), 7695 LoadFixedArrayElement(LoadNativeContext(context), var_map_index.value(),
7722 0, CodeStubAssembler::INTPTR_PARAMETERS); 7696 0, CodeStubAssembler::INTPTR_PARAMETERS);
7723 var_result.Bind(AllocateJSArrayIterator(array, var_array_map.value(), map)); 7697 var_result.Bind(AllocateJSArrayIterator(array, var_array_map.value(), map));
7724 Goto(&return_result); 7698 Goto(&return_result);
7725 } 7699 }
7726 7700
7727 Bind(&return_result); 7701 Bind(&return_result);
7728 return var_result.value(); 7702 return var_result.value();
7729 } 7703 }
7730 7704
7731 compiler::Node* CodeStubAssembler::AllocateJSArrayIterator( 7705 Node* CodeStubAssembler::AllocateJSArrayIterator(Node* array, Node* array_map,
7732 compiler::Node* array, compiler::Node* array_map, compiler::Node* map) { 7706 Node* map) {
7733 Node* iterator = Allocate(JSArrayIterator::kSize); 7707 Node* iterator = Allocate(JSArrayIterator::kSize);
7734 StoreMapNoWriteBarrier(iterator, map); 7708 StoreMapNoWriteBarrier(iterator, map);
7735 StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOffset, 7709 StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOffset,
7736 Heap::kEmptyFixedArrayRootIndex); 7710 Heap::kEmptyFixedArrayRootIndex);
7737 StoreObjectFieldRoot(iterator, JSArrayIterator::kElementsOffset, 7711 StoreObjectFieldRoot(iterator, JSArrayIterator::kElementsOffset,
7738 Heap::kEmptyFixedArrayRootIndex); 7712 Heap::kEmptyFixedArrayRootIndex);
7739 StoreObjectFieldNoWriteBarrier(iterator, 7713 StoreObjectFieldNoWriteBarrier(iterator,
7740 JSArrayIterator::kIteratedObjectOffset, array); 7714 JSArrayIterator::kIteratedObjectOffset, array);
7741 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset, 7715 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset,
7742 SmiConstant(Smi::FromInt(0))); 7716 SmiConstant(Smi::FromInt(0)));
7743 StoreObjectFieldNoWriteBarrier( 7717 StoreObjectFieldNoWriteBarrier(
7744 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map); 7718 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map);
7745 return iterator; 7719 return iterator;
7746 } 7720 }
7747 7721
7748 compiler::Node* CodeStubAssembler::IsDetachedBuffer(compiler::Node* buffer) { 7722 Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) {
7749 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); 7723 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE));
7750 7724
7751 Node* buffer_bit_field = LoadObjectField( 7725 Node* buffer_bit_field = LoadObjectField(
7752 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); 7726 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32());
7753 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); 7727 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask);
7754 7728
7755 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), 7729 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask),
7756 Int32Constant(0)); 7730 Int32Constant(0));
7757 } 7731 }
7758 7732
7759 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, 7733 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc,
7760 compiler::Node* argc,
7761 CodeStubAssembler::ParameterMode mode) 7734 CodeStubAssembler::ParameterMode mode)
7762 : assembler_(assembler), 7735 : assembler_(assembler),
7763 argc_(argc), 7736 argc_(argc),
7764 arguments_(nullptr), 7737 arguments_(nullptr),
7765 fp_(assembler->LoadFramePointer()) { 7738 fp_(assembler->LoadFramePointer()) {
7766 compiler::Node* offset = assembler->ElementOffsetFromIndex( 7739 Node* offset = assembler->ElementOffsetFromIndex(
7767 argc_, FAST_ELEMENTS, mode, 7740 argc_, FAST_ELEMENTS, mode,
7768 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize); 7741 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize);
7769 arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset); 7742 arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset);
7770 if (mode == CodeStubAssembler::INTEGER_PARAMETERS) { 7743 if (mode == CodeStubAssembler::INTEGER_PARAMETERS) {
7771 argc_ = assembler->ChangeInt32ToIntPtr(argc_); 7744 argc_ = assembler->ChangeInt32ToIntPtr(argc_);
7772 } else if (mode == CodeStubAssembler::SMI_PARAMETERS) { 7745 } else if (mode == CodeStubAssembler::SMI_PARAMETERS) {
7773 argc_ = assembler->SmiUntag(argc_); 7746 argc_ = assembler->SmiUntag(argc_);
7774 } 7747 }
7775 } 7748 }
7776 7749
7777 compiler::Node* CodeStubArguments::GetReceiver() { 7750 Node* CodeStubArguments::GetReceiver() {
7778 return assembler_->Load(MachineType::AnyTagged(), arguments_, 7751 return assembler_->Load(MachineType::AnyTagged(), arguments_,
7779 assembler_->IntPtrConstant(kPointerSize)); 7752 assembler_->IntPtrConstant(kPointerSize));
7780 } 7753 }
7781 7754
7782 compiler::Node* CodeStubArguments::AtIndex( 7755 Node* CodeStubArguments::AtIndex(Node* index,
7783 compiler::Node* index, CodeStubAssembler::ParameterMode mode) { 7756 CodeStubAssembler::ParameterMode mode) {
7784 typedef compiler::Node Node;
7785 Node* negated_index = assembler_->IntPtrSubFoldConstants( 7757 Node* negated_index = assembler_->IntPtrSubFoldConstants(
7786 assembler_->IntPtrOrSmiConstant(0, mode), index); 7758 assembler_->IntPtrOrSmiConstant(0, mode), index);
7787 Node* offset = 7759 Node* offset =
7788 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0); 7760 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0);
7789 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset); 7761 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset);
7790 } 7762 }
7791 7763
7792 compiler::Node* CodeStubArguments::AtIndex(int index) { 7764 Node* CodeStubArguments::AtIndex(int index) {
7793 return AtIndex(assembler_->IntPtrConstant(index)); 7765 return AtIndex(assembler_->IntPtrConstant(index));
7794 } 7766 }
7795 7767
7796 void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars, 7768 void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
7797 CodeStubArguments::ForEachBodyFunction body, 7769 CodeStubArguments::ForEachBodyFunction body,
7798 compiler::Node* first, compiler::Node* last, 7770 Node* first, Node* last,
7799 CodeStubAssembler::ParameterMode mode) { 7771 CodeStubAssembler::ParameterMode mode) {
7800 assembler_->Comment("CodeStubArguments::ForEach"); 7772 assembler_->Comment("CodeStubArguments::ForEach");
7801 DCHECK_IMPLIES(first == nullptr || last == nullptr, 7773 DCHECK_IMPLIES(first == nullptr || last == nullptr,
7802 mode == CodeStubAssembler::INTPTR_PARAMETERS); 7774 mode == CodeStubAssembler::INTPTR_PARAMETERS);
7803 if (first == nullptr) { 7775 if (first == nullptr) {
7804 first = assembler_->IntPtrOrSmiConstant(0, mode); 7776 first = assembler_->IntPtrOrSmiConstant(0, mode);
7805 } 7777 }
7806 if (last == nullptr) { 7778 if (last == nullptr) {
7807 last = argc_; 7779 last = argc_;
7808 } 7780 }
7809 compiler::Node* start = assembler_->IntPtrSubFoldConstants( 7781 Node* start = assembler_->IntPtrSubFoldConstants(
7810 arguments_, 7782 arguments_,
7811 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode)); 7783 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode));
7812 compiler::Node* end = assembler_->IntPtrSubFoldConstants( 7784 Node* end = assembler_->IntPtrSubFoldConstants(
7813 arguments_, 7785 arguments_,
7814 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode)); 7786 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
7815 assembler_->BuildFastLoop( 7787 assembler_->BuildFastLoop(
7816 vars, MachineType::PointerRepresentation(), start, end, 7788 vars, MachineType::PointerRepresentation(), start, end,
7817 [body](CodeStubAssembler* assembler, compiler::Node* current) { 7789 [body](CodeStubAssembler* assembler, Node* current) {
7818 Node* arg = assembler->Load(MachineType::AnyTagged(), current); 7790 Node* arg = assembler->Load(MachineType::AnyTagged(), current);
7819 body(assembler, arg); 7791 body(assembler, arg);
7820 }, 7792 },
7821 -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost); 7793 -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
7822 } 7794 }
7823 7795
7824 void CodeStubArguments::PopAndReturn(compiler::Node* value) { 7796 void CodeStubArguments::PopAndReturn(Node* value) {
7825 assembler_->PopAndReturn( 7797 assembler_->PopAndReturn(
7826 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)), 7798 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)),
7827 value); 7799 value);
7828 } 7800 }
7829 7801
7830 compiler::Node* CodeStubAssembler::IsFastElementsKind( 7802 Node* CodeStubAssembler::IsFastElementsKind(Node* elements_kind) {
7831 compiler::Node* elements_kind) {
7832 return Uint32LessThanOrEqual(elements_kind, 7803 return Uint32LessThanOrEqual(elements_kind,
7833 Int32Constant(LAST_FAST_ELEMENTS_KIND)); 7804 Int32Constant(LAST_FAST_ELEMENTS_KIND));
7834 } 7805 }
7835 7806
7836 compiler::Node* CodeStubAssembler::IsHoleyFastElementsKind( 7807 Node* CodeStubAssembler::IsHoleyFastElementsKind(Node* elements_kind) {
7837 compiler::Node* elements_kind) {
7838 CSA_ASSERT(this, IsFastElementsKind(elements_kind)); 7808 CSA_ASSERT(this, IsFastElementsKind(elements_kind));
7839 7809
7840 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1)); 7810 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1));
7841 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1)); 7811 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1));
7842 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1)); 7812 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1));
7843 7813
7844 // Check prototype chain if receiver does not have packed elements. 7814 // Check prototype chain if receiver does not have packed elements.
7845 Node* holey_elements = Word32And(elements_kind, Int32Constant(1)); 7815 Node* holey_elements = Word32And(elements_kind, Int32Constant(1));
7846 return Word32Equal(holey_elements, Int32Constant(1)); 7816 return Word32Equal(holey_elements, Int32Constant(1));
7847 } 7817 }
7848 7818
7849 compiler::Node* CodeStubAssembler::IsDebugActive() { 7819 compiler::Node* CodeStubAssembler::IsDebugActive() {
7850 Node* is_debug_active = Load( 7820 Node* is_debug_active = Load(
7851 MachineType::Uint8(), 7821 MachineType::Uint8(),
7852 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); 7822 ExternalConstant(ExternalReference::debug_is_active_address(isolate())));
7853 return WordNotEqual(is_debug_active, Int32Constant(0)); 7823 return WordNotEqual(is_debug_active, Int32Constant(0));
7854 } 7824 }
7855 7825
7856 } // namespace internal 7826 } // namespace internal
7857 } // namespace v8 7827 } // 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