| 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 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 namespace v8 { | 38 namespace v8 { |
| 39 namespace internal { | 39 namespace internal { |
| 40 | 40 |
| 41 //----------------------------------------------------------------------------- | 41 //----------------------------------------------------------------------------- |
| 42 // StubCompiler static helper functions | 42 // StubCompiler static helper functions |
| 43 | 43 |
| 44 #define __ ACCESS_MASM(masm) | 44 #define __ ACCESS_MASM(masm) |
| 45 | 45 |
| 46 | 46 |
| 47 static void ProbeTable(MacroAssembler* masm, | 47 static void ProbeTable(Isolate* isolate, |
| 48 MacroAssembler* masm, |
| 48 Code::Flags flags, | 49 Code::Flags flags, |
| 49 StubCache::Table table, | 50 StubCache::Table table, |
| 50 Register name, | 51 Register name, |
| 51 Register offset) { | 52 Register offset) { |
| 52 ASSERT_EQ(8, kPointerSize); | 53 ASSERT_EQ(8, kPointerSize); |
| 53 ASSERT_EQ(16, sizeof(StubCache::Entry)); | 54 ASSERT_EQ(16, sizeof(StubCache::Entry)); |
| 54 // The offset register holds the entry offset times four (due to masking | 55 // The offset register holds the entry offset times four (due to masking |
| 55 // and shifting optimizations). | 56 // and shifting optimizations). |
| 56 ExternalReference key_offset(SCTableReference::keyReference(table)); | 57 ExternalReference key_offset(isolate->stub_cache()->key_reference(table)); |
| 57 Label miss; | 58 Label miss; |
| 58 | 59 |
| 59 __ movq(kScratchRegister, key_offset); | 60 __ movq(kScratchRegister, key_offset); |
| 60 // Check that the key in the entry matches the name. | 61 // Check that the key in the entry matches the name. |
| 61 // Multiply entry offset by 16 to get the entry address. Since the | 62 // Multiply entry offset by 16 to get the entry address. Since the |
| 62 // offset register already holds the entry offset times four, multiply | 63 // offset register already holds the entry offset times four, multiply |
| 63 // by a further four. | 64 // by a further four. |
| 64 __ cmpl(name, Operand(kScratchRegister, offset, times_4, 0)); | 65 __ cmpl(name, Operand(kScratchRegister, offset, times_4, 0)); |
| 65 __ j(not_equal, &miss); | 66 __ j(not_equal, &miss); |
| 66 // Get the code entry from the cache. | 67 // Get the code entry from the cache. |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); | 163 __ push(FieldOperand(kScratchRegister, InterceptorInfo::kDataOffset)); |
| 163 } | 164 } |
| 164 | 165 |
| 165 | 166 |
| 166 void StubCache::GenerateProbe(MacroAssembler* masm, | 167 void StubCache::GenerateProbe(MacroAssembler* masm, |
| 167 Code::Flags flags, | 168 Code::Flags flags, |
| 168 Register receiver, | 169 Register receiver, |
| 169 Register name, | 170 Register name, |
| 170 Register scratch, | 171 Register scratch, |
| 171 Register extra) { | 172 Register extra) { |
| 173 Isolate* isolate = Isolate::Current(); |
| 174 |
| 172 Label miss; | 175 Label miss; |
| 173 USE(extra); // The register extra is not used on the X64 platform. | 176 USE(extra); // The register extra is not used on the X64 platform. |
| 174 // Make sure that code is valid. The shifting code relies on the | 177 // Make sure that code is valid. The shifting code relies on the |
| 175 // entry size being 16. | 178 // entry size being 16. |
| 176 ASSERT(sizeof(Entry) == 16); | 179 ASSERT(sizeof(Entry) == 16); |
| 177 | 180 |
| 178 // Make sure the flags do not name a specific type. | 181 // Make sure the flags do not name a specific type. |
| 179 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); | 182 ASSERT(Code::ExtractTypeFromFlags(flags) == 0); |
| 180 | 183 |
| 181 // Make sure that there are no register conflicts. | 184 // Make sure that there are no register conflicts. |
| 182 ASSERT(!scratch.is(receiver)); | 185 ASSERT(!scratch.is(receiver)); |
| 183 ASSERT(!scratch.is(name)); | 186 ASSERT(!scratch.is(name)); |
| 184 | 187 |
| 185 // Check that the receiver isn't a smi. | 188 // Check that the receiver isn't a smi. |
| 186 __ JumpIfSmi(receiver, &miss); | 189 __ JumpIfSmi(receiver, &miss); |
| 187 | 190 |
| 188 // Get the map of the receiver and compute the hash. | 191 // Get the map of the receiver and compute the hash. |
| 189 __ movl(scratch, FieldOperand(name, String::kHashFieldOffset)); | 192 __ movl(scratch, FieldOperand(name, String::kHashFieldOffset)); |
| 190 // Use only the low 32 bits of the map pointer. | 193 // Use only the low 32 bits of the map pointer. |
| 191 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 194 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 192 __ xor_(scratch, Immediate(flags)); | 195 __ xor_(scratch, Immediate(flags)); |
| 193 __ and_(scratch, Immediate((kPrimaryTableSize - 1) << kHeapObjectTagSize)); | 196 __ and_(scratch, Immediate((kPrimaryTableSize - 1) << kHeapObjectTagSize)); |
| 194 | 197 |
| 195 // Probe the primary table. | 198 // Probe the primary table. |
| 196 ProbeTable(masm, flags, kPrimary, name, scratch); | 199 ProbeTable(isolate, masm, flags, kPrimary, name, scratch); |
| 197 | 200 |
| 198 // Primary miss: Compute hash for secondary probe. | 201 // Primary miss: Compute hash for secondary probe. |
| 199 __ movl(scratch, FieldOperand(name, String::kHashFieldOffset)); | 202 __ movl(scratch, FieldOperand(name, String::kHashFieldOffset)); |
| 200 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); | 203 __ addl(scratch, FieldOperand(receiver, HeapObject::kMapOffset)); |
| 201 __ xor_(scratch, Immediate(flags)); | 204 __ xor_(scratch, Immediate(flags)); |
| 202 __ and_(scratch, Immediate((kPrimaryTableSize - 1) << kHeapObjectTagSize)); | 205 __ and_(scratch, Immediate((kPrimaryTableSize - 1) << kHeapObjectTagSize)); |
| 203 __ subl(scratch, name); | 206 __ subl(scratch, name); |
| 204 __ addl(scratch, Immediate(flags)); | 207 __ addl(scratch, Immediate(flags)); |
| 205 __ and_(scratch, Immediate((kSecondaryTableSize - 1) << kHeapObjectTagSize)); | 208 __ and_(scratch, Immediate((kSecondaryTableSize - 1) << kHeapObjectTagSize)); |
| 206 | 209 |
| 207 // Probe the secondary table. | 210 // Probe the secondary table. |
| 208 ProbeTable(masm, flags, kSecondary, name, scratch); | 211 ProbeTable(isolate, masm, flags, kSecondary, name, scratch); |
| 209 | 212 |
| 210 // Cache miss: Fall-through and let caller handle the miss by | 213 // Cache miss: Fall-through and let caller handle the miss by |
| 211 // entering the runtime system. | 214 // entering the runtime system. |
| 212 __ bind(&miss); | 215 __ bind(&miss); |
| 213 } | 216 } |
| 214 | 217 |
| 215 | 218 |
| 216 // Both name_reg and receiver_reg are preserved on jumps to miss_label, | 219 // Both name_reg and receiver_reg are preserved on jumps to miss_label, |
| 217 // but may be destroyed if store is successful. | 220 // but may be destroyed if store is successful. |
| 218 void StubCompiler::GenerateStoreField(MacroAssembler* masm, | 221 void StubCompiler::GenerateStoreField(MacroAssembler* masm, |
| (...skipping 2119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2338 // Return the generated code. | 2341 // Return the generated code. |
| 2339 return GetCode(); | 2342 return GetCode(); |
| 2340 } | 2343 } |
| 2341 | 2344 |
| 2342 | 2345 |
| 2343 #undef __ | 2346 #undef __ |
| 2344 | 2347 |
| 2345 } } // namespace v8::internal | 2348 } } // namespace v8::internal |
| 2346 | 2349 |
| 2347 #endif // V8_TARGET_ARCH_X64 | 2350 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |