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 // Load the function from the global context. | 141 // Load the function from the global context. |
142 __ ldr(prototype, MemOperand(prototype, Context::SlotOffset(index))); | 142 __ ldr(prototype, MemOperand(prototype, Context::SlotOffset(index))); |
143 // Load the initial map. The global functions all have initial maps. | 143 // Load the initial map. The global functions all have initial maps. |
144 __ ldr(prototype, | 144 __ ldr(prototype, |
145 FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 145 FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
146 // Load the prototype from the initial map. | 146 // Load the prototype from the initial map. |
147 __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); | 147 __ ldr(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
148 } | 148 } |
149 | 149 |
150 | 150 |
| 151 // Load a fast property out of a holder object (src). In-object properties |
| 152 // are loaded directly otherwise the property is loaded from the properties |
| 153 // fixed array. |
| 154 void StubCompiler::GenerateFastPropertyLoad(MacroAssembler* masm, |
| 155 Register dst, Register src, |
| 156 JSObject* holder, int index) { |
| 157 // Adjust for the number of properties stored in the holder. |
| 158 index -= holder->map()->inobject_properties(); |
| 159 if (index < 0) { |
| 160 // Get the property straight out of the holder. |
| 161 int offset = holder->map()->instance_size() + (index * kPointerSize); |
| 162 __ ldr(dst, FieldMemOperand(src, offset)); |
| 163 } else { |
| 164 // Calculate the offset into the properties array. |
| 165 int offset = index * kPointerSize + Array::kHeaderSize; |
| 166 __ ldr(dst, FieldMemOperand(src, JSObject::kPropertiesOffset)); |
| 167 __ ldr(dst, FieldMemOperand(dst, offset)); |
| 168 } |
| 169 } |
| 170 |
| 171 |
151 #undef __ | 172 #undef __ |
152 | 173 |
153 #define __ masm()-> | 174 #define __ masm()-> |
154 | 175 |
155 | 176 |
156 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { | 177 Object* StubCompiler::CompileLazyCompile(Code::Flags flags) { |
157 // ----------- S t a t e ------------- | 178 // ----------- S t a t e ------------- |
158 // -- r1: function | 179 // -- r1: function |
159 // -- lr: return address | 180 // -- lr: return address |
160 // ----------------------------------- | 181 // ----------------------------------- |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 | 222 |
202 // Get the receiver of the function from the stack into r1. | 223 // Get the receiver of the function from the stack into r1. |
203 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); | 224 __ ldr(r1, MemOperand(sp, argc * kPointerSize)); |
204 // Check that the receiver isn't a smi. | 225 // Check that the receiver isn't a smi. |
205 __ tst(r1, Operand(kSmiTagMask)); | 226 __ tst(r1, Operand(kSmiTagMask)); |
206 __ b(eq, &miss); | 227 __ b(eq, &miss); |
207 | 228 |
208 // Do the right check and compute the holder register. | 229 // Do the right check and compute the holder register. |
209 Register reg = | 230 Register reg = |
210 __ CheckMaps(JSObject::cast(object), r1, holder, r3, r2, &miss); | 231 __ CheckMaps(JSObject::cast(object), r1, holder, r3, r2, &miss); |
211 | 232 GenerateFastPropertyLoad(masm(), r1, reg, holder, index); |
212 // Adjust for the number of properties stored in the holder. | |
213 index -= holder->map()->inobject_properties(); | |
214 if (index < 0) { | |
215 // Get the property straight out of the holder. | |
216 int offset = holder->map()->instance_size() + (index * kPointerSize); | |
217 __ ldr(r1, FieldMemOperand(reg, offset)); | |
218 } else { | |
219 // Get the properties array of the holder and get the function from | |
220 // the field. | |
221 int offset = index * kPointerSize + Array::kHeaderSize; | |
222 __ ldr(r1, FieldMemOperand(reg, JSObject::kPropertiesOffset)); | |
223 __ ldr(r1, FieldMemOperand(r1, offset)); | |
224 } | |
225 | 233 |
226 // Check that the function really is a function. | 234 // Check that the function really is a function. |
227 __ tst(r1, Operand(kSmiTagMask)); | 235 __ tst(r1, Operand(kSmiTagMask)); |
228 __ b(eq, &miss); | 236 __ b(eq, &miss); |
229 // Get the map. | 237 // Get the map. |
230 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); | 238 __ ldr(r2, FieldMemOperand(r1, HeapObject::kMapOffset)); |
231 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); | 239 __ ldrb(r2, FieldMemOperand(r2, Map::kInstanceTypeOffset)); |
232 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); | 240 __ cmp(r2, Operand(JS_FUNCTION_TYPE)); |
233 __ b(ne, &miss); | 241 __ b(ne, &miss); |
234 | 242 |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
612 Label miss; | 620 Label miss; |
613 | 621 |
614 __ ldr(r0, MemOperand(sp, 0)); | 622 __ ldr(r0, MemOperand(sp, 0)); |
615 | 623 |
616 // Check that the receiver isn't a smi. | 624 // Check that the receiver isn't a smi. |
617 __ tst(r0, Operand(kSmiTagMask)); | 625 __ tst(r0, Operand(kSmiTagMask)); |
618 __ b(eq, &miss); | 626 __ b(eq, &miss); |
619 | 627 |
620 // Check that the maps haven't changed. | 628 // Check that the maps haven't changed. |
621 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss); | 629 Register reg = __ CheckMaps(object, r0, holder, r3, r1, &miss); |
622 | 630 GenerateFastPropertyLoad(masm(), r0, reg, holder, index); |
623 // Adjust for the number of properties stored in the holder. | |
624 index -= holder->map()->inobject_properties(); | |
625 if (index < 0) { | |
626 // Get the property straight out of the holder. | |
627 int offset = holder->map()->instance_size() + (index * kPointerSize); | |
628 __ ldr(r0, FieldMemOperand(reg, offset)); | |
629 } else { | |
630 // Get the properties array of the holder. | |
631 __ ldr(r3, FieldMemOperand(reg, JSObject::kPropertiesOffset)); | |
632 // Return the value from the properties array. | |
633 int offset = index * kPointerSize + Array::kHeaderSize; | |
634 __ ldr(r0, FieldMemOperand(r3, offset)); | |
635 } | |
636 __ Ret(); | 631 __ Ret(); |
637 | 632 |
638 // Handle load cache miss. | 633 // Handle load cache miss. |
639 __ bind(&miss); | 634 __ bind(&miss); |
640 __ ldr(r0, MemOperand(sp)); // restore receiver | 635 __ ldr(r0, MemOperand(sp)); // restore receiver |
641 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); | 636 Handle<Code> ic(Builtins::builtin(Builtins::LoadIC_Miss)); |
642 __ Jump(ic, RelocInfo::CODE_TARGET); | 637 __ Jump(ic, RelocInfo::CODE_TARGET); |
643 | 638 |
644 // Return the generated code. | 639 // Return the generated code. |
645 return GetCode(FIELD); | 640 return GetCode(FIELD); |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
835 String* name) { | 830 String* name) { |
836 UNIMPLEMENTED(); | 831 UNIMPLEMENTED(); |
837 return Heap::undefined_value(); | 832 return Heap::undefined_value(); |
838 } | 833 } |
839 | 834 |
840 | 835 |
841 | 836 |
842 #undef __ | 837 #undef __ |
843 | 838 |
844 } } // namespace v8::internal | 839 } } // namespace v8::internal |
OLD | NEW |