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

Side by Side Diff: src/code-stubs-hydrogen.cc

Issue 19492007: Generate KeyedLoadDictionaryElementStub with Hydrogen (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add V8_OVERRIDE Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.h » ('j') | src/hydrogen.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1245 matching lines...) Expand 10 before | Expand all | Expand 10 after
1256 1256
1257 return js_function; 1257 return js_function;
1258 } 1258 }
1259 1259
1260 1260
1261 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) { 1261 Handle<Code> FastNewClosureStub::GenerateCode(Isolate* isolate) {
1262 return DoGenerateCode(isolate, this); 1262 return DoGenerateCode(isolate, this);
1263 } 1263 }
1264 1264
1265 1265
1266 template <>
1267 class CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>
1268 : public CodeStubGraphBuilderBase {
1269 public:
1270 explicit CodeStubGraphBuilder(Isolate* isolate,
Jakob Kummerow 2013/11/06 10:48:12 nit: no "explicit" necessary
danno 2013/11/15 17:54:09 Done.
1271 KeyedLoadDictionaryElementStub* stub)
1272 : CodeStubGraphBuilderBase(isolate, stub) {}
1273
1274 protected:
1275 HValue* BuildCodeStubHelper(HValue* dictionary,
1276 HValue* key,
1277 HValue* hash,
1278 HValue* mask,
1279 int current_probe);
1280
1281 virtual HValue* BuildCodeStub();
1282
1283 KeyedLoadDictionaryElementStub* casted_stub() {
1284 return static_cast<KeyedLoadDictionaryElementStub*>(stub());
1285 }
1286 };
1287
1288
1289 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::
Jakob Kummerow 2013/11/06 10:48:12 nit: I'd break after "HValue*" instead of after ":
danno 2013/11/15 17:54:09 Done.
1290 BuildCodeStubHelper(
1291 HValue* elements,
1292 HValue* key,
1293 HValue* hash,
1294 HValue* mask,
1295 int current_probe) {
1296 if (current_probe == kNumberDictionaryProbes) {
1297 return NULL;
1298 }
1299
1300 int32_t offset = SeededNumberDictionary::GetProbeOffset(current_probe);
1301 HValue* raw_index = (current_probe == 0)
1302 ? hash
Jakob Kummerow 2013/11/06 10:48:12 nit: 4 space indent
danno 2013/11/15 17:54:09 Done.
1303 : Add<HAdd>(hash, Add<HConstant>(offset));
1304 raw_index = Add<HBitwise>(Token::BIT_AND, raw_index, mask);
1305 int32_t entry_size = SeededNumberDictionary::kEntrySize;
1306 raw_index = Add<HMul>(raw_index, Add<HConstant>(entry_size));
1307 raw_index->ClearFlag(HValue::kCanOverflow);
1308
1309 int32_t base_offset = SeededNumberDictionary::kElementsStartIndex;
1310 HValue* key_index = Add<HAdd>(raw_index, Add<HConstant>(base_offset));
1311 key_index->ClearFlag(HValue::kCanOverflow);
1312
1313 HValue* candidate_key = Add<HLoadKeyed>(elements, key_index,
1314 static_cast<HValue*>(NULL),
1315 FAST_SMI_ELEMENTS);
1316
1317 IfBuilder key_compare(this);
1318 key_compare.IfNot<HCompareObjectEqAndBranch>(key, candidate_key);
1319 key_compare.Then();
1320
1321 // Key at the current probe doesn't match, try at the next probe.
1322 HValue* result = BuildCodeStubHelper(elements, key, hash, mask,
1323 current_probe + 1);
mvstanton 2013/11/04 15:28:24 The recursive call is interesting here, but the ba
danno 2013/11/15 17:54:09 Done.
1324 if (result == NULL) {
1325 key_compare.Deopt("probes exhausted in keyed load dictionary lookup");
1326 result = graph()->GetConstantUndefined();
Jakob Kummerow 2013/11/06 10:48:12 As discussed, the automatic environment padding ha
danno 2013/11/15 17:54:09 Done.
1327 } else {
1328 Push(result);
1329 }
1330
1331 key_compare.Else();
1332 // Key at current probe matches. Details must be zero, otherwise the
1333 // dictionary element requires special handling.
1334 HValue* details_index = Add<HAdd>(raw_index,
1335 Add<HConstant>(base_offset + 2));
1336 details_index->ClearFlag(HValue::kCanOverflow);
1337
1338 HValue* details = Add<HLoadKeyed>(elements, details_index,
1339 static_cast<HValue*>(NULL),
1340 FAST_SMI_ELEMENTS);
1341 IfBuilder details_compare(this);
1342 details_compare.If<HCompareNumericAndBranch>(details,
1343 graph()->GetConstant0(),
1344 Token::NE);
1345 details_compare.ThenDeopt("keyed load dictionary element not fast case");
1346
1347 details_compare.Else();
1348 // Key matches and details are zero --> fast case. Load and return the value.
1349 HValue* result_index = Add<HAdd>(raw_index,
1350 Add<HConstant>(base_offset + 1));
1351 result_index->ClearFlag(HValue::kCanOverflow);
1352
1353 Push(Add<HLoadKeyed>(elements, result_index,
1354 static_cast<HValue*>(NULL),
1355 FAST_ELEMENTS));
1356
1357 details_compare.End();
mvstanton 2013/11/04 15:28:24 nit: I would engage in the { } indentation style h
danno 2013/11/15 17:54:09 Done.
1358
1359 key_compare.End();
1360
1361 return Pop();
1362 }
1363
1364
1365 HValue* CodeStubGraphBuilder<KeyedLoadDictionaryElementStub>::BuildCodeStub() {
1366 KeyedLoadDictionaryElementStub* stub = casted_stub();
1367
1368 HValue* dictionary = GetParameter(0);
1369 HValue* key = GetParameter(1);
1370 USE(stub);
mvstanton 2013/11/04 15:28:24 What are the USE statements for, can they be remov
danno 2013/11/15 17:54:09 Done.
1371 USE(dictionary);
1372
1373 HValue* elements = AddLoadElements(dictionary);
1374
1375 Add<HCheckSmi>(key);
1376
1377 HValue* hash = BuildElementIndexHash(key);
1378
1379 HValue* capacity = Add<HLoadKeyed>(
1380 elements,
1381 Add<HConstant>(NameDictionary::kCapacityIndex),
1382 static_cast<HValue*>(NULL),
1383 FAST_SMI_ELEMENTS);
1384
1385 HValue* mask = Add<HSub>(capacity, graph()->GetConstant1());
1386 mask->ChangeRepresentation(Representation::Integer32());
1387 mask->ClearFlag(HValue::kCanOverflow);
1388
1389 return BuildCodeStubHelper(elements, key, hash, mask, 0);
1390 }
1391
1392
1393 Handle<Code> KeyedLoadDictionaryElementStub::GenerateCode(Isolate* isolate) {
1394 return DoGenerateCode(isolate, this);
1395 }
1396
1397
1266 } } // namespace v8::internal 1398 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/code-stubs.cc ('k') | src/codegen.h » ('j') | src/hydrogen.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698