OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 __ j(not_zero, non_string_object, not_taken); | 178 __ j(not_zero, non_string_object, not_taken); |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, | 182 void StubCompiler::GenerateLoadStringLength(MacroAssembler* masm, |
183 Register receiver, | 183 Register receiver, |
184 Register scratch, | 184 Register scratch, |
185 Label* miss) { | 185 Label* miss) { |
186 Label load_length, check_wrapper; | 186 Label load_length, check_wrapper; |
187 | 187 |
188 // Check if the object is a string. | 188 // Check if the object is a string leaving the instance type in the |
| 189 // scratch register. |
189 GenerateStringCheck(masm, receiver, scratch, miss, &check_wrapper); | 190 GenerateStringCheck(masm, receiver, scratch, miss, &check_wrapper); |
190 | 191 |
191 // Load length directly from the string. | 192 // Load length directly from the string. |
192 __ bind(&load_length); | 193 __ bind(&load_length); |
193 __ and_(scratch, kStringSizeMask); | 194 __ and_(scratch, kStringSizeMask); |
194 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); | 195 __ mov(eax, FieldOperand(receiver, String::kLengthOffset)); |
195 // ecx is also the receiver. | 196 // ecx is also the receiver. |
196 __ lea(ecx, Operand(scratch, String::kLongLengthShift)); | 197 __ lea(ecx, Operand(scratch, String::kLongLengthShift)); |
197 __ shr(eax); // ecx is implicit shift register. | 198 __ shr(eax); // ecx is implicit shift register. |
198 __ shl(eax, kSmiTagSize); | 199 __ shl(eax, kSmiTagSize); |
199 __ ret(0); | 200 __ ret(0); |
200 | 201 |
201 // Check if the object is a JSValue wrapper. | 202 // Check if the object is a JSValue wrapper. |
202 __ bind(&check_wrapper); | 203 __ bind(&check_wrapper); |
203 __ cmp(receiver, JS_VALUE_TYPE); | 204 __ cmp(scratch, JS_VALUE_TYPE); |
204 __ j(not_equal, miss, not_taken); | 205 __ j(not_equal, miss, not_taken); |
205 | 206 |
206 // Check if the wrapped value is a string and load the length | 207 // Check if the wrapped value is a string and load the length |
207 // directly if it is. | 208 // directly if it is. |
208 __ mov(receiver, FieldOperand(receiver, JSValue::kValueOffset)); | 209 __ mov(receiver, FieldOperand(receiver, JSValue::kValueOffset)); |
209 GenerateStringCheck(masm, receiver, scratch, miss, miss); | 210 GenerateStringCheck(masm, receiver, scratch, miss, miss); |
210 __ jmp(&load_length); | 211 __ jmp(&load_length); |
211 } | 212 } |
212 | 213 |
213 | 214 |
(...skipping 987 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 1202 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
1202 | 1203 |
1203 // Return the generated code. | 1204 // Return the generated code. |
1204 return GetCode(CALLBACKS); | 1205 return GetCode(CALLBACKS); |
1205 } | 1206 } |
1206 | 1207 |
1207 | 1208 |
1208 #undef __ | 1209 #undef __ |
1209 | 1210 |
1210 } } // namespace v8::internal | 1211 } } // namespace v8::internal |
OLD | NEW |