| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 #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 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 Branch(condition, &ok, ¬_ok); | 67 Branch(condition, &ok, ¬_ok); |
| 68 BIND(¬_ok); | 68 BIND(¬_ok); |
| 69 if (message != nullptr) { | 69 if (message != nullptr) { |
| 70 char chars[1024]; | 70 char chars[1024]; |
| 71 Vector<char> buffer(chars); | 71 Vector<char> buffer(chars); |
| 72 if (file != nullptr) { | 72 if (file != nullptr) { |
| 73 SNPrintF(buffer, "CSA_ASSERT failed: %s [%s:%d]\n", message, file, line); | 73 SNPrintF(buffer, "CSA_ASSERT failed: %s [%s:%d]\n", message, file, line); |
| 74 } else { | 74 } else { |
| 75 SNPrintF(buffer, "CSA_ASSERT failed: %s\n", message); | 75 SNPrintF(buffer, "CSA_ASSERT failed: %s\n", message); |
| 76 } | 76 } |
| 77 CallRuntime(Runtime::kGlobalPrint, SmiConstant(0), | 77 CallRuntime( |
| 78 HeapConstant(factory()->InternalizeUtf8String(&(buffer[0])))); | 78 Runtime::kGlobalPrint, SmiConstant(Smi::kZero), |
| 79 HeapConstant(factory()->NewStringFromAsciiChecked(&(buffer[0])))); |
| 79 } | 80 } |
| 80 DebugBreak(); | 81 DebugBreak(); |
| 81 Goto(&ok); | 82 Goto(&ok); |
| 82 BIND(&ok); | 83 BIND(&ok); |
| 83 Comment("] Assert"); | 84 Comment("] Assert"); |
| 84 } | 85 } |
| 85 | 86 |
| 86 Node* CodeStubAssembler::Select(Node* condition, const NodeGenerator& true_body, | 87 Node* CodeStubAssembler::Select(Node* condition, const NodeGenerator& true_body, |
| 87 const NodeGenerator& false_body, | 88 const NodeGenerator& false_body, |
| 88 MachineRepresentation rep) { | 89 MachineRepresentation rep) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) { | 191 Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) { |
| 191 Comment("IntPtrRoundUpToPowerOfTwo32"); | 192 Comment("IntPtrRoundUpToPowerOfTwo32"); |
| 192 CSA_ASSERT(this, UintPtrLessThanOrEqual(value, IntPtrConstant(0x80000000u))); | 193 CSA_ASSERT(this, UintPtrLessThanOrEqual(value, IntPtrConstant(0x80000000u))); |
| 193 value = IntPtrSub(value, IntPtrConstant(1)); | 194 value = IntPtrSub(value, IntPtrConstant(1)); |
| 194 for (int i = 1; i <= 16; i *= 2) { | 195 for (int i = 1; i <= 16; i *= 2) { |
| 195 value = WordOr(value, WordShr(value, IntPtrConstant(i))); | 196 value = WordOr(value, WordShr(value, IntPtrConstant(i))); |
| 196 } | 197 } |
| 197 return IntPtrAdd(value, IntPtrConstant(1)); | 198 return IntPtrAdd(value, IntPtrConstant(1)); |
| 198 } | 199 } |
| 199 | 200 |
| 200 Node* CodeStubAssembler::MatchesParameterMode(Node* value, ParameterMode mode) { | |
| 201 return (mode == SMI_PARAMETERS) ? TaggedIsSmi(value) : Int32Constant(1); | |
| 202 } | |
| 203 | |
| 204 Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { | 201 Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { |
| 205 // value && !(value & (value - 1)) | 202 // value && !(value & (value - 1)) |
| 206 return WordEqual( | 203 return WordEqual( |
| 207 Select( | 204 Select( |
| 208 WordEqual(value, IntPtrConstant(0)), | 205 WordEqual(value, IntPtrConstant(0)), |
| 209 [=] { return IntPtrConstant(1); }, | 206 [=] { return IntPtrConstant(1); }, |
| 210 [=] { return WordAnd(value, IntPtrSub(value, IntPtrConstant(1))); }, | 207 [=] { return WordAnd(value, IntPtrSub(value, IntPtrConstant(1))); }, |
| 211 MachineType::PointerRepresentation()), | 208 MachineType::PointerRepresentation()), |
| 212 IntPtrConstant(0)); | 209 IntPtrConstant(0)); |
| 213 } | 210 } |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 | 434 |
| 438 Node* CodeStubAssembler::SmiTag(Node* value) { | 435 Node* CodeStubAssembler::SmiTag(Node* value) { |
| 439 int32_t constant_value; | 436 int32_t constant_value; |
| 440 if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { | 437 if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { |
| 441 return SmiConstant(Smi::FromInt(constant_value)); | 438 return SmiConstant(Smi::FromInt(constant_value)); |
| 442 } | 439 } |
| 443 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant())); | 440 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant())); |
| 444 } | 441 } |
| 445 | 442 |
| 446 Node* CodeStubAssembler::SmiUntag(Node* value) { | 443 Node* CodeStubAssembler::SmiUntag(Node* value) { |
| 447 CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); | |
| 448 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); | 444 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); |
| 449 } | 445 } |
| 450 | 446 |
| 451 Node* CodeStubAssembler::SmiToWord32(Node* value) { | 447 Node* CodeStubAssembler::SmiToWord32(Node* value) { |
| 452 CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); | |
| 453 Node* result = SmiUntag(value); | 448 Node* result = SmiUntag(value); |
| 454 return TruncateWordToWord32(result); | 449 return TruncateWordToWord32(result); |
| 455 } | 450 } |
| 456 | 451 |
| 457 Node* CodeStubAssembler::SmiToFloat64(Node* value) { | 452 Node* CodeStubAssembler::SmiToFloat64(Node* value) { |
| 458 CSA_SLOW_ASSERT(this, TaggedIsSmi(value)); | |
| 459 return ChangeInt32ToFloat64(SmiToWord32(value)); | 453 return ChangeInt32ToFloat64(SmiToWord32(value)); |
| 460 } | 454 } |
| 461 | 455 |
| 462 Node* CodeStubAssembler::SmiMax(Node* a, Node* b) { | 456 Node* CodeStubAssembler::SmiMax(Node* a, Node* b) { |
| 463 return SelectTaggedConstant(SmiLessThan(a, b), b, a); | 457 return SelectTaggedConstant(SmiLessThan(a, b), b, a); |
| 464 } | 458 } |
| 465 | 459 |
| 466 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) { | 460 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) { |
| 467 return SelectTaggedConstant(SmiLessThan(a, b), a, b); | 461 return SelectTaggedConstant(SmiLessThan(a, b), a, b); |
| 468 } | 462 } |
| 469 | 463 |
| 470 Node* CodeStubAssembler::SmiMod(Node* a, Node* b) { | 464 Node* CodeStubAssembler::SmiMod(Node* a, Node* b) { |
| 471 CSA_SLOW_ASSERT(this, TaggedIsSmi(a)); | |
| 472 CSA_SLOW_ASSERT(this, TaggedIsSmi(b)); | |
| 473 VARIABLE(var_result, MachineRepresentation::kTagged); | 465 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 474 Label return_result(this, &var_result), | 466 Label return_result(this, &var_result), |
| 475 return_minuszero(this, Label::kDeferred), | 467 return_minuszero(this, Label::kDeferred), |
| 476 return_nan(this, Label::kDeferred); | 468 return_nan(this, Label::kDeferred); |
| 477 | 469 |
| 478 // Untag {a} and {b}. | 470 // Untag {a} and {b}. |
| 479 a = SmiToWord32(a); | 471 a = SmiToWord32(a); |
| 480 b = SmiToWord32(b); | 472 b = SmiToWord32(b); |
| 481 | 473 |
| 482 // Return NaN if {b} is zero. | 474 // Return NaN if {b} is zero. |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 522 | 514 |
| 523 BIND(&return_minuszero); | 515 BIND(&return_minuszero); |
| 524 var_result.Bind(MinusZeroConstant()); | 516 var_result.Bind(MinusZeroConstant()); |
| 525 Goto(&return_result); | 517 Goto(&return_result); |
| 526 | 518 |
| 527 BIND(&return_nan); | 519 BIND(&return_nan); |
| 528 var_result.Bind(NanConstant()); | 520 var_result.Bind(NanConstant()); |
| 529 Goto(&return_result); | 521 Goto(&return_result); |
| 530 | 522 |
| 531 BIND(&return_result); | 523 BIND(&return_result); |
| 532 CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); | |
| 533 return var_result.value(); | 524 return var_result.value(); |
| 534 } | 525 } |
| 535 | 526 |
| 536 Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { | 527 Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { |
| 537 VARIABLE(var_result, MachineRepresentation::kTagged); | 528 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 538 VARIABLE(var_lhs_float64, MachineRepresentation::kFloat64); | 529 VARIABLE(var_lhs_float64, MachineRepresentation::kFloat64); |
| 539 VARIABLE(var_rhs_float64, MachineRepresentation::kFloat64); | 530 VARIABLE(var_rhs_float64, MachineRepresentation::kFloat64); |
| 540 Label return_result(this, &var_result); | 531 Label return_result(this, &var_result); |
| 541 | 532 |
| 542 // Both {a} and {b} are Smis. Convert them to integers and multiply. | 533 // Both {a} and {b} are Smis. Convert them to integers and multiply. |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 584 { | 575 { |
| 585 var_lhs_float64.Bind(SmiToFloat64(a)); | 576 var_lhs_float64.Bind(SmiToFloat64(a)); |
| 586 var_rhs_float64.Bind(SmiToFloat64(b)); | 577 var_rhs_float64.Bind(SmiToFloat64(b)); |
| 587 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); | 578 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); |
| 588 Node* result = AllocateHeapNumberWithValue(value); | 579 Node* result = AllocateHeapNumberWithValue(value); |
| 589 var_result.Bind(result); | 580 var_result.Bind(result); |
| 590 Goto(&return_result); | 581 Goto(&return_result); |
| 591 } | 582 } |
| 592 | 583 |
| 593 BIND(&return_result); | 584 BIND(&return_result); |
| 594 CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); | |
| 595 return var_result.value(); | 585 return var_result.value(); |
| 596 } | 586 } |
| 597 | 587 |
| 598 Node* CodeStubAssembler::TrySmiDiv(Node* dividend, Node* divisor, | 588 Node* CodeStubAssembler::TrySmiDiv(Node* dividend, Node* divisor, |
| 599 Label* bailout) { | 589 Label* bailout) { |
| 600 CSA_SLOW_ASSERT(this, TaggedIsSmi(dividend)); | |
| 601 CSA_SLOW_ASSERT(this, TaggedIsSmi(divisor)); | |
| 602 | |
| 603 // Both {a} and {b} are Smis. Bailout to floating point division if {divisor} | 590 // Both {a} and {b} are Smis. Bailout to floating point division if {divisor} |
| 604 // is zero. | 591 // is zero. |
| 605 GotoIf(WordEqual(divisor, SmiConstant(0)), bailout); | 592 GotoIf(WordEqual(divisor, SmiConstant(0)), bailout); |
| 606 | 593 |
| 607 // Do floating point division if {dividend} is zero and {divisor} is | 594 // Do floating point division if {dividend} is zero and {divisor} is |
| 608 // negative. | 595 // negative. |
| 609 Label dividend_is_zero(this), dividend_is_not_zero(this); | 596 Label dividend_is_zero(this), dividend_is_not_zero(this); |
| 610 Branch(WordEqual(dividend, SmiConstant(0)), ÷nd_is_zero, | 597 Branch(WordEqual(dividend, SmiConstant(0)), ÷nd_is_zero, |
| 611 ÷nd_is_not_zero); | 598 ÷nd_is_not_zero); |
| 612 | 599 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 670 } | 657 } |
| 671 | 658 |
| 672 Node* CodeStubAssembler::WordIsWordAligned(Node* word) { | 659 Node* CodeStubAssembler::WordIsWordAligned(Node* word) { |
| 673 return WordEqual(IntPtrConstant(0), | 660 return WordEqual(IntPtrConstant(0), |
| 674 WordAnd(word, IntPtrConstant((1 << kPointerSizeLog2) - 1))); | 661 WordAnd(word, IntPtrConstant((1 << kPointerSizeLog2) - 1))); |
| 675 } | 662 } |
| 676 | 663 |
| 677 void CodeStubAssembler::BranchIfPrototypesHaveNoElements( | 664 void CodeStubAssembler::BranchIfPrototypesHaveNoElements( |
| 678 Node* receiver_map, Label* definitely_no_elements, | 665 Node* receiver_map, Label* definitely_no_elements, |
| 679 Label* possibly_elements) { | 666 Label* possibly_elements) { |
| 680 CSA_SLOW_ASSERT(this, IsMap(receiver_map)); | |
| 681 VARIABLE(var_map, MachineRepresentation::kTagged, receiver_map); | 667 VARIABLE(var_map, MachineRepresentation::kTagged, receiver_map); |
| 682 Label loop_body(this, &var_map); | 668 Label loop_body(this, &var_map); |
| 683 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex); | 669 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex); |
| 684 Goto(&loop_body); | 670 Goto(&loop_body); |
| 685 | 671 |
| 686 BIND(&loop_body); | 672 BIND(&loop_body); |
| 687 { | 673 { |
| 688 Node* map = var_map.value(); | 674 Node* map = var_map.value(); |
| 689 Node* prototype = LoadMapPrototype(map); | 675 Node* prototype = LoadMapPrototype(map); |
| 690 GotoIf(WordEqual(prototype, NullConstant()), definitely_no_elements); | 676 GotoIf(WordEqual(prototype, NullConstant()), definitely_no_elements); |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 return Load(rep, buffer, IntPtrConstant(offset)); | 979 return Load(rep, buffer, IntPtrConstant(offset)); |
| 994 } | 980 } |
| 995 | 981 |
| 996 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset, | 982 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset, |
| 997 MachineType rep) { | 983 MachineType rep) { |
| 998 return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag)); | 984 return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag)); |
| 999 } | 985 } |
| 1000 | 986 |
| 1001 Node* CodeStubAssembler::LoadObjectField(Node* object, Node* offset, | 987 Node* CodeStubAssembler::LoadObjectField(Node* object, Node* offset, |
| 1002 MachineType rep) { | 988 MachineType rep) { |
| 1003 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1004 return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))); | 989 return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))); |
| 1005 } | 990 } |
| 1006 | 991 |
| 1007 Node* CodeStubAssembler::LoadAndUntagObjectField(Node* object, int offset) { | 992 Node* CodeStubAssembler::LoadAndUntagObjectField(Node* object, int offset) { |
| 1008 if (Is64()) { | 993 if (Is64()) { |
| 1009 #if V8_TARGET_LITTLE_ENDIAN | 994 #if V8_TARGET_LITTLE_ENDIAN |
| 1010 offset += kPointerSize / 2; | 995 offset += kPointerSize / 2; |
| 1011 #endif | 996 #endif |
| 1012 return ChangeInt32ToInt64( | 997 return ChangeInt32ToInt64( |
| 1013 LoadObjectField(object, offset, MachineType::Int32())); | 998 LoadObjectField(object, offset, MachineType::Int32())); |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1070 return StoreNoWriteBarrier(MachineRepresentation::kWord32, base, | 1055 return StoreNoWriteBarrier(MachineRepresentation::kWord32, base, |
| 1071 IntPtrConstant(payload_offset), | 1056 IntPtrConstant(payload_offset), |
| 1072 TruncateInt64ToInt32(value)); | 1057 TruncateInt64ToInt32(value)); |
| 1073 } else { | 1058 } else { |
| 1074 return StoreNoWriteBarrier(MachineRepresentation::kTaggedSigned, base, | 1059 return StoreNoWriteBarrier(MachineRepresentation::kTaggedSigned, base, |
| 1075 IntPtrConstant(offset), SmiTag(value)); | 1060 IntPtrConstant(offset), SmiTag(value)); |
| 1076 } | 1061 } |
| 1077 } | 1062 } |
| 1078 | 1063 |
| 1079 Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) { | 1064 Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) { |
| 1080 CSA_SLOW_ASSERT(this, IsAnyHeapNumber(object)); | |
| 1081 return LoadObjectField(object, HeapNumber::kValueOffset, | 1065 return LoadObjectField(object, HeapNumber::kValueOffset, |
| 1082 MachineType::Float64()); | 1066 MachineType::Float64()); |
| 1083 } | 1067 } |
| 1084 | 1068 |
| 1085 Node* CodeStubAssembler::LoadMap(Node* object) { | 1069 Node* CodeStubAssembler::LoadMap(Node* object) { |
| 1086 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1087 return LoadObjectField(object, HeapObject::kMapOffset); | 1070 return LoadObjectField(object, HeapObject::kMapOffset); |
| 1088 } | 1071 } |
| 1089 | 1072 |
| 1090 Node* CodeStubAssembler::LoadInstanceType(Node* object) { | 1073 Node* CodeStubAssembler::LoadInstanceType(Node* object) { |
| 1091 return LoadMapInstanceType(LoadMap(object)); | 1074 return LoadMapInstanceType(LoadMap(object)); |
| 1092 } | 1075 } |
| 1093 | 1076 |
| 1094 Node* CodeStubAssembler::HasInstanceType(Node* object, | 1077 Node* CodeStubAssembler::HasInstanceType(Node* object, |
| 1095 InstanceType instance_type) { | 1078 InstanceType instance_type) { |
| 1096 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type)); | 1079 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type)); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1131 CSA_SLOW_ASSERT(this, IsMap(map)); | 1114 CSA_SLOW_ASSERT(this, IsMap(map)); |
| 1132 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8()); | 1115 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8()); |
| 1133 } | 1116 } |
| 1134 | 1117 |
| 1135 Node* CodeStubAssembler::LoadMapBitField3(Node* map) { | 1118 Node* CodeStubAssembler::LoadMapBitField3(Node* map) { |
| 1136 CSA_SLOW_ASSERT(this, IsMap(map)); | 1119 CSA_SLOW_ASSERT(this, IsMap(map)); |
| 1137 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32()); | 1120 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32()); |
| 1138 } | 1121 } |
| 1139 | 1122 |
| 1140 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { | 1123 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { |
| 1141 CSA_SLOW_ASSERT(this, IsMap(map)); | |
| 1142 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); | 1124 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); |
| 1143 } | 1125 } |
| 1144 | 1126 |
| 1145 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) { | 1127 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) { |
| 1146 CSA_SLOW_ASSERT(this, IsMap(map)); | 1128 CSA_SLOW_ASSERT(this, IsMap(map)); |
| 1147 Node* bit_field2 = LoadMapBitField2(map); | 1129 Node* bit_field2 = LoadMapBitField2(map); |
| 1148 return DecodeWord32<Map::ElementsKindBits>(bit_field2); | 1130 return DecodeWord32<Map::ElementsKindBits>(bit_field2); |
| 1149 } | 1131 } |
| 1150 | 1132 |
| 1151 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { | 1133 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1215 result.Bind( | 1197 result.Bind( |
| 1216 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset)); | 1198 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset)); |
| 1217 Goto(&loop); | 1199 Goto(&loop); |
| 1218 } | 1200 } |
| 1219 BIND(&done); | 1201 BIND(&done); |
| 1220 return result.value(); | 1202 return result.value(); |
| 1221 } | 1203 } |
| 1222 | 1204 |
| 1223 Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField( | 1205 Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField( |
| 1224 Node* shared, int offset, ParameterMode mode) { | 1206 Node* shared, int offset, ParameterMode mode) { |
| 1225 CSA_SLOW_ASSERT(this, HasInstanceType(shared, SHARED_FUNCTION_INFO_TYPE)); | |
| 1226 if (Is64()) { | 1207 if (Is64()) { |
| 1227 Node* result = LoadObjectField(shared, offset, MachineType::Int32()); | 1208 Node* result = LoadObjectField(shared, offset, MachineType::Int32()); |
| 1228 if (mode == SMI_PARAMETERS) { | 1209 if (mode == SMI_PARAMETERS) { |
| 1229 result = SmiTag(result); | 1210 result = SmiTag(result); |
| 1230 } else { | 1211 } else { |
| 1231 result = ChangeUint32ToWord(result); | 1212 result = ChangeUint32ToWord(result); |
| 1232 } | 1213 } |
| 1233 return result; | 1214 return result; |
| 1234 } else { | 1215 } else { |
| 1235 Node* result = LoadObjectField(shared, offset); | 1216 Node* result = LoadObjectField(shared, offset); |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1360 return AllocateHeapNumberWithValue(value); | 1341 return AllocateHeapNumberWithValue(value); |
| 1361 default: | 1342 default: |
| 1362 UNREACHABLE(); | 1343 UNREACHABLE(); |
| 1363 return nullptr; | 1344 return nullptr; |
| 1364 } | 1345 } |
| 1365 } | 1346 } |
| 1366 | 1347 |
| 1367 Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement( | 1348 Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement( |
| 1368 Node* object, Node* index_node, int additional_offset, | 1349 Node* object, Node* index_node, int additional_offset, |
| 1369 ParameterMode parameter_mode) { | 1350 ParameterMode parameter_mode) { |
| 1370 CSA_SLOW_ASSERT(this, IsFixedArray(object)); | |
| 1371 CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode)); | |
| 1372 int32_t header_size = | 1351 int32_t header_size = |
| 1373 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; | 1352 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| 1374 #if V8_TARGET_LITTLE_ENDIAN | 1353 #if V8_TARGET_LITTLE_ENDIAN |
| 1375 if (Is64()) { | 1354 if (Is64()) { |
| 1376 header_size += kPointerSize / 2; | 1355 header_size += kPointerSize / 2; |
| 1377 } | 1356 } |
| 1378 #endif | 1357 #endif |
| 1379 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, | 1358 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
| 1380 parameter_mode, header_size); | 1359 parameter_mode, header_size); |
| 1381 if (Is64()) { | 1360 if (Is64()) { |
| 1382 return Load(MachineType::Int32(), object, offset); | 1361 return Load(MachineType::Int32(), object, offset); |
| 1383 } else { | 1362 } else { |
| 1384 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); | 1363 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); |
| 1385 } | 1364 } |
| 1386 } | 1365 } |
| 1387 | 1366 |
| 1388 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( | 1367 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( |
| 1389 Node* object, Node* index_node, MachineType machine_type, | 1368 Node* object, Node* index_node, MachineType machine_type, |
| 1390 int additional_offset, ParameterMode parameter_mode, Label* if_hole) { | 1369 int additional_offset, ParameterMode parameter_mode, Label* if_hole) { |
| 1391 CSA_SLOW_ASSERT(this, IsFixedDoubleArray(object)); | |
| 1392 CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode)); | |
| 1393 CSA_ASSERT(this, IsFixedDoubleArray(object)); | 1370 CSA_ASSERT(this, IsFixedDoubleArray(object)); |
| 1394 int32_t header_size = | 1371 int32_t header_size = |
| 1395 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; | 1372 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| 1396 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, | 1373 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, |
| 1397 parameter_mode, header_size); | 1374 parameter_mode, header_size); |
| 1398 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type); | 1375 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type); |
| 1399 } | 1376 } |
| 1400 | 1377 |
| 1401 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, | 1378 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, |
| 1402 Label* if_hole, | 1379 Label* if_hole, |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1417 } | 1394 } |
| 1418 } | 1395 } |
| 1419 if (machine_type.IsNone()) { | 1396 if (machine_type.IsNone()) { |
| 1420 // This means the actual value is not needed. | 1397 // This means the actual value is not needed. |
| 1421 return nullptr; | 1398 return nullptr; |
| 1422 } | 1399 } |
| 1423 return Load(machine_type, base, offset); | 1400 return Load(machine_type, base, offset); |
| 1424 } | 1401 } |
| 1425 | 1402 |
| 1426 Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) { | 1403 Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) { |
| 1427 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1428 int offset = Context::SlotOffset(slot_index); | 1404 int offset = Context::SlotOffset(slot_index); |
| 1429 return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset)); | 1405 return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset)); |
| 1430 } | 1406 } |
| 1431 | 1407 |
| 1432 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { | 1408 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { |
| 1433 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1434 Node* offset = | 1409 Node* offset = |
| 1435 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 1410 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| 1436 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 1411 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| 1437 return Load(MachineType::AnyTagged(), context, offset); | 1412 return Load(MachineType::AnyTagged(), context, offset); |
| 1438 } | 1413 } |
| 1439 | 1414 |
| 1440 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, | 1415 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, |
| 1441 Node* value) { | 1416 Node* value) { |
| 1442 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1443 int offset = Context::SlotOffset(slot_index); | 1417 int offset = Context::SlotOffset(slot_index); |
| 1444 return Store(context, IntPtrConstant(offset), value); | 1418 return Store(context, IntPtrConstant(offset), value); |
| 1445 } | 1419 } |
| 1446 | 1420 |
| 1447 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, | 1421 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, |
| 1448 Node* value) { | 1422 Node* value) { |
| 1449 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1450 Node* offset = | 1423 Node* offset = |
| 1451 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), | 1424 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), |
| 1452 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); | 1425 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); |
| 1453 return Store(context, offset, value); | 1426 return Store(context, offset, value); |
| 1454 } | 1427 } |
| 1455 | 1428 |
| 1456 Node* CodeStubAssembler::StoreContextElementNoWriteBarrier(Node* context, | 1429 Node* CodeStubAssembler::StoreContextElementNoWriteBarrier(Node* context, |
| 1457 int slot_index, | 1430 int slot_index, |
| 1458 Node* value) { | 1431 Node* value) { |
| 1459 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1460 int offset = Context::SlotOffset(slot_index); | 1432 int offset = Context::SlotOffset(slot_index); |
| 1461 return StoreNoWriteBarrier(MachineRepresentation::kTagged, context, | 1433 return StoreNoWriteBarrier(MachineRepresentation::kTagged, context, |
| 1462 IntPtrConstant(offset), value); | 1434 IntPtrConstant(offset), value); |
| 1463 } | 1435 } |
| 1464 | 1436 |
| 1465 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 1437 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
| 1466 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1467 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); | 1438 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
| 1468 } | 1439 } |
| 1469 | 1440 |
| 1470 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 1441 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
| 1471 Node* native_context) { | 1442 Node* native_context) { |
| 1472 CSA_ASSERT(this, IsNativeContext(native_context)); | 1443 CSA_ASSERT(this, IsNativeContext(native_context)); |
| 1473 return LoadContextElement(native_context, Context::ArrayMapIndex(kind)); | 1444 return LoadContextElement(native_context, Context::ArrayMapIndex(kind)); |
| 1474 } | 1445 } |
| 1475 | 1446 |
| 1476 Node* CodeStubAssembler::LoadJSFunctionPrototype(Node* function, | 1447 Node* CodeStubAssembler::LoadJSFunctionPrototype(Node* function, |
| (...skipping 11 matching lines...) Expand all Loading... |
| 1488 GotoIfNot(IsMap(proto_or_map), &done); | 1459 GotoIfNot(IsMap(proto_or_map), &done); |
| 1489 | 1460 |
| 1490 var_result.Bind(LoadMapPrototype(proto_or_map)); | 1461 var_result.Bind(LoadMapPrototype(proto_or_map)); |
| 1491 Goto(&done); | 1462 Goto(&done); |
| 1492 | 1463 |
| 1493 BIND(&done); | 1464 BIND(&done); |
| 1494 return var_result.value(); | 1465 return var_result.value(); |
| 1495 } | 1466 } |
| 1496 | 1467 |
| 1497 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 1468 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
| 1498 CSA_SLOW_ASSERT(this, IsAnyHeapNumber(object)); | |
| 1499 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, | 1469 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
| 1500 MachineRepresentation::kFloat64); | 1470 MachineRepresentation::kFloat64); |
| 1501 } | 1471 } |
| 1502 | 1472 |
| 1503 Node* CodeStubAssembler::StoreObjectField( | 1473 Node* CodeStubAssembler::StoreObjectField( |
| 1504 Node* object, int offset, Node* value) { | 1474 Node* object, int offset, Node* value) { |
| 1505 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1506 DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead. | 1475 DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead. |
| 1507 return Store(object, IntPtrConstant(offset - kHeapObjectTag), value); | 1476 return Store(object, IntPtrConstant(offset - kHeapObjectTag), value); |
| 1508 } | 1477 } |
| 1509 | 1478 |
| 1510 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, | 1479 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, |
| 1511 Node* value) { | 1480 Node* value) { |
| 1512 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1513 int const_offset; | 1481 int const_offset; |
| 1514 if (ToInt32Constant(offset, const_offset)) { | 1482 if (ToInt32Constant(offset, const_offset)) { |
| 1515 return StoreObjectField(object, const_offset, value); | 1483 return StoreObjectField(object, const_offset, value); |
| 1516 } | 1484 } |
| 1517 return Store(object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), | 1485 return Store(object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), |
| 1518 value); | 1486 value); |
| 1519 } | 1487 } |
| 1520 | 1488 |
| 1521 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( | 1489 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| 1522 Node* object, int offset, Node* value, MachineRepresentation rep) { | 1490 Node* object, int offset, Node* value, MachineRepresentation rep) { |
| 1523 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1524 return StoreNoWriteBarrier(rep, object, | 1491 return StoreNoWriteBarrier(rep, object, |
| 1525 IntPtrConstant(offset - kHeapObjectTag), value); | 1492 IntPtrConstant(offset - kHeapObjectTag), value); |
| 1526 } | 1493 } |
| 1527 | 1494 |
| 1528 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( | 1495 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( |
| 1529 Node* object, Node* offset, Node* value, MachineRepresentation rep) { | 1496 Node* object, Node* offset, Node* value, MachineRepresentation rep) { |
| 1530 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1531 int const_offset; | 1497 int const_offset; |
| 1532 if (ToInt32Constant(offset, const_offset)) { | 1498 if (ToInt32Constant(offset, const_offset)) { |
| 1533 return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep); | 1499 return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep); |
| 1534 } | 1500 } |
| 1535 return StoreNoWriteBarrier( | 1501 return StoreNoWriteBarrier( |
| 1536 rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value); | 1502 rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value); |
| 1537 } | 1503 } |
| 1538 | 1504 |
| 1539 Node* CodeStubAssembler::StoreMap(Node* object, Node* map) { | 1505 Node* CodeStubAssembler::StoreMap(Node* object, Node* map) { |
| 1540 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1541 CSA_SLOW_ASSERT(this, IsMap(map)); | 1506 CSA_SLOW_ASSERT(this, IsMap(map)); |
| 1542 return StoreWithMapWriteBarrier( | 1507 return StoreWithMapWriteBarrier( |
| 1543 object, IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); | 1508 object, IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); |
| 1544 } | 1509 } |
| 1545 | 1510 |
| 1546 Node* CodeStubAssembler::StoreMapNoWriteBarrier( | 1511 Node* CodeStubAssembler::StoreMapNoWriteBarrier( |
| 1547 Node* object, Heap::RootListIndex map_root_index) { | 1512 Node* object, Heap::RootListIndex map_root_index) { |
| 1548 return StoreMapNoWriteBarrier(object, LoadRoot(map_root_index)); | 1513 return StoreMapNoWriteBarrier(object, LoadRoot(map_root_index)); |
| 1549 } | 1514 } |
| 1550 | 1515 |
| 1551 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { | 1516 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { |
| 1552 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 1553 CSA_SLOW_ASSERT(this, IsMap(map)); | 1517 CSA_SLOW_ASSERT(this, IsMap(map)); |
| 1554 return StoreNoWriteBarrier( | 1518 return StoreNoWriteBarrier( |
| 1555 MachineRepresentation::kTagged, object, | 1519 MachineRepresentation::kTagged, object, |
| 1556 IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); | 1520 IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); |
| 1557 } | 1521 } |
| 1558 | 1522 |
| 1559 Node* CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset, | 1523 Node* CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset, |
| 1560 Heap::RootListIndex root_index) { | 1524 Heap::RootListIndex root_index) { |
| 1561 if (Heap::RootIsImmortalImmovable(root_index)) { | 1525 if (Heap::RootIsImmortalImmovable(root_index)) { |
| 1562 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index)); | 1526 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index)); |
| 1563 } else { | 1527 } else { |
| 1564 return StoreObjectField(object, offset, LoadRoot(root_index)); | 1528 return StoreObjectField(object, offset, LoadRoot(root_index)); |
| 1565 } | 1529 } |
| 1566 } | 1530 } |
| 1567 | 1531 |
| 1568 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, | 1532 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, |
| 1569 Node* value, | 1533 Node* value, |
| 1570 WriteBarrierMode barrier_mode, | 1534 WriteBarrierMode barrier_mode, |
| 1571 int additional_offset, | 1535 int additional_offset, |
| 1572 ParameterMode parameter_mode) { | 1536 ParameterMode parameter_mode) { |
| 1573 CSA_SLOW_ASSERT(this, IsFixedArray(object)); | |
| 1574 CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode)); | |
| 1575 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || | 1537 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || |
| 1576 barrier_mode == UPDATE_WRITE_BARRIER); | 1538 barrier_mode == UPDATE_WRITE_BARRIER); |
| 1577 int header_size = | 1539 int header_size = |
| 1578 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; | 1540 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; |
| 1579 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, | 1541 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, |
| 1580 parameter_mode, header_size); | 1542 parameter_mode, header_size); |
| 1581 if (barrier_mode == SKIP_WRITE_BARRIER) { | 1543 if (barrier_mode == SKIP_WRITE_BARRIER) { |
| 1582 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, | 1544 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, |
| 1583 value); | 1545 value); |
| 1584 } else { | 1546 } else { |
| 1585 return Store(object, offset, value); | 1547 return Store(object, offset, value); |
| 1586 } | 1548 } |
| 1587 } | 1549 } |
| 1588 | 1550 |
| 1589 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( | 1551 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
| 1590 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { | 1552 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
| 1591 CSA_ASSERT(this, IsFixedDoubleArray(object)); | 1553 CSA_ASSERT(this, IsFixedDoubleArray(object)); |
| 1592 CSA_SLOW_ASSERT(this, MatchesParameterMode(index_node, parameter_mode)); | |
| 1593 Node* offset = | 1554 Node* offset = |
| 1594 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, | 1555 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
| 1595 FixedArray::kHeaderSize - kHeapObjectTag); | 1556 FixedArray::kHeaderSize - kHeapObjectTag); |
| 1596 MachineRepresentation rep = MachineRepresentation::kFloat64; | 1557 MachineRepresentation rep = MachineRepresentation::kFloat64; |
| 1597 return StoreNoWriteBarrier(rep, object, offset, value); | 1558 return StoreNoWriteBarrier(rep, object, offset, value); |
| 1598 } | 1559 } |
| 1599 | 1560 |
| 1600 void CodeStubAssembler::EnsureArrayLengthWritable(Node* map, Label* bailout) { | 1561 void CodeStubAssembler::EnsureArrayLengthWritable(Node* map, Label* bailout) { |
| 1601 // Check whether the length property is writable. The length property is the | 1562 // Check whether the length property is writable. The length property is the |
| 1602 // only default named property on arrays. It's nonconfigurable, hence is | 1563 // only default named property on arrays. It's nonconfigurable, hence is |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1644 kind, capacity, new_capacity, mode, | 1605 kind, capacity, new_capacity, mode, |
| 1645 bailout)); | 1606 bailout)); |
| 1646 Goto(&fits); | 1607 Goto(&fits); |
| 1647 BIND(&fits); | 1608 BIND(&fits); |
| 1648 } | 1609 } |
| 1649 | 1610 |
| 1650 Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, | 1611 Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, |
| 1651 CodeStubArguments& args, | 1612 CodeStubArguments& args, |
| 1652 Variable& arg_index, | 1613 Variable& arg_index, |
| 1653 Label* bailout) { | 1614 Label* bailout) { |
| 1654 CSA_SLOW_ASSERT(this, IsJSArray(array)); | |
| 1655 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); | 1615 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); |
| 1656 Label pre_bailout(this); | 1616 Label pre_bailout(this); |
| 1657 Label success(this); | 1617 Label success(this); |
| 1658 VARIABLE(var_tagged_length, MachineRepresentation::kTagged); | 1618 VARIABLE(var_tagged_length, MachineRepresentation::kTagged); |
| 1659 ParameterMode mode = OptimalParameterMode(); | 1619 ParameterMode mode = OptimalParameterMode(); |
| 1660 VARIABLE(var_length, OptimalParameterRepresentation(), | 1620 VARIABLE(var_length, OptimalParameterRepresentation(), |
| 1661 TaggedToParameter(LoadJSArrayLength(array), mode)); | 1621 TaggedToParameter(LoadJSArrayLength(array), mode)); |
| 1662 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); | 1622 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); |
| 1663 | 1623 |
| 1664 // Resize the capacity of the fixed array if it doesn't fit. | 1624 // Resize the capacity of the fixed array if it doesn't fit. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 Float64SilenceNaN(double_value), mode); | 1675 Float64SilenceNaN(double_value), mode); |
| 1716 } else { | 1676 } else { |
| 1717 WriteBarrierMode barrier_mode = | 1677 WriteBarrierMode barrier_mode = |
| 1718 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; | 1678 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; |
| 1719 StoreFixedArrayElement(elements, index, value, barrier_mode, 0, mode); | 1679 StoreFixedArrayElement(elements, index, value, barrier_mode, 0, mode); |
| 1720 } | 1680 } |
| 1721 } | 1681 } |
| 1722 | 1682 |
| 1723 void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, | 1683 void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, |
| 1724 Node* value, Label* bailout) { | 1684 Node* value, Label* bailout) { |
| 1725 CSA_SLOW_ASSERT(this, IsJSArray(array)); | |
| 1726 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); | 1685 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); |
| 1727 ParameterMode mode = OptimalParameterMode(); | 1686 ParameterMode mode = OptimalParameterMode(); |
| 1728 VARIABLE(var_length, OptimalParameterRepresentation(), | 1687 VARIABLE(var_length, OptimalParameterRepresentation(), |
| 1729 TaggedToParameter(LoadJSArrayLength(array), mode)); | 1688 TaggedToParameter(LoadJSArrayLength(array), mode)); |
| 1730 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); | 1689 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); |
| 1731 | 1690 |
| 1732 // Resize the capacity of the fixed array if it doesn't fit. | 1691 // Resize the capacity of the fixed array if it doesn't fit. |
| 1733 Node* growth = IntPtrOrSmiConstant(1, mode); | 1692 Node* growth = IntPtrOrSmiConstant(1, mode); |
| 1734 PossiblyGrowElementsCapacity(mode, kind, array, var_length.value(), | 1693 PossiblyGrowElementsCapacity(mode, kind, array, var_length.value(), |
| 1735 &var_elements, growth, bailout); | 1694 &var_elements, growth, bailout); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1775 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, | 1734 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, |
| 1776 IntPtrConstant(String::kEmptyHashField), | 1735 IntPtrConstant(String::kEmptyHashField), |
| 1777 MachineType::PointerRepresentation()); | 1736 MachineType::PointerRepresentation()); |
| 1778 return result; | 1737 return result; |
| 1779 } | 1738 } |
| 1780 | 1739 |
| 1781 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, | 1740 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, |
| 1782 ParameterMode mode, | 1741 ParameterMode mode, |
| 1783 AllocationFlags flags) { | 1742 AllocationFlags flags) { |
| 1784 Comment("AllocateSeqOneByteString"); | 1743 Comment("AllocateSeqOneByteString"); |
| 1785 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1786 CSA_SLOW_ASSERT(this, MatchesParameterMode(length, mode)); | |
| 1787 VARIABLE(var_result, MachineRepresentation::kTagged); | 1744 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 1788 | 1745 |
| 1789 // Compute the SeqOneByteString size and check if it fits into new space. | 1746 // Compute the SeqOneByteString size and check if it fits into new space. |
| 1790 Label if_lengthiszero(this), if_sizeissmall(this), | 1747 Label if_lengthiszero(this), if_sizeissmall(this), |
| 1791 if_notsizeissmall(this, Label::kDeferred), if_join(this); | 1748 if_notsizeissmall(this, Label::kDeferred), if_join(this); |
| 1792 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); | 1749 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); |
| 1793 | 1750 |
| 1794 Node* raw_size = GetArrayAllocationSize( | 1751 Node* raw_size = GetArrayAllocationSize( |
| 1795 length, UINT8_ELEMENTS, mode, | 1752 length, UINT8_ELEMENTS, mode, |
| 1796 SeqOneByteString::kHeaderSize + kObjectAlignmentMask); | 1753 SeqOneByteString::kHeaderSize + kObjectAlignmentMask); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1847 // Initialize both used and unused parts of hash field slot at once. | 1804 // Initialize both used and unused parts of hash field slot at once. |
| 1848 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, | 1805 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, |
| 1849 IntPtrConstant(String::kEmptyHashField), | 1806 IntPtrConstant(String::kEmptyHashField), |
| 1850 MachineType::PointerRepresentation()); | 1807 MachineType::PointerRepresentation()); |
| 1851 return result; | 1808 return result; |
| 1852 } | 1809 } |
| 1853 | 1810 |
| 1854 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length, | 1811 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length, |
| 1855 ParameterMode mode, | 1812 ParameterMode mode, |
| 1856 AllocationFlags flags) { | 1813 AllocationFlags flags) { |
| 1857 CSA_SLOW_ASSERT(this, IsFixedArray(context)); | |
| 1858 CSA_SLOW_ASSERT(this, MatchesParameterMode(length, mode)); | |
| 1859 Comment("AllocateSeqTwoByteString"); | 1814 Comment("AllocateSeqTwoByteString"); |
| 1860 VARIABLE(var_result, MachineRepresentation::kTagged); | 1815 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 1861 | 1816 |
| 1862 // Compute the SeqTwoByteString size and check if it fits into new space. | 1817 // Compute the SeqTwoByteString size and check if it fits into new space. |
| 1863 Label if_lengthiszero(this), if_sizeissmall(this), | 1818 Label if_lengthiszero(this), if_sizeissmall(this), |
| 1864 if_notsizeissmall(this, Label::kDeferred), if_join(this); | 1819 if_notsizeissmall(this, Label::kDeferred), if_join(this); |
| 1865 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); | 1820 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); |
| 1866 | 1821 |
| 1867 Node* raw_size = GetArrayAllocationSize( | 1822 Node* raw_size = GetArrayAllocationSize( |
| 1868 length, UINT16_ELEMENTS, mode, | 1823 length, UINT16_ELEMENTS, mode, |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1904 Goto(&if_join); | 1859 Goto(&if_join); |
| 1905 } | 1860 } |
| 1906 | 1861 |
| 1907 BIND(&if_join); | 1862 BIND(&if_join); |
| 1908 return var_result.value(); | 1863 return var_result.value(); |
| 1909 } | 1864 } |
| 1910 | 1865 |
| 1911 Node* CodeStubAssembler::AllocateSlicedString( | 1866 Node* CodeStubAssembler::AllocateSlicedString( |
| 1912 Heap::RootListIndex map_root_index, Node* length, Node* parent, | 1867 Heap::RootListIndex map_root_index, Node* length, Node* parent, |
| 1913 Node* offset) { | 1868 Node* offset) { |
| 1914 CSA_ASSERT(this, IsString(parent)); | |
| 1915 CSA_ASSERT(this, TaggedIsSmi(length)); | 1869 CSA_ASSERT(this, TaggedIsSmi(length)); |
| 1916 CSA_ASSERT(this, TaggedIsSmi(offset)); | |
| 1917 Node* result = Allocate(SlicedString::kSize); | 1870 Node* result = Allocate(SlicedString::kSize); |
| 1918 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); | 1871 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); |
| 1919 StoreMapNoWriteBarrier(result, map_root_index); | 1872 StoreMapNoWriteBarrier(result, map_root_index); |
| 1920 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, | 1873 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, |
| 1921 MachineRepresentation::kTagged); | 1874 MachineRepresentation::kTagged); |
| 1922 // Initialize both used and unused parts of hash field slot at once. | 1875 // Initialize both used and unused parts of hash field slot at once. |
| 1923 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldSlot, | 1876 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldSlot, |
| 1924 IntPtrConstant(String::kEmptyHashField), | 1877 IntPtrConstant(String::kEmptyHashField), |
| 1925 MachineType::PointerRepresentation()); | 1878 MachineType::PointerRepresentation()); |
| 1926 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, | 1879 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1939 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent, | 1892 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent, |
| 1940 Node* offset) { | 1893 Node* offset) { |
| 1941 return AllocateSlicedString(Heap::kSlicedStringMapRootIndex, length, parent, | 1894 return AllocateSlicedString(Heap::kSlicedStringMapRootIndex, length, parent, |
| 1942 offset); | 1895 offset); |
| 1943 } | 1896 } |
| 1944 | 1897 |
| 1945 Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index, | 1898 Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index, |
| 1946 Node* length, Node* first, | 1899 Node* length, Node* first, |
| 1947 Node* second, | 1900 Node* second, |
| 1948 AllocationFlags flags) { | 1901 AllocationFlags flags) { |
| 1949 CSA_ASSERT(this, IsString(first)); | |
| 1950 CSA_ASSERT(this, IsString(second)); | |
| 1951 CSA_ASSERT(this, TaggedIsSmi(length)); | 1902 CSA_ASSERT(this, TaggedIsSmi(length)); |
| 1952 Node* result = Allocate(ConsString::kSize, flags); | 1903 Node* result = Allocate(ConsString::kSize, flags); |
| 1953 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); | 1904 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); |
| 1954 StoreMapNoWriteBarrier(result, map_root_index); | 1905 StoreMapNoWriteBarrier(result, map_root_index); |
| 1955 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, | 1906 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, |
| 1956 MachineRepresentation::kTagged); | 1907 MachineRepresentation::kTagged); |
| 1957 // Initialize both used and unused parts of hash field slot at once. | 1908 // Initialize both used and unused parts of hash field slot at once. |
| 1958 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldSlot, | 1909 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldSlot, |
| 1959 IntPtrConstant(String::kEmptyHashField), | 1910 IntPtrConstant(String::kEmptyHashField), |
| 1960 MachineType::PointerRepresentation()); | 1911 MachineType::PointerRepresentation()); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1980 | 1931 |
| 1981 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, | 1932 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, |
| 1982 Node* second, | 1933 Node* second, |
| 1983 AllocationFlags flags) { | 1934 AllocationFlags flags) { |
| 1984 return AllocateConsString(Heap::kConsStringMapRootIndex, length, first, | 1935 return AllocateConsString(Heap::kConsStringMapRootIndex, length, first, |
| 1985 second, flags); | 1936 second, flags); |
| 1986 } | 1937 } |
| 1987 | 1938 |
| 1988 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, | 1939 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, |
| 1989 Node* right, AllocationFlags flags) { | 1940 Node* right, AllocationFlags flags) { |
| 1990 CSA_ASSERT(this, IsFixedArray(context)); | |
| 1991 CSA_ASSERT(this, IsString(left)); | |
| 1992 CSA_ASSERT(this, IsString(right)); | |
| 1993 CSA_ASSERT(this, TaggedIsSmi(length)); | 1941 CSA_ASSERT(this, TaggedIsSmi(length)); |
| 1994 // Added string can be a cons string. | 1942 // Added string can be a cons string. |
| 1995 Comment("Allocating ConsString"); | 1943 Comment("Allocating ConsString"); |
| 1996 Node* left_instance_type = LoadInstanceType(left); | 1944 Node* left_instance_type = LoadInstanceType(left); |
| 1997 Node* right_instance_type = LoadInstanceType(right); | 1945 Node* right_instance_type = LoadInstanceType(right); |
| 1998 | 1946 |
| 1999 // Compute intersection and difference of instance types. | 1947 // Compute intersection and difference of instance types. |
| 2000 Node* anded_instance_types = | 1948 Node* anded_instance_types = |
| 2001 Word32And(left_instance_type, right_instance_type); | 1949 Word32And(left_instance_type, right_instance_type); |
| 2002 Node* xored_instance_types = | 1950 Node* xored_instance_types = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2038 result.Bind(AllocateTwoByteConsString(length, left, right, flags)); | 1986 result.Bind(AllocateTwoByteConsString(length, left, right, flags)); |
| 2039 Goto(&done); | 1987 Goto(&done); |
| 2040 | 1988 |
| 2041 BIND(&done); | 1989 BIND(&done); |
| 2042 | 1990 |
| 2043 return result.value(); | 1991 return result.value(); |
| 2044 } | 1992 } |
| 2045 | 1993 |
| 2046 Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, | 1994 Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, |
| 2047 Node* index, Node* input) { | 1995 Node* index, Node* input) { |
| 2048 CSA_ASSERT(this, IsFixedArray(context)); | |
| 2049 CSA_ASSERT(this, TaggedIsSmi(index)); | |
| 2050 CSA_ASSERT(this, TaggedIsSmi(length)); | |
| 2051 CSA_ASSERT(this, IsString(input)); | |
| 2052 | |
| 2053 #ifdef DEBUG | |
| 2054 Node* const max_length = | 1996 Node* const max_length = |
| 2055 SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray)); | 1997 SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray)); |
| 2056 CSA_ASSERT(this, SmiLessThanOrEqual(length, max_length)); | 1998 CSA_ASSERT(this, SmiLessThanOrEqual(length, max_length)); |
| 2057 #endif // DEBUG | 1999 USE(max_length); |
| 2058 | 2000 |
| 2059 // Allocate the JSRegExpResult. | 2001 // Allocate the JSRegExpResult. |
| 2060 // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove | 2002 // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove |
| 2061 // unneeded store of elements. | 2003 // unneeded store of elements. |
| 2062 Node* const result = Allocate(JSRegExpResult::kSize); | 2004 Node* const result = Allocate(JSRegExpResult::kSize); |
| 2063 | 2005 |
| 2064 // TODO(jgruber): Store map as Heap constant? | 2006 // TODO(jgruber): Store map as Heap constant? |
| 2065 Node* const native_context = LoadNativeContext(context); | 2007 Node* const native_context = LoadNativeContext(context); |
| 2066 Node* const map = | 2008 Node* const map = |
| 2067 LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX); | 2009 LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2170 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); | 2112 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); |
| 2171 Node* object = AllocateInNewSpace(size, flags); | 2113 Node* object = AllocateInNewSpace(size, flags); |
| 2172 StoreMapNoWriteBarrier(object, map); | 2114 StoreMapNoWriteBarrier(object, map); |
| 2173 InitializeJSObjectFromMap(object, map, size, properties, elements); | 2115 InitializeJSObjectFromMap(object, map, size, properties, elements); |
| 2174 return object; | 2116 return object; |
| 2175 } | 2117 } |
| 2176 | 2118 |
| 2177 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, | 2119 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
| 2178 Node* size, Node* properties, | 2120 Node* size, Node* properties, |
| 2179 Node* elements) { | 2121 Node* elements) { |
| 2180 CSA_SLOW_ASSERT(this, IsMap(map)); | |
| 2181 // This helper assumes that the object is in new-space, as guarded by the | 2122 // This helper assumes that the object is in new-space, as guarded by the |
| 2182 // check in AllocatedJSObjectFromMap. | 2123 // check in AllocatedJSObjectFromMap. |
| 2183 if (properties == nullptr) { | 2124 if (properties == nullptr) { |
| 2184 CSA_ASSERT(this, Word32BinaryNot(IsDictionaryMap((map)))); | 2125 CSA_ASSERT(this, Word32BinaryNot(IsDictionaryMap((map)))); |
| 2185 StoreObjectFieldRoot(object, JSObject::kPropertiesOffset, | 2126 StoreObjectFieldRoot(object, JSObject::kPropertiesOffset, |
| 2186 Heap::kEmptyFixedArrayRootIndex); | 2127 Heap::kEmptyFixedArrayRootIndex); |
| 2187 } else { | 2128 } else { |
| 2188 CSA_ASSERT(this, IsFixedArray(properties)); | |
| 2189 StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOffset, | 2129 StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOffset, |
| 2190 properties); | 2130 properties); |
| 2191 } | 2131 } |
| 2192 if (elements == nullptr) { | 2132 if (elements == nullptr) { |
| 2193 StoreObjectFieldRoot(object, JSObject::kElementsOffset, | 2133 StoreObjectFieldRoot(object, JSObject::kElementsOffset, |
| 2194 Heap::kEmptyFixedArrayRootIndex); | 2134 Heap::kEmptyFixedArrayRootIndex); |
| 2195 } else { | 2135 } else { |
| 2196 CSA_ASSERT(this, IsFixedArray(elements)); | |
| 2197 StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements); | 2136 StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements); |
| 2198 } | 2137 } |
| 2199 InitializeJSObjectBody(object, map, size, JSObject::kHeaderSize); | 2138 InitializeJSObjectBody(object, map, size, JSObject::kHeaderSize); |
| 2200 } | 2139 } |
| 2201 | 2140 |
| 2202 void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map, | 2141 void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map, |
| 2203 Node* size, int start_offset) { | 2142 Node* size, int start_offset) { |
| 2204 CSA_SLOW_ASSERT(this, IsMap(map)); | |
| 2205 // TODO(cbruni): activate in-object slack tracking machinery. | 2143 // TODO(cbruni): activate in-object slack tracking machinery. |
| 2206 Comment("InitializeJSObjectBody"); | 2144 Comment("InitializeJSObjectBody"); |
| 2207 Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); | 2145 Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); |
| 2208 // Calculate the untagged field addresses. | 2146 // Calculate the untagged field addresses. |
| 2209 object = BitcastTaggedToWord(object); | 2147 object = BitcastTaggedToWord(object); |
| 2210 Node* start_address = | 2148 Node* start_address = |
| 2211 IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag)); | 2149 IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag)); |
| 2212 Node* end_address = | 2150 Node* end_address = |
| 2213 IntPtrSub(IntPtrAdd(object, size), IntPtrConstant(kHeapObjectTag)); | 2151 IntPtrSub(IntPtrAdd(object, size), IntPtrConstant(kHeapObjectTag)); |
| 2214 StoreFieldsNoWriteBarrier(start_address, end_address, filler); | 2152 StoreFieldsNoWriteBarrier(start_address, end_address, filler); |
| 2215 } | 2153 } |
| 2216 | 2154 |
| 2217 void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address, | 2155 void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address, |
| 2218 Node* end_address, | 2156 Node* end_address, |
| 2219 Node* value) { | 2157 Node* value) { |
| 2220 Comment("StoreFieldsNoWriteBarrier"); | 2158 Comment("StoreFieldsNoWriteBarrier"); |
| 2221 CSA_ASSERT(this, WordIsWordAligned(start_address)); | 2159 CSA_ASSERT(this, WordIsWordAligned(start_address)); |
| 2222 CSA_ASSERT(this, WordIsWordAligned(end_address)); | 2160 CSA_ASSERT(this, WordIsWordAligned(end_address)); |
| 2223 BuildFastLoop(start_address, end_address, | 2161 BuildFastLoop(start_address, end_address, |
| 2224 [this, value](Node* current) { | 2162 [this, value](Node* current) { |
| 2225 StoreNoWriteBarrier(MachineRepresentation::kTagged, current, | 2163 StoreNoWriteBarrier(MachineRepresentation::kTagged, current, |
| 2226 value); | 2164 value); |
| 2227 }, | 2165 }, |
| 2228 kPointerSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); | 2166 kPointerSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); |
| 2229 } | 2167 } |
| 2230 | 2168 |
| 2231 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( | 2169 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( |
| 2232 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { | 2170 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { |
| 2233 Comment("begin allocation of JSArray without elements"); | 2171 Comment("begin allocation of JSArray without elements"); |
| 2234 CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); | |
| 2235 CSA_SLOW_ASSERT(this, IsMap(array_map)); | |
| 2236 int base_size = JSArray::kSize; | 2172 int base_size = JSArray::kSize; |
| 2237 if (allocation_site != nullptr) { | 2173 if (allocation_site != nullptr) { |
| 2238 base_size += AllocationMemento::kSize; | 2174 base_size += AllocationMemento::kSize; |
| 2239 } | 2175 } |
| 2240 | 2176 |
| 2241 Node* size = IntPtrConstant(base_size); | 2177 Node* size = IntPtrConstant(base_size); |
| 2242 Node* array = AllocateUninitializedJSArray(kind, array_map, length, | 2178 Node* array = AllocateUninitializedJSArray(kind, array_map, length, |
| 2243 allocation_site, size); | 2179 allocation_site, size); |
| 2244 return array; | 2180 return array; |
| 2245 } | 2181 } |
| 2246 | 2182 |
| 2247 std::pair<Node*, Node*> | 2183 std::pair<Node*, Node*> |
| 2248 CodeStubAssembler::AllocateUninitializedJSArrayWithElements( | 2184 CodeStubAssembler::AllocateUninitializedJSArrayWithElements( |
| 2249 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site, | 2185 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site, |
| 2250 Node* capacity, ParameterMode capacity_mode) { | 2186 Node* capacity, ParameterMode capacity_mode) { |
| 2251 Comment("begin allocation of JSArray with elements"); | 2187 Comment("begin allocation of JSArray with elements"); |
| 2252 CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); | |
| 2253 CSA_SLOW_ASSERT(this, IsMap(array_map)); | |
| 2254 int base_size = JSArray::kSize; | 2188 int base_size = JSArray::kSize; |
| 2255 | 2189 |
| 2256 if (allocation_site != nullptr) { | 2190 if (allocation_site != nullptr) { |
| 2257 base_size += AllocationMemento::kSize; | 2191 base_size += AllocationMemento::kSize; |
| 2258 } | 2192 } |
| 2259 | 2193 |
| 2260 int elements_offset = base_size; | 2194 int elements_offset = base_size; |
| 2261 | 2195 |
| 2262 // Compute space for elements | 2196 // Compute space for elements |
| 2263 base_size += FixedArray::kHeaderSize; | 2197 base_size += FixedArray::kHeaderSize; |
| 2264 Node* size = ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size); | 2198 Node* size = ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size); |
| 2265 | 2199 |
| 2266 Node* array = AllocateUninitializedJSArray(kind, array_map, length, | 2200 Node* array = AllocateUninitializedJSArray(kind, array_map, length, |
| 2267 allocation_site, size); | 2201 allocation_site, size); |
| 2268 | 2202 |
| 2269 Node* elements = InnerAllocate(array, elements_offset); | 2203 Node* elements = InnerAllocate(array, elements_offset); |
| 2270 StoreObjectFieldNoWriteBarrier(array, JSObject::kElementsOffset, elements); | 2204 StoreObjectFieldNoWriteBarrier(array, JSObject::kElementsOffset, elements); |
| 2271 | 2205 |
| 2272 return {array, elements}; | 2206 return {array, elements}; |
| 2273 } | 2207 } |
| 2274 | 2208 |
| 2275 Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind, | 2209 Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind, |
| 2276 Node* array_map, | 2210 Node* array_map, |
| 2277 Node* length, | 2211 Node* length, |
| 2278 Node* allocation_site, | 2212 Node* allocation_site, |
| 2279 Node* size_in_bytes) { | 2213 Node* size_in_bytes) { |
| 2280 CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); | |
| 2281 CSA_SLOW_ASSERT(this, IsMap(array_map)); | |
| 2282 | |
| 2283 // Allocate space for the JSArray and the elements FixedArray in one go. | 2214 // Allocate space for the JSArray and the elements FixedArray in one go. |
| 2284 Node* array = AllocateInNewSpace(size_in_bytes); | 2215 Node* array = AllocateInNewSpace(size_in_bytes); |
| 2285 | 2216 |
| 2286 Comment("write JSArray headers"); | 2217 Comment("write JSArray headers"); |
| 2287 StoreMapNoWriteBarrier(array, array_map); | 2218 StoreMapNoWriteBarrier(array, array_map); |
| 2288 | 2219 |
| 2220 CSA_ASSERT(this, TaggedIsSmi(length)); |
| 2289 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length); | 2221 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length); |
| 2290 | 2222 |
| 2291 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset, | 2223 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset, |
| 2292 Heap::kEmptyFixedArrayRootIndex); | 2224 Heap::kEmptyFixedArrayRootIndex); |
| 2293 | 2225 |
| 2294 if (allocation_site != nullptr) { | 2226 if (allocation_site != nullptr) { |
| 2295 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); | 2227 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); |
| 2296 } | 2228 } |
| 2297 return array; | 2229 return array; |
| 2298 } | 2230 } |
| 2299 | 2231 |
| 2300 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, | 2232 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, |
| 2301 Node* capacity, Node* length, | 2233 Node* capacity, Node* length, |
| 2302 Node* allocation_site, | 2234 Node* allocation_site, |
| 2303 ParameterMode capacity_mode) { | 2235 ParameterMode capacity_mode) { |
| 2304 CSA_SLOW_ASSERT(this, IsMap(array_map)); | |
| 2305 CSA_SLOW_ASSERT(this, TaggedIsPositiveSmi(length)); | |
| 2306 CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, capacity_mode)); | |
| 2307 | |
| 2308 Node *array = nullptr, *elements = nullptr; | 2236 Node *array = nullptr, *elements = nullptr; |
| 2309 if (IsIntPtrOrSmiConstantZero(capacity)) { | 2237 if (IsIntPtrOrSmiConstantZero(capacity)) { |
| 2310 // Array is empty. Use the shared empty fixed array instead of allocating a | 2238 // Array is empty. Use the shared empty fixed array instead of allocating a |
| 2311 // new one. | 2239 // new one. |
| 2312 array = AllocateUninitializedJSArrayWithoutElements(kind, array_map, length, | 2240 array = AllocateUninitializedJSArrayWithoutElements(kind, array_map, length, |
| 2313 nullptr); | 2241 nullptr); |
| 2314 StoreObjectFieldRoot(array, JSArray::kElementsOffset, | 2242 StoreObjectFieldRoot(array, JSArray::kElementsOffset, |
| 2315 Heap::kEmptyFixedArrayRootIndex); | 2243 Heap::kEmptyFixedArrayRootIndex); |
| 2316 } else { | 2244 } else { |
| 2317 // Allocate both array and elements object, and initialize the JSArray. | 2245 // Allocate both array and elements object, and initialize the JSArray. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 2331 Heap::kTheHoleValueRootIndex, capacity_mode); | 2259 Heap::kTheHoleValueRootIndex, capacity_mode); |
| 2332 } | 2260 } |
| 2333 | 2261 |
| 2334 return array; | 2262 return array; |
| 2335 } | 2263 } |
| 2336 | 2264 |
| 2337 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, | 2265 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
| 2338 Node* capacity_node, | 2266 Node* capacity_node, |
| 2339 ParameterMode mode, | 2267 ParameterMode mode, |
| 2340 AllocationFlags flags) { | 2268 AllocationFlags flags) { |
| 2341 CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity_node, mode)); | |
| 2342 CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, | 2269 CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, |
| 2343 IntPtrOrSmiConstant(0, mode), mode)); | 2270 IntPtrOrSmiConstant(0, mode), mode)); |
| 2344 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); | 2271 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); |
| 2345 | 2272 |
| 2346 // Allocate both array and elements object, and initialize the JSArray. | 2273 // Allocate both array and elements object, and initialize the JSArray. |
| 2347 Node* array = Allocate(total_size, flags); | 2274 Node* array = Allocate(total_size, flags); |
| 2348 Heap::RootListIndex map_index = IsFastDoubleElementsKind(kind) | 2275 Heap::RootListIndex map_index = IsFastDoubleElementsKind(kind) |
| 2349 ? Heap::kFixedDoubleArrayMapRootIndex | 2276 ? Heap::kFixedDoubleArrayMapRootIndex |
| 2350 : Heap::kFixedArrayMapRootIndex; | 2277 : Heap::kFixedArrayMapRootIndex; |
| 2351 DCHECK(Heap::RootIsImmortalImmovable(map_index)); | 2278 DCHECK(Heap::RootIsImmortalImmovable(map_index)); |
| 2352 StoreMapNoWriteBarrier(array, map_index); | 2279 StoreMapNoWriteBarrier(array, map_index); |
| 2353 StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset, | 2280 StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset, |
| 2354 ParameterToTagged(capacity_node, mode)); | 2281 ParameterToTagged(capacity_node, mode)); |
| 2355 return array; | 2282 return array; |
| 2356 } | 2283 } |
| 2357 | 2284 |
| 2358 void CodeStubAssembler::FillFixedArrayWithValue( | 2285 void CodeStubAssembler::FillFixedArrayWithValue( |
| 2359 ElementsKind kind, Node* array, Node* from_node, Node* to_node, | 2286 ElementsKind kind, Node* array, Node* from_node, Node* to_node, |
| 2360 Heap::RootListIndex value_root_index, ParameterMode mode) { | 2287 Heap::RootListIndex value_root_index, ParameterMode mode) { |
| 2361 CSA_SLOW_ASSERT(this, MatchesParameterMode(from_node, mode)); | |
| 2362 CSA_SLOW_ASSERT(this, MatchesParameterMode(to_node, mode)); | |
| 2363 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind)); | |
| 2364 bool is_double = IsFastDoubleElementsKind(kind); | 2288 bool is_double = IsFastDoubleElementsKind(kind); |
| 2365 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || | 2289 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || |
| 2366 value_root_index == Heap::kUndefinedValueRootIndex); | 2290 value_root_index == Heap::kUndefinedValueRootIndex); |
| 2367 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex); | 2291 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex); |
| 2368 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32); | 2292 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32); |
| 2369 Node* double_hole = | 2293 Node* double_hole = |
| 2370 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); | 2294 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); |
| 2371 Node* value = LoadRoot(value_root_index); | 2295 Node* value = LoadRoot(value_root_index); |
| 2372 | 2296 |
| 2373 BuildFastFixedArrayForEach( | 2297 BuildFastFixedArrayForEach( |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2397 value); | 2321 value); |
| 2398 } | 2322 } |
| 2399 }, | 2323 }, |
| 2400 mode); | 2324 mode); |
| 2401 } | 2325 } |
| 2402 | 2326 |
| 2403 void CodeStubAssembler::CopyFixedArrayElements( | 2327 void CodeStubAssembler::CopyFixedArrayElements( |
| 2404 ElementsKind from_kind, Node* from_array, ElementsKind to_kind, | 2328 ElementsKind from_kind, Node* from_array, ElementsKind to_kind, |
| 2405 Node* to_array, Node* element_count, Node* capacity, | 2329 Node* to_array, Node* element_count, Node* capacity, |
| 2406 WriteBarrierMode barrier_mode, ParameterMode mode) { | 2330 WriteBarrierMode barrier_mode, ParameterMode mode) { |
| 2407 CSA_SLOW_ASSERT(this, MatchesParameterMode(element_count, mode)); | |
| 2408 CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); | |
| 2409 CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(from_array, from_kind)); | |
| 2410 CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(to_array, to_kind)); | |
| 2411 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); | 2331 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); |
| 2412 const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; | 2332 const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; |
| 2413 Comment("[ CopyFixedArrayElements"); | 2333 Comment("[ CopyFixedArrayElements"); |
| 2414 | 2334 |
| 2415 // Typed array elements are not supported. | 2335 // Typed array elements are not supported. |
| 2416 DCHECK(!IsFixedTypedArrayElementsKind(from_kind)); | 2336 DCHECK(!IsFixedTypedArrayElementsKind(from_kind)); |
| 2417 DCHECK(!IsFixedTypedArrayElementsKind(to_kind)); | 2337 DCHECK(!IsFixedTypedArrayElementsKind(to_kind)); |
| 2418 | 2338 |
| 2419 Label done(this); | 2339 Label done(this); |
| 2420 bool from_double_elements = IsFastDoubleElementsKind(from_kind); | 2340 bool from_double_elements = IsFastDoubleElementsKind(from_kind); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2537 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1); | 2457 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1); |
| 2538 Comment("] CopyFixedArrayElements"); | 2458 Comment("] CopyFixedArrayElements"); |
| 2539 } | 2459 } |
| 2540 | 2460 |
| 2541 void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string, | 2461 void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string, |
| 2542 Node* from_index, Node* to_index, | 2462 Node* from_index, Node* to_index, |
| 2543 Node* character_count, | 2463 Node* character_count, |
| 2544 String::Encoding from_encoding, | 2464 String::Encoding from_encoding, |
| 2545 String::Encoding to_encoding, | 2465 String::Encoding to_encoding, |
| 2546 ParameterMode mode) { | 2466 ParameterMode mode) { |
| 2547 // Cannot assert IsString(from_string) and IsString(to_string) here because | |
| 2548 // CSA::SubString can pass in faked sequential strings when handling external | |
| 2549 // subject strings. | |
| 2550 CSA_SLOW_ASSERT(this, MatchesParameterMode(character_count, mode)); | |
| 2551 CSA_SLOW_ASSERT(this, MatchesParameterMode(from_index, mode)); | |
| 2552 CSA_SLOW_ASSERT(this, MatchesParameterMode(to_index, mode)); | |
| 2553 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING; | 2467 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING; |
| 2554 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING; | 2468 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING; |
| 2555 DCHECK_IMPLIES(to_one_byte, from_one_byte); | 2469 DCHECK_IMPLIES(to_one_byte, from_one_byte); |
| 2556 Comment("CopyStringCharacters %s -> %s", | 2470 Comment("CopyStringCharacters %s -> %s", |
| 2557 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING", | 2471 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING", |
| 2558 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING"); | 2472 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING"); |
| 2559 | 2473 |
| 2560 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; | 2474 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; |
| 2561 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; | 2475 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; |
| 2562 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize); | 2476 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2601 } | 2515 } |
| 2602 }, | 2516 }, |
| 2603 from_increment, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); | 2517 from_increment, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); |
| 2604 } | 2518 } |
| 2605 | 2519 |
| 2606 Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, | 2520 Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, |
| 2607 Node* offset, | 2521 Node* offset, |
| 2608 ElementsKind from_kind, | 2522 ElementsKind from_kind, |
| 2609 ElementsKind to_kind, | 2523 ElementsKind to_kind, |
| 2610 Label* if_hole) { | 2524 Label* if_hole) { |
| 2611 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, from_kind)); | |
| 2612 if (IsFastDoubleElementsKind(from_kind)) { | 2525 if (IsFastDoubleElementsKind(from_kind)) { |
| 2613 Node* value = | 2526 Node* value = |
| 2614 LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64()); | 2527 LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64()); |
| 2615 if (!IsFastDoubleElementsKind(to_kind)) { | 2528 if (!IsFastDoubleElementsKind(to_kind)) { |
| 2616 value = AllocateHeapNumberWithValue(value); | 2529 value = AllocateHeapNumberWithValue(value); |
| 2617 } | 2530 } |
| 2618 return value; | 2531 return value; |
| 2619 | 2532 |
| 2620 } else { | 2533 } else { |
| 2621 Node* value = Load(MachineType::AnyTagged(), array, offset); | 2534 Node* value = Load(MachineType::AnyTagged(), array, offset); |
| 2622 if (if_hole) { | 2535 if (if_hole) { |
| 2623 GotoIf(WordEqual(value, TheHoleConstant()), if_hole); | 2536 GotoIf(WordEqual(value, TheHoleConstant()), if_hole); |
| 2624 } | 2537 } |
| 2625 if (IsFastDoubleElementsKind(to_kind)) { | 2538 if (IsFastDoubleElementsKind(to_kind)) { |
| 2626 if (IsFastSmiElementsKind(from_kind)) { | 2539 if (IsFastSmiElementsKind(from_kind)) { |
| 2627 value = SmiToFloat64(value); | 2540 value = SmiToFloat64(value); |
| 2628 } else { | 2541 } else { |
| 2629 value = LoadHeapNumberValue(value); | 2542 value = LoadHeapNumberValue(value); |
| 2630 } | 2543 } |
| 2631 } | 2544 } |
| 2632 return value; | 2545 return value; |
| 2633 } | 2546 } |
| 2634 } | 2547 } |
| 2635 | 2548 |
| 2636 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, | 2549 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, |
| 2637 ParameterMode mode) { | 2550 ParameterMode mode) { |
| 2638 CSA_SLOW_ASSERT(this, MatchesParameterMode(old_capacity, mode)); | |
| 2639 Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); | 2551 Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); |
| 2640 Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); | 2552 Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); |
| 2641 Node* padding = IntPtrOrSmiConstant(16, mode); | 2553 Node* padding = IntPtrOrSmiConstant(16, mode); |
| 2642 return IntPtrOrSmiAdd(new_capacity, padding, mode); | 2554 return IntPtrOrSmiAdd(new_capacity, padding, mode); |
| 2643 } | 2555 } |
| 2644 | 2556 |
| 2645 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, | 2557 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
| 2646 ElementsKind kind, Node* key, | 2558 ElementsKind kind, Node* key, |
| 2647 Label* bailout) { | 2559 Label* bailout) { |
| 2648 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 2649 CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, kind)); | |
| 2650 CSA_SLOW_ASSERT(this, TaggedIsSmi(key)); | |
| 2651 Node* capacity = LoadFixedArrayBaseLength(elements); | 2560 Node* capacity = LoadFixedArrayBaseLength(elements); |
| 2652 | 2561 |
| 2653 ParameterMode mode = OptimalParameterMode(); | 2562 ParameterMode mode = OptimalParameterMode(); |
| 2654 capacity = TaggedToParameter(capacity, mode); | 2563 capacity = TaggedToParameter(capacity, mode); |
| 2655 key = TaggedToParameter(key, mode); | 2564 key = TaggedToParameter(key, mode); |
| 2656 | 2565 |
| 2657 return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode, | 2566 return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode, |
| 2658 bailout); | 2567 bailout); |
| 2659 } | 2568 } |
| 2660 | 2569 |
| 2661 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, | 2570 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, |
| 2662 ElementsKind kind, Node* key, | 2571 ElementsKind kind, Node* key, |
| 2663 Node* capacity, | 2572 Node* capacity, |
| 2664 ParameterMode mode, | 2573 ParameterMode mode, |
| 2665 Label* bailout) { | 2574 Label* bailout) { |
| 2666 Comment("TryGrowElementsCapacity"); | 2575 Comment("TryGrowElementsCapacity"); |
| 2667 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 2668 CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, kind)); | |
| 2669 CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); | |
| 2670 CSA_SLOW_ASSERT(this, MatchesParameterMode(key, mode)); | |
| 2671 | 2576 |
| 2672 // If the gap growth is too big, fall back to the runtime. | 2577 // If the gap growth is too big, fall back to the runtime. |
| 2673 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); | 2578 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); |
| 2674 Node* max_capacity = IntPtrOrSmiAdd(capacity, max_gap, mode); | 2579 Node* max_capacity = IntPtrOrSmiAdd(capacity, max_gap, mode); |
| 2675 GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity, mode), bailout); | 2580 GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity, mode), bailout); |
| 2676 | 2581 |
| 2677 // Calculate the capacity of the new backing store. | 2582 // Calculate the capacity of the new backing store. |
| 2678 Node* new_capacity = CalculateNewElementsCapacity( | 2583 Node* new_capacity = CalculateNewElementsCapacity( |
| 2679 IntPtrOrSmiAdd(key, IntPtrOrSmiConstant(1, mode), mode), mode); | 2584 IntPtrOrSmiAdd(key, IntPtrOrSmiConstant(1, mode), mode), mode); |
| 2680 return GrowElementsCapacity(object, elements, kind, kind, capacity, | 2585 return GrowElementsCapacity(object, elements, kind, kind, capacity, |
| 2681 new_capacity, mode, bailout); | 2586 new_capacity, mode, bailout); |
| 2682 } | 2587 } |
| 2683 | 2588 |
| 2684 Node* CodeStubAssembler::GrowElementsCapacity( | 2589 Node* CodeStubAssembler::GrowElementsCapacity( |
| 2685 Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind, | 2590 Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind, |
| 2686 Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) { | 2591 Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) { |
| 2687 Comment("[ GrowElementsCapacity"); | 2592 Comment("[ GrowElementsCapacity"); |
| 2688 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 2689 CSA_SLOW_ASSERT(this, IsFixedArrayWithKindOrEmpty(elements, from_kind)); | |
| 2690 CSA_SLOW_ASSERT(this, MatchesParameterMode(capacity, mode)); | |
| 2691 CSA_SLOW_ASSERT(this, MatchesParameterMode(new_capacity, mode)); | |
| 2692 | |
| 2693 // If size of the allocation for the new capacity doesn't fit in a page | 2593 // If size of the allocation for the new capacity doesn't fit in a page |
| 2694 // that we can bump-pointer allocate from, fall back to the runtime. | 2594 // that we can bump-pointer allocate from, fall back to the runtime. |
| 2695 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); | 2595 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); |
| 2696 GotoIf(UintPtrOrSmiGreaterThanOrEqual( | 2596 GotoIf(UintPtrOrSmiGreaterThanOrEqual( |
| 2697 new_capacity, IntPtrOrSmiConstant(max_size, mode), mode), | 2597 new_capacity, IntPtrOrSmiConstant(max_size, mode), mode), |
| 2698 bailout); | 2598 bailout); |
| 2699 | 2599 |
| 2700 // Allocate the new backing store. | 2600 // Allocate the new backing store. |
| 2701 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode); | 2601 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode); |
| 2702 | 2602 |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2891 } | 2791 } |
| 2892 } | 2792 } |
| 2893 } | 2793 } |
| 2894 BIND(&if_valueisheapnumber); | 2794 BIND(&if_valueisheapnumber); |
| 2895 { | 2795 { |
| 2896 Node* result = AllocateHeapNumberWithValue(value); | 2796 Node* result = AllocateHeapNumberWithValue(value); |
| 2897 var_result.Bind(result); | 2797 var_result.Bind(result); |
| 2898 Goto(&if_join); | 2798 Goto(&if_join); |
| 2899 } | 2799 } |
| 2900 BIND(&if_join); | 2800 BIND(&if_join); |
| 2901 CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); | |
| 2902 return var_result.value(); | 2801 return var_result.value(); |
| 2903 } | 2802 } |
| 2904 | 2803 |
| 2905 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { | 2804 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { |
| 2906 if (Is64()) { | 2805 if (Is64()) { |
| 2907 return SmiTag(ChangeInt32ToInt64(value)); | 2806 return SmiTag(ChangeInt32ToInt64(value)); |
| 2908 } | 2807 } |
| 2909 VARIABLE(var_result, MachineRepresentation::kTagged); | 2808 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 2910 Node* pair = Int32AddWithOverflow(value, value); | 2809 Node* pair = Int32AddWithOverflow(value, value); |
| 2911 Node* overflow = Projection(1, pair); | 2810 Node* overflow = Projection(1, pair); |
| 2912 Label if_overflow(this, Label::kDeferred), if_notoverflow(this), | 2811 Label if_overflow(this, Label::kDeferred), if_notoverflow(this), |
| 2913 if_join(this); | 2812 if_join(this); |
| 2914 Branch(overflow, &if_overflow, &if_notoverflow); | 2813 Branch(overflow, &if_overflow, &if_notoverflow); |
| 2915 BIND(&if_overflow); | 2814 BIND(&if_overflow); |
| 2916 { | 2815 { |
| 2917 Node* value64 = ChangeInt32ToFloat64(value); | 2816 Node* value64 = ChangeInt32ToFloat64(value); |
| 2918 Node* result = AllocateHeapNumberWithValue(value64); | 2817 Node* result = AllocateHeapNumberWithValue(value64); |
| 2919 var_result.Bind(result); | 2818 var_result.Bind(result); |
| 2920 } | 2819 } |
| 2921 Goto(&if_join); | 2820 Goto(&if_join); |
| 2922 BIND(&if_notoverflow); | 2821 BIND(&if_notoverflow); |
| 2923 { | 2822 { |
| 2924 Node* result = BitcastWordToTaggedSigned(Projection(0, pair)); | 2823 Node* result = BitcastWordToTaggedSigned(Projection(0, pair)); |
| 2925 var_result.Bind(result); | 2824 var_result.Bind(result); |
| 2926 } | 2825 } |
| 2927 Goto(&if_join); | 2826 Goto(&if_join); |
| 2928 BIND(&if_join); | 2827 BIND(&if_join); |
| 2929 CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); | |
| 2930 return var_result.value(); | 2828 return var_result.value(); |
| 2931 } | 2829 } |
| 2932 | 2830 |
| 2933 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { | 2831 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { |
| 2934 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), | 2832 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), |
| 2935 if_join(this); | 2833 if_join(this); |
| 2936 VARIABLE(var_result, MachineRepresentation::kTagged); | 2834 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 2937 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. | 2835 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. |
| 2938 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow, | 2836 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow, |
| 2939 &if_not_overflow); | 2837 &if_not_overflow); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 2956 Goto(&if_join); | 2854 Goto(&if_join); |
| 2957 | 2855 |
| 2958 BIND(&if_overflow); | 2856 BIND(&if_overflow); |
| 2959 { | 2857 { |
| 2960 Node* float64_value = ChangeUint32ToFloat64(value); | 2858 Node* float64_value = ChangeUint32ToFloat64(value); |
| 2961 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); | 2859 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); |
| 2962 } | 2860 } |
| 2963 Goto(&if_join); | 2861 Goto(&if_join); |
| 2964 | 2862 |
| 2965 BIND(&if_join); | 2863 BIND(&if_join); |
| 2966 CSA_SLOW_ASSERT(this, IsNumber(var_result.value())); | |
| 2967 return var_result.value(); | 2864 return var_result.value(); |
| 2968 } | 2865 } |
| 2969 | 2866 |
| 2970 Node* CodeStubAssembler::ToThisString(Node* context, Node* value, | 2867 Node* CodeStubAssembler::ToThisString(Node* context, Node* value, |
| 2971 char const* method_name) { | 2868 char const* method_name) { |
| 2972 VARIABLE(var_value, MachineRepresentation::kTagged, value); | 2869 VARIABLE(var_value, MachineRepresentation::kTagged, value); |
| 2973 | 2870 |
| 2974 // Check if the {value} is a Smi or a HeapObject. | 2871 // Check if the {value} is a Smi or a HeapObject. |
| 2975 Label if_valueissmi(this, Label::kDeferred), if_valueisnotsmi(this), | 2872 Label if_valueissmi(this, Label::kDeferred), if_valueisnotsmi(this), |
| 2976 if_valueisstring(this); | 2873 if_valueisstring(this); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3021 // The {value} is a Smi, convert it to a String. | 2918 // The {value} is a Smi, convert it to a String. |
| 3022 Callable callable = CodeFactory::NumberToString(isolate()); | 2919 Callable callable = CodeFactory::NumberToString(isolate()); |
| 3023 var_value.Bind(CallStub(callable, context, value)); | 2920 var_value.Bind(CallStub(callable, context, value)); |
| 3024 Goto(&if_valueisstring); | 2921 Goto(&if_valueisstring); |
| 3025 } | 2922 } |
| 3026 BIND(&if_valueisstring); | 2923 BIND(&if_valueisstring); |
| 3027 return var_value.value(); | 2924 return var_value.value(); |
| 3028 } | 2925 } |
| 3029 | 2926 |
| 3030 Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) { | 2927 Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) { |
| 3031 CSA_SLOW_ASSERT(this, IsNumber(value)); | |
| 3032 VARIABLE(result, MachineRepresentation::kFloat64); | 2928 VARIABLE(result, MachineRepresentation::kFloat64); |
| 3033 Label smi(this); | 2929 Label smi(this); |
| 3034 Label done(this, &result); | 2930 Label done(this, &result); |
| 3035 GotoIf(TaggedIsSmi(value), &smi); | 2931 GotoIf(TaggedIsSmi(value), &smi); |
| 3036 result.Bind( | 2932 result.Bind( |
| 3037 LoadObjectField(value, HeapNumber::kValueOffset, MachineType::Float64())); | 2933 LoadObjectField(value, HeapNumber::kValueOffset, MachineType::Float64())); |
| 3038 Goto(&done); | 2934 Goto(&done); |
| 3039 | 2935 |
| 3040 BIND(&smi); | 2936 BIND(&smi); |
| 3041 { | 2937 { |
| 3042 result.Bind(SmiToFloat64(value)); | 2938 result.Bind(SmiToFloat64(value)); |
| 3043 Goto(&done); | 2939 Goto(&done); |
| 3044 } | 2940 } |
| 3045 | 2941 |
| 3046 BIND(&done); | 2942 BIND(&done); |
| 3047 return result.value(); | 2943 return result.value(); |
| 3048 } | 2944 } |
| 3049 | 2945 |
| 3050 Node* CodeStubAssembler::ChangeNumberToIntPtr(Node* value) { | 2946 Node* CodeStubAssembler::ChangeNumberToIntPtr(Node* value) { |
| 3051 CSA_SLOW_ASSERT(this, IsNumber(value)); | |
| 3052 VARIABLE(result, MachineType::PointerRepresentation()); | 2947 VARIABLE(result, MachineType::PointerRepresentation()); |
| 3053 Label smi(this), done(this, &result); | 2948 Label smi(this), done(this, &result); |
| 3054 GotoIf(TaggedIsSmi(value), &smi); | 2949 GotoIf(TaggedIsSmi(value), &smi); |
| 3055 | 2950 |
| 3056 CSA_ASSERT(this, IsHeapNumber(value)); | 2951 CSA_ASSERT(this, IsHeapNumber(value)); |
| 3057 result.Bind(ChangeFloat64ToUintPtr(LoadHeapNumberValue(value))); | 2952 result.Bind(ChangeFloat64ToUintPtr(LoadHeapNumberValue(value))); |
| 3058 Goto(&done); | 2953 Goto(&done); |
| 3059 | 2954 |
| 3060 BIND(&smi); | 2955 BIND(&smi); |
| 3061 result.Bind(SmiToWord(value)); | 2956 result.Bind(SmiToWord(value)); |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3179 | 3074 |
| 3180 BIND(&out); | 3075 BIND(&out); |
| 3181 return var_value_map.value(); | 3076 return var_value_map.value(); |
| 3182 } | 3077 } |
| 3183 | 3078 |
| 3184 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { | 3079 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { |
| 3185 return Word32Equal(instance_type, Int32Constant(type)); | 3080 return Word32Equal(instance_type, Int32Constant(type)); |
| 3186 } | 3081 } |
| 3187 | 3082 |
| 3188 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { | 3083 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { |
| 3189 CSA_SLOW_ASSERT(this, IsMap(map)); | |
| 3190 Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); | 3084 Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); |
| 3191 uint32_t mask = | 3085 uint32_t mask = |
| 3192 1 << Map::kHasNamedInterceptor | 1 << Map::kIsAccessCheckNeeded; | 3086 1 << Map::kHasNamedInterceptor | 1 << Map::kIsAccessCheckNeeded; |
| 3193 USE(mask); | 3087 USE(mask); |
| 3194 // Interceptors or access checks imply special receiver. | 3088 // Interceptors or access checks imply special receiver. |
| 3195 CSA_ASSERT(this, | 3089 CSA_ASSERT(this, |
| 3196 SelectConstant(IsSetWord32(LoadMapBitField(map), mask), is_special, | 3090 SelectConstant(IsSetWord32(LoadMapBitField(map), mask), is_special, |
| 3197 Int32Constant(1), MachineRepresentation::kWord32)); | 3091 Int32Constant(1), MachineRepresentation::kWord32)); |
| 3198 return is_special; | 3092 return is_special; |
| 3199 } | 3093 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3306 | 3200 |
| 3307 Node* CodeStubAssembler::IsJSObject(Node* object) { | 3201 Node* CodeStubAssembler::IsJSObject(Node* object) { |
| 3308 return IsJSObjectMap(LoadMap(object)); | 3202 return IsJSObjectMap(LoadMap(object)); |
| 3309 } | 3203 } |
| 3310 | 3204 |
| 3311 Node* CodeStubAssembler::IsJSGlobalProxy(Node* object) { | 3205 Node* CodeStubAssembler::IsJSGlobalProxy(Node* object) { |
| 3312 return Word32Equal(LoadInstanceType(object), | 3206 return Word32Equal(LoadInstanceType(object), |
| 3313 Int32Constant(JS_GLOBAL_PROXY_TYPE)); | 3207 Int32Constant(JS_GLOBAL_PROXY_TYPE)); |
| 3314 } | 3208 } |
| 3315 | 3209 |
| 3316 Node* CodeStubAssembler::IsMap(Node* map) { return IsMetaMap(LoadMap(map)); } | 3210 Node* CodeStubAssembler::IsMap(Node* map) { |
| 3211 return HasInstanceType(map, MAP_TYPE); |
| 3212 } |
| 3317 | 3213 |
| 3318 Node* CodeStubAssembler::IsJSValueInstanceType(Node* instance_type) { | 3214 Node* CodeStubAssembler::IsJSValueInstanceType(Node* instance_type) { |
| 3319 return Word32Equal(instance_type, Int32Constant(JS_VALUE_TYPE)); | 3215 return Word32Equal(instance_type, Int32Constant(JS_VALUE_TYPE)); |
| 3320 } | 3216 } |
| 3321 | 3217 |
| 3322 Node* CodeStubAssembler::IsJSValue(Node* object) { | 3218 Node* CodeStubAssembler::IsJSValue(Node* object) { |
| 3323 return IsJSValueMap(LoadMap(object)); | 3219 return IsJSValueMap(LoadMap(object)); |
| 3324 } | 3220 } |
| 3325 | 3221 |
| 3326 Node* CodeStubAssembler::IsJSValueMap(Node* map) { | 3222 Node* CodeStubAssembler::IsJSValueMap(Node* map) { |
| 3327 return IsJSValueInstanceType(LoadMapInstanceType(map)); | 3223 return IsJSValueInstanceType(LoadMapInstanceType(map)); |
| 3328 } | 3224 } |
| 3329 | 3225 |
| 3330 Node* CodeStubAssembler::IsJSArrayInstanceType(Node* instance_type) { | 3226 Node* CodeStubAssembler::IsJSArrayInstanceType(Node* instance_type) { |
| 3331 return Word32Equal(instance_type, Int32Constant(JS_ARRAY_TYPE)); | 3227 return Word32Equal(instance_type, Int32Constant(JS_ARRAY_TYPE)); |
| 3332 } | 3228 } |
| 3333 | 3229 |
| 3334 Node* CodeStubAssembler::IsJSArray(Node* object) { | 3230 Node* CodeStubAssembler::IsJSArray(Node* object) { |
| 3335 return IsJSArrayMap(LoadMap(object)); | 3231 return IsJSArrayMap(LoadMap(object)); |
| 3336 } | 3232 } |
| 3337 | 3233 |
| 3338 Node* CodeStubAssembler::IsJSArrayMap(Node* map) { | 3234 Node* CodeStubAssembler::IsJSArrayMap(Node* map) { |
| 3339 return IsJSArrayInstanceType(LoadMapInstanceType(map)); | 3235 return IsJSArrayInstanceType(LoadMapInstanceType(map)); |
| 3340 } | 3236 } |
| 3341 | 3237 |
| 3342 Node* CodeStubAssembler::IsFixedArray(Node* object) { | |
| 3343 return HasInstanceType(object, FIXED_ARRAY_TYPE); | |
| 3344 } | |
| 3345 | |
| 3346 // This complicated check is due to elements oddities. If a smi array is empty | |
| 3347 // after Array.p.shift, it is replaced by the empty array constant. If it is | |
| 3348 // later filled with a double element, we try to grow it but pass in a double | |
| 3349 // elements kind. Usually this would cause a size mismatch (since the source | |
| 3350 // fixed array has FAST_HOLEY_ELEMENTS and destination has | |
| 3351 // FAST_HOLEY_DOUBLE_ELEMENTS), but we don't have to worry about it when the | |
| 3352 // source array is empty. | |
| 3353 // TODO(jgruber): It might we worth creating an empty_double_array constant to | |
| 3354 // simplify this case. | |
| 3355 Node* CodeStubAssembler::IsFixedArrayWithKindOrEmpty(Node* object, | |
| 3356 ElementsKind kind) { | |
| 3357 Label out(this); | |
| 3358 VARIABLE(var_result, MachineRepresentation::kWord32, Int32Constant(1)); | |
| 3359 | |
| 3360 GotoIf(IsFixedArrayWithKind(object, kind), &out); | |
| 3361 | |
| 3362 Node* const length = LoadFixedArrayBaseLength(object); | |
| 3363 GotoIf(SmiEqual(length, SmiConstant(0)), &out); | |
| 3364 | |
| 3365 var_result.Bind(Int32Constant(0)); | |
| 3366 Goto(&out); | |
| 3367 | |
| 3368 BIND(&out); | |
| 3369 return var_result.value(); | |
| 3370 } | |
| 3371 | |
| 3372 Node* CodeStubAssembler::IsFixedArrayWithKind(Node* object, ElementsKind kind) { | |
| 3373 if (IsFastDoubleElementsKind(kind)) { | |
| 3374 return IsFixedDoubleArray(object); | |
| 3375 } else { | |
| 3376 DCHECK(IsFastSmiOrObjectElementsKind(kind)); | |
| 3377 return IsFixedArray(object); | |
| 3378 } | |
| 3379 } | |
| 3380 | |
| 3381 Node* CodeStubAssembler::IsWeakCell(Node* object) { | 3238 Node* CodeStubAssembler::IsWeakCell(Node* object) { |
| 3382 return IsWeakCellMap(LoadMap(object)); | 3239 return IsWeakCellMap(LoadMap(object)); |
| 3383 } | 3240 } |
| 3384 | 3241 |
| 3385 Node* CodeStubAssembler::IsBoolean(Node* object) { | 3242 Node* CodeStubAssembler::IsBoolean(Node* object) { |
| 3386 return IsBooleanMap(LoadMap(object)); | 3243 return IsBooleanMap(LoadMap(object)); |
| 3387 } | 3244 } |
| 3388 | 3245 |
| 3389 Node* CodeStubAssembler::IsPropertyCell(Node* object) { | 3246 Node* CodeStubAssembler::IsPropertyCell(Node* object) { |
| 3390 return IsPropertyCellMap(LoadMap(object)); | 3247 return IsPropertyCellMap(LoadMap(object)); |
| 3391 } | 3248 } |
| 3392 | 3249 |
| 3393 Node* CodeStubAssembler::IsAccessorInfo(Node* object) { | 3250 Node* CodeStubAssembler::IsAccessorInfo(Node* object) { |
| 3394 return IsAccessorInfoMap(LoadMap(object)); | 3251 return IsAccessorInfoMap(LoadMap(object)); |
| 3395 } | 3252 } |
| 3396 | 3253 |
| 3397 Node* CodeStubAssembler::IsAccessorPair(Node* object) { | 3254 Node* CodeStubAssembler::IsAccessorPair(Node* object) { |
| 3398 return IsAccessorPairMap(LoadMap(object)); | 3255 return IsAccessorPairMap(LoadMap(object)); |
| 3399 } | 3256 } |
| 3400 | 3257 |
| 3401 Node* CodeStubAssembler::IsAnyHeapNumber(Node* object) { | |
| 3402 return Word32Or(IsMutableHeapNumber(object), IsHeapNumber(object)); | |
| 3403 } | |
| 3404 | |
| 3405 Node* CodeStubAssembler::IsMutableHeapNumber(Node* object) { | |
| 3406 return IsMutableHeapNumberMap(LoadMap(object)); | |
| 3407 } | |
| 3408 | |
| 3409 Node* CodeStubAssembler::IsHeapNumber(Node* object) { | 3258 Node* CodeStubAssembler::IsHeapNumber(Node* object) { |
| 3410 return IsHeapNumberMap(LoadMap(object)); | 3259 return IsHeapNumberMap(LoadMap(object)); |
| 3411 } | 3260 } |
| 3412 | 3261 |
| 3413 Node* CodeStubAssembler::IsFeedbackVector(Node* object) { | 3262 Node* CodeStubAssembler::IsFeedbackVector(Node* object) { |
| 3414 return IsFeedbackVectorMap(LoadMap(object)); | 3263 return IsFeedbackVectorMap(LoadMap(object)); |
| 3415 } | 3264 } |
| 3416 | 3265 |
| 3417 Node* CodeStubAssembler::IsName(Node* object) { | 3266 Node* CodeStubAssembler::IsName(Node* object) { |
| 3418 return Int32LessThanOrEqual(LoadInstanceType(object), | 3267 return Int32LessThanOrEqual(LoadInstanceType(object), |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3530 [=] { return TaggedIsPositiveSmi(number); }, | 3379 [=] { return TaggedIsPositiveSmi(number); }, |
| 3531 [=] { | 3380 [=] { |
| 3532 Node* v = LoadHeapNumberValue(number); | 3381 Node* v = LoadHeapNumberValue(number); |
| 3533 return Float64GreaterThanOrEqual(v, float_zero); | 3382 return Float64GreaterThanOrEqual(v, float_zero); |
| 3534 }, | 3383 }, |
| 3535 MachineRepresentation::kWord32); | 3384 MachineRepresentation::kWord32); |
| 3536 } | 3385 } |
| 3537 | 3386 |
| 3538 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index, | 3387 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index, |
| 3539 ParameterMode parameter_mode) { | 3388 ParameterMode parameter_mode) { |
| 3540 CSA_ASSERT(this, MatchesParameterMode(index, parameter_mode)); | 3389 if (parameter_mode == SMI_PARAMETERS) CSA_ASSERT(this, TaggedIsSmi(index)); |
| 3541 CSA_ASSERT(this, IsString(string)); | 3390 CSA_ASSERT(this, IsString(string)); |
| 3542 | 3391 |
| 3543 // Translate the {index} into a Word. | 3392 // Translate the {index} into a Word. |
| 3544 Node* const int_index = ParameterToWord(index, parameter_mode); | 3393 Node* const int_index = ParameterToWord(index, parameter_mode); |
| 3545 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0))); | 3394 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0))); |
| 3546 | 3395 |
| 3547 VARIABLE(var_result, MachineRepresentation::kWord32); | 3396 VARIABLE(var_result, MachineRepresentation::kWord32); |
| 3548 | 3397 |
| 3549 Label out(this, &var_result), runtime_generic(this), runtime_external(this); | 3398 Label out(this, &var_result), runtime_generic(this), runtime_external(this); |
| 3550 | 3399 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3642 // Allocate a new SeqTwoByteString for {code}. | 3491 // Allocate a new SeqTwoByteString for {code}. |
| 3643 Node* result = AllocateSeqTwoByteString(1); | 3492 Node* result = AllocateSeqTwoByteString(1); |
| 3644 StoreNoWriteBarrier( | 3493 StoreNoWriteBarrier( |
| 3645 MachineRepresentation::kWord16, result, | 3494 MachineRepresentation::kWord16, result, |
| 3646 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); | 3495 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); |
| 3647 var_result.Bind(result); | 3496 var_result.Bind(result); |
| 3648 Goto(&if_done); | 3497 Goto(&if_done); |
| 3649 } | 3498 } |
| 3650 | 3499 |
| 3651 BIND(&if_done); | 3500 BIND(&if_done); |
| 3652 CSA_ASSERT(this, IsString(var_result.value())); | |
| 3653 return var_result.value(); | 3501 return var_result.value(); |
| 3654 } | 3502 } |
| 3655 | 3503 |
| 3656 namespace { | 3504 namespace { |
| 3657 | 3505 |
| 3658 // A wrapper around CopyStringCharacters which determines the correct string | 3506 // A wrapper around CopyStringCharacters which determines the correct string |
| 3659 // encoding, allocates a corresponding sequential string, and then copies the | 3507 // encoding, allocates a corresponding sequential string, and then copies the |
| 3660 // given character range using CopyStringCharacters. | 3508 // given character range using CopyStringCharacters. |
| 3661 // |from_string| must be a sequential string. |from_index| and | 3509 // |from_string| must be a sequential string. |from_index| and |
| 3662 // |character_count| must be Smis s.t. | 3510 // |character_count| must be Smis s.t. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3853 | 3701 |
| 3854 // Fall back to a runtime call. | 3702 // Fall back to a runtime call. |
| 3855 BIND(&runtime); | 3703 BIND(&runtime); |
| 3856 { | 3704 { |
| 3857 var_result.Bind( | 3705 var_result.Bind( |
| 3858 CallRuntime(Runtime::kSubString, context, string, from, to)); | 3706 CallRuntime(Runtime::kSubString, context, string, from, to)); |
| 3859 Goto(&end); | 3707 Goto(&end); |
| 3860 } | 3708 } |
| 3861 | 3709 |
| 3862 BIND(&end); | 3710 BIND(&end); |
| 3863 CSA_ASSERT(this, IsString(var_result.value())); | |
| 3864 return var_result.value(); | 3711 return var_result.value(); |
| 3865 } | 3712 } |
| 3866 | 3713 |
| 3867 ToDirectStringAssembler::ToDirectStringAssembler( | 3714 ToDirectStringAssembler::ToDirectStringAssembler( |
| 3868 compiler::CodeAssemblerState* state, Node* string, Flags flags) | 3715 compiler::CodeAssemblerState* state, Node* string, Flags flags) |
| 3869 : CodeStubAssembler(state), | 3716 : CodeStubAssembler(state), |
| 3870 var_string_(this, MachineRepresentation::kTagged, string), | 3717 var_string_(this, MachineRepresentation::kTagged, string), |
| 3871 var_instance_type_(this, MachineRepresentation::kWord32), | 3718 var_instance_type_(this, MachineRepresentation::kWord32), |
| 3872 var_offset_(this, MachineType::PointerRepresentation()), | 3719 var_offset_(this, MachineType::PointerRepresentation()), |
| 3873 var_is_external_(this, MachineRepresentation::kWord32), | 3720 var_is_external_(this, MachineRepresentation::kWord32), |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4001 kHeapObjectTag)); | 3848 kHeapObjectTag)); |
| 4002 } | 3849 } |
| 4003 var_result.Bind(result); | 3850 var_result.Bind(result); |
| 4004 Goto(&out); | 3851 Goto(&out); |
| 4005 } | 3852 } |
| 4006 | 3853 |
| 4007 BIND(&out); | 3854 BIND(&out); |
| 4008 return var_result.value(); | 3855 return var_result.value(); |
| 4009 } | 3856 } |
| 4010 | 3857 |
| 3858 Node* CodeStubAssembler::TryDerefExternalString(Node* const string, |
| 3859 Node* const instance_type, |
| 3860 Label* if_bailout) { |
| 3861 Label out(this); |
| 3862 |
| 3863 CSA_ASSERT(this, IsExternalStringInstanceType(instance_type)); |
| 3864 GotoIf(IsShortExternalStringInstanceType(instance_type), if_bailout); |
| 3865 |
| 3866 // Move the pointer so that offset-wise, it looks like a sequential string. |
| 3867 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize); |
| 3868 |
| 3869 Node* resource_data = LoadObjectField( |
| 3870 string, ExternalString::kResourceDataOffset, MachineType::Pointer()); |
| 3871 Node* const fake_sequential_string = |
| 3872 IntPtrSub(resource_data, |
| 3873 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag)); |
| 3874 |
| 3875 return fake_sequential_string; |
| 3876 } |
| 3877 |
| 4011 void CodeStubAssembler::MaybeDerefIndirectString(Variable* var_string, | 3878 void CodeStubAssembler::MaybeDerefIndirectString(Variable* var_string, |
| 4012 Node* instance_type, | 3879 Node* instance_type, |
| 4013 Variable* var_did_something) { | 3880 Variable* var_did_something) { |
| 4014 Label deref(this), done(this, var_did_something); | 3881 Label deref(this), done(this, var_did_something); |
| 4015 Node* representation = | 3882 Node* representation = |
| 4016 Word32And(instance_type, Int32Constant(kStringRepresentationMask)); | 3883 Word32And(instance_type, Int32Constant(kStringRepresentationMask)); |
| 4017 GotoIf(Word32Equal(representation, Int32Constant(kThinStringTag)), &deref); | 3884 GotoIf(Word32Equal(representation, Int32Constant(kThinStringTag)), &deref); |
| 4018 GotoIf(Word32NotEqual(representation, Int32Constant(kConsStringTag)), &done); | 3885 GotoIf(Word32NotEqual(representation, Int32Constant(kConsStringTag)), &done); |
| 4019 // Cons string. | 3886 // Cons string. |
| 4020 Node* rhs = LoadObjectField(var_string->value(), ConsString::kSecondOffset); | 3887 Node* rhs = LoadObjectField(var_string->value(), ConsString::kSecondOffset); |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4206 Node* value = AllocateSeqTwoByteString(2); | 4073 Node* value = AllocateSeqTwoByteString(2); |
| 4207 StoreNoWriteBarrier( | 4074 StoreNoWriteBarrier( |
| 4208 MachineRepresentation::kWord32, value, | 4075 MachineRepresentation::kWord32, value, |
| 4209 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), | 4076 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), |
| 4210 codepoint); | 4077 codepoint); |
| 4211 var_result.Bind(value); | 4078 var_result.Bind(value); |
| 4212 Goto(&return_result); | 4079 Goto(&return_result); |
| 4213 } | 4080 } |
| 4214 | 4081 |
| 4215 BIND(&return_result); | 4082 BIND(&return_result); |
| 4216 CSA_ASSERT(this, IsString(var_result.value())); | |
| 4217 return var_result.value(); | 4083 return var_result.value(); |
| 4218 } | 4084 } |
| 4219 | 4085 |
| 4220 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { | 4086 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { |
| 4221 CSA_SLOW_ASSERT(this, IsString(input)); | |
| 4222 Label runtime(this, Label::kDeferred); | 4087 Label runtime(this, Label::kDeferred); |
| 4223 Label end(this); | 4088 Label end(this); |
| 4224 | 4089 |
| 4225 VARIABLE(var_result, MachineRepresentation::kTagged); | 4090 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 4226 | 4091 |
| 4227 // Check if string has a cached array index. | 4092 // Check if string has a cached array index. |
| 4228 Node* hash = LoadNameHashField(input); | 4093 Node* hash = LoadNameHashField(input); |
| 4229 Node* bit = | 4094 Node* bit = |
| 4230 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); | 4095 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); |
| 4231 GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime); | 4096 GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4266 GotoIfNot(IsHeapNumberMap(map), &runtime); | 4131 GotoIfNot(IsHeapNumberMap(map), &runtime); |
| 4267 | 4132 |
| 4268 // Make a hash from the two 32-bit values of the double. | 4133 // Make a hash from the two 32-bit values of the double. |
| 4269 Node* low = | 4134 Node* low = |
| 4270 LoadObjectField(argument, HeapNumber::kValueOffset, MachineType::Int32()); | 4135 LoadObjectField(argument, HeapNumber::kValueOffset, MachineType::Int32()); |
| 4271 Node* high = LoadObjectField(argument, HeapNumber::kValueOffset + kIntSize, | 4136 Node* high = LoadObjectField(argument, HeapNumber::kValueOffset + kIntSize, |
| 4272 MachineType::Int32()); | 4137 MachineType::Int32()); |
| 4273 Node* hash = Word32Xor(low, high); | 4138 Node* hash = Word32Xor(low, high); |
| 4274 hash = ChangeInt32ToIntPtr(hash); | 4139 hash = ChangeInt32ToIntPtr(hash); |
| 4275 hash = WordShl(hash, one); | 4140 hash = WordShl(hash, one); |
| 4276 Node* index = WordAnd(hash, WordSar(mask, SmiShiftBitsConstant())); | 4141 Node* index = WordAnd(hash, SmiUntag(BitcastWordToTagged(mask))); |
| 4277 | 4142 |
| 4278 // Cache entry's key must be a heap number | 4143 // Cache entry's key must be a heap number |
| 4279 Node* number_key = LoadFixedArrayElement(number_string_cache, index); | 4144 Node* number_key = LoadFixedArrayElement(number_string_cache, index); |
| 4280 GotoIf(TaggedIsSmi(number_key), &runtime); | 4145 GotoIf(TaggedIsSmi(number_key), &runtime); |
| 4281 map = LoadMap(number_key); | 4146 map = LoadMap(number_key); |
| 4282 GotoIfNot(IsHeapNumberMap(map), &runtime); | 4147 GotoIfNot(IsHeapNumberMap(map), &runtime); |
| 4283 | 4148 |
| 4284 // Cache entry's key must match the heap number value we're looking for. | 4149 // Cache entry's key must match the heap number value we're looking for. |
| 4285 Node* low_compare = LoadObjectField(number_key, HeapNumber::kValueOffset, | 4150 Node* low_compare = LoadObjectField(number_key, HeapNumber::kValueOffset, |
| 4286 MachineType::Int32()); | 4151 MachineType::Int32()); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 4311 GotoIf(WordNotEqual(smi_key, argument), &runtime); | 4176 GotoIf(WordNotEqual(smi_key, argument), &runtime); |
| 4312 | 4177 |
| 4313 // Smi match, return value from cache entry. | 4178 // Smi match, return value from cache entry. |
| 4314 IncrementCounter(isolate()->counters()->number_to_string_native(), 1); | 4179 IncrementCounter(isolate()->counters()->number_to_string_native(), 1); |
| 4315 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index, | 4180 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index, |
| 4316 kPointerSize, SMI_PARAMETERS)); | 4181 kPointerSize, SMI_PARAMETERS)); |
| 4317 Goto(&done); | 4182 Goto(&done); |
| 4318 } | 4183 } |
| 4319 | 4184 |
| 4320 BIND(&done); | 4185 BIND(&done); |
| 4321 CSA_ASSERT(this, IsString(result.value())); | |
| 4322 return result.value(); | 4186 return result.value(); |
| 4323 } | 4187 } |
| 4324 | 4188 |
| 4325 Node* CodeStubAssembler::ToName(Node* context, Node* value) { | 4189 Node* CodeStubAssembler::ToName(Node* context, Node* value) { |
| 4326 Label end(this); | 4190 Label end(this); |
| 4327 VARIABLE(var_result, MachineRepresentation::kTagged); | 4191 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 4328 | 4192 |
| 4329 Label is_number(this); | 4193 Label is_number(this); |
| 4330 GotoIf(TaggedIsSmi(value), &is_number); | 4194 GotoIf(TaggedIsSmi(value), &is_number); |
| 4331 | 4195 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 4358 Goto(&end); | 4222 Goto(&end); |
| 4359 | 4223 |
| 4360 BIND(¬_oddball); | 4224 BIND(¬_oddball); |
| 4361 { | 4225 { |
| 4362 var_result.Bind(CallRuntime(Runtime::kToName, context, value)); | 4226 var_result.Bind(CallRuntime(Runtime::kToName, context, value)); |
| 4363 Goto(&end); | 4227 Goto(&end); |
| 4364 } | 4228 } |
| 4365 } | 4229 } |
| 4366 | 4230 |
| 4367 BIND(&end); | 4231 BIND(&end); |
| 4368 CSA_ASSERT(this, IsName(var_result.value())); | |
| 4369 return var_result.value(); | 4232 return var_result.value(); |
| 4370 } | 4233 } |
| 4371 | 4234 |
| 4372 Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) { | 4235 Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) { |
| 4373 // Assert input is a HeapObject (not smi or heap number) | 4236 // Assert input is a HeapObject (not smi or heap number) |
| 4374 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(input))); | 4237 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(input))); |
| 4375 CSA_ASSERT(this, Word32BinaryNot(IsHeapNumberMap(LoadMap(input)))); | 4238 CSA_ASSERT(this, Word32BinaryNot(IsHeapNumberMap(LoadMap(input)))); |
| 4376 | 4239 |
| 4377 // We might need to loop once here due to ToPrimitive conversions. | 4240 // We might need to loop once here due to ToPrimitive conversions. |
| 4378 VARIABLE(var_input, MachineRepresentation::kTagged, input); | 4241 VARIABLE(var_input, MachineRepresentation::kTagged, input); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4447 // Note: We cannot tail call to the runtime here, as js-to-wasm | 4310 // Note: We cannot tail call to the runtime here, as js-to-wasm |
| 4448 // trampolines also use this code currently, and they declare all | 4311 // trampolines also use this code currently, and they declare all |
| 4449 // outgoing parameters as untagged, while we would push a tagged | 4312 // outgoing parameters as untagged, while we would push a tagged |
| 4450 // object here. | 4313 // object here. |
| 4451 var_result.Bind(CallRuntime(Runtime::kToNumber, context, input)); | 4314 var_result.Bind(CallRuntime(Runtime::kToNumber, context, input)); |
| 4452 Goto(&end); | 4315 Goto(&end); |
| 4453 } | 4316 } |
| 4454 } | 4317 } |
| 4455 | 4318 |
| 4456 BIND(&end); | 4319 BIND(&end); |
| 4457 CSA_ASSERT(this, IsNumber(var_result.value())); | |
| 4458 return var_result.value(); | 4320 return var_result.value(); |
| 4459 } | 4321 } |
| 4460 | 4322 |
| 4461 Node* CodeStubAssembler::ToNumber(Node* context, Node* input) { | 4323 Node* CodeStubAssembler::ToNumber(Node* context, Node* input) { |
| 4462 VARIABLE(var_result, MachineRepresentation::kTagged); | 4324 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 4463 Label end(this); | 4325 Label end(this); |
| 4464 | 4326 |
| 4465 Label not_smi(this, Label::kDeferred); | 4327 Label not_smi(this, Label::kDeferred); |
| 4466 GotoIfNot(TaggedIsSmi(input), ¬_smi); | 4328 GotoIfNot(TaggedIsSmi(input), ¬_smi); |
| 4467 var_result.Bind(input); | 4329 var_result.Bind(input); |
| 4468 Goto(&end); | 4330 Goto(&end); |
| 4469 | 4331 |
| 4470 BIND(¬_smi); | 4332 BIND(¬_smi); |
| 4471 { | 4333 { |
| 4472 Label not_heap_number(this, Label::kDeferred); | 4334 Label not_heap_number(this, Label::kDeferred); |
| 4473 Node* input_map = LoadMap(input); | 4335 Node* input_map = LoadMap(input); |
| 4474 GotoIfNot(IsHeapNumberMap(input_map), ¬_heap_number); | 4336 GotoIfNot(IsHeapNumberMap(input_map), ¬_heap_number); |
| 4475 | 4337 |
| 4476 var_result.Bind(input); | 4338 var_result.Bind(input); |
| 4477 Goto(&end); | 4339 Goto(&end); |
| 4478 | 4340 |
| 4479 BIND(¬_heap_number); | 4341 BIND(¬_heap_number); |
| 4480 { | 4342 { |
| 4481 var_result.Bind(NonNumberToNumber(context, input)); | 4343 var_result.Bind(NonNumberToNumber(context, input)); |
| 4482 Goto(&end); | 4344 Goto(&end); |
| 4483 } | 4345 } |
| 4484 } | 4346 } |
| 4485 | 4347 |
| 4486 BIND(&end); | 4348 BIND(&end); |
| 4487 CSA_ASSERT(this, IsNumber(var_result.value())); | |
| 4488 return var_result.value(); | 4349 return var_result.value(); |
| 4489 } | 4350 } |
| 4490 | 4351 |
| 4491 // ES#sec-touint32 | 4352 // ES#sec-touint32 |
| 4492 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { | 4353 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { |
| 4493 Node* const float_zero = Float64Constant(0.0); | 4354 Node* const float_zero = Float64Constant(0.0); |
| 4494 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32)); | 4355 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32)); |
| 4495 | 4356 |
| 4496 Label out(this); | 4357 Label out(this); |
| 4497 | 4358 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4580 } | 4441 } |
| 4581 | 4442 |
| 4582 BIND(&return_zero); | 4443 BIND(&return_zero); |
| 4583 { | 4444 { |
| 4584 var_result.Bind(SmiConstant(Smi::kZero)); | 4445 var_result.Bind(SmiConstant(Smi::kZero)); |
| 4585 Goto(&out); | 4446 Goto(&out); |
| 4586 } | 4447 } |
| 4587 } | 4448 } |
| 4588 | 4449 |
| 4589 BIND(&out); | 4450 BIND(&out); |
| 4590 CSA_ASSERT(this, IsNumber(var_result.value())); | |
| 4591 return var_result.value(); | 4451 return var_result.value(); |
| 4592 } | 4452 } |
| 4593 | 4453 |
| 4594 Node* CodeStubAssembler::ToString(Node* context, Node* input) { | 4454 Node* CodeStubAssembler::ToString(Node* context, Node* input) { |
| 4595 Label is_number(this); | 4455 Label is_number(this); |
| 4596 Label runtime(this, Label::kDeferred); | 4456 Label runtime(this, Label::kDeferred); |
| 4597 VARIABLE(result, MachineRepresentation::kTagged); | 4457 VARIABLE(result, MachineRepresentation::kTagged); |
| 4598 Label done(this, &result); | 4458 Label done(this, &result); |
| 4599 | 4459 |
| 4600 GotoIf(TaggedIsSmi(input), &is_number); | 4460 GotoIf(TaggedIsSmi(input), &is_number); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 4620 Goto(&done); | 4480 Goto(&done); |
| 4621 } | 4481 } |
| 4622 | 4482 |
| 4623 BIND(&runtime); | 4483 BIND(&runtime); |
| 4624 { | 4484 { |
| 4625 result.Bind(CallRuntime(Runtime::kToString, context, input)); | 4485 result.Bind(CallRuntime(Runtime::kToString, context, input)); |
| 4626 Goto(&done); | 4486 Goto(&done); |
| 4627 } | 4487 } |
| 4628 | 4488 |
| 4629 BIND(&done); | 4489 BIND(&done); |
| 4630 CSA_ASSERT(this, IsString(result.value())); | |
| 4631 return result.value(); | 4490 return result.value(); |
| 4632 } | 4491 } |
| 4633 | 4492 |
| 4634 Node* CodeStubAssembler::ToString_Inline(Node* const context, | 4493 Node* CodeStubAssembler::ToString_Inline(Node* const context, |
| 4635 Node* const input) { | 4494 Node* const input) { |
| 4636 VARIABLE(var_result, MachineRepresentation::kTagged, input); | 4495 VARIABLE(var_result, MachineRepresentation::kTagged, input); |
| 4637 Label stub_call(this, Label::kDeferred), out(this); | 4496 Label stub_call(this, Label::kDeferred), out(this); |
| 4638 | 4497 |
| 4639 GotoIf(TaggedIsSmi(input), &stub_call); | 4498 GotoIf(TaggedIsSmi(input), &stub_call); |
| 4640 Branch(IsString(input), &out, &stub_call); | 4499 Branch(IsString(input), &out, &stub_call); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4690 Goto(&negative_check); | 4549 Goto(&negative_check); |
| 4691 | 4550 |
| 4692 BIND(&negative_check); | 4551 BIND(&negative_check); |
| 4693 Branch(SmiLessThan(result.value(), SmiConstant(0)), range_error, &done); | 4552 Branch(SmiLessThan(result.value(), SmiConstant(0)), range_error, &done); |
| 4694 | 4553 |
| 4695 BIND(&return_zero); | 4554 BIND(&return_zero); |
| 4696 result.Bind(SmiConstant(0)); | 4555 result.Bind(SmiConstant(0)); |
| 4697 Goto(&done); | 4556 Goto(&done); |
| 4698 | 4557 |
| 4699 BIND(&done); | 4558 BIND(&done); |
| 4700 CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value())); | |
| 4701 return result.value(); | 4559 return result.value(); |
| 4702 } | 4560 } |
| 4703 | 4561 |
| 4704 Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context, | 4562 Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context, |
| 4705 Label* range_error) { | 4563 Label* range_error) { |
| 4706 VARIABLE(result, MachineRepresentation::kTagged, input); | 4564 VARIABLE(result, MachineRepresentation::kTagged, input); |
| 4707 Label to_integer(this), negative_check(this), return_zero(this), done(this); | 4565 Label to_integer(this), negative_check(this), return_zero(this), done(this); |
| 4708 Branch(TaggedIsSmi(result.value()), &negative_check, &to_integer); | 4566 Branch(TaggedIsSmi(result.value()), &negative_check, &to_integer); |
| 4709 | 4567 |
| 4710 BIND(&to_integer); | 4568 BIND(&to_integer); |
| 4711 result.Bind(ToInteger(context, result.value(), | 4569 result.Bind(ToInteger(context, result.value(), |
| 4712 CodeStubAssembler::kTruncateMinusZero)); | 4570 CodeStubAssembler::kTruncateMinusZero)); |
| 4713 GotoIfNot(TaggedIsSmi(result.value()), range_error); | 4571 GotoIfNot(TaggedIsSmi(result.value()), range_error); |
| 4714 CSA_ASSERT(this, TaggedIsSmi(result.value())); | 4572 CSA_ASSERT(this, TaggedIsSmi(result.value())); |
| 4715 Goto(&negative_check); | 4573 Goto(&negative_check); |
| 4716 | 4574 |
| 4717 BIND(&negative_check); | 4575 BIND(&negative_check); |
| 4718 Branch(SmiLessThan(result.value(), SmiConstant(0)), &return_zero, &done); | 4576 Branch(SmiLessThan(result.value(), SmiConstant(0)), &return_zero, &done); |
| 4719 | 4577 |
| 4720 BIND(&return_zero); | 4578 BIND(&return_zero); |
| 4721 result.Bind(SmiConstant(0)); | 4579 result.Bind(SmiConstant(0)); |
| 4722 Goto(&done); | 4580 Goto(&done); |
| 4723 | 4581 |
| 4724 BIND(&done); | 4582 BIND(&done); |
| 4725 CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value())); | |
| 4726 return result.value(); | 4583 return result.value(); |
| 4727 } | 4584 } |
| 4728 | 4585 |
| 4729 Node* CodeStubAssembler::ToLength_Inline(Node* const context, | 4586 Node* CodeStubAssembler::ToLength_Inline(Node* const context, |
| 4730 Node* const input) { | 4587 Node* const input) { |
| 4731 Node* const smi_zero = SmiConstant(0); | 4588 Node* const smi_zero = SmiConstant(0); |
| 4732 return Select( | 4589 return Select( |
| 4733 TaggedIsSmi(input), [=] { return SmiMax(input, smi_zero); }, | 4590 TaggedIsSmi(input), [=] { return SmiMax(input, smi_zero); }, |
| 4734 [=] { return CallBuiltin(Builtins::kToLength, context, input); }, | 4591 [=] { return CallBuiltin(Builtins::kToLength, context, input); }, |
| 4735 MachineRepresentation::kTagged); | 4592 MachineRepresentation::kTagged); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4785 var_arg.Bind(CallStub(callable, context, arg)); | 4642 var_arg.Bind(CallStub(callable, context, arg)); |
| 4786 Goto(&loop); | 4643 Goto(&loop); |
| 4787 } | 4644 } |
| 4788 | 4645 |
| 4789 BIND(&return_zero); | 4646 BIND(&return_zero); |
| 4790 var_arg.Bind(SmiConstant(Smi::kZero)); | 4647 var_arg.Bind(SmiConstant(Smi::kZero)); |
| 4791 Goto(&out); | 4648 Goto(&out); |
| 4792 } | 4649 } |
| 4793 | 4650 |
| 4794 BIND(&out); | 4651 BIND(&out); |
| 4795 CSA_SLOW_ASSERT(this, IsNumber(var_arg.value())); | |
| 4796 return var_arg.value(); | 4652 return var_arg.value(); |
| 4797 } | 4653 } |
| 4798 | 4654 |
| 4799 Node* CodeStubAssembler::DecodeWord32(Node* word32, uint32_t shift, | 4655 Node* CodeStubAssembler::DecodeWord32(Node* word32, uint32_t shift, |
| 4800 uint32_t mask) { | 4656 uint32_t mask) { |
| 4801 return Word32Shr(Word32And(word32, Int32Constant(mask)), | 4657 return Word32Shr(Word32And(word32, Int32Constant(mask)), |
| 4802 static_cast<int>(shift)); | 4658 static_cast<int>(shift)); |
| 4803 } | 4659 } |
| 4804 | 4660 |
| 4805 Node* CodeStubAssembler::DecodeWord(Node* word, uint32_t shift, uint32_t mask) { | 4661 Node* CodeStubAssembler::DecodeWord(Node* word, uint32_t shift, uint32_t mask) { |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4902 BIND(&if_hascachedindex); | 4758 BIND(&if_hascachedindex); |
| 4903 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash)); | 4759 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash)); |
| 4904 Goto(if_keyisindex); | 4760 Goto(if_keyisindex); |
| 4905 } | 4761 } |
| 4906 | 4762 |
| 4907 void CodeStubAssembler::TryInternalizeString( | 4763 void CodeStubAssembler::TryInternalizeString( |
| 4908 Node* string, Label* if_index, Variable* var_index, Label* if_internalized, | 4764 Node* string, Label* if_index, Variable* var_index, Label* if_internalized, |
| 4909 Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) { | 4765 Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) { |
| 4910 DCHECK(var_index->rep() == MachineType::PointerRepresentation()); | 4766 DCHECK(var_index->rep() == MachineType::PointerRepresentation()); |
| 4911 DCHECK(var_internalized->rep() == MachineRepresentation::kTagged); | 4767 DCHECK(var_internalized->rep() == MachineRepresentation::kTagged); |
| 4912 CSA_SLOW_ASSERT(this, IsString(string)); | |
| 4913 Node* function = ExternalConstant( | 4768 Node* function = ExternalConstant( |
| 4914 ExternalReference::try_internalize_string_function(isolate())); | 4769 ExternalReference::try_internalize_string_function(isolate())); |
| 4915 Node* result = CallCFunction1(MachineType::AnyTagged(), | 4770 Node* result = CallCFunction1(MachineType::AnyTagged(), |
| 4916 MachineType::AnyTagged(), function, string); | 4771 MachineType::AnyTagged(), function, string); |
| 4917 Label internalized(this); | 4772 Label internalized(this); |
| 4918 GotoIf(TaggedIsNotSmi(result), &internalized); | 4773 GotoIf(TaggedIsNotSmi(result), &internalized); |
| 4919 Node* word_result = SmiUntag(result); | 4774 Node* word_result = SmiUntag(result); |
| 4920 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kNotFound)), | 4775 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kNotFound)), |
| 4921 if_not_internalized); | 4776 if_not_internalized); |
| 4922 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kUnsupported)), | 4777 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kUnsupported)), |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5150 void CodeStubAssembler::InsertEntry(Node* dictionary, Node* key, Node* value, | 5005 void CodeStubAssembler::InsertEntry(Node* dictionary, Node* key, Node* value, |
| 5151 Node* index, Node* enum_index) { | 5006 Node* index, Node* enum_index) { |
| 5152 UNREACHABLE(); // Use specializations instead. | 5007 UNREACHABLE(); // Use specializations instead. |
| 5153 } | 5008 } |
| 5154 | 5009 |
| 5155 template <> | 5010 template <> |
| 5156 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, | 5011 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, |
| 5157 Node* name, Node* value, | 5012 Node* name, Node* value, |
| 5158 Node* index, | 5013 Node* index, |
| 5159 Node* enum_index) { | 5014 Node* enum_index) { |
| 5160 CSA_SLOW_ASSERT(this, IsDictionary(dictionary)); | |
| 5161 | |
| 5162 // Store name and value. | 5015 // Store name and value. |
| 5163 StoreFixedArrayElement(dictionary, index, name); | 5016 StoreFixedArrayElement(dictionary, index, name); |
| 5164 StoreValueByKeyIndex<NameDictionary>(dictionary, index, value); | 5017 StoreValueByKeyIndex<NameDictionary>(dictionary, index, value); |
| 5165 | 5018 |
| 5166 // Prepare details of the new property. | 5019 // Prepare details of the new property. |
| 5167 const int kInitialIndex = 0; | 5020 const int kInitialIndex = 0; |
| 5168 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell); | 5021 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell); |
| 5169 enum_index = | 5022 enum_index = |
| 5170 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); | 5023 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); |
| 5171 STATIC_ASSERT(kInitialIndex == 0); | 5024 STATIC_ASSERT(kInitialIndex == 0); |
| (...skipping 21 matching lines...) Expand all Loading... |
| 5193 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, | 5046 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, |
| 5194 Node* key, Node* value, | 5047 Node* key, Node* value, |
| 5195 Node* index, | 5048 Node* index, |
| 5196 Node* enum_index) { | 5049 Node* enum_index) { |
| 5197 UNIMPLEMENTED(); | 5050 UNIMPLEMENTED(); |
| 5198 } | 5051 } |
| 5199 | 5052 |
| 5200 template <class Dictionary> | 5053 template <class Dictionary> |
| 5201 void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value, | 5054 void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value, |
| 5202 Label* bailout) { | 5055 Label* bailout) { |
| 5203 CSA_SLOW_ASSERT(this, IsDictionary(dictionary)); | |
| 5204 Node* capacity = GetCapacity<Dictionary>(dictionary); | 5056 Node* capacity = GetCapacity<Dictionary>(dictionary); |
| 5205 Node* nof = GetNumberOfElements<Dictionary>(dictionary); | 5057 Node* nof = GetNumberOfElements<Dictionary>(dictionary); |
| 5206 Node* new_nof = SmiAdd(nof, SmiConstant(1)); | 5058 Node* new_nof = SmiAdd(nof, SmiConstant(1)); |
| 5207 // Require 33% to still be free after adding additional_elements. | 5059 // Require 33% to still be free after adding additional_elements. |
| 5208 // Computing "x + (x >> 1)" on a Smi x does not return a valid Smi! | 5060 // Computing "x + (x >> 1)" on a Smi x does not return a valid Smi! |
| 5209 // But that's OK here because it's only used for a comparison. | 5061 // But that's OK here because it's only used for a comparison. |
| 5210 Node* required_capacity_pseudo_smi = SmiAdd(new_nof, SmiShr(new_nof, 1)); | 5062 Node* required_capacity_pseudo_smi = SmiAdd(new_nof, SmiShr(new_nof, 1)); |
| 5211 GotoIf(SmiBelow(capacity, required_capacity_pseudo_smi), bailout); | 5063 GotoIf(SmiBelow(capacity, required_capacity_pseudo_smi), bailout); |
| 5212 // Require rehashing if more than 50% of free elements are deleted elements. | 5064 // Require rehashing if more than 50% of free elements are deleted elements. |
| 5213 Node* deleted = GetNumberOfDeletedElements<Dictionary>(dictionary); | 5065 Node* deleted = GetNumberOfDeletedElements<Dictionary>(dictionary); |
| (...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6912 Goto(&end); | 6764 Goto(&end); |
| 6913 } | 6765 } |
| 6914 | 6766 |
| 6915 BIND(&end); | 6767 BIND(&end); |
| 6916 } | 6768 } |
| 6917 | 6769 |
| 6918 Node* CodeStubAssembler::BuildFastLoop( | 6770 Node* CodeStubAssembler::BuildFastLoop( |
| 6919 const CodeStubAssembler::VariableList& vars, Node* start_index, | 6771 const CodeStubAssembler::VariableList& vars, Node* start_index, |
| 6920 Node* end_index, const FastLoopBody& body, int increment, | 6772 Node* end_index, const FastLoopBody& body, int increment, |
| 6921 ParameterMode parameter_mode, IndexAdvanceMode advance_mode) { | 6773 ParameterMode parameter_mode, IndexAdvanceMode advance_mode) { |
| 6922 CSA_SLOW_ASSERT(this, MatchesParameterMode(start_index, parameter_mode)); | |
| 6923 CSA_SLOW_ASSERT(this, MatchesParameterMode(end_index, parameter_mode)); | |
| 6924 MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS) | 6774 MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS) |
| 6925 ? MachineType::PointerRepresentation() | 6775 ? MachineType::PointerRepresentation() |
| 6926 : MachineRepresentation::kTaggedSigned; | 6776 : MachineRepresentation::kTaggedSigned; |
| 6927 VARIABLE(var, index_rep, start_index); | 6777 VARIABLE(var, index_rep, start_index); |
| 6928 VariableList vars_copy(vars, zone()); | 6778 VariableList vars_copy(vars, zone()); |
| 6929 vars_copy.Add(&var, zone()); | 6779 vars_copy.Add(&var, zone()); |
| 6930 Label loop(this, vars_copy); | 6780 Label loop(this, vars_copy); |
| 6931 Label after_loop(this); | 6781 Label after_loop(this); |
| 6932 // Introduce an explicit second check of the termination condition before the | 6782 // Introduce an explicit second check of the termination condition before the |
| 6933 // loop that helps turbofan generate better code. If there's only a single | 6783 // loop that helps turbofan generate better code. If there's only a single |
| (...skipping 17 matching lines...) Expand all Loading... |
| 6951 BIND(&after_loop); | 6801 BIND(&after_loop); |
| 6952 return var.value(); | 6802 return var.value(); |
| 6953 } | 6803 } |
| 6954 | 6804 |
| 6955 void CodeStubAssembler::BuildFastFixedArrayForEach( | 6805 void CodeStubAssembler::BuildFastFixedArrayForEach( |
| 6956 const CodeStubAssembler::VariableList& vars, Node* fixed_array, | 6806 const CodeStubAssembler::VariableList& vars, Node* fixed_array, |
| 6957 ElementsKind kind, Node* first_element_inclusive, | 6807 ElementsKind kind, Node* first_element_inclusive, |
| 6958 Node* last_element_exclusive, const FastFixedArrayForEachBody& body, | 6808 Node* last_element_exclusive, const FastFixedArrayForEachBody& body, |
| 6959 ParameterMode mode, ForEachDirection direction) { | 6809 ParameterMode mode, ForEachDirection direction) { |
| 6960 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); | 6810 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); |
| 6961 CSA_SLOW_ASSERT(this, MatchesParameterMode(first_element_inclusive, mode)); | |
| 6962 CSA_SLOW_ASSERT(this, MatchesParameterMode(last_element_exclusive, mode)); | |
| 6963 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(fixed_array, kind)); | |
| 6964 int32_t first_val; | 6811 int32_t first_val; |
| 6965 bool constant_first = ToInt32Constant(first_element_inclusive, first_val); | 6812 bool constant_first = ToInt32Constant(first_element_inclusive, first_val); |
| 6966 int32_t last_val; | 6813 int32_t last_val; |
| 6967 bool constent_last = ToInt32Constant(last_element_exclusive, last_val); | 6814 bool constent_last = ToInt32Constant(last_element_exclusive, last_val); |
| 6968 if (constant_first && constent_last) { | 6815 if (constant_first && constent_last) { |
| 6969 int delta = last_val - first_val; | 6816 int delta = last_val - first_val; |
| 6970 DCHECK(delta >= 0); | 6817 DCHECK(delta >= 0); |
| 6971 if (delta <= kElementLoopUnrollThreshold) { | 6818 if (delta <= kElementLoopUnrollThreshold) { |
| 6972 if (direction == ForEachDirection::kForward) { | 6819 if (direction == ForEachDirection::kForward) { |
| 6973 for (int i = first_val; i < last_val; ++i) { | 6820 for (int i = first_val; i < last_val; ++i) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7014 (kMaxRegularHeapObjectSize - base_size) / kPointerSize; | 6861 (kMaxRegularHeapObjectSize - base_size) / kPointerSize; |
| 7015 GotoIf(IntPtrOrSmiGreaterThan( | 6862 GotoIf(IntPtrOrSmiGreaterThan( |
| 7016 element_count, IntPtrOrSmiConstant(max_newspace_parameters, mode), | 6863 element_count, IntPtrOrSmiConstant(max_newspace_parameters, mode), |
| 7017 mode), | 6864 mode), |
| 7018 doesnt_fit); | 6865 doesnt_fit); |
| 7019 } | 6866 } |
| 7020 | 6867 |
| 7021 void CodeStubAssembler::InitializeFieldsWithRoot( | 6868 void CodeStubAssembler::InitializeFieldsWithRoot( |
| 7022 Node* object, Node* start_offset, Node* end_offset, | 6869 Node* object, Node* start_offset, Node* end_offset, |
| 7023 Heap::RootListIndex root_index) { | 6870 Heap::RootListIndex root_index) { |
| 7024 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object)); | |
| 7025 start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag)); | 6871 start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag)); |
| 7026 end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag)); | 6872 end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag)); |
| 7027 Node* root_value = LoadRoot(root_index); | 6873 Node* root_value = LoadRoot(root_index); |
| 7028 BuildFastLoop(end_offset, start_offset, | 6874 BuildFastLoop(end_offset, start_offset, |
| 7029 [this, object, root_value](Node* current) { | 6875 [this, object, root_value](Node* current) { |
| 7030 StoreNoWriteBarrier(MachineRepresentation::kTagged, object, | 6876 StoreNoWriteBarrier(MachineRepresentation::kTagged, object, |
| 7031 current, root_value); | 6877 current, root_value); |
| 7032 }, | 6878 }, |
| 7033 -kPointerSize, INTPTR_PARAMETERS, | 6879 -kPointerSize, INTPTR_PARAMETERS, |
| 7034 CodeStubAssembler::IndexAdvanceMode::kPre); | 6880 CodeStubAssembler::IndexAdvanceMode::kPre); |
| 7035 } | 6881 } |
| 7036 | 6882 |
| 7037 void CodeStubAssembler::BranchIfNumericRelationalComparison( | 6883 void CodeStubAssembler::BranchIfNumericRelationalComparison( |
| 7038 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true, | 6884 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true, |
| 7039 Label* if_false) { | 6885 Label* if_false) { |
| 7040 CSA_SLOW_ASSERT(this, IsNumber(lhs)); | |
| 7041 CSA_SLOW_ASSERT(this, IsNumber(rhs)); | |
| 7042 | |
| 7043 Label end(this); | 6886 Label end(this); |
| 7044 VARIABLE(result, MachineRepresentation::kTagged); | 6887 VARIABLE(result, MachineRepresentation::kTagged); |
| 7045 | 6888 |
| 7046 // Shared entry for floating point comparison. | 6889 // Shared entry for floating point comparison. |
| 7047 Label do_fcmp(this); | 6890 Label do_fcmp(this); |
| 7048 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); | 6891 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); |
| 7049 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); | 6892 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); |
| 7050 | 6893 |
| 7051 // Check if the {lhs} is a Smi or a HeapObject. | 6894 // Check if the {lhs} is a Smi or a HeapObject. |
| 7052 Label if_lhsissmi(this), if_lhsisnotsmi(this); | 6895 Label if_lhsissmi(this), if_lhsisnotsmi(this); |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7145 Label* if_false) { | 6988 Label* if_false) { |
| 7146 Label if_true(this); | 6989 Label if_true(this); |
| 7147 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false); | 6990 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false); |
| 7148 BIND(&if_true); | 6991 BIND(&if_true); |
| 7149 } | 6992 } |
| 7150 | 6993 |
| 7151 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode, | 6994 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode, |
| 7152 Node* lhs, Node* rhs, | 6995 Node* lhs, Node* rhs, |
| 7153 Node* context, | 6996 Node* context, |
| 7154 Variable* var_type_feedback) { | 6997 Variable* var_type_feedback) { |
| 7155 CSA_SLOW_ASSERT(this, IsNumber(lhs)); | |
| 7156 CSA_SLOW_ASSERT(this, IsNumber(rhs)); | |
| 7157 | |
| 7158 Label return_true(this), return_false(this), end(this); | 6998 Label return_true(this), return_false(this), end(this); |
| 7159 VARIABLE(result, MachineRepresentation::kTagged); | 6999 VARIABLE(result, MachineRepresentation::kTagged); |
| 7160 | 7000 |
| 7161 // Shared entry for floating point comparison. | 7001 // Shared entry for floating point comparison. |
| 7162 Label do_fcmp(this); | 7002 Label do_fcmp(this); |
| 7163 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); | 7003 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); |
| 7164 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); | 7004 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); |
| 7165 | 7005 |
| 7166 // We might need to loop several times due to ToPrimitive and/or ToNumber | 7006 // We might need to loop several times due to ToPrimitive and/or ToNumber |
| 7167 // conversions. | 7007 // conversions. |
| (...skipping 1638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8806 | 8646 |
| 8807 BIND(&return_false); | 8647 BIND(&return_false); |
| 8808 var_result.Bind(FalseConstant()); | 8648 var_result.Bind(FalseConstant()); |
| 8809 Goto(&return_result); | 8649 Goto(&return_result); |
| 8810 | 8650 |
| 8811 BIND(&return_result); | 8651 BIND(&return_result); |
| 8812 return var_result.value(); | 8652 return var_result.value(); |
| 8813 } | 8653 } |
| 8814 | 8654 |
| 8815 Node* CodeStubAssembler::NumberInc(Node* value) { | 8655 Node* CodeStubAssembler::NumberInc(Node* value) { |
| 8816 CSA_SLOW_ASSERT(this, IsNumber(value)); | |
| 8817 | |
| 8818 VARIABLE(var_result, MachineRepresentation::kTagged); | 8656 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 8819 VARIABLE(var_finc_value, MachineRepresentation::kFloat64); | 8657 VARIABLE(var_finc_value, MachineRepresentation::kFloat64); |
| 8820 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); | 8658 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); |
| 8821 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); | 8659 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); |
| 8822 | 8660 |
| 8823 BIND(&if_issmi); | 8661 BIND(&if_issmi); |
| 8824 { | 8662 { |
| 8825 // Try fast Smi addition first. | 8663 // Try fast Smi addition first. |
| 8826 Node* one = SmiConstant(Smi::FromInt(1)); | 8664 Node* one = SmiConstant(Smi::FromInt(1)); |
| 8827 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value), | 8665 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value), |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8860 Node* finc_result = Float64Add(finc_value, one); | 8698 Node* finc_result = Float64Add(finc_value, one); |
| 8861 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); | 8699 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); |
| 8862 Goto(&end); | 8700 Goto(&end); |
| 8863 } | 8701 } |
| 8864 | 8702 |
| 8865 BIND(&end); | 8703 BIND(&end); |
| 8866 return var_result.value(); | 8704 return var_result.value(); |
| 8867 } | 8705 } |
| 8868 | 8706 |
| 8869 Node* CodeStubAssembler::NumberDec(Node* value) { | 8707 Node* CodeStubAssembler::NumberDec(Node* value) { |
| 8870 CSA_SLOW_ASSERT(this, IsNumber(value)); | |
| 8871 | |
| 8872 VARIABLE(var_result, MachineRepresentation::kTagged); | 8708 VARIABLE(var_result, MachineRepresentation::kTagged); |
| 8873 VARIABLE(var_fdec_value, MachineRepresentation::kFloat64); | 8709 VARIABLE(var_fdec_value, MachineRepresentation::kFloat64); |
| 8874 Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this); | 8710 Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this); |
| 8875 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); | 8711 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); |
| 8876 | 8712 |
| 8877 BIND(&if_issmi); | 8713 BIND(&if_issmi); |
| 8878 { | 8714 { |
| 8879 // Try fast Smi addition first. | 8715 // Try fast Smi addition first. |
| 8880 Node* one = SmiConstant(Smi::FromInt(1)); | 8716 Node* one = SmiConstant(Smi::FromInt(1)); |
| 8881 Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value), | 8717 Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value), |
| (...skipping 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9287 Load(MachineType::Uint8(), | 9123 Load(MachineType::Uint8(), |
| 9288 ExternalConstant( | 9124 ExternalConstant( |
| 9289 ExternalReference::promise_hook_or_debug_is_active_address( | 9125 ExternalReference::promise_hook_or_debug_is_active_address( |
| 9290 isolate()))); | 9126 isolate()))); |
| 9291 return Word32NotEqual(promise_hook_or_debug_is_active, Int32Constant(0)); | 9127 return Word32NotEqual(promise_hook_or_debug_is_active, Int32Constant(0)); |
| 9292 } | 9128 } |
| 9293 | 9129 |
| 9294 Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map, | 9130 Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map, |
| 9295 Node* shared_info, | 9131 Node* shared_info, |
| 9296 Node* context) { | 9132 Node* context) { |
| 9297 CSA_SLOW_ASSERT(this, IsMap(map)); | |
| 9298 | |
| 9299 Node* const code = BitcastTaggedToWord( | 9133 Node* const code = BitcastTaggedToWord( |
| 9300 LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset)); | 9134 LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset)); |
| 9301 Node* const code_entry = | 9135 Node* const code_entry = |
| 9302 IntPtrAdd(code, IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); | 9136 IntPtrAdd(code, IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); |
| 9303 | 9137 |
| 9304 Node* const fun = Allocate(JSFunction::kSize); | 9138 Node* const fun = Allocate(JSFunction::kSize); |
| 9305 StoreMapNoWriteBarrier(fun, map); | 9139 StoreMapNoWriteBarrier(fun, map); |
| 9306 StoreObjectFieldRoot(fun, JSObject::kPropertiesOffset, | 9140 StoreObjectFieldRoot(fun, JSObject::kPropertiesOffset, |
| 9307 Heap::kEmptyFixedArrayRootIndex); | 9141 Heap::kEmptyFixedArrayRootIndex); |
| 9308 StoreObjectFieldRoot(fun, JSObject::kElementsOffset, | 9142 StoreObjectFieldRoot(fun, JSObject::kElementsOffset, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9375 formatted.c_str(), TENURED); | 9209 formatted.c_str(), TENURED); |
| 9376 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), | 9210 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), |
| 9377 HeapConstant(string)); | 9211 HeapConstant(string)); |
| 9378 } | 9212 } |
| 9379 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); | 9213 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); |
| 9380 #endif | 9214 #endif |
| 9381 } | 9215 } |
| 9382 | 9216 |
| 9383 } // namespace internal | 9217 } // namespace internal |
| 9384 } // namespace v8 | 9218 } // namespace v8 |
| OLD | NEW |