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

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

Issue 1894953004: Add HasProperty code stub that tries simple lookups or jumps to runtime otherwise. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebasing Created 4 years, 8 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') | src/code-stubs.h » ('j') | 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 4
5 #include "src/code-stub-assembler.h" 5 #include "src/code-stub-assembler.h"
6 #include "src/code-factory.h" 6 #include "src/code-factory.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
(...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after
482 482
483 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) { 483 Node* CodeStubAssembler::LoadMapInstanceType(Node* map) {
484 return Load(MachineType::Uint8(), map, 484 return Load(MachineType::Uint8(), map,
485 IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag)); 485 IntPtrConstant(Map::kInstanceTypeOffset - kHeapObjectTag));
486 } 486 }
487 487
488 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) { 488 Node* CodeStubAssembler::LoadMapDescriptors(Node* map) {
489 return LoadObjectField(map, Map::kDescriptorsOffset); 489 return LoadObjectField(map, Map::kDescriptorsOffset);
490 } 490 }
491 491
492 Node* CodeStubAssembler::LoadMapPrototype(Node* map) {
493 return LoadObjectField(map, Map::kPrototypeOffset);
494 }
495
492 Node* CodeStubAssembler::LoadNameHash(Node* name) { 496 Node* CodeStubAssembler::LoadNameHash(Node* name) {
493 return Load(MachineType::Uint32(), name, 497 return Load(MachineType::Uint32(), name,
494 IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag)); 498 IntPtrConstant(Name::kHashFieldOffset - kHeapObjectTag));
495 } 499 }
496 500
497 Node* CodeStubAssembler::AllocateUninitializedFixedArray(Node* length) { 501 Node* CodeStubAssembler::AllocateUninitializedFixedArray(Node* length) {
498 Node* header_size = IntPtrConstant(FixedArray::kHeaderSize); 502 Node* header_size = IntPtrConstant(FixedArray::kHeaderSize);
499 Node* data_size = WordShl(length, IntPtrConstant(kPointerSizeLog2)); 503 Node* data_size = WordShl(length, IntPtrConstant(kPointerSizeLog2));
500 Node* total_size = IntPtrAdd(data_size, header_size); 504 Node* total_size = IntPtrAdd(data_size, header_size);
501 505
(...skipping 630 matching lines...) Expand 10 before | Expand all | Expand 10 after
1132 Bind(&if_done); 1136 Bind(&if_done);
1133 return var_result.value(); 1137 return var_result.value();
1134 } 1138 }
1135 1139
1136 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift, 1140 Node* CodeStubAssembler::BitFieldDecode(Node* word32, uint32_t shift,
1137 uint32_t mask) { 1141 uint32_t mask) {
1138 return Word32Shr(Word32And(word32, Int32Constant(mask)), 1142 return Word32Shr(Word32And(word32, Int32Constant(mask)),
1139 Int32Constant(shift)); 1143 Int32Constant(shift));
1140 } 1144 }
1141 1145
1146 void CodeStubAssembler::TryToName(Node* key, Label* if_keyisindex,
1147 Variable* var_index, Label* if_keyisunique,
1148 Label* call_runtime) {
1149 DCHECK_EQ(MachineRepresentation::kWord32, var_index->rep());
1150
1151 Label if_keyissmi(this), if_keyisnotsmi(this);
1152 Branch(WordIsSmi(key), &if_keyissmi, &if_keyisnotsmi);
1153 Bind(&if_keyissmi);
1154 {
1155 // Negative smi keys are named properties. Handle in the runtime.
1156 Label if_keyispositive(this);
1157 Branch(WordIsPositiveSmi(key), &if_keyispositive, call_runtime);
1158 Bind(&if_keyispositive);
1159
1160 var_index->Bind(SmiToWord32(key));
1161 Goto(if_keyisindex);
1162 }
1163
1164 Bind(&if_keyisnotsmi);
1165
1166 Node* key_instance_type = LoadInstanceType(key);
1167 Label if_keyisnotsymbol(this);
1168 Branch(Word32Equal(key_instance_type, Int32Constant(SYMBOL_TYPE)),
1169 if_keyisunique, &if_keyisnotsymbol);
1170 Bind(&if_keyisnotsymbol);
1171 {
1172 Label if_keyisinternalized(this);
1173 Node* bits =
1174 WordAnd(key_instance_type,
1175 Int32Constant(kIsNotStringMask | kIsNotInternalizedMask));
1176 Branch(Word32Equal(bits, Int32Constant(kStringTag | kInternalizedTag)),
1177 &if_keyisinternalized, call_runtime);
1178 Bind(&if_keyisinternalized);
1179
1180 // Check whether the key is an array index passed in as string. Handle
1181 // uniform with smi keys if so.
1182 // TODO(verwaest): Also support non-internalized strings.
1183 Node* hash = LoadNameHash(key);
1184 Node* bit =
1185 Word32And(hash, Int32Constant(internal::Name::kIsNotArrayIndexMask));
1186 Label if_isarrayindex(this);
1187 Branch(Word32Equal(bit, Int32Constant(0)), &if_isarrayindex,
1188 if_keyisunique);
1189 Bind(&if_isarrayindex);
1190 var_index->Bind(BitFieldDecode<internal::Name::ArrayIndexValueBits>(hash));
1191 Goto(if_keyisindex);
1192 }
1193 }
1194
1195 void CodeStubAssembler::TryLookupProperty(Node* object, Node* map,
1196 Node* instance_type, Node* name,
1197 Label* if_found, Label* if_not_found,
1198 Label* call_runtime) {
1199 {
1200 Label if_objectissimple(this);
1201 Branch(Int32LessThanOrEqual(instance_type,
1202 Int32Constant(LAST_SPECIAL_RECEIVER_TYPE)),
1203 call_runtime, &if_objectissimple);
1204 Bind(&if_objectissimple);
1205 }
1206
1207 // TODO(verwaest): Perform a dictonary lookup on slow-mode receivers.
1208 Node* bit_field3 = LoadMapBitField3(map);
1209 Node* bit = BitFieldDecode<Map::DictionaryMap>(bit_field3);
1210 Label if_isfastmap(this);
1211 Branch(Word32Equal(bit, Int32Constant(0)), &if_isfastmap, call_runtime);
1212 Bind(&if_isfastmap);
1213 Node* nof = BitFieldDecode<Map::NumberOfOwnDescriptorsBits>(bit_field3);
1214 // Bail out to the runtime for large numbers of own descriptors. The stub only
1215 // does linear search, which becomes too expensive in that case.
1216 {
1217 static const int32_t kMaxLinear = 210;
1218 Label above_max(this), below_max(this);
1219 Branch(Int32LessThanOrEqual(nof, Int32Constant(kMaxLinear)), &below_max,
1220 call_runtime);
1221 Bind(&below_max);
1222 }
1223 Node* descriptors = LoadMapDescriptors(map);
1224
1225 Variable var_descriptor(this, MachineRepresentation::kWord32);
1226 Label loop(this, &var_descriptor);
1227 var_descriptor.Bind(Int32Constant(0));
1228 Goto(&loop);
1229 Bind(&loop);
1230 {
1231 Node* index = var_descriptor.value();
1232 Node* offset = Int32Constant(DescriptorArray::ToKeyIndex(0));
1233 Node* factor = Int32Constant(DescriptorArray::kDescriptorSize);
1234 Label if_notdone(this);
1235 Branch(Word32Equal(index, nof), if_not_found, &if_notdone);
1236 Bind(&if_notdone);
1237 {
1238 Node* array_index = Int32Add(offset, Int32Mul(index, factor));
1239 Node* current = LoadFixedArrayElementInt32Index(descriptors, array_index);
1240 Label if_unequal(this);
1241 Branch(WordEqual(current, name), if_found, &if_unequal);
1242 Bind(&if_unequal);
1243
1244 var_descriptor.Bind(Int32Add(index, Int32Constant(1)));
1245 Goto(&loop);
1246 }
1247 }
1248 }
1249
1250 void CodeStubAssembler::TryLookupElement(Node* object, Node* map,
1251 Node* instance_type, Node* index,
1252 Label* if_found, Label* if_not_found,
1253 Label* call_runtime) {
1254 {
1255 Label if_objectissimple(this);
1256 Branch(Int32LessThanOrEqual(instance_type,
1257 Int32Constant(LAST_CUSTOM_ELEMENTS_RECEIVER)),
1258 call_runtime, &if_objectissimple);
1259 Bind(&if_objectissimple);
1260 }
1261
1262 Node* bit_field2 = LoadMapBitField2(map);
1263 Node* elements_kind = BitFieldDecode<Map::ElementsKindBits>(bit_field2);
1264
1265 // TODO(verwaest): Support other elements kinds as well.
1266 Label if_isobjectorsmi(this);
1267 Branch(
1268 Int32LessThanOrEqual(elements_kind, Int32Constant(FAST_HOLEY_ELEMENTS)),
1269 &if_isobjectorsmi, call_runtime);
1270 Bind(&if_isobjectorsmi);
1271 {
1272 Node* elements = LoadElements(object);
1273 Node* length = LoadFixedArrayBaseLength(elements);
1274
1275 Label if_iskeyinrange(this);
1276 Branch(Int32LessThan(index, SmiToWord32(length)), &if_iskeyinrange,
1277 if_not_found);
1278
1279 Bind(&if_iskeyinrange);
1280 Node* element = LoadFixedArrayElementInt32Index(elements, index);
1281 Node* the_hole = LoadRoot(Heap::kTheHoleValueRootIndex);
1282 Branch(WordEqual(element, the_hole), if_not_found, if_found);
1283 }
1284 }
1285
1142 } // namespace internal 1286 } // namespace internal
1143 } // namespace v8 1287 } // namespace v8
OLDNEW
« no previous file with comments | « src/code-stub-assembler.h ('k') | src/code-stubs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698