| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1151 if (expr->depth() > 1) { | 1151 if (expr->depth() > 1) { |
| 1152 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1152 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1153 } else { | 1153 } else { |
| 1154 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); | 1154 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 // If result_saved is true the result is on top of the stack. If | 1157 // If result_saved is true the result is on top of the stack. If |
| 1158 // result_saved is false the result is in rax. | 1158 // result_saved is false the result is in rax. |
| 1159 bool result_saved = false; | 1159 bool result_saved = false; |
| 1160 | 1160 |
| 1161 // Mark all computed expressions that are bound to a key that |
| 1162 // is shadowed by a later occurrence of the same key. For the |
| 1163 // marked expressions, no store code is emitted. |
| 1164 expr->CalculateEmitStore(); |
| 1165 |
| 1161 for (int i = 0; i < expr->properties()->length(); i++) { | 1166 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1162 ObjectLiteral::Property* property = expr->properties()->at(i); | 1167 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1163 if (property->IsCompileTimeValue()) continue; | 1168 if (property->IsCompileTimeValue()) continue; |
| 1164 | 1169 |
| 1165 Literal* key = property->key(); | 1170 Literal* key = property->key(); |
| 1166 Expression* value = property->value(); | 1171 Expression* value = property->value(); |
| 1167 if (!result_saved) { | 1172 if (!result_saved) { |
| 1168 __ push(rax); // Save result on the stack | 1173 __ push(rax); // Save result on the stack |
| 1169 result_saved = true; | 1174 result_saved = true; |
| 1170 } | 1175 } |
| 1171 switch (property->kind()) { | 1176 switch (property->kind()) { |
| 1172 case ObjectLiteral::Property::CONSTANT: | 1177 case ObjectLiteral::Property::CONSTANT: |
| 1173 UNREACHABLE(); | 1178 UNREACHABLE(); |
| 1174 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1179 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1175 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1180 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
| 1176 // Fall through. | 1181 // Fall through. |
| 1177 case ObjectLiteral::Property::COMPUTED: | 1182 case ObjectLiteral::Property::COMPUTED: |
| 1178 if (key->handle()->IsSymbol()) { | 1183 if (key->handle()->IsSymbol()) { |
| 1179 VisitForAccumulatorValue(value); | 1184 VisitForAccumulatorValue(value); |
| 1180 __ Move(rcx, key->handle()); | 1185 __ Move(rcx, key->handle()); |
| 1181 __ movq(rdx, Operand(rsp, 0)); | 1186 __ movq(rdx, Operand(rsp, 0)); |
| 1182 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 1187 if (property->emit_store()) { |
| 1183 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1188 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 1189 EmitCallIC(ic, RelocInfo::CODE_TARGET); |
| 1190 } |
| 1184 break; | 1191 break; |
| 1185 } | 1192 } |
| 1186 // Fall through. | 1193 // Fall through. |
| 1187 case ObjectLiteral::Property::PROTOTYPE: | 1194 case ObjectLiteral::Property::PROTOTYPE: |
| 1188 __ push(Operand(rsp, 0)); // Duplicate receiver. | 1195 __ push(Operand(rsp, 0)); // Duplicate receiver. |
| 1189 VisitForStackValue(key); | 1196 VisitForStackValue(key); |
| 1190 VisitForStackValue(value); | 1197 VisitForStackValue(value); |
| 1191 __ CallRuntime(Runtime::kSetProperty, 3); | 1198 if (property->emit_store()) { |
| 1199 __ CallRuntime(Runtime::kSetProperty, 3); |
| 1200 } else { |
| 1201 __ Drop(3); |
| 1202 } |
| 1192 break; | 1203 break; |
| 1193 case ObjectLiteral::Property::SETTER: | 1204 case ObjectLiteral::Property::SETTER: |
| 1194 case ObjectLiteral::Property::GETTER: | 1205 case ObjectLiteral::Property::GETTER: |
| 1195 __ push(Operand(rsp, 0)); // Duplicate receiver. | 1206 __ push(Operand(rsp, 0)); // Duplicate receiver. |
| 1196 VisitForStackValue(key); | 1207 VisitForStackValue(key); |
| 1197 __ Push(property->kind() == ObjectLiteral::Property::SETTER ? | 1208 __ Push(property->kind() == ObjectLiteral::Property::SETTER ? |
| 1198 Smi::FromInt(1) : | 1209 Smi::FromInt(1) : |
| 1199 Smi::FromInt(0)); | 1210 Smi::FromInt(0)); |
| 1200 VisitForStackValue(value); | 1211 VisitForStackValue(value); |
| 1201 __ CallRuntime(Runtime::kDefineAccessor, 4); | 1212 __ CallRuntime(Runtime::kDefineAccessor, 4); |
| (...skipping 2223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3425 __ ret(0); | 3436 __ ret(0); |
| 3426 } | 3437 } |
| 3427 | 3438 |
| 3428 | 3439 |
| 3429 #undef __ | 3440 #undef __ |
| 3430 | 3441 |
| 3431 | 3442 |
| 3432 } } // namespace v8::internal | 3443 } } // namespace v8::internal |
| 3433 | 3444 |
| 3434 #endif // V8_TARGET_ARCH_X64 | 3445 #endif // V8_TARGET_ARCH_X64 |
| OLD | NEW |