| OLD | NEW |
| 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 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 Context::SECURITY_TOKEN_INDEX * kPointerSize; | 336 Context::SECURITY_TOKEN_INDEX * kPointerSize; |
| 337 | 337 |
| 338 lw(scratch, FieldMemOperand(scratch, token_offset)); | 338 lw(scratch, FieldMemOperand(scratch, token_offset)); |
| 339 lw(at, FieldMemOperand(at, token_offset)); | 339 lw(at, FieldMemOperand(at, token_offset)); |
| 340 Branch(miss, ne, scratch, Operand(at)); | 340 Branch(miss, ne, scratch, Operand(at)); |
| 341 | 341 |
| 342 bind(&same_contexts); | 342 bind(&same_contexts); |
| 343 } | 343 } |
| 344 | 344 |
| 345 | 345 |
| 346 void MacroAssembler::GetNumberHash(Register reg0, Register scratch) { |
| 347 // First of all we assign the hash seed to scratch. |
| 348 LoadRoot(scratch, Heap::kHashSeedRootIndex); |
| 349 SmiUntag(scratch); |
| 350 |
| 351 // Xor original key with a seed. |
| 352 xor_(reg0, reg0, scratch); |
| 353 |
| 354 // Compute the hash code from the untagged key. This must be kept in sync |
| 355 // with ComputeIntegerHash in utils.h. |
| 356 // |
| 357 // hash = ~hash + (hash << 15); |
| 358 nor(scratch, reg0, zero_reg); |
| 359 sll(at, reg0, 15); |
| 360 addu(reg0, scratch, at); |
| 361 |
| 362 // hash = hash ^ (hash >> 12); |
| 363 srl(at, reg0, 12); |
| 364 xor_(reg0, reg0, at); |
| 365 |
| 366 // hash = hash + (hash << 2); |
| 367 sll(at, reg0, 2); |
| 368 addu(reg0, reg0, at); |
| 369 |
| 370 // hash = hash ^ (hash >> 4); |
| 371 srl(at, reg0, 4); |
| 372 xor_(reg0, reg0, at); |
| 373 |
| 374 // hash = hash * 2057; |
| 375 li(scratch, Operand(2057)); |
| 376 mul(reg0, reg0, scratch); |
| 377 |
| 378 // hash = hash ^ (hash >> 16); |
| 379 srl(at, reg0, 16); |
| 380 xor_(reg0, reg0, at); |
| 381 } |
| 382 |
| 383 |
| 346 void MacroAssembler::LoadFromNumberDictionary(Label* miss, | 384 void MacroAssembler::LoadFromNumberDictionary(Label* miss, |
| 347 Register elements, | 385 Register elements, |
| 348 Register key, | 386 Register key, |
| 349 Register result, | 387 Register result, |
| 350 Register reg0, | 388 Register reg0, |
| 351 Register reg1, | 389 Register reg1, |
| 352 Register reg2) { | 390 Register reg2) { |
| 353 // Register use: | 391 // Register use: |
| 354 // | 392 // |
| 355 // elements - holds the slow-case elements of the receiver on entry. | 393 // elements - holds the slow-case elements of the receiver on entry. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 367 // Scratch registers: | 405 // Scratch registers: |
| 368 // | 406 // |
| 369 // reg0 - holds the untagged key on entry and holds the hash once computed. | 407 // reg0 - holds the untagged key on entry and holds the hash once computed. |
| 370 // | 408 // |
| 371 // reg1 - Used to hold the capacity mask of the dictionary. | 409 // reg1 - Used to hold the capacity mask of the dictionary. |
| 372 // | 410 // |
| 373 // reg2 - Used for the index into the dictionary. | 411 // reg2 - Used for the index into the dictionary. |
| 374 // at - Temporary (avoid MacroAssembler instructions also using 'at'). | 412 // at - Temporary (avoid MacroAssembler instructions also using 'at'). |
| 375 Label done; | 413 Label done; |
| 376 | 414 |
| 377 // Compute the hash code from the untagged key. This must be kept in sync | 415 GetNumberHash(reg0, reg1); |
| 378 // with ComputeIntegerHash in utils.h. | |
| 379 // | |
| 380 // hash = ~hash + (hash << 15); | |
| 381 nor(reg1, reg0, zero_reg); | |
| 382 sll(at, reg0, 15); | |
| 383 addu(reg0, reg1, at); | |
| 384 | |
| 385 // hash = hash ^ (hash >> 12); | |
| 386 srl(at, reg0, 12); | |
| 387 xor_(reg0, reg0, at); | |
| 388 | |
| 389 // hash = hash + (hash << 2); | |
| 390 sll(at, reg0, 2); | |
| 391 addu(reg0, reg0, at); | |
| 392 | |
| 393 // hash = hash ^ (hash >> 4); | |
| 394 srl(at, reg0, 4); | |
| 395 xor_(reg0, reg0, at); | |
| 396 | |
| 397 // hash = hash * 2057; | |
| 398 li(reg1, Operand(2057)); | |
| 399 mul(reg0, reg0, reg1); | |
| 400 | |
| 401 // hash = hash ^ (hash >> 16); | |
| 402 srl(at, reg0, 16); | |
| 403 xor_(reg0, reg0, at); | |
| 404 | 416 |
| 405 // Compute the capacity mask. | 417 // Compute the capacity mask. |
| 406 lw(reg1, FieldMemOperand(elements, NumberDictionary::kCapacityOffset)); | 418 lw(reg1, FieldMemOperand(elements, SeededNumberDictionary::kCapacityOffset)); |
| 407 sra(reg1, reg1, kSmiTagSize); | 419 sra(reg1, reg1, kSmiTagSize); |
| 408 Subu(reg1, reg1, Operand(1)); | 420 Subu(reg1, reg1, Operand(1)); |
| 409 | 421 |
| 410 // Generate an unrolled loop that performs a few probes before giving up. | 422 // Generate an unrolled loop that performs a few probes before giving up. |
| 411 static const int kProbes = 4; | 423 static const int kProbes = 4; |
| 412 for (int i = 0; i < kProbes; i++) { | 424 for (int i = 0; i < kProbes; i++) { |
| 413 // Use reg2 for index calculations and keep the hash intact in reg0. | 425 // Use reg2 for index calculations and keep the hash intact in reg0. |
| 414 mov(reg2, reg0); | 426 mov(reg2, reg0); |
| 415 // Compute the masked index: (hash + i + i * i) & mask. | 427 // Compute the masked index: (hash + i + i * i) & mask. |
| 416 if (i > 0) { | 428 if (i > 0) { |
| 417 Addu(reg2, reg2, Operand(NumberDictionary::GetProbeOffset(i))); | 429 Addu(reg2, reg2, Operand(SeededNumberDictionary::GetProbeOffset(i))); |
| 418 } | 430 } |
| 419 and_(reg2, reg2, reg1); | 431 and_(reg2, reg2, reg1); |
| 420 | 432 |
| 421 // Scale the index by multiplying by the element size. | 433 // Scale the index by multiplying by the element size. |
| 422 ASSERT(NumberDictionary::kEntrySize == 3); | 434 ASSERT(SeededNumberDictionary::kEntrySize == 3); |
| 423 sll(at, reg2, 1); // 2x. | 435 sll(at, reg2, 1); // 2x. |
| 424 addu(reg2, reg2, at); // reg2 = reg2 * 3. | 436 addu(reg2, reg2, at); // reg2 = reg2 * 3. |
| 425 | 437 |
| 426 // Check if the key is identical to the name. | 438 // Check if the key is identical to the name. |
| 427 sll(at, reg2, kPointerSizeLog2); | 439 sll(at, reg2, kPointerSizeLog2); |
| 428 addu(reg2, elements, at); | 440 addu(reg2, elements, at); |
| 429 | 441 |
| 430 lw(at, FieldMemOperand(reg2, NumberDictionary::kElementsStartOffset)); | 442 lw(at, FieldMemOperand(reg2, SeededNumberDictionary::kElementsStartOffset)); |
| 431 if (i != kProbes - 1) { | 443 if (i != kProbes - 1) { |
| 432 Branch(&done, eq, key, Operand(at)); | 444 Branch(&done, eq, key, Operand(at)); |
| 433 } else { | 445 } else { |
| 434 Branch(miss, ne, key, Operand(at)); | 446 Branch(miss, ne, key, Operand(at)); |
| 435 } | 447 } |
| 436 } | 448 } |
| 437 | 449 |
| 438 bind(&done); | 450 bind(&done); |
| 439 // Check that the value is a normal property. | 451 // Check that the value is a normal property. |
| 440 // reg2: elements + (index * kPointerSize). | 452 // reg2: elements + (index * kPointerSize). |
| 441 const int kDetailsOffset = | 453 const int kDetailsOffset = |
| 442 NumberDictionary::kElementsStartOffset + 2 * kPointerSize; | 454 SeededNumberDictionary::kElementsStartOffset + 2 * kPointerSize; |
| 443 lw(reg1, FieldMemOperand(reg2, kDetailsOffset)); | 455 lw(reg1, FieldMemOperand(reg2, kDetailsOffset)); |
| 444 And(at, reg1, Operand(Smi::FromInt(PropertyDetails::TypeField::kMask))); | 456 And(at, reg1, Operand(Smi::FromInt(PropertyDetails::TypeField::kMask))); |
| 445 Branch(miss, ne, at, Operand(zero_reg)); | 457 Branch(miss, ne, at, Operand(zero_reg)); |
| 446 | 458 |
| 447 // Get the value at the masked, scaled index and return. | 459 // Get the value at the masked, scaled index and return. |
| 448 const int kValueOffset = | 460 const int kValueOffset = |
| 449 NumberDictionary::kElementsStartOffset + kPointerSize; | 461 SeededNumberDictionary::kElementsStartOffset + kPointerSize; |
| 450 lw(result, FieldMemOperand(reg2, kValueOffset)); | 462 lw(result, FieldMemOperand(reg2, kValueOffset)); |
| 451 } | 463 } |
| 452 | 464 |
| 453 | 465 |
| 454 // --------------------------------------------------------------------------- | 466 // --------------------------------------------------------------------------- |
| 455 // Instruction macros. | 467 // Instruction macros. |
| 456 | 468 |
| 457 void MacroAssembler::Addu(Register rd, Register rs, const Operand& rt) { | 469 void MacroAssembler::Addu(Register rd, Register rs, const Operand& rt) { |
| 458 if (rt.is_reg()) { | 470 if (rt.is_reg()) { |
| 459 addu(rd, rs, rt.rm()); | 471 addu(rd, rs, rt.rm()); |
| (...skipping 3943 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4403 opcode == BGTZL); | 4415 opcode == BGTZL); |
| 4404 opcode = (cond == eq) ? BEQ : BNE; | 4416 opcode = (cond == eq) ? BEQ : BNE; |
| 4405 instr = (instr & ~kOpcodeMask) | opcode; | 4417 instr = (instr & ~kOpcodeMask) | opcode; |
| 4406 masm_.emit(instr); | 4418 masm_.emit(instr); |
| 4407 } | 4419 } |
| 4408 | 4420 |
| 4409 | 4421 |
| 4410 } } // namespace v8::internal | 4422 } } // namespace v8::internal |
| 4411 | 4423 |
| 4412 #endif // V8_TARGET_ARCH_MIPS | 4424 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |