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 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
149 __ ldr(r0, FieldMemOperand(r0, JSArray::kLengthOffset)); | 149 __ ldr(r0, FieldMemOperand(r0, JSArray::kLengthOffset)); |
150 __ Ret(); | 150 __ Ret(); |
151 | 151 |
152 // Cache miss: Jump to runtime. | 152 // Cache miss: Jump to runtime. |
153 __ bind(&miss); | 153 __ bind(&miss); |
154 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 154 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); |
155 __ Jump(ic, RelocInfo::CODE_TARGET); | 155 __ Jump(ic, RelocInfo::CODE_TARGET); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 // Generate code to check is an object is a string. If the object is | |
160 // a string, the map's instance type is left in the scratch1 register. | |
161 static void GenerateStringCheck(MacroAssembler* masm, | |
162 Register receiver, | |
163 Register scratch1, | |
Erik Corry
2008/10/27 14:41:23
This shouldn't be called scratch, since we are goi
| |
164 Register scratch2, | |
165 Label* smi, | |
166 Label* non_string_object) { | |
167 // Check that the receiver isn't a smi. | |
168 __ tst(receiver, Operand(kSmiTagMask)); | |
169 __ b(eq, smi); | |
170 | |
171 // Check that the object is a string. | |
172 __ ldr(scratch1, FieldMemOperand(receiver, HeapObject::kMapOffset)); | |
173 __ ldrb(scratch1, FieldMemOperand(scratch1, Map::kInstanceTypeOffset)); | |
174 __ and_(scratch2, scratch1, Operand(kIsNotStringMask)); | |
175 // The cast is to resolve the overload for the argument of 0x0. | |
176 __ cmp(scratch2, Operand(static_cast<int32_t>(kStringTag))); | |
177 __ b(ne, non_string_object); | |
178 } | |
179 | |
180 | |
159 void LoadIC::GenerateStringLength(MacroAssembler* masm) { | 181 void LoadIC::GenerateStringLength(MacroAssembler* masm) { |
160 // ----------- S t a t e ------------- | 182 // ----------- S t a t e ------------- |
161 // -- r2 : name | 183 // -- r2 : name |
162 // -- lr : return address | 184 // -- lr : return address |
163 // -- [sp] : receiver | 185 // -- [sp] : receiver |
164 // ----------------------------------- | 186 // ----------------------------------- |
165 | 187 |
166 Label miss; | 188 Label miss, load_length, check_wrapper; |
167 | 189 |
168 __ ldr(r0, MemOperand(sp, 0)); | 190 __ ldr(r0, MemOperand(sp, 0)); |
169 | 191 |
170 // Check that the receiver isn't a smi. | 192 // Check if the object is a string. |
171 __ tst(r0, Operand(kSmiTagMask)); | 193 GenerateStringCheck(masm, r0, r1, r3, &miss, &check_wrapper); |
172 __ b(eq, &miss); | |
173 | 194 |
174 // Check that the object is a string. | 195 // Load length directly from the string. |
175 __ ldr(r1, FieldMemOperand(r0, HeapObject::kMapOffset)); | 196 __ bind(&load_length); |
176 __ ldrb(r1, FieldMemOperand(r1, Map::kInstanceTypeOffset)); | |
177 __ and_(r3, r1, Operand(kIsNotStringMask)); | |
178 // The cast is to resolve the overload for the argument of 0x0. | |
179 __ cmp(r3, Operand(static_cast<int32_t>(kStringTag))); | |
180 __ b(ne, &miss); | |
181 | |
182 __ and_(r1, r1, Operand(kStringSizeMask)); | 197 __ and_(r1, r1, Operand(kStringSizeMask)); |
183 __ add(r1, r1, Operand(String::kHashShift)); | 198 __ add(r1, r1, Operand(String::kHashShift)); |
184 // Load length directly from the string. | |
185 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); | 199 __ ldr(r0, FieldMemOperand(r0, String::kLengthOffset)); |
186 __ mov(r0, Operand(r0, LSR, r1)); | 200 __ mov(r0, Operand(r0, LSR, r1)); |
187 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); | 201 __ mov(r0, Operand(r0, LSL, kSmiTagSize)); |
188 __ Ret(); | 202 __ Ret(); |
189 | 203 |
204 // Check if the object is a JSValue wrapper. | |
205 __ bind(&check_wrapper); | |
206 __ cmp(r0, Operand(JS_VALUE_TYPE)); | |
207 __ b(ne, &miss); | |
208 | |
209 // Check if the wrapped value is a string and load the length | |
210 // directly if it is. | |
211 __ ldr(r0, FieldMemOperand(r0, JSValue::kValueOffset)); | |
212 GenerateStringCheck(masm, r0, r1, r3, &miss, &miss); | |
213 __ b(&load_length); | |
214 | |
190 // Cache miss: Jump to runtime. | 215 // Cache miss: Jump to runtime. |
191 __ bind(&miss); | 216 __ bind(&miss); |
192 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 217 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); |
193 __ Jump(ic, RelocInfo::CODE_TARGET); | 218 __ Jump(ic, RelocInfo::CODE_TARGET); |
194 } | 219 } |
195 | 220 |
196 | 221 |
197 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { | 222 void LoadIC::GenerateFunctionPrototype(MacroAssembler* masm) { |
198 // ----------- S t a t e ------------- | 223 // ----------- S t a t e ------------- |
199 // -- r2 : name | 224 // -- r2 : name |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
522 | 547 |
523 // Perform tail call to the entry. | 548 // Perform tail call to the entry. |
524 __ TailCallRuntime(f, 3); | 549 __ TailCallRuntime(f, 3); |
525 } | 550 } |
526 | 551 |
527 | 552 |
528 #undef __ | 553 #undef __ |
529 | 554 |
530 | 555 |
531 } } // namespace v8::internal | 556 } } // namespace v8::internal |
OLD | NEW |