| 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 838 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 849 __ jmp(true_label_); | 849 __ jmp(true_label_); |
| 850 break; | 850 break; |
| 851 } | 851 } |
| 852 } | 852 } |
| 853 } | 853 } |
| 854 | 854 |
| 855 | 855 |
| 856 void FastCodeGenerator::EmitVariableAssignment(Assignment* expr) { | 856 void FastCodeGenerator::EmitVariableAssignment(Assignment* expr) { |
| 857 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); | 857 Variable* var = expr->target()->AsVariableProxy()->AsVariable(); |
| 858 ASSERT(var != NULL); | 858 ASSERT(var != NULL); |
| 859 | 859 ASSERT(var->is_global() || var->slot() != NULL); |
| 860 if (var->is_global()) { | 860 if (var->is_global()) { |
| 861 // Assignment to a global variable. Use inline caching for the | 861 // Assignment to a global variable. Use inline caching for the |
| 862 // assignment. Right-hand-side value is passed in rax, variable name in | 862 // assignment. Right-hand-side value is passed in rax, variable name in |
| 863 // rcx, and the global object on the stack. | 863 // rcx, and the global object on the stack. |
| 864 __ pop(rax); | 864 __ pop(rax); |
| 865 __ Move(rcx, var->name()); | 865 __ Move(rcx, var->name()); |
| 866 __ push(CodeGenerator::GlobalObject()); | 866 __ push(CodeGenerator::GlobalObject()); |
| 867 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 867 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 868 __ Call(ic, RelocInfo::CODE_TARGET); | 868 __ Call(ic, RelocInfo::CODE_TARGET); |
| 869 // Overwrite the global object on the stack with the result if needed. | 869 // Overwrite the global object on the stack with the result if needed. |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 954 expr->context() != Expression::kValue) { | 954 expr->context() != Expression::kValue) { |
| 955 Move(expr->context(), rdx); | 955 Move(expr->context(), rdx); |
| 956 } | 956 } |
| 957 break; | 957 break; |
| 958 } | 958 } |
| 959 | 959 |
| 960 case Slot::LOOKUP: | 960 case Slot::LOOKUP: |
| 961 UNREACHABLE(); | 961 UNREACHABLE(); |
| 962 break; | 962 break; |
| 963 } | 963 } |
| 964 } else { | |
| 965 Property* property = var->AsProperty(); | |
| 966 ASSERT_NOT_NULL(property); | |
| 967 // A variable has been rewritten into a property on an object. | |
| 968 | |
| 969 // Load object and key onto the stack. | |
| 970 Slot* object_slot = property->obj()->AsSlot(); | |
| 971 ASSERT_NOT_NULL(object_slot); | |
| 972 Move(Expression::kValue, object_slot, rax); | |
| 973 | |
| 974 Literal* key_literal = property->key()->AsLiteral(); | |
| 975 ASSERT_NOT_NULL(key_literal); | |
| 976 Move(Expression::kValue, key_literal); | |
| 977 | |
| 978 // Value to store was pushed before object and key on the stack. | |
| 979 __ movq(rax, Operand(rsp, 2 * kPointerSize)); | |
| 980 | |
| 981 // Arguments to ic is value in rax, object and key on stack. | |
| 982 Handle<Code> ic(Builtins::builtin(Builtins::KeyedStoreIC_Initialize)); | |
| 983 __ call(ic, RelocInfo::CODE_TARGET); | |
| 984 | |
| 985 if (expr->context() == Expression::kEffect) { | |
| 986 __ addq(rsp, Immediate(3 * kPointerSize)); | |
| 987 } else if (expr->context() == Expression::kValue) { | |
| 988 // Value is still on the stack in rsp[2 * kPointerSize] | |
| 989 __ addq(rsp, Immediate(2 * kPointerSize)); | |
| 990 } else { | |
| 991 __ movq(rax, Operand(rsp, 2 * kPointerSize)); | |
| 992 DropAndMove(expr->context(), rax, 3); | |
| 993 } | |
| 994 } | 964 } |
| 995 } | 965 } |
| 996 | 966 |
| 997 | 967 |
| 998 void FastCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { | 968 void FastCodeGenerator::EmitNamedPropertyAssignment(Assignment* expr) { |
| 999 // Assignment to a property, using a named store IC. | 969 // Assignment to a property, using a named store IC. |
| 1000 Property* prop = expr->target()->AsProperty(); | 970 Property* prop = expr->target()->AsProperty(); |
| 1001 ASSERT(prop != NULL); | 971 ASSERT(prop != NULL); |
| 1002 ASSERT(prop->key()->AsLiteral() != NULL); | 972 ASSERT(prop->key()->AsLiteral() != NULL); |
| 1003 | 973 |
| (...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1681 true_label_ = saved_true; | 1651 true_label_ = saved_true; |
| 1682 false_label_ = saved_false; | 1652 false_label_ = saved_false; |
| 1683 // Convert current context to test context: End post-test code. | 1653 // Convert current context to test context: End post-test code. |
| 1684 } | 1654 } |
| 1685 | 1655 |
| 1686 | 1656 |
| 1687 #undef __ | 1657 #undef __ |
| 1688 | 1658 |
| 1689 | 1659 |
| 1690 } } // namespace v8::internal | 1660 } } // namespace v8::internal |
| OLD | NEW |