| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 __ bind(&miss); | 263 __ bind(&miss); |
| 264 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, | 264 __ IncrementCounter(counters->megamorphic_stub_cache_misses(), 1, |
| 265 extra2, extra3); | 265 extra2, extra3); |
| 266 } | 266 } |
| 267 | 267 |
| 268 | 268 |
| 269 void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, | 269 void StubCompiler::GenerateLoadGlobalFunctionPrototype(MacroAssembler* masm, |
| 270 int index, | 270 int index, |
| 271 Register prototype) { | 271 Register prototype) { |
| 272 // Load the global or builtins object from the current context. | 272 // Load the global or builtins object from the current context. |
| 273 __ lw(prototype, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 274 // Load the global context from the global or builtins object. |
| 273 __ lw(prototype, | 275 __ lw(prototype, |
| 274 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | 276 FieldMemOperand(prototype, GlobalObject::kGlobalContextOffset)); |
| 275 // Load the native context from the global or builtins object. | 277 // Load the function from the global context. |
| 276 __ lw(prototype, | |
| 277 FieldMemOperand(prototype, GlobalObject::kNativeContextOffset)); | |
| 278 // Load the function from the native context. | |
| 279 __ lw(prototype, MemOperand(prototype, Context::SlotOffset(index))); | 278 __ lw(prototype, MemOperand(prototype, Context::SlotOffset(index))); |
| 280 // Load the initial map. The global functions all have initial maps. | 279 // Load the initial map. The global functions all have initial maps. |
| 281 __ lw(prototype, | 280 __ lw(prototype, |
| 282 FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); | 281 FieldMemOperand(prototype, JSFunction::kPrototypeOrInitialMapOffset)); |
| 283 // Load the prototype from the initial map. | 282 // Load the prototype from the initial map. |
| 284 __ lw(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); | 283 __ lw(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
| 285 } | 284 } |
| 286 | 285 |
| 287 | 286 |
| 288 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( | 287 void StubCompiler::GenerateDirectLoadGlobalFunctionPrototype( |
| 289 MacroAssembler* masm, | 288 MacroAssembler* masm, |
| 290 int index, | 289 int index, |
| 291 Register prototype, | 290 Register prototype, |
| 292 Label* miss) { | 291 Label* miss) { |
| 293 Isolate* isolate = masm->isolate(); | 292 Isolate* isolate = masm->isolate(); |
| 294 // Check we're still in the same context. | 293 // Check we're still in the same context. |
| 295 __ lw(prototype, | 294 __ lw(prototype, MemOperand(cp, Context::SlotOffset(Context::GLOBAL_INDEX))); |
| 296 MemOperand(cp, Context::SlotOffset(Context::GLOBAL_OBJECT_INDEX))); | |
| 297 ASSERT(!prototype.is(at)); | 295 ASSERT(!prototype.is(at)); |
| 298 __ li(at, isolate->global_object()); | 296 __ li(at, isolate->global()); |
| 299 __ Branch(miss, ne, prototype, Operand(at)); | 297 __ Branch(miss, ne, prototype, Operand(at)); |
| 300 // Get the global function with the given index. | 298 // Get the global function with the given index. |
| 301 Handle<JSFunction> function( | 299 Handle<JSFunction> function( |
| 302 JSFunction::cast(isolate->native_context()->get(index))); | 300 JSFunction::cast(isolate->global_context()->get(index))); |
| 303 // Load its initial map. The global functions all have initial maps. | 301 // Load its initial map. The global functions all have initial maps. |
| 304 __ li(prototype, Handle<Map>(function->initial_map())); | 302 __ li(prototype, Handle<Map>(function->initial_map())); |
| 305 // Load the prototype from the initial map. | 303 // Load the prototype from the initial map. |
| 306 __ lw(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); | 304 __ lw(prototype, FieldMemOperand(prototype, Map::kPrototypeOffset)); |
| 307 } | 305 } |
| 308 | 306 |
| 309 | 307 |
| 310 // Load a fast property out of a holder object (src). In-object properties | 308 // Load a fast property out of a holder object (src). In-object properties |
| 311 // are loaded directly otherwise the property is loaded from the properties | 309 // are loaded directly otherwise the property is loaded from the properties |
| 312 // fixed array. | 310 // fixed array. |
| (...skipping 2400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2713 // Handle store cache miss. | 2711 // Handle store cache miss. |
| 2714 __ bind(&miss); | 2712 __ bind(&miss); |
| 2715 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); | 2713 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
| 2716 __ Jump(ic, RelocInfo::CODE_TARGET); | 2714 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 2717 | 2715 |
| 2718 // Return the generated code. | 2716 // Return the generated code. |
| 2719 return GetCode(Code::CALLBACKS, name); | 2717 return GetCode(Code::CALLBACKS, name); |
| 2720 } | 2718 } |
| 2721 | 2719 |
| 2722 | 2720 |
| 2723 #undef __ | 2721 Handle<Code> StoreStubCompiler::CompileStoreViaSetter( |
| 2724 #define __ ACCESS_MASM(masm) | 2722 Handle<String> name, |
| 2725 | 2723 Handle<JSObject> receiver, |
| 2726 | 2724 Handle<JSObject> holder, |
| 2727 void StoreStubCompiler::GenerateStoreViaSetter( | |
| 2728 MacroAssembler* masm, | |
| 2729 Handle<JSFunction> setter) { | 2725 Handle<JSFunction> setter) { |
| 2730 // ----------- S t a t e ------------- | 2726 // ----------- S t a t e ------------- |
| 2731 // -- a0 : value | 2727 // -- a0 : value |
| 2732 // -- a1 : receiver | 2728 // -- a1 : receiver |
| 2733 // -- a2 : name | 2729 // -- a2 : name |
| 2734 // -- ra : return address | 2730 // -- ra : return address |
| 2735 // ----------------------------------- | 2731 // ----------------------------------- |
| 2732 Label miss; |
| 2733 |
| 2734 // Check that the maps haven't changed. |
| 2735 __ JumpIfSmi(a1, &miss); |
| 2736 CheckPrototypes(receiver, a1, holder, a3, t0, t1, name, &miss); |
| 2737 |
| 2736 { | 2738 { |
| 2737 FrameScope scope(masm, StackFrame::INTERNAL); | 2739 FrameScope scope(masm(), StackFrame::INTERNAL); |
| 2738 | 2740 |
| 2739 // Save value register, so we can restore it later. | 2741 // Save value register, so we can restore it later. |
| 2740 __ push(a0); | 2742 __ push(a0); |
| 2741 | 2743 |
| 2742 if (!setter.is_null()) { | 2744 // Call the JavaScript setter with the receiver and the value on the stack. |
| 2743 // Call the JavaScript setter with receiver and value on the stack. | 2745 __ push(a1); |
| 2744 __ push(a1); | 2746 __ push(a0); |
| 2745 __ push(a0); | 2747 ParameterCount actual(1); |
| 2746 ParameterCount actual(1); | 2748 __ InvokeFunction(setter, actual, CALL_FUNCTION, NullCallWrapper(), |
| 2747 __ InvokeFunction(setter, actual, CALL_FUNCTION, NullCallWrapper(), | 2749 CALL_AS_METHOD); |
| 2748 CALL_AS_METHOD); | |
| 2749 } else { | |
| 2750 // If we generate a global code snippet for deoptimization only, remember | |
| 2751 // the place to continue after deoptimization. | |
| 2752 masm->isolate()->heap()->SetSetterStubDeoptPCOffset(masm->pc_offset()); | |
| 2753 } | |
| 2754 | 2750 |
| 2755 // We have to return the passed value, not the return value of the setter. | 2751 // We have to return the passed value, not the return value of the setter. |
| 2756 __ pop(v0); | 2752 __ pop(v0); |
| 2757 | 2753 |
| 2758 // Restore context register. | 2754 // Restore context register. |
| 2759 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); | 2755 __ lw(cp, MemOperand(fp, StandardFrameConstants::kContextOffset)); |
| 2760 } | 2756 } |
| 2761 __ Ret(); | 2757 __ Ret(); |
| 2762 } | |
| 2763 | |
| 2764 | |
| 2765 #undef __ | |
| 2766 #define __ ACCESS_MASM(masm()) | |
| 2767 | |
| 2768 | |
| 2769 Handle<Code> StoreStubCompiler::CompileStoreViaSetter( | |
| 2770 Handle<String> name, | |
| 2771 Handle<JSObject> receiver, | |
| 2772 Handle<JSObject> holder, | |
| 2773 Handle<JSFunction> setter) { | |
| 2774 // ----------- S t a t e ------------- | |
| 2775 // -- a0 : value | |
| 2776 // -- a1 : receiver | |
| 2777 // -- a2 : name | |
| 2778 // -- ra : return address | |
| 2779 // ----------------------------------- | |
| 2780 Label miss; | |
| 2781 | |
| 2782 // Check that the maps haven't changed. | |
| 2783 __ JumpIfSmi(a1, &miss); | |
| 2784 CheckPrototypes(receiver, a1, holder, a3, t0, t1, name, &miss); | |
| 2785 | |
| 2786 GenerateStoreViaSetter(masm(), setter); | |
| 2787 | 2758 |
| 2788 __ bind(&miss); | 2759 __ bind(&miss); |
| 2789 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); | 2760 Handle<Code> ic = masm()->isolate()->builtins()->StoreIC_Miss(); |
| 2790 __ Jump(ic, RelocInfo::CODE_TARGET); | 2761 __ Jump(ic, RelocInfo::CODE_TARGET); |
| 2791 | 2762 |
| 2792 // Return the generated code. | 2763 // Return the generated code. |
| 2793 return GetCode(Code::CALLBACKS, name); | 2764 return GetCode(Code::CALLBACKS, name); |
| 2794 } | 2765 } |
| 2795 | 2766 |
| 2796 | 2767 |
| (...skipping 2018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4815 __ Jump(ic_slow, RelocInfo::CODE_TARGET); | 4786 __ Jump(ic_slow, RelocInfo::CODE_TARGET); |
| 4816 } | 4787 } |
| 4817 } | 4788 } |
| 4818 | 4789 |
| 4819 | 4790 |
| 4820 #undef __ | 4791 #undef __ |
| 4821 | 4792 |
| 4822 } } // namespace v8::internal | 4793 } } // namespace v8::internal |
| 4823 | 4794 |
| 4824 #endif // V8_TARGET_ARCH_MIPS | 4795 #endif // V8_TARGET_ARCH_MIPS |
| OLD | NEW |