Chromium Code Reviews| 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 1165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1176 __ mov(ecx, FieldOperand(ebx, i + kPointerSize)); | 1176 __ mov(ecx, FieldOperand(ebx, i + kPointerSize)); |
| 1177 __ mov(FieldOperand(eax, i), edx); | 1177 __ mov(FieldOperand(eax, i), edx); |
| 1178 __ mov(FieldOperand(eax, i + kPointerSize), ecx); | 1178 __ mov(FieldOperand(eax, i + kPointerSize), ecx); |
| 1179 } | 1179 } |
| 1180 if ((size % (2 * kPointerSize)) != 0) { | 1180 if ((size % (2 * kPointerSize)) != 0) { |
| 1181 __ mov(edx, FieldOperand(ebx, size - kPointerSize)); | 1181 __ mov(edx, FieldOperand(ebx, size - kPointerSize)); |
| 1182 __ mov(FieldOperand(eax, size - kPointerSize), edx); | 1182 __ mov(FieldOperand(eax, size - kPointerSize), edx); |
| 1183 } | 1183 } |
| 1184 context()->Plug(eax); | 1184 context()->Plug(eax); |
| 1185 } | 1185 } |
| 1186 | 1186 |
|
Mads Ager (chromium)
2010/10/27 09:28:54
Please add back this line.
| |
| 1187 | |
| 1188 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { | 1187 void FullCodeGenerator::VisitObjectLiteral(ObjectLiteral* expr) { |
| 1189 Comment cmnt(masm_, "[ ObjectLiteral"); | 1188 Comment cmnt(masm_, "[ ObjectLiteral"); |
| 1190 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); | 1189 __ mov(edi, Operand(ebp, JavaScriptFrameConstants::kFunctionOffset)); |
| 1191 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); | 1190 __ push(FieldOperand(edi, JSFunction::kLiteralsOffset)); |
| 1192 __ push(Immediate(Smi::FromInt(expr->literal_index()))); | 1191 __ push(Immediate(Smi::FromInt(expr->literal_index()))); |
| 1193 __ push(Immediate(expr->constant_properties())); | 1192 __ push(Immediate(expr->constant_properties())); |
| 1194 __ push(Immediate(Smi::FromInt(expr->fast_elements() ? 1 : 0))); | 1193 __ push(Immediate(Smi::FromInt(expr->fast_elements() ? 1 : 0))); |
| 1195 if (expr->depth() > 1) { | 1194 if (expr->depth() > 1) { |
| 1196 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); | 1195 __ CallRuntime(Runtime::kCreateObjectLiteral, 4); |
| 1197 } else { | 1196 } else { |
| 1198 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); | 1197 __ CallRuntime(Runtime::kCreateObjectLiteralShallow, 4); |
| 1199 } | 1198 } |
| 1200 | 1199 |
| 1201 // If result_saved is true the result is on top of the stack. If | 1200 // If result_saved is true the result is on top of the stack. If |
| 1202 // result_saved is false the result is in eax. | 1201 // result_saved is false the result is in eax. |
| 1203 bool result_saved = false; | 1202 bool result_saved = false; |
| 1204 | 1203 |
| 1204 // Mark all computed expressions that are bound to a key that | |
| 1205 // is shadowed by a later occurrence of the same key. For the | |
| 1206 // marked expressions, no store code is emitted. | |
| 1207 expr->CalculateEmitStore(); | |
| 1208 | |
| 1205 for (int i = 0; i < expr->properties()->length(); i++) { | 1209 for (int i = 0; i < expr->properties()->length(); i++) { |
| 1206 ObjectLiteral::Property* property = expr->properties()->at(i); | 1210 ObjectLiteral::Property* property = expr->properties()->at(i); |
| 1207 if (property->IsCompileTimeValue()) continue; | 1211 if (property->IsCompileTimeValue()) continue; |
| 1208 | 1212 |
| 1209 Literal* key = property->key(); | 1213 Literal* key = property->key(); |
| 1210 Expression* value = property->value(); | 1214 Expression* value = property->value(); |
| 1211 if (!result_saved) { | 1215 if (!result_saved) { |
| 1212 __ push(eax); // Save result on the stack | 1216 __ push(eax); // Save result on the stack |
| 1213 result_saved = true; | 1217 result_saved = true; |
| 1214 } | 1218 } |
| 1215 switch (property->kind()) { | 1219 switch (property->kind()) { |
| 1216 case ObjectLiteral::Property::MATERIALIZED_LITERAL: | 1220 case ObjectLiteral::Property::MATERIALIZED_LITERAL: |
| 1217 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); | 1221 ASSERT(!CompileTimeValue::IsCompileTimeValue(value)); |
| 1218 // Fall through. | 1222 // Fall through. |
| 1219 case ObjectLiteral::Property::COMPUTED: | 1223 case ObjectLiteral::Property::COMPUTED: |
| 1220 if (key->handle()->IsSymbol()) { | 1224 if (key->handle()->IsSymbol()) { |
| 1221 VisitForAccumulatorValue(value); | 1225 VisitForAccumulatorValue(value); |
| 1222 __ mov(ecx, Immediate(key->handle())); | 1226 __ mov(ecx, Immediate(key->handle())); |
| 1223 __ mov(edx, Operand(esp, 0)); | 1227 __ mov(edx, Operand(esp, 0)); |
| 1224 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); | 1228 if (property->emit_store()) { |
| 1225 EmitCallIC(ic, RelocInfo::CODE_TARGET); | 1229 Handle<Code> ic(Builtins::builtin(Builtins::StoreIC_Initialize)); |
| 1230 EmitCallIC(ic, RelocInfo::CODE_TARGET); | |
| 1231 } | |
| 1226 break; | 1232 break; |
| 1227 } | 1233 } |
| 1228 // Fall through. | 1234 // Fall through. |
| 1229 case ObjectLiteral::Property::PROTOTYPE: | 1235 case ObjectLiteral::Property::PROTOTYPE: |
| 1230 __ push(Operand(esp, 0)); // Duplicate receiver. | 1236 __ push(Operand(esp, 0)); // Duplicate receiver. |
| 1231 VisitForStackValue(key); | 1237 VisitForStackValue(key); |
| 1232 VisitForStackValue(value); | 1238 VisitForStackValue(value); |
| 1233 __ CallRuntime(Runtime::kSetProperty, 3); | 1239 if (property->emit_store()) { |
| 1240 __ CallRuntime(Runtime::kSetProperty, 3); | |
| 1241 } else { | |
| 1242 __ Drop(3); | |
| 1243 } | |
| 1234 break; | 1244 break; |
| 1235 case ObjectLiteral::Property::SETTER: | 1245 case ObjectLiteral::Property::SETTER: |
| 1236 case ObjectLiteral::Property::GETTER: | 1246 case ObjectLiteral::Property::GETTER: |
| 1237 __ push(Operand(esp, 0)); // Duplicate receiver. | 1247 __ push(Operand(esp, 0)); // Duplicate receiver. |
| 1238 VisitForStackValue(key); | 1248 VisitForStackValue(key); |
| 1239 __ push(Immediate(property->kind() == ObjectLiteral::Property::SETTER ? | 1249 __ push(Immediate(property->kind() == ObjectLiteral::Property::SETTER ? |
| 1240 Smi::FromInt(1) : | 1250 Smi::FromInt(1) : |
| 1241 Smi::FromInt(0))); | 1251 Smi::FromInt(0))); |
| 1242 VisitForStackValue(value); | 1252 VisitForStackValue(value); |
| 1243 __ CallRuntime(Runtime::kDefineAccessor, 4); | 1253 __ CallRuntime(Runtime::kDefineAccessor, 4); |
| (...skipping 2479 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3723 // And return. | 3733 // And return. |
| 3724 __ ret(0); | 3734 __ ret(0); |
| 3725 } | 3735 } |
| 3726 | 3736 |
| 3727 | 3737 |
| 3728 #undef __ | 3738 #undef __ |
| 3729 | 3739 |
| 3730 } } // namespace v8::internal | 3740 } } // namespace v8::internal |
| 3731 | 3741 |
| 3732 #endif // V8_TARGET_ARCH_IA32 | 3742 #endif // V8_TARGET_ARCH_IA32 |
| OLD | NEW |