OLD | NEW |
1 // Copyright 2009 the V8 project authors. All rights reserved. | 1 // Copyright 2009 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 3852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3863 __ movq(temp.reg(), SlotOperand(slot, temp.reg())); | 3863 __ movq(temp.reg(), SlotOperand(slot, temp.reg())); |
3864 frame_->Push(&temp); | 3864 frame_->Push(&temp); |
3865 } | 3865 } |
3866 } | 3866 } |
3867 | 3867 |
3868 | 3868 |
3869 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { | 3869 void CodeGenerator::StoreToSlot(Slot* slot, InitState init_state) { |
3870 // TODO(X64): Enable more types of slot. | 3870 // TODO(X64): Enable more types of slot. |
3871 | 3871 |
3872 if (slot->type() == Slot::LOOKUP) { | 3872 if (slot->type() == Slot::LOOKUP) { |
3873 UNIMPLEMENTED(); | |
3874 /* | |
3875 ASSERT(slot->var()->is_dynamic()); | 3873 ASSERT(slot->var()->is_dynamic()); |
3876 | 3874 |
3877 // For now, just do a runtime call. Since the call is inevitable, | 3875 // For now, just do a runtime call. Since the call is inevitable, |
3878 // we eagerly sync the virtual frame so we can directly push the | 3876 // we eagerly sync the virtual frame so we can directly push the |
3879 // arguments into place. | 3877 // arguments into place. |
3880 frame_->SyncRange(0, frame_->element_count() - 1); | 3878 frame_->SyncRange(0, frame_->element_count() - 1); |
3881 | 3879 |
3882 frame_->EmitPush(esi); | 3880 frame_->EmitPush(rsi); |
3883 frame_->EmitPush(Immediate(slot->var()->name())); | 3881 frame_->EmitPush(slot->var()->name()); |
3884 | 3882 |
3885 Result value; | 3883 Result value; |
3886 if (init_state == CONST_INIT) { | 3884 if (init_state == CONST_INIT) { |
3887 // Same as the case for a normal store, but ignores attribute | 3885 // Same as the case for a normal store, but ignores attribute |
3888 // (e.g. READ_ONLY) of context slot so that we can initialize const | 3886 // (e.g. READ_ONLY) of context slot so that we can initialize const |
3889 // properties (introduced via eval("const foo = (some expr);")). Also, | 3887 // properties (introduced via eval("const foo = (some expr);")). Also, |
3890 // uses the current function context instead of the top context. | 3888 // uses the current function context instead of the top context. |
3891 // | 3889 // |
3892 // Note that we must declare the foo upon entry of eval(), via a | 3890 // Note that we must declare the foo upon entry of eval(), via a |
3893 // context slot declaration, but we cannot initialize it at the same | 3891 // context slot declaration, but we cannot initialize it at the same |
3894 // time, because the const declaration may be at the end of the eval | 3892 // time, because the const declaration may be at the end of the eval |
3895 // code (sigh...) and the const variable may have been used before | 3893 // code (sigh...) and the const variable may have been used before |
3896 // (where its value is 'undefined'). Thus, we can only do the | 3894 // (where its value is 'undefined'). Thus, we can only do the |
3897 // initialization when we actually encounter the expression and when | 3895 // initialization when we actually encounter the expression and when |
3898 // the expression operands are defined and valid, and thus we need the | 3896 // the expression operands are defined and valid, and thus we need the |
3899 // split into 2 operations: declaration of the context slot followed | 3897 // split into 2 operations: declaration of the context slot followed |
3900 // by initialization. | 3898 // by initialization. |
3901 value = frame_->CallRuntime(Runtime::kInitializeConstContextSlot, 3); | 3899 value = frame_->CallRuntime(Runtime::kInitializeConstContextSlot, 3); |
3902 } else { | 3900 } else { |
3903 value = frame_->CallRuntime(Runtime::kStoreContextSlot, 3); | 3901 value = frame_->CallRuntime(Runtime::kStoreContextSlot, 3); |
3904 } | 3902 } |
3905 // Storing a variable must keep the (new) value on the expression | 3903 // Storing a variable must keep the (new) value on the expression |
3906 // stack. This is necessary for compiling chained assignment | 3904 // stack. This is necessary for compiling chained assignment |
3907 // expressions. | 3905 // expressions. |
3908 frame_->Push(&value); | 3906 frame_->Push(&value); |
3909 */ | |
3910 } else { | 3907 } else { |
3911 ASSERT(!slot->var()->is_dynamic()); | 3908 ASSERT(!slot->var()->is_dynamic()); |
3912 | 3909 |
3913 JumpTarget exit; | 3910 JumpTarget exit; |
3914 if (init_state == CONST_INIT) { | 3911 if (init_state == CONST_INIT) { |
3915 ASSERT(slot->var()->mode() == Variable::CONST); | 3912 ASSERT(slot->var()->mode() == Variable::CONST); |
3916 // Only the first const initialization must be executed (the slot | 3913 // Only the first const initialization must be executed (the slot |
3917 // still contains 'the hole' value). When the assignment is executed, | 3914 // still contains 'the hole' value). When the assignment is executed, |
3918 // the code is identical to a normal store (see below). | 3915 // the code is identical to a normal store (see below). |
3919 // | 3916 // |
(...skipping 2836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6756 break; | 6753 break; |
6757 default: | 6754 default: |
6758 UNREACHABLE(); | 6755 UNREACHABLE(); |
6759 } | 6756 } |
6760 } | 6757 } |
6761 | 6758 |
6762 | 6759 |
6763 #undef __ | 6760 #undef __ |
6764 | 6761 |
6765 } } // namespace v8::internal | 6762 } } // namespace v8::internal |
OLD | NEW |