| 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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 | 141 |
| 142 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, | 142 void StubCompiler::GenerateLoadArrayLength(MacroAssembler* masm, |
| 143 Register receiver, | 143 Register receiver, |
| 144 Register scratch, | 144 Register scratch, |
| 145 Label* miss_label) { | 145 Label* miss_label) { |
| 146 // Check that the receiver isn't a smi. | 146 // Check that the receiver isn't a smi. |
| 147 __ test(receiver, Immediate(kSmiTagMask)); | 147 __ test(receiver, Immediate(kSmiTagMask)); |
| 148 __ j(zero, miss_label, not_taken); | 148 __ j(zero, miss_label, not_taken); |
| 149 | 149 |
| 150 // Check that the object is a JS array. | 150 // Check that the object is a JS array. |
| 151 __ mov(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 151 __ CmpObjectType(receiver, JS_ARRAY_TYPE, scratch); |
| 152 __ movzx_b(scratch, FieldOperand(scratch, Map::kInstanceTypeOffset)); | |
| 153 __ cmp(scratch, JS_ARRAY_TYPE); | |
| 154 __ j(not_equal, miss_label, not_taken); | 152 __ j(not_equal, miss_label, not_taken); |
| 155 | 153 |
| 156 // Load length directly from the JS array. | 154 // Load length directly from the JS array. |
| 157 __ mov(eax, FieldOperand(receiver, JSArray::kLengthOffset)); | 155 __ mov(eax, FieldOperand(receiver, JSArray::kLengthOffset)); |
| 158 __ ret(0); | 156 __ ret(0); |
| 159 } | 157 } |
| 160 | 158 |
| 161 | 159 |
| 162 // Generate code to check if an object is a string. If the object is | 160 // Generate code to check if an object is a string. If the object is |
| 163 // a string, the map's instance type is left in the scratch register. | 161 // a string, the map's instance type is left in the scratch register. |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 485 |
| 488 // Do the right check and compute the holder register. | 486 // Do the right check and compute the holder register. |
| 489 Register reg = | 487 Register reg = |
| 490 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); | 488 __ CheckMaps(JSObject::cast(object), edx, holder, ebx, ecx, &miss); |
| 491 | 489 |
| 492 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); | 490 GenerateFastPropertyLoad(masm(), edi, reg, holder, index); |
| 493 | 491 |
| 494 // Check that the function really is a function. | 492 // Check that the function really is a function. |
| 495 __ test(edi, Immediate(kSmiTagMask)); | 493 __ test(edi, Immediate(kSmiTagMask)); |
| 496 __ j(zero, &miss, not_taken); | 494 __ j(zero, &miss, not_taken); |
| 497 __ mov(ebx, FieldOperand(edi, HeapObject::kMapOffset)); // get the map | 495 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); |
| 498 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 499 __ cmp(ebx, JS_FUNCTION_TYPE); | |
| 500 __ j(not_equal, &miss, not_taken); | 496 __ j(not_equal, &miss, not_taken); |
| 501 | 497 |
| 502 // Patch the receiver on the stack with the global proxy if | 498 // Patch the receiver on the stack with the global proxy if |
| 503 // necessary. | 499 // necessary. |
| 504 if (object->IsGlobalObject()) { | 500 if (object->IsGlobalObject()) { |
| 505 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); | 501 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
| 506 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); | 502 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
| 507 } | 503 } |
| 508 | 504 |
| 509 // Invoke the function. | 505 // Invoke the function. |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 566 ecx); | 562 ecx); |
| 567 __ CheckMaps(JSObject::cast(object->GetPrototype()), | 563 __ CheckMaps(JSObject::cast(object->GetPrototype()), |
| 568 ecx, holder, ebx, edx, &miss); | 564 ecx, holder, ebx, edx, &miss); |
| 569 break; | 565 break; |
| 570 | 566 |
| 571 case NUMBER_CHECK: { | 567 case NUMBER_CHECK: { |
| 572 Label fast; | 568 Label fast; |
| 573 // Check that the object is a smi or a heap number. | 569 // Check that the object is a smi or a heap number. |
| 574 __ test(edx, Immediate(kSmiTagMask)); | 570 __ test(edx, Immediate(kSmiTagMask)); |
| 575 __ j(zero, &fast, taken); | 571 __ j(zero, &fast, taken); |
| 576 __ mov(ecx, FieldOperand(edx, HeapObject::kMapOffset)); | 572 __ CmpObjectType(edx, HEAP_NUMBER_TYPE, ecx); |
| 577 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | |
| 578 __ cmp(ecx, HEAP_NUMBER_TYPE); | |
| 579 __ j(not_equal, &miss, not_taken); | 573 __ j(not_equal, &miss, not_taken); |
| 580 __ bind(&fast); | 574 __ bind(&fast); |
| 581 // Check that the maps starting from the prototype haven't changed. | 575 // Check that the maps starting from the prototype haven't changed. |
| 582 GenerateLoadGlobalFunctionPrototype(masm(), | 576 GenerateLoadGlobalFunctionPrototype(masm(), |
| 583 Context::NUMBER_FUNCTION_INDEX, | 577 Context::NUMBER_FUNCTION_INDEX, |
| 584 ecx); | 578 ecx); |
| 585 __ CheckMaps(JSObject::cast(object->GetPrototype()), | 579 __ CheckMaps(JSObject::cast(object->GetPrototype()), |
| 586 ecx, holder, ebx, edx, &miss); | 580 ecx, holder, ebx, edx, &miss); |
| 587 break; | 581 break; |
| 588 } | 582 } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 // Move result to edi and restore receiver. | 678 // Move result to edi and restore receiver. |
| 685 __ mov(edi, eax); | 679 __ mov(edi, eax); |
| 686 __ mov(edx, Operand(ebp, (argc + 2) * kPointerSize)); // receiver | 680 __ mov(edx, Operand(ebp, (argc + 2) * kPointerSize)); // receiver |
| 687 | 681 |
| 688 // Exit frame. | 682 // Exit frame. |
| 689 __ LeaveInternalFrame(); | 683 __ LeaveInternalFrame(); |
| 690 | 684 |
| 691 // Check that the function really is a function. | 685 // Check that the function really is a function. |
| 692 __ test(edi, Immediate(kSmiTagMask)); | 686 __ test(edi, Immediate(kSmiTagMask)); |
| 693 __ j(zero, &miss, not_taken); | 687 __ j(zero, &miss, not_taken); |
| 694 __ mov(ebx, FieldOperand(edi, HeapObject::kMapOffset)); | 688 __ CmpObjectType(edi, JS_FUNCTION_TYPE, ebx); |
| 695 __ movzx_b(ebx, FieldOperand(ebx, Map::kInstanceTypeOffset)); | |
| 696 __ cmp(ebx, JS_FUNCTION_TYPE); | |
| 697 __ j(not_equal, &miss, not_taken); | 689 __ j(not_equal, &miss, not_taken); |
| 698 | 690 |
| 699 // Patch the receiver on the stack with the global proxy if | 691 // Patch the receiver on the stack with the global proxy if |
| 700 // necessary. | 692 // necessary. |
| 701 if (object->IsGlobalObject()) { | 693 if (object->IsGlobalObject()) { |
| 702 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); | 694 __ mov(edx, FieldOperand(edx, GlobalObject::kGlobalReceiverOffset)); |
| 703 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); | 695 __ mov(Operand(esp, (argc + 1) * kPointerSize), edx); |
| 704 } | 696 } |
| 705 | 697 |
| 706 // Invoke the function. | 698 // Invoke the function. |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1178 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); | 1170 GenerateLoadMiss(masm(), Code::KEYED_LOAD_IC); |
| 1179 | 1171 |
| 1180 // Return the generated code. | 1172 // Return the generated code. |
| 1181 return GetCode(CALLBACKS, name); | 1173 return GetCode(CALLBACKS, name); |
| 1182 } | 1174 } |
| 1183 | 1175 |
| 1184 | 1176 |
| 1185 #undef __ | 1177 #undef __ |
| 1186 | 1178 |
| 1187 } } // namespace v8::internal | 1179 } } // namespace v8::internal |
| OLD | NEW |