| 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 5171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5182 __ movzx_b(result_, FieldOperand(object_, | 5182 __ movzx_b(result_, FieldOperand(object_, |
| 5183 scratch_, times_1, | 5183 scratch_, times_1, |
| 5184 SeqAsciiString::kHeaderSize)); | 5184 SeqAsciiString::kHeaderSize)); |
| 5185 __ bind(&got_char_code); | 5185 __ bind(&got_char_code); |
| 5186 __ SmiTag(result_); | 5186 __ SmiTag(result_); |
| 5187 __ bind(&exit_); | 5187 __ bind(&exit_); |
| 5188 } | 5188 } |
| 5189 | 5189 |
| 5190 | 5190 |
| 5191 void StringCharCodeAtGenerator::GenerateSlow( | 5191 void StringCharCodeAtGenerator::GenerateSlow( |
| 5192 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5192 MacroAssembler* masm, |
| 5193 const RuntimeCallHelper& call_helper) { |
| 5193 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); | 5194 __ Abort("Unexpected fallthrough to CharCodeAt slow case"); |
| 5194 | 5195 |
| 5195 // Index is not a smi. | 5196 // Index is not a smi. |
| 5196 __ bind(&index_not_smi_); | 5197 __ bind(&index_not_smi_); |
| 5197 // If index is a heap number, try converting it to an integer. | 5198 // If index is a heap number, try converting it to an integer. |
| 5198 __ CheckMap(index_, | 5199 __ CheckMap(index_, |
| 5199 masm->isolate()->factory()->heap_number_map(), | 5200 masm->isolate()->factory()->heap_number_map(), |
| 5200 index_not_number_, | 5201 index_not_number_, |
| 5201 DONT_DO_SMI_CHECK); | 5202 DONT_DO_SMI_CHECK); |
| 5202 call_helper.BeforeCall(masm); | 5203 call_helper.BeforeCall(masm); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5267 __ mov(result_, FieldOperand(result_, | 5268 __ mov(result_, FieldOperand(result_, |
| 5268 code_, times_half_pointer_size, | 5269 code_, times_half_pointer_size, |
| 5269 FixedArray::kHeaderSize)); | 5270 FixedArray::kHeaderSize)); |
| 5270 __ cmp(result_, factory->undefined_value()); | 5271 __ cmp(result_, factory->undefined_value()); |
| 5271 __ j(equal, &slow_case_); | 5272 __ j(equal, &slow_case_); |
| 5272 __ bind(&exit_); | 5273 __ bind(&exit_); |
| 5273 } | 5274 } |
| 5274 | 5275 |
| 5275 | 5276 |
| 5276 void StringCharFromCodeGenerator::GenerateSlow( | 5277 void StringCharFromCodeGenerator::GenerateSlow( |
| 5277 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5278 MacroAssembler* masm, |
| 5279 const RuntimeCallHelper& call_helper) { |
| 5278 __ Abort("Unexpected fallthrough to CharFromCode slow case"); | 5280 __ Abort("Unexpected fallthrough to CharFromCode slow case"); |
| 5279 | 5281 |
| 5280 __ bind(&slow_case_); | 5282 __ bind(&slow_case_); |
| 5281 call_helper.BeforeCall(masm); | 5283 call_helper.BeforeCall(masm); |
| 5282 __ push(code_); | 5284 __ push(code_); |
| 5283 __ CallRuntime(Runtime::kCharFromCode, 1); | 5285 __ CallRuntime(Runtime::kCharFromCode, 1); |
| 5284 if (!result_.is(eax)) { | 5286 if (!result_.is(eax)) { |
| 5285 __ mov(result_, eax); | 5287 __ mov(result_, eax); |
| 5286 } | 5288 } |
| 5287 call_helper.AfterCall(masm); | 5289 call_helper.AfterCall(masm); |
| 5288 __ jmp(&exit_); | 5290 __ jmp(&exit_); |
| 5289 | 5291 |
| 5290 __ Abort("Unexpected fallthrough from CharFromCode slow case"); | 5292 __ Abort("Unexpected fallthrough from CharFromCode slow case"); |
| 5291 } | 5293 } |
| 5292 | 5294 |
| 5293 | 5295 |
| 5294 // ------------------------------------------------------------------------- | 5296 // ------------------------------------------------------------------------- |
| 5295 // StringCharAtGenerator | 5297 // StringCharAtGenerator |
| 5296 | 5298 |
| 5297 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) { | 5299 void StringCharAtGenerator::GenerateFast(MacroAssembler* masm) { |
| 5298 char_code_at_generator_.GenerateFast(masm); | 5300 char_code_at_generator_.GenerateFast(masm); |
| 5299 char_from_code_generator_.GenerateFast(masm); | 5301 char_from_code_generator_.GenerateFast(masm); |
| 5300 } | 5302 } |
| 5301 | 5303 |
| 5302 | 5304 |
| 5303 void StringCharAtGenerator::GenerateSlow( | 5305 void StringCharAtGenerator::GenerateSlow( |
| 5304 MacroAssembler* masm, const RuntimeCallHelper& call_helper) { | 5306 MacroAssembler* masm, |
| 5307 const RuntimeCallHelper& call_helper) { |
| 5305 char_code_at_generator_.GenerateSlow(masm, call_helper); | 5308 char_code_at_generator_.GenerateSlow(masm, call_helper); |
| 5306 char_from_code_generator_.GenerateSlow(masm, call_helper); | 5309 char_from_code_generator_.GenerateSlow(masm, call_helper); |
| 5307 } | 5310 } |
| 5308 | 5311 |
| 5309 | 5312 |
| 5310 void StringAddStub::Generate(MacroAssembler* masm) { | 5313 void StringAddStub::Generate(MacroAssembler* masm) { |
| 5311 Label string_add_runtime, call_builtin; | 5314 Label string_add_runtime, call_builtin; |
| 5312 Builtins::JavaScript builtin_id = Builtins::ADD; | 5315 Builtins::JavaScript builtin_id = Builtins::ADD; |
| 5313 | 5316 |
| 5314 // Load the two arguments. | 5317 // Load the two arguments. |
| (...skipping 1277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6592 StringDictionaryLookupStub::NEGATIVE_LOOKUP); | 6595 StringDictionaryLookupStub::NEGATIVE_LOOKUP); |
| 6593 __ push(Immediate(Handle<Object>(name))); | 6596 __ push(Immediate(Handle<Object>(name))); |
| 6594 __ push(Immediate(name->Hash())); | 6597 __ push(Immediate(name->Hash())); |
| 6595 __ CallStub(&stub); | 6598 __ CallStub(&stub); |
| 6596 __ test(r0, r0); | 6599 __ test(r0, r0); |
| 6597 __ j(not_zero, miss); | 6600 __ j(not_zero, miss); |
| 6598 __ jmp(done); | 6601 __ jmp(done); |
| 6599 } | 6602 } |
| 6600 | 6603 |
| 6601 | 6604 |
| 6602 // TODO(kmillikin): Eliminate this function when the stub cache is fully | |
| 6603 // handlified. | |
| 6604 MaybeObject* StringDictionaryLookupStub::TryGenerateNegativeLookup( | |
| 6605 MacroAssembler* masm, | |
| 6606 Label* miss, | |
| 6607 Label* done, | |
| 6608 Register properties, | |
| 6609 String* name, | |
| 6610 Register r0) { | |
| 6611 ASSERT(name->IsSymbol()); | |
| 6612 | |
| 6613 // If names of slots in range from 1 to kProbes - 1 for the hash value are | |
| 6614 // not equal to the name and kProbes-th slot is not used (its name is the | |
| 6615 // undefined value), it guarantees the hash table doesn't contain the | |
| 6616 // property. It's true even if some slots represent deleted properties | |
| 6617 // (their names are the null value). | |
| 6618 for (int i = 0; i < kInlinedProbes; i++) { | |
| 6619 // Compute the masked index: (hash + i + i * i) & mask. | |
| 6620 Register index = r0; | |
| 6621 // Capacity is smi 2^n. | |
| 6622 __ mov(index, FieldOperand(properties, kCapacityOffset)); | |
| 6623 __ dec(index); | |
| 6624 __ and_(index, | |
| 6625 Immediate(Smi::FromInt(name->Hash() + | |
| 6626 StringDictionary::GetProbeOffset(i)))); | |
| 6627 | |
| 6628 // Scale the index by multiplying by the entry size. | |
| 6629 ASSERT(StringDictionary::kEntrySize == 3); | |
| 6630 __ lea(index, Operand(index, index, times_2, 0)); // index *= 3. | |
| 6631 Register entity_name = r0; | |
| 6632 // Having undefined at this place means the name is not contained. | |
| 6633 ASSERT_EQ(kSmiTagSize, 1); | |
| 6634 __ mov(entity_name, Operand(properties, index, times_half_pointer_size, | |
| 6635 kElementsStartOffset - kHeapObjectTag)); | |
| 6636 __ cmp(entity_name, masm->isolate()->factory()->undefined_value()); | |
| 6637 __ j(equal, done); | |
| 6638 | |
| 6639 // Stop if found the property. | |
| 6640 __ cmp(entity_name, Handle<String>(name)); | |
| 6641 __ j(equal, miss); | |
| 6642 | |
| 6643 // Check if the entry name is not a symbol. | |
| 6644 __ mov(entity_name, FieldOperand(entity_name, HeapObject::kMapOffset)); | |
| 6645 __ test_b(FieldOperand(entity_name, Map::kInstanceTypeOffset), | |
| 6646 kIsSymbolMask); | |
| 6647 __ j(zero, miss); | |
| 6648 } | |
| 6649 | |
| 6650 StringDictionaryLookupStub stub(properties, | |
| 6651 r0, | |
| 6652 r0, | |
| 6653 StringDictionaryLookupStub::NEGATIVE_LOOKUP); | |
| 6654 __ push(Immediate(Handle<Object>(name))); | |
| 6655 __ push(Immediate(name->Hash())); | |
| 6656 MaybeObject* result = masm->TryCallStub(&stub); | |
| 6657 if (result->IsFailure()) return result; | |
| 6658 __ test(r0, r0); | |
| 6659 __ j(not_zero, miss); | |
| 6660 __ jmp(done); | |
| 6661 return result; | |
| 6662 } | |
| 6663 | |
| 6664 | |
| 6665 // Probe the string dictionary in the |elements| register. Jump to the | 6605 // Probe the string dictionary in the |elements| register. Jump to the |
| 6666 // |done| label if a property with the given name is found leaving the | 6606 // |done| label if a property with the given name is found leaving the |
| 6667 // index into the dictionary in |r0|. Jump to the |miss| label | 6607 // index into the dictionary in |r0|. Jump to the |miss| label |
| 6668 // otherwise. | 6608 // otherwise. |
| 6669 void StringDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, | 6609 void StringDictionaryLookupStub::GeneratePositiveLookup(MacroAssembler* masm, |
| 6670 Label* miss, | 6610 Label* miss, |
| 6671 Label* done, | 6611 Label* done, |
| 6672 Register elements, | 6612 Register elements, |
| 6673 Register name, | 6613 Register name, |
| 6674 Register r0, | 6614 Register r0, |
| (...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 7082 __ bind(&need_incremental); | 7022 __ bind(&need_incremental); |
| 7083 | 7023 |
| 7084 // Fall through when we need to inform the incremental marker. | 7024 // Fall through when we need to inform the incremental marker. |
| 7085 } | 7025 } |
| 7086 | 7026 |
| 7087 #undef __ | 7027 #undef __ |
| 7088 | 7028 |
| 7089 } } // namespace v8::internal | 7029 } } // namespace v8::internal |
| 7090 | 7030 |
| 7091 #endif // V8_TARGET_ARCH_IA32 | 7031 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |