| OLD | NEW |
| 1 // Copyright 2006-2009 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2009 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 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 ASSERT(!scratch.is(name)); | 119 ASSERT(!scratch.is(name)); |
| 120 ASSERT(!extra.is(receiver)); | 120 ASSERT(!extra.is(receiver)); |
| 121 ASSERT(!extra.is(name)); | 121 ASSERT(!extra.is(name)); |
| 122 ASSERT(!extra.is(scratch)); | 122 ASSERT(!extra.is(scratch)); |
| 123 | 123 |
| 124 // Check that the receiver isn't a smi. | 124 // Check that the receiver isn't a smi. |
| 125 __ test(receiver, Immediate(kSmiTagMask)); | 125 __ test(receiver, Immediate(kSmiTagMask)); |
| 126 __ j(zero, &miss, not_taken); | 126 __ j(zero, &miss, not_taken); |
| 127 | 127 |
| 128 // Get the map of the receiver and compute the hash. | 128 // Get the map of the receiver and compute the hash. |
| 129 __ mov(scratch, FieldOperand(name, String::kLengthOffset)); | 129 __ mov(scratch, FieldOperand(name, String::kHashFieldOffset)); |
| 130 __ add(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 130 __ add(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 131 __ xor_(scratch, flags); | 131 __ xor_(scratch, flags); |
| 132 __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); | 132 __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); |
| 133 | 133 |
| 134 // Probe the primary table. | 134 // Probe the primary table. |
| 135 ProbeTable(masm, flags, kPrimary, name, scratch, extra); | 135 ProbeTable(masm, flags, kPrimary, name, scratch, extra); |
| 136 | 136 |
| 137 // Primary miss: Compute hash for secondary probe. | 137 // Primary miss: Compute hash for secondary probe. |
| 138 __ mov(scratch, FieldOperand(name, String::kLengthOffset)); | 138 __ mov(scratch, FieldOperand(name, String::kHashFieldOffset)); |
| 139 __ add(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 139 __ add(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 140 __ xor_(scratch, flags); | 140 __ xor_(scratch, flags); |
| 141 __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); | 141 __ and_(scratch, (kPrimaryTableSize - 1) << kHeapObjectTagSize); |
| 142 __ sub(scratch, Operand(name)); | 142 __ sub(scratch, Operand(name)); |
| 143 __ add(Operand(scratch), Immediate(flags)); | 143 __ add(Operand(scratch), Immediate(flags)); |
| 144 __ and_(scratch, (kSecondaryTableSize - 1) << kHeapObjectTagSize); | 144 __ and_(scratch, (kSecondaryTableSize - 1) << kHeapObjectTagSize); |
| 145 | 145 |
| 146 // Probe the secondary table. | 146 // Probe the secondary table. |
| 147 ProbeTable(masm, flags, kSecondary, name, scratch, extra); | 147 ProbeTable(masm, flags, kSecondary, name, scratch, extra); |
| 148 | 148 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | 227 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, |
| 228 Register receiver, | 228 Register receiver, |
| 229 Register scratch, | 229 Register scratch, |
| 230 Label* miss) { | 230 Label* miss) { |
| 231 Label load_length, check_wrapper; | 231 Label load_length, check_wrapper; |
| 232 | 232 |
| 233 // Check if the object is a string leaving the instance type in the | 233 // Check if the object is a string leaving the instance type in the |
| 234 // scratch register. | 234 // scratch register. |
| 235 GenerateStringCheck(masm, receiver, scratch, miss, &check_wrapper); | 235 GenerateStringCheck(masm, receiver, scratch, miss, &check_wrapper); |
| 236 | 236 |
| 237 // Load length directly from the string. | 237 // Load length from the string and convert to a smi. |
| 238 __ bind(&load_length); | 238 __ bind(&load_length); |
| 239 __ and_(scratch, kStringSizeMask); | |
| 240 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); | 239 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); |
| 241 // ecx is also the receiver. | |
| 242 __ lea(ecx, Operand(scratch, String::kLongLengthShift)); | |
| 243 __ shr_cl(eax); | |
| 244 __ shl(eax, kSmiTagSize); | 240 __ shl(eax, kSmiTagSize); |
| 245 __ ret(0); | 241 __ ret(0); |
| 246 | 242 |
| 247 // Check if the object is a JSValue wrapper. | 243 // Check if the object is a JSValue wrapper. |
| 248 __ bind(&check_wrapper); | 244 __ bind(&check_wrapper); |
| 249 __ cmp(scratch, JS_VALUE_TYPE); | 245 __ cmp(scratch, JS_VALUE_TYPE); |
| 250 __ j(not_equal, miss, not_taken); | 246 __ j(not_equal, miss, not_taken); |
| 251 | 247 |
| 252 // Check if the wrapped value is a string and load the length | 248 // Check if the wrapped value is a string and load the length |
| 253 // directly if it is. | 249 // directly if it is. |
| (...skipping 1633 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1887 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); | 1883 __ jmp(generic_construct_stub, RelocInfo::CODE_TARGET); |
| 1888 | 1884 |
| 1889 // Return the generated code. | 1885 // Return the generated code. |
| 1890 return GetCode(); | 1886 return GetCode(); |
| 1891 } | 1887 } |
| 1892 | 1888 |
| 1893 | 1889 |
| 1894 #undef __ | 1890 #undef __ |
| 1895 | 1891 |
| 1896 } } // namespace v8::internal | 1892 } } // namespace v8::internal |
| OLD | NEW |