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

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

Issue 2847923003: [csa] Add assertions to CSA (Closed)
Patch Set: FixedArray asserts Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 #include "src/code-stub-assembler.h" 4 #include "src/code-stub-assembler.h"
5 #include "src/code-factory.h" 5 #include "src/code-factory.h"
6 #include "src/frames-inl.h" 6 #include "src/frames-inl.h"
7 #include "src/frames.h" 7 #include "src/frames.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) { 187 Node* CodeStubAssembler::IntPtrRoundUpToPowerOfTwo32(Node* value) {
188 Comment("IntPtrRoundUpToPowerOfTwo32"); 188 Comment("IntPtrRoundUpToPowerOfTwo32");
189 CSA_ASSERT(this, UintPtrLessThanOrEqual(value, IntPtrConstant(0x80000000u))); 189 CSA_ASSERT(this, UintPtrLessThanOrEqual(value, IntPtrConstant(0x80000000u)));
190 value = IntPtrSub(value, IntPtrConstant(1)); 190 value = IntPtrSub(value, IntPtrConstant(1));
191 for (int i = 1; i <= 16; i *= 2) { 191 for (int i = 1; i <= 16; i *= 2) {
192 value = WordOr(value, WordShr(value, IntPtrConstant(i))); 192 value = WordOr(value, WordShr(value, IntPtrConstant(i)));
193 } 193 }
194 return IntPtrAdd(value, IntPtrConstant(1)); 194 return IntPtrAdd(value, IntPtrConstant(1));
195 } 195 }
196 196
197 Node* CodeStubAssembler::IsParameterMode(Node* value, ParameterMode mode) {
198 return (mode == SMI_PARAMETERS) ? TaggedIsSmi(value) : Int32Constant(1);
Igor Sheludko 2017/05/02 10:37:16 Maybe CSA_ASSERT_PARAMETER_MODE(csa, value, mode)
jgruber 2017/05/03 11:11:51 CSA_ASSERT_PARAMETER_MODE(csa, value, mode) CSA_AS
Igor Sheludko 2017/05/03 11:21:45 Even better idea: ensure that CSA::Assert() is no-
199 }
200
197 Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) { 201 Node* CodeStubAssembler::WordIsPowerOfTwo(Node* value) {
198 // value && !(value & (value - 1)) 202 // value && !(value & (value - 1))
199 return WordEqual( 203 return WordEqual(
200 Select( 204 Select(
201 WordEqual(value, IntPtrConstant(0)), 205 WordEqual(value, IntPtrConstant(0)),
202 [=] { return IntPtrConstant(1); }, 206 [=] { return IntPtrConstant(1); },
203 [=] { return WordAnd(value, IntPtrSub(value, IntPtrConstant(1))); }, 207 [=] { return WordAnd(value, IntPtrSub(value, IntPtrConstant(1))); },
204 MachineType::PointerRepresentation()), 208 MachineType::PointerRepresentation()),
205 IntPtrConstant(0)); 209 IntPtrConstant(0));
206 } 210 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 434
431 Node* CodeStubAssembler::SmiTag(Node* value) { 435 Node* CodeStubAssembler::SmiTag(Node* value) {
432 int32_t constant_value; 436 int32_t constant_value;
433 if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) { 437 if (ToInt32Constant(value, constant_value) && Smi::IsValid(constant_value)) {
434 return SmiConstant(Smi::FromInt(constant_value)); 438 return SmiConstant(Smi::FromInt(constant_value));
435 } 439 }
436 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant())); 440 return BitcastWordToTaggedSigned(WordShl(value, SmiShiftBitsConstant()));
437 } 441 }
438 442
439 Node* CodeStubAssembler::SmiUntag(Node* value) { 443 Node* CodeStubAssembler::SmiUntag(Node* value) {
444 CSA_SLOW_ASSERT(this, TaggedIsSmi(value));
440 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant()); 445 return WordSar(BitcastTaggedToWord(value), SmiShiftBitsConstant());
441 } 446 }
442 447
443 Node* CodeStubAssembler::SmiToWord32(Node* value) { 448 Node* CodeStubAssembler::SmiToWord32(Node* value) {
449 CSA_SLOW_ASSERT(this, TaggedIsSmi(value));
444 Node* result = SmiUntag(value); 450 Node* result = SmiUntag(value);
445 return TruncateWordToWord32(result); 451 return TruncateWordToWord32(result);
446 } 452 }
447 453
448 Node* CodeStubAssembler::SmiToFloat64(Node* value) { 454 Node* CodeStubAssembler::SmiToFloat64(Node* value) {
455 CSA_SLOW_ASSERT(this, TaggedIsSmi(value));
449 return ChangeInt32ToFloat64(SmiToWord32(value)); 456 return ChangeInt32ToFloat64(SmiToWord32(value));
450 } 457 }
451 458
452 Node* CodeStubAssembler::SmiMax(Node* a, Node* b) { 459 Node* CodeStubAssembler::SmiMax(Node* a, Node* b) {
460 CSA_SLOW_ASSERT(this, TaggedIsSmi(a));
461 CSA_SLOW_ASSERT(this, TaggedIsSmi(b));
Igor Sheludko 2017/05/02 10:37:17 I'd rather put these asserts into SmiLessThan() (s
jgruber 2017/05/03 11:11:50 Done.
453 return SelectTaggedConstant(SmiLessThan(a, b), b, a); 462 return SelectTaggedConstant(SmiLessThan(a, b), b, a);
454 } 463 }
455 464
456 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) { 465 Node* CodeStubAssembler::SmiMin(Node* a, Node* b) {
466 CSA_SLOW_ASSERT(this, TaggedIsSmi(a));
467 CSA_SLOW_ASSERT(this, TaggedIsSmi(b));
457 return SelectTaggedConstant(SmiLessThan(a, b), a, b); 468 return SelectTaggedConstant(SmiLessThan(a, b), a, b);
458 } 469 }
459 470
460 Node* CodeStubAssembler::SmiMod(Node* a, Node* b) { 471 Node* CodeStubAssembler::SmiMod(Node* a, Node* b) {
472 CSA_SLOW_ASSERT(this, TaggedIsSmi(a));
473 CSA_SLOW_ASSERT(this, TaggedIsSmi(b));
Igor Sheludko 2017/05/02 10:37:17 This is overkill, since SmiToWord32()s will do the
jgruber 2017/05/03 11:11:50 Done. Although I like having documentation of the
461 VARIABLE(var_result, MachineRepresentation::kTagged); 474 VARIABLE(var_result, MachineRepresentation::kTagged);
462 Label return_result(this, &var_result), 475 Label return_result(this, &var_result),
463 return_minuszero(this, Label::kDeferred), 476 return_minuszero(this, Label::kDeferred),
464 return_nan(this, Label::kDeferred); 477 return_nan(this, Label::kDeferred);
465 478
466 // Untag {a} and {b}. 479 // Untag {a} and {b}.
467 a = SmiToWord32(a); 480 a = SmiToWord32(a);
468 b = SmiToWord32(b); 481 b = SmiToWord32(b);
469 482
470 // Return NaN if {b} is zero. 483 // Return NaN if {b} is zero.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
510 523
511 BIND(&return_minuszero); 524 BIND(&return_minuszero);
512 var_result.Bind(MinusZeroConstant()); 525 var_result.Bind(MinusZeroConstant());
513 Goto(&return_result); 526 Goto(&return_result);
514 527
515 BIND(&return_nan); 528 BIND(&return_nan);
516 var_result.Bind(NanConstant()); 529 var_result.Bind(NanConstant());
517 Goto(&return_result); 530 Goto(&return_result);
518 531
519 BIND(&return_result); 532 BIND(&return_result);
533 CSA_SLOW_ASSERT(this, IsNumber(var_result.value()));
520 return var_result.value(); 534 return var_result.value();
521 } 535 }
522 536
523 Node* CodeStubAssembler::SmiMul(Node* a, Node* b) { 537 Node* CodeStubAssembler::SmiMul(Node* a, Node* b) {
538 CSA_SLOW_ASSERT(this, TaggedIsSmi(a));
539 CSA_SLOW_ASSERT(this, TaggedIsSmi(b));
Igor Sheludko 2017/05/02 10:37:17 Same here.
jgruber 2017/05/03 11:11:51 Done.
524 VARIABLE(var_result, MachineRepresentation::kTagged); 540 VARIABLE(var_result, MachineRepresentation::kTagged);
525 VARIABLE(var_lhs_float64, MachineRepresentation::kFloat64); 541 VARIABLE(var_lhs_float64, MachineRepresentation::kFloat64);
526 VARIABLE(var_rhs_float64, MachineRepresentation::kFloat64); 542 VARIABLE(var_rhs_float64, MachineRepresentation::kFloat64);
527 Label return_result(this, &var_result); 543 Label return_result(this, &var_result);
528 544
529 // Both {a} and {b} are Smis. Convert them to integers and multiply. 545 // Both {a} and {b} are Smis. Convert them to integers and multiply.
530 Node* lhs32 = SmiToWord32(a); 546 Node* lhs32 = SmiToWord32(a);
531 Node* rhs32 = SmiToWord32(b); 547 Node* rhs32 = SmiToWord32(b);
532 Node* pair = Int32MulWithOverflow(lhs32, rhs32); 548 Node* pair = Int32MulWithOverflow(lhs32, rhs32);
533 549
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
571 { 587 {
572 var_lhs_float64.Bind(SmiToFloat64(a)); 588 var_lhs_float64.Bind(SmiToFloat64(a));
573 var_rhs_float64.Bind(SmiToFloat64(b)); 589 var_rhs_float64.Bind(SmiToFloat64(b));
574 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value()); 590 Node* value = Float64Mul(var_lhs_float64.value(), var_rhs_float64.value());
575 Node* result = AllocateHeapNumberWithValue(value); 591 Node* result = AllocateHeapNumberWithValue(value);
576 var_result.Bind(result); 592 var_result.Bind(result);
577 Goto(&return_result); 593 Goto(&return_result);
578 } 594 }
579 595
580 BIND(&return_result); 596 BIND(&return_result);
597 CSA_SLOW_ASSERT(this, IsNumber(var_result.value()));
581 return var_result.value(); 598 return var_result.value();
582 } 599 }
583 600
584 Node* CodeStubAssembler::TrySmiDiv(Node* dividend, Node* divisor, 601 Node* CodeStubAssembler::TrySmiDiv(Node* dividend, Node* divisor,
585 Label* bailout) { 602 Label* bailout) {
603 CSA_SLOW_ASSERT(this, TaggedIsSmi(dividend));
604 CSA_SLOW_ASSERT(this, TaggedIsSmi(divisor));
605
586 // Both {a} and {b} are Smis. Bailout to floating point division if {divisor} 606 // Both {a} and {b} are Smis. Bailout to floating point division if {divisor}
587 // is zero. 607 // is zero.
588 GotoIf(WordEqual(divisor, SmiConstant(0)), bailout); 608 GotoIf(WordEqual(divisor, SmiConstant(0)), bailout);
589 609
590 // Do floating point division if {dividend} is zero and {divisor} is 610 // Do floating point division if {dividend} is zero and {divisor} is
591 // negative. 611 // negative.
592 Label dividend_is_zero(this), dividend_is_not_zero(this); 612 Label dividend_is_zero(this), dividend_is_not_zero(this);
593 Branch(WordEqual(dividend, SmiConstant(0)), &dividend_is_zero, 613 Branch(WordEqual(dividend, SmiConstant(0)), &dividend_is_zero,
594 &dividend_is_not_zero); 614 &dividend_is_not_zero);
595 615
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
653 } 673 }
654 674
655 Node* CodeStubAssembler::WordIsWordAligned(Node* word) { 675 Node* CodeStubAssembler::WordIsWordAligned(Node* word) {
656 return WordEqual(IntPtrConstant(0), 676 return WordEqual(IntPtrConstant(0),
657 WordAnd(word, IntPtrConstant((1 << kPointerSizeLog2) - 1))); 677 WordAnd(word, IntPtrConstant((1 << kPointerSizeLog2) - 1)));
658 } 678 }
659 679
660 void CodeStubAssembler::BranchIfPrototypesHaveNoElements( 680 void CodeStubAssembler::BranchIfPrototypesHaveNoElements(
661 Node* receiver_map, Label* definitely_no_elements, 681 Node* receiver_map, Label* definitely_no_elements,
662 Label* possibly_elements) { 682 Label* possibly_elements) {
683 CSA_SLOW_ASSERT(this, IsMap(receiver_map));
663 VARIABLE(var_map, MachineRepresentation::kTagged, receiver_map); 684 VARIABLE(var_map, MachineRepresentation::kTagged, receiver_map);
664 Label loop_body(this, &var_map); 685 Label loop_body(this, &var_map);
665 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex); 686 Node* empty_elements = LoadRoot(Heap::kEmptyFixedArrayRootIndex);
666 Goto(&loop_body); 687 Goto(&loop_body);
667 688
668 BIND(&loop_body); 689 BIND(&loop_body);
669 { 690 {
670 Node* map = var_map.value(); 691 Node* map = var_map.value();
671 Node* prototype = LoadMapPrototype(map); 692 Node* prototype = LoadMapPrototype(map);
672 GotoIf(WordEqual(prototype, NullConstant()), definitely_no_elements); 693 GotoIf(WordEqual(prototype, NullConstant()), definitely_no_elements);
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 return Load(rep, frame_pointer, IntPtrConstant(offset)); 991 return Load(rep, frame_pointer, IntPtrConstant(offset));
971 } 992 }
972 993
973 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset, 994 Node* CodeStubAssembler::LoadBufferObject(Node* buffer, int offset,
974 MachineType rep) { 995 MachineType rep) {
975 return Load(rep, buffer, IntPtrConstant(offset)); 996 return Load(rep, buffer, IntPtrConstant(offset));
976 } 997 }
977 998
978 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset, 999 Node* CodeStubAssembler::LoadObjectField(Node* object, int offset,
979 MachineType rep) { 1000 MachineType rep) {
1001 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
980 return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag)); 1002 return Load(rep, object, IntPtrConstant(offset - kHeapObjectTag));
981 } 1003 }
982 1004
983 Node* CodeStubAssembler::LoadObjectField(Node* object, Node* offset, 1005 Node* CodeStubAssembler::LoadObjectField(Node* object, Node* offset,
984 MachineType rep) { 1006 MachineType rep) {
1007 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
985 return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag))); 1008 return Load(rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)));
986 } 1009 }
987 1010
988 Node* CodeStubAssembler::LoadAndUntagObjectField(Node* object, int offset) { 1011 Node* CodeStubAssembler::LoadAndUntagObjectField(Node* object, int offset) {
989 if (Is64()) { 1012 if (Is64()) {
990 #if V8_TARGET_LITTLE_ENDIAN 1013 #if V8_TARGET_LITTLE_ENDIAN
991 offset += kPointerSize / 2; 1014 offset += kPointerSize / 2;
992 #endif 1015 #endif
993 return ChangeInt32ToInt64( 1016 return ChangeInt32ToInt64(
994 LoadObjectField(object, offset, MachineType::Int32())); 1017 LoadObjectField(object, offset, MachineType::Int32()));
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1051 return StoreNoWriteBarrier(MachineRepresentation::kWord32, base, 1074 return StoreNoWriteBarrier(MachineRepresentation::kWord32, base,
1052 IntPtrConstant(payload_offset), 1075 IntPtrConstant(payload_offset),
1053 TruncateInt64ToInt32(value)); 1076 TruncateInt64ToInt32(value));
1054 } else { 1077 } else {
1055 return StoreNoWriteBarrier(MachineRepresentation::kTaggedSigned, base, 1078 return StoreNoWriteBarrier(MachineRepresentation::kTaggedSigned, base,
1056 IntPtrConstant(offset), SmiTag(value)); 1079 IntPtrConstant(offset), SmiTag(value));
1057 } 1080 }
1058 } 1081 }
1059 1082
1060 Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) { 1083 Node* CodeStubAssembler::LoadHeapNumberValue(Node* object) {
1084 CSA_SLOW_ASSERT(this, IsHeapNumber(object));
1061 return LoadObjectField(object, HeapNumber::kValueOffset, 1085 return LoadObjectField(object, HeapNumber::kValueOffset,
1062 MachineType::Float64()); 1086 MachineType::Float64());
1063 } 1087 }
1064 1088
1065 Node* CodeStubAssembler::LoadMap(Node* object) { 1089 Node* CodeStubAssembler::LoadMap(Node* object) {
1090 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1066 return LoadObjectField(object, HeapObject::kMapOffset); 1091 return LoadObjectField(object, HeapObject::kMapOffset);
1067 } 1092 }
1068 1093
1069 Node* CodeStubAssembler::LoadInstanceType(Node* object) { 1094 Node* CodeStubAssembler::LoadInstanceType(Node* object) {
1070 return LoadMapInstanceType(LoadMap(object)); 1095 return LoadMapInstanceType(LoadMap(object));
1071 } 1096 }
1072 1097
1073 Node* CodeStubAssembler::HasInstanceType(Node* object, 1098 Node* CodeStubAssembler::HasInstanceType(Node* object,
1074 InstanceType instance_type) { 1099 InstanceType instance_type) {
1075 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type)); 1100 return Word32Equal(LoadInstanceType(object), Int32Constant(instance_type));
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1110 CSA_SLOW_ASSERT(this, IsMap(map)); 1135 CSA_SLOW_ASSERT(this, IsMap(map));
1111 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8()); 1136 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8());
1112 } 1137 }
1113 1138
1114 Node* CodeStubAssembler::LoadMapBitField3(Node* map) { 1139 Node* CodeStubAssembler::LoadMapBitField3(Node* map) {
1115 CSA_SLOW_ASSERT(this, IsMap(map)); 1140 CSA_SLOW_ASSERT(this, IsMap(map));
1116 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32()); 1141 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32());
1117 } 1142 }
1118 1143
1119 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { 1144 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) {
1145 // Cannot assert IsMap(map) here since that would induce a cycle.
Igor Sheludko 2017/05/02 10:37:16 IsMap() should be implemented via comparing map of
jgruber 2017/05/03 11:11:51 Done.
1120 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); 1146 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8());
1121 } 1147 }
1122 1148
1123 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) { 1149 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) {
1124 CSA_SLOW_ASSERT(this, IsMap(map)); 1150 CSA_SLOW_ASSERT(this, IsMap(map));
1125 Node* bit_field2 = LoadMapBitField2(map); 1151 Node* bit_field2 = LoadMapBitField2(map);
1126 return DecodeWord32<Map::ElementsKindBits>(bit_field2); 1152 return DecodeWord32<Map::ElementsKindBits>(bit_field2);
1127 } 1153 }
1128 1154
1129 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { 1155 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1193 result.Bind( 1219 result.Bind(
1194 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset)); 1220 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset));
1195 Goto(&loop); 1221 Goto(&loop);
1196 } 1222 }
1197 BIND(&done); 1223 BIND(&done);
1198 return result.value(); 1224 return result.value();
1199 } 1225 }
1200 1226
1201 Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField( 1227 Node* CodeStubAssembler::LoadSharedFunctionInfoSpecialField(
1202 Node* shared, int offset, ParameterMode mode) { 1228 Node* shared, int offset, ParameterMode mode) {
1229 CSA_SLOW_ASSERT(this, HasInstanceType(shared, SHARED_FUNCTION_INFO_TYPE));
1203 if (Is64()) { 1230 if (Is64()) {
1204 Node* result = LoadObjectField(shared, offset, MachineType::Int32()); 1231 Node* result = LoadObjectField(shared, offset, MachineType::Int32());
1205 if (mode == SMI_PARAMETERS) { 1232 if (mode == SMI_PARAMETERS) {
1206 result = SmiTag(result); 1233 result = SmiTag(result);
1207 } else { 1234 } else {
1208 result = ChangeUint32ToWord(result); 1235 result = ChangeUint32ToWord(result);
1209 } 1236 }
1210 return result; 1237 return result;
1211 } else { 1238 } else {
1212 Node* result = LoadObjectField(shared, offset); 1239 Node* result = LoadObjectField(shared, offset);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1253 Node* value = LoadWeakCellValueUnchecked(weak_cell); 1280 Node* value = LoadWeakCellValueUnchecked(weak_cell);
1254 if (if_cleared != nullptr) { 1281 if (if_cleared != nullptr) {
1255 GotoIf(WordEqual(value, IntPtrConstant(0)), if_cleared); 1282 GotoIf(WordEqual(value, IntPtrConstant(0)), if_cleared);
1256 } 1283 }
1257 return value; 1284 return value;
1258 } 1285 }
1259 1286
1260 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, 1287 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node,
1261 int additional_offset, 1288 int additional_offset,
1262 ParameterMode parameter_mode) { 1289 ParameterMode parameter_mode) {
1290 CSA_SLOW_ASSERT(this, IsFixedArray(object));
1263 int32_t header_size = 1291 int32_t header_size =
1264 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; 1292 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
1265 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, 1293 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS,
1266 parameter_mode, header_size); 1294 parameter_mode, header_size);
1267 return Load(MachineType::AnyTagged(), object, offset); 1295 return Load(MachineType::AnyTagged(), object, offset);
1268 } 1296 }
1269 1297
1270 Node* CodeStubAssembler::LoadFixedTypedArrayElement( 1298 Node* CodeStubAssembler::LoadFixedTypedArrayElement(
1271 Node* data_pointer, Node* index_node, ElementsKind elements_kind, 1299 Node* data_pointer, Node* index_node, ElementsKind elements_kind,
1272 ParameterMode parameter_mode) { 1300 ParameterMode parameter_mode) {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1327 return AllocateHeapNumberWithValue(value); 1355 return AllocateHeapNumberWithValue(value);
1328 default: 1356 default:
1329 UNREACHABLE(); 1357 UNREACHABLE();
1330 return nullptr; 1358 return nullptr;
1331 } 1359 }
1332 } 1360 }
1333 1361
1334 Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement( 1362 Node* CodeStubAssembler::LoadAndUntagToWord32FixedArrayElement(
1335 Node* object, Node* index_node, int additional_offset, 1363 Node* object, Node* index_node, int additional_offset,
1336 ParameterMode parameter_mode) { 1364 ParameterMode parameter_mode) {
1365 CSA_SLOW_ASSERT(this, IsFixedArray(object));
1366 CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode));
1337 int32_t header_size = 1367 int32_t header_size =
1338 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; 1368 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
1339 #if V8_TARGET_LITTLE_ENDIAN 1369 #if V8_TARGET_LITTLE_ENDIAN
1340 if (Is64()) { 1370 if (Is64()) {
1341 header_size += kPointerSize / 2; 1371 header_size += kPointerSize / 2;
1342 } 1372 }
1343 #endif 1373 #endif
1344 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, 1374 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS,
1345 parameter_mode, header_size); 1375 parameter_mode, header_size);
1346 if (Is64()) { 1376 if (Is64()) {
1347 return Load(MachineType::Int32(), object, offset); 1377 return Load(MachineType::Int32(), object, offset);
1348 } else { 1378 } else {
1349 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); 1379 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset));
1350 } 1380 }
1351 } 1381 }
1352 1382
1353 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( 1383 Node* CodeStubAssembler::LoadFixedDoubleArrayElement(
1354 Node* object, Node* index_node, MachineType machine_type, 1384 Node* object, Node* index_node, MachineType machine_type,
1355 int additional_offset, ParameterMode parameter_mode, Label* if_hole) { 1385 int additional_offset, ParameterMode parameter_mode, Label* if_hole) {
1386 CSA_SLOW_ASSERT(this, IsFixedDoubleArray(object));
1387 CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode));
1356 CSA_ASSERT(this, IsFixedDoubleArray(object)); 1388 CSA_ASSERT(this, IsFixedDoubleArray(object));
1357 int32_t header_size = 1389 int32_t header_size =
1358 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; 1390 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag;
1359 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, 1391 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS,
1360 parameter_mode, header_size); 1392 parameter_mode, header_size);
1361 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type); 1393 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type);
1362 } 1394 }
1363 1395
1364 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, 1396 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset,
1365 Label* if_hole, 1397 Label* if_hole,
(...skipping 14 matching lines...) Expand all
1380 } 1412 }
1381 } 1413 }
1382 if (machine_type.IsNone()) { 1414 if (machine_type.IsNone()) {
1383 // This means the actual value is not needed. 1415 // This means the actual value is not needed.
1384 return nullptr; 1416 return nullptr;
1385 } 1417 }
1386 return Load(machine_type, base, offset); 1418 return Load(machine_type, base, offset);
1387 } 1419 }
1388 1420
1389 Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) { 1421 Node* CodeStubAssembler::LoadContextElement(Node* context, int slot_index) {
1422 CSA_SLOW_ASSERT(this, IsFixedArray(context));
Igor Sheludko 2017/05/02 10:37:16 Maybe also add IsContext(). BTW, I saw a CL flyi
jgruber 2017/05/03 11:11:50 I suggest we wait for Camillo's IsContext to land
1390 int offset = Context::SlotOffset(slot_index); 1423 int offset = Context::SlotOffset(slot_index);
1391 return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset)); 1424 return Load(MachineType::AnyTagged(), context, IntPtrConstant(offset));
1392 } 1425 }
1393 1426
1394 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) { 1427 Node* CodeStubAssembler::LoadContextElement(Node* context, Node* slot_index) {
1428 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1395 Node* offset = 1429 Node* offset =
1396 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), 1430 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2),
1397 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); 1431 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag));
1398 return Load(MachineType::AnyTagged(), context, offset); 1432 return Load(MachineType::AnyTagged(), context, offset);
1399 } 1433 }
1400 1434
1401 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index, 1435 Node* CodeStubAssembler::StoreContextElement(Node* context, int slot_index,
1402 Node* value) { 1436 Node* value) {
1437 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1403 int offset = Context::SlotOffset(slot_index); 1438 int offset = Context::SlotOffset(slot_index);
1404 return Store(context, IntPtrConstant(offset), value); 1439 return Store(context, IntPtrConstant(offset), value);
1405 } 1440 }
1406 1441
1407 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index, 1442 Node* CodeStubAssembler::StoreContextElement(Node* context, Node* slot_index,
1408 Node* value) { 1443 Node* value) {
1444 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1409 Node* offset = 1445 Node* offset =
1410 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2), 1446 IntPtrAdd(WordShl(slot_index, kPointerSizeLog2),
1411 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag)); 1447 IntPtrConstant(Context::kHeaderSize - kHeapObjectTag));
1412 return Store(context, offset, value); 1448 return Store(context, offset, value);
1413 } 1449 }
1414 1450
1415 Node* CodeStubAssembler::StoreContextElementNoWriteBarrier(Node* context, 1451 Node* CodeStubAssembler::StoreContextElementNoWriteBarrier(Node* context,
1416 int slot_index, 1452 int slot_index,
1417 Node* value) { 1453 Node* value) {
1454 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1418 int offset = Context::SlotOffset(slot_index); 1455 int offset = Context::SlotOffset(slot_index);
1419 return StoreNoWriteBarrier(MachineRepresentation::kTagged, context, 1456 return StoreNoWriteBarrier(MachineRepresentation::kTagged, context,
1420 IntPtrConstant(offset), value); 1457 IntPtrConstant(offset), value);
1421 } 1458 }
1422 1459
1423 Node* CodeStubAssembler::LoadNativeContext(Node* context) { 1460 Node* CodeStubAssembler::LoadNativeContext(Node* context) {
1461 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1424 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); 1462 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX);
1425 } 1463 }
1426 1464
1427 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, 1465 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind,
1428 Node* native_context) { 1466 Node* native_context) {
1429 CSA_ASSERT(this, IsNativeContext(native_context)); 1467 CSA_ASSERT(this, IsNativeContext(native_context));
1430 return LoadContextElement(native_context, Context::ArrayMapIndex(kind)); 1468 return LoadContextElement(native_context, Context::ArrayMapIndex(kind));
1431 } 1469 }
1432 1470
1433 Node* CodeStubAssembler::LoadJSFunctionPrototype(Node* function, 1471 Node* CodeStubAssembler::LoadJSFunctionPrototype(Node* function,
(...skipping 11 matching lines...) Expand all
1445 GotoIfNot(IsMap(proto_or_map), &done); 1483 GotoIfNot(IsMap(proto_or_map), &done);
1446 1484
1447 var_result.Bind(LoadMapPrototype(proto_or_map)); 1485 var_result.Bind(LoadMapPrototype(proto_or_map));
1448 Goto(&done); 1486 Goto(&done);
1449 1487
1450 BIND(&done); 1488 BIND(&done);
1451 return var_result.value(); 1489 return var_result.value();
1452 } 1490 }
1453 1491
1454 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { 1492 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) {
1493 CSA_SLOW_ASSERT(this, IsHeapNumber(object));
1455 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, 1494 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value,
1456 MachineRepresentation::kFloat64); 1495 MachineRepresentation::kFloat64);
1457 } 1496 }
1458 1497
1459 Node* CodeStubAssembler::StoreObjectField( 1498 Node* CodeStubAssembler::StoreObjectField(
1460 Node* object, int offset, Node* value) { 1499 Node* object, int offset, Node* value) {
1500 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1461 DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead. 1501 DCHECK_NE(HeapObject::kMapOffset, offset); // Use StoreMap instead.
1462 return Store(object, IntPtrConstant(offset - kHeapObjectTag), value); 1502 return Store(object, IntPtrConstant(offset - kHeapObjectTag), value);
1463 } 1503 }
1464 1504
1465 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset, 1505 Node* CodeStubAssembler::StoreObjectField(Node* object, Node* offset,
1466 Node* value) { 1506 Node* value) {
1507 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1467 int const_offset; 1508 int const_offset;
1468 if (ToInt32Constant(offset, const_offset)) { 1509 if (ToInt32Constant(offset, const_offset)) {
1469 return StoreObjectField(object, const_offset, value); 1510 return StoreObjectField(object, const_offset, value);
1470 } 1511 }
1471 return Store(object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), 1512 return Store(object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)),
1472 value); 1513 value);
1473 } 1514 }
1474 1515
1475 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( 1516 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier(
1476 Node* object, int offset, Node* value, MachineRepresentation rep) { 1517 Node* object, int offset, Node* value, MachineRepresentation rep) {
1518 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1477 return StoreNoWriteBarrier(rep, object, 1519 return StoreNoWriteBarrier(rep, object,
1478 IntPtrConstant(offset - kHeapObjectTag), value); 1520 IntPtrConstant(offset - kHeapObjectTag), value);
1479 } 1521 }
1480 1522
1481 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier( 1523 Node* CodeStubAssembler::StoreObjectFieldNoWriteBarrier(
1482 Node* object, Node* offset, Node* value, MachineRepresentation rep) { 1524 Node* object, Node* offset, Node* value, MachineRepresentation rep) {
1525 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1483 int const_offset; 1526 int const_offset;
1484 if (ToInt32Constant(offset, const_offset)) { 1527 if (ToInt32Constant(offset, const_offset)) {
1485 return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep); 1528 return StoreObjectFieldNoWriteBarrier(object, const_offset, value, rep);
1486 } 1529 }
1487 return StoreNoWriteBarrier( 1530 return StoreNoWriteBarrier(
1488 rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value); 1531 rep, object, IntPtrSub(offset, IntPtrConstant(kHeapObjectTag)), value);
1489 } 1532 }
1490 1533
1491 Node* CodeStubAssembler::StoreMap(Node* object, Node* map) { 1534 Node* CodeStubAssembler::StoreMap(Node* object, Node* map) {
1535 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1492 CSA_SLOW_ASSERT(this, IsMap(map)); 1536 CSA_SLOW_ASSERT(this, IsMap(map));
1493 return StoreWithMapWriteBarrier( 1537 return StoreWithMapWriteBarrier(
1494 object, IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); 1538 object, IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map);
1495 } 1539 }
1496 1540
1497 Node* CodeStubAssembler::StoreMapNoWriteBarrier( 1541 Node* CodeStubAssembler::StoreMapNoWriteBarrier(
1498 Node* object, Heap::RootListIndex map_root_index) { 1542 Node* object, Heap::RootListIndex map_root_index) {
1499 return StoreMapNoWriteBarrier(object, LoadRoot(map_root_index)); 1543 return StoreMapNoWriteBarrier(object, LoadRoot(map_root_index));
1500 } 1544 }
1501 1545
1502 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) { 1546 Node* CodeStubAssembler::StoreMapNoWriteBarrier(Node* object, Node* map) {
1547 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
1503 CSA_SLOW_ASSERT(this, IsMap(map)); 1548 CSA_SLOW_ASSERT(this, IsMap(map));
1504 return StoreNoWriteBarrier( 1549 return StoreNoWriteBarrier(
1505 MachineRepresentation::kTagged, object, 1550 MachineRepresentation::kTagged, object,
1506 IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map); 1551 IntPtrConstant(HeapObject::kMapOffset - kHeapObjectTag), map);
1507 } 1552 }
1508 1553
1509 Node* CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset, 1554 Node* CodeStubAssembler::StoreObjectFieldRoot(Node* object, int offset,
1510 Heap::RootListIndex root_index) { 1555 Heap::RootListIndex root_index) {
1511 if (Heap::RootIsImmortalImmovable(root_index)) { 1556 if (Heap::RootIsImmortalImmovable(root_index)) {
1512 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index)); 1557 return StoreObjectFieldNoWriteBarrier(object, offset, LoadRoot(root_index));
1513 } else { 1558 } else {
1514 return StoreObjectField(object, offset, LoadRoot(root_index)); 1559 return StoreObjectField(object, offset, LoadRoot(root_index));
1515 } 1560 }
1516 } 1561 }
1517 1562
1518 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node, 1563 Node* CodeStubAssembler::StoreFixedArrayElement(Node* object, Node* index_node,
1519 Node* value, 1564 Node* value,
1520 WriteBarrierMode barrier_mode, 1565 WriteBarrierMode barrier_mode,
1521 int additional_offset, 1566 int additional_offset,
1522 ParameterMode parameter_mode) { 1567 ParameterMode parameter_mode) {
1568 CSA_SLOW_ASSERT(this, IsFixedArray(object));
1569 CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode));
1523 DCHECK(barrier_mode == SKIP_WRITE_BARRIER || 1570 DCHECK(barrier_mode == SKIP_WRITE_BARRIER ||
1524 barrier_mode == UPDATE_WRITE_BARRIER); 1571 barrier_mode == UPDATE_WRITE_BARRIER);
1525 int header_size = 1572 int header_size =
1526 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag; 1573 FixedArray::kHeaderSize + additional_offset - kHeapObjectTag;
1527 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS, 1574 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_ELEMENTS,
1528 parameter_mode, header_size); 1575 parameter_mode, header_size);
1529 if (barrier_mode == SKIP_WRITE_BARRIER) { 1576 if (barrier_mode == SKIP_WRITE_BARRIER) {
1530 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset, 1577 return StoreNoWriteBarrier(MachineRepresentation::kTagged, object, offset,
1531 value); 1578 value);
1532 } else { 1579 } else {
1533 return Store(object, offset, value); 1580 return Store(object, offset, value);
1534 } 1581 }
1535 } 1582 }
1536 1583
1537 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( 1584 Node* CodeStubAssembler::StoreFixedDoubleArrayElement(
1538 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { 1585 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) {
1539 CSA_ASSERT(this, IsFixedDoubleArray(object)); 1586 CSA_ASSERT(this, IsFixedDoubleArray(object));
1587 CSA_SLOW_ASSERT(this, IsParameterMode(index_node, parameter_mode));
1540 Node* offset = 1588 Node* offset =
1541 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, 1589 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode,
1542 FixedArray::kHeaderSize - kHeapObjectTag); 1590 FixedArray::kHeaderSize - kHeapObjectTag);
1543 MachineRepresentation rep = MachineRepresentation::kFloat64; 1591 MachineRepresentation rep = MachineRepresentation::kFloat64;
1544 return StoreNoWriteBarrier(rep, object, offset, value); 1592 return StoreNoWriteBarrier(rep, object, offset, value);
1545 } 1593 }
1546 1594
1547 Node* CodeStubAssembler::EnsureArrayPushable(Node* receiver, Label* bailout) { 1595 Node* CodeStubAssembler::EnsureArrayPushable(Node* receiver, Label* bailout) {
1548 // Disallow pushing onto prototypes. It might be the JSArray prototype. 1596 // Disallow pushing onto prototypes. It might be the JSArray prototype.
1549 // Disallow pushing onto non-extensible objects. 1597 // Disallow pushing onto non-extensible objects.
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1587 kind, capacity, new_capacity, mode, 1635 kind, capacity, new_capacity, mode,
1588 bailout)); 1636 bailout));
1589 Goto(&fits); 1637 Goto(&fits);
1590 BIND(&fits); 1638 BIND(&fits);
1591 } 1639 }
1592 1640
1593 Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, 1641 Node* CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array,
1594 CodeStubArguments& args, 1642 CodeStubArguments& args,
1595 Variable& arg_index, 1643 Variable& arg_index,
1596 Label* bailout) { 1644 Label* bailout) {
1645 CSA_SLOW_ASSERT(this, IsJSArray(array));
1597 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); 1646 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind));
1598 Label pre_bailout(this); 1647 Label pre_bailout(this);
1599 Label success(this); 1648 Label success(this);
1600 VARIABLE(var_tagged_length, MachineRepresentation::kTagged); 1649 VARIABLE(var_tagged_length, MachineRepresentation::kTagged);
1601 ParameterMode mode = OptimalParameterMode(); 1650 ParameterMode mode = OptimalParameterMode();
1602 VARIABLE(var_length, OptimalParameterRepresentation(), 1651 VARIABLE(var_length, OptimalParameterRepresentation(),
1603 TaggedToParameter(LoadJSArrayLength(array), mode)); 1652 TaggedToParameter(LoadJSArrayLength(array), mode));
1604 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); 1653 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array));
1605 1654
1606 // Resize the capacity of the fixed array if it doesn't fit. 1655 // Resize the capacity of the fixed array if it doesn't fit.
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 Float64SilenceNaN(double_value), mode); 1706 Float64SilenceNaN(double_value), mode);
1658 } else { 1707 } else {
1659 WriteBarrierMode barrier_mode = 1708 WriteBarrierMode barrier_mode =
1660 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER; 1709 IsFastSmiElementsKind(kind) ? SKIP_WRITE_BARRIER : UPDATE_WRITE_BARRIER;
1661 StoreFixedArrayElement(elements, index, value, barrier_mode, 0, mode); 1710 StoreFixedArrayElement(elements, index, value, barrier_mode, 0, mode);
1662 } 1711 }
1663 } 1712 }
1664 1713
1665 void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array, 1714 void CodeStubAssembler::BuildAppendJSArray(ElementsKind kind, Node* array,
1666 Node* value, Label* bailout) { 1715 Node* value, Label* bailout) {
1716 CSA_SLOW_ASSERT(this, IsJSArray(array));
1667 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind)); 1717 Comment("BuildAppendJSArray: %s", ElementsKindToString(kind));
1668 ParameterMode mode = OptimalParameterMode(); 1718 ParameterMode mode = OptimalParameterMode();
1669 VARIABLE(var_length, OptimalParameterRepresentation(), 1719 VARIABLE(var_length, OptimalParameterRepresentation(),
1670 TaggedToParameter(LoadJSArrayLength(array), mode)); 1720 TaggedToParameter(LoadJSArrayLength(array), mode));
1671 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array)); 1721 VARIABLE(var_elements, MachineRepresentation::kTagged, LoadElements(array));
1672 1722
1673 // Resize the capacity of the fixed array if it doesn't fit. 1723 // Resize the capacity of the fixed array if it doesn't fit.
1674 Node* growth = IntPtrOrSmiConstant(1, mode); 1724 Node* growth = IntPtrOrSmiConstant(1, mode);
1675 PossiblyGrowElementsCapacity(mode, kind, array, var_length.value(), 1725 PossiblyGrowElementsCapacity(mode, kind, array, var_length.value(),
1676 &var_elements, growth, bailout); 1726 &var_elements, growth, bailout);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1716 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot, 1766 StoreObjectFieldNoWriteBarrier(result, SeqOneByteString::kHashFieldSlot,
1717 IntPtrConstant(String::kEmptyHashField), 1767 IntPtrConstant(String::kEmptyHashField),
1718 MachineType::PointerRepresentation()); 1768 MachineType::PointerRepresentation());
1719 return result; 1769 return result;
1720 } 1770 }
1721 1771
1722 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length, 1772 Node* CodeStubAssembler::AllocateSeqOneByteString(Node* context, Node* length,
1723 ParameterMode mode, 1773 ParameterMode mode,
1724 AllocationFlags flags) { 1774 AllocationFlags flags) {
1725 Comment("AllocateSeqOneByteString"); 1775 Comment("AllocateSeqOneByteString");
1776 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1777 CSA_SLOW_ASSERT(this, IsParameterMode(length, mode));
1726 VARIABLE(var_result, MachineRepresentation::kTagged); 1778 VARIABLE(var_result, MachineRepresentation::kTagged);
1727 1779
1728 // Compute the SeqOneByteString size and check if it fits into new space. 1780 // Compute the SeqOneByteString size and check if it fits into new space.
1729 Label if_lengthiszero(this), if_sizeissmall(this), 1781 Label if_lengthiszero(this), if_sizeissmall(this),
1730 if_notsizeissmall(this, Label::kDeferred), if_join(this); 1782 if_notsizeissmall(this, Label::kDeferred), if_join(this);
1731 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); 1783 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero);
1732 1784
1733 Node* raw_size = GetArrayAllocationSize( 1785 Node* raw_size = GetArrayAllocationSize(
1734 length, UINT8_ELEMENTS, mode, 1786 length, UINT8_ELEMENTS, mode,
1735 SeqOneByteString::kHeaderSize + kObjectAlignmentMask); 1787 SeqOneByteString::kHeaderSize + kObjectAlignmentMask);
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
1786 // Initialize both used and unused parts of hash field slot at once. 1838 // Initialize both used and unused parts of hash field slot at once.
1787 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot, 1839 StoreObjectFieldNoWriteBarrier(result, SeqTwoByteString::kHashFieldSlot,
1788 IntPtrConstant(String::kEmptyHashField), 1840 IntPtrConstant(String::kEmptyHashField),
1789 MachineType::PointerRepresentation()); 1841 MachineType::PointerRepresentation());
1790 return result; 1842 return result;
1791 } 1843 }
1792 1844
1793 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length, 1845 Node* CodeStubAssembler::AllocateSeqTwoByteString(Node* context, Node* length,
1794 ParameterMode mode, 1846 ParameterMode mode,
1795 AllocationFlags flags) { 1847 AllocationFlags flags) {
1848 CSA_SLOW_ASSERT(this, IsFixedArray(context));
1849 CSA_SLOW_ASSERT(this, IsParameterMode(length, mode));
1796 Comment("AllocateSeqTwoByteString"); 1850 Comment("AllocateSeqTwoByteString");
1797 VARIABLE(var_result, MachineRepresentation::kTagged); 1851 VARIABLE(var_result, MachineRepresentation::kTagged);
1798 1852
1799 // Compute the SeqTwoByteString size and check if it fits into new space. 1853 // Compute the SeqTwoByteString size and check if it fits into new space.
1800 Label if_lengthiszero(this), if_sizeissmall(this), 1854 Label if_lengthiszero(this), if_sizeissmall(this),
1801 if_notsizeissmall(this, Label::kDeferred), if_join(this); 1855 if_notsizeissmall(this, Label::kDeferred), if_join(this);
1802 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero); 1856 GotoIf(WordEqual(length, IntPtrOrSmiConstant(0, mode)), &if_lengthiszero);
1803 1857
1804 Node* raw_size = GetArrayAllocationSize( 1858 Node* raw_size = GetArrayAllocationSize(
1805 length, UINT16_ELEMENTS, mode, 1859 length, UINT16_ELEMENTS, mode,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 Goto(&if_join); 1895 Goto(&if_join);
1842 } 1896 }
1843 1897
1844 BIND(&if_join); 1898 BIND(&if_join);
1845 return var_result.value(); 1899 return var_result.value();
1846 } 1900 }
1847 1901
1848 Node* CodeStubAssembler::AllocateSlicedString( 1902 Node* CodeStubAssembler::AllocateSlicedString(
1849 Heap::RootListIndex map_root_index, Node* length, Node* parent, 1903 Heap::RootListIndex map_root_index, Node* length, Node* parent,
1850 Node* offset) { 1904 Node* offset) {
1905 CSA_ASSERT(this, IsString(parent));
1851 CSA_ASSERT(this, TaggedIsSmi(length)); 1906 CSA_ASSERT(this, TaggedIsSmi(length));
1907 CSA_ASSERT(this, TaggedIsSmi(offset));
1852 Node* result = Allocate(SlicedString::kSize); 1908 Node* result = Allocate(SlicedString::kSize);
1853 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); 1909 DCHECK(Heap::RootIsImmortalImmovable(map_root_index));
1854 StoreMapNoWriteBarrier(result, map_root_index); 1910 StoreMapNoWriteBarrier(result, map_root_index);
1855 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, 1911 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length,
1856 MachineRepresentation::kTagged); 1912 MachineRepresentation::kTagged);
1857 // Initialize both used and unused parts of hash field slot at once. 1913 // Initialize both used and unused parts of hash field slot at once.
1858 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldSlot, 1914 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldSlot,
1859 IntPtrConstant(String::kEmptyHashField), 1915 IntPtrConstant(String::kEmptyHashField),
1860 MachineType::PointerRepresentation()); 1916 MachineType::PointerRepresentation());
1861 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, 1917 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent,
(...skipping 12 matching lines...) Expand all
1874 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent, 1930 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent,
1875 Node* offset) { 1931 Node* offset) {
1876 return AllocateSlicedString(Heap::kSlicedStringMapRootIndex, length, parent, 1932 return AllocateSlicedString(Heap::kSlicedStringMapRootIndex, length, parent,
1877 offset); 1933 offset);
1878 } 1934 }
1879 1935
1880 Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index, 1936 Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index,
1881 Node* length, Node* first, 1937 Node* length, Node* first,
1882 Node* second, 1938 Node* second,
1883 AllocationFlags flags) { 1939 AllocationFlags flags) {
1940 CSA_ASSERT(this, IsString(first));
1941 CSA_ASSERT(this, IsString(second));
1884 CSA_ASSERT(this, TaggedIsSmi(length)); 1942 CSA_ASSERT(this, TaggedIsSmi(length));
1885 Node* result = Allocate(ConsString::kSize, flags); 1943 Node* result = Allocate(ConsString::kSize, flags);
1886 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); 1944 DCHECK(Heap::RootIsImmortalImmovable(map_root_index));
1887 StoreMapNoWriteBarrier(result, map_root_index); 1945 StoreMapNoWriteBarrier(result, map_root_index);
1888 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, 1946 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length,
1889 MachineRepresentation::kTagged); 1947 MachineRepresentation::kTagged);
1890 // Initialize both used and unused parts of hash field slot at once. 1948 // Initialize both used and unused parts of hash field slot at once.
1891 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldSlot, 1949 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldSlot,
1892 IntPtrConstant(String::kEmptyHashField), 1950 IntPtrConstant(String::kEmptyHashField),
1893 MachineType::PointerRepresentation()); 1951 MachineType::PointerRepresentation());
(...skipping 19 matching lines...) Expand all
1913 1971
1914 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, 1972 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first,
1915 Node* second, 1973 Node* second,
1916 AllocationFlags flags) { 1974 AllocationFlags flags) {
1917 return AllocateConsString(Heap::kConsStringMapRootIndex, length, first, 1975 return AllocateConsString(Heap::kConsStringMapRootIndex, length, first,
1918 second, flags); 1976 second, flags);
1919 } 1977 }
1920 1978
1921 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, 1979 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left,
1922 Node* right, AllocationFlags flags) { 1980 Node* right, AllocationFlags flags) {
1981 CSA_ASSERT(this, IsFixedArray(context));
1982 CSA_ASSERT(this, IsString(left));
1983 CSA_ASSERT(this, IsString(right));
1923 CSA_ASSERT(this, TaggedIsSmi(length)); 1984 CSA_ASSERT(this, TaggedIsSmi(length));
1924 // Added string can be a cons string. 1985 // Added string can be a cons string.
1925 Comment("Allocating ConsString"); 1986 Comment("Allocating ConsString");
1926 Node* left_instance_type = LoadInstanceType(left); 1987 Node* left_instance_type = LoadInstanceType(left);
1927 Node* right_instance_type = LoadInstanceType(right); 1988 Node* right_instance_type = LoadInstanceType(right);
1928 1989
1929 // Compute intersection and difference of instance types. 1990 // Compute intersection and difference of instance types.
1930 Node* anded_instance_types = 1991 Node* anded_instance_types =
1931 Word32And(left_instance_type, right_instance_type); 1992 Word32And(left_instance_type, right_instance_type);
1932 Node* xored_instance_types = 1993 Node* xored_instance_types =
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
1968 result.Bind(AllocateTwoByteConsString(length, left, right, flags)); 2029 result.Bind(AllocateTwoByteConsString(length, left, right, flags));
1969 Goto(&done); 2030 Goto(&done);
1970 2031
1971 BIND(&done); 2032 BIND(&done);
1972 2033
1973 return result.value(); 2034 return result.value();
1974 } 2035 }
1975 2036
1976 Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length, 2037 Node* CodeStubAssembler::AllocateRegExpResult(Node* context, Node* length,
1977 Node* index, Node* input) { 2038 Node* index, Node* input) {
2039 CSA_ASSERT(this, IsFixedArray(context));
2040 CSA_ASSERT(this, TaggedIsSmi(index));
2041 CSA_ASSERT(this, TaggedIsSmi(length));
2042 CSA_ASSERT(this, IsString(input));
2043
2044 #ifdef DEBUG
1978 Node* const max_length = 2045 Node* const max_length =
1979 SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray)); 2046 SmiConstant(Smi::FromInt(JSArray::kInitialMaxFastElementArray));
1980 CSA_ASSERT(this, SmiLessThanOrEqual(length, max_length)); 2047 CSA_ASSERT(this, SmiLessThanOrEqual(length, max_length));
1981 USE(max_length); 2048 #endif // DEBUG
1982 2049
1983 // Allocate the JSRegExpResult. 2050 // Allocate the JSRegExpResult.
1984 // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove 2051 // TODO(jgruber): Fold JSArray and FixedArray allocations, then remove
1985 // unneeded store of elements. 2052 // unneeded store of elements.
1986 Node* const result = Allocate(JSRegExpResult::kSize); 2053 Node* const result = Allocate(JSRegExpResult::kSize);
1987 2054
1988 // TODO(jgruber): Store map as Heap constant? 2055 // TODO(jgruber): Store map as Heap constant?
1989 Node* const native_context = LoadNativeContext(context); 2056 Node* const native_context = LoadNativeContext(context);
1990 Node* const map = 2057 Node* const map =
1991 LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX); 2058 LoadContextElement(native_context, Context::REGEXP_RESULT_MAP_INDEX);
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2064 kHeapObjectTag)); 2131 kHeapObjectTag));
2065 Node* end_address = IntPtrAdd( 2132 Node* end_address = IntPtrAdd(
2066 result_word, IntPtrSub(store_size, IntPtrConstant(kHeapObjectTag))); 2133 result_word, IntPtrSub(store_size, IntPtrConstant(kHeapObjectTag)));
2067 StoreFieldsNoWriteBarrier(start_address, end_address, filler); 2134 StoreFieldsNoWriteBarrier(start_address, end_address, filler);
2068 return result; 2135 return result;
2069 } 2136 }
2070 2137
2071 Node* CodeStubAssembler::CopyNameDictionary(Node* dictionary, 2138 Node* CodeStubAssembler::CopyNameDictionary(Node* dictionary,
2072 Label* large_object_fallback) { 2139 Label* large_object_fallback) {
2073 Comment("Copy boilerplate property dict"); 2140 Comment("Copy boilerplate property dict");
2141 CSA_SLOW_ASSERT(this, IsFixedArray(dictionary));
Igor Sheludko 2017/05/02 10:37:17 CSA::IsDictionary(dictionary)
jgruber 2017/05/03 11:11:50 Done.
2074 Label done(this); 2142 Label done(this);
2075 Node* length = SmiUntag(LoadFixedArrayBaseLength(dictionary)); 2143 Node* length = SmiUntag(LoadFixedArrayBaseLength(dictionary));
2076 GotoIf( 2144 GotoIf(
2077 IntPtrGreaterThan(length, IntPtrConstant(FixedArray::kMaxRegularLength)), 2145 IntPtrGreaterThan(length, IntPtrConstant(FixedArray::kMaxRegularLength)),
2078 large_object_fallback); 2146 large_object_fallback);
2079 Node* properties = 2147 Node* properties =
2080 AllocateNameDictionary(SmiUntag(GetCapacity<NameDictionary>(dictionary))); 2148 AllocateNameDictionary(SmiUntag(GetCapacity<NameDictionary>(dictionary)));
2081 CopyFixedArrayElements(FAST_ELEMENTS, dictionary, properties, length, 2149 CopyFixedArrayElements(FAST_ELEMENTS, dictionary, properties, length,
2082 SKIP_WRITE_BARRIER, INTPTR_PARAMETERS); 2150 SKIP_WRITE_BARRIER, INTPTR_PARAMETERS);
2083 return properties; 2151 return properties;
2084 } 2152 }
2085 2153
2086 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, 2154 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties,
2087 Node* elements, 2155 Node* elements,
2088 AllocationFlags flags) { 2156 AllocationFlags flags) {
2089 CSA_ASSERT(this, IsMap(map)); 2157 CSA_ASSERT(this, IsMap(map));
2090 Node* size = 2158 Node* size =
2091 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); 2159 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize));
2092 Node* object = AllocateInNewSpace(size, flags); 2160 Node* object = AllocateInNewSpace(size, flags);
2093 StoreMapNoWriteBarrier(object, map); 2161 StoreMapNoWriteBarrier(object, map);
2094 InitializeJSObjectFromMap(object, map, size, properties, elements); 2162 InitializeJSObjectFromMap(object, map, size, properties, elements);
2095 return object; 2163 return object;
2096 } 2164 }
2097 2165
2098 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, 2166 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map,
2099 Node* size, Node* properties, 2167 Node* size, Node* properties,
2100 Node* elements) { 2168 Node* elements) {
2169 CSA_SLOW_ASSERT(this, IsMap(map));
2101 // This helper assumes that the object is in new-space, as guarded by the 2170 // This helper assumes that the object is in new-space, as guarded by the
2102 // check in AllocatedJSObjectFromMap. 2171 // check in AllocatedJSObjectFromMap.
2103 if (properties == nullptr) { 2172 if (properties == nullptr) {
2104 CSA_ASSERT(this, Word32BinaryNot(IsDictionaryMap((map)))); 2173 CSA_ASSERT(this, Word32BinaryNot(IsDictionaryMap((map))));
2105 StoreObjectFieldRoot(object, JSObject::kPropertiesOffset, 2174 StoreObjectFieldRoot(object, JSObject::kPropertiesOffset,
2106 Heap::kEmptyFixedArrayRootIndex); 2175 Heap::kEmptyFixedArrayRootIndex);
2107 } else { 2176 } else {
2177 CSA_ASSERT(this, IsFixedArray(properties));
2108 StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOffset, 2178 StoreObjectFieldNoWriteBarrier(object, JSObject::kPropertiesOffset,
2109 properties); 2179 properties);
2110 } 2180 }
2111 if (elements == nullptr) { 2181 if (elements == nullptr) {
2112 StoreObjectFieldRoot(object, JSObject::kElementsOffset, 2182 StoreObjectFieldRoot(object, JSObject::kElementsOffset,
2113 Heap::kEmptyFixedArrayRootIndex); 2183 Heap::kEmptyFixedArrayRootIndex);
2114 } else { 2184 } else {
2185 CSA_ASSERT(this, IsFixedArray(elements));
2115 StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements); 2186 StoreObjectFieldNoWriteBarrier(object, JSObject::kElementsOffset, elements);
2116 } 2187 }
2117 InitializeJSObjectBody(object, map, size, JSObject::kHeaderSize); 2188 InitializeJSObjectBody(object, map, size, JSObject::kHeaderSize);
2118 } 2189 }
2119 2190
2120 void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map, 2191 void CodeStubAssembler::InitializeJSObjectBody(Node* object, Node* map,
2121 Node* size, int start_offset) { 2192 Node* size, int start_offset) {
2193 CSA_SLOW_ASSERT(this, IsMap(map));
2122 // TODO(cbruni): activate in-object slack tracking machinery. 2194 // TODO(cbruni): activate in-object slack tracking machinery.
2123 Comment("InitializeJSObjectBody"); 2195 Comment("InitializeJSObjectBody");
2124 Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex); 2196 Node* filler = LoadRoot(Heap::kUndefinedValueRootIndex);
2125 // Calculate the untagged field addresses. 2197 // Calculate the untagged field addresses.
2126 object = BitcastTaggedToWord(object); 2198 object = BitcastTaggedToWord(object);
2127 Node* start_address = 2199 Node* start_address =
2128 IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag)); 2200 IntPtrAdd(object, IntPtrConstant(start_offset - kHeapObjectTag));
2129 Node* end_address = 2201 Node* end_address =
2130 IntPtrSub(IntPtrAdd(object, size), IntPtrConstant(kHeapObjectTag)); 2202 IntPtrSub(IntPtrAdd(object, size), IntPtrConstant(kHeapObjectTag));
2131 StoreFieldsNoWriteBarrier(start_address, end_address, filler); 2203 StoreFieldsNoWriteBarrier(start_address, end_address, filler);
2132 } 2204 }
2133 2205
2134 void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address, 2206 void CodeStubAssembler::StoreFieldsNoWriteBarrier(Node* start_address,
2135 Node* end_address, 2207 Node* end_address,
2136 Node* value) { 2208 Node* value) {
2137 Comment("StoreFieldsNoWriteBarrier"); 2209 Comment("StoreFieldsNoWriteBarrier");
2138 CSA_ASSERT(this, WordIsWordAligned(start_address)); 2210 CSA_ASSERT(this, WordIsWordAligned(start_address));
2139 CSA_ASSERT(this, WordIsWordAligned(end_address)); 2211 CSA_ASSERT(this, WordIsWordAligned(end_address));
2140 BuildFastLoop(start_address, end_address, 2212 BuildFastLoop(start_address, end_address,
2141 [this, value](Node* current) { 2213 [this, value](Node* current) {
2142 StoreNoWriteBarrier(MachineRepresentation::kTagged, current, 2214 StoreNoWriteBarrier(MachineRepresentation::kTagged, current,
2143 value); 2215 value);
2144 }, 2216 },
2145 kPointerSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); 2217 kPointerSize, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
2146 } 2218 }
2147 2219
2148 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements( 2220 Node* CodeStubAssembler::AllocateUninitializedJSArrayWithoutElements(
2149 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) { 2221 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site) {
2150 Comment("begin allocation of JSArray without elements"); 2222 Comment("begin allocation of JSArray without elements");
2223 CSA_SLOW_ASSERT(this, TaggedIsSmi(length));
2224 CSA_SLOW_ASSERT(this, IsMap(array_map));
2151 int base_size = JSArray::kSize; 2225 int base_size = JSArray::kSize;
2152 if (allocation_site != nullptr) { 2226 if (allocation_site != nullptr) {
2153 base_size += AllocationMemento::kSize; 2227 base_size += AllocationMemento::kSize;
2154 } 2228 }
2155 2229
2156 Node* size = IntPtrConstant(base_size); 2230 Node* size = IntPtrConstant(base_size);
2157 Node* array = AllocateUninitializedJSArray(kind, array_map, length, 2231 Node* array = AllocateUninitializedJSArray(kind, array_map, length,
2158 allocation_site, size); 2232 allocation_site, size);
2159 return array; 2233 return array;
2160 } 2234 }
2161 2235
2162 std::pair<Node*, Node*> 2236 std::pair<Node*, Node*>
2163 CodeStubAssembler::AllocateUninitializedJSArrayWithElements( 2237 CodeStubAssembler::AllocateUninitializedJSArrayWithElements(
2164 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site, 2238 ElementsKind kind, Node* array_map, Node* length, Node* allocation_site,
2165 Node* capacity, ParameterMode capacity_mode) { 2239 Node* capacity, ParameterMode capacity_mode) {
2166 Comment("begin allocation of JSArray with elements"); 2240 Comment("begin allocation of JSArray with elements");
2241 CSA_SLOW_ASSERT(this, TaggedIsSmi(length));
2242 CSA_SLOW_ASSERT(this, IsMap(array_map));
2167 int base_size = JSArray::kSize; 2243 int base_size = JSArray::kSize;
2168 2244
2169 if (allocation_site != nullptr) { 2245 if (allocation_site != nullptr) {
2170 base_size += AllocationMemento::kSize; 2246 base_size += AllocationMemento::kSize;
2171 } 2247 }
2172 2248
2173 int elements_offset = base_size; 2249 int elements_offset = base_size;
2174 2250
2175 // Compute space for elements 2251 // Compute space for elements
2176 base_size += FixedArray::kHeaderSize; 2252 base_size += FixedArray::kHeaderSize;
2177 Node* size = ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size); 2253 Node* size = ElementOffsetFromIndex(capacity, kind, capacity_mode, base_size);
2178 2254
2179 Node* array = AllocateUninitializedJSArray(kind, array_map, length, 2255 Node* array = AllocateUninitializedJSArray(kind, array_map, length,
2180 allocation_site, size); 2256 allocation_site, size);
2181 2257
2182 Node* elements = InnerAllocate(array, elements_offset); 2258 Node* elements = InnerAllocate(array, elements_offset);
2183 StoreObjectFieldNoWriteBarrier(array, JSObject::kElementsOffset, elements); 2259 StoreObjectFieldNoWriteBarrier(array, JSObject::kElementsOffset, elements);
2184 2260
2185 return {array, elements}; 2261 return {array, elements};
2186 } 2262 }
2187 2263
2188 Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind, 2264 Node* CodeStubAssembler::AllocateUninitializedJSArray(ElementsKind kind,
2189 Node* array_map, 2265 Node* array_map,
2190 Node* length, 2266 Node* length,
2191 Node* allocation_site, 2267 Node* allocation_site,
2192 Node* size_in_bytes) { 2268 Node* size_in_bytes) {
2269 CSA_SLOW_ASSERT(this, TaggedIsSmi(length));
2270 CSA_SLOW_ASSERT(this, IsMap(array_map));
2271
2193 // Allocate space for the JSArray and the elements FixedArray in one go. 2272 // Allocate space for the JSArray and the elements FixedArray in one go.
2194 Node* array = AllocateInNewSpace(size_in_bytes); 2273 Node* array = AllocateInNewSpace(size_in_bytes);
2195 2274
2196 Comment("write JSArray headers"); 2275 Comment("write JSArray headers");
2197 StoreMapNoWriteBarrier(array, array_map); 2276 StoreMapNoWriteBarrier(array, array_map);
2198 2277
2199 CSA_ASSERT(this, TaggedIsSmi(length)); 2278 CSA_ASSERT(this, TaggedIsSmi(length));
Igor Sheludko 2017/05/02 10:37:17 Already exists. "Only one can remain" (c).
jgruber 2017/05/03 11:11:51 Done.
2200 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length); 2279 StoreObjectFieldNoWriteBarrier(array, JSArray::kLengthOffset, length);
2201 2280
2202 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset, 2281 StoreObjectFieldRoot(array, JSArray::kPropertiesOffset,
2203 Heap::kEmptyFixedArrayRootIndex); 2282 Heap::kEmptyFixedArrayRootIndex);
2204 2283
2205 if (allocation_site != nullptr) { 2284 if (allocation_site != nullptr) {
2206 InitializeAllocationMemento(array, JSArray::kSize, allocation_site); 2285 InitializeAllocationMemento(array, JSArray::kSize, allocation_site);
2207 } 2286 }
2208 return array; 2287 return array;
2209 } 2288 }
2210 2289
2211 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map, 2290 Node* CodeStubAssembler::AllocateJSArray(ElementsKind kind, Node* array_map,
2212 Node* capacity, Node* length, 2291 Node* capacity, Node* length,
2213 Node* allocation_site, 2292 Node* allocation_site,
2214 ParameterMode capacity_mode) { 2293 ParameterMode capacity_mode) {
2294 CSA_SLOW_ASSERT(this, TaggedIsSmi(length));
2295 CSA_SLOW_ASSERT(this, IsMap(array_map));
2296 CSA_SLOW_ASSERT(this, IsParameterMode(capacity, capacity_mode));
2297
2215 Node *array = nullptr, *elements = nullptr; 2298 Node *array = nullptr, *elements = nullptr;
2216 if (IsIntPtrOrSmiConstantZero(capacity)) { 2299 if (IsIntPtrOrSmiConstantZero(capacity)) {
2217 // Array is empty. Use the shared empty fixed array instead of allocating a 2300 // Array is empty. Use the shared empty fixed array instead of allocating a
2218 // new one. 2301 // new one.
2219 array = AllocateUninitializedJSArrayWithoutElements(kind, array_map, length, 2302 array = AllocateUninitializedJSArrayWithoutElements(kind, array_map, length,
2220 nullptr); 2303 nullptr);
2221 StoreObjectFieldRoot(array, JSArray::kElementsOffset, 2304 StoreObjectFieldRoot(array, JSArray::kElementsOffset,
2222 Heap::kEmptyFixedArrayRootIndex); 2305 Heap::kEmptyFixedArrayRootIndex);
2223 } else { 2306 } else {
2224 // Allocate both array and elements object, and initialize the JSArray. 2307 // Allocate both array and elements object, and initialize the JSArray.
(...skipping 13 matching lines...) Expand all
2238 Heap::kTheHoleValueRootIndex, capacity_mode); 2321 Heap::kTheHoleValueRootIndex, capacity_mode);
2239 } 2322 }
2240 2323
2241 return array; 2324 return array;
2242 } 2325 }
2243 2326
2244 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, 2327 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind,
2245 Node* capacity_node, 2328 Node* capacity_node,
2246 ParameterMode mode, 2329 ParameterMode mode,
2247 AllocationFlags flags) { 2330 AllocationFlags flags) {
2331 CSA_SLOW_ASSERT(this, IsParameterMode(capacity_node, mode));
2248 CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node, 2332 CSA_ASSERT(this, IntPtrOrSmiGreaterThan(capacity_node,
2249 IntPtrOrSmiConstant(0, mode), mode)); 2333 IntPtrOrSmiConstant(0, mode), mode));
2250 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); 2334 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode);
2251 2335
2252 // Allocate both array and elements object, and initialize the JSArray. 2336 // Allocate both array and elements object, and initialize the JSArray.
2253 Node* array = Allocate(total_size, flags); 2337 Node* array = Allocate(total_size, flags);
2254 Heap::RootListIndex map_index = IsFastDoubleElementsKind(kind) 2338 Heap::RootListIndex map_index = IsFastDoubleElementsKind(kind)
2255 ? Heap::kFixedDoubleArrayMapRootIndex 2339 ? Heap::kFixedDoubleArrayMapRootIndex
2256 : Heap::kFixedArrayMapRootIndex; 2340 : Heap::kFixedArrayMapRootIndex;
2257 DCHECK(Heap::RootIsImmortalImmovable(map_index)); 2341 DCHECK(Heap::RootIsImmortalImmovable(map_index));
2258 StoreMapNoWriteBarrier(array, map_index); 2342 StoreMapNoWriteBarrier(array, map_index);
2259 StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset, 2343 StoreObjectFieldNoWriteBarrier(array, FixedArray::kLengthOffset,
2260 ParameterToTagged(capacity_node, mode)); 2344 ParameterToTagged(capacity_node, mode));
2261 return array; 2345 return array;
2262 } 2346 }
2263 2347
2264 void CodeStubAssembler::FillFixedArrayWithValue( 2348 void CodeStubAssembler::FillFixedArrayWithValue(
2265 ElementsKind kind, Node* array, Node* from_node, Node* to_node, 2349 ElementsKind kind, Node* array, Node* from_node, Node* to_node,
2266 Heap::RootListIndex value_root_index, ParameterMode mode) { 2350 Heap::RootListIndex value_root_index, ParameterMode mode) {
2351 CSA_SLOW_ASSERT(this, IsParameterMode(from_node, mode));
2352 CSA_SLOW_ASSERT(this, IsParameterMode(to_node, mode));
2353 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, kind));
2267 bool is_double = IsFastDoubleElementsKind(kind); 2354 bool is_double = IsFastDoubleElementsKind(kind);
2268 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex || 2355 DCHECK(value_root_index == Heap::kTheHoleValueRootIndex ||
2269 value_root_index == Heap::kUndefinedValueRootIndex); 2356 value_root_index == Heap::kUndefinedValueRootIndex);
2270 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex); 2357 DCHECK_IMPLIES(is_double, value_root_index == Heap::kTheHoleValueRootIndex);
2271 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32); 2358 STATIC_ASSERT(kHoleNanLower32 == kHoleNanUpper32);
2272 Node* double_hole = 2359 Node* double_hole =
2273 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32); 2360 Is64() ? Int64Constant(kHoleNanInt64) : Int32Constant(kHoleNanLower32);
2274 Node* value = LoadRoot(value_root_index); 2361 Node* value = LoadRoot(value_root_index);
2275 2362
2276 BuildFastFixedArrayForEach( 2363 BuildFastFixedArrayForEach(
(...skipping 23 matching lines...) Expand all
2300 value); 2387 value);
2301 } 2388 }
2302 }, 2389 },
2303 mode); 2390 mode);
2304 } 2391 }
2305 2392
2306 void CodeStubAssembler::CopyFixedArrayElements( 2393 void CodeStubAssembler::CopyFixedArrayElements(
2307 ElementsKind from_kind, Node* from_array, ElementsKind to_kind, 2394 ElementsKind from_kind, Node* from_array, ElementsKind to_kind,
2308 Node* to_array, Node* element_count, Node* capacity, 2395 Node* to_array, Node* element_count, Node* capacity,
2309 WriteBarrierMode barrier_mode, ParameterMode mode) { 2396 WriteBarrierMode barrier_mode, ParameterMode mode) {
2397 CSA_SLOW_ASSERT(this, IsParameterMode(element_count, mode));
2398 CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode));
2399 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(from_array, from_kind));
2400 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(to_array, to_kind));
2310 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); 2401 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
2311 const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag; 2402 const int first_element_offset = FixedArray::kHeaderSize - kHeapObjectTag;
2312 Comment("[ CopyFixedArrayElements"); 2403 Comment("[ CopyFixedArrayElements");
2313 2404
2314 // Typed array elements are not supported. 2405 // Typed array elements are not supported.
2315 DCHECK(!IsFixedTypedArrayElementsKind(from_kind)); 2406 DCHECK(!IsFixedTypedArrayElementsKind(from_kind));
2316 DCHECK(!IsFixedTypedArrayElementsKind(to_kind)); 2407 DCHECK(!IsFixedTypedArrayElementsKind(to_kind));
2317 2408
2318 Label done(this); 2409 Label done(this);
2319 bool from_double_elements = IsFastDoubleElementsKind(from_kind); 2410 bool from_double_elements = IsFastDoubleElementsKind(from_kind);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2436 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1); 2527 IncrementCounter(isolate()->counters()->inlined_copied_elements(), 1);
2437 Comment("] CopyFixedArrayElements"); 2528 Comment("] CopyFixedArrayElements");
2438 } 2529 }
2439 2530
2440 void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string, 2531 void CodeStubAssembler::CopyStringCharacters(Node* from_string, Node* to_string,
2441 Node* from_index, Node* to_index, 2532 Node* from_index, Node* to_index,
2442 Node* character_count, 2533 Node* character_count,
2443 String::Encoding from_encoding, 2534 String::Encoding from_encoding,
2444 String::Encoding to_encoding, 2535 String::Encoding to_encoding,
2445 ParameterMode mode) { 2536 ParameterMode mode) {
2537 CSA_SLOW_ASSERT(this, IsString(from_string));
2538 CSA_SLOW_ASSERT(this, IsString(to_string));
2539 CSA_SLOW_ASSERT(this, IsParameterMode(character_count, mode));
2540 CSA_SLOW_ASSERT(this, IsParameterMode(from_index, mode));
2541 CSA_SLOW_ASSERT(this, IsParameterMode(to_index, mode));
2446 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING; 2542 bool from_one_byte = from_encoding == String::ONE_BYTE_ENCODING;
2447 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING; 2543 bool to_one_byte = to_encoding == String::ONE_BYTE_ENCODING;
2448 DCHECK_IMPLIES(to_one_byte, from_one_byte); 2544 DCHECK_IMPLIES(to_one_byte, from_one_byte);
2449 Comment("CopyStringCharacters %s -> %s", 2545 Comment("CopyStringCharacters %s -> %s",
2450 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING", 2546 from_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING",
2451 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING"); 2547 to_one_byte ? "ONE_BYTE_ENCODING" : "TWO_BYTE_ENCODING");
2452 2548
2453 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; 2549 ElementsKind from_kind = from_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS;
2454 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS; 2550 ElementsKind to_kind = to_one_byte ? UINT8_ELEMENTS : UINT16_ELEMENTS;
2455 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize); 2551 STATIC_ASSERT(SeqOneByteString::kHeaderSize == SeqTwoByteString::kHeaderSize);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
2494 } 2590 }
2495 }, 2591 },
2496 from_increment, INTPTR_PARAMETERS, IndexAdvanceMode::kPost); 2592 from_increment, INTPTR_PARAMETERS, IndexAdvanceMode::kPost);
2497 } 2593 }
2498 2594
2499 Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array, 2595 Node* CodeStubAssembler::LoadElementAndPrepareForStore(Node* array,
2500 Node* offset, 2596 Node* offset,
2501 ElementsKind from_kind, 2597 ElementsKind from_kind,
2502 ElementsKind to_kind, 2598 ElementsKind to_kind,
2503 Label* if_hole) { 2599 Label* if_hole) {
2600 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(array, from_kind));
2504 if (IsFastDoubleElementsKind(from_kind)) { 2601 if (IsFastDoubleElementsKind(from_kind)) {
2505 Node* value = 2602 Node* value =
2506 LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64()); 2603 LoadDoubleWithHoleCheck(array, offset, if_hole, MachineType::Float64());
2507 if (!IsFastDoubleElementsKind(to_kind)) { 2604 if (!IsFastDoubleElementsKind(to_kind)) {
2508 value = AllocateHeapNumberWithValue(value); 2605 value = AllocateHeapNumberWithValue(value);
2509 } 2606 }
2510 return value; 2607 return value;
2511 2608
2512 } else { 2609 } else {
2513 Node* value = Load(MachineType::AnyTagged(), array, offset); 2610 Node* value = Load(MachineType::AnyTagged(), array, offset);
2514 if (if_hole) { 2611 if (if_hole) {
2515 GotoIf(WordEqual(value, TheHoleConstant()), if_hole); 2612 GotoIf(WordEqual(value, TheHoleConstant()), if_hole);
2516 } 2613 }
2517 if (IsFastDoubleElementsKind(to_kind)) { 2614 if (IsFastDoubleElementsKind(to_kind)) {
2518 if (IsFastSmiElementsKind(from_kind)) { 2615 if (IsFastSmiElementsKind(from_kind)) {
2519 value = SmiToFloat64(value); 2616 value = SmiToFloat64(value);
2520 } else { 2617 } else {
2521 value = LoadHeapNumberValue(value); 2618 value = LoadHeapNumberValue(value);
2522 } 2619 }
2523 } 2620 }
2524 return value; 2621 return value;
2525 } 2622 }
2526 } 2623 }
2527 2624
2528 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity, 2625 Node* CodeStubAssembler::CalculateNewElementsCapacity(Node* old_capacity,
2529 ParameterMode mode) { 2626 ParameterMode mode) {
2627 CSA_SLOW_ASSERT(this, IsParameterMode(old_capacity, mode));
2530 Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode); 2628 Node* half_old_capacity = WordOrSmiShr(old_capacity, 1, mode);
2531 Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode); 2629 Node* new_capacity = IntPtrOrSmiAdd(half_old_capacity, old_capacity, mode);
2532 Node* padding = IntPtrOrSmiConstant(16, mode); 2630 Node* padding = IntPtrOrSmiConstant(16, mode);
2533 return IntPtrOrSmiAdd(new_capacity, padding, mode); 2631 return IntPtrOrSmiAdd(new_capacity, padding, mode);
2534 } 2632 }
2535 2633
2536 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, 2634 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
2537 ElementsKind kind, Node* key, 2635 ElementsKind kind, Node* key,
2538 Label* bailout) { 2636 Label* bailout) {
2637 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
2638 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(elements, kind));
2639 CSA_SLOW_ASSERT(this, TaggedIsSmi(key));
2539 Node* capacity = LoadFixedArrayBaseLength(elements); 2640 Node* capacity = LoadFixedArrayBaseLength(elements);
2540 2641
2541 ParameterMode mode = OptimalParameterMode(); 2642 ParameterMode mode = OptimalParameterMode();
2542 capacity = TaggedToParameter(capacity, mode); 2643 capacity = TaggedToParameter(capacity, mode);
2543 key = TaggedToParameter(key, mode); 2644 key = TaggedToParameter(key, mode);
2544 2645
2545 return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode, 2646 return TryGrowElementsCapacity(object, elements, kind, key, capacity, mode,
2546 bailout); 2647 bailout);
2547 } 2648 }
2548 2649
2549 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements, 2650 Node* CodeStubAssembler::TryGrowElementsCapacity(Node* object, Node* elements,
2550 ElementsKind kind, Node* key, 2651 ElementsKind kind, Node* key,
2551 Node* capacity, 2652 Node* capacity,
2552 ParameterMode mode, 2653 ParameterMode mode,
2553 Label* bailout) { 2654 Label* bailout) {
2554 Comment("TryGrowElementsCapacity"); 2655 Comment("TryGrowElementsCapacity");
2656 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
2657 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(elements, kind));
2658 CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode));
2659 CSA_SLOW_ASSERT(this, IsParameterMode(key, mode));
2555 2660
2556 // If the gap growth is too big, fall back to the runtime. 2661 // If the gap growth is too big, fall back to the runtime.
2557 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode); 2662 Node* max_gap = IntPtrOrSmiConstant(JSObject::kMaxGap, mode);
2558 Node* max_capacity = IntPtrOrSmiAdd(capacity, max_gap, mode); 2663 Node* max_capacity = IntPtrOrSmiAdd(capacity, max_gap, mode);
2559 GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity, mode), bailout); 2664 GotoIf(UintPtrOrSmiGreaterThanOrEqual(key, max_capacity, mode), bailout);
2560 2665
2561 // Calculate the capacity of the new backing store. 2666 // Calculate the capacity of the new backing store.
2562 Node* new_capacity = CalculateNewElementsCapacity( 2667 Node* new_capacity = CalculateNewElementsCapacity(
2563 IntPtrOrSmiAdd(key, IntPtrOrSmiConstant(1, mode), mode), mode); 2668 IntPtrOrSmiAdd(key, IntPtrOrSmiConstant(1, mode), mode), mode);
2564 return GrowElementsCapacity(object, elements, kind, kind, capacity, 2669 return GrowElementsCapacity(object, elements, kind, kind, capacity,
2565 new_capacity, mode, bailout); 2670 new_capacity, mode, bailout);
2566 } 2671 }
2567 2672
2568 Node* CodeStubAssembler::GrowElementsCapacity( 2673 Node* CodeStubAssembler::GrowElementsCapacity(
2569 Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind, 2674 Node* object, Node* elements, ElementsKind from_kind, ElementsKind to_kind,
2570 Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) { 2675 Node* capacity, Node* new_capacity, ParameterMode mode, Label* bailout) {
2571 Comment("[ GrowElementsCapacity"); 2676 Comment("[ GrowElementsCapacity");
2677 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
2678 CSA_SLOW_ASSERT(this, IsFixedArrayWithKind(elements, from_kind));
2679 CSA_SLOW_ASSERT(this, IsParameterMode(capacity, mode));
2680 CSA_SLOW_ASSERT(this, IsParameterMode(new_capacity, mode));
2681
2572 // If size of the allocation for the new capacity doesn't fit in a page 2682 // If size of the allocation for the new capacity doesn't fit in a page
2573 // that we can bump-pointer allocate from, fall back to the runtime. 2683 // that we can bump-pointer allocate from, fall back to the runtime.
2574 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind); 2684 int max_size = FixedArrayBase::GetMaxLengthForNewSpaceAllocation(to_kind);
2575 GotoIf(UintPtrOrSmiGreaterThanOrEqual( 2685 GotoIf(UintPtrOrSmiGreaterThanOrEqual(
2576 new_capacity, IntPtrOrSmiConstant(max_size, mode), mode), 2686 new_capacity, IntPtrOrSmiConstant(max_size, mode), mode),
2577 bailout); 2687 bailout);
2578 2688
2579 // Allocate the new backing store. 2689 // Allocate the new backing store.
2580 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode); 2690 Node* new_elements = AllocateFixedArray(to_kind, new_capacity, mode);
2581 2691
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
2770 } 2880 }
2771 } 2881 }
2772 } 2882 }
2773 BIND(&if_valueisheapnumber); 2883 BIND(&if_valueisheapnumber);
2774 { 2884 {
2775 Node* result = AllocateHeapNumberWithValue(value); 2885 Node* result = AllocateHeapNumberWithValue(value);
2776 var_result.Bind(result); 2886 var_result.Bind(result);
2777 Goto(&if_join); 2887 Goto(&if_join);
2778 } 2888 }
2779 BIND(&if_join); 2889 BIND(&if_join);
2890 CSA_SLOW_ASSERT(this, IsNumber(var_result.value()));
2780 return var_result.value(); 2891 return var_result.value();
2781 } 2892 }
2782 2893
2783 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) { 2894 Node* CodeStubAssembler::ChangeInt32ToTagged(Node* value) {
2784 if (Is64()) { 2895 if (Is64()) {
2785 return SmiTag(ChangeInt32ToInt64(value)); 2896 return SmiTag(ChangeInt32ToInt64(value));
2786 } 2897 }
2787 VARIABLE(var_result, MachineRepresentation::kTagged); 2898 VARIABLE(var_result, MachineRepresentation::kTagged);
2788 Node* pair = Int32AddWithOverflow(value, value); 2899 Node* pair = Int32AddWithOverflow(value, value);
2789 Node* overflow = Projection(1, pair); 2900 Node* overflow = Projection(1, pair);
2790 Label if_overflow(this, Label::kDeferred), if_notoverflow(this), 2901 Label if_overflow(this, Label::kDeferred), if_notoverflow(this),
2791 if_join(this); 2902 if_join(this);
2792 Branch(overflow, &if_overflow, &if_notoverflow); 2903 Branch(overflow, &if_overflow, &if_notoverflow);
2793 BIND(&if_overflow); 2904 BIND(&if_overflow);
2794 { 2905 {
2795 Node* value64 = ChangeInt32ToFloat64(value); 2906 Node* value64 = ChangeInt32ToFloat64(value);
2796 Node* result = AllocateHeapNumberWithValue(value64); 2907 Node* result = AllocateHeapNumberWithValue(value64);
2797 var_result.Bind(result); 2908 var_result.Bind(result);
2798 } 2909 }
2799 Goto(&if_join); 2910 Goto(&if_join);
2800 BIND(&if_notoverflow); 2911 BIND(&if_notoverflow);
2801 { 2912 {
2802 Node* result = BitcastWordToTaggedSigned(Projection(0, pair)); 2913 Node* result = BitcastWordToTaggedSigned(Projection(0, pair));
2803 var_result.Bind(result); 2914 var_result.Bind(result);
2804 } 2915 }
2805 Goto(&if_join); 2916 Goto(&if_join);
2806 BIND(&if_join); 2917 BIND(&if_join);
2918 CSA_SLOW_ASSERT(this, IsNumber(var_result.value()));
2807 return var_result.value(); 2919 return var_result.value();
2808 } 2920 }
2809 2921
2810 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) { 2922 Node* CodeStubAssembler::ChangeUint32ToTagged(Node* value) {
2811 Label if_overflow(this, Label::kDeferred), if_not_overflow(this), 2923 Label if_overflow(this, Label::kDeferred), if_not_overflow(this),
2812 if_join(this); 2924 if_join(this);
2813 VARIABLE(var_result, MachineRepresentation::kTagged); 2925 VARIABLE(var_result, MachineRepresentation::kTagged);
2814 // If {value} > 2^31 - 1, we need to store it in a HeapNumber. 2926 // If {value} > 2^31 - 1, we need to store it in a HeapNumber.
2815 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow, 2927 Branch(Uint32LessThan(Int32Constant(Smi::kMaxValue), value), &if_overflow,
2816 &if_not_overflow); 2928 &if_not_overflow);
(...skipping 16 matching lines...) Expand all
2833 Goto(&if_join); 2945 Goto(&if_join);
2834 2946
2835 BIND(&if_overflow); 2947 BIND(&if_overflow);
2836 { 2948 {
2837 Node* float64_value = ChangeUint32ToFloat64(value); 2949 Node* float64_value = ChangeUint32ToFloat64(value);
2838 var_result.Bind(AllocateHeapNumberWithValue(float64_value)); 2950 var_result.Bind(AllocateHeapNumberWithValue(float64_value));
2839 } 2951 }
2840 Goto(&if_join); 2952 Goto(&if_join);
2841 2953
2842 BIND(&if_join); 2954 BIND(&if_join);
2955 CSA_SLOW_ASSERT(this, IsNumber(var_result.value()));
2843 return var_result.value(); 2956 return var_result.value();
2844 } 2957 }
2845 2958
2846 Node* CodeStubAssembler::ToThisString(Node* context, Node* value, 2959 Node* CodeStubAssembler::ToThisString(Node* context, Node* value,
2847 char const* method_name) { 2960 char const* method_name) {
2848 VARIABLE(var_value, MachineRepresentation::kTagged, value); 2961 VARIABLE(var_value, MachineRepresentation::kTagged, value);
2849 2962
2850 // Check if the {value} is a Smi or a HeapObject. 2963 // Check if the {value} is a Smi or a HeapObject.
2851 Label if_valueissmi(this, Label::kDeferred), if_valueisnotsmi(this), 2964 Label if_valueissmi(this, Label::kDeferred), if_valueisnotsmi(this),
2852 if_valueisstring(this); 2965 if_valueisstring(this);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
2897 // The {value} is a Smi, convert it to a String. 3010 // The {value} is a Smi, convert it to a String.
2898 Callable callable = CodeFactory::NumberToString(isolate()); 3011 Callable callable = CodeFactory::NumberToString(isolate());
2899 var_value.Bind(CallStub(callable, context, value)); 3012 var_value.Bind(CallStub(callable, context, value));
2900 Goto(&if_valueisstring); 3013 Goto(&if_valueisstring);
2901 } 3014 }
2902 BIND(&if_valueisstring); 3015 BIND(&if_valueisstring);
2903 return var_value.value(); 3016 return var_value.value();
2904 } 3017 }
2905 3018
2906 Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) { 3019 Node* CodeStubAssembler::ChangeNumberToFloat64(Node* value) {
3020 CSA_SLOW_ASSERT(this, IsNumber(value));
2907 VARIABLE(result, MachineRepresentation::kFloat64); 3021 VARIABLE(result, MachineRepresentation::kFloat64);
2908 Label smi(this); 3022 Label smi(this);
2909 Label done(this, &result); 3023 Label done(this, &result);
2910 GotoIf(TaggedIsSmi(value), &smi); 3024 GotoIf(TaggedIsSmi(value), &smi);
2911 result.Bind( 3025 result.Bind(
2912 LoadObjectField(value, HeapNumber::kValueOffset, MachineType::Float64())); 3026 LoadObjectField(value, HeapNumber::kValueOffset, MachineType::Float64()));
2913 Goto(&done); 3027 Goto(&done);
2914 3028
2915 BIND(&smi); 3029 BIND(&smi);
2916 { 3030 {
2917 result.Bind(SmiToFloat64(value)); 3031 result.Bind(SmiToFloat64(value));
2918 Goto(&done); 3032 Goto(&done);
2919 } 3033 }
2920 3034
2921 BIND(&done); 3035 BIND(&done);
2922 return result.value(); 3036 return result.value();
2923 } 3037 }
2924 3038
2925 Node* CodeStubAssembler::ChangeNumberToIntPtr(Node* value) { 3039 Node* CodeStubAssembler::ChangeNumberToIntPtr(Node* value) {
3040 CSA_SLOW_ASSERT(this, IsNumber(value));
2926 VARIABLE(result, MachineType::PointerRepresentation()); 3041 VARIABLE(result, MachineType::PointerRepresentation());
2927 Label smi(this), done(this, &result); 3042 Label smi(this), done(this, &result);
2928 GotoIf(TaggedIsSmi(value), &smi); 3043 GotoIf(TaggedIsSmi(value), &smi);
2929 3044
2930 CSA_ASSERT(this, IsHeapNumber(value)); 3045 CSA_ASSERT(this, IsHeapNumber(value));
2931 result.Bind(ChangeFloat64ToUintPtr(LoadHeapNumberValue(value))); 3046 result.Bind(ChangeFloat64ToUintPtr(LoadHeapNumberValue(value)));
2932 Goto(&done); 3047 Goto(&done);
2933 3048
2934 BIND(&smi); 3049 BIND(&smi);
2935 result.Bind(SmiToWord(value)); 3050 result.Bind(SmiToWord(value));
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
3053 3168
3054 BIND(&out); 3169 BIND(&out);
3055 return var_value_map.value(); 3170 return var_value_map.value();
3056 } 3171 }
3057 3172
3058 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) { 3173 Node* CodeStubAssembler::InstanceTypeEqual(Node* instance_type, int type) {
3059 return Word32Equal(instance_type, Int32Constant(type)); 3174 return Word32Equal(instance_type, Int32Constant(type));
3060 } 3175 }
3061 3176
3062 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { 3177 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) {
3178 CSA_SLOW_ASSERT(this, IsMap(map));
3063 Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); 3179 Node* is_special = IsSpecialReceiverInstanceType(LoadMapInstanceType(map));
3064 uint32_t mask = 3180 uint32_t mask =
3065 1 << Map::kHasNamedInterceptor | 1 << Map::kIsAccessCheckNeeded; 3181 1 << Map::kHasNamedInterceptor | 1 << Map::kIsAccessCheckNeeded;
3066 USE(mask); 3182 USE(mask);
3067 // Interceptors or access checks imply special receiver. 3183 // Interceptors or access checks imply special receiver.
3068 CSA_ASSERT(this, 3184 CSA_ASSERT(this,
3069 SelectConstant(IsSetWord32(LoadMapBitField(map), mask), is_special, 3185 SelectConstant(IsSetWord32(LoadMapBitField(map), mask), is_special,
3070 Int32Constant(1), MachineRepresentation::kWord32)); 3186 Int32Constant(1), MachineRepresentation::kWord32));
3071 return is_special; 3187 return is_special;
3072 } 3188 }
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
3197 } 3313 }
3198 3314
3199 Node* CodeStubAssembler::IsJSArray(Node* object) { 3315 Node* CodeStubAssembler::IsJSArray(Node* object) {
3200 return IsJSArrayMap(LoadMap(object)); 3316 return IsJSArrayMap(LoadMap(object));
3201 } 3317 }
3202 3318
3203 Node* CodeStubAssembler::IsJSArrayMap(Node* map) { 3319 Node* CodeStubAssembler::IsJSArrayMap(Node* map) {
3204 return IsJSArrayInstanceType(LoadMapInstanceType(map)); 3320 return IsJSArrayInstanceType(LoadMapInstanceType(map));
3205 } 3321 }
3206 3322
3323 Node* CodeStubAssembler::IsFixedArray(Node* object) {
3324 return HasInstanceType(object, FIXED_ARRAY_TYPE);
3325 }
3326
3327 Node* CodeStubAssembler::IsFixedArrayWithKind(Node* object, ElementsKind kind) {
3328 if (IsFastDoubleElementsKind(kind)) {
3329 return IsFixedDoubleArray(object);
3330 } else {
3331 DCHECK(IsFastSmiOrObjectElementsKind(kind));
3332 return IsFixedArray(object);
3333 }
3334 }
3335
3207 Node* CodeStubAssembler::IsWeakCell(Node* object) { 3336 Node* CodeStubAssembler::IsWeakCell(Node* object) {
3208 return IsWeakCellMap(LoadMap(object)); 3337 return IsWeakCellMap(LoadMap(object));
3209 } 3338 }
3210 3339
3211 Node* CodeStubAssembler::IsBoolean(Node* object) { 3340 Node* CodeStubAssembler::IsBoolean(Node* object) {
3212 return IsBooleanMap(LoadMap(object)); 3341 return IsBooleanMap(LoadMap(object));
3213 } 3342 }
3214 3343
3215 Node* CodeStubAssembler::IsPropertyCell(Node* object) { 3344 Node* CodeStubAssembler::IsPropertyCell(Node* object) {
3216 return IsPropertyCellMap(LoadMap(object)); 3345 return IsPropertyCellMap(LoadMap(object));
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3332 3461
3333 var_result.Bind(Int32Constant(0)); 3462 var_result.Bind(Int32Constant(0));
3334 Goto(&out); 3463 Goto(&out);
3335 3464
3336 BIND(&out); 3465 BIND(&out);
3337 return var_result.value(); 3466 return var_result.value();
3338 } 3467 }
3339 3468
3340 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index, 3469 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index,
3341 ParameterMode parameter_mode) { 3470 ParameterMode parameter_mode) {
3342 if (parameter_mode == SMI_PARAMETERS) CSA_ASSERT(this, TaggedIsSmi(index)); 3471 CSA_ASSERT(this, IsParameterMode(index, parameter_mode));
3343 CSA_ASSERT(this, IsString(string)); 3472 CSA_ASSERT(this, IsString(string));
3344 3473
3345 // Translate the {index} into a Word. 3474 // Translate the {index} into a Word.
3346 Node* const int_index = ParameterToWord(index, parameter_mode); 3475 Node* const int_index = ParameterToWord(index, parameter_mode);
3347 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0))); 3476 CSA_ASSERT(this, IntPtrGreaterThanOrEqual(int_index, IntPtrConstant(0)));
3348 3477
3349 VARIABLE(var_result, MachineRepresentation::kWord32); 3478 VARIABLE(var_result, MachineRepresentation::kWord32);
3350 3479
3351 Label out(this, &var_result), runtime_generic(this), runtime_external(this); 3480 Label out(this, &var_result), runtime_generic(this), runtime_external(this);
3352 3481
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
3444 // Allocate a new SeqTwoByteString for {code}. 3573 // Allocate a new SeqTwoByteString for {code}.
3445 Node* result = AllocateSeqTwoByteString(1); 3574 Node* result = AllocateSeqTwoByteString(1);
3446 StoreNoWriteBarrier( 3575 StoreNoWriteBarrier(
3447 MachineRepresentation::kWord16, result, 3576 MachineRepresentation::kWord16, result,
3448 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code); 3577 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), code);
3449 var_result.Bind(result); 3578 var_result.Bind(result);
3450 Goto(&if_done); 3579 Goto(&if_done);
3451 } 3580 }
3452 3581
3453 BIND(&if_done); 3582 BIND(&if_done);
3583 CSA_ASSERT(this, IsString(var_result.value()));
3454 return var_result.value(); 3584 return var_result.value();
3455 } 3585 }
3456 3586
3457 namespace { 3587 namespace {
3458 3588
3459 // A wrapper around CopyStringCharacters which determines the correct string 3589 // A wrapper around CopyStringCharacters which determines the correct string
3460 // encoding, allocates a corresponding sequential string, and then copies the 3590 // encoding, allocates a corresponding sequential string, and then copies the
3461 // given character range using CopyStringCharacters. 3591 // given character range using CopyStringCharacters.
3462 // |from_string| must be a sequential string. |from_index| and 3592 // |from_string| must be a sequential string. |from_index| and
3463 // |character_count| must be Smis s.t. 3593 // |character_count| must be Smis s.t.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
3641 3771
3642 // Fall back to a runtime call. 3772 // Fall back to a runtime call.
3643 BIND(&runtime); 3773 BIND(&runtime);
3644 { 3774 {
3645 var_result.Bind( 3775 var_result.Bind(
3646 CallRuntime(Runtime::kSubString, context, string, from, to)); 3776 CallRuntime(Runtime::kSubString, context, string, from, to));
3647 Goto(&end); 3777 Goto(&end);
3648 } 3778 }
3649 3779
3650 BIND(&end); 3780 BIND(&end);
3781 CSA_ASSERT(this, IsString(var_result.value()));
3651 return var_result.value(); 3782 return var_result.value();
3652 } 3783 }
3653 3784
3654 ToDirectStringAssembler::ToDirectStringAssembler( 3785 ToDirectStringAssembler::ToDirectStringAssembler(
3655 compiler::CodeAssemblerState* state, Node* string) 3786 compiler::CodeAssemblerState* state, Node* string)
3656 : CodeStubAssembler(state), 3787 : CodeStubAssembler(state),
3657 var_string_(this, MachineRepresentation::kTagged, string), 3788 var_string_(this, MachineRepresentation::kTagged, string),
3658 var_instance_type_(this, MachineRepresentation::kWord32), 3789 var_instance_type_(this, MachineRepresentation::kWord32),
3659 var_offset_(this, MachineType::PointerRepresentation()), 3790 var_offset_(this, MachineType::PointerRepresentation()),
3660 var_is_external_(this, MachineRepresentation::kWord32) { 3791 var_is_external_(this, MachineRepresentation::kWord32) {
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
3783 kHeapObjectTag)); 3914 kHeapObjectTag));
3784 } 3915 }
3785 var_result.Bind(result); 3916 var_result.Bind(result);
3786 Goto(&out); 3917 Goto(&out);
3787 } 3918 }
3788 3919
3789 BIND(&out); 3920 BIND(&out);
3790 return var_result.value(); 3921 return var_result.value();
3791 } 3922 }
3792 3923
3793 Node* CodeStubAssembler::TryDerefExternalString(Node* const string,
3794 Node* const instance_type,
3795 Label* if_bailout) {
3796 Label out(this);
3797
3798 CSA_ASSERT(this, IsExternalStringInstanceType(instance_type));
3799 GotoIf(IsShortExternalStringInstanceType(instance_type), if_bailout);
3800
3801 // Move the pointer so that offset-wise, it looks like a sequential string.
3802 STATIC_ASSERT(SeqTwoByteString::kHeaderSize == SeqOneByteString::kHeaderSize);
3803
3804 Node* resource_data = LoadObjectField(
3805 string, ExternalString::kResourceDataOffset, MachineType::Pointer());
3806 Node* const fake_sequential_string =
3807 IntPtrSub(resource_data,
3808 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag));
3809
3810 return fake_sequential_string;
3811 }
3812
3813 void CodeStubAssembler::MaybeDerefIndirectString(Variable* var_string, 3924 void CodeStubAssembler::MaybeDerefIndirectString(Variable* var_string,
3814 Node* instance_type, 3925 Node* instance_type,
3815 Variable* var_did_something) { 3926 Variable* var_did_something) {
3816 Label deref(this), done(this, var_did_something); 3927 Label deref(this), done(this, var_did_something);
3817 Node* representation = 3928 Node* representation =
3818 Word32And(instance_type, Int32Constant(kStringRepresentationMask)); 3929 Word32And(instance_type, Int32Constant(kStringRepresentationMask));
3819 GotoIf(Word32Equal(representation, Int32Constant(kThinStringTag)), &deref); 3930 GotoIf(Word32Equal(representation, Int32Constant(kThinStringTag)), &deref);
3820 GotoIf(Word32NotEqual(representation, Int32Constant(kConsStringTag)), &done); 3931 GotoIf(Word32NotEqual(representation, Int32Constant(kConsStringTag)), &done);
3821 // Cons string. 3932 // Cons string.
3822 Node* rhs = LoadObjectField(var_string->value(), ConsString::kSecondOffset); 3933 Node* rhs = LoadObjectField(var_string->value(), ConsString::kSecondOffset);
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
4008 Node* value = AllocateSeqTwoByteString(2); 4119 Node* value = AllocateSeqTwoByteString(2);
4009 StoreNoWriteBarrier( 4120 StoreNoWriteBarrier(
4010 MachineRepresentation::kWord32, value, 4121 MachineRepresentation::kWord32, value,
4011 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag), 4122 IntPtrConstant(SeqTwoByteString::kHeaderSize - kHeapObjectTag),
4012 codepoint); 4123 codepoint);
4013 var_result.Bind(value); 4124 var_result.Bind(value);
4014 Goto(&return_result); 4125 Goto(&return_result);
4015 } 4126 }
4016 4127
4017 BIND(&return_result); 4128 BIND(&return_result);
4129 CSA_ASSERT(this, IsString(var_result.value()));
4018 return var_result.value(); 4130 return var_result.value();
4019 } 4131 }
4020 4132
4021 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) { 4133 Node* CodeStubAssembler::StringToNumber(Node* context, Node* input) {
4134 CSA_SLOW_ASSERT(this, IsString(input));
4022 Label runtime(this, Label::kDeferred); 4135 Label runtime(this, Label::kDeferred);
4023 Label end(this); 4136 Label end(this);
4024 4137
4025 VARIABLE(var_result, MachineRepresentation::kTagged); 4138 VARIABLE(var_result, MachineRepresentation::kTagged);
4026 4139
4027 // Check if string has a cached array index. 4140 // Check if string has a cached array index.
4028 Node* hash = LoadNameHashField(input); 4141 Node* hash = LoadNameHashField(input);
4029 Node* bit = 4142 Node* bit =
4030 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask)); 4143 Word32And(hash, Int32Constant(String::kContainsCachedArrayIndexMask));
4031 GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime); 4144 GotoIf(Word32NotEqual(bit, Int32Constant(0)), &runtime);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
4111 GotoIf(WordNotEqual(smi_key, argument), &runtime); 4224 GotoIf(WordNotEqual(smi_key, argument), &runtime);
4112 4225
4113 // Smi match, return value from cache entry. 4226 // Smi match, return value from cache entry.
4114 IncrementCounter(isolate()->counters()->number_to_string_native(), 1); 4227 IncrementCounter(isolate()->counters()->number_to_string_native(), 1);
4115 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index, 4228 result.Bind(LoadFixedArrayElement(number_string_cache, smi_index,
4116 kPointerSize, SMI_PARAMETERS)); 4229 kPointerSize, SMI_PARAMETERS));
4117 Goto(&done); 4230 Goto(&done);
4118 } 4231 }
4119 4232
4120 BIND(&done); 4233 BIND(&done);
4234 CSA_ASSERT(this, IsString(result.value()));
4121 return result.value(); 4235 return result.value();
4122 } 4236 }
4123 4237
4124 Node* CodeStubAssembler::ToName(Node* context, Node* value) { 4238 Node* CodeStubAssembler::ToName(Node* context, Node* value) {
4125 Label end(this); 4239 Label end(this);
4126 VARIABLE(var_result, MachineRepresentation::kTagged); 4240 VARIABLE(var_result, MachineRepresentation::kTagged);
4127 4241
4128 Label is_number(this); 4242 Label is_number(this);
4129 GotoIf(TaggedIsSmi(value), &is_number); 4243 GotoIf(TaggedIsSmi(value), &is_number);
4130 4244
(...skipping 26 matching lines...) Expand all
4157 Goto(&end); 4271 Goto(&end);
4158 4272
4159 BIND(&not_oddball); 4273 BIND(&not_oddball);
4160 { 4274 {
4161 var_result.Bind(CallRuntime(Runtime::kToName, context, value)); 4275 var_result.Bind(CallRuntime(Runtime::kToName, context, value));
4162 Goto(&end); 4276 Goto(&end);
4163 } 4277 }
4164 } 4278 }
4165 4279
4166 BIND(&end); 4280 BIND(&end);
4281 CSA_ASSERT(this, IsName(var_result.value()));
4167 return var_result.value(); 4282 return var_result.value();
4168 } 4283 }
4169 4284
4170 Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) { 4285 Node* CodeStubAssembler::NonNumberToNumber(Node* context, Node* input) {
4171 // Assert input is a HeapObject (not smi or heap number) 4286 // Assert input is a HeapObject (not smi or heap number)
4172 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(input))); 4287 CSA_ASSERT(this, Word32BinaryNot(TaggedIsSmi(input)));
4173 CSA_ASSERT(this, Word32BinaryNot(IsHeapNumberMap(LoadMap(input)))); 4288 CSA_ASSERT(this, Word32BinaryNot(IsHeapNumberMap(LoadMap(input))));
4174 4289
4175 // We might need to loop once here due to ToPrimitive conversions. 4290 // We might need to loop once here due to ToPrimitive conversions.
4176 VARIABLE(var_input, MachineRepresentation::kTagged, input); 4291 VARIABLE(var_input, MachineRepresentation::kTagged, input);
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
4245 // Note: We cannot tail call to the runtime here, as js-to-wasm 4360 // Note: We cannot tail call to the runtime here, as js-to-wasm
4246 // trampolines also use this code currently, and they declare all 4361 // trampolines also use this code currently, and they declare all
4247 // outgoing parameters as untagged, while we would push a tagged 4362 // outgoing parameters as untagged, while we would push a tagged
4248 // object here. 4363 // object here.
4249 var_result.Bind(CallRuntime(Runtime::kToNumber, context, input)); 4364 var_result.Bind(CallRuntime(Runtime::kToNumber, context, input));
4250 Goto(&end); 4365 Goto(&end);
4251 } 4366 }
4252 } 4367 }
4253 4368
4254 BIND(&end); 4369 BIND(&end);
4370 CSA_ASSERT(this, IsNumber(var_result.value()));
4255 return var_result.value(); 4371 return var_result.value();
4256 } 4372 }
4257 4373
4258 Node* CodeStubAssembler::ToNumber(Node* context, Node* input) { 4374 Node* CodeStubAssembler::ToNumber(Node* context, Node* input) {
4259 VARIABLE(var_result, MachineRepresentation::kTagged); 4375 VARIABLE(var_result, MachineRepresentation::kTagged);
4260 Label end(this); 4376 Label end(this);
4261 4377
4262 Label not_smi(this, Label::kDeferred); 4378 Label not_smi(this, Label::kDeferred);
4263 GotoIfNot(TaggedIsSmi(input), &not_smi); 4379 GotoIfNot(TaggedIsSmi(input), &not_smi);
4264 var_result.Bind(input); 4380 var_result.Bind(input);
4265 Goto(&end); 4381 Goto(&end);
4266 4382
4267 BIND(&not_smi); 4383 BIND(&not_smi);
4268 { 4384 {
4269 Label not_heap_number(this, Label::kDeferred); 4385 Label not_heap_number(this, Label::kDeferred);
4270 Node* input_map = LoadMap(input); 4386 Node* input_map = LoadMap(input);
4271 GotoIfNot(IsHeapNumberMap(input_map), &not_heap_number); 4387 GotoIfNot(IsHeapNumberMap(input_map), &not_heap_number);
4272 4388
4273 var_result.Bind(input); 4389 var_result.Bind(input);
4274 Goto(&end); 4390 Goto(&end);
4275 4391
4276 BIND(&not_heap_number); 4392 BIND(&not_heap_number);
4277 { 4393 {
4278 var_result.Bind(NonNumberToNumber(context, input)); 4394 var_result.Bind(NonNumberToNumber(context, input));
4279 Goto(&end); 4395 Goto(&end);
4280 } 4396 }
4281 } 4397 }
4282 4398
4283 BIND(&end); 4399 BIND(&end);
4400 CSA_ASSERT(this, IsNumber(var_result.value()));
4284 return var_result.value(); 4401 return var_result.value();
4285 } 4402 }
4286 4403
4287 // ES#sec-touint32 4404 // ES#sec-touint32
4288 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) { 4405 Node* CodeStubAssembler::ToUint32(Node* context, Node* input) {
4289 Node* const float_zero = Float64Constant(0.0); 4406 Node* const float_zero = Float64Constant(0.0);
4290 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32)); 4407 Node* const float_two_32 = Float64Constant(static_cast<double>(1ULL << 32));
4291 4408
4292 Label out(this); 4409 Label out(this);
4293 4410
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
4376 } 4493 }
4377 4494
4378 BIND(&return_zero); 4495 BIND(&return_zero);
4379 { 4496 {
4380 var_result.Bind(SmiConstant(Smi::kZero)); 4497 var_result.Bind(SmiConstant(Smi::kZero));
4381 Goto(&out); 4498 Goto(&out);
4382 } 4499 }
4383 } 4500 }
4384 4501
4385 BIND(&out); 4502 BIND(&out);
4503 CSA_ASSERT(this, IsNumber(var_result.value()));
4386 return var_result.value(); 4504 return var_result.value();
4387 } 4505 }
4388 4506
4389 Node* CodeStubAssembler::ToString(Node* context, Node* input) { 4507 Node* CodeStubAssembler::ToString(Node* context, Node* input) {
4390 Label is_number(this); 4508 Label is_number(this);
4391 Label runtime(this, Label::kDeferred); 4509 Label runtime(this, Label::kDeferred);
4392 VARIABLE(result, MachineRepresentation::kTagged); 4510 VARIABLE(result, MachineRepresentation::kTagged);
4393 Label done(this, &result); 4511 Label done(this, &result);
4394 4512
4395 GotoIf(TaggedIsSmi(input), &is_number); 4513 GotoIf(TaggedIsSmi(input), &is_number);
(...skipping 19 matching lines...) Expand all
4415 Goto(&done); 4533 Goto(&done);
4416 } 4534 }
4417 4535
4418 BIND(&runtime); 4536 BIND(&runtime);
4419 { 4537 {
4420 result.Bind(CallRuntime(Runtime::kToString, context, input)); 4538 result.Bind(CallRuntime(Runtime::kToString, context, input));
4421 Goto(&done); 4539 Goto(&done);
4422 } 4540 }
4423 4541
4424 BIND(&done); 4542 BIND(&done);
4543 CSA_ASSERT(this, IsString(result.value()));
4425 return result.value(); 4544 return result.value();
4426 } 4545 }
4427 4546
4428 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) { 4547 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) {
4429 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this); 4548 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this);
4430 VARIABLE(result, MachineRepresentation::kTagged); 4549 VARIABLE(result, MachineRepresentation::kTagged);
4431 Label done(this, &result); 4550 Label done(this, &result);
4432 4551
4433 BranchIfJSReceiver(input, &if_isreceiver, &if_isnotreceiver); 4552 BranchIfJSReceiver(input, &if_isreceiver, &if_isnotreceiver);
4434 4553
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
4468 Goto(&negative_check); 4587 Goto(&negative_check);
4469 4588
4470 BIND(&negative_check); 4589 BIND(&negative_check);
4471 Branch(SmiLessThan(result.value(), SmiConstant(0)), range_error, &done); 4590 Branch(SmiLessThan(result.value(), SmiConstant(0)), range_error, &done);
4472 4591
4473 BIND(&return_zero); 4592 BIND(&return_zero);
4474 result.Bind(SmiConstant(0)); 4593 result.Bind(SmiConstant(0));
4475 Goto(&done); 4594 Goto(&done);
4476 4595
4477 BIND(&done); 4596 BIND(&done);
4597 CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value()));
4478 return result.value(); 4598 return result.value();
4479 } 4599 }
4480 4600
4481 Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context, 4601 Node* CodeStubAssembler::ToSmiLength(Node* input, Node* const context,
4482 Label* range_error) { 4602 Label* range_error) {
4483 VARIABLE(result, MachineRepresentation::kTagged, input); 4603 VARIABLE(result, MachineRepresentation::kTagged, input);
4484 Label to_integer(this), negative_check(this), return_zero(this), done(this); 4604 Label to_integer(this), negative_check(this), return_zero(this), done(this);
4485 Branch(TaggedIsSmi(result.value()), &negative_check, &to_integer); 4605 Branch(TaggedIsSmi(result.value()), &negative_check, &to_integer);
4486 4606
4487 BIND(&to_integer); 4607 BIND(&to_integer);
4488 result.Bind(ToInteger(context, result.value(), 4608 result.Bind(ToInteger(context, result.value(),
4489 CodeStubAssembler::kTruncateMinusZero)); 4609 CodeStubAssembler::kTruncateMinusZero));
4490 GotoIfNot(TaggedIsSmi(result.value()), range_error); 4610 GotoIfNot(TaggedIsSmi(result.value()), range_error);
4491 CSA_ASSERT(this, TaggedIsSmi(result.value())); 4611 CSA_ASSERT(this, TaggedIsSmi(result.value()));
4492 Goto(&negative_check); 4612 Goto(&negative_check);
4493 4613
4494 BIND(&negative_check); 4614 BIND(&negative_check);
4495 Branch(SmiLessThan(result.value(), SmiConstant(0)), &return_zero, &done); 4615 Branch(SmiLessThan(result.value(), SmiConstant(0)), &return_zero, &done);
4496 4616
4497 BIND(&return_zero); 4617 BIND(&return_zero);
4498 result.Bind(SmiConstant(0)); 4618 result.Bind(SmiConstant(0));
4499 Goto(&done); 4619 Goto(&done);
4500 4620
4501 BIND(&done); 4621 BIND(&done);
4622 CSA_SLOW_ASSERT(this, TaggedIsSmi(result.value()));
4502 return result.value(); 4623 return result.value();
4503 } 4624 }
4504 4625
4505 Node* CodeStubAssembler::ToInteger(Node* context, Node* input, 4626 Node* CodeStubAssembler::ToInteger(Node* context, Node* input,
4506 ToIntegerTruncationMode mode) { 4627 ToIntegerTruncationMode mode) {
4507 // We might need to loop once for ToNumber conversion. 4628 // We might need to loop once for ToNumber conversion.
4508 VARIABLE(var_arg, MachineRepresentation::kTagged, input); 4629 VARIABLE(var_arg, MachineRepresentation::kTagged, input);
4509 Label loop(this, &var_arg), out(this); 4630 Label loop(this, &var_arg), out(this);
4510 Goto(&loop); 4631 Goto(&loop);
4511 BIND(&loop); 4632 BIND(&loop);
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
4552 var_arg.Bind(CallStub(callable, context, arg)); 4673 var_arg.Bind(CallStub(callable, context, arg));
4553 Goto(&loop); 4674 Goto(&loop);
4554 } 4675 }
4555 4676
4556 BIND(&return_zero); 4677 BIND(&return_zero);
4557 var_arg.Bind(SmiConstant(Smi::kZero)); 4678 var_arg.Bind(SmiConstant(Smi::kZero));
4558 Goto(&out); 4679 Goto(&out);
4559 } 4680 }
4560 4681
4561 BIND(&out); 4682 BIND(&out);
4683 CSA_SLOW_ASSERT(this, IsNumber(var_arg.value()));
4562 return var_arg.value(); 4684 return var_arg.value();
4563 } 4685 }
4564 4686
4565 Node* CodeStubAssembler::DecodeWord32(Node* word32, uint32_t shift, 4687 Node* CodeStubAssembler::DecodeWord32(Node* word32, uint32_t shift,
4566 uint32_t mask) { 4688 uint32_t mask) {
4567 return Word32Shr(Word32And(word32, Int32Constant(mask)), 4689 return Word32Shr(Word32And(word32, Int32Constant(mask)),
4568 static_cast<int>(shift)); 4690 static_cast<int>(shift));
4569 } 4691 }
4570 4692
4571 Node* CodeStubAssembler::DecodeWord(Node* word, uint32_t shift, uint32_t mask) { 4693 Node* CodeStubAssembler::DecodeWord(Node* word, uint32_t shift, uint32_t mask) {
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
4668 BIND(&if_hascachedindex); 4790 BIND(&if_hascachedindex);
4669 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash)); 4791 var_index->Bind(DecodeWordFromWord32<Name::ArrayIndexValueBits>(hash));
4670 Goto(if_keyisindex); 4792 Goto(if_keyisindex);
4671 } 4793 }
4672 4794
4673 void CodeStubAssembler::TryInternalizeString( 4795 void CodeStubAssembler::TryInternalizeString(
4674 Node* string, Label* if_index, Variable* var_index, Label* if_internalized, 4796 Node* string, Label* if_index, Variable* var_index, Label* if_internalized,
4675 Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) { 4797 Variable* var_internalized, Label* if_not_internalized, Label* if_bailout) {
4676 DCHECK(var_index->rep() == MachineType::PointerRepresentation()); 4798 DCHECK(var_index->rep() == MachineType::PointerRepresentation());
4677 DCHECK(var_internalized->rep() == MachineRepresentation::kTagged); 4799 DCHECK(var_internalized->rep() == MachineRepresentation::kTagged);
4800 CSA_SLOW_ASSERT(this, IsString(string));
4678 Node* function = ExternalConstant( 4801 Node* function = ExternalConstant(
4679 ExternalReference::try_internalize_string_function(isolate())); 4802 ExternalReference::try_internalize_string_function(isolate()));
4680 Node* result = CallCFunction1(MachineType::AnyTagged(), 4803 Node* result = CallCFunction1(MachineType::AnyTagged(),
4681 MachineType::AnyTagged(), function, string); 4804 MachineType::AnyTagged(), function, string);
4682 Label internalized(this); 4805 Label internalized(this);
4683 GotoIf(TaggedIsNotSmi(result), &internalized); 4806 GotoIf(TaggedIsNotSmi(result), &internalized);
4684 Node* word_result = SmiUntag(result); 4807 Node* word_result = SmiUntag(result);
4685 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kNotFound)), 4808 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kNotFound)),
4686 if_not_internalized); 4809 if_not_internalized);
4687 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kUnsupported)), 4810 GotoIf(WordEqual(word_result, IntPtrConstant(ResultSentinel::kUnsupported)),
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
4915 void CodeStubAssembler::InsertEntry(Node* dictionary, Node* key, Node* value, 5038 void CodeStubAssembler::InsertEntry(Node* dictionary, Node* key, Node* value,
4916 Node* index, Node* enum_index) { 5039 Node* index, Node* enum_index) {
4917 UNREACHABLE(); // Use specializations instead. 5040 UNREACHABLE(); // Use specializations instead.
4918 } 5041 }
4919 5042
4920 template <> 5043 template <>
4921 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary, 5044 void CodeStubAssembler::InsertEntry<NameDictionary>(Node* dictionary,
4922 Node* name, Node* value, 5045 Node* name, Node* value,
4923 Node* index, 5046 Node* index,
4924 Node* enum_index) { 5047 Node* enum_index) {
5048 CSA_SLOW_ASSERT(this, IsDictionary(dictionary));
5049
4925 // Store name and value. 5050 // Store name and value.
4926 StoreFixedArrayElement(dictionary, index, name); 5051 StoreFixedArrayElement(dictionary, index, name);
4927 StoreValueByKeyIndex<NameDictionary>(dictionary, index, value); 5052 StoreValueByKeyIndex<NameDictionary>(dictionary, index, value);
4928 5053
4929 // Prepare details of the new property. 5054 // Prepare details of the new property.
4930 const int kInitialIndex = 0; 5055 const int kInitialIndex = 0;
4931 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell); 5056 PropertyDetails d(kData, NONE, kInitialIndex, PropertyCellType::kNoCell);
4932 enum_index = 5057 enum_index =
4933 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift); 5058 SmiShl(enum_index, PropertyDetails::DictionaryStorageField::kShift);
4934 STATIC_ASSERT(kInitialIndex == 0); 5059 STATIC_ASSERT(kInitialIndex == 0);
(...skipping 21 matching lines...) Expand all
4956 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary, 5081 void CodeStubAssembler::InsertEntry<GlobalDictionary>(Node* dictionary,
4957 Node* key, Node* value, 5082 Node* key, Node* value,
4958 Node* index, 5083 Node* index,
4959 Node* enum_index) { 5084 Node* enum_index) {
4960 UNIMPLEMENTED(); 5085 UNIMPLEMENTED();
4961 } 5086 }
4962 5087
4963 template <class Dictionary> 5088 template <class Dictionary>
4964 void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value, 5089 void CodeStubAssembler::Add(Node* dictionary, Node* key, Node* value,
4965 Label* bailout) { 5090 Label* bailout) {
5091 CSA_SLOW_ASSERT(this, IsDictionary(dictionary));
4966 Node* capacity = GetCapacity<Dictionary>(dictionary); 5092 Node* capacity = GetCapacity<Dictionary>(dictionary);
4967 Node* nof = GetNumberOfElements<Dictionary>(dictionary); 5093 Node* nof = GetNumberOfElements<Dictionary>(dictionary);
4968 Node* new_nof = SmiAdd(nof, SmiConstant(1)); 5094 Node* new_nof = SmiAdd(nof, SmiConstant(1));
4969 // Require 33% to still be free after adding additional_elements. 5095 // Require 33% to still be free after adding additional_elements.
4970 // Computing "x + (x >> 1)" on a Smi x does not return a valid Smi! 5096 // Computing "x + (x >> 1)" on a Smi x does not return a valid Smi!
4971 // But that's OK here because it's only used for a comparison. 5097 // But that's OK here because it's only used for a comparison.
4972 Node* required_capacity_pseudo_smi = SmiAdd(new_nof, SmiShr(new_nof, 1)); 5098 Node* required_capacity_pseudo_smi = SmiAdd(new_nof, SmiShr(new_nof, 1));
4973 GotoIf(SmiBelow(capacity, required_capacity_pseudo_smi), bailout); 5099 GotoIf(SmiBelow(capacity, required_capacity_pseudo_smi), bailout);
4974 // Require rehashing if more than 50% of free elements are deleted elements. 5100 // Require rehashing if more than 50% of free elements are deleted elements.
4975 Node* deleted = GetNumberOfDeletedElements<Dictionary>(dictionary); 5101 Node* deleted = GetNumberOfDeletedElements<Dictionary>(dictionary);
(...skipping 1617 matching lines...) Expand 10 before | Expand all | Expand 10 after
6593 // Store the WeakCell in the feedback vector. 6719 // Store the WeakCell in the feedback vector.
6594 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 0, 6720 StoreFixedArrayElement(feedback_vector, slot, cell, UPDATE_WRITE_BARRIER, 0,
6595 CodeStubAssembler::SMI_PARAMETERS); 6721 CodeStubAssembler::SMI_PARAMETERS);
6596 return cell; 6722 return cell;
6597 } 6723 }
6598 6724
6599 Node* CodeStubAssembler::BuildFastLoop( 6725 Node* CodeStubAssembler::BuildFastLoop(
6600 const CodeStubAssembler::VariableList& vars, Node* start_index, 6726 const CodeStubAssembler::VariableList& vars, Node* start_index,
6601 Node* end_index, const FastLoopBody& body, int increment, 6727 Node* end_index, const FastLoopBody& body, int increment,
6602 ParameterMode parameter_mode, IndexAdvanceMode advance_mode) { 6728 ParameterMode parameter_mode, IndexAdvanceMode advance_mode) {
6729 CSA_SLOW_ASSERT(this, IsParameterMode(start_index, parameter_mode));
6730 CSA_SLOW_ASSERT(this, IsParameterMode(end_index, parameter_mode));
6603 MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS) 6731 MachineRepresentation index_rep = (parameter_mode == INTPTR_PARAMETERS)
6604 ? MachineType::PointerRepresentation() 6732 ? MachineType::PointerRepresentation()
6605 : MachineRepresentation::kTaggedSigned; 6733 : MachineRepresentation::kTaggedSigned;
6606 VARIABLE(var, index_rep, start_index); 6734 VARIABLE(var, index_rep, start_index);
6607 VariableList vars_copy(vars, zone()); 6735 VariableList vars_copy(vars, zone());
6608 vars_copy.Add(&var, zone()); 6736 vars_copy.Add(&var, zone());
6609 Label loop(this, vars_copy); 6737 Label loop(this, vars_copy);
6610 Label after_loop(this); 6738 Label after_loop(this);
6611 // Introduce an explicit second check of the termination condition before the 6739 // Introduce an explicit second check of the termination condition before the
6612 // loop that helps turbofan generate better code. If there's only a single 6740 // loop that helps turbofan generate better code. If there's only a single
(...skipping 17 matching lines...) Expand all
6630 BIND(&after_loop); 6758 BIND(&after_loop);
6631 return var.value(); 6759 return var.value();
6632 } 6760 }
6633 6761
6634 void CodeStubAssembler::BuildFastFixedArrayForEach( 6762 void CodeStubAssembler::BuildFastFixedArrayForEach(
6635 const CodeStubAssembler::VariableList& vars, Node* fixed_array, 6763 const CodeStubAssembler::VariableList& vars, Node* fixed_array,
6636 ElementsKind kind, Node* first_element_inclusive, 6764 ElementsKind kind, Node* first_element_inclusive,
6637 Node* last_element_exclusive, const FastFixedArrayForEachBody& body, 6765 Node* last_element_exclusive, const FastFixedArrayForEachBody& body,
6638 ParameterMode mode, ForEachDirection direction) { 6766 ParameterMode mode, ForEachDirection direction) {
6639 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize); 6767 STATIC_ASSERT(FixedArray::kHeaderSize == FixedDoubleArray::kHeaderSize);
6768 CSA_SLOW_ASSERT(this, IsParameterMode(first_element_inclusive, mode));
6769 CSA_SLOW_ASSERT(this, IsParameterMode(last_element_exclusive, mode));
6770 CSA_SLOW_ASSERT(this, IsFixedArray(fixed_array));
6640 int32_t first_val; 6771 int32_t first_val;
6641 bool constant_first = ToInt32Constant(first_element_inclusive, first_val); 6772 bool constant_first = ToInt32Constant(first_element_inclusive, first_val);
6642 int32_t last_val; 6773 int32_t last_val;
6643 bool constent_last = ToInt32Constant(last_element_exclusive, last_val); 6774 bool constent_last = ToInt32Constant(last_element_exclusive, last_val);
6644 if (constant_first && constent_last) { 6775 if (constant_first && constent_last) {
6645 int delta = last_val - first_val; 6776 int delta = last_val - first_val;
6646 DCHECK(delta >= 0); 6777 DCHECK(delta >= 0);
6647 if (delta <= kElementLoopUnrollThreshold) { 6778 if (delta <= kElementLoopUnrollThreshold) {
6648 if (direction == ForEachDirection::kForward) { 6779 if (direction == ForEachDirection::kForward) {
6649 for (int i = first_val; i < last_val; ++i) { 6780 for (int i = first_val; i < last_val; ++i) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
6690 (kMaxRegularHeapObjectSize - base_size) / kPointerSize; 6821 (kMaxRegularHeapObjectSize - base_size) / kPointerSize;
6691 GotoIf(IntPtrOrSmiGreaterThan( 6822 GotoIf(IntPtrOrSmiGreaterThan(
6692 element_count, IntPtrOrSmiConstant(max_newspace_parameters, mode), 6823 element_count, IntPtrOrSmiConstant(max_newspace_parameters, mode),
6693 mode), 6824 mode),
6694 doesnt_fit); 6825 doesnt_fit);
6695 } 6826 }
6696 6827
6697 void CodeStubAssembler::InitializeFieldsWithRoot( 6828 void CodeStubAssembler::InitializeFieldsWithRoot(
6698 Node* object, Node* start_offset, Node* end_offset, 6829 Node* object, Node* start_offset, Node* end_offset,
6699 Heap::RootListIndex root_index) { 6830 Heap::RootListIndex root_index) {
6831 CSA_SLOW_ASSERT(this, TaggedIsNotSmi(object));
6700 start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag)); 6832 start_offset = IntPtrAdd(start_offset, IntPtrConstant(-kHeapObjectTag));
6701 end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag)); 6833 end_offset = IntPtrAdd(end_offset, IntPtrConstant(-kHeapObjectTag));
6702 Node* root_value = LoadRoot(root_index); 6834 Node* root_value = LoadRoot(root_index);
6703 BuildFastLoop(end_offset, start_offset, 6835 BuildFastLoop(end_offset, start_offset,
6704 [this, object, root_value](Node* current) { 6836 [this, object, root_value](Node* current) {
6705 StoreNoWriteBarrier(MachineRepresentation::kTagged, object, 6837 StoreNoWriteBarrier(MachineRepresentation::kTagged, object,
6706 current, root_value); 6838 current, root_value);
6707 }, 6839 },
6708 -kPointerSize, INTPTR_PARAMETERS, 6840 -kPointerSize, INTPTR_PARAMETERS,
6709 CodeStubAssembler::IndexAdvanceMode::kPre); 6841 CodeStubAssembler::IndexAdvanceMode::kPre);
6710 } 6842 }
6711 6843
6712 void CodeStubAssembler::BranchIfNumericRelationalComparison( 6844 void CodeStubAssembler::BranchIfNumericRelationalComparison(
6713 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true, 6845 RelationalComparisonMode mode, Node* lhs, Node* rhs, Label* if_true,
6714 Label* if_false) { 6846 Label* if_false) {
6847 CSA_SLOW_ASSERT(this, IsNumber(lhs));
6848 CSA_SLOW_ASSERT(this, IsNumber(rhs));
6849
6715 Label end(this); 6850 Label end(this);
6716 VARIABLE(result, MachineRepresentation::kTagged); 6851 VARIABLE(result, MachineRepresentation::kTagged);
6717 6852
6718 // Shared entry for floating point comparison. 6853 // Shared entry for floating point comparison.
6719 Label do_fcmp(this); 6854 Label do_fcmp(this);
6720 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); 6855 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64);
6721 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); 6856 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64);
6722 6857
6723 // Check if the {lhs} is a Smi or a HeapObject. 6858 // Check if the {lhs} is a Smi or a HeapObject.
6724 Label if_lhsissmi(this), if_lhsisnotsmi(this); 6859 Label if_lhsissmi(this), if_lhsisnotsmi(this);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
6816 void CodeStubAssembler::GotoUnlessNumberLessThan(Node* lhs, Node* rhs, 6951 void CodeStubAssembler::GotoUnlessNumberLessThan(Node* lhs, Node* rhs,
6817 Label* if_false) { 6952 Label* if_false) {
6818 Label if_true(this); 6953 Label if_true(this);
6819 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false); 6954 BranchIfNumericRelationalComparison(kLessThan, lhs, rhs, &if_true, if_false);
6820 BIND(&if_true); 6955 BIND(&if_true);
6821 } 6956 }
6822 6957
6823 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode, 6958 Node* CodeStubAssembler::RelationalComparison(RelationalComparisonMode mode,
6824 Node* lhs, Node* rhs, 6959 Node* lhs, Node* rhs,
6825 Node* context) { 6960 Node* context) {
6961 CSA_SLOW_ASSERT(this, IsNumber(lhs));
6962 CSA_SLOW_ASSERT(this, IsNumber(rhs));
6963
6826 Label return_true(this), return_false(this), end(this); 6964 Label return_true(this), return_false(this), end(this);
6827 VARIABLE(result, MachineRepresentation::kTagged); 6965 VARIABLE(result, MachineRepresentation::kTagged);
6828 6966
6829 // Shared entry for floating point comparison. 6967 // Shared entry for floating point comparison.
6830 Label do_fcmp(this); 6968 Label do_fcmp(this);
6831 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64); 6969 VARIABLE(var_fcmp_lhs, MachineRepresentation::kFloat64);
6832 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64); 6970 VARIABLE(var_fcmp_rhs, MachineRepresentation::kFloat64);
6833 6971
6834 // We might need to loop several times due to ToPrimitive and/or ToNumber 6972 // We might need to loop several times due to ToPrimitive and/or ToNumber
6835 // conversions. 6973 // conversions.
(...skipping 1481 matching lines...) Expand 10 before | Expand all | Expand 10 after
8317 8455
8318 BIND(&return_false); 8456 BIND(&return_false);
8319 var_result.Bind(FalseConstant()); 8457 var_result.Bind(FalseConstant());
8320 Goto(&return_result); 8458 Goto(&return_result);
8321 8459
8322 BIND(&return_result); 8460 BIND(&return_result);
8323 return var_result.value(); 8461 return var_result.value();
8324 } 8462 }
8325 8463
8326 Node* CodeStubAssembler::NumberInc(Node* value) { 8464 Node* CodeStubAssembler::NumberInc(Node* value) {
8465 CSA_SLOW_ASSERT(this, IsNumber(value));
8466
8327 VARIABLE(var_result, MachineRepresentation::kTagged); 8467 VARIABLE(var_result, MachineRepresentation::kTagged);
8328 VARIABLE(var_finc_value, MachineRepresentation::kFloat64); 8468 VARIABLE(var_finc_value, MachineRepresentation::kFloat64);
8329 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this); 8469 Label if_issmi(this), if_isnotsmi(this), do_finc(this), end(this);
8330 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); 8470 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
8331 8471
8332 BIND(&if_issmi); 8472 BIND(&if_issmi);
8333 { 8473 {
8334 // Try fast Smi addition first. 8474 // Try fast Smi addition first.
8335 Node* one = SmiConstant(Smi::FromInt(1)); 8475 Node* one = SmiConstant(Smi::FromInt(1));
8336 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value), 8476 Node* pair = IntPtrAddWithOverflow(BitcastTaggedToWord(value),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
8369 Node* finc_result = Float64Add(finc_value, one); 8509 Node* finc_result = Float64Add(finc_value, one);
8370 var_result.Bind(AllocateHeapNumberWithValue(finc_result)); 8510 var_result.Bind(AllocateHeapNumberWithValue(finc_result));
8371 Goto(&end); 8511 Goto(&end);
8372 } 8512 }
8373 8513
8374 BIND(&end); 8514 BIND(&end);
8375 return var_result.value(); 8515 return var_result.value();
8376 } 8516 }
8377 8517
8378 Node* CodeStubAssembler::NumberDec(Node* value) { 8518 Node* CodeStubAssembler::NumberDec(Node* value) {
8519 CSA_SLOW_ASSERT(this, IsNumber(value));
8520
8379 VARIABLE(var_result, MachineRepresentation::kTagged); 8521 VARIABLE(var_result, MachineRepresentation::kTagged);
8380 VARIABLE(var_fdec_value, MachineRepresentation::kFloat64); 8522 VARIABLE(var_fdec_value, MachineRepresentation::kFloat64);
8381 Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this); 8523 Label if_issmi(this), if_isnotsmi(this), do_fdec(this), end(this);
8382 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi); 8524 Branch(TaggedIsSmi(value), &if_issmi, &if_isnotsmi);
8383 8525
8384 BIND(&if_issmi); 8526 BIND(&if_issmi);
8385 { 8527 {
8386 // Try fast Smi addition first. 8528 // Try fast Smi addition first.
8387 Node* one = SmiConstant(Smi::FromInt(1)); 8529 Node* one = SmiConstant(Smi::FromInt(1));
8388 Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value), 8530 Node* pair = IntPtrSubWithOverflow(BitcastTaggedToWord(value),
(...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after
8773 Load(MachineType::Uint8(), 8915 Load(MachineType::Uint8(),
8774 ExternalConstant( 8916 ExternalConstant(
8775 ExternalReference::promise_hook_or_debug_is_active_address( 8917 ExternalReference::promise_hook_or_debug_is_active_address(
8776 isolate()))); 8918 isolate())));
8777 return Word32NotEqual(promise_hook_or_debug_is_active, Int32Constant(0)); 8919 return Word32NotEqual(promise_hook_or_debug_is_active, Int32Constant(0));
8778 } 8920 }
8779 8921
8780 Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map, 8922 Node* CodeStubAssembler::AllocateFunctionWithMapAndContext(Node* map,
8781 Node* shared_info, 8923 Node* shared_info,
8782 Node* context) { 8924 Node* context) {
8925 CSA_SLOW_ASSERT(this, IsMap(map));
8926
8783 Node* const code = BitcastTaggedToWord( 8927 Node* const code = BitcastTaggedToWord(
8784 LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset)); 8928 LoadObjectField(shared_info, SharedFunctionInfo::kCodeOffset));
8785 Node* const code_entry = 8929 Node* const code_entry =
8786 IntPtrAdd(code, IntPtrConstant(Code::kHeaderSize - kHeapObjectTag)); 8930 IntPtrAdd(code, IntPtrConstant(Code::kHeaderSize - kHeapObjectTag));
8787 8931
8788 Node* const fun = Allocate(JSFunction::kSize); 8932 Node* const fun = Allocate(JSFunction::kSize);
8789 StoreMapNoWriteBarrier(fun, map); 8933 StoreMapNoWriteBarrier(fun, map);
8790 StoreObjectFieldRoot(fun, JSObject::kPropertiesOffset, 8934 StoreObjectFieldRoot(fun, JSObject::kPropertiesOffset,
8791 Heap::kEmptyFixedArrayRootIndex); 8935 Heap::kEmptyFixedArrayRootIndex);
8792 StoreObjectFieldRoot(fun, JSObject::kElementsOffset, 8936 StoreObjectFieldRoot(fun, JSObject::kElementsOffset,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
8859 formatted.c_str(), TENURED); 9003 formatted.c_str(), TENURED);
8860 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(), 9004 CallRuntime(Runtime::kGlobalPrint, NoContextConstant(),
8861 HeapConstant(string)); 9005 HeapConstant(string));
8862 } 9006 }
8863 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value); 9007 CallRuntime(Runtime::kDebugPrint, NoContextConstant(), tagged_value);
8864 #endif 9008 #endif
8865 } 9009 }
8866 9010
8867 } // namespace internal 9011 } // namespace internal
8868 } // namespace v8 9012 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698