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