| 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 5333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5344 | 5344 |
| 5345 __ lbu(result_, FieldMemOperand(scratch_, SeqAsciiString::kHeaderSize)); | 5345 __ lbu(result_, FieldMemOperand(scratch_, SeqAsciiString::kHeaderSize)); |
| 5346 | 5346 |
| 5347 __ bind(&got_char_code); | 5347 __ bind(&got_char_code); |
| 5348 __ sll(result_, result_, kSmiTagSize); | 5348 __ sll(result_, result_, kSmiTagSize); |
| 5349 __ bind(&exit_); | 5349 __ bind(&exit_); |
| 5350 } | 5350 } |
| 5351 | 5351 |
| 5352 | 5352 |
| 5353 void StringCharCodeAtGenerator::GenerateSlow( | 5353 void StringCharCodeAtGenerator::GenerateSlow( |
| 5354 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5354 MacroAssembler* masm, |
| 5355 const RuntimeCallHelper& call_helper) { |
| 5355 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); | 5356 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); |
| 5356 | 5357 |
| 5357 // Index is not a smi. | 5358 // Index is not a smi. |
| 5358 __ bind(&index_not_smi_); | 5359 __ bind(&index_not_smi_); |
| 5359 // If index is a heap number, try converting it to an integer. | 5360 // If index is a heap number, try converting it to an integer. |
| 5360 __ CheckMap(index_, | 5361 __ CheckMap(index_, |
| 5361 scratch_, | 5362 scratch_, |
| 5362 Heap::kHeapNumberMapRootIndex, | 5363 Heap::kHeapNumberMapRootIndex, |
| 5363 index_not_number_, | 5364 index_not_number_, |
| 5364 DONT_DO_SMI_CHECK); | 5365 DONT_DO_SMI_CHECK); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5430 __ sll(t0, code_, kPointerSizeLog2 - kSmiTagSize); | 5431 __ sll(t0, code_, kPointerSizeLog2 - kSmiTagSize); |
| 5431 __ Addu(result_, result_, t0); | 5432 __ Addu(result_, result_, t0); |
| 5432 __ lw(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); | 5433 __ lw(result_, FieldMemOperand(result_, FixedArray::kHeaderSize)); |
| 5433 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); | 5434 __ LoadRoot(t0, Heap::kUndefinedValueRootIndex); |
| 5434 __ Branch(&slow_case_, eq, result_, Operand(t0)); | 5435 __ Branch(&slow_case_, eq, result_, Operand(t0)); |
| 5435 __ bind(&exit_); | 5436 __ bind(&exit_); |
| 5436 } | 5437 } |
| 5437 | 5438 |
| 5438 | 5439 |
| 5439 void StringCharFromCodeGenerator::GenerateSlow( | 5440 void StringCharFromCodeGenerator::GenerateSlow( |
| 5440 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5441 MacroAssembler* masm, |
| 5442 const RuntimeCallHelper& call_helper) { |
| 5441 __ Abort("Unexpected fallthrough to CharFromCode slow case"); | 5443 __ Abort("Unexpected fallthrough to CharFromCode slow case"); |
| 5442 | 5444 |
| 5443 __ bind(&slow_case_); | 5445 __ bind(&slow_case_); |
| 5444 call_helper.BeforeCall(masm); | 5446 call_helper.BeforeCall(masm); |
| 5445 __ push(code_); | 5447 __ push(code_); |
| 5446 __ CallRuntime(Runtime::kCharFromCode, 1); | 5448 __ CallRuntime(Runtime::kCharFromCode, 1); |
| 5447 __ Move(result_, v0); | 5449 __ Move(result_, v0); |
| 5448 | 5450 |
| 5449 call_helper.AfterCall(masm); | 5451 call_helper.AfterCall(masm); |
| 5450 __ Branch(&exit_); | 5452 __ Branch(&exit_); |
| 5451 | 5453 |
| 5452 __ Abort("Unexpected fallthrough from CharFromCode slow case"); | 5454 __ Abort("Unexpected fallthrough from CharFromCode slow case"); |
| 5453 } | 5455 } |
| 5454 | 5456 |
| 5455 | 5457 |
| 5456 // ------------------------------------------------------------------------- | 5458 // ------------------------------------------------------------------------- |
| 5457 // StringCharAtGenerator | 5459 // StringCharAtGenerator |
| 5458 | 5460 |
| 5459 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) { | 5461 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) { |
| 5460 char_code_at_generator_.GenerateFast(masm); | 5462 char_code_at_generator_.GenerateFast(masm); |
| 5461 char_from_code_generator_.GenerateFast(masm); | 5463 char_from_code_generator_.GenerateFast(masm); |
| 5462 } | 5464 } |
| 5463 | 5465 |
| 5464 | 5466 |
| 5465 void StringCharAtGenerator::GenerateSlow( | 5467 void StringCharAtGenerator::GenerateSlow( |
| 5466 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5468 MacroAssembler* masm, |
| 5469 const RuntimeCallHelper& call_helper) { |
| 5467 char_code_at_generator_.GenerateSlow(masm, call_helper); | 5470 char_code_at_generator_.GenerateSlow(masm, call_helper); |
| 5468 char_from_code_generator_.GenerateSlow(masm, call_helper); | 5471 char_from_code_generator_.GenerateSlow(masm, call_helper); |
| 5469 } | 5472 } |
| 5470 | 5473 |
| 5471 | 5474 |
| 5472 class StringHelper : public AllStatic { | 5475 class StringHelper : public AllStatic { |
| 5473 public: | 5476 public: |
| 5474 // Generate code for copying characters using a simple loop. This should only | 5477 // Generate code for copying characters using a simple loop. This should only |
| 5475 // be used in places where the number of characters is small and the | 5478 // be used in places where the number of characters is small and the |
| 5476 // additional setup and checking in GenerateCopyCharactersLong adds too much | 5479 // additional setup and checking in GenerateCopyCharactersLong adds too much |
| (...skipping 1537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7014 StringDictionaryLookupStub stub(NEGATIVE_LOOKUP); | 7017 StringDictionaryLookupStub stub(NEGATIVE_LOOKUP); |
| 7015 __ CallStub(&stub); | 7018 __ CallStub(&stub); |
| 7016 __ mov(at, v0); | 7019 __ mov(at, v0); |
| 7017 __ MultiPop(spill_mask); | 7020 __ MultiPop(spill_mask); |
| 7018 | 7021 |
| 7019 __ Branch(done, eq, at, Operand(zero_reg)); | 7022 __ Branch(done, eq, at, Operand(zero_reg)); |
| 7020 __ Branch(miss, ne, at, Operand(zero_reg)); | 7023 __ Branch(miss, ne, at, Operand(zero_reg)); |
| 7021 } | 7024 } |
| 7022 | 7025 |
| 7023 | 7026 |
| 7024 // TODO(kmillikin): Eliminate this function when the stub cache is fully | |
| 7025 // handlified. | |
| 7026 MaybeObject* StringDictionaryLookupStub::TryGenerateNegativeLookup( | |
| 7027 MacroAssembler* masm, | |
| 7028 Label* miss, | |
| 7029 Label* done, | |
| 7030 Register receiver, | |
| 7031 Register properties, | |
| 7032 String* name, | |
| 7033 Register scratch0) { | |
| 7034 // If names of slots in range from 1 to kProbes - 1 for the hash value are | |
| 7035 // not equal to the name and kProbes-th slot is not used (its name is the | |
| 7036 // undefined value), it guarantees the hash table doesn't contain the | |
| 7037 // property. It's true even if some slots represent deleted properties | |
| 7038 // (their names are the null value). | |
| 7039 for (int i = 0; i < kInlinedProbes; i++) { | |
| 7040 // scratch0 points to properties hash. | |
| 7041 // Compute the masked index: (hash + i + i * i) & mask. | |
| 7042 Register index = scratch0; | |
| 7043 // Capacity is smi 2^n. | |
| 7044 __ lw(index, FieldMemOperand(properties, kCapacityOffset)); | |
| 7045 __ Subu(index, index, Operand(1)); | |
| 7046 __ And(index, index, Operand( | |
| 7047 Smi::FromInt(name->Hash() + StringDictionary::GetProbeOffset(i)))); | |
| 7048 | |
| 7049 // Scale the index by multiplying by the entry size. | |
| 7050 ASSERT(StringDictionary::kEntrySize == 3); | |
| 7051 // index *= 3. | |
| 7052 __ sll(at, index, 1); | |
| 7053 __ Addu(index, index, at); | |
| 7054 | |
| 7055 Register entity_name = scratch0; | |
| 7056 // Having undefined at this place means the name is not contained. | |
| 7057 ASSERT_EQ(kSmiTagSize, 1); | |
| 7058 Register tmp = properties; | |
| 7059 | |
| 7060 __ sll(scratch0, index, 1); | |
| 7061 __ Addu(tmp, properties, scratch0); | |
| 7062 __ lw(entity_name, FieldMemOperand(tmp, kElementsStartOffset)); | |
| 7063 | |
| 7064 ASSERT(!tmp.is(entity_name)); | |
| 7065 __ LoadRoot(tmp, Heap::kUndefinedValueRootIndex); | |
| 7066 __ Branch(done, eq, entity_name, Operand(tmp)); | |
| 7067 | |
| 7068 if (i != kInlinedProbes - 1) { | |
| 7069 // Stop if found the property. | |
| 7070 __ Branch(miss, eq, entity_name, Operand(Handle<String>(name))); | |
| 7071 | |
| 7072 // Check if the entry name is not a symbol. | |
| 7073 __ lw(entity_name, FieldMemOperand(entity_name, HeapObject::kMapOffset)); | |
| 7074 __ lbu(entity_name, | |
| 7075 FieldMemOperand(entity_name, Map::kInstanceTypeOffset)); | |
| 7076 __ And(scratch0, entity_name, Operand(kIsSymbolMask)); | |
| 7077 __ Branch(miss, eq, scratch0, Operand(zero_reg)); | |
| 7078 | |
| 7079 // Restore the properties. | |
| 7080 __ lw(properties, | |
| 7081 FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | |
| 7082 } | |
| 7083 } | |
| 7084 | |
| 7085 const int spill_mask = | |
| 7086 (ra.bit() | t2.bit() | t1.bit() | t0.bit() | a3.bit() | | |
| 7087 a2.bit() | a1.bit() | a0.bit() | v0.bit()); | |
| 7088 | |
| 7089 __ MultiPush(spill_mask); | |
| 7090 __ lw(a0, FieldMemOperand(receiver, JSObject::kPropertiesOffset)); | |
| 7091 __ li(a1, Operand(Handle<String>(name))); | |
| 7092 StringDictionaryLookupStub stub(NEGATIVE_LOOKUP); | |
| 7093 MaybeObject* result = masm->TryCallStub(&stub); | |
| 7094 if (result->IsFailure()) return result; | |
| 7095 __ mov(at, v0); | |
| 7096 __ MultiPop(spill_mask); | |
| 7097 | |
| 7098 __ Branch(done, eq, at, Operand(zero_reg)); | |
| 7099 __ Branch(miss, ne, at, Operand(zero_reg)); | |
| 7100 return result; | |
| 7101 } | |
| 7102 | |
| 7103 | |
| 7104 // Probe the string dictionary in the |elements| register. Jump to the | 7027 // Probe the string dictionary in the |elements| register. Jump to the |
| 7105 // |done| label if a property with the given name is found. Jump to | 7028 // |done| label if a property with the given name is found. Jump to |
| 7106 // the |miss| label otherwise. | 7029 // the |miss| label otherwise. |
| 7107 // If lookup was successful |scratch2| will be equal to elements + 4 * index. | 7030 // If lookup was successful |scratch2| will be equal to elements + 4 * index. |
| 7108 void StringDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | 7031 void StringDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, |
| 7109 Label* miss, | 7032 Label* miss, |
| 7110 Label* done, | 7033 Label* done, |
| 7111 Register elements, | 7034 Register elements, |
| 7112 Register name, | 7035 Register name, |
| 7113 Register scratch1, | 7036 Register scratch1, |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7546 | 7469 |
| 7547 // Fall through when we need to inform the incremental marker. | 7470 // Fall through when we need to inform the incremental marker. |
| 7548 } | 7471 } |
| 7549 | 7472 |
| 7550 | 7473 |
| 7551 #undef __ | 7474 #undef __ |
| 7552 | 7475 |
| 7553 } } // namespace v8::internal | 7476 } } // namespace v8::internal |
| 7554 | 7477 |
| 7555 #endif // V8_TARGET_ARCH_MIPS | 7478 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |