| 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 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 int index, | 247 int index, |
| 248 Label* miss_label) { | 248 Label* miss_label) { |
| 249 // Check that the receiver isn't a smi. | 249 // Check that the receiver isn't a smi. |
| 250 __ test(receiver, Immediate(kSmiTagMask)); | 250 __ test(receiver, Immediate(kSmiTagMask)); |
| 251 __ j(zero, miss_label, not_taken); | 251 __ j(zero, miss_label, not_taken); |
| 252 | 252 |
| 253 // Check that the maps haven't changed. | 253 // Check that the maps haven't changed. |
| 254 Register reg = | 254 Register reg = |
| 255 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); | 255 __ CheckMaps(object, receiver, holder, scratch1, scratch2, miss_label); |
| 256 | 256 |
| 257 // Get the properties array of the holder. | 257 // Adjust for the number of properties stored in the holder. |
| 258 __ mov(scratch1, FieldOperand(reg, JSObject::kPropertiesOffset)); | 258 index -= holder->map()->inobject_properties(); |
| 259 | 259 if (index < 0) { |
| 260 // Return the value from the properties array. | 260 // Get the property straight out of the holder. |
| 261 int offset = index * kPointerSize + Array::kHeaderSize; | 261 int offset = holder->map()->instance_size() + (index * kPointerSize); |
| 262 __ mov(eax, FieldOperand(scratch1, offset)); | 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 } |
| 263 __ ret(0); | 270 __ ret(0); |
| 264 } | 271 } |
| 265 | 272 |
| 266 | 273 |
| 267 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, | 274 void StubCompiler::GenerateLoadCallback(MacroAssembler* masm, |
| 268 JSObject* object, | 275 JSObject* object, |
| 269 JSObject* holder, | 276 JSObject* holder, |
| 270 Register receiver, | 277 Register receiver, |
| 271 Register name, | 278 Register name, |
| 272 Register scratch1, | 279 Register scratch1, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 // Perform map transition for the receiver if necessary. | 399 // Perform map transition for the receiver if necessary. |
| 393 if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { | 400 if ((transition != NULL) && (object->map()->unused_property_fields() == 0)) { |
| 394 // The properties must be extended before we can store the value. | 401 // The properties must be extended before we can store the value. |
| 395 // We jump to a runtime call that extends the propeties array. | 402 // We jump to a runtime call that extends the propeties array. |
| 396 __ mov(Operand(ecx), Immediate(Handle<Map>(transition))); | 403 __ mov(Operand(ecx), Immediate(Handle<Map>(transition))); |
| 397 Handle<Code> ic(Builtins::builtin(storage_extend)); | 404 Handle<Code> ic(Builtins::builtin(storage_extend)); |
| 398 __ jmp(ic, RelocInfo::CODE_TARGET); | 405 __ jmp(ic, RelocInfo::CODE_TARGET); |
| 399 return; | 406 return; |
| 400 } | 407 } |
| 401 | 408 |
| 402 // Get the properties array (optimistically). | 409 // Adjust for the number of properties stored in the object. Even in the |
| 403 __ mov(scratch, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); | 410 // face of a transition we can use the old map here because the size of the |
| 411 // object and the number of in-object properties is not going to change. |
| 412 index -= object->map()->inobject_properties(); |
| 413 |
| 414 if (index >= 0) { |
| 415 // Get the properties array (optimistically). |
| 416 __ mov(scratch, FieldOperand(receiver_reg, JSObject::kPropertiesOffset)); |
| 417 } |
| 418 |
| 404 if (transition != NULL) { | 419 if (transition != NULL) { |
| 405 // Update the map of the object; no write barrier updating is | 420 // Update the map of the object; no write barrier updating is |
| 406 // needed because the map is never in new space. | 421 // needed because the map is never in new space. |
| 407 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), | 422 __ mov(FieldOperand(receiver_reg, HeapObject::kMapOffset), |
| 408 Immediate(Handle<Map>(transition))); | 423 Immediate(Handle<Map>(transition))); |
| 409 } | 424 } |
| 410 | 425 |
| 411 // Write to the properties array. | 426 if (index < 0) { |
| 412 int offset = index * kPointerSize + Array::kHeaderSize; | 427 // Set the property straight into the object. |
| 413 __ mov(FieldOperand(scratch, offset), eax); | 428 int offset = object->map()->instance_size() + (index * kPointerSize); |
| 429 __ mov(FieldOperand(receiver_reg, offset), eax); |
| 414 | 430 |
| 415 // Update the write barrier for the array address. | 431 // Update the write barrier for the array address. |
| 416 // Pass the value being stored in the now unused name_reg. | 432 // Pass the value being stored in the now unused name_reg. |
| 417 __ mov(name_reg, Operand(eax)); | 433 __ mov(name_reg, Operand(eax)); |
| 418 __ RecordWrite(scratch, offset, name_reg, receiver_reg); | 434 __ RecordWrite(receiver_reg, offset, name_reg, scratch); |
| 435 } else { |
| 436 // Write to the properties array. |
| 437 int offset = index * kPointerSize + Array::kHeaderSize; |
| 438 __ mov(FieldOperand(scratch, offset), eax); |
| 439 |
| 440 // Update the write barrier for the array address. |
| 441 // Pass the value being stored in the now unused name_reg. |
| 442 __ mov(name_reg, Operand(eax)); |
| 443 __ RecordWrite(scratch, offset, name_reg, receiver_reg); |
| 444 } |
| 419 | 445 |
| 420 // Return the value (register eax). | 446 // Return the value (register eax). |
| 421 __ ret(0); | 447 __ ret(0); |
| 422 } | 448 } |
| 423 | 449 |
| 424 | 450 |
| 425 #undef __ | 451 #undef __ |
| 426 | 452 |
| 427 #define __ masm()-> | 453 #define __ masm()-> |
| 428 | 454 |
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1211 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 1237 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 1212 | 1238 |
| 1213 // Return the generated code. | 1239 // Return the generated code. |
| 1214 return GetCode(CALLBACKS); | 1240 return GetCode(CALLBACKS); |
| 1215 } | 1241 } |
| 1216 | 1242 |
| 1217 | 1243 |
| 1218 #undef __ | 1244 #undef __ |
| 1219 | 1245 |
| 1220 } } // namespace v8::internal | 1246 } } // namespace v8::internal |
| OLD | NEW |