OLD | NEW |
---|---|
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 #include "src/code-stub-assembler.h" | 4 #include "src/code-stub-assembler.h" |
5 #include "src/code-factory.h" | 5 #include "src/code-factory.h" |
6 #include "src/frames-inl.h" | 6 #include "src/frames-inl.h" |
7 #include "src/frames.h" | 7 #include "src/frames.h" |
8 #include "src/ic/handler-configuration.h" | 8 #include "src/ic/handler-configuration.h" |
9 #include "src/ic/stub-cache.h" | 9 #include "src/ic/stub-cache.h" |
10 | 10 |
(...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1006 } | 1006 } |
1007 | 1007 |
1008 Node* CodeStubAssembler::LoadProperties(Node* object) { | 1008 Node* CodeStubAssembler::LoadProperties(Node* object) { |
1009 return LoadObjectField(object, JSObject::kPropertiesOffset); | 1009 return LoadObjectField(object, JSObject::kPropertiesOffset); |
1010 } | 1010 } |
1011 | 1011 |
1012 Node* CodeStubAssembler::LoadElements(Node* object) { | 1012 Node* CodeStubAssembler::LoadElements(Node* object) { |
1013 return LoadObjectField(object, JSObject::kElementsOffset); | 1013 return LoadObjectField(object, JSObject::kElementsOffset); |
1014 } | 1014 } |
1015 | 1015 |
1016 Node* CodeStubAssembler::LoadJSArrayLength(compiler::Node* array) { | 1016 Node* CodeStubAssembler::LoadJSArrayLength(Node* array) { |
1017 CSA_ASSERT(IsJSArray(array)); | |
1017 return LoadObjectField(array, JSArray::kLengthOffset); | 1018 return LoadObjectField(array, JSArray::kLengthOffset); |
1018 } | 1019 } |
1019 | 1020 |
1020 Node* CodeStubAssembler::LoadFixedArrayBaseLength(compiler::Node* array) { | 1021 Node* CodeStubAssembler::LoadFixedArrayBaseLength(Node* array) { |
1021 return LoadObjectField(array, FixedArrayBase::kLengthOffset); | 1022 return LoadObjectField(array, FixedArrayBase::kLengthOffset); |
1022 } | 1023 } |
1023 | 1024 |
1024 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) { | 1025 Node* CodeStubAssembler::LoadAndUntagFixedArrayBaseLength(Node* array) { |
1025 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset); | 1026 return LoadAndUntagObjectField(array, FixedArrayBase::kLengthOffset); |
1026 } | 1027 } |
1027 | 1028 |
1028 Node* CodeStubAssembler::LoadMapBitField(Node* map) { | 1029 Node* CodeStubAssembler::LoadMapBitField(Node* map) { |
1030 CSA_ASSERT(IsMap(map)); | |
1029 return LoadObjectField(map, Map::kBitFieldOffset, MachineType::Uint8()); | 1031 return LoadObjectField(map, Map::kBitFieldOffset, MachineType::Uint8()); |
1030 } | 1032 } |
1031 | 1033 |
1032 Node* CodeStubAssembler::LoadMapBitField2(Node* map) { | 1034 Node* CodeStubAssembler::LoadMapBitField2(Node* map) { |
1035 CSA_ASSERT(IsMap(map)); | |
1033 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8()); | 1036 return LoadObjectField(map, Map::kBitField2Offset, MachineType::Uint8()); |
1034 } | 1037 } |
1035 | 1038 |
1036 Node* CodeStubAssembler::LoadMapBitField3(Node* map) { | 1039 Node* CodeStubAssembler::LoadMapBitField3(Node* map) { |
1040 CSA_ASSERT(IsMap(map)); | |
1037 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32()); | 1041 return LoadObjectField(map, Map::kBitField3Offset, MachineType::Uint32()); |
1038 } | 1042 } |
1039 | 1043 |
1040 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { | 1044 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { |
1041 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); | 1045 return LoadObjectField(map, Map::kInstanceTypeOffset, MachineType::Uint8()); |
1042 } | 1046 } |
1043 | 1047 |
1044 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) { | 1048 Node* CodeStubAssembler::LoadMapElementsKind(Node* map) { |
1045 Node* bit_field2 = LoadMapBitField2(map); | 1049 Node* bit_field2 = LoadMapBitField2(map); |
1046 return DecodeWord32<Map::ElementsKindBits>(bit_field2); | 1050 return DecodeWord32<Map::ElementsKindBits>(bit_field2); |
1047 } | 1051 } |
1048 | 1052 |
1049 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { | 1053 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { |
1054 CSA_ASSERT(IsMap(map)); | |
1050 return LoadObjectField(map, Map::kDescriptorsOffset); | 1055 return LoadObjectField(map, Map::kDescriptorsOffset); |
1051 } | 1056 } |
1052 | 1057 |
1053 Node* CodeStubAssembler::LoadMapPrototype(Node* map) { | 1058 Node* CodeStubAssembler::LoadMapPrototype(Node* map) { |
1059 CSA_ASSERT(IsMap(map)); | |
1054 return LoadObjectField(map, Map::kPrototypeOffset); | 1060 return LoadObjectField(map, Map::kPrototypeOffset); |
1055 } | 1061 } |
1056 | 1062 |
1057 Node* CodeStubAssembler::LoadMapPrototypeInfo(Node* map, | 1063 Node* CodeStubAssembler::LoadMapPrototypeInfo(Node* map, |
1058 Label* if_no_proto_info) { | 1064 Label* if_no_proto_info) { |
1065 CSA_ASSERT(IsMap(map)); | |
1059 Node* prototype_info = | 1066 Node* prototype_info = |
1060 LoadObjectField(map, Map::kTransitionsOrPrototypeInfoOffset); | 1067 LoadObjectField(map, Map::kTransitionsOrPrototypeInfoOffset); |
1061 GotoIf(TaggedIsSmi(prototype_info), if_no_proto_info); | 1068 GotoIf(TaggedIsSmi(prototype_info), if_no_proto_info); |
1062 GotoUnless(WordEqual(LoadMap(prototype_info), | 1069 GotoUnless(WordEqual(LoadMap(prototype_info), |
1063 LoadRoot(Heap::kPrototypeInfoMapRootIndex)), | 1070 LoadRoot(Heap::kPrototypeInfoMapRootIndex)), |
1064 if_no_proto_info); | 1071 if_no_proto_info); |
1065 return prototype_info; | 1072 return prototype_info; |
1066 } | 1073 } |
1067 | 1074 |
1068 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) { | 1075 Node* CodeStubAssembler::LoadMapInstanceSize(Node* map) { |
1076 CSA_ASSERT(IsMap(map)); | |
1069 return ChangeUint32ToWord( | 1077 return ChangeUint32ToWord( |
1070 LoadObjectField(map, Map::kInstanceSizeOffset, MachineType::Uint8())); | 1078 LoadObjectField(map, Map::kInstanceSizeOffset, MachineType::Uint8())); |
1071 } | 1079 } |
1072 | 1080 |
1073 Node* CodeStubAssembler::LoadMapInobjectProperties(Node* map) { | 1081 Node* CodeStubAssembler::LoadMapInobjectProperties(Node* map) { |
1082 CSA_ASSERT(IsMap(map)); | |
1074 // See Map::GetInObjectProperties() for details. | 1083 // See Map::GetInObjectProperties() for details. |
1075 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE); | 1084 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE); |
1076 CSA_ASSERT(Int32GreaterThanOrEqual(LoadMapInstanceType(map), | 1085 CSA_ASSERT(Int32GreaterThanOrEqual(LoadMapInstanceType(map), |
1077 Int32Constant(FIRST_JS_OBJECT_TYPE))); | 1086 Int32Constant(FIRST_JS_OBJECT_TYPE))); |
1078 return ChangeUint32ToWord(LoadObjectField( | 1087 return ChangeUint32ToWord(LoadObjectField( |
1079 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, | 1088 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, |
1080 MachineType::Uint8())); | 1089 MachineType::Uint8())); |
1081 } | 1090 } |
1082 | 1091 |
1083 Node* CodeStubAssembler::LoadMapConstructorFunctionIndex(Node* map) { | 1092 Node* CodeStubAssembler::LoadMapConstructorFunctionIndex(Node* map) { |
1093 CSA_ASSERT(IsMap(map)); | |
1084 // See Map::GetConstructorFunctionIndex() for details. | 1094 // See Map::GetConstructorFunctionIndex() for details. |
1085 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); | 1095 STATIC_ASSERT(FIRST_PRIMITIVE_TYPE == FIRST_TYPE); |
1086 CSA_ASSERT(Int32LessThanOrEqual(LoadMapInstanceType(map), | 1096 CSA_ASSERT(Int32LessThanOrEqual(LoadMapInstanceType(map), |
1087 Int32Constant(LAST_PRIMITIVE_TYPE))); | 1097 Int32Constant(LAST_PRIMITIVE_TYPE))); |
1088 return ChangeUint32ToWord(LoadObjectField( | 1098 return ChangeUint32ToWord(LoadObjectField( |
1089 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, | 1099 map, Map::kInObjectPropertiesOrConstructorFunctionIndexOffset, |
1090 MachineType::Uint8())); | 1100 MachineType::Uint8())); |
1091 } | 1101 } |
1092 | 1102 |
1093 Node* CodeStubAssembler::LoadMapConstructor(Node* map) { | 1103 Node* CodeStubAssembler::LoadMapConstructor(Node* map) { |
1104 CSA_ASSERT(IsMap(map)); | |
1094 Variable result(this, MachineRepresentation::kTagged); | 1105 Variable result(this, MachineRepresentation::kTagged); |
1095 result.Bind(LoadObjectField(map, Map::kConstructorOrBackPointerOffset)); | 1106 result.Bind(LoadObjectField(map, Map::kConstructorOrBackPointerOffset)); |
1096 | 1107 |
1097 Label done(this), loop(this, &result); | 1108 Label done(this), loop(this, &result); |
1098 Goto(&loop); | 1109 Goto(&loop); |
1099 Bind(&loop); | 1110 Bind(&loop); |
1100 { | 1111 { |
1101 GotoIf(TaggedIsSmi(result.value()), &done); | 1112 GotoIf(TaggedIsSmi(result.value()), &done); |
1102 Node* is_map_type = | 1113 Node* is_map_type = |
1103 Word32Equal(LoadInstanceType(result.value()), Int32Constant(MAP_TYPE)); | 1114 Word32Equal(LoadInstanceType(result.value()), Int32Constant(MAP_TYPE)); |
1104 GotoUnless(is_map_type, &done); | 1115 GotoUnless(is_map_type, &done); |
1105 result.Bind( | 1116 result.Bind( |
1106 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset)); | 1117 LoadObjectField(result.value(), Map::kConstructorOrBackPointerOffset)); |
1107 Goto(&loop); | 1118 Goto(&loop); |
1108 } | 1119 } |
1109 Bind(&done); | 1120 Bind(&done); |
1110 return result.value(); | 1121 return result.value(); |
1111 } | 1122 } |
1112 | 1123 |
1113 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { | |
1114 Node* bit_field = LoadMapBitField(map); | |
1115 Node* mask = Int32Constant(1 << Map::kHasNamedInterceptor | | |
1116 1 << Map::kIsAccessCheckNeeded); | |
1117 Assert(Word32Equal(Word32And(bit_field, mask), Int32Constant(0))); | |
1118 return IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); | |
1119 } | |
1120 | |
1121 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { | |
1122 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); | |
1123 return Int32LessThanOrEqual(instance_type, | |
1124 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); | |
1125 } | |
1126 | |
1127 Node* CodeStubAssembler::IsDictionaryMap(Node* map) { | 1124 Node* CodeStubAssembler::IsDictionaryMap(Node* map) { |
1128 Node* bit_field3 = LoadMapBitField3(map); | 1125 Node* bit_field3 = LoadMapBitField3(map); |
1129 return Word32NotEqual(IsSetWord32<Map::DictionaryMap>(bit_field3), | 1126 return Word32NotEqual(IsSetWord32<Map::DictionaryMap>(bit_field3), |
1130 Int32Constant(0)); | 1127 Int32Constant(0)); |
1131 } | 1128 } |
1132 | 1129 |
1133 Node* CodeStubAssembler::LoadNameHashField(Node* name) { | 1130 Node* CodeStubAssembler::LoadNameHashField(Node* name) { |
1131 CSA_ASSERT(IsName(name)); | |
1134 return LoadObjectField(name, Name::kHashFieldOffset, MachineType::Uint32()); | 1132 return LoadObjectField(name, Name::kHashFieldOffset, MachineType::Uint32()); |
1135 } | 1133 } |
1136 | 1134 |
1137 Node* CodeStubAssembler::LoadNameHash(Node* name, Label* if_hash_not_computed) { | 1135 Node* CodeStubAssembler::LoadNameHash(Node* name, Label* if_hash_not_computed) { |
1138 Node* hash_field = LoadNameHashField(name); | 1136 Node* hash_field = LoadNameHashField(name); |
1139 if (if_hash_not_computed != nullptr) { | 1137 if (if_hash_not_computed != nullptr) { |
1140 GotoIf(Word32Equal( | 1138 GotoIf(Word32Equal( |
1141 Word32And(hash_field, Int32Constant(Name::kHashNotComputedMask)), | 1139 Word32And(hash_field, Int32Constant(Name::kHashNotComputedMask)), |
1142 Int32Constant(0)), | 1140 Int32Constant(0)), |
1143 if_hash_not_computed); | 1141 if_hash_not_computed); |
1144 } | 1142 } |
1145 return Word32Shr(hash_field, Int32Constant(Name::kHashShift)); | 1143 return Word32Shr(hash_field, Int32Constant(Name::kHashShift)); |
1146 } | 1144 } |
1147 | 1145 |
1148 Node* CodeStubAssembler::LoadStringLength(Node* object) { | 1146 Node* CodeStubAssembler::LoadStringLength(Node* object) { |
1147 CSA_ASSERT(IsString(object)); | |
1149 return LoadObjectField(object, String::kLengthOffset); | 1148 return LoadObjectField(object, String::kLengthOffset); |
1150 } | 1149 } |
1151 | 1150 |
1152 Node* CodeStubAssembler::LoadJSValueValue(Node* object) { | 1151 Node* CodeStubAssembler::LoadJSValueValue(Node* object) { |
1152 CSA_ASSERT(IsJSValue(object)); | |
1153 return LoadObjectField(object, JSValue::kValueOffset); | 1153 return LoadObjectField(object, JSValue::kValueOffset); |
1154 } | 1154 } |
1155 | 1155 |
1156 Node* CodeStubAssembler::LoadWeakCellValueUnchecked(Node* weak_cell) { | |
1157 // TODO(ishell): fix callers. | |
1158 return LoadObjectField(weak_cell, WeakCell::kValueOffset); | |
1159 } | |
1160 | |
1156 Node* CodeStubAssembler::LoadWeakCellValue(Node* weak_cell, Label* if_cleared) { | 1161 Node* CodeStubAssembler::LoadWeakCellValue(Node* weak_cell, Label* if_cleared) { |
Igor Sheludko
2016/10/26 08:58:51
CSA_ASSERT(IsWeakCell(weak_cell));
| |
1157 Node* value = LoadObjectField(weak_cell, WeakCell::kValueOffset); | 1162 Node* value = LoadWeakCellValueUnchecked(weak_cell); |
1158 if (if_cleared != nullptr) { | 1163 if (if_cleared != nullptr) { |
1159 GotoIf(WordEqual(value, IntPtrConstant(0)), if_cleared); | 1164 GotoIf(WordEqual(value, IntPtrConstant(0)), if_cleared); |
1160 } | 1165 } |
1161 return value; | 1166 return value; |
1162 } | 1167 } |
1163 | 1168 |
1164 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, | 1169 Node* CodeStubAssembler::LoadFixedArrayElement(Node* object, Node* index_node, |
1165 int additional_offset, | 1170 int additional_offset, |
1166 ParameterMode parameter_mode) { | 1171 ParameterMode parameter_mode) { |
1167 int32_t header_size = | 1172 int32_t header_size = |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1224 if (Is64()) { | 1229 if (Is64()) { |
1225 return Load(MachineType::Int32(), object, offset); | 1230 return Load(MachineType::Int32(), object, offset); |
1226 } else { | 1231 } else { |
1227 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); | 1232 return SmiToWord32(Load(MachineType::AnyTagged(), object, offset)); |
1228 } | 1233 } |
1229 } | 1234 } |
1230 | 1235 |
1231 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( | 1236 Node* CodeStubAssembler::LoadFixedDoubleArrayElement( |
1232 Node* object, Node* index_node, MachineType machine_type, | 1237 Node* object, Node* index_node, MachineType machine_type, |
1233 int additional_offset, ParameterMode parameter_mode, Label* if_hole) { | 1238 int additional_offset, ParameterMode parameter_mode, Label* if_hole) { |
1239 CSA_ASSERT(IsFixedDoubleArray(object)); | |
1234 int32_t header_size = | 1240 int32_t header_size = |
1235 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; | 1241 FixedDoubleArray::kHeaderSize + additional_offset - kHeapObjectTag; |
1236 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, | 1242 Node* offset = ElementOffsetFromIndex(index_node, FAST_HOLEY_DOUBLE_ELEMENTS, |
1237 parameter_mode, header_size); | 1243 parameter_mode, header_size); |
1238 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type); | 1244 return LoadDoubleWithHoleCheck(object, offset, if_hole, machine_type); |
1239 } | 1245 } |
1240 | 1246 |
1241 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, | 1247 Node* CodeStubAssembler::LoadDoubleWithHoleCheck(Node* base, Node* offset, |
1242 Label* if_hole, | 1248 Label* if_hole, |
1243 MachineType machine_type) { | 1249 MachineType machine_type) { |
(...skipping 30 matching lines...) Expand all Loading... | |
1274 return Store(MachineRepresentation::kTagged, context, IntPtrConstant(offset), | 1280 return Store(MachineRepresentation::kTagged, context, IntPtrConstant(offset), |
1275 value); | 1281 value); |
1276 } | 1282 } |
1277 | 1283 |
1278 Node* CodeStubAssembler::LoadNativeContext(Node* context) { | 1284 Node* CodeStubAssembler::LoadNativeContext(Node* context) { |
1279 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); | 1285 return LoadContextElement(context, Context::NATIVE_CONTEXT_INDEX); |
1280 } | 1286 } |
1281 | 1287 |
1282 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, | 1288 Node* CodeStubAssembler::LoadJSArrayElementsMap(ElementsKind kind, |
1283 Node* native_context) { | 1289 Node* native_context) { |
1290 CSA_ASSERT(IsNativeContext(native_context)); | |
1284 return LoadFixedArrayElement(native_context, | 1291 return LoadFixedArrayElement(native_context, |
1285 IntPtrConstant(Context::ArrayMapIndex(kind))); | 1292 IntPtrConstant(Context::ArrayMapIndex(kind))); |
1286 } | 1293 } |
1287 | 1294 |
1288 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { | 1295 Node* CodeStubAssembler::StoreHeapNumberValue(Node* object, Node* value) { |
1289 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, | 1296 return StoreObjectFieldNoWriteBarrier(object, HeapNumber::kValueOffset, value, |
1290 MachineRepresentation::kFloat64); | 1297 MachineRepresentation::kFloat64); |
1291 } | 1298 } |
1292 | 1299 |
1293 Node* CodeStubAssembler::StoreObjectField( | 1300 Node* CodeStubAssembler::StoreObjectField( |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1349 MachineRepresentation rep = MachineRepresentation::kTagged; | 1356 MachineRepresentation rep = MachineRepresentation::kTagged; |
1350 if (barrier_mode == SKIP_WRITE_BARRIER) { | 1357 if (barrier_mode == SKIP_WRITE_BARRIER) { |
1351 return StoreNoWriteBarrier(rep, object, offset, value); | 1358 return StoreNoWriteBarrier(rep, object, offset, value); |
1352 } else { | 1359 } else { |
1353 return Store(rep, object, offset, value); | 1360 return Store(rep, object, offset, value); |
1354 } | 1361 } |
1355 } | 1362 } |
1356 | 1363 |
1357 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( | 1364 Node* CodeStubAssembler::StoreFixedDoubleArrayElement( |
1358 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { | 1365 Node* object, Node* index_node, Node* value, ParameterMode parameter_mode) { |
1366 CSA_ASSERT(IsFixedDoubleArray(object)); | |
1359 Node* offset = | 1367 Node* offset = |
1360 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, | 1368 ElementOffsetFromIndex(index_node, FAST_DOUBLE_ELEMENTS, parameter_mode, |
1361 FixedArray::kHeaderSize - kHeapObjectTag); | 1369 FixedArray::kHeaderSize - kHeapObjectTag); |
1362 MachineRepresentation rep = MachineRepresentation::kFloat64; | 1370 MachineRepresentation rep = MachineRepresentation::kFloat64; |
1363 return StoreNoWriteBarrier(rep, object, offset, value); | 1371 return StoreNoWriteBarrier(rep, object, offset, value); |
1364 } | 1372 } |
1365 | 1373 |
1366 Node* CodeStubAssembler::AllocateHeapNumber(MutableMode mode) { | 1374 Node* CodeStubAssembler::AllocateHeapNumber(MutableMode mode) { |
1367 Node* result = Allocate(HeapNumber::kSize, kNone); | 1375 Node* result = Allocate(HeapNumber::kSize, kNone); |
1368 Heap::RootListIndex heap_map_index = | 1376 Heap::RootListIndex heap_map_index = |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1493 CallRuntime(Runtime::kAllocateSeqTwoByteString, context, | 1501 CallRuntime(Runtime::kAllocateSeqTwoByteString, context, |
1494 mode == SMI_PARAMETERS ? length : SmiFromWord(length)); | 1502 mode == SMI_PARAMETERS ? length : SmiFromWord(length)); |
1495 var_result.Bind(result); | 1503 var_result.Bind(result); |
1496 Goto(&if_join); | 1504 Goto(&if_join); |
1497 } | 1505 } |
1498 | 1506 |
1499 Bind(&if_join); | 1507 Bind(&if_join); |
1500 return var_result.value(); | 1508 return var_result.value(); |
1501 } | 1509 } |
1502 | 1510 |
1503 Node* CodeStubAssembler::AllocateSlicedOneByteString(Node* length, Node* parent, | 1511 Node* CodeStubAssembler::AllocateSlicedString( |
1504 Node* offset) { | 1512 Heap::RootListIndex map_root_index, Node* length, Node* parent, |
1513 Node* offset) { | |
1514 CSA_ASSERT(TaggedIsSmi(length)); | |
1505 Node* result = Allocate(SlicedString::kSize); | 1515 Node* result = Allocate(SlicedString::kSize); |
1506 Node* map = LoadRoot(Heap::kSlicedOneByteStringMapRootIndex); | 1516 Node* map = LoadRoot(map_root_index); |
1517 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); | |
1507 StoreMapNoWriteBarrier(result, map); | 1518 StoreMapNoWriteBarrier(result, map); |
1508 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, | 1519 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, |
1509 MachineRepresentation::kTagged); | 1520 MachineRepresentation::kTagged); |
1510 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset, | 1521 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset, |
1511 Int32Constant(String::kEmptyHashField), | 1522 Int32Constant(String::kEmptyHashField), |
1512 MachineRepresentation::kWord32); | 1523 MachineRepresentation::kWord32); |
1513 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, | 1524 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, |
1514 MachineRepresentation::kTagged); | 1525 MachineRepresentation::kTagged); |
1515 StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset, | 1526 StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset, |
1516 MachineRepresentation::kTagged); | 1527 MachineRepresentation::kTagged); |
1517 return result; | 1528 return result; |
1518 } | 1529 } |
1519 | 1530 |
1531 Node* CodeStubAssembler::AllocateSlicedOneByteString(Node* length, Node* parent, | |
1532 Node* offset) { | |
1533 return AllocateSlicedString(Heap::kSlicedOneByteStringMapRootIndex, length, | |
1534 parent, offset); | |
1535 } | |
1536 | |
1520 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent, | 1537 Node* CodeStubAssembler::AllocateSlicedTwoByteString(Node* length, Node* parent, |
1521 Node* offset) { | 1538 Node* offset) { |
1522 CSA_ASSERT(TaggedIsSmi(length)); | 1539 return AllocateSlicedString(Heap::kSlicedStringMapRootIndex, length, parent, |
1523 Node* result = Allocate(SlicedString::kSize); | 1540 offset); |
1524 Node* map = LoadRoot(Heap::kSlicedStringMapRootIndex); | |
1525 StoreMapNoWriteBarrier(result, map); | |
1526 StoreObjectFieldNoWriteBarrier(result, SlicedString::kLengthOffset, length, | |
1527 MachineRepresentation::kTagged); | |
1528 StoreObjectFieldNoWriteBarrier(result, SlicedString::kHashFieldOffset, | |
1529 Int32Constant(String::kEmptyHashField), | |
1530 MachineRepresentation::kWord32); | |
1531 StoreObjectFieldNoWriteBarrier(result, SlicedString::kParentOffset, parent, | |
1532 MachineRepresentation::kTagged); | |
1533 StoreObjectFieldNoWriteBarrier(result, SlicedString::kOffsetOffset, offset, | |
1534 MachineRepresentation::kTagged); | |
1535 return result; | |
1536 } | 1541 } |
1537 | 1542 |
1538 Node* CodeStubAssembler::AllocateOneByteConsString(Node* length, Node* first, | 1543 Node* CodeStubAssembler::AllocateConsString(Heap::RootListIndex map_root_index, |
1539 Node* second, | 1544 Node* length, Node* first, |
1540 AllocationFlags flags) { | 1545 Node* second, |
1546 AllocationFlags flags) { | |
1541 CSA_ASSERT(TaggedIsSmi(length)); | 1547 CSA_ASSERT(TaggedIsSmi(length)); |
1542 Node* result = Allocate(ConsString::kSize, flags); | 1548 Node* result = Allocate(ConsString::kSize, flags); |
1543 Node* map = LoadRoot(Heap::kConsOneByteStringMapRootIndex); | 1549 Node* map = LoadRoot(map_root_index); |
1544 DCHECK(Heap::RootIsImmortalImmovable(Heap::kConsOneByteStringMapRootIndex)); | 1550 DCHECK(Heap::RootIsImmortalImmovable(map_root_index)); |
1545 StoreMapNoWriteBarrier(result, map); | 1551 StoreMapNoWriteBarrier(result, map); |
1546 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, | 1552 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, |
1547 MachineRepresentation::kTagged); | 1553 MachineRepresentation::kTagged); |
1548 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldOffset, | 1554 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldOffset, |
1549 Int32Constant(String::kEmptyHashField), | 1555 Int32Constant(String::kEmptyHashField), |
1550 MachineRepresentation::kWord32); | 1556 MachineRepresentation::kWord32); |
1551 bool const new_space = !(flags & kPretenured); | 1557 bool const new_space = !(flags & kPretenured); |
1552 if (new_space) { | 1558 if (new_space) { |
1553 StoreObjectFieldNoWriteBarrier(result, ConsString::kFirstOffset, first, | 1559 StoreObjectFieldNoWriteBarrier(result, ConsString::kFirstOffset, first, |
1554 MachineRepresentation::kTagged); | 1560 MachineRepresentation::kTagged); |
1555 StoreObjectFieldNoWriteBarrier(result, ConsString::kSecondOffset, second, | 1561 StoreObjectFieldNoWriteBarrier(result, ConsString::kSecondOffset, second, |
1556 MachineRepresentation::kTagged); | 1562 MachineRepresentation::kTagged); |
1557 } else { | 1563 } else { |
1558 StoreObjectField(result, ConsString::kFirstOffset, first); | 1564 StoreObjectField(result, ConsString::kFirstOffset, first); |
1559 StoreObjectField(result, ConsString::kSecondOffset, second); | 1565 StoreObjectField(result, ConsString::kSecondOffset, second); |
1560 } | 1566 } |
1561 return result; | 1567 return result; |
1562 } | 1568 } |
1563 | 1569 |
1570 Node* CodeStubAssembler::AllocateOneByteConsString(Node* length, Node* first, | |
1571 Node* second, | |
1572 AllocationFlags flags) { | |
1573 return AllocateConsString(Heap::kConsOneByteStringMapRootIndex, length, first, | |
1574 second, flags); | |
1575 } | |
1576 | |
1564 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, | 1577 Node* CodeStubAssembler::AllocateTwoByteConsString(Node* length, Node* first, |
1565 Node* second, | 1578 Node* second, |
1566 AllocationFlags flags) { | 1579 AllocationFlags flags) { |
1567 CSA_ASSERT(TaggedIsSmi(length)); | 1580 return AllocateConsString(Heap::kConsStringMapRootIndex, length, first, |
1568 Node* result = Allocate(ConsString::kSize, flags); | 1581 second, flags); |
1569 Node* map = LoadRoot(Heap::kConsStringMapRootIndex); | |
1570 DCHECK(Heap::RootIsImmortalImmovable(Heap::kConsStringMapRootIndex)); | |
1571 StoreMapNoWriteBarrier(result, map); | |
1572 StoreObjectFieldNoWriteBarrier(result, ConsString::kLengthOffset, length, | |
1573 MachineRepresentation::kTagged); | |
1574 StoreObjectFieldNoWriteBarrier(result, ConsString::kHashFieldOffset, | |
1575 Int32Constant(String::kEmptyHashField), | |
1576 MachineRepresentation::kWord32); | |
1577 bool const new_space = !(flags & kPretenured); | |
1578 if (new_space) { | |
1579 StoreObjectFieldNoWriteBarrier(result, ConsString::kFirstOffset, first, | |
1580 MachineRepresentation::kTagged); | |
1581 StoreObjectFieldNoWriteBarrier(result, ConsString::kSecondOffset, second, | |
1582 MachineRepresentation::kTagged); | |
1583 } else { | |
1584 StoreObjectField(result, ConsString::kFirstOffset, first); | |
1585 StoreObjectField(result, ConsString::kSecondOffset, second); | |
1586 } | |
1587 return result; | |
1588 } | 1582 } |
1589 | 1583 |
1590 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, | 1584 Node* CodeStubAssembler::NewConsString(Node* context, Node* length, Node* left, |
1591 Node* right, AllocationFlags flags) { | 1585 Node* right, AllocationFlags flags) { |
1592 CSA_ASSERT(TaggedIsSmi(length)); | 1586 CSA_ASSERT(TaggedIsSmi(length)); |
1593 // Added string can be a cons string. | 1587 // Added string can be a cons string. |
1594 Comment("Allocating ConsString"); | 1588 Comment("Allocating ConsString"); |
1595 Node* left_instance_type = LoadInstanceType(left); | 1589 Node* left_instance_type = LoadInstanceType(left); |
1596 Node* right_instance_type = LoadInstanceType(right); | 1590 Node* right_instance_type = LoadInstanceType(right); |
1597 | 1591 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1730 kHeapObjectTag)); | 1724 kHeapObjectTag)); |
1731 Node* end_address = IntPtrAdd( | 1725 Node* end_address = IntPtrAdd( |
1732 result, | 1726 result, |
1733 IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag))); | 1727 IntPtrSubFoldConstants(store_size, IntPtrConstant(kHeapObjectTag))); |
1734 StoreFieldsNoWriteBarrier(start_address, end_address, filler); | 1728 StoreFieldsNoWriteBarrier(start_address, end_address, filler); |
1735 return result; | 1729 return result; |
1736 } | 1730 } |
1737 | 1731 |
1738 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, | 1732 Node* CodeStubAssembler::AllocateJSObjectFromMap(Node* map, Node* properties, |
1739 Node* elements) { | 1733 Node* elements) { |
1734 CSA_ASSERT(IsMap(map)); | |
1740 Node* size = | 1735 Node* size = |
1741 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); | 1736 IntPtrMul(LoadMapInstanceSize(map), IntPtrConstant(kPointerSize)); |
1742 CSA_ASSERT(IsRegularHeapObjectSize(size)); | 1737 CSA_ASSERT(IsRegularHeapObjectSize(size)); |
1743 Node* object = Allocate(size); | 1738 Node* object = Allocate(size); |
1744 StoreMapNoWriteBarrier(object, map); | 1739 StoreMapNoWriteBarrier(object, map); |
1745 InitializeJSObjectFromMap(object, map, size, properties, elements); | 1740 InitializeJSObjectFromMap(object, map, size, properties, elements); |
1746 return object; | 1741 return object; |
1747 } | 1742 } |
1748 | 1743 |
1749 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, | 1744 void CodeStubAssembler::InitializeJSObjectFromMap(Node* object, Node* map, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1882 : IntPtrConstant(0), | 1877 : IntPtrConstant(0), |
1883 capacity, Heap::kTheHoleValueRootIndex, capacity_mode); | 1878 capacity, Heap::kTheHoleValueRootIndex, capacity_mode); |
1884 | 1879 |
1885 return array; | 1880 return array; |
1886 } | 1881 } |
1887 | 1882 |
1888 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, | 1883 Node* CodeStubAssembler::AllocateFixedArray(ElementsKind kind, |
1889 Node* capacity_node, | 1884 Node* capacity_node, |
1890 ParameterMode mode, | 1885 ParameterMode mode, |
1891 AllocationFlags flags) { | 1886 AllocationFlags flags) { |
1887 CSA_ASSERT(IntPtrGreaterThan(capacity_node, IntPtrConstant(0))); | |
Igor Sheludko
2016/10/26 08:58:51
SmiOrIntPtrConstant(0, mode) to be consistent.
Camillo Bruni
2016/10/26 13:10:41
done.
| |
1892 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); | 1888 Node* total_size = GetFixedArrayAllocationSize(capacity_node, kind, mode); |
1893 | 1889 |
1894 // Allocate both array and elements object, and initialize the JSArray. | 1890 // Allocate both array and elements object, and initialize the JSArray. |
1895 Node* array = Allocate(total_size, flags); | 1891 Node* array = Allocate(total_size, flags); |
1896 Heap* heap = isolate()->heap(); | 1892 Heap* heap = isolate()->heap(); |
1897 Handle<Map> map(IsFastDoubleElementsKind(kind) | 1893 Handle<Map> map(IsFastDoubleElementsKind(kind) |
1898 ? heap->fixed_double_array_map() | 1894 ? heap->fixed_double_array_map() |
1899 : heap->fixed_array_map()); | 1895 : heap->fixed_array_map()); |
1900 if (flags & kPretenured) { | 1896 if (flags & kPretenured) { |
1901 StoreObjectField(array, JSObject::kMapOffset, HeapConstant(map)); | 1897 StoreObjectField(array, JSObject::kMapOffset, HeapConstant(map)); |
(...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2628 Runtime::kThrowIncompatibleMethodReceiver, context, | 2624 Runtime::kThrowIncompatibleMethodReceiver, context, |
2629 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)), | 2625 HeapConstant(factory()->NewStringFromAsciiChecked(method_name, TENURED)), |
2630 value); | 2626 value); |
2631 var_value_map.Bind(UndefinedConstant()); | 2627 var_value_map.Bind(UndefinedConstant()); |
2632 Goto(&out); // Never reached. | 2628 Goto(&out); // Never reached. |
2633 | 2629 |
2634 Bind(&out); | 2630 Bind(&out); |
2635 return var_value_map.value(); | 2631 return var_value_map.value(); |
2636 } | 2632 } |
2637 | 2633 |
2634 Node* CodeStubAssembler::IsSpecialReceiverMap(Node* map) { | |
2635 CSA_ASSERT(IsMap(map)); | |
2636 Node* bit_field = LoadMapBitField(map); | |
2637 Node* mask = Int32Constant(1 << Map::kHasNamedInterceptor | | |
2638 1 << Map::kIsAccessCheckNeeded); | |
2639 Assert(Word32Equal(Word32And(bit_field, mask), Int32Constant(0))); | |
2640 return IsSpecialReceiverInstanceType(LoadMapInstanceType(map)); | |
2641 } | |
2642 | |
2643 Node* CodeStubAssembler::IsCallableMap(Node* map) { | |
2644 CSA_ASSERT(IsMap(map)); | |
2645 return Word32NotEqual( | |
2646 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), | |
2647 Int32Constant(0)); | |
2648 } | |
2649 | |
2650 Node* CodeStubAssembler::IsSpecialReceiverInstanceType(Node* instance_type) { | |
2651 STATIC_ASSERT(JS_GLOBAL_OBJECT_TYPE <= LAST_SPECIAL_RECEIVER_TYPE); | |
2652 return Int32LessThanOrEqual(instance_type, | |
2653 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)); | |
2654 } | |
2655 | |
2638 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { | 2656 Node* CodeStubAssembler::IsStringInstanceType(Node* instance_type) { |
2639 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); | 2657 STATIC_ASSERT(INTERNALIZED_STRING_TYPE == FIRST_TYPE); |
2640 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); | 2658 return Int32LessThan(instance_type, Int32Constant(FIRST_NONSTRING_TYPE)); |
2641 } | 2659 } |
2642 | 2660 |
2643 Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) { | 2661 Node* CodeStubAssembler::IsJSReceiverInstanceType(Node* instance_type) { |
2644 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | 2662 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); |
2645 return Int32GreaterThanOrEqual(instance_type, | 2663 return Int32GreaterThanOrEqual(instance_type, |
2646 Int32Constant(FIRST_JS_RECEIVER_TYPE)); | 2664 Int32Constant(FIRST_JS_RECEIVER_TYPE)); |
2647 } | 2665 } |
2648 | 2666 |
2649 Node* CodeStubAssembler::IsCallableMap(Node* map) { | 2667 Node* CodeStubAssembler::IsJSReceiver(Node* object) { |
2650 return Word32NotEqual( | 2668 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE); |
2651 Word32And(LoadMapBitField(map), Int32Constant(1 << Map::kIsCallable)), | 2669 return IsJSReceiverInstanceType(LoadInstanceType(object)); |
2652 Int32Constant(0)); | 2670 } |
2671 | |
2672 Node* CodeStubAssembler::IsJSObject(Node* object) { | |
2673 STATIC_ASSERT(LAST_JS_OBJECT_TYPE == LAST_TYPE); | |
2674 return Int32GreaterThanOrEqual(LoadInstanceType(object), | |
2675 Int32Constant(FIRST_JS_RECEIVER_TYPE)); | |
2676 } | |
2677 | |
2678 Node* CodeStubAssembler::IsMap(Node* map) { | |
2679 return HasInstanceType(map, MAP_TYPE); | |
2680 } | |
2681 | |
2682 Node* CodeStubAssembler::IsJSValue(Node* map) { | |
2683 return HasInstanceType(map, JS_VALUE_TYPE); | |
2684 } | |
2685 | |
2686 Node* CodeStubAssembler::IsJSArray(Node* object) { | |
2687 return HasInstanceType(object, JS_ARRAY_TYPE); | |
2688 } | |
2689 | |
2690 Node* CodeStubAssembler::IsWeakCell(Node* object) { | |
2691 return HasInstanceType(object, WEAK_CELL_TYPE); | |
2692 } | |
2693 | |
2694 Node* CodeStubAssembler::IsName(Node* object) { | |
2695 return Int32LessThanOrEqual(LoadInstanceType(object), | |
2696 Int32Constant(LAST_NAME_TYPE)); | |
2697 } | |
2698 | |
2699 Node* CodeStubAssembler::IsString(Node* object) { | |
2700 return Int32LessThanOrEqual(LoadInstanceType(object), | |
2701 Int32Constant(FIRST_NONSTRING_TYPE)); | |
2702 } | |
2703 | |
2704 Node* CodeStubAssembler::IsNativeContext(Node* object) { | |
2705 return WordEqual(LoadMap(object), LoadRoot(Heap::kNativeContextMapRootIndex)); | |
2706 } | |
2707 | |
2708 Node* CodeStubAssembler::IsFixedDoubleArray(Node* object) { | |
2709 return WordEqual(LoadMap(object), FixedDoubleArrayMapConstant()); | |
2710 } | |
2711 | |
2712 Node* CodeStubAssembler::IsHashTable(Node* object) { | |
2713 return WordEqual(LoadMap(object), LoadRoot(Heap::kHashTableMapRootIndex)); | |
2714 } | |
2715 | |
2716 Node* CodeStubAssembler::IsDictionary(Node* object) { | |
2717 return WordOr(IsHashTable(object), IsSeededNumberDictionary(object)); | |
2718 } | |
2719 | |
2720 Node* CodeStubAssembler::IsSeededNumberDictionary(Node* object) { | |
Igor Sheludko
2016/10/26 08:58:51
IsUnseededNumberDictionary
Camillo Bruni
2016/10/26 13:10:41
done.
| |
2721 return WordEqual(LoadMap(object), | |
2722 LoadRoot(Heap::kUnseededNumberDictionaryMapRootIndex)); | |
2653 } | 2723 } |
2654 | 2724 |
2655 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { | 2725 Node* CodeStubAssembler::StringCharCodeAt(Node* string, Node* index) { |
2726 CSA_ASSERT(IsString(string)); | |
2656 // Translate the {index} into a Word. | 2727 // Translate the {index} into a Word. |
2657 index = SmiToWord(index); | 2728 index = SmiToWord(index); |
2658 | 2729 |
2659 // We may need to loop in case of cons or sliced strings. | 2730 // We may need to loop in case of cons or sliced strings. |
2660 Variable var_index(this, MachineType::PointerRepresentation()); | 2731 Variable var_index(this, MachineType::PointerRepresentation()); |
2661 Variable var_result(this, MachineRepresentation::kWord32); | 2732 Variable var_result(this, MachineRepresentation::kWord32); |
2662 Variable var_string(this, MachineRepresentation::kTagged); | 2733 Variable var_string(this, MachineRepresentation::kTagged); |
2663 Variable* loop_vars[] = {&var_index, &var_string}; | 2734 Variable* loop_vars[] = {&var_index, &var_string}; |
2664 Label done_loop(this, &var_result), loop(this, 2, loop_vars); | 2735 Label done_loop(this, &var_result), loop(this, 2, loop_vars); |
2665 var_string.Bind(string); | 2736 var_string.Bind(string); |
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3257 IncrementCounter(counters->string_add_native(), 1); | 3328 IncrementCounter(counters->string_add_native(), 1); |
3258 Goto(&done); | 3329 Goto(&done); |
3259 } | 3330 } |
3260 | 3331 |
3261 Bind(&done); | 3332 Bind(&done); |
3262 return result.value(); | 3333 return result.value(); |
3263 } | 3334 } |
3264 | 3335 |
3265 Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, | 3336 Node* CodeStubAssembler::StringIndexOfChar(Node* context, Node* string, |
3266 Node* needle_char, Node* from) { | 3337 Node* needle_char, Node* from) { |
3338 CSA_ASSERT(IsString(string)); | |
3267 Variable var_result(this, MachineRepresentation::kTagged); | 3339 Variable var_result(this, MachineRepresentation::kTagged); |
3268 | 3340 |
3269 Label out(this), runtime(this, Label::kDeferred); | 3341 Label out(this), runtime(this, Label::kDeferred); |
3270 | 3342 |
3271 // Let runtime handle non-one-byte {needle_char}. | 3343 // Let runtime handle non-one-byte {needle_char}. |
3272 | 3344 |
3273 Node* const one_byte_char_mask = IntPtrConstant(0xFF); | 3345 Node* const one_byte_char_mask = IntPtrConstant(0xFF); |
3274 GotoUnless(WordEqual(WordAnd(needle_char, one_byte_char_mask), needle_char), | 3346 GotoUnless(WordEqual(WordAnd(needle_char, one_byte_char_mask), needle_char), |
3275 &runtime); | 3347 &runtime); |
3276 | 3348 |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3686 { | 3758 { |
3687 result.Bind(CallRuntime(Runtime::kToString, context, input)); | 3759 result.Bind(CallRuntime(Runtime::kToString, context, input)); |
3688 Goto(&done); | 3760 Goto(&done); |
3689 } | 3761 } |
3690 | 3762 |
3691 Bind(&done); | 3763 Bind(&done); |
3692 return result.value(); | 3764 return result.value(); |
3693 } | 3765 } |
3694 | 3766 |
3695 Node* CodeStubAssembler::FlattenString(Node* string) { | 3767 Node* CodeStubAssembler::FlattenString(Node* string) { |
3768 CSA_ASSERT(IsString(string)); | |
3696 Variable var_result(this, MachineRepresentation::kTagged); | 3769 Variable var_result(this, MachineRepresentation::kTagged); |
3697 var_result.Bind(string); | 3770 var_result.Bind(string); |
3698 | 3771 |
3699 Node* instance_type = LoadInstanceType(string); | 3772 Node* instance_type = LoadInstanceType(string); |
3700 | 3773 |
3701 // Check if the {string} is not a ConsString (i.e. already flat). | 3774 // Check if the {string} is not a ConsString (i.e. already flat). |
3702 Label is_cons(this, Label::kDeferred), is_flat_in_cons(this), end(this); | 3775 Label is_cons(this, Label::kDeferred), is_flat_in_cons(this), end(this); |
3703 { | 3776 { |
3704 GotoUnless(Word32Equal(Word32And(instance_type, | 3777 GotoUnless(Word32Equal(Word32And(instance_type, |
3705 Int32Constant(kStringRepresentationMask)), | 3778 Int32Constant(kStringRepresentationMask)), |
(...skipping 18 matching lines...) Expand all Loading... | |
3724 { | 3797 { |
3725 var_result.Bind(LoadObjectField(string, ConsString::kFirstOffset)); | 3798 var_result.Bind(LoadObjectField(string, ConsString::kFirstOffset)); |
3726 Goto(&end); | 3799 Goto(&end); |
3727 } | 3800 } |
3728 | 3801 |
3729 Bind(&end); | 3802 Bind(&end); |
3730 return var_result.value(); | 3803 return var_result.value(); |
3731 } | 3804 } |
3732 | 3805 |
3733 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) { | 3806 Node* CodeStubAssembler::JSReceiverToPrimitive(Node* context, Node* input) { |
3734 STATIC_ASSERT(LAST_JS_RECEIVER_TYPE == LAST_TYPE); | |
3735 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this); | 3807 Label if_isreceiver(this, Label::kDeferred), if_isnotreceiver(this); |
3736 Variable result(this, MachineRepresentation::kTagged); | 3808 Variable result(this, MachineRepresentation::kTagged); |
3737 Label done(this, &result); | 3809 Label done(this, &result); |
3738 | 3810 |
3739 GotoIf(TaggedIsSmi(input), &if_isnotreceiver); | 3811 BranchIfJSReceiver(input, &if_isreceiver, &if_isnotreceiver); |
3740 | |
3741 Node* map = LoadMap(input); | |
3742 Node* instance_type = LoadMapInstanceType(map); | |
3743 Branch(IsJSReceiverInstanceType(instance_type), &if_isreceiver, | |
3744 &if_isnotreceiver); | |
3745 | 3812 |
3746 Bind(&if_isreceiver); | 3813 Bind(&if_isreceiver); |
3747 { | 3814 { |
3748 // Convert {input} to a primitive first passing Number hint. | 3815 // Convert {input} to a primitive first passing Number hint. |
3749 Callable callable = CodeFactory::NonPrimitiveToPrimitive(isolate()); | 3816 Callable callable = CodeFactory::NonPrimitiveToPrimitive(isolate()); |
3750 result.Bind(CallStub(callable, context, input)); | 3817 result.Bind(CallStub(callable, context, input)); |
3751 Goto(&done); | 3818 Goto(&done); |
3752 } | 3819 } |
3753 | 3820 |
3754 Bind(&if_isnotreceiver); | 3821 Bind(&if_isnotreceiver); |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3924 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { | 3991 Node* CodeStubAssembler::IntPtrMax(Node* left, Node* right) { |
3925 return Select(IntPtrGreaterThanOrEqual(left, right), left, right); | 3992 return Select(IntPtrGreaterThanOrEqual(left, right), left, right); |
3926 } | 3993 } |
3927 | 3994 |
3928 template <typename Dictionary> | 3995 template <typename Dictionary> |
3929 void CodeStubAssembler::NameDictionaryLookup(Node* dictionary, | 3996 void CodeStubAssembler::NameDictionaryLookup(Node* dictionary, |
3930 Node* unique_name, Label* if_found, | 3997 Node* unique_name, Label* if_found, |
3931 Variable* var_name_index, | 3998 Variable* var_name_index, |
3932 Label* if_not_found, | 3999 Label* if_not_found, |
3933 int inlined_probes) { | 4000 int inlined_probes) { |
4001 CSA_ASSERT(IsDictionary(dictionary)); | |
3934 DCHECK_EQ(MachineType::PointerRepresentation(), var_name_index->rep()); | 4002 DCHECK_EQ(MachineType::PointerRepresentation(), var_name_index->rep()); |
3935 Comment("NameDictionaryLookup"); | 4003 Comment("NameDictionaryLookup"); |
3936 | 4004 |
3937 Node* capacity = SmiUntag(LoadFixedArrayElement( | 4005 Node* capacity = SmiUntag(LoadFixedArrayElement( |
3938 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, | 4006 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, |
3939 INTPTR_PARAMETERS)); | 4007 INTPTR_PARAMETERS)); |
3940 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); | 4008 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); |
3941 Node* hash = ChangeUint32ToWord(LoadNameHash(unique_name)); | 4009 Node* hash = ChangeUint32ToWord(LoadNameHash(unique_name)); |
3942 | 4010 |
3943 // See Dictionary::FirstProbe(). | 4011 // See Dictionary::FirstProbe(). |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4008 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); | 4076 hash = Word32Xor(hash, Word32Shr(hash, Int32Constant(16))); |
4009 return Word32And(hash, Int32Constant(0x3fffffff)); | 4077 return Word32And(hash, Int32Constant(0x3fffffff)); |
4010 } | 4078 } |
4011 | 4079 |
4012 template <typename Dictionary> | 4080 template <typename Dictionary> |
4013 void CodeStubAssembler::NumberDictionaryLookup(Node* dictionary, | 4081 void CodeStubAssembler::NumberDictionaryLookup(Node* dictionary, |
4014 Node* intptr_index, | 4082 Node* intptr_index, |
4015 Label* if_found, | 4083 Label* if_found, |
4016 Variable* var_entry, | 4084 Variable* var_entry, |
4017 Label* if_not_found) { | 4085 Label* if_not_found) { |
4086 CSA_ASSERT(IsDictionary(dictionary)); | |
4018 DCHECK_EQ(MachineType::PointerRepresentation(), var_entry->rep()); | 4087 DCHECK_EQ(MachineType::PointerRepresentation(), var_entry->rep()); |
4019 Comment("NumberDictionaryLookup"); | 4088 Comment("NumberDictionaryLookup"); |
4020 | 4089 |
4021 Node* capacity = SmiUntag(LoadFixedArrayElement( | 4090 Node* capacity = SmiUntag(LoadFixedArrayElement( |
4022 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, | 4091 dictionary, IntPtrConstant(Dictionary::kCapacityIndex), 0, |
4023 INTPTR_PARAMETERS)); | 4092 INTPTR_PARAMETERS)); |
4024 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); | 4093 Node* mask = IntPtrSub(capacity, IntPtrConstant(1)); |
4025 | 4094 |
4026 Node* int32_seed; | 4095 Node* int32_seed; |
4027 if (Dictionary::ShapeT::UsesSeed) { | 4096 if (Dictionary::ShapeT::UsesSeed) { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4310 Bind(&done); | 4379 Bind(&done); |
4311 | 4380 |
4312 Comment("] LoadPropertyFromFastObject"); | 4381 Comment("] LoadPropertyFromFastObject"); |
4313 } | 4382 } |
4314 | 4383 |
4315 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary, | 4384 void CodeStubAssembler::LoadPropertyFromNameDictionary(Node* dictionary, |
4316 Node* name_index, | 4385 Node* name_index, |
4317 Variable* var_details, | 4386 Variable* var_details, |
4318 Variable* var_value) { | 4387 Variable* var_value) { |
4319 Comment("LoadPropertyFromNameDictionary"); | 4388 Comment("LoadPropertyFromNameDictionary"); |
4320 | 4389 CSA_ASSERT(IsDictionary(dictionary)); |
4321 const int name_to_details_offset = | 4390 const int name_to_details_offset = |
4322 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * | 4391 (NameDictionary::kEntryDetailsIndex - NameDictionary::kEntryKeyIndex) * |
4323 kPointerSize; | 4392 kPointerSize; |
4324 const int name_to_value_offset = | 4393 const int name_to_value_offset = |
4325 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) * | 4394 (NameDictionary::kEntryValueIndex - NameDictionary::kEntryKeyIndex) * |
4326 kPointerSize; | 4395 kPointerSize; |
4327 | 4396 |
4328 Node* details = LoadAndUntagToWord32FixedArrayElement(dictionary, name_index, | 4397 Node* details = LoadAndUntagToWord32FixedArrayElement(dictionary, name_index, |
4329 name_to_details_offset); | 4398 name_to_details_offset); |
4330 | 4399 |
4331 var_details->Bind(details); | 4400 var_details->Bind(details); |
4332 var_value->Bind( | 4401 var_value->Bind( |
4333 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset)); | 4402 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset)); |
4334 | 4403 |
4335 Comment("] LoadPropertyFromNameDictionary"); | 4404 Comment("] LoadPropertyFromNameDictionary"); |
4336 } | 4405 } |
4337 | 4406 |
4338 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary, | 4407 void CodeStubAssembler::LoadPropertyFromGlobalDictionary(Node* dictionary, |
4339 Node* name_index, | 4408 Node* name_index, |
4340 Variable* var_details, | 4409 Variable* var_details, |
4341 Variable* var_value, | 4410 Variable* var_value, |
4342 Label* if_deleted) { | 4411 Label* if_deleted) { |
4343 Comment("[ LoadPropertyFromGlobalDictionary"); | 4412 Comment("[ LoadPropertyFromGlobalDictionary"); |
4413 CSA_ASSERT(IsDictionary(dictionary)); | |
4344 | 4414 |
4345 const int name_to_value_offset = | 4415 const int name_to_value_offset = |
4346 (GlobalDictionary::kEntryValueIndex - GlobalDictionary::kEntryKeyIndex) * | 4416 (GlobalDictionary::kEntryValueIndex - GlobalDictionary::kEntryKeyIndex) * |
4347 kPointerSize; | 4417 kPointerSize; |
4348 | 4418 |
4349 Node* property_cell = | 4419 Node* property_cell = |
4350 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset); | 4420 LoadFixedArrayElement(dictionary, name_index, name_to_value_offset); |
4351 | 4421 |
4352 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); | 4422 Node* value = LoadObjectField(property_cell, PropertyCell::kValueOffset); |
4353 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted); | 4423 GotoIf(WordEqual(value, TheHoleConstant()), if_deleted); |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4888 var_receiver_map.Bind(LoadMap(receiver)); | 4958 var_receiver_map.Bind(LoadMap(receiver)); |
4889 Goto(&if_result); | 4959 Goto(&if_result); |
4890 } | 4960 } |
4891 Bind(&if_result); | 4961 Bind(&if_result); |
4892 return var_receiver_map.value(); | 4962 return var_receiver_map.value(); |
4893 } | 4963 } |
4894 | 4964 |
4895 compiler::Node* CodeStubAssembler::TryMonomorphicCase( | 4965 compiler::Node* CodeStubAssembler::TryMonomorphicCase( |
4896 compiler::Node* slot, compiler::Node* vector, compiler::Node* receiver_map, | 4966 compiler::Node* slot, compiler::Node* vector, compiler::Node* receiver_map, |
4897 Label* if_handler, Variable* var_handler, Label* if_miss) { | 4967 Label* if_handler, Variable* var_handler, Label* if_miss) { |
4968 Comment("TryMonomorphicCase"); | |
4898 DCHECK_EQ(MachineRepresentation::kTagged, var_handler->rep()); | 4969 DCHECK_EQ(MachineRepresentation::kTagged, var_handler->rep()); |
4899 | 4970 |
4900 // TODO(ishell): add helper class that hides offset computations for a series | 4971 // TODO(ishell): add helper class that hides offset computations for a series |
4901 // of loads. | 4972 // of loads. |
4902 int32_t header_size = FixedArray::kHeaderSize - kHeapObjectTag; | 4973 int32_t header_size = FixedArray::kHeaderSize - kHeapObjectTag; |
4903 // Adding |header_size| with a separate IntPtrAdd rather than passing it | 4974 // Adding |header_size| with a separate IntPtrAdd rather than passing it |
4904 // into ElementOffsetFromIndex() allows it to be folded into a single | 4975 // into ElementOffsetFromIndex() allows it to be folded into a single |
4905 // [base, index, offset] indirect memory access on x64. | 4976 // [base, index, offset] indirect memory access on x64. |
4906 Node* offset = | 4977 Node* offset = |
4907 ElementOffsetFromIndex(slot, FAST_HOLEY_ELEMENTS, SMI_PARAMETERS); | 4978 ElementOffsetFromIndex(slot, FAST_HOLEY_ELEMENTS, SMI_PARAMETERS); |
4908 Node* feedback = Load(MachineType::AnyTagged(), vector, | 4979 Node* feedback = Load(MachineType::AnyTagged(), vector, |
4909 IntPtrAdd(offset, IntPtrConstant(header_size))); | 4980 IntPtrAdd(offset, IntPtrConstant(header_size))); |
4910 | 4981 |
4911 // Try to quickly handle the monomorphic case without knowing for sure | 4982 // Try to quickly handle the monomorphic case without knowing for sure |
4912 // if we have a weak cell in feedback. We do know it's safe to look | 4983 // if we have a weak cell in feedback. We do know it's safe to look |
4913 // at WeakCell::kValueOffset. | 4984 // at WeakCell::kValueOffset. |
4914 GotoIf(WordNotEqual(receiver_map, LoadWeakCellValue(feedback)), if_miss); | 4985 GotoIf(WordNotEqual(receiver_map, LoadWeakCellValueUnchecked(feedback)), |
4986 if_miss); | |
4915 | 4987 |
4916 Node* handler = | 4988 Node* handler = |
4917 Load(MachineType::AnyTagged(), vector, | 4989 Load(MachineType::AnyTagged(), vector, |
4918 IntPtrAdd(offset, IntPtrConstant(header_size + kPointerSize))); | 4990 IntPtrAdd(offset, IntPtrConstant(header_size + kPointerSize))); |
4919 | 4991 |
4920 var_handler->Bind(handler); | 4992 var_handler->Bind(handler); |
4921 Goto(if_handler); | 4993 Goto(if_handler); |
4922 return feedback; | 4994 return feedback; |
4923 } | 4995 } |
4924 | 4996 |
4925 void CodeStubAssembler::HandlePolymorphicCase( | 4997 void CodeStubAssembler::HandlePolymorphicCase( |
4926 compiler::Node* receiver_map, compiler::Node* feedback, Label* if_handler, | 4998 compiler::Node* receiver_map, compiler::Node* feedback, Label* if_handler, |
4927 Variable* var_handler, Label* if_miss, int unroll_count) { | 4999 Variable* var_handler, Label* if_miss, int unroll_count) { |
5000 Comment("HandlePolymorphicCase"); | |
4928 DCHECK_EQ(MachineRepresentation::kTagged, var_handler->rep()); | 5001 DCHECK_EQ(MachineRepresentation::kTagged, var_handler->rep()); |
4929 | 5002 |
4930 // Iterate {feedback} array. | 5003 // Iterate {feedback} array. |
4931 const int kEntrySize = 2; | 5004 const int kEntrySize = 2; |
4932 | 5005 |
4933 for (int i = 0; i < unroll_count; i++) { | 5006 for (int i = 0; i < unroll_count; i++) { |
4934 Label next_entry(this); | 5007 Label next_entry(this); |
4935 Node* cached_map = LoadWeakCellValue(LoadFixedArrayElement( | 5008 Node* cached_map = LoadWeakCellValue(LoadFixedArrayElement( |
4936 feedback, IntPtrConstant(i * kEntrySize), 0, INTPTR_PARAMETERS)); | 5009 feedback, IntPtrConstant(i * kEntrySize), 0, INTPTR_PARAMETERS)); |
4937 GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry); | 5010 GotoIf(WordNotEqual(receiver_map, cached_map), &next_entry); |
(...skipping 1709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
6647 } | 6720 } |
6648 Bind(&no_memento_found); | 6721 Bind(&no_memento_found); |
6649 Comment("] TrapAllocationMemento"); | 6722 Comment("] TrapAllocationMemento"); |
6650 } | 6723 } |
6651 | 6724 |
6652 Node* CodeStubAssembler::PageFromAddress(Node* address) { | 6725 Node* CodeStubAssembler::PageFromAddress(Node* address) { |
6653 return WordAnd(address, IntPtrConstant(~Page::kPageAlignmentMask)); | 6726 return WordAnd(address, IntPtrConstant(~Page::kPageAlignmentMask)); |
6654 } | 6727 } |
6655 | 6728 |
6656 Node* CodeStubAssembler::EnumLength(Node* map) { | 6729 Node* CodeStubAssembler::EnumLength(Node* map) { |
6730 CSA_ASSERT(IsMap(map)); | |
6657 Node* bitfield_3 = LoadMapBitField3(map); | 6731 Node* bitfield_3 = LoadMapBitField3(map); |
6658 Node* enum_length = DecodeWordFromWord32<Map::EnumLengthBits>(bitfield_3); | 6732 Node* enum_length = DecodeWordFromWord32<Map::EnumLengthBits>(bitfield_3); |
6659 return SmiTag(enum_length); | 6733 return SmiTag(enum_length); |
6660 } | 6734 } |
6661 | 6735 |
6662 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, | 6736 void CodeStubAssembler::CheckEnumCache(Node* receiver, Label* use_cache, |
6663 Label* use_runtime) { | 6737 Label* use_runtime) { |
6664 Variable current_js_object(this, MachineRepresentation::kTagged); | 6738 Variable current_js_object(this, MachineRepresentation::kTagged); |
6665 current_js_object.Bind(receiver); | 6739 current_js_object.Bind(receiver); |
6666 | 6740 |
(...skipping 1878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
8545 Node* buffer_bit_field = LoadObjectField( | 8619 Node* buffer_bit_field = LoadObjectField( |
8546 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); | 8620 buffer, JSArrayBuffer::kBitFieldOffset, MachineType::Uint32()); |
8547 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); | 8621 Node* was_neutered_mask = Int32Constant(JSArrayBuffer::WasNeutered::kMask); |
8548 | 8622 |
8549 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), | 8623 return Word32NotEqual(Word32And(buffer_bit_field, was_neutered_mask), |
8550 Int32Constant(0)); | 8624 Int32Constant(0)); |
8551 } | 8625 } |
8552 | 8626 |
8553 } // namespace internal | 8627 } // namespace internal |
8554 } // namespace v8 | 8628 } // namespace v8 |
OLD | NEW |