OLD | NEW |
1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 12050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12061 // Check that the left hand is a JS object. | 12061 // Check that the left hand is a JS object. |
12062 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); // eax - object map | 12062 __ mov(eax, FieldOperand(eax, HeapObject::kMapOffset)); // eax - object map |
12063 __ movzx_b(ecx, FieldOperand(eax, Map::kInstanceTypeOffset)); // ecx - type | 12063 __ movzx_b(ecx, FieldOperand(eax, Map::kInstanceTypeOffset)); // ecx - type |
12064 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 12064 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
12065 __ j(less, &slow, not_taken); | 12065 __ j(less, &slow, not_taken); |
12066 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 12066 __ cmp(ecx, LAST_JS_OBJECT_TYPE); |
12067 __ j(greater, &slow, not_taken); | 12067 __ j(greater, &slow, not_taken); |
12068 | 12068 |
12069 // Get the prototype of the function. | 12069 // Get the prototype of the function. |
12070 __ mov(edx, Operand(esp, 1 * kPointerSize)); // 1 ~ return address | 12070 __ mov(edx, Operand(esp, 1 * kPointerSize)); // 1 ~ return address |
| 12071 // edx is function, eax is map. |
| 12072 |
| 12073 // Look up the function and the map in the instanceof cache. |
| 12074 Label miss; |
| 12075 ExternalReference roots_address = ExternalReference::roots_address(); |
| 12076 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); |
| 12077 __ cmp(edx, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12078 __ j(not_equal, &miss); |
| 12079 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); |
| 12080 __ cmp(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12081 __ j(not_equal, &miss); |
| 12082 __ mov(ecx, Immediate(Heap::kInstanceofCacheAnswerRootIndex)); |
| 12083 __ mov(eax, Operand::StaticArray(ecx, times_pointer_size, roots_address)); |
| 12084 __ ret(2 * kPointerSize); |
| 12085 |
| 12086 __ bind(&miss); |
12071 __ TryGetFunctionPrototype(edx, ebx, ecx, &slow); | 12087 __ TryGetFunctionPrototype(edx, ebx, ecx, &slow); |
12072 | 12088 |
12073 // Check that the function prototype is a JS object. | 12089 // Check that the function prototype is a JS object. |
12074 __ test(ebx, Immediate(kSmiTagMask)); | 12090 __ test(ebx, Immediate(kSmiTagMask)); |
12075 __ j(zero, &slow, not_taken); | 12091 __ j(zero, &slow, not_taken); |
12076 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); | 12092 __ mov(ecx, FieldOperand(ebx, HeapObject::kMapOffset)); |
12077 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); | 12093 __ movzx_b(ecx, FieldOperand(ecx, Map::kInstanceTypeOffset)); |
12078 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); | 12094 __ cmp(ecx, FIRST_JS_OBJECT_TYPE); |
12079 __ j(less, &slow, not_taken); | 12095 __ j(less, &slow, not_taken); |
12080 __ cmp(ecx, LAST_JS_OBJECT_TYPE); | 12096 __ cmp(ecx, LAST_JS_OBJECT_TYPE); |
12081 __ j(greater, &slow, not_taken); | 12097 __ j(greater, &slow, not_taken); |
12082 | 12098 |
12083 // Register mapping: eax is object map and ebx is function prototype. | 12099 // Register mapping: |
| 12100 // eax is object map. |
| 12101 // edx is function. |
| 12102 // ebx is function prototype. |
| 12103 __ mov(ecx, Immediate(Heap::kInstanceofCacheMapRootIndex)); |
| 12104 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), eax); |
| 12105 __ mov(ecx, Immediate(Heap::kInstanceofCacheFunctionRootIndex)); |
| 12106 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), edx); |
| 12107 |
12084 __ mov(ecx, FieldOperand(eax, Map::kPrototypeOffset)); | 12108 __ mov(ecx, FieldOperand(eax, Map::kPrototypeOffset)); |
12085 | 12109 |
12086 // Loop through the prototype chain looking for the function prototype. | 12110 // Loop through the prototype chain looking for the function prototype. |
12087 Label loop, is_instance, is_not_instance; | 12111 Label loop, is_instance, is_not_instance; |
12088 __ bind(&loop); | 12112 __ bind(&loop); |
12089 __ cmp(ecx, Operand(ebx)); | 12113 __ cmp(ecx, Operand(ebx)); |
12090 __ j(equal, &is_instance); | 12114 __ j(equal, &is_instance); |
12091 __ cmp(Operand(ecx), Immediate(Factory::null_value())); | 12115 __ cmp(Operand(ecx), Immediate(Factory::null_value())); |
12092 __ j(equal, &is_not_instance); | 12116 __ j(equal, &is_not_instance); |
12093 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); | 12117 __ mov(ecx, FieldOperand(ecx, HeapObject::kMapOffset)); |
12094 __ mov(ecx, FieldOperand(ecx, Map::kPrototypeOffset)); | 12118 __ mov(ecx, FieldOperand(ecx, Map::kPrototypeOffset)); |
12095 __ jmp(&loop); | 12119 __ jmp(&loop); |
12096 | 12120 |
12097 __ bind(&is_instance); | 12121 __ bind(&is_instance); |
12098 __ Set(eax, Immediate(0)); | 12122 __ Set(eax, Immediate(0)); |
| 12123 __ mov(ecx, Immediate(Heap::kInstanceofCacheAnswerRootIndex)); |
| 12124 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), eax); |
12099 __ ret(2 * kPointerSize); | 12125 __ ret(2 * kPointerSize); |
12100 | 12126 |
12101 __ bind(&is_not_instance); | 12127 __ bind(&is_not_instance); |
12102 __ Set(eax, Immediate(Smi::FromInt(1))); | 12128 __ Set(eax, Immediate(Smi::FromInt(1))); |
| 12129 __ mov(ecx, Immediate(Heap::kInstanceofCacheAnswerRootIndex)); |
| 12130 __ mov(Operand::StaticArray(ecx, times_pointer_size, roots_address), eax); |
12103 __ ret(2 * kPointerSize); | 12131 __ ret(2 * kPointerSize); |
12104 | 12132 |
12105 // Slow-case: Go through the JavaScript implementation. | 12133 // Slow-case: Go through the JavaScript implementation. |
12106 __ bind(&slow); | 12134 __ bind(&slow); |
12107 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); | 12135 __ InvokeBuiltin(Builtins::INSTANCE_OF, JUMP_FUNCTION); |
12108 } | 12136 } |
12109 | 12137 |
12110 | 12138 |
12111 int CompareStub::MinorKey() { | 12139 int CompareStub::MinorKey() { |
12112 // Encode the three parameters in a unique 16 bit value. To avoid duplicate | 12140 // Encode the three parameters in a unique 16 bit value. To avoid duplicate |
(...skipping 933 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
13046 | 13074 |
13047 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) | 13075 // Call the runtime; it returns -1 (less), 0 (equal), or 1 (greater) |
13048 // tagged as a small integer. | 13076 // tagged as a small integer. |
13049 __ bind(&runtime); | 13077 __ bind(&runtime); |
13050 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); | 13078 __ TailCallRuntime(Runtime::kStringCompare, 2, 1); |
13051 } | 13079 } |
13052 | 13080 |
13053 #undef __ | 13081 #undef __ |
13054 | 13082 |
13055 } } // namespace v8::internal | 13083 } } // namespace v8::internal |
OLD | NEW |