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

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

Issue 2532063002: Reland of [cleanup] CodeStubAssembler: s/compiler::Node/Node/ (Closed)
Patch Set: rebased Created 4 years 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 834 matching lines...) Expand 10 before | Expand all | Expand 10 after
4450 if_bailout); 4446 if_bailout);
4451 4447
4452 Node* dictionary = LoadProperties(object); 4448 Node* dictionary = LoadProperties(object);
4453 var_meta_storage->Bind(dictionary); 4449 var_meta_storage->Bind(dictionary);
4454 4450
4455 NameDictionaryLookup<GlobalDictionary>( 4451 NameDictionaryLookup<GlobalDictionary>(
4456 dictionary, unique_name, if_found_global, var_name_index, if_not_found); 4452 dictionary, unique_name, if_found_global, var_name_index, if_not_found);
4457 } 4453 }
4458 } 4454 }
4459 4455
4460 void CodeStubAssembler::TryHasOwnProperty(compiler::Node* object, 4456 void CodeStubAssembler::TryHasOwnProperty(Node* object, Node* map,
4461 compiler::Node* map, 4457 Node* instance_type,
4462 compiler::Node* instance_type, 4458 Node* unique_name, Label* if_found,
4463 compiler::Node* unique_name, 4459 Label* if_not_found,
4464 Label* if_found, Label* if_not_found,
4465 Label* if_bailout) { 4460 Label* if_bailout) {
4466 Comment("TryHasOwnProperty"); 4461 Comment("TryHasOwnProperty");
4467 Variable var_meta_storage(this, MachineRepresentation::kTagged); 4462 Variable var_meta_storage(this, MachineRepresentation::kTagged);
4468 Variable var_name_index(this, MachineType::PointerRepresentation()); 4463 Variable var_name_index(this, MachineType::PointerRepresentation());
4469 4464
4470 Label if_found_global(this); 4465 Label if_found_global(this);
4471 TryLookupProperty(object, map, instance_type, unique_name, if_found, if_found, 4466 TryLookupProperty(object, map, instance_type, unique_name, if_found, if_found,
4472 &if_found_global, &var_meta_storage, &var_name_index, 4467 &if_found_global, &var_meta_storage, &var_name_index,
4473 if_not_found, if_bailout); 4468 if_not_found, if_bailout);
4474 Bind(&if_found_global); 4469 Bind(&if_found_global);
(...skipping 611 matching lines...) Expand 10 before | Expand all | Expand 10 after
5086 // Fallback to the runtime implementation. 5081 // Fallback to the runtime implementation.
5087 var_result.Bind( 5082 var_result.Bind(
5088 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object)); 5083 CallRuntime(Runtime::kOrdinaryHasInstance, context, callable, object));
5089 } 5084 }
5090 Goto(&return_result); 5085 Goto(&return_result);
5091 5086
5092 Bind(&return_result); 5087 Bind(&return_result);
5093 return var_result.value(); 5088 return var_result.value();
5094 } 5089 }
5095 5090
5096 compiler::Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node, 5091 Node* CodeStubAssembler::ElementOffsetFromIndex(Node* index_node,
5097 ElementsKind kind, 5092 ElementsKind kind,
5098 ParameterMode mode, 5093 ParameterMode mode,
5099 int base_size) { 5094 int base_size) {
5100 int element_size_shift = ElementsKindToShiftSize(kind); 5095 int element_size_shift = ElementsKindToShiftSize(kind);
5101 int element_size = 1 << element_size_shift; 5096 int element_size = 1 << element_size_shift;
5102 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize; 5097 int const kSmiShiftBits = kSmiShiftSize + kSmiTagSize;
5103 intptr_t index = 0; 5098 intptr_t index = 0;
5104 bool constant_index = false; 5099 bool constant_index = false;
5105 if (mode == SMI_PARAMETERS) { 5100 if (mode == SMI_PARAMETERS) {
5106 element_size_shift -= kSmiShiftBits; 5101 element_size_shift -= kSmiShiftBits;
5107 Smi* smi_index; 5102 Smi* smi_index;
5108 constant_index = ToSmiConstant(index_node, smi_index); 5103 constant_index = ToSmiConstant(index_node, smi_index);
5109 if (constant_index) index = smi_index->value(); 5104 if (constant_index) index = smi_index->value();
(...skipping 15 matching lines...) Expand all
5125 5120
5126 Node* shifted_index = 5121 Node* shifted_index =
5127 (element_size_shift == 0) 5122 (element_size_shift == 0)
5128 ? index_node 5123 ? index_node
5129 : ((element_size_shift > 0) 5124 : ((element_size_shift > 0)
5130 ? WordShl(index_node, IntPtrConstant(element_size_shift)) 5125 ? WordShl(index_node, IntPtrConstant(element_size_shift))
5131 : WordShr(index_node, IntPtrConstant(-element_size_shift))); 5126 : WordShr(index_node, IntPtrConstant(-element_size_shift)));
5132 return IntPtrAddFoldConstants(IntPtrConstant(base_size), shifted_index); 5127 return IntPtrAddFoldConstants(IntPtrConstant(base_size), shifted_index);
5133 } 5128 }
5134 5129
5135 compiler::Node* CodeStubAssembler::LoadTypeFeedbackVectorForStub() { 5130 Node* CodeStubAssembler::LoadTypeFeedbackVectorForStub() {
5136 Node* function = 5131 Node* function =
5137 LoadFromParentFrame(JavaScriptFrameConstants::kFunctionOffset); 5132 LoadFromParentFrame(JavaScriptFrameConstants::kFunctionOffset);
5138 Node* literals = LoadObjectField(function, JSFunction::kLiteralsOffset); 5133 Node* literals = LoadObjectField(function, JSFunction::kLiteralsOffset);
5139 return LoadObjectField(literals, LiteralsArray::kFeedbackVectorOffset); 5134 return LoadObjectField(literals, LiteralsArray::kFeedbackVectorOffset);
5140 } 5135 }
5141 5136
5142 void CodeStubAssembler::UpdateFeedback(compiler::Node* feedback, 5137 void CodeStubAssembler::UpdateFeedback(Node* feedback,
5143 compiler::Node* type_feedback_vector, 5138 Node* type_feedback_vector,
5144 compiler::Node* slot_id) { 5139 Node* slot_id) {
5145 // This method is used for binary op and compare feedback. These 5140 // This method is used for binary op and compare feedback. These
5146 // vector nodes are initialized with a smi 0, so we can simply OR 5141 // vector nodes are initialized with a smi 0, so we can simply OR
5147 // our new feedback in place. 5142 // our new feedback in place.
5148 // TODO(interpreter): Consider passing the feedback as Smi already to avoid 5143 // TODO(interpreter): Consider passing the feedback as Smi already to avoid
5149 // the tagging completely. 5144 // the tagging completely.
5150 Node* previous_feedback = 5145 Node* previous_feedback =
5151 LoadFixedArrayElement(type_feedback_vector, slot_id); 5146 LoadFixedArrayElement(type_feedback_vector, slot_id);
5152 Node* combined_feedback = SmiOr(previous_feedback, SmiFromWord32(feedback)); 5147 Node* combined_feedback = SmiOr(previous_feedback, SmiFromWord32(feedback));
5153 StoreFixedArrayElement(type_feedback_vector, slot_id, combined_feedback, 5148 StoreFixedArrayElement(type_feedback_vector, slot_id, combined_feedback,
5154 SKIP_WRITE_BARRIER); 5149 SKIP_WRITE_BARRIER);
5155 } 5150 }
5156 5151
5157 compiler::Node* CodeStubAssembler::LoadReceiverMap(compiler::Node* receiver) { 5152 Node* CodeStubAssembler::LoadReceiverMap(Node* receiver) {
5158 Variable var_receiver_map(this, MachineRepresentation::kTagged); 5153 Variable var_receiver_map(this, MachineRepresentation::kTagged);
5159 Label load_smi_map(this, Label::kDeferred), load_receiver_map(this), 5154 Label load_smi_map(this, Label::kDeferred), load_receiver_map(this),
5160 if_result(this); 5155 if_result(this);
5161 5156
5162 Branch(TaggedIsSmi(receiver), &load_smi_map, &load_receiver_map); 5157 Branch(TaggedIsSmi(receiver), &load_smi_map, &load_receiver_map);
5163 Bind(&load_smi_map); 5158 Bind(&load_smi_map);
5164 { 5159 {
5165 var_receiver_map.Bind(LoadRoot(Heap::kHeapNumberMapRootIndex)); 5160 var_receiver_map.Bind(LoadRoot(Heap::kHeapNumberMapRootIndex));
5166 Goto(&if_result); 5161 Goto(&if_result);
5167 } 5162 }
(...skipping 23 matching lines...) Expand all
5191 Bind(&key_is_smi); 5186 Bind(&key_is_smi);
5192 { 5187 {
5193 var_intptr_key.Bind(SmiUntag(key)); 5188 var_intptr_key.Bind(SmiUntag(key));
5194 Goto(&done); 5189 Goto(&done);
5195 } 5190 }
5196 5191
5197 Bind(&done); 5192 Bind(&done);
5198 return var_intptr_key.value(); 5193 return var_intptr_key.value();
5199 } 5194 }
5200 5195
5201 void CodeStubAssembler::ExtendPropertiesBackingStore(compiler::Node* object) { 5196 void CodeStubAssembler::ExtendPropertiesBackingStore(Node* object) {
5202 Node* properties = LoadProperties(object); 5197 Node* properties = LoadProperties(object);
5203 Node* length = LoadFixedArrayBaseLength(properties); 5198 Node* length = LoadFixedArrayBaseLength(properties);
5204 5199
5205 ParameterMode mode = OptimalParameterMode(); 5200 ParameterMode mode = OptimalParameterMode();
5206 length = UntagParameter(length, mode); 5201 length = UntagParameter(length, mode);
5207 5202
5208 Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode); 5203 Node* delta = IntPtrOrSmiConstant(JSObject::kFieldsAdded, mode);
5209 Node* new_capacity = IntPtrAdd(length, delta); 5204 Node* new_capacity = IntPtrAdd(length, delta);
5210 5205
5211 // Grow properties array. 5206 // Grow properties array.
(...skipping 433 matching lines...) Expand 10 before | Expand all | Expand 10 after
5645 length, capacity, mode, bailout); 5640 length, capacity, mode, bailout);
5646 5641
5647 new_elements_var.Bind(new_elements); 5642 new_elements_var.Bind(new_elements);
5648 Goto(&done); 5643 Goto(&done);
5649 } 5644 }
5650 5645
5651 Bind(&done); 5646 Bind(&done);
5652 return new_elements_var.value(); 5647 return new_elements_var.value();
5653 } 5648 }
5654 5649
5655 void CodeStubAssembler::TransitionElementsKind( 5650 void CodeStubAssembler::TransitionElementsKind(Node* object, Node* map,
5656 compiler::Node* object, compiler::Node* map, ElementsKind from_kind, 5651 ElementsKind from_kind,
5657 ElementsKind to_kind, bool is_jsarray, Label* bailout) { 5652 ElementsKind to_kind,
5653 bool is_jsarray,
5654 Label* bailout) {
5658 DCHECK(!IsFastHoleyElementsKind(from_kind) || 5655 DCHECK(!IsFastHoleyElementsKind(from_kind) ||
5659 IsFastHoleyElementsKind(to_kind)); 5656 IsFastHoleyElementsKind(to_kind));
5660 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) { 5657 if (AllocationSite::GetMode(from_kind, to_kind) == TRACK_ALLOCATION_SITE) {
5661 TrapAllocationMemento(object, bailout); 5658 TrapAllocationMemento(object, bailout);
5662 } 5659 }
5663 5660
5664 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) { 5661 if (!IsSimpleMapChangeTransition(from_kind, to_kind)) {
5665 Comment("Non-simple map transition"); 5662 Comment("Non-simple map transition");
5666 Node* elements = LoadElements(object); 5663 Node* elements = LoadElements(object);
5667 5664
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
5910 body(this, var.value()); 5907 body(this, var.value());
5911 if (mode == IndexAdvanceMode::kPost) { 5908 if (mode == IndexAdvanceMode::kPost) {
5912 var.Bind(IntPtrAdd(var.value(), IntPtrConstant(increment))); 5909 var.Bind(IntPtrAdd(var.value(), IntPtrConstant(increment)));
5913 } 5910 }
5914 Branch(WordNotEqual(var.value(), end_index), &loop, &after_loop); 5911 Branch(WordNotEqual(var.value(), end_index), &loop, &after_loop);
5915 } 5912 }
5916 Bind(&after_loop); 5913 Bind(&after_loop);
5917 } 5914 }
5918 5915
5919 void CodeStubAssembler::BuildFastFixedArrayForEach( 5916 void CodeStubAssembler::BuildFastFixedArrayForEach(
5920 compiler::Node* fixed_array, ElementsKind kind, 5917 Node* fixed_array, ElementsKind kind, Node* first_element_inclusive,
5921 compiler::Node* first_element_inclusive, 5918 Node* last_element_exclusive,
5922 compiler::Node* last_element_exclusive, 5919 std::function<void(CodeStubAssembler* assembler, Node* fixed_array,
5923 std::function<void(CodeStubAssembler* assembler, 5920 Node* offset)>
5924 compiler::Node* fixed_array, compiler::Node* offset)>
5925 body, 5921 body,
5926 ParameterMode mode, ForEachDirection direction) { 5922 ParameterMode mode, ForEachDirection direction) {
5927 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); 5923 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
5928 int32_t first_val; 5924 int32_t first_val;
5929 bool constant_first = ToInt32Constant(first_element_inclusive, first_val); 5925 bool constant_first = ToInt32Constant(first_element_inclusive, first_val);
5930 int32_t last_val; 5926 int32_t last_val;
5931 bool constent_last = ToInt32Constant(last_element_exclusive, last_val); 5927 bool constent_last = ToInt32Constant(last_element_exclusive, last_val);
5932 if (constant_first && constent_last) { 5928 if (constant_first && constent_last) {
5933 int delta = last_val - first_val; 5929 int delta = last_val - first_val;
5934 DCHECK(delta >= 0); 5930 DCHECK(delta >= 0);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
5967 MachineType::PointerRepresentation(), start, limit, 5963 MachineType::PointerRepresentation(), start, limit,
5968 [fixed_array, body](CodeStubAssembler* assembler, Node* offset) { 5964 [fixed_array, body](CodeStubAssembler* assembler, Node* offset) {
5969 body(assembler, fixed_array, offset); 5965 body(assembler, fixed_array, offset);
5970 }, 5966 },
5971 direction == ForEachDirection::kReverse ? -increment : increment, 5967 direction == ForEachDirection::kReverse ? -increment : increment,
5972 direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre 5968 direction == ForEachDirection::kReverse ? IndexAdvanceMode::kPre
5973 : IndexAdvanceMode::kPost); 5969 : IndexAdvanceMode::kPost);
5974 } 5970 }
5975 5971
5976 void CodeStubAssembler::BranchIfNumericRelationalComparison( 5972 void CodeStubAssembler::BranchIfNumericRelationalComparison(
5977 RelationalComparisonMode mode, compiler::Node* lhs, compiler::Node* rhs, 5973 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true,
5978 Label* if_true, Label* if_false) { 5974 Label* if_false) {
5979 typedef compiler::Node Node;
5980
5981 Label end(this); 5975 Label end(this);
5982 Variable result(this, MachineRepresentation::kTagged); 5976 Variable result(this, MachineRepresentation::kTagged);
5983 5977
5984 // Shared entry for floating point comparison. 5978 // Shared entry for floating point comparison.
5985 Label do_fcmp(this); 5979 Label do_fcmp(this);
5986 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 5980 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
5987 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 5981 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
5988 5982
5989 // Check if the {lhs} is a Smi or a HeapObject. 5983 // Check if the {lhs} is a Smi or a HeapObject.
5990 Label if_lhsissmi(this), if_lhsisnotsmi(this); 5984 Label if_lhsissmi(this), if_lhsisnotsmi(this);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
6072 case kGreaterThan: 6066 case kGreaterThan:
6073 Branch(Float64GreaterThan(lhs, rhs), if_true, if_false); 6067 Branch(Float64GreaterThan(lhs, rhs), if_true, if_false);
6074 break; 6068 break;
6075 case kGreaterThanOrEqual: 6069 case kGreaterThanOrEqual:
6076 Branch(Float64GreaterThanOrEqual(lhs, rhs), if_true, if_false); 6070 Branch(Float64GreaterThanOrEqual(lhs, rhs), if_true, if_false);
6077 break; 6071 break;
6078 } 6072 }
6079 } 6073 }
6080 } 6074 }
6081 6075
6082 void CodeStubAssembler::GotoUnlessNumberLessThan(compiler::Node* lhs, 6076 void CodeStubAssembler::GotoUnlessNumberLessThan(Node* lhs, Node* rhs,
6083 compiler::Node* rhs,
6084 Label* if_false) { 6077 Label* if_false) {
6085 Label if_true(this); 6078 Label if_true(this);
6086 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false); 6079 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false);
6087 Bind(&if_true); 6080 Bind(&if_true);
6088 } 6081 }
6089 6082
6090 compiler::Node* CodeStubAssembler::RelationalComparison( 6083 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
6091 RelationalComparisonMode mode, compiler::Node* lhs, compiler::Node* rhs, 6084 Node* lhs, Node* rhs,
6092 compiler::Node* context) { 6085 Node* context) {
6093 typedef compiler::Node Node;
6094
6095 Label return_true(this), return_false(this), end(this); 6086 Label return_true(this), return_false(this), end(this);
6096 Variable result(this, MachineRepresentation::kTagged); 6087 Variable result(this, MachineRepresentation::kTagged);
6097 6088
6098 // Shared entry for floating point comparison. 6089 // Shared entry for floating point comparison.
6099 Label do_fcmp(this); 6090 Label do_fcmp(this);
6100 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 6091 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
6101 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 6092 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
6102 6093
6103 // We might need to loop several times due to ToPrimitive and/or ToNumber 6094 // We might need to loop several times due to ToPrimitive and/or ToNumber
6104 // conversions. 6095 // conversions.
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
6405 result.Bind(BooleanConstant(false)); 6396 result.Bind(BooleanConstant(false));
6406 Goto(&end); 6397 Goto(&end);
6407 } 6398 }
6408 6399
6409 Bind(&end); 6400 Bind(&end);
6410 return result.value(); 6401 return result.value();
6411 } 6402 }
6412 6403
6413 namespace { 6404 namespace {
6414 6405
6415 void GenerateEqual_Same(CodeStubAssembler* assembler, compiler::Node* value, 6406 void GenerateEqual_Same(CodeStubAssembler* assembler, Node* value,
6416 CodeStubAssembler::Label* if_equal, 6407 CodeStubAssembler::Label* if_equal,
6417 CodeStubAssembler::Label* if_notequal) { 6408 CodeStubAssembler::Label* if_notequal) {
6418 // In case of abstract or strict equality checks, we need additional checks 6409 // In case of abstract or strict equality checks, we need additional checks
6419 // for NaN values because they are not considered equal, even if both the 6410 // for NaN values because they are not considered equal, even if both the
6420 // left and the right hand side reference exactly the same value. 6411 // left and the right hand side reference exactly the same value.
6421 // TODO(bmeurer): This seems to violate the SIMD.js specification, but it 6412 // TODO(bmeurer): This seems to violate the SIMD.js specification, but it
6422 // seems to be what is tested in the current SIMD.js testsuite. 6413 // seems to be what is tested in the current SIMD.js testsuite.
6423 6414
6424 typedef CodeStubAssembler::Label Label; 6415 typedef CodeStubAssembler::Label Label;
6425 typedef compiler::Node Node;
6426 6416
6427 // Check if {value} is a Smi or a HeapObject. 6417 // Check if {value} is a Smi or a HeapObject.
6428 Label if_valueissmi(assembler), if_valueisnotsmi(assembler); 6418 Label if_valueissmi(assembler), if_valueisnotsmi(assembler);
6429 assembler->Branch(assembler->TaggedIsSmi(value), &if_valueissmi, 6419 assembler->Branch(assembler->TaggedIsSmi(value), &if_valueissmi,
6430 &if_valueisnotsmi); 6420 &if_valueisnotsmi);
6431 6421
6432 assembler->Bind(&if_valueisnotsmi); 6422 assembler->Bind(&if_valueisnotsmi);
6433 { 6423 {
6434 // Load the map of {value}. 6424 // Load the map of {value}.
6435 Node* value_map = assembler->LoadMap(value); 6425 Node* value_map = assembler->LoadMap(value);
(...skipping 14 matching lines...) Expand all
6450 6440
6451 assembler->Bind(&if_valueisnotnumber); 6441 assembler->Bind(&if_valueisnotnumber);
6452 assembler->Goto(if_equal); 6442 assembler->Goto(if_equal);
6453 } 6443 }
6454 6444
6455 assembler->Bind(&if_valueissmi); 6445 assembler->Bind(&if_valueissmi);
6456 assembler->Goto(if_equal); 6446 assembler->Goto(if_equal);
6457 } 6447 }
6458 6448
6459 void GenerateEqual_Simd128Value_HeapObject( 6449 void GenerateEqual_Simd128Value_HeapObject(
6460 CodeStubAssembler* assembler, compiler::Node* lhs, compiler::Node* lhs_map, 6450 CodeStubAssembler* assembler, Node* lhs, Node* lhs_map, Node* rhs,
6461 compiler::Node* rhs, compiler::Node* rhs_map, 6451 Node* rhs_map, CodeStubAssembler::Label* if_equal,
6462 CodeStubAssembler::Label* if_equal, CodeStubAssembler::Label* if_notequal) { 6452 CodeStubAssembler::Label* if_notequal) {
6463 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal, 6453 assembler->BranchIfSimd128Equal(lhs, lhs_map, rhs, rhs_map, if_equal,
6464 if_notequal); 6454 if_notequal);
6465 } 6455 }
6466 6456
6467 } // namespace 6457 } // namespace
6468 6458
6469 // ES6 section 7.2.12 Abstract Equality Comparison 6459 // ES6 section 7.2.12 Abstract Equality Comparison
6470 compiler::Node* CodeStubAssembler::Equal(ResultMode mode, compiler::Node* lhs, 6460 Node* CodeStubAssembler::Equal(ResultMode mode, Node* lhs, Node* rhs,
6471 compiler::Node* rhs, 6461 Node* context) {
6472 compiler::Node* context) {
6473 // This is a slightly optimized version of Object::Equals represented as 6462 // This is a slightly optimized version of Object::Equals represented as
6474 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you 6463 // scheduled TurboFan graph utilizing the CodeStubAssembler. Whenever you
6475 // change something functionality wise in here, remember to update the 6464 // change something functionality wise in here, remember to update the
6476 // Object::Equals method as well. 6465 // Object::Equals method as well.
6477 typedef compiler::Node Node;
6478 6466
6479 Label if_equal(this), if_notequal(this), 6467 Label if_equal(this), if_notequal(this),
6480 do_rhsstringtonumber(this, Label::kDeferred), end(this); 6468 do_rhsstringtonumber(this, Label::kDeferred), end(this);
6481 Variable result(this, MachineRepresentation::kTagged); 6469 Variable result(this, MachineRepresentation::kTagged);
6482 6470
6483 // Shared entry for floating point comparison. 6471 // Shared entry for floating point comparison.
6484 Label do_fcmp(this); 6472 Label do_fcmp(this);
6485 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64), 6473 Variable var_fcmp_lhs(this, MachineRepresentation::kFloat64),
6486 var_fcmp_rhs(this, MachineRepresentation::kFloat64); 6474 var_fcmp_rhs(this, MachineRepresentation::kFloat64);
6487 6475
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
6961 Bind(&if_notequal); 6949 Bind(&if_notequal);
6962 { 6950 {
6963 result.Bind(BooleanConstant(mode == kNegateResult)); 6951 result.Bind(BooleanConstant(mode == kNegateResult));
6964 Goto(&end); 6952 Goto(&end);
6965 } 6953 }
6966 6954
6967 Bind(&end); 6955 Bind(&end);
6968 return result.value(); 6956 return result.value();
6969 } 6957 }
6970 6958
6971 compiler::Node* CodeStubAssembler::StrictEqual(ResultMode mode, 6959 Node* CodeStubAssembler::StrictEqual(ResultMode mode, Node* lhs, Node* rhs,
6972 compiler::Node* lhs, 6960 Node* context) {
6973 compiler::Node* rhs,
6974 compiler::Node* context) {
6975 // Here's pseudo-code for the algorithm below in case of kDontNegateResult 6961 // Here's pseudo-code for the algorithm below in case of kDontNegateResult
6976 // mode; for kNegateResult mode we properly negate the result. 6962 // mode; for kNegateResult mode we properly negate the result.
6977 // 6963 //
6978 // if (lhs == rhs) { 6964 // if (lhs == rhs) {
6979 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN; 6965 // if (lhs->IsHeapNumber()) return HeapNumber::cast(lhs)->value() != NaN;
6980 // return true; 6966 // return true;
6981 // } 6967 // }
6982 // if (!lhs->IsSmi()) { 6968 // if (!lhs->IsSmi()) {
6983 // if (lhs->IsHeapNumber()) { 6969 // if (lhs->IsHeapNumber()) {
6984 // if (rhs->IsSmi()) { 6970 // if (rhs->IsSmi()) {
(...skipping 28 matching lines...) Expand all
7013 // return false; 6999 // return false;
7014 // } else { 7000 // } else {
7015 // if (rhs->IsHeapNumber()) { 7001 // if (rhs->IsHeapNumber()) {
7016 // return Smi::cast(lhs)->value() == HeapNumber::cast(rhs)->value(); 7002 // return Smi::cast(lhs)->value() == HeapNumber::cast(rhs)->value();
7017 // } else { 7003 // } else {
7018 // return false; 7004 // return false;
7019 // } 7005 // }
7020 // } 7006 // }
7021 // } 7007 // }
7022 7008
7023 typedef compiler::Node Node;
7024
7025 Label if_equal(this), if_notequal(this), end(this); 7009 Label if_equal(this), if_notequal(this), end(this);
7026 Variable result(this, MachineRepresentation::kTagged); 7010 Variable result(this, MachineRepresentation::kTagged);
7027 7011
7028 // Check if {lhs} and {rhs} refer to the same object. 7012 // Check if {lhs} and {rhs} refer to the same object.
7029 Label if_same(this), if_notsame(this); 7013 Label if_same(this), if_notsame(this);
7030 Branch(WordEqual(lhs, rhs), &if_same, &if_notsame); 7014 Branch(WordEqual(lhs, rhs), &if_same, &if_notsame);
7031 7015
7032 Bind(&if_same); 7016 Bind(&if_same);
7033 { 7017 {
7034 // The {lhs} and {rhs} reference the exact same value, yet we need special 7018 // 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
7216 Goto(&end); 7200 Goto(&end);
7217 } 7201 }
7218 7202
7219 Bind(&end); 7203 Bind(&end);
7220 return result.value(); 7204 return result.value();
7221 } 7205 }
7222 7206
7223 // ECMA#sec-samevalue 7207 // ECMA#sec-samevalue
7224 // This algorithm differs from the Strict Equality Comparison Algorithm in its 7208 // This algorithm differs from the Strict Equality Comparison Algorithm in its
7225 // treatment of signed zeroes and NaNs. 7209 // treatment of signed zeroes and NaNs.
7226 compiler::Node* CodeStubAssembler::SameValue(compiler::Node* lhs, 7210 Node* CodeStubAssembler::SameValue(Node* lhs, Node* rhs, Node* context) {
7227 compiler::Node* rhs,
7228 compiler::Node* context) {
7229 Variable var_result(this, MachineType::PointerRepresentation()); 7211 Variable var_result(this, MachineType::PointerRepresentation());
7230 Label strict_equal(this), out(this); 7212 Label strict_equal(this), out(this);
7231 7213
7232 Node* const int_false = IntPtrConstant(0); 7214 Node* const int_false = IntPtrConstant(0);
7233 Node* const int_true = IntPtrConstant(1); 7215 Node* const int_true = IntPtrConstant(1);
7234 7216
7235 Label if_equal(this), if_notequal(this); 7217 Label if_equal(this), if_notequal(this);
7236 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal); 7218 Branch(WordEqual(lhs, rhs), &if_equal, &if_notequal);
7237 7219
7238 Bind(&if_equal); 7220 Bind(&if_equal);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
7302 Node* const is_equal = StrictEqual(kDontNegateResult, lhs, rhs, context); 7284 Node* const is_equal = StrictEqual(kDontNegateResult, lhs, rhs, context);
7303 Node* const result = WordEqual(is_equal, TrueConstant()); 7285 Node* const result = WordEqual(is_equal, TrueConstant());
7304 var_result.Bind(result); 7286 var_result.Bind(result);
7305 Goto(&out); 7287 Goto(&out);
7306 } 7288 }
7307 7289
7308 Bind(&out); 7290 Bind(&out);
7309 return var_result.value(); 7291 return var_result.value();
7310 } 7292 }
7311 7293
7312 compiler::Node* CodeStubAssembler::ForInFilter(compiler::Node* key, 7294 Node* CodeStubAssembler::ForInFilter(Node* key, Node* object, Node* context) {
7313 compiler::Node* object,
7314 compiler::Node* context) {
7315 Label return_undefined(this, Label::kDeferred), return_to_name(this), 7295 Label return_undefined(this, Label::kDeferred), return_to_name(this),
7316 end(this); 7296 end(this);
7317 7297
7318 Variable var_result(this, MachineRepresentation::kTagged); 7298 Variable var_result(this, MachineRepresentation::kTagged);
7319 7299
7320 Node* has_property = 7300 Node* has_property =
7321 HasProperty(object, key, context, Runtime::kForInHasProperty); 7301 HasProperty(object, key, context, Runtime::kForInHasProperty);
7322 7302
7323 Branch(WordEqual(has_property, BooleanConstant(true)), &return_to_name, 7303 Branch(WordEqual(has_property, BooleanConstant(true)), &return_to_name,
7324 &return_undefined); 7304 &return_undefined);
7325 7305
7326 Bind(&return_to_name); 7306 Bind(&return_to_name);
7327 { 7307 {
7328 var_result.Bind(ToName(context, key)); 7308 var_result.Bind(ToName(context, key));
7329 Goto(&end); 7309 Goto(&end);
7330 } 7310 }
7331 7311
7332 Bind(&return_undefined); 7312 Bind(&return_undefined);
7333 { 7313 {
7334 var_result.Bind(UndefinedConstant()); 7314 var_result.Bind(UndefinedConstant());
7335 Goto(&end); 7315 Goto(&end);
7336 } 7316 }
7337 7317
7338 Bind(&end); 7318 Bind(&end);
7339 return var_result.value(); 7319 return var_result.value();
7340 } 7320 }
7341 7321
7342 compiler::Node* CodeStubAssembler::HasProperty( 7322 Node* CodeStubAssembler::HasProperty(
7343 compiler::Node* object, compiler::Node* key, compiler::Node* context, 7323 Node* object, Node* key, Node* context,
7344 Runtime::FunctionId fallback_runtime_function_id) { 7324 Runtime::FunctionId fallback_runtime_function_id) {
7345 typedef compiler::Node Node;
7346 typedef CodeStubAssembler::Label Label;
7347 typedef CodeStubAssembler::Variable Variable;
7348
7349 Label call_runtime(this, Label::kDeferred), return_true(this), 7325 Label call_runtime(this, Label::kDeferred), return_true(this),
7350 return_false(this), end(this); 7326 return_false(this), end(this);
7351 7327
7352 CodeStubAssembler::LookupInHolder lookup_property_in_holder = 7328 CodeStubAssembler::LookupInHolder lookup_property_in_holder =
7353 [this, &return_true](Node* receiver, Node* holder, Node* holder_map, 7329 [this, &return_true](Node* receiver, Node* holder, Node* holder_map,
7354 Node* holder_instance_type, Node* unique_name, 7330 Node* holder_instance_type, Node* unique_name,
7355 Label* next_holder, Label* if_bailout) { 7331 Label* next_holder, Label* if_bailout) {
7356 TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name, 7332 TryHasOwnProperty(holder, holder_map, holder_instance_type, unique_name,
7357 &return_true, next_holder, if_bailout); 7333 &return_true, next_holder, if_bailout);
7358 }; 7334 };
(...skipping 27 matching lines...) Expand all
7386 { 7362 {
7387 result.Bind( 7363 result.Bind(
7388 CallRuntime(fallback_runtime_function_id, context, object, key)); 7364 CallRuntime(fallback_runtime_function_id, context, object, key));
7389 Goto(&end); 7365 Goto(&end);
7390 } 7366 }
7391 7367
7392 Bind(&end); 7368 Bind(&end);
7393 return result.value(); 7369 return result.value();
7394 } 7370 }
7395 7371
7396 compiler::Node* CodeStubAssembler::Typeof(compiler::Node* value, 7372 Node* CodeStubAssembler::Typeof(Node* value, Node* context) {
7397 compiler::Node* context) {
7398 Variable result_var(this, MachineRepresentation::kTagged); 7373 Variable result_var(this, MachineRepresentation::kTagged);
7399 7374
7400 Label return_number(this, Label::kDeferred), if_oddball(this), 7375 Label return_number(this, Label::kDeferred), if_oddball(this),
7401 return_function(this), return_undefined(this), return_object(this), 7376 return_function(this), return_undefined(this), return_object(this),
7402 return_string(this), return_result(this); 7377 return_string(this), return_result(this);
7403 7378
7404 GotoIf(TaggedIsSmi(value), &return_number); 7379 GotoIf(TaggedIsSmi(value), &return_number);
7405 7380
7406 Node* map = LoadMap(value); 7381 Node* map = LoadMap(value);
7407 7382
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
7480 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \ 7455 result_var.Bind(HeapConstant(isolate()->factory()->type##_string())); \
7481 Goto(&return_result); \ 7456 Goto(&return_result); \
7482 } 7457 }
7483 SIMD128_TYPES(SIMD128_BIND_RETURN) 7458 SIMD128_TYPES(SIMD128_BIND_RETURN)
7484 #undef SIMD128_BIND_RETURN 7459 #undef SIMD128_BIND_RETURN
7485 7460
7486 Bind(&return_result); 7461 Bind(&return_result);
7487 return result_var.value(); 7462 return result_var.value();
7488 } 7463 }
7489 7464
7490 compiler::Node* CodeStubAssembler::InstanceOf(compiler::Node* object, 7465 Node* CodeStubAssembler::InstanceOf(Node* object, Node* callable,
7491 compiler::Node* callable, 7466 Node* context) {
7492 compiler::Node* context) {
7493 Label return_runtime(this, Label::kDeferred), end(this); 7467 Label return_runtime(this, Label::kDeferred), end(this);
7494 Variable result(this, MachineRepresentation::kTagged); 7468 Variable result(this, MachineRepresentation::kTagged);
7495 7469
7496 // Check if no one installed @@hasInstance somewhere. 7470 // Check if no one installed @@hasInstance somewhere.
7497 GotoUnless( 7471 GotoUnless(
7498 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex), 7472 WordEqual(LoadObjectField(LoadRoot(Heap::kHasInstanceProtectorRootIndex),
7499 PropertyCell::kValueOffset), 7473 PropertyCell::kValueOffset),
7500 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))), 7474 SmiConstant(Smi::FromInt(Isolate::kProtectorValid))),
7501 &return_runtime); 7475 &return_runtime);
7502 7476
7503 // Check if {callable} is a valid receiver. 7477 // Check if {callable} is a valid receiver.
7504 GotoIf(TaggedIsSmi(callable), &return_runtime); 7478 GotoIf(TaggedIsSmi(callable), &return_runtime);
7505 GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime); 7479 GotoUnless(IsCallableMap(LoadMap(callable)), &return_runtime);
7506 7480
7507 // Use the inline OrdinaryHasInstance directly. 7481 // Use the inline OrdinaryHasInstance directly.
7508 result.Bind(OrdinaryHasInstance(context, callable, object)); 7482 result.Bind(OrdinaryHasInstance(context, callable, object));
7509 Goto(&end); 7483 Goto(&end);
7510 7484
7511 // TODO(bmeurer): Use GetPropertyStub here once available. 7485 // TODO(bmeurer): Use GetPropertyStub here once available.
7512 Bind(&return_runtime); 7486 Bind(&return_runtime);
7513 { 7487 {
7514 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable)); 7488 result.Bind(CallRuntime(Runtime::kInstanceOf, context, object, callable));
7515 Goto(&end); 7489 Goto(&end);
7516 } 7490 }
7517 7491
7518 Bind(&end); 7492 Bind(&end);
7519 return result.value(); 7493 return result.value();
7520 } 7494 }
7521 7495
7522 compiler::Node* CodeStubAssembler::NumberInc(compiler::Node* value) { 7496 Node* CodeStubAssembler::NumberInc(Node* value) {
7523 Variable var_result(this, MachineRepresentation::kTagged), 7497 Variable var_result(this, MachineRepresentation::kTagged),
7524 var_finc_value(this, MachineRepresentation::kFloat64); 7498 var_finc_value(this, MachineRepresentation::kFloat64);
7525 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); 7499 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this);
7526 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); 7500 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
7527 7501
7528 Bind(&if_issmi); 7502 Bind(&if_issmi);
7529 { 7503 {
7530 // Try fast Smi addition first. 7504 // Try fast Smi addition first.
7531 Node* one = SmiConstant(Smi::FromInt(1)); 7505 Node* one = SmiConstant(Smi::FromInt(1));
7532 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value), 7506 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value),
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
7564 Node* one = Float64Constant(1.0); 7538 Node* one = Float64Constant(1.0);
7565 Node* finc_result = Float64Add(finc_value, one); 7539 Node* finc_result = Float64Add(finc_value, one);
7566 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); 7540 var_result.Bind(AllocateHeapNumberWithValue(finc_result));
7567 Goto(&end); 7541 Goto(&end);
7568 } 7542 }
7569 7543
7570 Bind(&end); 7544 Bind(&end);
7571 return var_result.value(); 7545 return var_result.value();
7572 } 7546 }
7573 7547
7574 compiler::Node* CodeStubAssembler::CreateArrayIterator( 7548 Node* CodeStubAssembler::CreateArrayIterator(Node* array, Node* array_map,
7575 compiler::Node* array, compiler::Node* array_map, 7549 Node* array_type, Node* context,
7576 compiler::Node* array_type, compiler::Node* context, IterationKind mode) { 7550 IterationKind mode) {
7577 int kBaseMapIndex = 0; 7551 int kBaseMapIndex = 0;
7578 switch (mode) { 7552 switch (mode) {
7579 case IterationKind::kKeys: 7553 case IterationKind::kKeys:
7580 kBaseMapIndex = Context::TYPED_ARRAY_KEY_ITERATOR_MAP_INDEX; 7554 kBaseMapIndex = Context::TYPED_ARRAY_KEY_ITERATOR_MAP_INDEX;
7581 break; 7555 break;
7582 case IterationKind::kValues: 7556 case IterationKind::kValues:
7583 kBaseMapIndex = Context::UINT8_ARRAY_VALUE_ITERATOR_MAP_INDEX; 7557 kBaseMapIndex = Context::UINT8_ARRAY_VALUE_ITERATOR_MAP_INDEX;
7584 break; 7558 break;
7585 case IterationKind::kEntries: 7559 case IterationKind::kEntries:
7586 kBaseMapIndex = Context::UINT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX; 7560 kBaseMapIndex = Context::UINT8_ARRAY_KEY_VALUE_ITERATOR_MAP_INDEX;
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after
7752 LoadFixedArrayElement(LoadNativeContext(context), var_map_index.value(), 7726 LoadFixedArrayElement(LoadNativeContext(context), var_map_index.value(),
7753 0, CodeStubAssembler::INTPTR_PARAMETERS); 7727 0, CodeStubAssembler::INTPTR_PARAMETERS);
7754 var_result.Bind(AllocateJSArrayIterator(array, var_array_map.value(), map)); 7728 var_result.Bind(AllocateJSArrayIterator(array, var_array_map.value(), map));
7755 Goto(&return_result); 7729 Goto(&return_result);
7756 } 7730 }
7757 7731
7758 Bind(&return_result); 7732 Bind(&return_result);
7759 return var_result.value(); 7733 return var_result.value();
7760 } 7734 }
7761 7735
7762 compiler::Node* CodeStubAssembler::AllocateJSArrayIterator( 7736 Node* CodeStubAssembler::AllocateJSArrayIterator(Node* array, Node* array_map,
7763 compiler::Node* array, compiler::Node* array_map, compiler::Node* map) { 7737 Node* map) {
7764 Node* iterator = Allocate(JSArrayIterator::kSize); 7738 Node* iterator = Allocate(JSArrayIterator::kSize);
7765 StoreMapNoWriteBarrier(iterator, map); 7739 StoreMapNoWriteBarrier(iterator, map);
7766 StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOffset, 7740 StoreObjectFieldRoot(iterator, JSArrayIterator::kPropertiesOffset,
7767 Heap::kEmptyFixedArrayRootIndex); 7741 Heap::kEmptyFixedArrayRootIndex);
7768 StoreObjectFieldRoot(iterator, JSArrayIterator::kElementsOffset, 7742 StoreObjectFieldRoot(iterator, JSArrayIterator::kElementsOffset,
7769 Heap::kEmptyFixedArrayRootIndex); 7743 Heap::kEmptyFixedArrayRootIndex);
7770 StoreObjectFieldNoWriteBarrier(iterator, 7744 StoreObjectFieldNoWriteBarrier(iterator,
7771 JSArrayIterator::kIteratedObjectOffset, array); 7745 JSArrayIterator::kIteratedObjectOffset, array);
7772 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset, 7746 StoreObjectFieldNoWriteBarrier(iterator, JSArrayIterator::kNextIndexOffset,
7773 SmiConstant(Smi::FromInt(0))); 7747 SmiConstant(Smi::FromInt(0)));
7774 StoreObjectFieldNoWriteBarrier( 7748 StoreObjectFieldNoWriteBarrier(
7775 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map); 7749 iterator, JSArrayIterator::kIteratedObjectMapOffset, array_map);
7776 return iterator; 7750 return iterator;
7777 } 7751 }
7778 7752
7779 compiler::Node* CodeStubAssembler::IsDetachedBuffer(compiler::Node* buffer) { 7753 Node* CodeStubAssembler::IsDetachedBuffer(Node* buffer) {
7780 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE)); 7754 CSA_ASSERT(this, HasInstanceType(buffer, JS_ARRAY_BUFFER_TYPE));
7781 7755
7782 Node* buffer_bit_field = LoadObjectField( 7756 Node* buffer_bit_field = LoadObjectField(
7783 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); 7757 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32());
7784 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); 7758 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask);
7785 7759
7786 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), 7760 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask),
7787 Int32Constant(0)); 7761 Int32Constant(0));
7788 } 7762 }
7789 7763
7790 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, 7764 CodeStubArguments::CodeStubArguments(CodeStubAssembler* assembler, Node* argc,
7791 compiler::Node* argc,
7792 CodeStubAssembler::ParameterMode mode) 7765 CodeStubAssembler::ParameterMode mode)
7793 : assembler_(assembler), 7766 : assembler_(assembler),
7794 argc_(argc), 7767 argc_(argc),
7795 arguments_(nullptr), 7768 arguments_(nullptr),
7796 fp_(assembler->LoadFramePointer()) { 7769 fp_(assembler->LoadFramePointer()) {
7797 compiler::Node* offset = assembler->ElementOffsetFromIndex( 7770 Node* offset = assembler->ElementOffsetFromIndex(
7798 argc_, FAST_ELEMENTS, mode, 7771 argc_, FAST_ELEMENTS, mode,
7799 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize); 7772 (StandardFrameConstants::kFixedSlotCountAboveFp - 1) * kPointerSize);
7800 arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset); 7773 arguments_ = assembler_->IntPtrAddFoldConstants(fp_, offset);
7801 if (mode == CodeStubAssembler::INTEGER_PARAMETERS) { 7774 if (mode == CodeStubAssembler::INTEGER_PARAMETERS) {
7802 argc_ = assembler->ChangeInt32ToIntPtr(argc_); 7775 argc_ = assembler->ChangeInt32ToIntPtr(argc_);
7803 } else if (mode == CodeStubAssembler::SMI_PARAMETERS) { 7776 } else if (mode == CodeStubAssembler::SMI_PARAMETERS) {
7804 argc_ = assembler->SmiUntag(argc_); 7777 argc_ = assembler->SmiUntag(argc_);
7805 } 7778 }
7806 } 7779 }
7807 7780
7808 compiler::Node* CodeStubArguments::GetReceiver() { 7781 Node* CodeStubArguments::GetReceiver() {
7809 return assembler_->Load(MachineType::AnyTagged(), arguments_, 7782 return assembler_->Load(MachineType::AnyTagged(), arguments_,
7810 assembler_->IntPtrConstant(kPointerSize)); 7783 assembler_->IntPtrConstant(kPointerSize));
7811 } 7784 }
7812 7785
7813 compiler::Node* CodeStubArguments::AtIndex( 7786 Node* CodeStubArguments::AtIndex(Node* index,
7814 compiler::Node* index, CodeStubAssembler::ParameterMode mode) { 7787 CodeStubAssembler::ParameterMode mode) {
7815 typedef compiler::Node Node;
7816 Node* negated_index = assembler_->IntPtrSubFoldConstants( 7788 Node* negated_index = assembler_->IntPtrSubFoldConstants(
7817 assembler_->IntPtrOrSmiConstant(0, mode), index); 7789 assembler_->IntPtrOrSmiConstant(0, mode), index);
7818 Node* offset = 7790 Node* offset =
7819 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0); 7791 assembler_->ElementOffsetFromIndex(negated_index, FAST_ELEMENTS, mode, 0);
7820 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset); 7792 return assembler_->Load(MachineType::AnyTagged(), arguments_, offset);
7821 } 7793 }
7822 7794
7823 compiler::Node* CodeStubArguments::AtIndex(int index) { 7795 Node* CodeStubArguments::AtIndex(int index) {
7824 return AtIndex(assembler_->IntPtrConstant(index)); 7796 return AtIndex(assembler_->IntPtrConstant(index));
7825 } 7797 }
7826 7798
7827 void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars, 7799 void CodeStubArguments::ForEach(const CodeStubAssembler::VariableList& vars,
7828 CodeStubArguments::ForEachBodyFunction body, 7800 CodeStubArguments::ForEachBodyFunction body,
7829 compiler::Node* first, compiler::Node* last, 7801 Node* first, Node* last,
7830 CodeStubAssembler::ParameterMode mode) { 7802 CodeStubAssembler::ParameterMode mode) {
7831 assembler_->Comment("CodeStubArguments::ForEach"); 7803 assembler_->Comment("CodeStubArguments::ForEach");
7832 DCHECK_IMPLIES(first == nullptr || last == nullptr, 7804 DCHECK_IMPLIES(first == nullptr || last == nullptr,
7833 mode == CodeStubAssembler::INTPTR_PARAMETERS); 7805 mode == CodeStubAssembler::INTPTR_PARAMETERS);
7834 if (first == nullptr) { 7806 if (first == nullptr) {
7835 first = assembler_->IntPtrOrSmiConstant(0, mode); 7807 first = assembler_->IntPtrOrSmiConstant(0, mode);
7836 } 7808 }
7837 if (last == nullptr) { 7809 if (last == nullptr) {
7838 last = argc_; 7810 last = argc_;
7839 } 7811 }
7840 compiler::Node* start = assembler_->IntPtrSubFoldConstants( 7812 Node* start = assembler_->IntPtrSubFoldConstants(
7841 arguments_, 7813 arguments_,
7842 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode)); 7814 assembler_->ElementOffsetFromIndex(first, FAST_ELEMENTS, mode));
7843 compiler::Node* end = assembler_->IntPtrSubFoldConstants( 7815 Node* end = assembler_->IntPtrSubFoldConstants(
7844 arguments_, 7816 arguments_,
7845 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode)); 7817 assembler_->ElementOffsetFromIndex(last, FAST_ELEMENTS, mode));
7846 assembler_->BuildFastLoop( 7818 assembler_->BuildFastLoop(
7847 vars, MachineType::PointerRepresentation(), start, end, 7819 vars, MachineType::PointerRepresentation(), start, end,
7848 [body](CodeStubAssembler* assembler, compiler::Node* current) { 7820 [body](CodeStubAssembler* assembler, Node* current) {
7849 Node* arg = assembler->Load(MachineType::AnyTagged(), current); 7821 Node* arg = assembler->Load(MachineType::AnyTagged(), current);
7850 body(assembler, arg); 7822 body(assembler, arg);
7851 }, 7823 },
7852 -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost); 7824 -kPointerSize, CodeStubAssembler::IndexAdvanceMode::kPost);
7853 } 7825 }
7854 7826
7855 void CodeStubArguments::PopAndReturn(compiler::Node* value) { 7827 void CodeStubArguments::PopAndReturn(Node* value) {
7856 assembler_->PopAndReturn( 7828 assembler_->PopAndReturn(
7857 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)), 7829 assembler_->IntPtrAddFoldConstants(argc_, assembler_->IntPtrConstant(1)),
7858 value); 7830 value);
7859 } 7831 }
7860 7832
7861 compiler::Node* CodeStubAssembler::IsFastElementsKind( 7833 Node* CodeStubAssembler::IsFastElementsKind(Node* elements_kind) {
7862 compiler::Node* elements_kind) {
7863 return Uint32LessThanOrEqual(elements_kind, 7834 return Uint32LessThanOrEqual(elements_kind,
7864 Int32Constant(LAST_FAST_ELEMENTS_KIND)); 7835 Int32Constant(LAST_FAST_ELEMENTS_KIND));
7865 } 7836 }
7866 7837
7867 compiler::Node* CodeStubAssembler::IsHoleyFastElementsKind( 7838 Node* CodeStubAssembler::IsHoleyFastElementsKind(Node* elements_kind) {
7868 compiler::Node* elements_kind) {
7869 CSA_ASSERT(this, IsFastElementsKind(elements_kind)); 7839 CSA_ASSERT(this, IsFastElementsKind(elements_kind));
7870 7840
7871 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1)); 7841 STATIC_ASSERT(FAST_HOLEY_SMI_ELEMENTS == (FAST_SMI_ELEMENTS | 1));
7872 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1)); 7842 STATIC_ASSERT(FAST_HOLEY_ELEMENTS == (FAST_ELEMENTS | 1));
7873 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1)); 7843 STATIC_ASSERT(FAST_HOLEY_DOUBLE_ELEMENTS == (FAST_DOUBLE_ELEMENTS | 1));
7874 7844
7875 // Check prototype chain if receiver does not have packed elements. 7845 // Check prototype chain if receiver does not have packed elements.
7876 Node* holey_elements = Word32And(elements_kind, Int32Constant(1)); 7846 Node* holey_elements = Word32And(elements_kind, Int32Constant(1));
7877 return Word32Equal(holey_elements, Int32Constant(1)); 7847 return Word32Equal(holey_elements, Int32Constant(1));
7878 } 7848 }
7879 7849
7880 compiler::Node* CodeStubAssembler::IsDebugActive() { 7850 Node* CodeStubAssembler::IsDebugActive() {
7881 Node* is_debug_active = Load( 7851 Node* is_debug_active = Load(
7882 MachineType::Uint8(), 7852 MachineType::Uint8(),
7883 ExternalConstant(ExternalReference::debug_is_active_address(isolate()))); 7853 ExternalConstant(ExternalReference::debug_is_active_address(isolate())));
7884 return WordNotEqual(is_debug_active, Int32Constant(0)); 7854 return WordNotEqual(is_debug_active, Int32Constant(0));
7885 } 7855 }
7886 7856
7887 } // namespace internal 7857 } // namespace internal
7888 } // namespace v8 7858 } // 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