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

Side by Side Diff: src/arm/macro-assembler-arm.cc

Issue 9148006: [objects] seed NumberDictionary (only ia32 now) Base URL: gh:v8/v8@master
Patch Set: added test, decoupled code Created 8 years, 11 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
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 1396 matching lines...) Expand 10 before | Expand all | Expand 10 after
1407 1407
1408 ldr(scratch, FieldMemOperand(scratch, token_offset)); 1408 ldr(scratch, FieldMemOperand(scratch, token_offset));
1409 ldr(ip, FieldMemOperand(ip, token_offset)); 1409 ldr(ip, FieldMemOperand(ip, token_offset));
1410 cmp(scratch, Operand(ip)); 1410 cmp(scratch, Operand(ip));
1411 b(ne, miss); 1411 b(ne, miss);
1412 1412
1413 bind(&same_contexts); 1413 bind(&same_contexts);
1414 } 1414 }
1415 1415
1416 1416
1417 void MacroAssembler::GetNumberHash(Register t0, Register scratch) {
1418 // First of all we assign the hash seed to scratch.
1419 LoadRoot(scratch, Heap::kStringHashSeedRootIndex);
1420 mov(scratch, Operand(scratch, LSR, kSmiTagSize));
Erik Corry 2012/01/10 11:53:16 Use SmiUntag(scratch)
1421
1422 // Xor original key with a seed
Erik Corry 2012/01/10 11:53:16 seed -> seed.
1423 eor(t0, t0, Operand(scratch));
1424
1425 // Compute the hash code from the untagged key. This must be kept in sync
1426 // with ComputeIntegerHash in utils.h.
1427 //
1428 // hash = ~hash + (hash << 15);
1429 mvn(scratch, Operand(t0));
1430 add(t0, scratch, Operand(t0, LSL, 15));
1431 // hash = hash ^ (hash >> 12);
1432 eor(t0, t0, Operand(t0, LSR, 12));
1433 // hash = hash + (hash << 2);
1434 add(t0, t0, Operand(t0, LSL, 2));
1435 // hash = hash ^ (hash >> 4);
1436 eor(t0, t0, Operand(t0, LSR, 4));
1437 // hash = hash * 2057;
1438 mov(scratch, Operand(2057));
Erik Corry 2012/01/10 11:53:16 This should be done with shifts and adds. See the
1439 mul(t0, t0, scratch);
1440 // hash = hash ^ (hash >> 16);
1441 eor(t0, t0, Operand(t0, LSR, 16));
1442 }
1443
1444
1417 void MacroAssembler::LoadFromNumberDictionary(Label* miss, 1445 void MacroAssembler::LoadFromNumberDictionary(Label* miss,
1418 Register elements, 1446 Register elements,
1419 Register key, 1447 Register key,
1420 Register result, 1448 Register result,
1421 Register t0, 1449 Register t0,
1422 Register t1, 1450 Register t1,
1423 Register t2) { 1451 Register t2) {
1424 // Register use: 1452 // Register use:
1425 // 1453 //
1426 // elements - holds the slow-case elements of the receiver on entry. 1454 // elements - holds the slow-case elements of the receiver on entry.
1427 // Unchanged unless 'result' is the same register. 1455 // Unchanged unless 'result' is the same register.
1428 // 1456 //
1429 // key - holds the smi key on entry. 1457 // key - holds the smi key on entry.
1430 // Unchanged unless 'result' is the same register. 1458 // Unchanged unless 'result' is the same register.
1431 // 1459 //
1432 // result - holds the result on exit if the load succeeded. 1460 // result - holds the result on exit if the load succeeded.
1433 // Allowed to be the same as 'key' or 'result'. 1461 // Allowed to be the same as 'key' or 'result'.
1434 // Unchanged on bailout so 'key' or 'result' can be used 1462 // Unchanged on bailout so 'key' or 'result' can be used
1435 // in further computation. 1463 // in further computation.
1436 // 1464 //
1437 // Scratch registers: 1465 // Scratch registers:
1438 // 1466 //
1439 // t0 - holds the untagged key on entry and holds the hash once computed. 1467 // t0 - holds the untagged key on entry and holds the hash once computed.
1440 // 1468 //
1441 // t1 - used to hold the capacity mask of the dictionary 1469 // t1 - used to hold the capacity mask of the dictionary
1442 // 1470 //
1443 // t2 - used for the index into the dictionary. 1471 // t2 - used for the index into the dictionary.
1444 Label done; 1472 Label done;
1445 1473
1446 // Compute the hash code from the untagged key. This must be kept in sync 1474 GetNumberHash(t0, t1);
1447 // with ComputeIntegerHash in utils.h.
1448 //
1449 // hash = ~hash + (hash << 15);
1450 mvn(t1, Operand(t0));
1451 add(t0, t1, Operand(t0, LSL, 15));
1452 // hash = hash ^ (hash >> 12);
1453 eor(t0, t0, Operand(t0, LSR, 12));
1454 // hash = hash + (hash << 2);
1455 add(t0, t0, Operand(t0, LSL, 2));
1456 // hash = hash ^ (hash >> 4);
1457 eor(t0, t0, Operand(t0, LSR, 4));
1458 // hash = hash * 2057;
1459 mov(t1, Operand(2057));
1460 mul(t0, t0, t1);
1461 // hash = hash ^ (hash >> 16);
1462 eor(t0, t0, Operand(t0, LSR, 16));
1463 1475
1464 // Compute the capacity mask. 1476 // Compute the capacity mask.
1465 ldr(t1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); 1477 ldr(t1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset));
1466 mov(t1, Operand(t1, ASR, kSmiTagSize)); // convert smi to int 1478 mov(t1, Operand(t1, ASR, kSmiTagSize)); // convert smi to int
1467 sub(t1, t1, Operand(1)); 1479 sub(t1, t1, Operand(1));
1468 1480
1469 // Generate an unrolled loop that performs a few probes before giving up. 1481 // Generate an unrolled loop that performs a few probes before giving up.
1470 static const int kProbes = 4; 1482 static const int kProbes = 4;
1471 for (int i = 0; i < kProbes; i++) { 1483 for (int i = 0; i < kProbes; i++) {
1472 // Use t2 for index calculations and keep the hash intact in t0. 1484 // Use t2 for index calculations and keep the hash intact in t0.
(...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after
3625 void CodePatcher::EmitCondition(Condition cond) { 3637 void CodePatcher::EmitCondition(Condition cond) {
3626 Instr instr = Assembler::instr_at(masm_.pc_); 3638 Instr instr = Assembler::instr_at(masm_.pc_);
3627 instr = (instr & ~kCondMask) | cond; 3639 instr = (instr & ~kCondMask) | cond;
3628 masm_.emit(instr); 3640 masm_.emit(instr);
3629 } 3641 }
3630 3642
3631 3643
3632 } } // namespace v8::internal 3644 } } // namespace v8::internal
3633 3645
3634 #endif // V8_TARGET_ARCH_ARM 3646 #endif // V8_TARGET_ARCH_ARM
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698