Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: src/full-codegen/x87/full-codegen-x87.cc

Issue 2547433003: [fullcodegen] Remove non-"static" part in VisitArrayLiteral functions. (Closed)
Patch Set: Simplify bailout id in ObjectLiteral. Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/full-codegen/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #if V8_TARGET_ARCH_X87 5 #if V8_TARGET_ARCH_X87
6 6
7 #include "src/full-codegen/full-codegen.h" 7 #include "src/full-codegen/full-codegen.h"
8 #include "src/ast/compile-time-value.h" 8 #include "src/ast/compile-time-value.h"
9 #include "src/ast/scopes.h" 9 #include "src/ast/scopes.h"
10 #include "src/code-factory.h" 10 #include "src/code-factory.h"
(...skipping 1130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 __ CallStub(&stub); 1141 __ CallStub(&stub);
1142 RestoreContext(); 1142 RestoreContext();
1143 } 1143 }
1144 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER); 1144 PrepareForBailoutForId(expr->CreateLiteralId(), BailoutState::TOS_REGISTER);
1145 1145
1146 // If result_saved is true the result is on top of the stack. If 1146 // If result_saved is true the result is on top of the stack. If
1147 // result_saved is false the result is in eax. 1147 // result_saved is false the result is in eax.
1148 bool result_saved = false; 1148 bool result_saved = false;
1149 1149
1150 AccessorTable accessor_table(zone()); 1150 AccessorTable accessor_table(zone());
1151 int property_index = 0; 1151 for (int i = 0; i < expr->properties()->length(); i++) {
1152 for (; property_index < expr->properties()->length(); property_index++) { 1152 ObjectLiteral::Property* property = expr->properties()->at(i);
1153 ObjectLiteral::Property* property = expr->properties()->at(property_index); 1153 DCHECK(!property->is_computed_name());
1154 if (property->is_computed_name()) break;
1155 if (property->IsCompileTimeValue()) continue; 1154 if (property->IsCompileTimeValue()) continue;
1156 1155
1157 Literal* key = property->key()->AsLiteral(); 1156 Literal* key = property->key()->AsLiteral();
1158 Expression* value = property->value(); 1157 Expression* value = property->value();
1159 if (!result_saved) { 1158 if (!result_saved) {
1160 PushOperand(eax); // Save result on the stack 1159 PushOperand(eax); // Save result on the stack
1161 result_saved = true; 1160 result_saved = true;
1162 } 1161 }
1163 switch (property->kind()) { 1162 switch (property->kind()) {
1164 case ObjectLiteral::Property::CONSTANT: 1163 case ObjectLiteral::Property::CONSTANT:
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1196 CallRuntimeWithOperands(Runtime::kSetProperty); 1195 CallRuntimeWithOperands(Runtime::kSetProperty);
1197 } else { 1196 } else {
1198 DropOperands(3); 1197 DropOperands(3);
1199 } 1198 }
1200 break; 1199 break;
1201 case ObjectLiteral::Property::PROTOTYPE: 1200 case ObjectLiteral::Property::PROTOTYPE:
1202 PushOperand(Operand(esp, 0)); // Duplicate receiver. 1201 PushOperand(Operand(esp, 0)); // Duplicate receiver.
1203 VisitForStackValue(value); 1202 VisitForStackValue(value);
1204 DCHECK(property->emit_store()); 1203 DCHECK(property->emit_store());
1205 CallRuntimeWithOperands(Runtime::kInternalSetPrototype); 1204 CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
1206 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index), 1205 PrepareForBailoutForId(expr->GetIdForPropertySet(i),
1207 BailoutState::NO_REGISTERS); 1206 BailoutState::NO_REGISTERS);
1208 break; 1207 break;
1209 case ObjectLiteral::Property::GETTER: 1208 case ObjectLiteral::Property::GETTER:
1210 if (property->emit_store()) { 1209 if (property->emit_store()) {
1211 AccessorTable::Iterator it = accessor_table.lookup(key); 1210 AccessorTable::Iterator it = accessor_table.lookup(key);
1212 it->second->bailout_id = expr->GetIdForPropertySet(property_index); 1211 it->second->bailout_id = expr->GetIdForPropertySet(i);
1213 it->second->getter = property; 1212 it->second->getter = property;
1214 } 1213 }
1215 break; 1214 break;
1216 case ObjectLiteral::Property::SETTER: 1215 case ObjectLiteral::Property::SETTER:
1217 if (property->emit_store()) { 1216 if (property->emit_store()) {
1218 AccessorTable::Iterator it = accessor_table.lookup(key); 1217 AccessorTable::Iterator it = accessor_table.lookup(key);
1219 it->second->bailout_id = expr->GetIdForPropertySet(property_index); 1218 it->second->bailout_id = expr->GetIdForPropertySet(i);
1220 it->second->setter = property; 1219 it->second->setter = property;
1221 } 1220 }
1222 break; 1221 break;
1223 } 1222 }
1224 } 1223 }
1225 1224
1226 // Emit code to define accessors, using only a single call to the runtime for 1225 // Emit code to define accessors, using only a single call to the runtime for
1227 // each pair of corresponding getters and setters. 1226 // each pair of corresponding getters and setters.
1228 for (AccessorTable::Iterator it = accessor_table.begin(); 1227 for (AccessorTable::Iterator it = accessor_table.begin();
1229 it != accessor_table.end(); 1228 it != accessor_table.end();
1230 ++it) { 1229 ++it) {
1231 PushOperand(Operand(esp, 0)); // Duplicate receiver. 1230 PushOperand(Operand(esp, 0)); // Duplicate receiver.
1232 VisitForStackValue(it->first); 1231 VisitForStackValue(it->first);
1233 1232
1234 EmitAccessor(it->second->getter); 1233 EmitAccessor(it->second->getter);
1235 EmitAccessor(it->second->setter); 1234 EmitAccessor(it->second->setter);
1236 1235
1237 PushOperand(Smi::FromInt(NONE)); 1236 PushOperand(Smi::FromInt(NONE));
1238 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked); 1237 CallRuntimeWithOperands(Runtime::kDefineAccessorPropertyUnchecked);
1239 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS); 1238 PrepareForBailoutForId(it->second->bailout_id, BailoutState::NO_REGISTERS);
1240 } 1239 }
1241 1240
1242 // Object literals have two parts. The "static" part on the left contains no
1243 // computed property names, and so we can compute its map ahead of time; see
1244 // runtime.cc::CreateObjectLiteralBoilerplate. The second "dynamic" part
1245 // starts with the first computed property name, and continues with all
1246 // properties to its right. All the code from above initializes the static
1247 // component of the object literal, and arranges for the map of the result to
1248 // reflect the static order in which the keys appear. For the dynamic
1249 // properties, we compile them into a series of "SetOwnProperty" runtime
1250 // calls. This will preserve insertion order.
1251 for (; property_index < expr->properties()->length(); property_index++) {
1252 ObjectLiteral::Property* property = expr->properties()->at(property_index);
1253
1254 Expression* value = property->value();
1255 if (!result_saved) {
1256 PushOperand(eax); // Save result on the stack
1257 result_saved = true;
1258 }
1259
1260 PushOperand(Operand(esp, 0)); // Duplicate receiver.
1261
1262 if (property->kind() == ObjectLiteral::Property::PROTOTYPE) {
1263 DCHECK(!property->is_computed_name());
1264 VisitForStackValue(value);
1265 DCHECK(property->emit_store());
1266 CallRuntimeWithOperands(Runtime::kInternalSetPrototype);
1267 PrepareForBailoutForId(expr->GetIdForPropertySet(property_index),
1268 BailoutState::NO_REGISTERS);
1269 } else {
1270 EmitPropertyKey(property, expr->GetIdForPropertyName(property_index));
1271 VisitForStackValue(value);
1272 if (NeedsHomeObject(value)) {
1273 EmitSetHomeObject(value, 2, property->GetSlot());
1274 }
1275
1276 switch (property->kind()) {
1277 case ObjectLiteral::Property::CONSTANT:
1278 case ObjectLiteral::Property::MATERIALIZED_LITERAL:
1279 case ObjectLiteral::Property::COMPUTED:
1280 case ObjectLiteral::Property::PROTOTYPE:
1281 UNREACHABLE();
1282 break;
1283
1284 case ObjectLiteral::Property::GETTER:
1285 PushOperand(Smi::FromInt(NONE));
1286 CallRuntimeWithOperands(Runtime::kDefineGetterPropertyUnchecked);
1287 break;
1288
1289 case ObjectLiteral::Property::SETTER:
1290 PushOperand(Smi::FromInt(NONE));
1291 CallRuntimeWithOperands(Runtime::kDefineSetterPropertyUnchecked);
1292 break;
1293 }
1294 }
1295 }
1296
1297 if (result_saved) { 1241 if (result_saved) {
1298 context()->PlugTOS(); 1242 context()->PlugTOS();
1299 } else { 1243 } else {
1300 context()->Plug(eax); 1244 context()->Plug(eax);
1301 } 1245 }
1302 } 1246 }
1303 1247
1304 1248
1305 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) { 1249 void FullCodeGenerator::VisitArrayLiteral(ArrayLiteral* expr) {
1306 Comment cmnt(masm_, "[ ArrayLiteral"); 1250 Comment cmnt(masm_, "[ ArrayLiteral");
(...skipping 1736 matching lines...) Expand 10 before | Expand all | Expand 10 after
3043 isolate->builtins()->OnStackReplacement()->entry(), 2987 isolate->builtins()->OnStackReplacement()->entry(),
3044 Assembler::target_address_at(call_target_address, unoptimized_code)); 2988 Assembler::target_address_at(call_target_address, unoptimized_code));
3045 return ON_STACK_REPLACEMENT; 2989 return ON_STACK_REPLACEMENT;
3046 } 2990 }
3047 2991
3048 2992
3049 } // namespace internal 2993 } // namespace internal
3050 } // namespace v8 2994 } // namespace v8
3051 2995
3052 #endif // V8_TARGET_ARCH_X87 2996 #endif // V8_TARGET_ARCH_X87
OLDNEW
« no previous file with comments | « src/full-codegen/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698