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 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 Register receiver, | 231 Register receiver, |
232 Register scratch1, | 232 Register scratch1, |
233 Register scratch2, | 233 Register scratch2, |
234 Label* miss_label) { | 234 Label* miss_label) { |
235 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); | 235 __ TryGetFunctionPrototype(receiver, scratch1, scratch2, miss_label); |
236 __ mov(eax, Operand(scratch1)); | 236 __ mov(eax, Operand(scratch1)); |
237 __ ret(0); | 237 __ ret(0); |
238 } | 238 } |
239 | 239 |
240 | 240 |
| 241 // Load a fast property out of a holder object (src). In-object properties |
| 242 // are loaded directly otherwise the property is loaded from the properties |
| 243 // fixed array. |
| 244 void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm, |
| 245 Register dst, Register src, |
| 246 JSObject* holder, int index) { |
| 247 // Adjust for the number of properties stored in the holder. |
| 248 index -= holder->map()->inobject_properties(); |
| 249 if (index < 0) { |
| 250 // Get the property straight out of the holder. |
| 251 int offset = holder->map()->instance_size() + (index * kPointerSize); |
| 252 __ mov(dst, FieldOperand(src, offset)); |
| 253 } else { |
| 254 // Calculate the offset into the properties array. |
| 255 int offset = index * kPointerSize + Array::kHeaderSize; |
| 256 __ mov(dst, FieldOperand(src, JSObject::kPropertiesOffset)); |
| 257 __ mov(dst, FieldOperand(dst, offset)); |
| 258 } |
| 259 } |
| 260 |
| 261 |
241 void StubCompiler::GenerateLoadField(MacroAssembler* masm, | 262 void StubCompiler::GenerateLoadField(MacroAssembler* masm, |
242 JSObject* object, | 263 JSObject* object, |
243 JSObject* holder, | 264 JSObject* holder, |
244 Register receiver, | 265 Register receiver, |
245 Register scratch1, | 266 Register scratch1, |
246 Register scratch2, | 267 Register scratch2, |
247 int index, | 268 int index, |
248 Label* miss_label) { | 269 Label* miss_label) { |
249 // Check that the receiver isn't a smi. | 270 // Check that the receiver isn't a smi. |
250 __ test(receiver, Immediate(kSmiTagMask)); | 271 __ test(receiver, Immediate(kSmiTagMask)); |
251 __ j(zero, miss_label, not_taken); | 272 __ j(zero, miss_label, not_taken); |
252 | 273 |
253 // Check that the maps haven't changed. | 274 // Check that the maps haven't changed. |
254 Register reg = | 275 Register reg = |
255 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 276 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
256 | 277 |
257 // Adjust for the number of properties stored in the holder. | 278 // Get the value from the properties. |
258 index -= holder->map()->inobject_properties(); | 279 GenerateFastPropertyLoad(masm, eax, reg, holder, index); |
259 if (index < 0) { | |
260 // Get the property straight out of the holder. | |
261 int offset = holder->map()->instance_size() + (index * kPointerSize); | |
262 __ mov(eax, FieldOperand(reg, offset)); | |
263 } else { | |
264 // Get the properties array of the holder. | |
265 __ mov(scratch1, FieldOperand(reg, JSObject::kPropertiesOffset)); | |
266 // Return the value from the properties array. | |
267 int offset = index * kPointerSize + Array::kHeaderSize; | |
268 __ mov(eax, FieldOperand(scratch1, offset)); | |
269 } | |
270 __ ret(0); | 280 __ ret(0); |
271 } | 281 } |
272 | 282 |
273 | 283 |
274 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, | 284 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, |
275 JSObject* object, | 285 JSObject* object, |
276 JSObject* holder, | 286 JSObject* holder, |
277 Register receiver, | 287 Register receiver, |
278 Register name, | 288 Register name, |
279 Register scratch1, | 289 Register scratch1, |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); | 502 __ mov(edx, Operand(esp, (argc + 1) * kPointerSize)); |
493 | 503 |
494 // Check that the receiver isn't a smi. | 504 // Check that the receiver isn't a smi. |
495 __ test(edx, Immediate(kSmiTagMask)); | 505 __ test(edx, Immediate(kSmiTagMask)); |
496 __ j(zero, &miss, not_taken); | 506 __ j(zero, &miss, not_taken); |
497 | 507 |
498 // Do the right check and compute the holder register. | 508 // Do the right check and compute the holder register. |
499 Register reg = | 509 Register reg = |
500 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | 510 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); |
501 | 511 |
502 // Adjust for the number of properties stored in the holder. | 512 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); |
503 index -= holder->map()->inobject_properties(); | |
504 if (index < 0) { | |
505 // Get the property straight out of the holder. | |
506 int offset = holder->map()->instance_size() + (index * kPointerSize); | |
507 __ mov(edi, FieldOperand(reg, offset)); | |
508 } else { | |
509 // Get the properties array of the holder and get the function from | |
510 // the field. | |
511 int offset = index * kPointerSize + Array::kHeaderSize; | |
512 __ mov(edi, FieldOperand(reg, JSObject::kPropertiesOffset)); | |
513 __ mov(edi, FieldOperand(edi, offset)); | |
514 } | |
515 | 513 |
516 // Check that the function really is a function. | 514 // Check that the function really is a function. |
517 __ test(edi, Immediate(kSmiTagMask)); | 515 __ test(edi, Immediate(kSmiTagMask)); |
518 __ j(zero, &miss, not_taken); | 516 __ j(zero, &miss, not_taken); |
519 __ mov(ebx, FieldOperand(edi, HeapObject::kMapOffset)); // get the map | 517 __ mov(ebx, FieldOperand(edi, HeapObject::kMapOffset)); // get the map |
520 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | 518 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); |
521 __ cmp(ebx, JS_FUNCTION_TYPE); | 519 __ cmp(ebx, JS_FUNCTION_TYPE); |
522 __ j(not_equal, &miss, not_taken); | 520 __ j(not_equal, &miss, not_taken); |
523 | 521 |
524 // Invoke the function. | 522 // Invoke the function. |
(...skipping 721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1246 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 1244 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
1247 | 1245 |
1248 // Return the generated code. | 1246 // Return the generated code. |
1249 return GetCode(CALLBACKS); | 1247 return GetCode(CALLBACKS); |
1250 } | 1248 } |
1251 | 1249 |
1252 | 1250 |
1253 #undef __ | 1251 #undef __ |
1254 | 1252 |
1255 } } // namespace v8::internal | 1253 } } // namespace v8::internal |
OLD | NEW |